@byloth/vuert
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -46,3 +46,3 @@ import { getCurrentScope as x, inject as T, ref as w, computed as D, defineComponent as A, shallowRef as C, onMounted as j, onUnmounted as E, openBlock as N, createBlock as V, resolveDynamicComponent as F, withCtx as I, renderSlot as k, createCommentVNode as U, nextTick as $ } from "vue"; | ||
}; | ||
h.VERSION = "1.3.0"; | ||
h.VERSION = "1.3.1"; | ||
let b = h, y; | ||
@@ -49,0 +49,0 @@ const q = (t) => { |
@@ -1,2 +0,2 @@ | ||
var Vuert=function(a,o,h,u){"use strict";const w={$vuert:Symbol("[vuert]: vuert")};class g extends h.RuntimeException{constructor(e,i,s,l="AlertThrottledException"){i===void 0&&(i="The alert has been throttled to prevent spamming the user with too many alerts."),super(i,s,l),this.alert=e}}const m=class m{static get DEFAULT_OPTS(){return{useThrottling:!0,throttlingDuration:100,transitionDuration:200}}get options(){return{...this._options}}constructor(e){this._subscribers=[],this._throttlers=new Map,this._options={...m.DEFAULT_OPTS,...e},this._options.useThrottling?this._throttle=i=>{if(!i.id)return!1;const s=Date.now(),l=this._throttlers.get(i.id)??0;return s-l>this._options.throttlingDuration?(this._throttlers.set(i.id,s),!1):!0}:this._throttle=()=>!1}emit(e){if(this._throttle(e))throw new g(e);const l=this._subscribers.slice().map(c=>c(e)).filter(c=>!!c);if(!l.length)throw new h.RuntimeException("Unable to handle the emitted alert properly. There wasn't found any supported subscribers.");if(l.length>1)throw new h.RuntimeException("Unable to handle the emitted alert properly. There were found too many supported subscribers.");return l[0]}subscribe(e){return this._subscribers.push(e),()=>{const i=this._subscribers.indexOf(e);return this._subscribers.splice(i,1)[0]}}};m.VERSION="1.3.0";let b=m,v;const T=t=>{v=t},E=()=>o.getCurrentScope()?o.inject(w.$vuert):v,A=t=>({install:({config:e,provide:i})=>{const s=new b(t);T(s),e.globalProperties.$vuert=s,i(w.$vuert,s)}}),p=()=>{const t=E();if(!t)throw new h.RuntimeException("`useVuert()` was called but there was not active Vuert. Did you forget to install `Vuert` plugin in your App?");return t};class f{constructor(e){this.id=e.id??Symbol(),this.type=e.type??"secondary",this.icon=e.icon,this.label=e.label,this.callback=e.callback??(()=>e.value)}}class d{constructor(e){var i;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 h.ValueException("The `message` and `component` properties cannot both be valued at the same time.");if(this.message=e.message,this.payload=e.payload,this.actions=((i=e.actions)==null?void 0:i.map(s=>new f(s)))??[],this.dismissible=e.dismissible||!1,e.timeout!==void 0){if(e.timeout<=0)throw new h.ValueException("The `timeout` property must be a positive integer or -at least- `undefined`.");this.timeout=e.timeout}else this.timeout=0}}class y extends u.DeferredPromise{constructor(e,i){const s=async()=>{if(!this._isOpen.value)throw new Error("Unable to close the alert. It has already been closed or not even opened yet.");this._isOpen.value=!1,this._timeoutId!==void 0&&(clearTimeout(this._timeoutId),this._timeoutId=void 0),this._closingSubscribers.call(),await u.delay(this._duration.leave),this._closedSubscribers.call()},l=n=>(s(),n instanceof f?n.callback():n instanceof Function?n():n),c=n=>{throw s(),n};if(super(l,c),typeof i=="object")this._duration={enter:Number(i.enter),leave:Number(i.leave)};else{const n=Number(i);this._duration={enter:n,leave:n}}this._openingSubscribers=new u.Subscribers,this._openedSubscribers=new u.Subscribers,this._closingSubscribers=new u.Subscribers,this._closedSubscribers=new u.Subscribers,this.alert=new d(e),this._isOpen=o.ref(!1),this.isOpen=o.computed(()=>this._isOpen.value),this.component=e.component}async open(){if(this._isOpen.value)throw new Error("Unable to open the alert. It has already been opened.");this._isOpen.value=!0,this._openingSubscribers.call(),await u.delay(this._duration.enter),this._openedSubscribers.call(),this.alert.timeout&&(this._timeoutId=setTimeout(this.resolve,this.alert.timeout))}onOpening(e){this._openingSubscribers.add(e)}onOpened(e){this._openedSubscribers.add(e)}onClosing(e){this._closingSubscribers.add(e)}onClosed(e){this._closedSubscribers.add(e)}}const V=o.defineComponent({__name:"AlertHandler",props:{is:{default:"div",type:[String,Object]},filter:{default:()=>!0,type:Function},transitionDuration:{default:()=>p().options.transitionDuration,type:[Number,Object],validator:t=>t instanceof Object?"enter"in t&&"leave"in t?isFinite(Number(t.enter))&&isFinite(Number(t.leave)):!1:isFinite(Number(t))}},emits:{opening:t=>t instanceof d,opened:t=>t instanceof d,closing:t=>t instanceof d,closed:t=>t instanceof d},setup(t,{emit:e}){const i=t,s=e,l=[],c=o.ref(0),n=o.shallowRef(),S=async()=>{const r=l[0];r.onOpening(()=>s("opening",r.alert)),r.onOpened(()=>s("opened",r.alert)),r.onClosing(()=>s("closing",r.alert)),r.onClosed(async()=>{s("closed",r.alert),l.shift(),n.value=void 0,c.value-=1,await o.nextTick(),l.length>0&&S()}),n.value=r,await r.open()},C=r=>{const _=new y(r,i.transitionDuration);return l.push(_),l.length===1&&S(),c.value+=1,_};let O;return o.onMounted(()=>{O=p().subscribe(r=>{if(i.filter(r))return C(r)})}),o.onUnmounted(()=>O()),(r,_)=>(o.openBlock(),o.createBlock(o.resolveDynamicComponent(t.is),null,{default:o.withCtx(()=>[n.value?o.renderSlot(r.$slots,"default",{key:0,alert:n.value.alert,customComponent:n.value.component,isOpen:n.value.isOpen.value,queue:c.value,resolve:n.value.resolve,reject:n.value.reject}):o.createCommentVNode("",!0)]),_:3}))}});return a.Action=f,a.Alert=d,a.AlertHandler=V,a.AlertThrottledException=g,a.Context=y,a.createVuert=A,a.default=b,a.useVuert=p,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),a}({},Vue,Exceptions,Core); | ||
var Vuert=function(a,o,h,u){"use strict";const w={$vuert:Symbol("[vuert]: vuert")};class g extends h.RuntimeException{constructor(e,i,s,l="AlertThrottledException"){i===void 0&&(i="The alert has been throttled to prevent spamming the user with too many alerts."),super(i,s,l),this.alert=e}}const m=class m{static get DEFAULT_OPTS(){return{useThrottling:!0,throttlingDuration:100,transitionDuration:200}}get options(){return{...this._options}}constructor(e){this._subscribers=[],this._throttlers=new Map,this._options={...m.DEFAULT_OPTS,...e},this._options.useThrottling?this._throttle=i=>{if(!i.id)return!1;const s=Date.now(),l=this._throttlers.get(i.id)??0;return s-l>this._options.throttlingDuration?(this._throttlers.set(i.id,s),!1):!0}:this._throttle=()=>!1}emit(e){if(this._throttle(e))throw new g(e);const l=this._subscribers.slice().map(c=>c(e)).filter(c=>!!c);if(!l.length)throw new h.RuntimeException("Unable to handle the emitted alert properly. There wasn't found any supported subscribers.");if(l.length>1)throw new h.RuntimeException("Unable to handle the emitted alert properly. There were found too many supported subscribers.");return l[0]}subscribe(e){return this._subscribers.push(e),()=>{const i=this._subscribers.indexOf(e);return this._subscribers.splice(i,1)[0]}}};m.VERSION="1.3.1";let b=m,v;const T=t=>{v=t},E=()=>o.getCurrentScope()?o.inject(w.$vuert):v,A=t=>({install:({config:e,provide:i})=>{const s=new b(t);T(s),e.globalProperties.$vuert=s,i(w.$vuert,s)}}),p=()=>{const t=E();if(!t)throw new h.RuntimeException("`useVuert()` was called but there was not active Vuert. Did you forget to install `Vuert` plugin in your App?");return t};class f{constructor(e){this.id=e.id??Symbol(),this.type=e.type??"secondary",this.icon=e.icon,this.label=e.label,this.callback=e.callback??(()=>e.value)}}class d{constructor(e){var i;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 h.ValueException("The `message` and `component` properties cannot both be valued at the same time.");if(this.message=e.message,this.payload=e.payload,this.actions=((i=e.actions)==null?void 0:i.map(s=>new f(s)))??[],this.dismissible=e.dismissible||!1,e.timeout!==void 0){if(e.timeout<=0)throw new h.ValueException("The `timeout` property must be a positive integer or -at least- `undefined`.");this.timeout=e.timeout}else this.timeout=0}}class y extends u.DeferredPromise{constructor(e,i){const s=async()=>{if(!this._isOpen.value)throw new Error("Unable to close the alert. It has already been closed or not even opened yet.");this._isOpen.value=!1,this._timeoutId!==void 0&&(clearTimeout(this._timeoutId),this._timeoutId=void 0),this._closingSubscribers.call(),await u.delay(this._duration.leave),this._closedSubscribers.call()},l=n=>(s(),n instanceof f?n.callback():n instanceof Function?n():n),c=n=>{throw s(),n};if(super(l,c),typeof i=="object")this._duration={enter:Number(i.enter),leave:Number(i.leave)};else{const n=Number(i);this._duration={enter:n,leave:n}}this._openingSubscribers=new u.Subscribers,this._openedSubscribers=new u.Subscribers,this._closingSubscribers=new u.Subscribers,this._closedSubscribers=new u.Subscribers,this.alert=new d(e),this._isOpen=o.ref(!1),this.isOpen=o.computed(()=>this._isOpen.value),this.component=e.component}async open(){if(this._isOpen.value)throw new Error("Unable to open the alert. It has already been opened.");this._isOpen.value=!0,this._openingSubscribers.call(),await u.delay(this._duration.enter),this._openedSubscribers.call(),this.alert.timeout&&(this._timeoutId=setTimeout(this.resolve,this.alert.timeout))}onOpening(e){this._openingSubscribers.add(e)}onOpened(e){this._openedSubscribers.add(e)}onClosing(e){this._closingSubscribers.add(e)}onClosed(e){this._closedSubscribers.add(e)}}const V=o.defineComponent({__name:"AlertHandler",props:{is:{default:"div",type:[String,Object]},filter:{default:()=>!0,type:Function},transitionDuration:{default:()=>p().options.transitionDuration,type:[Number,Object],validator:t=>t instanceof Object?"enter"in t&&"leave"in t?isFinite(Number(t.enter))&&isFinite(Number(t.leave)):!1:isFinite(Number(t))}},emits:{opening:t=>t instanceof d,opened:t=>t instanceof d,closing:t=>t instanceof d,closed:t=>t instanceof d},setup(t,{emit:e}){const i=t,s=e,l=[],c=o.ref(0),n=o.shallowRef(),S=async()=>{const r=l[0];r.onOpening(()=>s("opening",r.alert)),r.onOpened(()=>s("opened",r.alert)),r.onClosing(()=>s("closing",r.alert)),r.onClosed(async()=>{s("closed",r.alert),l.shift(),n.value=void 0,c.value-=1,await o.nextTick(),l.length>0&&S()}),n.value=r,await r.open()},C=r=>{const _=new y(r,i.transitionDuration);return l.push(_),l.length===1&&S(),c.value+=1,_};let O;return o.onMounted(()=>{O=p().subscribe(r=>{if(i.filter(r))return C(r)})}),o.onUnmounted(()=>O()),(r,_)=>(o.openBlock(),o.createBlock(o.resolveDynamicComponent(t.is),null,{default:o.withCtx(()=>[n.value?o.renderSlot(r.$slots,"default",{key:0,alert:n.value.alert,customComponent:n.value.component,isOpen:n.value.isOpen.value,queue:c.value,resolve:n.value.resolve,reject:n.value.reject}):o.createCommentVNode("",!0)]),_:3}))}});return a.Action=f,a.Alert=d,a.AlertHandler=V,a.AlertThrottledException=g,a.Context=y,a.createVuert=A,a.default=b,a.useVuert=p,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),a}({},Vue,Exceptions,Core); | ||
//# sourceMappingURL=vuert.global.js.map |
{ | ||
"name": "@byloth/vuert", | ||
"version": "1.3.0", | ||
"description": "The headless alerts, notifications & popups library for Vue.js craftsmen. ℹ", | ||
"version": "1.3.1", | ||
"description": "The headless alerts, modals, notifications & popups library for Vue.js craftsmen. ℹ", | ||
"keywords": [ | ||
@@ -34,3 +34,3 @@ "Alert", | ||
"dist", | ||
"src" | ||
"types" | ||
], | ||
@@ -45,9 +45,10 @@ "main": "dist/vuert.umd.cjs", | ||
"require": "./dist/vuert.cjs.js", | ||
"types": "./src/index.ts" | ||
"types": "./types/index.d.ts" | ||
} | ||
}, | ||
"types": "src/index.ts", | ||
"types": "types/index.d.ts", | ||
"scripts": { | ||
"build": "vite build", | ||
"build:types": "vue-tsc --build --emitDeclarationOnly --force", | ||
"build": "yarn build:source && yarn build:types", | ||
"build:source": "vite build", | ||
"build:types": "vue-tsc --build --emitDeclarationOnly --force && rm -rf ./types && mv ./build/src ./types && rm -rf ./build", | ||
"check:types": "vue-tsc --noEmit", | ||
@@ -58,21 +59,20 @@ "lint": "eslint --ext .cjs,.js,.json,.ts,.vue --ignore-path .gitignore .", | ||
"dependencies": { | ||
"@byloth/core": "^1.3.0", | ||
"@byloth/core": "^1.4.1", | ||
"@byloth/exceptions": "^2.2.4", | ||
"vue": "^3.4.19" | ||
"vue": "^3.4.21" | ||
}, | ||
"devDependencies": { | ||
"@byloth/eslint-config-typescript": "^2.7.0", | ||
"@byloth/eslint-config-vue": "^2.7.0", | ||
"@types/node": "^20.11.20", | ||
"@typescript-eslint/eslint-plugin": "^7.0.2", | ||
"@typescript-eslint/parser": "^7.0.2", | ||
"@byloth/eslint-config-nuxt": "^2.7.0", | ||
"@types/node": "^20.11.30", | ||
"@typescript-eslint/eslint-plugin": "^7.4.0", | ||
"@typescript-eslint/parser": "^7.4.0", | ||
"@vitejs/plugin-vue": "^5.0.4", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-vue": "^9.22.0", | ||
"typescript": "^5.3.3", | ||
"vite": "^5.1.4", | ||
"eslint-plugin-vue": "^9.24.0", | ||
"typescript": "^5.4.3", | ||
"vite": "^5.2.6", | ||
"vue-eslint-parser": "^9.4.2", | ||
"vue-tsc": "^1.8.27" | ||
"vue-tsc": "^2.0.7" | ||
}, | ||
"gitHead": "b8cc6239e5580fa3fc80647e130be058920d286d" | ||
"gitHead": "ac4781b38e13ef09ae6430a573c347321c8d5bc8" | ||
} |
@@ -6,3 +6,3 @@ # Vuert ℹ | ||
The headless alerts, notifications & popups library for Vue.js craftsmen. | ||
The headless alerts, modals, notifications & popups library for Vue.js craftsmen. | ||
@@ -9,0 +9,0 @@ ## 📝 Documentation |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11
137857
30
519
1
Updated@byloth/core@^1.4.1
Updatedvue@^3.4.21