chizu 0.2.8 → 0.2.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/chizu.js CHANGED
@@ -1,10 +1,10 @@
1
1
  var J = Object.defineProperty;
2
- var k = (t) => {
2
+ var D = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
5
  var q = (t, e, n) => e in t ? J(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
- var w = (t, e, n) => q(t, typeof e != "symbol" ? e + "" : e, n), D = (t, e, n) => e.has(t) || k("Cannot " + n);
7
- var E = (t, e, n) => (D(t, e, "read from private field"), n ? n.call(t) : e.get(t)), R = (t, e, n) => e.has(t) ? k("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), b = (t, e, n, r) => (D(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n);
6
+ var w = (t, e, n) => q(t, typeof e != "symbol" ? e + "" : e, n), k = (t, e, n) => e.has(t) || D("Cannot " + n);
7
+ var E = (t, e, n) => (k(t, e, "read from private field"), n ? n.call(t) : e.get(t)), R = (t, e, n) => e.has(t) ? D("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), b = (t, e, n, r) => (k(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n);
8
8
  import { jsx as p, Fragment as z } from "react/jsx-runtime";
9
9
  import { Immer as F } from "immer";
10
10
  import v from "lodash/get";
@@ -64,10 +64,10 @@ function C(t, e = []) {
64
64
  const o = S(t, e);
65
65
  if (!o) return !1;
66
66
  const u = new Set(
67
- o.flatMap((i) => i.operations)
67
+ o.flatMap((c) => c.operations)
68
68
  );
69
69
  return !!(Array.from(u).reduce(
70
- (i, d) => i | (d ?? 0),
70
+ (c, d) => c | (d ?? 0),
71
71
  0
72
72
  ) & s);
73
73
  };
@@ -106,17 +106,17 @@ function Q(t, e, n) {
106
106
  return;
107
107
  }
108
108
  if (this.node instanceof M) {
109
- const u = typeof this.node.value == "object", c = [
109
+ const u = typeof this.node.value == "object", i = [
110
110
  ...u ? this.path : this.path.slice(0, -1),
111
111
  l.annotations
112
- ], i = v(t.stateful, c) ?? [], d = this.node.attach(e);
112
+ ], c = v(t.stateful, i) ?? [], d = this.node.attach(e);
113
113
  u ? this.update(
114
114
  {
115
115
  ...this.node.value,
116
- [l.annotations]: [d, ...i]
116
+ [l.annotations]: [d, ...c]
117
117
  },
118
118
  !0
119
- ) : (this.parent && (this.parent.node[l.annotations] = [d, ...i]), this.update(this.node.value, !0));
119
+ ) : (this.parent && (this.parent.node[l.annotations] = [d, ...c]), this.update(this.node.value, !0));
120
120
  }
121
121
  });
122
122
  }
