Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@byloth/vuert

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@byloth/vuert - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

195

dist/vuert.js
var N = Object.defineProperty;
var S = (t, e, n) => e in t ? N(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
var r = (t, e, n) => (S(t, typeof e != "symbol" ? e + "" : e, n), n);
import { getCurrentScope as E, inject as I, ref as V, computed as k, nextTick as F, defineComponent as $, shallowRef as D, onMounted as P, onUnmounted as C, openBlock as U, createBlock as H, resolveDynamicComponent as L, withCtx as R, renderSlot as B, createCommentVNode as K } from "vue";
import { RuntimeException as d, handle as _, ValueException as g, FatalErrorException as M } from "@byloth/exceptions";
const x = { $vuert: Symbol("[vuert]: vuert") }, f = class {
var S = (t, e, s) => e in t ? N(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
var i = (t, e, s) => (S(t, typeof e != "symbol" ? e + "" : e, s), s);
import { getCurrentScope as A, inject as I, ref as V, computed as k, nextTick as F, defineComponent as $, shallowRef as E, onMounted as P, onUnmounted as C, openBlock as D, createBlock as U, resolveDynamicComponent as R, withCtx as B, renderSlot as H, createCommentVNode as L } from "vue";
import { RuntimeException as d, ValueException as w, FatalErrorException as K } from "@byloth/exceptions";
const O = { $vuert: Symbol("[vuert]: vuert") }, b = class {
constructor(e) {
r(this, "_subscribers");
r(this, "_options");
this._subscribers = [], this._options = { ...f.DEFAULT_OPTS, ...e };
i(this, "_subscribers");
i(this, "_options");
this._subscribers = [], this._options = { ...b.DEFAULT_OPTS, ...e };
}

@@ -19,35 +19,26 @@ static get DEFAULT_OPTS() {

emit(e) {
const s = this._subscribers.slice().map((i) => i(e)).filter((i) => !!i);
if (!s.length)
const o = this._subscribers.slice().map((n) => n(e)).filter((n) => !!n);
if (!o.length)
throw new d("Unable to handle the emitted alert properly. There wasn't found any supported subscribers.");
return Promise.any(s);
return Promise.any(o);
}
subscribe(e) {
return this._subscribers.push(e), () => {
const n = this._subscribers.indexOf(e);
return this._subscribers.splice(n, 1)[0];
const s = this._subscribers.indexOf(e);
return this._subscribers.splice(s, 1)[0];
};
}
};
let u = f;
r(u, "VERSION", "1.0.3");
let T;
const q = (t) => {
T = t;
}, z = () => E() ? I(x.$vuert) : T, Y = (t) => ({
install: ({ config: e, provide: n }) => {
const a = new u(t);
if (q(a), e.globalProperties.$vuert = a, n(x.$vuert, a), t != null && t.enableErrorsHandling) {
const s = (i) => {
console.error(i), a.emit(t.defaultAlertOptions);
};
e.errorHandler = (i, v, h) => {
_(i, s);
}, window.addEventListener("unhandledrejection", (i) => {
i.preventDefault(), _(i.reason, s);
});
}
let u = b;
i(u, "VERSION", "1.0.4");
let j;
const M = (t) => {
j = t;
}, q = () => A() ? I(O.$vuert) : j, X = (t) => ({
install: ({ config: e, provide: s }) => {
const c = new u(t);
M(c), e.globalProperties.$vuert = c, s(O.$vuert, c);
}
}), O = () => {
const t = z();
}), _ = () => {
const t = q();
if (!t)

@@ -59,9 +50,9 @@ throw new d(

};
class A {
class x {
constructor(e) {
r(this, "id");
r(this, "type");
r(this, "icon");
r(this, "label");
r(this, "callback");
i(this, "id");
i(this, "type");
i(this, "icon");
i(this, "label");
i(this, "callback");
this.id = e.id ?? Symbol(), this.type = e.type ?? "secondary", this.icon = e.icon, this.label = e.label, this.callback = e.callback ?? (() => {

@@ -72,20 +63,20 @@ });

class l {
constructor(e, n) {
r(this, "id");
r(this, "type");
r(this, "priority");
r(this, "icon");
r(this, "title");
r(this, "message");
r(this, "component");
r(this, "props");
r(this, "actions");
r(this, "dismissible");
r(this, "timeout");
var a;
constructor(e, s) {
i(this, "id");
i(this, "type");
i(this, "priority");
i(this, "icon");
i(this, "title");
i(this, "message");
i(this, "component");
i(this, "props");
i(this, "actions");
i(this, "dismissible");
i(this, "timeout");
var c;
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)
throw new g("The `message` and `component` properties cannot both be valued at the same time.");
if (this.message = e.message, this.component = e.component, this.props = e.props, this.actions = ((a = e.actions) == null ? void 0 : a.map((s) => new A(s))) ?? [], this.dismissible = e.dismissible || !1, e.timeout !== void 0) {
throw new w("The `message` and `component` properties cannot both be valued at the same time.");
if (this.message = e.message, this.component = e.component, this.props = e.props, this.actions = ((c = e.actions) == null ? void 0 : c.map((o) => new x(o))) ?? [], this.dismissible = e.dismissible || !1, e.timeout !== void 0) {
if (e.timeout <= 0)
throw new g("The `timeout` property must be a positive integer or -at least- `undefined`.");
throw new w("The `timeout` property must be a positive integer or -at least- `undefined`.");
this.timeout = e.timeout;

@@ -96,12 +87,12 @@ } else

}
class G {
constructor(e, { resolve: n, reject: a }) {
r(this, "_timeoutId");
r(this, "_isOpen");
r(this, "alert");
r(this, "isOpen");
r(this, "resolver");
r(this, "rejecter");
class z {
constructor(e, { resolve: s, reject: c }) {
i(this, "_timeoutId");
i(this, "_isOpen");
i(this, "alert");
i(this, "isOpen");
i(this, "resolver");
i(this, "rejecter");
this.alert = new l(e);
const s = () => {
const o = () => {
if (!this._isOpen.value)

@@ -111,6 +102,6 @@ throw new d("Unable to close the alert. It has already been closed or not even opened.");

};
this.resolver = (i) => {
s(), i instanceof A ? n(i.callback()) : i instanceof Function ? n(i()) : n(i);
}, this.rejecter = (i) => {
s(), a(i);
this.resolver = (n) => {
o(), n instanceof x ? s(n.callback()) : n instanceof Function ? s(n()) : s(n);
}, this.rejecter = (n) => {
o(), c(n);
}, this._isOpen = V(!1), this.isOpen = k(() => this._isOpen.value);

@@ -127,3 +118,3 @@ }

}
const j = (t) => new Promise((e) => setTimeout(e, t)), J = () => new Promise((t) => F(t)), Z = /* @__PURE__ */ $({
const g = (t) => new Promise((e) => setTimeout(e, t)), G = () => new Promise((t) => F(t)), Y = /* @__PURE__ */ $({
__name: "AlertHandler",

@@ -136,3 +127,3 @@ props: {

duration: {
default: () => O().options.duration,
default: () => _().options.duration,
type: [Number, String, Object],

@@ -153,37 +144,37 @@ validator: (t) => t instanceof Object ? "enter" in t && "leave" in t ? isFinite(Number(t.enter)) && isFinite(Number(t.leave)) : !1 : isFinite(Number(t))

setup(t, { emit: e }) {
const n = t, a = O(), s = [], i = D(), v = (o, { resolve: c, reject: m }) => {
const p = new G(o, {
resolve: async (b) => {
await w(p), c(b);
const s = t, c = _(), o = [], n = E(), T = (r, { resolve: a, reject: h }) => {
const m = new z(r, {
resolve: async (p) => {
await v(m), a(p);
},
reject: async (b) => {
await w(p), m(b);
reject: async (p) => {
await v(m), h(p);
}
});
s.push(p), s.length === 1 && h();
}, h = async () => {
const o = s[0];
let c;
n.duration instanceof Object ? c = Number(n.duration.enter) : c = Number(n.duration), i.value = o, o.opening(), e("opening", o.alert), await j(c), e("opened", o.alert), o.opened();
}, w = async (o) => {
if (o.alert.id !== s[0].alert.id)
throw new M();
let c;
n.duration instanceof Object ? c = Number(n.duration.leave) : c = Number(n.duration), e("closing", o.alert), await j(c), e("closed", o.alert), s.shift(), i.value = void 0, await J(), s.length > 0 && h();
o.push(m), o.length === 1 && f();
}, f = async () => {
const r = o[0];
let a;
s.duration instanceof Object ? a = Number(s.duration.enter) : a = Number(s.duration), n.value = r, r.opening(), e("opening", r.alert), await g(a), e("opened", r.alert), r.opened();
}, v = async (r) => {
if (r.alert.id !== o[0].alert.id)
throw new K();
let a;
s.duration instanceof Object ? a = Number(s.duration.leave) : a = Number(s.duration), e("closing", r.alert), await g(a), e("closed", r.alert), o.shift(), n.value = void 0, await G(), o.length > 0 && f();
};
let y;
return P(() => {
y = a.subscribe((o) => {
if (n.filter(o))
return new Promise((c, m) => v(o, { resolve: c, reject: m }));
y = c.subscribe((r) => {
if (s.filter(r))
return new Promise((a, h) => T(r, { resolve: a, reject: h }));
});
}), C(() => y()), (o, c) => (U(), H(L(t.is), null, {
default: R(() => [
i.value ? B(o.$slots, "default", {
}), C(() => y()), (r, a) => (D(), U(R(t.is), null, {
default: B(() => [
n.value ? H(r.$slots, "default", {
key: 0,
alert: i.value.alert,
isOpen: i.value.isOpen.value,
resolve: i.value.resolver,
reject: i.value.rejecter
}) : K("", !0)
alert: n.value.alert,
isOpen: n.value.isOpen.value,
resolve: n.value.resolver,
reject: n.value.rejecter
}) : L("", !0)
]),

@@ -195,10 +186,10 @@ _: 3

export {
A as Action,
x as Action,
l as Alert,
Z as AlertHandler,
G as Context,
Y as createVuert,
Y as AlertHandler,
z as Context,
X as createVuert,
u as default,
O as useVuert
_ as useVuert
};
//# sourceMappingURL=vuert.js.map
{
"name": "@byloth/vuert",
"version": "1.0.3",
"version": "1.0.4",
"description": "The headless alerts, notifications & popups library for Vue.js craftsmen. ℹ",

@@ -5,0 +5,0 @@ "keywords": [

import { inject, getCurrentScope } from "vue";
import type { App, ComponentPublicInstance, Plugin } from "vue";
import type { App, Plugin } from "vue";
import { handle, RuntimeException } from "@byloth/exceptions";
import { RuntimeException } from "@byloth/exceptions";

@@ -10,17 +10,3 @@ import { InjectionKeys } from "./core.js";

import type { VuertOptions } from "./vuert.js";
import type { AlertOptions } from "./types/alert/index.js";
interface EnabledErrorsHandling
{
enableErrorsHandling: true;
defaultAlertOptions: AlertOptions;
}
interface DisabledErrorsHandling
{
enableErrorsHandling?: false;
defaultAlertOptions?: never;
}
type ErrorsHandling = EnabledErrorsHandling | DisabledErrorsHandling;
let _activeVuert: Vuert | undefined = undefined;

@@ -39,3 +25,3 @@

export type PluginOptions = Partial<VuertOptions> & ErrorsHandling;
export type PluginOptions = Partial<VuertOptions>;
export const createVuert = (options?: PluginOptions): Plugin =>

@@ -52,25 +38,2 @@ {

provide(InjectionKeys.$vuert, $vuert);
if (options?.enableErrorsHandling)
{
const _handler = (exc: unknown) =>
{
// eslint-disable-next-line no-console
console.error(exc);
$vuert.emit(options.defaultAlertOptions);
};
config.errorHandler = (error: unknown, instance: ComponentPublicInstance | null, info: string) =>
{
handle(error, _handler);
};
window.addEventListener("unhandledrejection", (evt: PromiseRejectionEvent) =>
{
evt.preventDefault();
handle(evt.reason, _handler);
});
}
}

@@ -77,0 +40,0 @@ };

@@ -16,3 +16,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

{
public static readonly VERSION: string = "1.0.3";
public static readonly VERSION: string = "1.0.4";

@@ -19,0 +19,0 @@ public static get DEFAULT_OPTS(): VuertOptions

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc