@byloth/vuert
Advanced tools
Comparing version 1.2.2-rc.1 to 1.2.2-rc.2
@@ -12,3 +12,3 @@ import { ref as T, computed as D, getCurrentScope as j, inject as A, defineComponent as C, shallowRef as N, onMounted as V, onUnmounted as k, openBlock as F, createBlock as I, resolveDynamicComponent as U, withCtx as $, renderSlot as E, createCommentVNode as R, nextTick as P } from "vue"; | ||
class l { | ||
constructor(e, i) { | ||
constructor(e, s) { | ||
var r; | ||
@@ -27,6 +27,6 @@ if (this.id = e.id ?? Symbol(), this.type = e.type ?? "info", this.priority = e.priority ?? "normal", this.icon = e.icon, this.title = e.title, e.message !== void 0 && e.component !== void 0) | ||
static Resolved(e) { | ||
const i = new h(e, 0); | ||
return i.resolve(), i; | ||
const s = new h(e, 0); | ||
return s.resolve(), s; | ||
} | ||
constructor(e, i) { | ||
constructor(e, s) { | ||
const r = async () => { | ||
@@ -39,9 +39,9 @@ if (!this._isOpen.value) | ||
}; | ||
if (super(o, c), typeof i == "object") | ||
if (super(o, c), typeof s == "object") | ||
this._duration = { | ||
enter: Number(i.enter), | ||
leave: Number(i.leave) | ||
enter: Number(s.enter), | ||
leave: Number(s.leave) | ||
}; | ||
else { | ||
const n = Number(i); | ||
const n = Number(s); | ||
this._duration = { | ||
@@ -84,5 +84,7 @@ enter: n, | ||
constructor(e) { | ||
this._subscribers = [], this._throttlers = /* @__PURE__ */ new Map(), this._options = { ...u.DEFAULT_OPTS, ...e }, this._options.useThrottling ? this._throttle = (i) => { | ||
const r = Date.now(), o = this._throttlers.get(i) ?? 0; | ||
return r - o > this._options.throttleDuration ? (this._throttlers.set(i, r), !1) : !0; | ||
this._subscribers = [], this._throttlers = /* @__PURE__ */ new Map(), this._options = { ...u.DEFAULT_OPTS, ...e }, this._options.useThrottling ? this._throttle = (s) => { | ||
if (!s.id) | ||
return !1; | ||
const r = Date.now(), o = this._throttlers.get(s.id) ?? 0; | ||
return r - o > this._options.throttleDuration ? (this._throttlers.set(s.id, r), !1) : !0; | ||
} : this._throttle = () => !1; | ||
@@ -102,8 +104,8 @@ } | ||
return this._subscribers.push(e), () => { | ||
const i = this._subscribers.indexOf(e); | ||
return this._subscribers.splice(i, 1)[0]; | ||
const s = this._subscribers.indexOf(e); | ||
return this._subscribers.splice(s, 1)[0]; | ||
}; | ||
} | ||
}; | ||
u.VERSION = "1.2.2-rc.1"; | ||
u.VERSION = "1.2.2-rc.2"; | ||
let p = u, S; | ||
@@ -113,5 +115,5 @@ const H = (t) => { | ||
}, L = () => j() ? A(g.$vuert) : S, z = (t) => ({ | ||
install: ({ config: e, provide: i }) => { | ||
install: ({ config: e, provide: s }) => { | ||
const r = new p(t); | ||
H(r), e.globalProperties.$vuert = r, i(g.$vuert, r); | ||
H(r), e.globalProperties.$vuert = r, s(g.$vuert, r); | ||
} | ||
@@ -149,9 +151,9 @@ }), w = () => { | ||
setup(t, { emit: e }) { | ||
const i = w(), r = t, o = e, c = [], n = N(), O = () => new Promise((s) => P(s)), m = async () => { | ||
const s = c[0]; | ||
s.onOpening(() => o("opening", s.alert)), s.onOpened(() => o("opened", s.alert)), s.onClosing(() => o("closing", s.alert)), s.onClosed(async () => { | ||
o("closed", s.alert), c.shift(), n.value = void 0, await O(), c.length > 0 && m(); | ||
}), n.value = s, await s.open(); | ||
}, x = (s) => { | ||
const d = new h(s, r.duration); | ||
const s = w(), r = t, o = e, c = [], n = N(), O = () => new Promise((i) => P(i)), m = async () => { | ||
const i = c[0]; | ||
i.onOpening(() => o("opening", i.alert)), i.onOpened(() => o("opened", i.alert)), i.onClosing(() => o("closing", i.alert)), i.onClosed(async () => { | ||
o("closed", i.alert), c.shift(), n.value = void 0, await O(), c.length > 0 && m(); | ||
}), n.value = i, await i.open(); | ||
}, x = (i) => { | ||
const d = new h(i, r.duration); | ||
return c.push(d), c.length === 1 && m(), d; | ||
@@ -161,9 +163,9 @@ }; | ||
return V(() => { | ||
f = i.subscribe((s) => { | ||
if (r.filter(s)) | ||
return x(s); | ||
f = s.subscribe((i) => { | ||
if (r.filter(i)) | ||
return x(i); | ||
}); | ||
}), k(() => f()), (s, d) => (F(), I(U(t.is), null, { | ||
}), k(() => f()), (i, d) => (F(), I(U(t.is), null, { | ||
default: $(() => [ | ||
n.value ? E(s.$slots, "default", { | ||
n.value ? E(i.$slots, "default", { | ||
key: 0, | ||
@@ -170,0 +172,0 @@ alert: n.value.alert, |
{ | ||
"name": "@byloth/vuert", | ||
"version": "1.2.2-rc.1", | ||
"version": "1.2.2-rc.2", | ||
"description": "The headless alerts, notifications & popups library for Vue.js craftsmen. ℹ", | ||
@@ -72,3 +72,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "dd5776f2d2f180272f832f440c285ea02392b4ce" | ||
"gitHead": "7946297c0d91e7d129c87cc9f3c076452a512d40" | ||
} |
@@ -22,3 +22,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
{ | ||
public static readonly VERSION: string = "1.2.2-rc.1"; | ||
public static readonly VERSION: string = "1.2.2-rc.2"; | ||
@@ -35,3 +35,3 @@ public static get DEFAULT_OPTS(): VuertOptions | ||
protected _subscribers: VuertSubscriber<any>[]; | ||
protected _throttlers: Map<AlertOptions<unknown>, number>; | ||
protected _throttlers: Map<symbol, number>; | ||
@@ -57,8 +57,10 @@ protected _options: VuertOptions; | ||
{ | ||
if (!(alert.id)) { return false; } | ||
const now = Date.now(); | ||
const last = this._throttlers.get(alert) ?? 0; | ||
const last = this._throttlers.get(alert.id) ?? 0; | ||
if ((now - last) > this._options.throttleDuration) | ||
{ | ||
this._throttlers.set(alert, now); | ||
this._throttlers.set(alert.id, now); | ||
@@ -65,0 +67,0 @@ return false; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
95455
711