@vue-modeler/model 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index.cjs → decorator.cjs.js} +1 -1
- package/dist/{index.js → decorator.es.js} +1 -1
- package/dist/{index2.cjs → index.cjs.js} +1 -1
- package/dist/{index2.js → index.es.js} +1 -1
- package/dist/proto-model-BbeUu-fI.cjs +1 -0
- package/dist/{proto-model-BXAhWQOY.js → proto-model-CFE7kMpT.js} +1 -1
- package/package.json +9 -9
- package/dist/proto-model-B4Pm8x5w.cjs +0 -1
- /package/dist/{index3.cjs → error.cjs.js} +0 -0
- /package/dist/{index3.js → error.es.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./proto-model-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./proto-model-BbeUu-fI.cjs"),u=(e,o,t)=>{if(typeof o!="string")throw new Error("Action name is not a string");if(typeof t.value!="function")throw new Error("Property value is not a function");if(!(e instanceof r.ProtoModel))throw new Error("Target is not instance of ProtoModel");const i=t.value,n={[o]:function(...s){return this.action(n[o]).exec(...s)}};n[o][r.Action.actionFlag]=i,t.value=n[o]};exports.action=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("vue"),a=require("./proto-model-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("vue"),a=require("./proto-model-BbeUu-fI.cjs");var S=Object.defineProperty,f=(t,e,r)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,s=(t,e,r)=>f(t,typeof e!="symbol"?e+"":e,r);function v(){var t;const e=(t=c.getCurrentInstance())==null?void 0:t.proxy;if(!e)throw new Error("Current instance is undefined");if(!e.$vueModelerDc)throw new Error("Dependency container undefined. Check plugin setup");return e.$vueModelerDc}function u(t,e={persistentInstance:!1}){const r=Symbol("provider"),i=()=>{const n=v(),o=n.get(r)||n.add(r,t);return e.persistentInstance||(o.subscribeOnParentScopeDispose(c.onScopeDispose),c.onScopeDispose(()=>{o.parentScopeCount>0||n.delete(r)})),o.instance};return i.__isProvider__=!0,Object.defineProperty(i,"asKey",{value:r,writable:!1}),i}class p{constructor(){s(this,"isServer",!0),s(this,"stateKey","__SSR_STATE__"),s(this,"serializers",new Set),s(this,"stateFromServer",{}),this.isServer=typeof window>"u",this.initStateFromServer()}initStateFromServer(){if(this.isServer||!globalThis.__INITIAL_STATE__)return;const e=typeof globalThis.__INITIAL_STATE__=="string"?JSON.parse(globalThis.__INITIAL_STATE__):globalThis.__INITIAL_STATE__;typeof e[this.stateKey]=="object"&&(this.stateFromServer=e[this.stateKey])}extractState(e){return this.stateFromServer[e]}addSerializer(e){return this.isServer&&this.serializers.add(e),e}removeSerializer(e){return this.isServer?this.serializers.delete(e):!1}serialize(){const e={};for(const r of this.serializers){const i=r();i.value!==void 0&&(e[i.extractionKey]=i.value)}return e}injectState(e){this.isServer&&(e[this.stateKey]=this.serialize())}}u(()=>new p);const _=Proxy;function d(t){if(!(t instanceof a.ProtoModel))throw new Error("ProtoModel instance is required");return new _(c.shallowReactive(t),{get(r,i,n){const o=Reflect.get(r,i,n),l=typeof o=="function";return l&&a.Action.actionFlag in o&&typeof o[a.Action.actionFlag]=="function"?r.action(o):l?o.bind(r):o}})}function h(t,e){return u(()=>d(t()),e)}exports.ProtoModel=a.ProtoModel;exports.createModel=d;exports.model=h;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { onScopeDispose as c, getCurrentInstance as f, shallowReactive as d } from "vue";
|
|
2
|
-
import { P as S, A as l } from "./proto-model-
|
|
2
|
+
import { P as S, A as l } from "./proto-model-CFE7kMpT.js";
|
|
3
3
|
var _ = Object.defineProperty, h = (t, e, r) => e in t ? _(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, s = (t, e, r) => h(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
4
|
function p() {
|
|
5
5
|
var t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var S=(i,t,e)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var r=(i,t,e)=>S(i,typeof t!="symbol"?t+"":t,e);const l=require("vue"),a=require("./error.cjs.js"),b=i=>i instanceof DOMException&&i.name==="AbortError"||typeof i=="object"&&i!==null&&"message"in i&&i.message==="canceled",s=class s{constructor(t,e){r(this,"name");r(this,"_state",s.possibleState.ready);r(this,"_value",null);r(this,"_args",null);this.model=t,this.actionFunction=e;const o=e.name;if(!(o in t&&typeof t[o]=="function"))throw new a.ActionInternalError(`Model does not contain method ${o}`);if(typeof e[s.actionFlag]!="function")throw new a.ActionInternalError(`Method ${o} is not action`);this.name=o}toString(){return this.name}get possibleStates(){return Object.values(s.possibleState)}get state(){return this._state}set state(t){this._state=t,this.model.setActionState(this)}get abortController(){return this.isPending?this._value.abortController:null}get args(){return this._args||[]}get promise(){return this.isPending?this._value.promise:null}get error(){return this.isError?this._value:null}get abortReason(){return this.isAbort?this._value.abortController.signal.reason:null}get isPending(){return this.state===s.possibleState.pending}get isError(){return this.state===s.possibleState.error}get isReady(){return this.state===s.possibleState.ready}get isLock(){return this.state===s.possibleState.lock}get isAbort(){return this.state===s.possibleState.abort}is(...t){return!!t.find(e=>this.state===e)}exec(...t){if(this.is(s.possibleState.lock,s.possibleState.pending))throw new a.ActionStatusConflictError(this.name,this.state,s.possibleState.pending);const e=[...t];let o=t.length&&t[t.length-1];o instanceof AbortController||(o=new AbortController,e.push(o)),this.state=s.possibleState.pending,this._args=t;const h=this.actionFunction[s.actionFlag].apply(this.model,e);if(!(h instanceof Promise))return this.state=s.possibleState.ready,Promise.resolve(h);const f=h.then(()=>{this.ready()}).catch(n=>{if(n instanceof a.ActionInternalError||n instanceof RangeError||n instanceof ReferenceError||n instanceof SyntaxError||n instanceof TypeError||n instanceof URIError||n instanceof EvalError)throw n;const d=b(n);if(d&&!this.is(s.possibleState.pending,s.possibleState.lock))throw new a.ActionUnexpectedAbortError(this.name,this.state);if(d&&this._value.abortController instanceof AbortController&&this._value.abortController.signal.reason===s.abortedByLock){this.state=s.possibleState.lock,this._value=null;return}if(d){this.state=s.possibleState.abort;return}this.setError(new a.ActionError(this.name,{cause:n}))});return this._value={promise:f,abortController:o},f}abort(t){return this.isPending?(this._value.abortController.abort(t),this._value.promise):Promise.resolve()}lock(){return this.isPending?this.abort(s.abortedByLock):(this.state=s.possibleState.lock,this._value=null,Promise.resolve())}unlock(){if(!this.isLock)throw new a.ActionStatusConflictError(this.name,this.state,s.possibleState.ready);return this.ready()}setError(t){if(!this.isPending)throw new a.ActionStatusConflictError(this.name,this.state,s.possibleState.error);return this.state=s.possibleState.error,this._value=t,this}ready(){return this.state=s.possibleState.ready,this}resetError(){if(!this.error)throw new a.ActionStatusConflictError(this.name,this.state,s.possibleState.ready);return this.ready()}};r(s,"actionFlag",Symbol("__action_original_method__")),r(s,"possibleState",{pending:"pending",error:"error",lock:"lock",ready:"ready",abort:"abort"}),r(s,"abortedByLock",Symbol("lock"));let c=s;class g{constructor(){r(this,"_effectScope",l.effectScope(!0));r(this,"_actions",new WeakMap);r(this,"_actionIds",new WeakMap);r(this,"_actionStates",new Map);r(this,"_actionsSize",0);r(this,"_unwatchers",new Set)}get hasPendingActions(){return!!this.getActionStatesRef(c.possibleState.pending).value}get hasActionWithError(){return!!this.getActionStatesRef(c.possibleState.error).value}watch(...t){const e=this._effectScope.run(()=>l.watch(...t));if(!e)throw new Error("watchStopHandler is undefined");return this._unwatchers.add(e),e}computed(t,e){return this._effectScope.run(()=>l.computed(t,e))}updateBit(t,e,o){const u=o?1:0,h=~(1<<e);return t&h|u<<e}createAction(t){const e=l.shallowReactive(new c(this,t));return this._actions.set(t,e),this._actionIds.set(e,++this._actionsSize),this.setActionState(e),e}getActionStatesRef(t){const e=this._actionStates.get(t)||l.ref(0);return this._actionStates.get(t)===void 0&&this._actionStates.set(t,e),e}setActionState(t){const e=this._actionIds.get(t);if(!e)throw new Error("Action not found");for(const o of t.possibleStates)o!==t.state&&(this.getActionStatesRef(o).value=this.updateBit(this.getActionStatesRef(o).value,e,!1));this.getActionStatesRef(t.state).value=this.updateBit(this.getActionStatesRef(t.state).value,e,!0)}isModelOf(t){return this instanceof t}action(t){return this._actions.get(t)||this.createAction(t)}destructor(){this._unwatchers.forEach(t=>{t()}),this._unwatchers=new Set,this._effectScope.stop()}}exports.Action=c;exports.ProtoModel=g;
|
|
@@ -2,7 +2,7 @@ var p = Object.defineProperty;
|
|
|
2
2
|
var b = (r, t, e) => t in r ? p(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
3
|
var i = (r, t, e) => b(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { effectScope as S, watch as g, computed as w, shallowReactive as m, ref as A } from "vue";
|
|
5
|
-
import { ActionInternalError as d, ActionStatusConflictError as c, ActionUnexpectedAbortError as v, ActionError as y } from "./
|
|
5
|
+
import { ActionInternalError as d, ActionStatusConflictError as c, ActionUnexpectedAbortError as v, ActionError as y } from "./error.es.js";
|
|
6
6
|
const k = (r) => r instanceof DOMException && r.name === "AbortError" || typeof r == "object" && r !== null && "message" in r && r.message === "canceled", s = class s {
|
|
7
7
|
constructor(t, e) {
|
|
8
8
|
i(this, "name");
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@vue-modeler/model",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"description": "A state management library based on models for Vue.js",
|
|
6
6
|
"author": "abratko",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
|
-
"main": "./dist/index.
|
|
12
|
-
"module": "./dist/index.js",
|
|
11
|
+
"main": "./dist/index.cjs.js",
|
|
12
|
+
"module": "./dist/index.es.js",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"import": "./dist/index.js",
|
|
16
|
-
"require": "./dist/index.
|
|
15
|
+
"import": "./dist/index.es.js",
|
|
16
|
+
"require": "./dist/index.cjs.js"
|
|
17
17
|
},
|
|
18
18
|
"./decorator": {
|
|
19
|
-
"import": "./dist/decorator.js",
|
|
20
|
-
"require": "./dist/decorator.
|
|
19
|
+
"import": "./dist/decorator.es.js",
|
|
20
|
+
"require": "./dist/decorator.cjs.js"
|
|
21
21
|
},
|
|
22
22
|
"./error": {
|
|
23
|
-
"import": "./dist/error.js",
|
|
24
|
-
"require": "./dist/error.
|
|
23
|
+
"import": "./dist/error.es.js",
|
|
24
|
+
"require": "./dist/error.cjs.js"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"types": "./dist/index.d.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var S=(i,t,e)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var r=(i,t,e)=>S(i,typeof t!="symbol"?t+"":t,e);const l=require("vue"),a=require("./index3.cjs"),b=i=>i instanceof DOMException&&i.name==="AbortError"||typeof i=="object"&&i!==null&&"message"in i&&i.message==="canceled",s=class s{constructor(t,e){r(this,"name");r(this,"_state",s.possibleState.ready);r(this,"_value",null);r(this,"_args",null);this.model=t,this.actionFunction=e;const o=e.name;if(!(o in t&&typeof t[o]=="function"))throw new a.ActionInternalError(`Model does not contain method ${o}`);if(typeof e[s.actionFlag]!="function")throw new a.ActionInternalError(`Method ${o} is not action`);this.name=o}toString(){return this.name}get possibleStates(){return Object.values(s.possibleState)}get state(){return this._state}set state(t){this._state=t,this.model.setActionState(this)}get abortController(){return this.isPending?this._value.abortController:null}get args(){return this._args||[]}get promise(){return this.isPending?this._value.promise:null}get error(){return this.isError?this._value:null}get abortReason(){return this.isAbort?this._value.abortController.signal.reason:null}get isPending(){return this.state===s.possibleState.pending}get isError(){return this.state===s.possibleState.error}get isReady(){return this.state===s.possibleState.ready}get isLock(){return this.state===s.possibleState.lock}get isAbort(){return this.state===s.possibleState.abort}is(...t){return!!t.find(e=>this.state===e)}exec(...t){if(this.is(s.possibleState.lock,s.possibleState.pending))throw new a.ActionStatusConflictError(this.name,this.state,s.possibleState.pending);const e=[...t];let o=t.length&&t[t.length-1];o instanceof AbortController||(o=new AbortController,e.push(o)),this.state=s.possibleState.pending,this._args=t;const h=this.actionFunction[s.actionFlag].apply(this.model,e);if(!(h instanceof Promise))return this.state=s.possibleState.ready,Promise.resolve(h);const f=h.then(()=>{this.ready()}).catch(n=>{if(n instanceof a.ActionInternalError||n instanceof RangeError||n instanceof ReferenceError||n instanceof SyntaxError||n instanceof TypeError||n instanceof URIError||n instanceof EvalError)throw n;const d=b(n);if(d&&!this.is(s.possibleState.pending,s.possibleState.lock))throw new a.ActionUnexpectedAbortError(this.name,this.state);if(d&&this._value.abortController instanceof AbortController&&this._value.abortController.signal.reason===s.abortedByLock){this.state=s.possibleState.lock,this._value=null;return}if(d){this.state=s.possibleState.abort;return}this.setError(new a.ActionError(this.name,{cause:n}))});return this._value={promise:f,abortController:o},f}abort(t){return this.isPending?(this._value.abortController.abort(t),this._value.promise):Promise.resolve()}lock(){return this.isPending?this.abort(s.abortedByLock):(this.state=s.possibleState.lock,this._value=null,Promise.resolve())}unlock(){if(!this.isLock)throw new a.ActionStatusConflictError(this.name,this.state,s.possibleState.ready);return this.ready()}setError(t){if(!this.isPending)throw new a.ActionStatusConflictError(this.name,this.state,s.possibleState.error);return this.state=s.possibleState.error,this._value=t,this}ready(){return this.state=s.possibleState.ready,this}resetError(){if(!this.error)throw new a.ActionStatusConflictError(this.name,this.state,s.possibleState.ready);return this.ready()}};r(s,"actionFlag",Symbol("__action_original_method__")),r(s,"possibleState",{pending:"pending",error:"error",lock:"lock",ready:"ready",abort:"abort"}),r(s,"abortedByLock",Symbol("lock"));let c=s;class g{constructor(){r(this,"_effectScope",l.effectScope(!0));r(this,"_actions",new WeakMap);r(this,"_actionIds",new WeakMap);r(this,"_actionStates",new Map);r(this,"_actionsSize",0);r(this,"_unwatchers",new Set)}get hasPendingActions(){return!!this.getActionStatesRef(c.possibleState.pending).value}get hasActionWithError(){return!!this.getActionStatesRef(c.possibleState.error).value}watch(...t){const e=this._effectScope.run(()=>l.watch(...t));if(!e)throw new Error("watchStopHandler is undefined");return this._unwatchers.add(e),e}computed(t,e){return this._effectScope.run(()=>l.computed(t,e))}updateBit(t,e,o){const u=o?1:0,h=~(1<<e);return t&h|u<<e}createAction(t){const e=l.shallowReactive(new c(this,t));return this._actions.set(t,e),this._actionIds.set(e,++this._actionsSize),this.setActionState(e),e}getActionStatesRef(t){const e=this._actionStates.get(t)||l.ref(0);return this._actionStates.get(t)===void 0&&this._actionStates.set(t,e),e}setActionState(t){const e=this._actionIds.get(t);if(!e)throw new Error("Action not found");for(const o of t.possibleStates)o!==t.state&&(this.getActionStatesRef(o).value=this.updateBit(this.getActionStatesRef(o).value,e,!1));this.getActionStatesRef(t.state).value=this.updateBit(this.getActionStatesRef(t.state).value,e,!0)}isModelOf(t){return this instanceof t}action(t){return this._actions.get(t)||this.createAction(t)}destructor(){this._unwatchers.forEach(t=>{t()}),this._unwatchers=new Set,this._effectScope.stop()}}exports.Action=c;exports.ProtoModel=g;
|
|
File without changes
|
|
File without changes
|