@storix-js/sync 0.2.0 → 0.3.0

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/README.md CHANGED
@@ -19,4 +19,4 @@ const storix = createStorix({
19
19
  });
20
20
  ```
21
21
 
22
- The plugin uses `BroadcastChannel` when available and falls back to the `storage` event.
22
+ The plugin uses `BroadcastChannel` when available and the `storage` event only as a fallback, never as a duplicate second transport. Local changes are debounced/coalesced by scope and key, remote-origin changes are not echoed, and cross-namespace delivery requires explicit `namespaces` configuration.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var fe=Symbol.for("preact-signals");function G(){if(H>1)H--;else{var t,e=!1;for((function(){var w=K;for(K=void 0;w!==void 0;)w.S.v===w.v&&(w.S.i=w.i),w=w.o})();Z!==void 0;){var s=Z;for(Z=void 0,B++;s!==void 0;){var l=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&ae(s))try{s.c()}catch(w){e||(t=w,e=!0)}s=l}}if(B=0,H--,e)throw t}}function L(t){if(H>0)return t();X=++ve,H++;try{return t()}finally{G()}}var p=void 0;function Y(t){var e=p;p=void 0;try{return t()}finally{p=e}}var Z=void 0,H=0,B=0,ve=0,X=0,K=void 0,F=0;function re(t){if(p!==void 0){var e=t.n;if(e===void 0||e.t!==p)return e={i:0,S:t,p:p.s,n:void 0,t:p,e:void 0,x:void 0,r:e},p.s!==void 0&&(p.s.n=e),p.s=e,t.n=e,32&p.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=p.s,e.n=void 0,p.s.n=e,p.s=e),e}}function x(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}x.prototype.brand=fe;x.prototype.h=function(){return!0};x.prototype.S=function(t){var e=this,s=this.t;s!==t&&t.e===void 0&&(t.x=s,this.t=t,s!==void 0?s.e=t:Y(function(){var l;(l=e.W)==null||l.call(e)}))};x.prototype.U=function(t){var e=this;if(this.t!==void 0){var s=t.e,l=t.x;s!==void 0&&(s.x=l,t.e=void 0),l!==void 0&&(l.e=s,t.x=void 0),t===this.t&&(this.t=l,l===void 0&&Y(function(){var w;(w=e.Z)==null||w.call(e)}))}};x.prototype.subscribe=function(t){var e=this;return he(function(){var s=e.value,l=p;p=void 0;try{t(s)}finally{p=l}},{name:"sub"})};x.prototype.valueOf=function(){return this.value};x.prototype.toString=function(){return this.value+""};x.prototype.toJSON=function(){return this.value};x.prototype.peek=function(){var t=this;return Y(function(){return t.value})};Object.defineProperty(x.prototype,"value",{get:function(){var t=re(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(B>100)throw new Error("Cycle detected");(function(s){H!==0&&B===0&&s.l!==X&&(s.l=X,K={S:s,v:s.v,i:s.i,o:K})})(this),this.v=t,this.i++,F++,H++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{G()}}}});function Q(t,e){return new x(t,e)}function ae(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function ce(t){for(var e=t.s;e!==void 0;e=e.n){var s=e.S.n;if(s!==void 0&&(e.r=s),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function ue(t){for(var e=t.s,s=void 0;e!==void 0;){var l=e.p;e.i===-1?(e.S.U(e),l!==void 0&&(l.n=e.n),e.n!==void 0&&(e.n.p=l)):s=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=l}t.s=s}function A(t,e){x.call(this,void 0),this.x=t,this.s=void 0,this.g=F-1,this.f=4,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}A.prototype=new x;A.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===F))return!0;if(this.g=F,this.f|=1,this.i>0&&!ae(this))return this.f&=-2,!0;var t=p;try{ce(this),p=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return p=t,ue(this),this.f&=-2,!0};A.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}x.prototype.S.call(this,t)};A.prototype.U=function(t){if(this.t!==void 0&&(x.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};A.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(A.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=re(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function se(t,e){return new A(t,e)}function le(t){var e=t.m;if(t.m=void 0,typeof e=="function"){H++;var s=p;p=void 0;try{e()}catch(l){throw t.f&=-2,t.f|=8,ee(t),l}finally{p=s,G()}}}function ee(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,le(t)}function de(t){if(p!==this)throw new Error("Out-of-order effect");ue(this),p=t,this.f&=-2,8&this.f&&ee(this),G()}function _(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e==null?void 0:e.name}_.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};_.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,le(this),ce(this),H++;var t=p;return p=this,de.bind(this,t)};_.prototype.N=function(){2&this.f||(this.f|=2,this.u=Z,Z=this)};_.prototype.d=function(){this.f|=8,1&this.f||ee(this)};_.prototype.dispose=function(){this.d()};function he(t,e){var s=new _(t,e);try{s.c()}catch(w){throw s.d(),w}var l=s.d.bind(s);return l[Symbol.dispose]=l,l}function pe(t={}){const e=(t.namespace??"default").trim()||"default",s=t.plugins??[],l=new Map;function w(S,I){return function(){var E;const M=`${e}:${S}`,P=l.get(S);if(P)return P;const R=I.state(),g=I.modules??{},b={...R};for(const[r,o]of Object.entries(g))b[r]=o.state();const h=Q(b),j=new Map,T=new Map,U=new Map,N=new Map,m=new Map,i=new Set,n=new Set(Object.keys(R)),c=new Set(Object.keys(I.getters??{})),d=new Set(Object.keys(I.actions??{})),$=r=>h.value[r]??{},W=(r,o)=>{h.value={...h.value,[r]:o}},q=new Proxy({},{get(r,o){var u,f;if(j.has(o))return(u=j.get(o))==null?void 0:u.value;if(m.has(o))return(f=m.get(o))==null?void 0:f.value;if(n.has(o))return h.value[o];const y=N.get(o);return y?$(y.moduleName)[y.key]:h.value[o]}});for(const[r,o]of Object.entries(I.getters??{}))j.set(r,se(()=>o(h.value,q)));const te=(r,o)=>{var u;for(const f of i)f(r);for(const f of s)(u=f.onMutation)==null||u.call(f,o,r)},ne=(r,o,u,f)=>{const y=h.value[r];Object.is(y,o)||(h.value={...h.value,[r]:o},te({namespace:e,scopeId:M,storeId:S,key:r,oldValue:y,newValue:o,origin:u},f))},C=(r,o,u,f,y)=>{const O=$(r),a=O[o];Object.is(a,u)||(W(r,{...O,[o]:u}),te({namespace:e,scopeId:M,storeId:S,key:`${r}.${o}`,oldValue:a,newValue:u,origin:f},y))},D={$id:S,$namespace:e,$scopeId:M,$subscribe(r){return i.add(r),()=>i.delete(r)},$dispose(){var r;i.clear();for(const o of s)(r=o.onDispose)==null||r.call(o,k);l.delete(S)},$patch(r,o="local"){L(()=>{for(const[u,f]of Object.entries(r)){const y=N.get(u);if(y){C(y.moduleName,y.key,f,o,k);continue}if(u.includes(".")){const[O,a]=u.split(".",2);if(g[O]){C(O,a,f,o,k);continue}}if(g[u]&&f&&typeof f=="object"&&!Array.isArray(f)){for(const[O,a]of Object.entries(f))C(u,O,a,o,k);continue}ne(u,f,o,k)}})},$snapshot(){return{...h.value}}};for(const[r,o]of Object.entries(g)){const u=new Map,f=new Map,y=new Proxy({},{get(a,v){var V,z,ie;if(u.has(v))return(V=u.get(v))==null?void 0:V.value;if(j.has(v))return(z=j.get(v))==null?void 0:z.value;if(m.has(v))return(ie=m.get(v))==null?void 0:ie.value;const oe=$(r);if(v in oe)return oe[v];if(n.has(v))return h.value[v]}});for(const[a,v]of Object.entries(o.getters??{}))u.set(a,se(()=>v($(r),h.value,y)));let O;for(const[a,v]of Object.entries(o.actions??{}))f.set(a,(...V)=>L(()=>v.apply(O,V)));O=new Proxy({},{get(a,v){var V;if(f.has(v))return f.get(v);if(u.has(v))return(V=u.get(v))==null?void 0:V.value;const z=$(r);return v in z?z[v]:k[v]},set(a,v,V){if(f.has(v)||u.has(v))return!1;const z=$(r);return v in z?C(r,v,V,"local",k):k[v]=V,!0}}),U.set(r,O),T.set(r,u);for(const a of Object.keys($(r)))!(n.has(a)||c.has(a)||d.has(a)||Reflect.has(D,a)||g[a]!==void 0)&&!N.has(a)&&N.set(a,{moduleName:r,key:a});for(const[a,v]of u.entries())!(n.has(a)||c.has(a)||d.has(a)||Reflect.has(D,a)||g[a]!==void 0)&&!m.has(a)&&m.set(a,v);for(const[a,v]of f.entries())!(n.has(a)||c.has(a)||d.has(a)||Reflect.has(D,a)||g[a]!==void 0)&&!Reflect.has(D,a)&&(D[a]=v)}const k=new Proxy(D,{get(r,o,u){var f,y;if(Reflect.has(r,o))return Reflect.get(r,o,u);if(U.has(o))return U.get(o);if(j.has(o))return(f=j.get(o))==null?void 0:f.value;if(m.has(o))return(y=m.get(o))==null?void 0:y.value;if(n.has(o))return h.value[o];const O=N.get(o);return O?$(O.moduleName)[O.key]:h.value[o]},set(r,o,u,f){if(Reflect.has(r,o))return Reflect.set(r,o,u,f);const y=N.get(o);return y?(C(y.moduleName,y.key,u,"local",f),!0):(ne(o,u,"local",f),!0)}});for(const[r,o]of Object.entries(I.actions??{}))D[r]=(...u)=>L(()=>o.apply(k,u));for(const r of s)(E=r.onInit)==null||E.call(r,k);return l.set(S,k),k}}function J(S,I){return function(){var E;const M=`\0machine:${S}`,P=l.get(M);if(P)return P;const R=`${e}:${S}`,g=Q(I.initial),b=Q((I.context??(()=>({})))()),h=new Set,j=(i,n)=>{var c;for(const d of h)d(i);for(const d of s)(c=d.onMutation)==null||c.call(d,n,i)},T=(i,n,c,d)=>{const $=b.value[i];Object.is($,n)||(b.value={...b.value,[i]:n},j({namespace:e,scopeId:R,storeId:S,key:i,oldValue:$,newValue:n,origin:c},d))},U=(i,n,c)=>{const d=g.value;Object.is(d,i)||(g.value=i,j({namespace:e,scopeId:R,storeId:S,key:"$state",oldValue:d,newValue:i,origin:n},c))},N={$id:S,$namespace:e,$scopeId:R,$subscribe(i){return h.add(i),()=>h.delete(i)},$dispose(){var i;h.clear();for(const n of s)(i=n.onDispose)==null||i.call(n,m);l.delete(M)},$patch(i,n="local"){L(()=>{for(const[c,d]of Object.entries(i))c==="$state"?U(d,n,m):T(c,d,n,m)})},$snapshot(){return{$state:g.value,...b.value}},send(i,n){L(()=>{var c,d,$;const W=(c=I.actions)==null?void 0:c[i];W&&W.call(m,n);const q=($=(d=I.states[g.value])==null?void 0:d.on)==null?void 0:$[i];q!==void 0&&U(q,"local",m)})},matches(i){return g.value===i},can(i){const n=I.states[g.value];return!!(n!=null&&n.on&&i in n.on)}},m=new Proxy(N,{get(i,n,c){return n==="state"?g.value:Reflect.has(i,n)?Reflect.get(i,n,c):b.value[n]},set(i,n,c,d){return n==="state"?!1:Reflect.has(i,n)?Reflect.set(i,n,c,d):(T(n,c,"local",d),!0)}});for(const i of s)(E=i.onInit)==null||E.call(i,m);return l.set(M,m),m}}return{defineStore:w,defineMachine:J,use(S){s.push(S)}}}pe();function ye(t={}){const e=t.channelName??"storix-sync",s=new Set(t.include??[]),l=new Set(t.exclude??[]),w=t.namespaces??[],J=w==="*"?null:new Set(w),S=t.debounce??16,I=crypto.randomUUID(),E=`__storix_sync__:${e}`,M=new Map,P=new Set,R=new Map,g=new Map;let b=null;const h=typeof window<"u"&&"BroadcastChannel"in window?new BroadcastChannel(e):null,j=i=>{const n=[i.$id,i.$scopeId];return!(n.some(c=>l.has(c))||s.size>0&&!n.some(c=>s.has(c)))},T=(i,n)=>n===i||J===null?!0:J.has(n),U=(i,n)=>{!n||n.originTabId===I||T(i.$namespace,n.namespace)&&n.storeId===i.$id&&j(i)&&i.$patch({[n.key]:n.newValue},"remote")},N=()=>{if(b=null,M.size===0)return;const i=Array.from(M.values());M.clear();for(const n of i){const c={...n,originTabId:I};if(h&&h.postMessage(c),typeof window<"u"&&"localStorage"in window)try{window.localStorage.setItem(E,JSON.stringify(c)),window.localStorage.removeItem(E)}catch{}}},m=i=>{if(M.set(`${i.scopeId}:${i.key}`,i),S<=0){N();return}b||(b=setTimeout(N,S))};return{name:"sync",onInit(i){const n=i;if(j(n)){if(P.add(n.$scopeId),h){const c=d=>{U(n,d.data)};R.set(n.$scopeId,c),h.addEventListener("message",c)}if(typeof window<"u"){const c=d=>{if(!(d.key!==E||!d.newValue))try{const $=JSON.parse(d.newValue);U(n,$)}catch{}};g.set(n.$scopeId,c),window.addEventListener("storage",c)}}},onMutation(i,n){n.origin!=="remote"&&j(i)&&m(n)},onDispose(i){const n=i;P.delete(n.$scopeId);const c=R.get(n.$scopeId);h&&c&&(h.removeEventListener("message",c),R.delete(n.$scopeId));const d=g.get(n.$scopeId);typeof window<"u"&&d&&(window.removeEventListener("storage",d),g.delete(n.$scopeId)),b&&(clearTimeout(b),b=null),N(),P.size===0&&(h==null||h.close())}}}exports.syncPlugin=ye;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@storix-js/core");function t(t={}){let n=t.channelName??`storix-sync`,r=new Set(t.include??[]),i=new Set(t.exclude??[]),a=t.namespaces??[],o=a===`*`?null:new Set(a),s=t.debounce??16,c=globalThis.crypto?.randomUUID?.()??`storix-${Date.now()}-${Math.random().toString(36).slice(2)}`,l=`__storix_sync__:${n}`,u=new Map,d=new Set,f=new Map,p=new Map,m=null,h=null,g=()=>(h||typeof window>`u`||typeof window.BroadcastChannel!=`function`||(h=new window.BroadcastChannel(n)),h),_=e=>{let t=[e.$id,e.$scopeId];return!(t.some(e=>i.has(e))||r.size>0&&!t.some(e=>r.has(e)))},v=(e,t)=>t===e||o===null||o.has(t),y=(e,t)=>{t&&t.originTabId!==c&&v(e.$namespace,t.namespace)&&t.storeId===e.$id&&_(e)&&e.$patch({[t.key]:t.newValue},`remote`)},b=()=>{if(m=null,u.size===0)return;let e=Array.from(u.values());u.clear();for(let t of e){let e={...t,originTabId:c},n=g();if(n&&n.postMessage(e),!n&&typeof window<`u`&&`localStorage`in window)try{window.localStorage.setItem(l,JSON.stringify(e)),window.localStorage.removeItem(l)}catch{}}},x=e=>{if(u.set(`${e.scopeId}:${e.key}`,e),s<=0){b();return}m||=setTimeout(b,s)};return(0,e.definePlugin)({name:`sync`,onInit(e){let t=e;if(!_(t))return;d.add(t.$scopeId);let n=g();if(n){let e=e=>{y(t,e.data)};f.set(t.$scopeId,e),n.addEventListener(`message`,e)}if(typeof window<`u`){let e=e=>{if(e.key===l&&e.newValue)try{let n=JSON.parse(e.newValue);y(t,n)}catch{}};p.set(t.$scopeId,e),window.addEventListener(`storage`,e)}},onMutation(e,t){t.origin!==`remote`&&_(e)&&x(t)},onDispose(e){let t=e;d.delete(t.$scopeId);let n=f.get(t.$scopeId);h&&n&&(h.removeEventListener(`message`,n),f.delete(t.$scopeId));let r=p.get(t.$scopeId);typeof window<`u`&&r&&(window.removeEventListener(`storage`,r),p.delete(t.$scopeId)),m&&=(clearTimeout(m),null),b(),d.size===0&&(h?.close(),h=null)}})}exports.syncPlugin=t;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type MutationPayload } from '@storix-js/core';
1
2
  export interface SyncPluginOptions {
2
3
  channelName?: string;
3
4
  include?: string[];
@@ -5,5 +6,10 @@ export interface SyncPluginOptions {
5
6
  namespaces?: string[] | '*';
6
7
  debounce?: number;
7
8
  }
8
- export declare function syncPlugin(options?: SyncPluginOptions): import("@storix-js/core").StorePlugin;
9
+ export declare function syncPlugin(options?: SyncPluginOptions): {
10
+ name: string;
11
+ onInit(store: import("@storix-js/core").StoreInstance<{}, {}, {}, {}>): void;
12
+ onMutation(store: import("@storix-js/core").StoreInstance<{}, {}, {}, {}>, mutation: MutationPayload): void;
13
+ onDispose(store: import("@storix-js/core").StoreInstance<{}, {}, {}, {}>): void;
14
+ };
9
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AASD,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,yCA8IzD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AASD,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB;;;;;EAwJzD"}
package/dist/index.js CHANGED
@@ -1,588 +1,66 @@
1
- var fe = Symbol.for("preact-signals");
2
- function G() {
3
- if (H > 1)
4
- H--;
5
- else {
6
- var t, e = !1;
7
- for ((function() {
8
- var w = K;
9
- for (K = void 0; w !== void 0; )
10
- w.S.v === w.v && (w.S.i = w.i), w = w.o;
11
- })(); Z !== void 0; ) {
12
- var s = Z;
13
- for (Z = void 0, B++; s !== void 0; ) {
14
- var l = s.u;
15
- if (s.u = void 0, s.f &= -3, !(8 & s.f) && ae(s)) try {
16
- s.c();
17
- } catch (w) {
18
- e || (t = w, e = !0);
19
- }
20
- s = l;
21
- }
22
- }
23
- if (B = 0, H--, e) throw t;
24
- }
25
- }
26
- function T(t) {
27
- if (H > 0) return t();
28
- X = ++ve, H++;
29
- try {
30
- return t();
31
- } finally {
32
- G();
33
- }
34
- }
35
- var p = void 0;
36
- function Y(t) {
37
- var e = p;
38
- p = void 0;
39
- try {
40
- return t();
41
- } finally {
42
- p = e;
43
- }
44
- }
45
- var Z = void 0, H = 0, B = 0, ve = 0, X = 0, K = void 0, F = 0;
46
- function re(t) {
47
- if (p !== void 0) {
48
- var e = t.n;
49
- if (e === void 0 || e.t !== p)
50
- return e = { i: 0, S: t, p: p.s, n: void 0, t: p, e: void 0, x: void 0, r: e }, p.s !== void 0 && (p.s.n = e), p.s = e, t.n = e, 32 & p.f && t.S(e), e;
51
- if (e.i === -1)
52
- return e.i = 0, e.n !== void 0 && (e.n.p = e.p, e.p !== void 0 && (e.p.n = e.n), e.p = p.s, e.n = void 0, p.s.n = e, p.s = e), e;
53
- }
54
- }
55
- function O(t, e) {
56
- this.v = t, this.i = 0, this.n = void 0, this.t = void 0, this.l = 0, this.W = e == null ? void 0 : e.watched, this.Z = e == null ? void 0 : e.unwatched, this.name = e == null ? void 0 : e.name;
57
- }
58
- O.prototype.brand = fe;
59
- O.prototype.h = function() {
60
- return !0;
61
- };
62
- O.prototype.S = function(t) {
63
- var e = this, s = this.t;
64
- s !== t && t.e === void 0 && (t.x = s, this.t = t, s !== void 0 ? s.e = t : Y(function() {
65
- var l;
66
- (l = e.W) == null || l.call(e);
67
- }));
68
- };
69
- O.prototype.U = function(t) {
70
- var e = this;
71
- if (this.t !== void 0) {
72
- var s = t.e, l = t.x;
73
- s !== void 0 && (s.x = l, t.e = void 0), l !== void 0 && (l.e = s, t.x = void 0), t === this.t && (this.t = l, l === void 0 && Y(function() {
74
- var w;
75
- (w = e.Z) == null || w.call(e);
76
- }));
77
- }
78
- };
79
- O.prototype.subscribe = function(t) {
80
- var e = this;
81
- return he(function() {
82
- var s = e.value, l = p;
83
- p = void 0;
84
- try {
85
- t(s);
86
- } finally {
87
- p = l;
88
- }
89
- }, { name: "sub" });
90
- };
91
- O.prototype.valueOf = function() {
92
- return this.value;
93
- };
94
- O.prototype.toString = function() {
95
- return this.value + "";
96
- };
97
- O.prototype.toJSON = function() {
98
- return this.value;
99
- };
100
- O.prototype.peek = function() {
101
- var t = this;
102
- return Y(function() {
103
- return t.value;
104
- });
105
- };
106
- Object.defineProperty(O.prototype, "value", { get: function() {
107
- var t = re(this);
108
- return t !== void 0 && (t.i = this.i), this.v;
109
- }, set: function(t) {
110
- if (t !== this.v) {
111
- if (B > 100) throw new Error("Cycle detected");
112
- (function(s) {
113
- H !== 0 && B === 0 && s.l !== X && (s.l = X, K = { S: s, v: s.v, i: s.i, o: K });
114
- })(this), this.v = t, this.i++, F++, H++;
115
- try {
116
- for (var e = this.t; e !== void 0; e = e.x) e.t.N();
117
- } finally {
118
- G();
119
- }
120
- }
121
- } });
122
- function Q(t, e) {
123
- return new O(t, e);
124
- }
125
- function ae(t) {
126
- for (var e = t.s; e !== void 0; e = e.n) if (e.S.i !== e.i || !e.S.h() || e.S.i !== e.i) return !0;
127
- return !1;
128
- }
129
- function ce(t) {
130
- for (var e = t.s; e !== void 0; e = e.n) {
131
- var s = e.S.n;
132
- if (s !== void 0 && (e.r = s), e.S.n = e, e.i = -1, e.n === void 0) {
133
- t.s = e;
134
- break;
135
- }
136
- }
137
- }
138
- function ue(t) {
139
- for (var e = t.s, s = void 0; e !== void 0; ) {
140
- var l = e.p;
141
- e.i === -1 ? (e.S.U(e), l !== void 0 && (l.n = e.n), e.n !== void 0 && (e.n.p = l)) : s = e, e.S.n = e.r, e.r !== void 0 && (e.r = void 0), e = l;
142
- }
143
- t.s = s;
144
- }
145
- function A(t, e) {
146
- O.call(this, void 0), this.x = t, this.s = void 0, this.g = F - 1, this.f = 4, this.W = e == null ? void 0 : e.watched, this.Z = e == null ? void 0 : e.unwatched, this.name = e == null ? void 0 : e.name;
147
- }
148
- A.prototype = new O();
149
- A.prototype.h = function() {
150
- if (this.f &= -3, 1 & this.f) return !1;
151
- if ((36 & this.f) == 32 || (this.f &= -5, this.g === F)) return !0;
152
- if (this.g = F, this.f |= 1, this.i > 0 && !ae(this))
153
- return this.f &= -2, !0;
154
- var t = p;
155
- try {
156
- ce(this), p = this;
157
- var e = this.x();
158
- (16 & this.f || this.v !== e || this.i === 0) && (this.v = e, this.f &= -17, this.i++);
159
- } catch (s) {
160
- this.v = s, this.f |= 16, this.i++;
161
- }
162
- return p = t, ue(this), this.f &= -2, !0;
163
- };
164
- A.prototype.S = function(t) {
165
- if (this.t === void 0) {
166
- this.f |= 36;
167
- for (var e = this.s; e !== void 0; e = e.n) e.S.S(e);
168
- }
169
- O.prototype.S.call(this, t);
170
- };
171
- A.prototype.U = function(t) {
172
- if (this.t !== void 0 && (O.prototype.U.call(this, t), this.t === void 0)) {
173
- this.f &= -33;
174
- for (var e = this.s; e !== void 0; e = e.n) e.S.U(e);
175
- }
176
- };
177
- A.prototype.N = function() {
178
- if (!(2 & this.f)) {
179
- this.f |= 6;
180
- for (var t = this.t; t !== void 0; t = t.x) t.t.N();
181
- }
182
- };
183
- Object.defineProperty(A.prototype, "value", { get: function() {
184
- if (1 & this.f) throw new Error("Cycle detected");
185
- var t = re(this);
186
- if (this.h(), t !== void 0 && (t.i = this.i), 16 & this.f) throw this.v;
187
- return this.v;
188
- } });
189
- function se(t, e) {
190
- return new A(t, e);
191
- }
192
- function le(t) {
193
- var e = t.m;
194
- if (t.m = void 0, typeof e == "function") {
195
- H++;
196
- var s = p;
197
- p = void 0;
198
- try {
199
- e();
200
- } catch (l) {
201
- throw t.f &= -2, t.f |= 8, ee(t), l;
202
- } finally {
203
- p = s, G();
204
- }
205
- }
206
- }
207
- function ee(t) {
208
- for (var e = t.s; e !== void 0; e = e.n) e.S.U(e);
209
- t.x = void 0, t.s = void 0, le(t);
210
- }
211
- function de(t) {
212
- if (p !== this) throw new Error("Out-of-order effect");
213
- ue(this), p = t, this.f &= -2, 8 & this.f && ee(this), G();
214
- }
215
- function C(t, e) {
216
- this.x = t, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = e == null ? void 0 : e.name;
217
- }
218
- C.prototype.c = function() {
219
- var t = this.S();
220
- try {
221
- if (8 & this.f || this.x === void 0) return;
222
- var e = this.x();
223
- typeof e == "function" && (this.m = e);
224
- } finally {
225
- t();
226
- }
227
- };
228
- C.prototype.S = function() {
229
- if (1 & this.f) throw new Error("Cycle detected");
230
- this.f |= 1, this.f &= -9, le(this), ce(this), H++;
231
- var t = p;
232
- return p = this, de.bind(this, t);
233
- };
234
- C.prototype.N = function() {
235
- 2 & this.f || (this.f |= 2, this.u = Z, Z = this);
236
- };
237
- C.prototype.d = function() {
238
- this.f |= 8, 1 & this.f || ee(this);
239
- };
240
- C.prototype.dispose = function() {
241
- this.d();
242
- };
243
- function he(t, e) {
244
- var s = new C(t, e);
245
- try {
246
- s.c();
247
- } catch (w) {
248
- throw s.d(), w;
249
- }
250
- var l = s.d.bind(s);
251
- return l[Symbol.dispose] = l, l;
252
- }
253
- function pe(t = {}) {
254
- const e = (t.namespace ?? "default").trim() || "default", s = t.plugins ?? [], l = /* @__PURE__ */ new Map();
255
- function w(S, I) {
256
- return function() {
257
- var E;
258
- const M = `${e}:${S}`, U = l.get(S);
259
- if (U) return U;
260
- const R = I.state(), m = I.modules ?? {}, b = { ...R };
261
- for (const [r, i] of Object.entries(m))
262
- b[r] = i.state();
263
- const h = Q(b), j = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), n = new Set(Object.keys(R)), c = new Set(Object.keys(I.getters ?? {})), d = new Set(Object.keys(I.actions ?? {})), $ = (r) => h.value[r] ?? {}, W = (r, i) => {
264
- h.value = {
265
- ...h.value,
266
- [r]: i
267
- };
268
- }, q = new Proxy(
269
- {},
270
- {
271
- get(r, i) {
272
- var u, f;
273
- if (j.has(i)) return (u = j.get(i)) == null ? void 0 : u.value;
274
- if (g.has(i)) return (f = g.get(i)) == null ? void 0 : f.value;
275
- if (n.has(i)) return h.value[i];
276
- const y = N.get(i);
277
- return y ? $(y.moduleName)[y.key] : h.value[i];
278
- }
279
- }
280
- );
281
- for (const [r, i] of Object.entries(I.getters ?? {}))
282
- j.set(
283
- r,
284
- se(() => i(h.value, q))
285
- );
286
- const te = (r, i) => {
287
- var u;
288
- for (const f of o) f(r);
289
- for (const f of s)
290
- (u = f.onMutation) == null || u.call(f, i, r);
291
- }, ne = (r, i, u, f) => {
292
- const y = h.value[r];
293
- Object.is(y, i) || (h.value = {
294
- ...h.value,
295
- [r]: i
296
- }, te(
297
- {
298
- namespace: e,
299
- scopeId: M,
300
- storeId: S,
301
- key: r,
302
- oldValue: y,
303
- newValue: i,
304
- origin: u
305
- },
306
- f
307
- ));
308
- }, L = (r, i, u, f, y) => {
309
- const x = $(r), a = x[i];
310
- Object.is(a, u) || (W(r, {
311
- ...x,
312
- [i]: u
313
- }), te(
314
- {
315
- namespace: e,
316
- scopeId: M,
317
- storeId: S,
318
- key: `${r}.${i}`,
319
- oldValue: a,
320
- newValue: u,
321
- origin: f
322
- },
323
- y
324
- ));
325
- }, D = {
326
- $id: S,
327
- $namespace: e,
328
- $scopeId: M,
329
- $subscribe(r) {
330
- return o.add(r), () => o.delete(r);
331
- },
332
- $dispose() {
333
- var r;
334
- o.clear();
335
- for (const i of s)
336
- (r = i.onDispose) == null || r.call(i, k);
337
- l.delete(S);
338
- },
339
- $patch(r, i = "local") {
340
- T(() => {
341
- for (const [u, f] of Object.entries(r)) {
342
- const y = N.get(u);
343
- if (y) {
344
- L(y.moduleName, y.key, f, i, k);
345
- continue;
346
- }
347
- if (u.includes(".")) {
348
- const [x, a] = u.split(".", 2);
349
- if (m[x]) {
350
- L(x, a, f, i, k);
351
- continue;
352
- }
353
- }
354
- if (m[u] && f && typeof f == "object" && !Array.isArray(f)) {
355
- for (const [x, a] of Object.entries(f))
356
- L(u, x, a, i, k);
357
- continue;
358
- }
359
- ne(u, f, i, k);
360
- }
361
- });
362
- },
363
- $snapshot() {
364
- return { ...h.value };
365
- }
366
- };
367
- for (const [r, i] of Object.entries(m)) {
368
- const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), y = new Proxy(
369
- {},
370
- {
371
- get(a, v) {
372
- var V, z, oe;
373
- if (u.has(v)) return (V = u.get(v)) == null ? void 0 : V.value;
374
- if (j.has(v)) return (z = j.get(v)) == null ? void 0 : z.value;
375
- if (g.has(v)) return (oe = g.get(v)) == null ? void 0 : oe.value;
376
- const ie = $(r);
377
- if (v in ie) return ie[v];
378
- if (n.has(v)) return h.value[v];
379
- }
380
- }
381
- );
382
- for (const [a, v] of Object.entries(i.getters ?? {}))
383
- u.set(
384
- a,
385
- se(() => v($(r), h.value, y))
386
- );
387
- let x;
388
- for (const [a, v] of Object.entries(i.actions ?? {}))
389
- f.set(a, (...V) => T(() => v.apply(x, V)));
390
- x = new Proxy(
391
- {},
392
- {
393
- get(a, v) {
394
- var V;
395
- if (f.has(v)) return f.get(v);
396
- if (u.has(v)) return (V = u.get(v)) == null ? void 0 : V.value;
397
- const z = $(r);
398
- return v in z ? z[v] : k[v];
399
- },
400
- set(a, v, V) {
401
- if (f.has(v) || u.has(v)) return !1;
402
- const z = $(r);
403
- return v in z ? L(r, v, V, "local", k) : k[v] = V, !0;
404
- }
405
- }
406
- ), P.set(r, x), _.set(r, u);
407
- for (const a of Object.keys($(r)))
408
- !(n.has(a) || c.has(a) || d.has(a) || Reflect.has(D, a) || m[a] !== void 0) && !N.has(a) && N.set(a, { moduleName: r, key: a });
409
- for (const [a, v] of u.entries())
410
- !(n.has(a) || c.has(a) || d.has(a) || Reflect.has(D, a) || m[a] !== void 0) && !g.has(a) && g.set(a, v);
411
- for (const [a, v] of f.entries())
412
- !(n.has(a) || c.has(a) || d.has(a) || Reflect.has(D, a) || m[a] !== void 0) && !Reflect.has(D, a) && (D[a] = v);
413
- }
414
- const k = new Proxy(D, {
415
- get(r, i, u) {
416
- var f, y;
417
- if (Reflect.has(r, i)) return Reflect.get(r, i, u);
418
- if (P.has(i)) return P.get(i);
419
- if (j.has(i)) return (f = j.get(i)) == null ? void 0 : f.value;
420
- if (g.has(i)) return (y = g.get(i)) == null ? void 0 : y.value;
421
- if (n.has(i)) return h.value[i];
422
- const x = N.get(i);
423
- return x ? $(x.moduleName)[x.key] : h.value[i];
424
- },
425
- set(r, i, u, f) {
426
- if (Reflect.has(r, i))
427
- return Reflect.set(r, i, u, f);
428
- const y = N.get(i);
429
- return y ? (L(y.moduleName, y.key, u, "local", f), !0) : (ne(i, u, "local", f), !0);
430
- }
431
- });
432
- for (const [r, i] of Object.entries(I.actions ?? {}))
433
- D[r] = (...u) => T(() => i.apply(k, u));
434
- for (const r of s)
435
- (E = r.onInit) == null || E.call(r, k);
436
- return l.set(S, k), k;
437
- };
438
- }
439
- function J(S, I) {
440
- return function() {
441
- var E;
442
- const M = `\0machine:${S}`, U = l.get(M);
443
- if (U) return U;
444
- const R = `${e}:${S}`, m = Q(I.initial), b = Q((I.context ?? (() => ({})))()), h = /* @__PURE__ */ new Set(), j = (o, n) => {
445
- var c;
446
- for (const d of h) d(o);
447
- for (const d of s)
448
- (c = d.onMutation) == null || c.call(d, n, o);
449
- }, _ = (o, n, c, d) => {
450
- const $ = b.value[o];
451
- Object.is($, n) || (b.value = { ...b.value, [o]: n }, j({ namespace: e, scopeId: R, storeId: S, key: o, oldValue: $, newValue: n, origin: c }, d));
452
- }, P = (o, n, c) => {
453
- const d = m.value;
454
- Object.is(d, o) || (m.value = o, j(
455
- { namespace: e, scopeId: R, storeId: S, key: "$state", oldValue: d, newValue: o, origin: n },
456
- c
457
- ));
458
- }, N = {
459
- $id: S,
460
- $namespace: e,
461
- $scopeId: R,
462
- $subscribe(o) {
463
- return h.add(o), () => h.delete(o);
464
- },
465
- $dispose() {
466
- var o;
467
- h.clear();
468
- for (const n of s)
469
- (o = n.onDispose) == null || o.call(n, g);
470
- l.delete(M);
471
- },
472
- $patch(o, n = "local") {
473
- T(() => {
474
- for (const [c, d] of Object.entries(o))
475
- c === "$state" ? P(d, n, g) : _(c, d, n, g);
476
- });
477
- },
478
- $snapshot() {
479
- return { $state: m.value, ...b.value };
480
- },
481
- send(o, n) {
482
- T(() => {
483
- var c, d, $;
484
- const W = (c = I.actions) == null ? void 0 : c[o];
485
- W && W.call(g, n);
486
- const q = ($ = (d = I.states[m.value]) == null ? void 0 : d.on) == null ? void 0 : $[o];
487
- q !== void 0 && P(q, "local", g);
488
- });
489
- },
490
- matches(o) {
491
- return m.value === o;
492
- },
493
- can(o) {
494
- const n = I.states[m.value];
495
- return !!(n != null && n.on && o in n.on);
496
- }
497
- }, g = new Proxy(N, {
498
- get(o, n, c) {
499
- return n === "state" ? m.value : Reflect.has(o, n) ? Reflect.get(o, n, c) : b.value[n];
500
- },
501
- set(o, n, c, d) {
502
- return n === "state" ? !1 : Reflect.has(o, n) ? Reflect.set(o, n, c, d) : (_(n, c, "local", d), !0);
503
- }
504
- });
505
- for (const o of s)
506
- (E = o.onInit) == null || E.call(o, g);
507
- return l.set(M, g), g;
508
- };
509
- }
510
- return {
511
- defineStore: w,
512
- defineMachine: J,
513
- use(S) {
514
- s.push(S);
515
- }
516
- };
517
- }
518
- pe();
519
- function ye(t = {}) {
520
- const e = t.channelName ?? "storix-sync", s = new Set(t.include ?? []), l = new Set(t.exclude ?? []), w = t.namespaces ?? [], J = w === "*" ? null : new Set(w), S = t.debounce ?? 16, I = crypto.randomUUID(), E = `__storix_sync__:${e}`, M = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
521
- let b = null;
522
- const h = typeof window < "u" && "BroadcastChannel" in window ? new BroadcastChannel(e) : null, j = (o) => {
523
- const n = [o.$id, o.$scopeId];
524
- return !(n.some((c) => l.has(c)) || s.size > 0 && !n.some((c) => s.has(c)));
525
- }, _ = (o, n) => n === o || J === null ? !0 : J.has(n), P = (o, n) => {
526
- !n || n.originTabId === I || _(o.$namespace, n.namespace) && n.storeId === o.$id && j(o) && o.$patch({ [n.key]: n.newValue }, "remote");
527
- }, N = () => {
528
- if (b = null, M.size === 0) return;
529
- const o = Array.from(M.values());
530
- M.clear();
531
- for (const n of o) {
532
- const c = {
533
- ...n,
534
- originTabId: I
535
- };
536
- if (h && h.postMessage(c), typeof window < "u" && "localStorage" in window)
537
- try {
538
- window.localStorage.setItem(E, JSON.stringify(c)), window.localStorage.removeItem(E);
539
- } catch {
540
- }
541
- }
542
- }, g = (o) => {
543
- if (M.set(`${o.scopeId}:${o.key}`, o), S <= 0) {
544
- N();
545
- return;
546
- }
547
- b || (b = setTimeout(N, S));
548
- };
549
- return {
550
- name: "sync",
551
- onInit(o) {
552
- const n = o;
553
- if (j(n)) {
554
- if (U.add(n.$scopeId), h) {
555
- const c = (d) => {
556
- P(n, d.data);
557
- };
558
- R.set(n.$scopeId, c), h.addEventListener("message", c);
559
- }
560
- if (typeof window < "u") {
561
- const c = (d) => {
562
- if (!(d.key !== E || !d.newValue))
563
- try {
564
- const $ = JSON.parse(d.newValue);
565
- P(n, $);
566
- } catch {
567
- }
568
- };
569
- m.set(n.$scopeId, c), window.addEventListener("storage", c);
570
- }
571
- }
572
- },
573
- onMutation(o, n) {
574
- n.origin !== "remote" && j(o) && g(n);
575
- },
576
- onDispose(o) {
577
- const n = o;
578
- U.delete(n.$scopeId);
579
- const c = R.get(n.$scopeId);
580
- h && c && (h.removeEventListener("message", c), R.delete(n.$scopeId));
581
- const d = m.get(n.$scopeId);
582
- typeof window < "u" && d && (window.removeEventListener("storage", d), m.delete(n.$scopeId)), b && (clearTimeout(b), b = null), N(), U.size === 0 && (h == null || h.close());
583
- }
584
- };
585
- }
586
- export {
587
- ye as syncPlugin
588
- };
1
+ import { definePlugin as e } from "@storix-js/core";
2
+ //#region src/index.ts
3
+ function t(t = {}) {
4
+ let n = t.channelName ?? "storix-sync", r = new Set(t.include ?? []), i = new Set(t.exclude ?? []), a = t.namespaces ?? [], o = a === "*" ? null : new Set(a), s = t.debounce ?? 16, c = globalThis.crypto?.randomUUID?.() ?? `storix-${Date.now()}-${Math.random().toString(36).slice(2)}`, l = `__storix_sync__:${n}`, u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), m = null, h = null, g = () => (h || typeof window > "u" || typeof window.BroadcastChannel != "function" || (h = new window.BroadcastChannel(n)), h), _ = (e) => {
5
+ let t = [e.$id, e.$scopeId];
6
+ return !(t.some((e) => i.has(e)) || r.size > 0 && !t.some((e) => r.has(e)));
7
+ }, v = (e, t) => t === e || o === null || o.has(t), y = (e, t) => {
8
+ t && t.originTabId !== c && v(e.$namespace, t.namespace) && t.storeId === e.$id && _(e) && e.$patch({ [t.key]: t.newValue }, "remote");
9
+ }, b = () => {
10
+ if (m = null, u.size === 0) return;
11
+ let e = Array.from(u.values());
12
+ u.clear();
13
+ for (let t of e) {
14
+ let e = {
15
+ ...t,
16
+ originTabId: c
17
+ }, n = g();
18
+ if (n && n.postMessage(e), !n && typeof window < "u" && "localStorage" in window) try {
19
+ window.localStorage.setItem(l, JSON.stringify(e)), window.localStorage.removeItem(l);
20
+ } catch {}
21
+ }
22
+ }, x = (e) => {
23
+ if (u.set(`${e.scopeId}:${e.key}`, e), s <= 0) {
24
+ b();
25
+ return;
26
+ }
27
+ m ||= setTimeout(b, s);
28
+ };
29
+ return e({
30
+ name: "sync",
31
+ onInit(e) {
32
+ let t = e;
33
+ if (!_(t)) return;
34
+ d.add(t.$scopeId);
35
+ let n = g();
36
+ if (n) {
37
+ let e = (e) => {
38
+ y(t, e.data);
39
+ };
40
+ f.set(t.$scopeId, e), n.addEventListener("message", e);
41
+ }
42
+ if (typeof window < "u") {
43
+ let e = (e) => {
44
+ if (e.key === l && e.newValue) try {
45
+ let n = JSON.parse(e.newValue);
46
+ y(t, n);
47
+ } catch {}
48
+ };
49
+ p.set(t.$scopeId, e), window.addEventListener("storage", e);
50
+ }
51
+ },
52
+ onMutation(e, t) {
53
+ t.origin !== "remote" && _(e) && x(t);
54
+ },
55
+ onDispose(e) {
56
+ let t = e;
57
+ d.delete(t.$scopeId);
58
+ let n = f.get(t.$scopeId);
59
+ h && n && (h.removeEventListener("message", n), f.delete(t.$scopeId));
60
+ let r = p.get(t.$scopeId);
61
+ typeof window < "u" && r && (window.removeEventListener("storage", r), p.delete(t.$scopeId)), m &&= (clearTimeout(m), null), b(), d.size === 0 && (h?.close(), h = null);
62
+ }
63
+ });
64
+ }
65
+ //#endregion
66
+ export { t as syncPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storix-js/sync",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -19,13 +19,13 @@
19
19
  "require": "./dist/index.cjs"
20
20
  }
21
21
  },
22
+ "dependencies": {
23
+ "@storix-js/core": "0.3.0"
24
+ },
22
25
  "scripts": {
23
26
  "build": "vite build && tsc -p tsconfig.build.json --emitDeclarationOnly",
24
27
  "dev": "vite build --watch",
25
28
  "test": "vitest run --passWithNoTests",
26
29
  "typecheck": "tsc -p tsconfig.json --noEmit"
27
- },
28
- "dependencies": {
29
- "@storix-js/core": "workspace:*"
30
30
  }
31
- }
31
+ }