@stonecrop/stonecrop 0.3.7 → 0.3.9
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/composable.js +15 -10
- package/dist/registry.js +1 -1
- package/dist/src/composable.d.ts.map +1 -1
- package/dist/src/stonecrop.d.ts +7 -7
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stores/xstate.d.ts +22 -1
- package/dist/src/stores/xstate.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +6 -6
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/stonecrop.d.ts +11 -11
- package/dist/stonecrop.js +129 -124
- package/dist/stonecrop.js.map +1 -1
- package/dist/stonecrop.umd.cjs +2 -2
- package/dist/stonecrop.umd.cjs.map +1 -1
- package/dist/stores/xstate.js +1 -1
- package/package.json +4 -4
- package/src/composable.ts +15 -9
- package/src/registry.ts +1 -1
- package/src/stonecrop.ts +22 -19
- package/src/stores/xstate.ts +1 -1
- package/src/types/index.ts +6 -6
package/dist/stonecrop.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(B,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],m):(B=typeof globalThis<"u"?globalThis:B||self,m(B["@stonecrop/stonecrop"]={},B.Vue))})(this,function(B,m){"use strict";var li=Object.defineProperty;var fi=(B,m,ne)=>m in B?li(B,m,{enumerable:!0,configurable:!0,writable:!0,value:ne}):B[m]=ne;var L=(B,m,ne)=>fi(B,typeof m!="symbol"?m+"":m,ne);function ne(e){this.message=e||""}ne.prototype=Object.create(Error.prototype,{constructor:{value:ne},name:{value:"NotImplemented"},stack:{get:function(){return new Error().stack}}});const Ee=class Ee{constructor(t,n,r,o,s){L(this,"name","Stonecrop");L(this,"registry");L(this,"
|
|
1
|
+
(function(B,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],m):(B=typeof globalThis<"u"?globalThis:B||self,m(B["@stonecrop/stonecrop"]={},B.Vue))})(this,function(B,m){"use strict";var li=Object.defineProperty;var fi=(B,m,ne)=>m in B?li(B,m,{enumerable:!0,configurable:!0,writable:!0,value:ne}):B[m]=ne;var L=(B,m,ne)=>fi(B,typeof m!="symbol"?m+"":m,ne);function ne(e){this.message=e||""}ne.prototype=Object.create(Error.prototype,{constructor:{value:ne},name:{value:"NotImplemented"},stack:{get:function(){return new Error().stack}}});const Ee=class Ee{constructor(t,n,r,o,s){L(this,"name","Stonecrop");L(this,"registry");L(this,"store");L(this,"schema");L(this,"workflow");L(this,"actions");if(Ee._root)return Ee._root;Ee._root=this,this.registry=t,this.store=n,this.schema=r,this.workflow=o,this.actions=s}setup(t){this.getMeta(t),this.getWorkflow(t),this.getActions(t)}getMeta(t){return this.registry.getMeta?this.registry.getMeta(t.doctype):new ne(t.doctype)}getWorkflow(t){const n=this.registry.registry[t.slug];this.workflow=n.workflow}getActions(t){const n=this.registry.registry[t.slug];this.actions=n.actions}async getRecords(t,n){this.store.$patch({records:[]});const o=await(await fetch(`/${t.slug}`,n)).json();this.store.$patch({records:o})}async getRecord(t,n){this.store.$patch({record:{}});const o=await(await fetch(`/${t.slug}/${n}`)).json();this.store.$patch({record:o})}runAction(t,n,r){var i;const s=(i=this.registry.registry[t.slug].actions)==null?void 0:i.get(n);if(this.workflow){const{initialState:a}=this.workflow;this.workflow.transition(a,{type:n}),s&&s.length>0&&s.forEach(c=>{new Function(c)(r)})}}};L(Ee,"_root");let Ge=Ee;var Ot=!1;function Ce(e,t,n){return Array.isArray(e)?(e.length=Math.max(e.length,t),e.splice(t,1,n),n):(e[t]=n,n)}function ze(e,t){if(Array.isArray(e)){e.splice(t,1);return}delete e[t]}function tr(){return Nt().__VUE_DEVTOOLS_GLOBAL_HOOK__}function Nt(){return typeof navigator<"u"&&typeof window<"u"?window:typeof globalThis<"u"?globalThis:{}}const nr=typeof Proxy=="function",rr="devtools-plugin:setup",or="plugin:settings:set";let he,qe;function sr(){var e;return he!==void 0||(typeof window<"u"&&window.performance?(he=!0,qe=window.performance):typeof globalThis<"u"&&(!((e=globalThis.perf_hooks)===null||e===void 0)&&e.performance)?(he=!0,qe=globalThis.perf_hooks.performance):he=!1),he}function ir(){return sr()?qe.now():Date.now()}class ar{constructor(t,n){this.target=null,this.targetQueue=[],this.onQueue=[],this.plugin=t,this.hook=n;const r={};if(t.settings)for(const i in t.settings){const a=t.settings[i];r[i]=a.defaultValue}const o=`__vue-devtools-plugin-settings__${t.id}`;let s=Object.assign({},r);try{const i=localStorage.getItem(o),a=JSON.parse(i);Object.assign(s,a)}catch{}this.fallbacks={getSettings(){return s},setSettings(i){try{localStorage.setItem(o,JSON.stringify(i))}catch{}s=i},now(){return ir()}},n&&n.on(or,(i,a)=>{i===this.plugin.id&&this.fallbacks.setSettings(a)}),this.proxiedOn=new Proxy({},{get:(i,a)=>this.target?this.target.on[a]:(...c)=>{this.onQueue.push({method:a,args:c})}}),this.proxiedTarget=new Proxy({},{get:(i,a)=>this.target?this.target[a]:a==="on"?this.proxiedOn:Object.keys(this.fallbacks).includes(a)?(...c)=>(this.targetQueue.push({method:a,args:c,resolve:()=>{}}),this.fallbacks[a](...c)):(...c)=>new Promise(l=>{this.targetQueue.push({method:a,args:c,resolve:l})})})}async setRealTarget(t){this.target=t;for(const n of this.onQueue)this.target.on[n.method](...n.args);for(const n of this.targetQueue)n.resolve(await this.target[n.method](...n.args))}}function Je(e,t){const n=e,r=Nt(),o=tr(),s=nr&&n.enableEarlyProxy;if(o&&(r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__||!s))o.emit(rr,e,t);else{const i=s?new ar(n,o):null;(r.__VUE_DEVTOOLS_PLUGINS__=r.__VUE_DEVTOOLS_PLUGINS__||[]).push({pluginDescriptor:n,setupFn:t,proxy:i}),i&&t(i.proxiedTarget)}}/*!
|
|
2
2
|
* pinia v2.3.0
|
|
3
3
|
* (c) 2024 Eduardo San Martin Morote
|
|
4
4
|
* @license MIT
|
|
@@ -8,7 +8,7 @@ Only state can be modified.`);i[0]="$state",me=!1,r.set(s,i,r.state.value),me=!0
|
|
|
8
8
|
state: () => new MyClass()
|
|
9
9
|
Found in store "${S.$id}".`),b&&s&&n.hydrate&&n.hydrate(S.$state,b),l=!0,f=!0,S}/*! #__NO_SIDE_EFFECTS__ */function $r(e,t,n){let r,o;const s=typeof t=="function";r=e,o=s?n:t;function i(a,c){const l=m.hasInjectionContext();if(a=(process.env.NODE_ENV==="test"&&Oe&&Oe._testing?null:a)||(l?m.inject(kt,null):null),a&&Ne(a),process.env.NODE_ENV!=="production"&&!Oe)throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
|
|
10
10
|
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
|
|
11
|
-
This will fail in production.`);a=Oe,a._s.has(r)||(s?Ze(r,t,o,a):Ft(r,o,a),process.env.NODE_ENV!=="production"&&(i._pinia=a));const f=a._s.get(r);if(process.env.NODE_ENV!=="production"&&c){const u="__hot:"+r,d=s?Ze(u,t,o,a,!0):Ft(u,z({},o),a,!0);c._hotUpdate(d),delete a.state.value[u],a._s.delete(u)}if(process.env.NODE_ENV!=="production"&&re){const u=m.getCurrentInstance();if(u&&u.proxy&&!c){const d=u.proxy,h="_pStores"in d?d._pStores:d._pStores={};h[r]=f}}return f}return i.$id=r,i}const Ir=$r("data",()=>{const e=m.ref([]),t=m.ref({});return{records:e,record:t}});function Cr(e){e||(e=m.inject("$registry"));let t;try{t=Ir()}catch{throw new Error("Please enable the Stonecrop plugin before using the Stonecrop composable")}const n=m.ref(new Ge(e,t)),r=m.ref(!1);return m.onBeforeMount(async()=>{var c,l;const o=e.router.currentRoute.value,s=(c=o.params.records)==null?void 0:c.toString().toLowerCase(),i=(l=o.params.record)==null?void 0:l.toString().toLowerCase();if(!s&&!i)return;const a=await
|
|
11
|
+
This will fail in production.`);a=Oe,a._s.has(r)||(s?Ze(r,t,o,a):Ft(r,o,a),process.env.NODE_ENV!=="production"&&(i._pinia=a));const f=a._s.get(r);if(process.env.NODE_ENV!=="production"&&c){const u="__hot:"+r,d=s?Ze(u,t,o,a,!0):Ft(u,z({},o),a,!0);c._hotUpdate(d),delete a.state.value[u],a._s.delete(u)}if(process.env.NODE_ENV!=="production"&&re){const u=m.getCurrentInstance();if(u&&u.proxy&&!c){const d=u.proxy,h="_pStores"in d?d._pStores:d._pStores={};h[r]=f}}return f}return i.$id=r,i}const Ir=$r("data",()=>{const e=m.ref([]),t=m.ref({});return{records:e,record:t}});function Cr(e){e||(e=m.inject("$registry"));let t;try{t=Ir()}catch{throw new Error("Please enable the Stonecrop plugin before using the Stonecrop composable")}const n=m.ref(new Ge(e,t)),r=m.ref(!1);return m.onBeforeMount(async()=>{var c,l,f;if(!e)return;const o=e.router.currentRoute.value,s=(c=o.params.records)==null?void 0:c.toString().toLowerCase(),i=(l=o.params.record)==null?void 0:l.toString().toLowerCase();if(!s&&!i)return;const a=await((f=e.getMeta)==null?void 0:f.call(e,s));a&&(e.addDoctype(a),n.value.setup(a),s&&(i?await n.value.getRecord(a,i):await n.value.getRecords(a)),n.value.runAction(a,"LOAD",i?[i]:void 0)),r.value=!0}),{stonecrop:n,isReady:r}}class Tr{constructor(t,n,r,o,s){L(this,"doctype");L(this,"schema");L(this,"workflow");L(this,"actions");L(this,"component");this.doctype=t,this.schema=n,this.workflow=r,this.actions=o,this.component=s}get slug(){return this.doctype.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}}const we=class we{constructor(t,n){L(this,"name");L(this,"router");L(this,"registry");L(this,"getMeta");if(we._root)return we._root;we._root=this,this.name="Registry",this.router=t,this.registry={},this.getMeta=n}addDoctype(t){t.doctype in Object.keys(this.registry)||(this.registry[t.slug]=t),!this.router.hasRoute(t.doctype)&&t.component&&this.router.addRoute({path:`/${t.slug}`,name:t.slug,component:t.component})}};L(we,"_root");let je=we;/*!
|
|
12
12
|
* vue-router v4.5.0
|
|
13
13
|
* (c) 2024 Eduardo San Martin Morote
|
|
14
14
|
* @license MIT
|