@@ -150,18 +150,20 @@ function W(t) {
150
150
  return (e, n) => async (r = Promise.withResolvers(), s) => {
151
151
  if (typeof n != "function") return;
152
152
  const o = Symbol("process"), u = n(...s);
153
+ if (u == null)
154
+ return void r.resolve();
153
155
  if (typeof u == "function") {
154
- const c = u(t.model.current, o);
155
- return t.model.current = A(c, o), t.update.rerender(), void r.resolve();
156
+ const i = u(t.model.current, o);
157
+ return t.model.current = A(i, o), t.update.rerender(), void r.resolve();
156
158
  }
157
159
  for (; ; ) {
158
- const { value: c, done: i } = await u.next();
159
- if (i) {
160
- const H = c(t.model.current, o);
160
+ const { value: i, done: c } = await u.next();
161
+ if (c) {
162
+ const H = i(t.model.current, o);
161
163
  t.model.current = A(H, o), t.update.rerender();
162
164
  break;
163
165
  }
164
- const d = c;
166
+ const d = i;
165
167
  t.model.current = d(t.model.current, o), t.update.rerender();
166
168
  }
167
169
  r.resolve();
@@ -301,12 +303,12 @@ function tt(t) {
301
303
  const r = new P(), s = e.appEmitter;
302
304
  return {
303
305
  attach(o, u) {
304
- const c = String(o);
305
- N(c) ? s.on(c, n(o, u)) : r.on(c, n(o, u));
306
- },
307
- dispatch(o, u, c) {
308
306
  const i = String(o);
309
- N(i) ? s.emit(i, c, u) : r.emit(i, c, u);
307
+ N(i) ? s.on(i, n(o, u)) : r.on(i, n(o, u));
308
+ },
309
+ dispatch(o, u, i) {
310
+ const c = String(o);
311
+ N(c) ? s.emit(c, i, u) : r.emit(c, i, u);
310
312
  }
311
313
  };
312
314
  }, []);
@@ -339,9 +341,9 @@ function st() {
339
341
  return a.useRef(null);
340
342
  }
341
343
  function ut({ using: t, children: e }) {
342
- return h.useInRouterContext() ? /* @__PURE__ */ p(ct, { using: t, children: e }) : e();
344
+ return h.useInRouterContext() ? /* @__PURE__ */ p(it, { using: t, children: e }) : e();
343
345
  }
344
- function ct({ using: t, children: e }) {
346
+ function it({ using: t, children: e }) {
345
347
  return t.current = {
346
348
  navigate: h.useNavigate(),
347
349
  location: h.useLocation(),
@@ -349,18 +351,18 @@ function ct({ using: t, children: e }) {
349
351
  search: h.useSearchParams()
350
352
  }, /* @__PURE__ */ p(z, { children: e() });
351
353
  }
352
- function it() {
354
+ function ct() {
353
355
  const [t, e] = a.useReducer((n) => n + 1, 0);
354
356
  return f(() => ({ hash: t, rerender: e }), [t]);
355
357
  }
356
358
  function at({
357
359
  options: t
358
360
  }) {
359
- const e = B(), n = it(), r = ot(), s = et(), o = st(), u = rt({ options: t }), c = tt({ app: e, options: t, update: n, model: u, queue: r }), i = Z({ app: e, options: t, model: u, dispatchers: c, router: o });
360
- return L({ options: t, dispatchers: c, actions: i }), nt({ options: t, dispatchers: c, elements: s, router: o }), f(() => a.createElement(t.name, {
361
+ const e = B(), n = ct(), r = ot(), s = et(), o = st(), u = rt({ options: t }), i = tt({ app: e, options: t, update: n, model: u, queue: r }), c = Z({ app: e, options: t, model: u, dispatchers: i, router: o });
362
+ return L({ options: t, dispatchers: i, actions: c }), nt({ options: t, dispatchers: i, elements: s, router: o }), f(() => a.createElement(t.name, {
361
363
  ref: s.customElement,
362
364
  style: { display: "contents" },
363
- children: /* @__PURE__ */ p(ut, { using: o, children: () => t.view(i.view) })
365
+ children: /* @__PURE__ */ p(ut, { using: o, children: () => t.view(c.view) })
364
366
  }), [n.hash]);
365
367
  }
366
368
  function lt(t) {
@@ -1 +1 @@
1
- (function(s,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react/jsx-runtime"),require("immer"),require("lodash/get"),require("traverse"),require("react"),require("eventemitter3"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","immer","lodash/get","traverse","react","eventemitter3","react-router-dom"],u):(s=typeof globalThis<"u"?globalThis:s||self,u(s.Chizu={},s.jsxRuntime,s.Immer,s.get,s.Traverse,s.React,s.EventEmitter3,s.ReactRouterDOM))})(this,function(s,u,l,m,S,F,E,$){"use strict";var me=Object.defineProperty;var H=s=>{throw TypeError(s)};var pe=(s,u,l)=>u in s?me(s,u,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[u]=l;var P=(s,u,l)=>pe(s,typeof u!="symbol"?u+"":u,l),J=(s,u,l)=>u.has(s)||H("Cannot "+l);var D=(s,u,l)=>(J(s,u,"read from private field"),l?l.call(s):u.get(s)),_=(s,u,l)=>u.has(s)?H("Cannot add the same private member more than once"):u instanceof WeakSet?u.add(s):u.set(s,l),k=(s,u,l,m)=>(J(s,u,"write to private field"),m?m.call(s,l):u.set(s,l),l);var w,b;function x(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const d=x(F),g=x($);class q{constructor(t){this.value=t}}class N{static Draft(t){return new q(t)}}P(N,"Op",{Add:1,Remove:2,Update:4,Move:8,Replace:16});var v=(e=>(e.Mount="lifecycle/mount",e.Node="lifecycle/node",e.Derive="lifecycle/derive",e.Error="distributed/lifecycle/error",e.Unmount="lifecycle/unmount",e))(v||{});const h={immer:new l.Immer,annotations:Symbol("annotations")};h.immer.setAutoFreeze(!1);class R{constructor(t,n,r=null){P(this,"process");this.value=t,this.operations=n,this.field=r,this.process=null}attach(t){return this.process=t,this}}function Q(e,t=[]){return new R(e,t)}class j{constructor(t,n=t){this.stateless=t,this.stateful=n}get validatable(){return T(this.stateful)}}function T(e,t=[]){return new Proxy(e,{get(n,r){switch(r){case"is":return c=>{const o=O(e,t);if(!o)return!1;const i=new Set(o.flatMap(f=>f.operations));return!!(Array.from(i).reduce((f,y)=>f|(y??0),0)&c)};case"pending":return()=>!!O(e,t);case"draft":return()=>{const c=O(e,t);if(!c)return m(e,t);const o=c.flatMap(i=>i.operations).find(i=>i instanceof q);return o?o.value:m(e,t)}}return T(e,[...t,String(r)])}})}function O(e,t){const r=typeof m(e,t)=="object"?t:t.slice(0,-1),c=r.length===0?e:m(e,r),o=(c==null?void 0:c[h.annotations])??[];return o.length>0?o:null}function W(e,t,n){function r(o){return S(o).forEach(function(){if(this.key===h.annotations){this.block();return}this.node instanceof R&&this.update(this.node.value)})}function c(o){return S(o).forEach(function(){if(this.key===h.annotations){this.block();return}if(this.node instanceof R){const i=typeof this.node.value=="object",a=[...i?this.path:this.path.slice(0,-1),h.annotations],f=m(e.stateful,a)??[],y=this.node.attach(t);i?this.update({...this.node.value,[h.annotations]:[y,...f]},!0):(this.parent&&(this.parent.node[h.annotations]=[y,...f]),this.update(this.node.value,!0))}})}return new j(r(h.immer.produce(e.stateless,n)),c(h.immer.produce(e.stateful,n)))}function A(e,t){const n=S(e.stateful).forEach(function(){if(this.key===h.annotations){this.block();return}if(this.node&&this.node[h.annotations]){const r=this.node[h.annotations];this.update({...this.node,[h.annotations]:r.filter(c=>c.process!==t)},!0)}});return new j(e.stateless,n)}function G(e){return(t,n)=>async(r=Promise.withResolvers(),c)=>{if(typeof n!="function")return;const o=Symbol("process"),i=n(...c);if(typeof i=="function"){const a=i(e.model.current,o);return e.model.current=A(a,o),e.update.rerender(),void r.resolve()}for(;;){const{value:a,done:f}=await i.next();if(f){const he=a(e.model.current,o);e.model.current=A(he,o),e.update.rerender();break}const y=a;e.model.current=y(e.model.current,o),e.update.rerender()}r.resolve()}}function C(e){return e.startsWith("distributed")}class I extends Error{constructor(n,r=null){super(String(r));_(this,w);_(this,b);k(this,w,n),k(this,b,r)}get type(){return D(this,w)}get message(){return D(this,b)||""}}w=new WeakMap,b=new WeakMap;function K(e){return new Promise(t=>setTimeout(t,e))}function V(e){return e?!!(e&&typeof e!="symbol"):Symbol(`pk.${Date.now()}.${crypto.randomUUID()}`)}function X(e){return e instanceof I}function M(e){return JSON.stringify(e)}const Y=Object.freeze(Object.defineProperty({__proto__:null,hash:M,isEventError:X,pk:V,sleep:K},Symbol.toStringTag,{value:"Module"}));function p(e,t){const n=d.useRef(null),r=d.useRef(null);return d.useMemo(()=>{const c=M(t);if(r.current!==c){r.current=c;const o=e();return n.current=o,o}return n.current},t)}function U(e,t){const n=d.useRef(null);d.useEffect(()=>{const r=M(t);if(n.current!==r)return n.current=r,e()},t)}const z=d.createContext({appEmitter:new E});function B(){return d.useContext(z)}function Z(e){return()=>{const t=p(()=>({appEmitter:new E}),[]);return u.jsx(z.Provider,{value:t,children:u.jsx(e,{})})}}function L(e){return p(()=>({controller:{get model(){return e.model.current.stateful},get router(){return e.router.current},queue:[],props:e.options.props,actions:{annotate(t,n){return Q(t,n)},produce(t){return(n,r)=>W(n,r,t)},dispatch([t,...n]){if(t==null)return Promise.reject();const r=Promise.withResolvers();return e.dispatchers.dispatch(t,n,r),r.promise}}},view:{get model(){return e.model.current.stateless},get validate(){return e.model.current.validatable},props:e.options.props,actions:{dispatch([t,...n]){if(t==null)return Promise.reject();const r=Promise.withResolvers();return e.dispatchers.dispatch(t,n,r),r.promise}}}}),[])}function ee(e){return p(()=>{var r,c;const t=(c=(r=e.options).controller)==null?void 0:c.call(r,e.actions.controller);return t?(Object.entries(t).forEach(([o,i])=>e.dispatchers.attach(o,i)),t):void 0},[])}function te(e){const t=B(),n=G(e);return p(()=>{const r=new E,c=t.appEmitter;return{attach(o,i){const a=String(o);C(a)?c.on(a,n(o,i)):r.on(a,n(o,i))},dispatch(o,i,a){const f=String(o);C(f)?c.emit(f,a,i):r.emit(f,a,i)}}},[])}function ne(){const e=d.useRef(null);return p(()=>({customElement:e}),[])}function re(e){var t,n,r,c;U(()=>{e.dispatchers.dispatch(v.Derive,[])},[e.options.props,(t=e.router.current)==null?void 0:t.location,(n=e.router.current)==null?void 0:n.params,(c=(r=e.router.current)==null?void 0:r.search)==null?void 0:c[0]]),U(()=>(e.dispatchers.dispatch(v.Mount,[]),e.dispatchers.dispatch(v.Node,[e.elements.customElement.current]),()=>e.dispatchers.dispatch(v.Unmount,[])),[])}function se(e){const t=p(()=>e.options.model??{},[]);return d.useRef(new j(t,t))}function oe(){return d.useRef(new Set)}function ue(){return d.useRef(null)}function ce({using:e,children:t}){return g.useInRouterContext()?u.jsx(ie,{using:e,children:t}):t()}function ie({using:e,children:t}){return e.current={navigate:g.useNavigate(),location:g.useLocation(),params:g.useParams(),search:g.useSearchParams()},u.jsx(u.Fragment,{children:t()})}function ae(){const[e,t]=d.useReducer(n=>n+1,0);return p(()=>({hash:e,rerender:t}),[e])}function le({options:e}){const t=B(),n=ae(),r=oe(),c=ne(),o=ue(),i=se({options:e}),a=te({app:t,options:e,update:n,model:i,queue:r}),f=L({app:t,options:e,model:i,dispatchers:a,router:o});return ee({options:e,dispatchers:a,actions:f}),re({options:e,dispatchers:a,elements:c,router:o}),p(()=>d.createElement(e.name,{ref:c.customElement,style:{display:"contents"},children:u.jsx(ce,{using:o,children:()=>e.view(f.view)})}),[n.hash])}function fe(e){return t=>d.memo(n=>le({options:{...t,name:e.join(""),props:n}}),(n,r)=>JSON.stringify(n)===JSON.stringify(r))}const de={app:Z,module:fe};s.EventError=I,s.Lifecycle=v,s.State=N,s.create=de,s.utils=Y,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react/jsx-runtime"),require("immer"),require("lodash/get"),require("traverse"),require("react"),require("eventemitter3"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","immer","lodash/get","traverse","react","eventemitter3","react-router-dom"],u):(s=typeof globalThis<"u"?globalThis:s||self,u(s.Chizu={},s.jsxRuntime,s.Immer,s.get,s.Traverse,s.React,s.EventEmitter3,s.ReactRouterDOM))})(this,function(s,u,l,m,S,F,E,$){"use strict";var me=Object.defineProperty;var H=s=>{throw TypeError(s)};var pe=(s,u,l)=>u in s?me(s,u,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[u]=l;var P=(s,u,l)=>pe(s,typeof u!="symbol"?u+"":u,l),J=(s,u,l)=>u.has(s)||H("Cannot "+l);var D=(s,u,l)=>(J(s,u,"read from private field"),l?l.call(s):u.get(s)),_=(s,u,l)=>u.has(s)?H("Cannot add the same private member more than once"):u instanceof WeakSet?u.add(s):u.set(s,l),x=(s,u,l,m)=>(J(s,u,"write to private field"),m?m.call(s,l):u.set(s,l),l);var w,b;function k(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const d=k(F),g=k($);class q{constructor(t){this.value=t}}class N{static Draft(t){return new q(t)}}P(N,"Op",{Add:1,Remove:2,Update:4,Move:8,Replace:16});var v=(e=>(e.Mount="lifecycle/mount",e.Node="lifecycle/node",e.Derive="lifecycle/derive",e.Error="distributed/lifecycle/error",e.Unmount="lifecycle/unmount",e))(v||{});const h={immer:new l.Immer,annotations:Symbol("annotations")};h.immer.setAutoFreeze(!1);class R{constructor(t,n,r=null){P(this,"process");this.value=t,this.operations=n,this.field=r,this.process=null}attach(t){return this.process=t,this}}function Q(e,t=[]){return new R(e,t)}class j{constructor(t,n=t){this.stateless=t,this.stateful=n}get validatable(){return T(this.stateful)}}function T(e,t=[]){return new Proxy(e,{get(n,r){switch(r){case"is":return c=>{const o=O(e,t);if(!o)return!1;const i=new Set(o.flatMap(f=>f.operations));return!!(Array.from(i).reduce((f,y)=>f|(y??0),0)&c)};case"pending":return()=>!!O(e,t);case"draft":return()=>{const c=O(e,t);if(!c)return m(e,t);const o=c.flatMap(i=>i.operations).find(i=>i instanceof q);return o?o.value:m(e,t)}}return T(e,[...t,String(r)])}})}function O(e,t){const r=typeof m(e,t)=="object"?t:t.slice(0,-1),c=r.length===0?e:m(e,r),o=(c==null?void 0:c[h.annotations])??[];return o.length>0?o:null}function W(e,t,n){function r(o){return S(o).forEach(function(){if(this.key===h.annotations){this.block();return}this.node instanceof R&&this.update(this.node.value)})}function c(o){return S(o).forEach(function(){if(this.key===h.annotations){this.block();return}if(this.node instanceof R){const i=typeof this.node.value=="object",a=[...i?this.path:this.path.slice(0,-1),h.annotations],f=m(e.stateful,a)??[],y=this.node.attach(t);i?this.update({...this.node.value,[h.annotations]:[y,...f]},!0):(this.parent&&(this.parent.node[h.annotations]=[y,...f]),this.update(this.node.value,!0))}})}return new j(r(h.immer.produce(e.stateless,n)),c(h.immer.produce(e.stateful,n)))}function A(e,t){const n=S(e.stateful).forEach(function(){if(this.key===h.annotations){this.block();return}if(this.node&&this.node[h.annotations]){const r=this.node[h.annotations];this.update({...this.node,[h.annotations]:r.filter(c=>c.process!==t)},!0)}});return new j(e.stateless,n)}function G(e){return(t,n)=>async(r=Promise.withResolvers(),c)=>{if(typeof n!="function")return;const o=Symbol("process"),i=n(...c);if(i==null)return void r.resolve();if(typeof i=="function"){const a=i(e.model.current,o);return e.model.current=A(a,o),e.update.rerender(),void r.resolve()}for(;;){const{value:a,done:f}=await i.next();if(f){const he=a(e.model.current,o);e.model.current=A(he,o),e.update.rerender();break}const y=a;e.model.current=y(e.model.current,o),e.update.rerender()}r.resolve()}}function C(e){return e.startsWith("distributed")}class I extends Error{constructor(n,r=null){super(String(r));_(this,w);_(this,b);x(this,w,n),x(this,b,r)}get type(){return D(this,w)}get message(){return D(this,b)||""}}w=new WeakMap,b=new WeakMap;function K(e){return new Promise(t=>setTimeout(t,e))}function V(e){return e?!!(e&&typeof e!="symbol"):Symbol(`pk.${Date.now()}.${crypto.randomUUID()}`)}function X(e){return e instanceof I}function M(e){return JSON.stringify(e)}const Y=Object.freeze(Object.defineProperty({__proto__:null,hash:M,isEventError:X,pk:V,sleep:K},Symbol.toStringTag,{value:"Module"}));function p(e,t){const n=d.useRef(null),r=d.useRef(null);return d.useMemo(()=>{const c=M(t);if(r.current!==c){r.current=c;const o=e();return n.current=o,o}return n.current},t)}function U(e,t){const n=d.useRef(null);d.useEffect(()=>{const r=M(t);if(n.current!==r)return n.current=r,e()},t)}const z=d.createContext({appEmitter:new E});function B(){return d.useContext(z)}function Z(e){return()=>{const t=p(()=>({appEmitter:new E}),[]);return u.jsx(z.Provider,{value:t,children:u.jsx(e,{})})}}function L(e){return p(()=>({controller:{get model(){return e.model.current.stateful},get router(){return e.router.current},queue:[],props:e.options.props,actions:{annotate(t,n){return Q(t,n)},produce(t){return(n,r)=>W(n,r,t)},dispatch([t,...n]){if(t==null)return Promise.reject();const r=Promise.withResolvers();return e.dispatchers.dispatch(t,n,r),r.promise}}},view:{get model(){return e.model.current.stateless},get validate(){return e.model.current.validatable},props:e.options.props,actions:{dispatch([t,...n]){if(t==null)return Promise.reject();const r=Promise.withResolvers();return e.dispatchers.dispatch(t,n,r),r.promise}}}}),[])}function ee(e){return p(()=>{var r,c;const t=(c=(r=e.options).controller)==null?void 0:c.call(r,e.actions.controller);return t?(Object.entries(t).forEach(([o,i])=>e.dispatchers.attach(o,i)),t):void 0},[])}function te(e){const t=B(),n=G(e);return p(()=>{const r=new E,c=t.appEmitter;return{attach(o,i){const a=String(o);C(a)?c.on(a,n(o,i)):r.on(a,n(o,i))},dispatch(o,i,a){const f=String(o);C(f)?c.emit(f,a,i):r.emit(f,a,i)}}},[])}function ne(){const e=d.useRef(null);return p(()=>({customElement:e}),[])}function re(e){var t,n,r,c;U(()=>{e.dispatchers.dispatch(v.Derive,[])},[e.options.props,(t=e.router.current)==null?void 0:t.location,(n=e.router.current)==null?void 0:n.params,(c=(r=e.router.current)==null?void 0:r.search)==null?void 0:c[0]]),U(()=>(e.dispatchers.dispatch(v.Mount,[]),e.dispatchers.dispatch(v.Node,[e.elements.customElement.current]),()=>e.dispatchers.dispatch(v.Unmount,[])),[])}function se(e){const t=p(()=>e.options.model??{},[]);return d.useRef(new j(t,t))}function oe(){return d.useRef(new Set)}function ue(){return d.useRef(null)}function ce({using:e,children:t}){return g.useInRouterContext()?u.jsx(ie,{using:e,children:t}):t()}function ie({using:e,children:t}){return e.current={navigate:g.useNavigate(),location:g.useLocation(),params:g.useParams(),search:g.useSearchParams()},u.jsx(u.Fragment,{children:t()})}function ae(){const[e,t]=d.useReducer(n=>n+1,0);return p(()=>({hash:e,rerender:t}),[e])}function le({options:e}){const t=B(),n=ae(),r=oe(),c=ne(),o=ue(),i=se({options:e}),a=te({app:t,options:e,update:n,model:i,queue:r}),f=L({app:t,options:e,model:i,dispatchers:a,router:o});return ee({options:e,dispatchers:a,actions:f}),re({options:e,dispatchers:a,elements:c,router:o}),p(()=>d.createElement(e.name,{ref:c.customElement,style:{display:"contents"},children:u.jsx(ce,{using:o,children:()=>e.view(f.view)})}),[n.hash])}function fe(e){return t=>d.memo(n=>le({options:{...t,name:e.join(""),props:n}}),(n,r)=>JSON.stringify(n)===JSON.stringify(r))}const de={app:Z,module:fe};s.EventError=I,s.Lifecycle=v,s.State=N,s.create=de,s.utils=Y,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
@@ -19,7 +19,7 @@ export type ActionEvent<M extends ModuleDefinition> = (...args: M["Actions"][num
19
19
  type ActionEvents<M extends ModuleDefinition> = {
20
20
  [K in Head<M["Actions"]>]: (payload: Payload<M["Actions"], K>) => ActionGenerator<M>;
21
21
  };
22
- export type ActionGenerator<M extends ModuleDefinition> = ((models: Models<M["Model"]>, process: Symbol) => Models<M["Model"]>) | AsyncGenerator<(models: Models<M["Model"]>, process: Symbol) => Models<M["Model"]>, (models: Models<M["Model"]>, process: Symbol) => Models<M["Model"]>, unknown>;
22
+ export type ActionGenerator<M extends ModuleDefinition> = void | ((models: Models<M["Model"]>, process: Symbol) => Models<M["Model"]>) | AsyncGenerator<(models: Models<M["Model"]>, process: Symbol) => Models<M["Model"]>, (models: Models<M["Model"]>, process: Symbol) => Models<M["Model"]>, unknown>;
23
23
  export type ControllerDefinition<M extends ModuleDefinition> = (controller: ControllerArgs<M>) => ControllerInstance<M>;
24
24
  export type ControllerInstance<M extends ModuleDefinition> = {
25
25
  [Lifecycle.Mount]?(): ActionGenerator<M>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chizu",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "type": "module",
5
5
  "main": "./dist/chizu.js",
6
6
  "types": "./dist/index.d.ts",