chizu 0.2.24 → 0.2.25

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
@@ -246,3 +246,27 @@ export default <Actions<Module>>function Actions(module) {
246
246
  };
247
247
  };
248
248
  ```
249
+
250
+ If you need the context values to be reactive and fire the `Lifecycle.Derive` method then simply add it to your `props` definition when you initialise your scoped component:
251
+
252
+ ```tsx
253
+ export default function Profile(props: Props): React.ReactElement {
254
+ const name = React.useContext(NameContext);
255
+
256
+ return (
257
+ <Scope<Module> using={{ model, actions, props: { ...props, name } }}>
258
+ {(module) => (
259
+ <>
260
+ <p>Hey {module.model.name}</p>
261
+
262
+ <button
263
+ onClick={() => module.actions.dispatch([Action.Name, randomName()])}
264
+ >
265
+ Switch profile
266
+ </button>
267
+ </>
268
+ )}
269
+ </Scope>
270
+ );
271
+ }
272
+ ```
package/dist/chizu.js CHANGED
@@ -1,231 +1,231 @@
1
1
  var Q = Object.defineProperty;
2
- var U = (t) => {
3
- throw TypeError(t);
2
+ var _ = (e) => {
3
+ throw TypeError(e);
4
4
  };
5
- var W = (t, e, n) => e in t ? Q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
- var w = (t, e, n) => W(t, typeof e != "symbol" ? e + "" : e, n), _ = (t, e, n) => e.has(t) || U("Cannot " + n);
7
- var g = (t, e, n) => (_(t, e, "read from private field"), n ? n.call(t) : e.get(t)), x = (t, e, n) => e.has(t) ? U("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), R = (t, e, n, r) => (_(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n);
5
+ var W = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
+ var g = (e, t, n) => W(e, typeof t != "symbol" ? t + "" : t, n), A = (e, t, n) => t.has(e) || _("Cannot " + n);
7
+ var x = (e, t, n) => (A(e, t, "read from private field"), n ? n.call(e) : t.get(e)), R = (e, t, n) => t.has(e) ? _("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), S = (e, t, n, r) => (A(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n);
8
8
  import { jsx as C } from "react/jsx-runtime";
9
- import * as u from "react";
9
+ import * as c from "react";
10
10
  import { useRef as B } from "react";
11
- import k from "eventemitter3";
11
+ import M from "eventemitter3";
12
12
  import { Immer as G, enablePatches as K } from "immer";
13
13
  import m from "lodash/get";
14
- import P from "traverse";
14
+ import D from "traverse";
15
15
  class H {
16
- constructor(e) {
17
- this.value = e;
16
+ constructor(t) {
17
+ this.value = t;
18
18
  }
19
19
  }
20
20
  class V {
21
- static Draft(e) {
22
- return new H(e);
21
+ static Draft(t) {
22
+ return new H(t);
23
23
  }
24
24
  }
25
- w(V, "Op", {
25
+ g(V, "Op", {
26
26
  Add: 1,
27
27
  Remove: 2,
28
28
  Update: 4,
29
29
  Move: 8,
30
30
  Replace: 16
31
31
  });
32
- var h = /* @__PURE__ */ ((t) => (t.Mount = "lifecycle/mount", t.Node = "lifecycle/node", t.Derive = "lifecycle/derive", t.Error = "lifecycle/error", t.Unmount = "lifecycle/unmount", t))(h || {}), M = /* @__PURE__ */ ((t) => (t[t.Default = 0] = "Default", t[t.Error = 1] = "Error", t))(M || {});
33
- function X(t) {
34
- return new Promise((e) => setTimeout(e, t));
32
+ var h = /* @__PURE__ */ ((e) => (e.Mount = "lifecycle/mount", e.Node = "lifecycle/node", e.Derive = "lifecycle/derive", e.Error = "lifecycle/error", e.Unmount = "lifecycle/unmount", e))(h || {}), O = /* @__PURE__ */ ((e) => (e[e.Default = 0] = "Default", e[e.Error = 1] = "Error", e))(O || {});
33
+ function X(e) {
34
+ return new Promise((t) => setTimeout(t, e));
35
35
  }
36
- function Y(t) {
37
- return t ? !!(t && typeof t != "symbol") : Symbol(`pk.${Date.now()}.${crypto.randomUUID()}`);
36
+ function Y(e) {
37
+ return e ? !!(e && typeof e != "symbol") : Symbol(`pk.${Date.now()}.${crypto.randomUUID()}`);
38
38
  }
39
- function b(t) {
40
- return JSON.stringify(t);
39
+ function w(e) {
40
+ return JSON.stringify(e);
41
41
  }
42
- const E = Symbol("meta"), gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
42
+ const E = Symbol("meta"), ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
43
43
  __proto__: null,
44
- hash: b,
44
+ hash: w,
45
45
  meta: E,
46
46
  pk: Y,
47
47
  sleep: X
48
48
  }, Symbol.toStringTag, { value: "Module" }));
49
- function f(t, e) {
50
- const n = u.useRef(null), r = u.useRef(null);
51
- return u.useMemo(() => {
52
- const s = b(e);
49
+ function f(e, t) {
50
+ const n = c.useRef(null), r = c.useRef(null);
51
+ return c.useMemo(() => {
52
+ const s = w(t);
53
53
  if (r.current !== s) {
54
54
  r.current = s;
55
- const o = t();
55
+ const o = e();
56
56
  return n.current = o, o;
57
57
  }
58
58
  return n.current;
59
- }, e);
59
+ }, t);
60
60
  }
61
- function A(t, e) {
62
- const n = u.useRef(null);
63
- u.useEffect(() => {
64
- const r = b(e);
61
+ function k(e, t) {
62
+ const n = c.useRef(null);
63
+ c.useEffect(() => {
64
+ const r = w(t);
65
65
  if (n.current !== r)
66
- return n.current = r, t();
67
- }, e);
66
+ return n.current = r, e();
67
+ }, t);
68
68
  }
69
- const T = u.createContext({
70
- instance: new k()
69
+ const T = c.createContext({
70
+ instance: new M()
71
71
  });
72
72
  function $() {
73
- return u.useContext(T);
73
+ return c.useContext(T);
74
74
  }
75
- function xt({ children: t }) {
76
- const e = f(
75
+ function xe({ children: e }) {
76
+ const t = f(
77
77
  () => ({
78
- instance: new k()
78
+ instance: new M()
79
79
  }),
80
80
  []
81
81
  );
82
- return /* @__PURE__ */ C(T.Provider, { value: e, children: t });
82
+ return /* @__PURE__ */ C(T.Provider, { value: t, children: e });
83
83
  }
84
- const a = {
84
+ const l = {
85
85
  immer: new G(),
86
86
  annotations: Symbol("annotations")
87
87
  };
88
88
  K();
89
- a.immer.setAutoFreeze(!1);
89
+ l.immer.setAutoFreeze(!1);
90
90
  class j {
91
- constructor(e, n, r = null) {
92
- w(this, "process");
93
- this.value = e, this.operations = n, this.field = r, this.process = null;
91
+ constructor(t, n, r = null) {
92
+ g(this, "process");
93
+ this.value = t, this.operations = n, this.field = r, this.process = null;
94
94
  }
95
- attach(e) {
96
- return this.process = e, this;
95
+ attach(t) {
96
+ return this.process = t, this;
97
97
  }
98
98
  }
99
- function Z(t, e = []) {
100
- return new j(t, e);
99
+ function Z(e, t = []) {
100
+ return new j(e, t);
101
101
  }
102
- class O {
103
- constructor(e, n = e) {
104
- this.stateless = e, this.stateful = n;
102
+ class U {
103
+ constructor(t, n = t) {
104
+ this.stateless = t, this.stateful = n;
105
105
  }
106
106
  get validatable() {
107
107
  return z(this.stateful);
108
108
  }
109
109
  }
110
- function z(t, e = []) {
111
- return new Proxy(t, {
110
+ function z(e, t = []) {
111
+ return new Proxy(e, {
112
112
  get(n, r) {
113
113
  switch (r) {
114
114
  case "is":
115
115
  return (s) => {
116
- const o = S(t, e);
116
+ const o = P(e, t);
117
117
  if (!o) return !1;
118
- const c = new Set(
119
- o.flatMap((l) => l.operations)
118
+ const u = new Set(
119
+ o.flatMap((d) => d.operations)
120
120
  );
121
- return !!(Array.from(c).reduce(
122
- (l, d) => l | (d ?? 0),
121
+ return !!(Array.from(u).reduce(
122
+ (d, a) => d | (a ?? 0),
123
123
  0
124
124
  ) & s);
125
125
  };
126
126
  case "pending":
127
- return () => !!S(t, e);
127
+ return () => !!P(e, t);
128
128
  case "draft":
129
129
  return () => {
130
- const s = S(t, e);
131
- if (!s) return m(t, e);
132
- const o = s.flatMap((c) => c.operations).find((c) => c instanceof H);
133
- return o ? o.value : m(t, e);
130
+ const s = P(e, t);
131
+ if (!s) return m(e, t);
132
+ const o = s.flatMap((u) => u.operations).find((u) => u instanceof H);
133
+ return o ? o.value : m(e, t);
134
134
  };
135
135
  }
136
- return z(t, [...e, String(r)]);
136
+ return z(e, [...t, String(r)]);
137
137
  }
138
138
  });
139
139
  }
140
- function S(t, e) {
141
- const r = typeof m(t, e) == "object" ? e : e.slice(0, -1), s = r.length === 0 ? t : m(t, r), o = (s == null ? void 0 : s[a.annotations]) ?? [];
140
+ function P(e, t) {
141
+ const r = typeof m(e, t) == "object" ? t : t.slice(0, -1), s = r.length === 0 ? e : m(e, r), o = (s == null ? void 0 : s[l.annotations]) ?? [];
142
142
  return o.length > 0 ? o : null;
143
143
  }
144
- function q(t, e, n) {
145
- function r(c) {
146
- return P(c).forEach(function() {
147
- if (this.key === a.annotations) {
144
+ function q(e, t, n) {
145
+ function r(u) {
146
+ return D(u).forEach(function() {
147
+ if (this.key === l.annotations) {
148
148
  this.block();
149
149
  return;
150
150
  }
151
151
  this.node instanceof j && this.update(this.node.value);
152
152
  });
153
153
  }
154
- function s(c) {
155
- return P(c).forEach(function() {
156
- if (this.key === a.annotations) {
154
+ function s(u) {
155
+ return D(u).forEach(function() {
156
+ if (this.key === l.annotations) {
157
157
  this.block();
158
158
  return;
159
159
  }
160
160
  if (this.node instanceof j) {
161
- const i = typeof this.node.value == "object", l = [
161
+ const i = typeof this.node.value == "object", d = [
162
162
  ...i ? this.path : this.path.slice(0, -1),
163
- a.annotations
164
- ], d = m(t.stateful, l) ?? [], y = this.node.attach(e);
163
+ l.annotations
164
+ ], a = m(e.stateful, d) ?? [], y = this.node.attach(t);
165
165
  i ? this.update(
166
166
  {
167
167
  ...this.node.value,
168
- [a.annotations]: [y, ...d]
168
+ [l.annotations]: [y, ...a]
169
169
  },
170
170
  !0
171
- ) : (this.parent && (this.parent.node[a.annotations] = [y, ...d]), this.update(this.node.value, !0));
171
+ ) : (this.parent && (this.parent.node[l.annotations] = [y, ...a]), this.update(this.node.value, !0));
172
172
  }
173
173
  });
174
174
  }
175
- const o = (c) => n(c, c[E]);
176
- return new O(
177
- r(a.immer.produce(t.stateless, o)),
178
- s(a.immer.produce(t.stateful, o))
175
+ const o = (u) => n(u, u[E]);
176
+ return new U(
177
+ r(l.immer.produce(e.stateless, o)),
178
+ s(l.immer.produce(e.stateful, o))
179
179
  );
180
180
  }
181
- function D(t, e) {
182
- const n = P(t.stateful).forEach(function() {
183
- if (this.key === a.annotations) {
181
+ function b(e, t) {
182
+ const n = D(e.stateful).forEach(function() {
183
+ if (this.key === l.annotations) {
184
184
  this.block();
185
185
  return;
186
186
  }
187
- if (this.node && this.node[a.annotations]) {
188
- const r = this.node[a.annotations];
187
+ if (this.node && this.node[l.annotations]) {
188
+ const r = this.node[l.annotations];
189
189
  this.update(
190
190
  {
191
191
  ...this.node,
192
- [a.annotations]: r.filter(
193
- (s) => s.process !== e
192
+ [l.annotations]: r.filter(
193
+ (s) => s.process !== t
194
194
  )
195
195
  },
196
196
  !0
197
197
  );
198
198
  }
199
199
  });
200
- return new O(t.stateless, n);
200
+ return new U(e.stateless, n);
201
201
  }
202
- function L(t) {
202
+ function L(e) {
203
203
  return f(
204
204
  () => ({
205
205
  controller: {
206
206
  get model() {
207
- return t.model.current.stateful;
207
+ return e.model.current.stateful;
208
208
  },
209
209
  queue: [],
210
210
  actions: {
211
- annotate(e, n) {
212
- return Z(e, n);
211
+ annotate(t, n) {
212
+ return Z(t, n);
213
213
  },
214
- produce(e) {
215
- return (n, r) => q(n, r, e);
214
+ produce(t) {
215
+ return (n, r) => q(n, r, t);
216
216
  },
217
- dispatch([e, ...n]) {
218
- if (e == null) return Promise.reject();
217
+ dispatch([t, ...n]) {
218
+ if (t == null) return Promise.reject();
219
219
  const r = Promise.withResolvers();
220
- return t.dispatchers.dispatch(e, n, r), r.promise;
220
+ return e.dispatchers.dispatch(t, n, r), r.promise;
221
221
  },
222
- context(e) {
223
- const n = Object.keys(e);
224
- return t.context.use.current = e, t.context.update(), n.reduce(
222
+ context(t) {
223
+ const n = Object.keys(t);
224
+ return e.context.use.current = t, e.context.update(), n.reduce(
225
225
  (r, s) => ({
226
226
  ...r,
227
227
  get [s]() {
228
- return t.context.values.current[s];
228
+ return e.context.values.current[s];
229
229
  }
230
230
  }),
231
231
  {}
@@ -235,21 +235,21 @@ function L(t) {
235
235
  },
236
236
  view: {
237
237
  get model() {
238
- return t.model.current.stateless;
238
+ return e.model.current.stateless;
239
239
  },
240
240
  get validate() {
241
- return t.model.current.validatable;
241
+ return e.model.current.validatable;
242
242
  },
243
243
  boundary: {
244
- is(e) {
245
- return t.model.current.stateless[E].boundary === e;
244
+ is(t) {
245
+ return e.model.current.stateless[E].boundary === t;
246
246
  }
247
247
  },
248
248
  actions: {
249
- dispatch([e, ...n]) {
250
- if (e == null) return Promise.reject();
249
+ dispatch([t, ...n]) {
250
+ if (t == null) return Promise.reject();
251
251
  const r = Promise.withResolvers();
252
- return t.dispatchers.dispatch(e, n, r), r.promise;
252
+ return e.dispatchers.dispatch(t, n, r), r.promise;
253
253
  }
254
254
  }
255
255
  }
@@ -257,188 +257,191 @@ function L(t) {
257
257
  []
258
258
  );
259
259
  }
260
- function tt(t) {
261
- const e = B(null);
262
- return e.current == null && (e.current = t.options.using.actions(t.actions.controller)), f(() => {
263
- if (e.current)
264
- return Object.entries(e.current).forEach(([r, s]) => t.dispatchers.attach(r, s)), e.current;
260
+ function ee(e) {
261
+ const t = B(null);
262
+ return t.current == null && (t.current = e.options.using.actions(e.actions.controller)), f(() => {
263
+ if (t.current)
264
+ return Object.entries(t.current).forEach(([r, s]) => e.dispatchers.attach(r, s)), t.current;
265
265
  }, []);
266
266
  }
267
- function N(t) {
268
- return t.startsWith("distributed");
267
+ function N(e) {
268
+ return e.startsWith("distributed");
269
269
  }
270
- function Rt(t) {
271
- return t instanceof F;
270
+ function Re(e) {
271
+ return e instanceof F;
272
272
  }
273
- function I(t) {
274
- return t instanceof F || t instanceof Error ? t : new Error("Unknown error", { cause: t });
273
+ function I(e) {
274
+ return e instanceof F || e instanceof Error ? e : new Error("Unknown error", { cause: e });
275
275
  }
276
- var p, v;
276
+ var v, p;
277
277
  class F extends Error {
278
278
  constructor(n, r = null) {
279
279
  super(String(r));
280
- x(this, p);
281
- x(this, v);
282
- R(this, p, n), R(this, v, r);
280
+ R(this, v);
281
+ R(this, p);
282
+ S(this, v, n), S(this, p, r);
283
283
  }
284
284
  get type() {
285
- return g(this, p);
285
+ return x(this, v);
286
286
  }
287
287
  get message() {
288
- return g(this, v) || "";
288
+ return x(this, p) || "";
289
289
  }
290
290
  }
291
- p = new WeakMap(), v = new WeakMap();
292
- function et({
293
- children: t
291
+ v = new WeakMap(), p = new WeakMap();
292
+ function te({
293
+ children: e
294
294
  }) {
295
- return t();
295
+ return e();
296
296
  }
297
- function nt(t) {
298
- return (e, n) => async (r = Promise.withResolvers(), s) => {
299
- if (typeof n != "function") return;
300
- const o = Symbol("process"), c = n(...s);
297
+ function ne(e) {
298
+ return (t, n) => async (r = Promise.withResolvers(), s) => {
299
+ if (typeof n != "function") return void r.resolve();
300
+ const o = Symbol("process"), u = n(...s);
301
301
  try {
302
- if (c == null) return;
303
- if (typeof c == "function") {
304
- const i = c(t.model.current, o);
305
- t.model.current = D(i, o), t.update.rerender(), r.resolve();
306
- return;
302
+ if (u == null) return void r.resolve();
303
+ if (typeof u == "function") {
304
+ const i = u(e.model.current, o);
305
+ return e.model.current = b(i, o), e.update.rerender(), void r.resolve();
307
306
  }
308
307
  for (; ; ) {
309
- const { value: i, done: l } = await c.next();
310
- if (l) {
311
- const y = i(t.model.current, o);
312
- t.model.current = D(y, o), t.update.rerender();
313
- break;
308
+ if (u instanceof Promise) {
309
+ const a = await u;
310
+ if (a == null) return void r.resolve();
311
+ const y = a(e.model.current, o);
312
+ return e.model.current = b(y, o), e.update.rerender(), void r.resolve();
313
+ }
314
+ const { value: i, done: d } = await u.next();
315
+ if (d) {
316
+ const a = i(e.model.current, o);
317
+ return e.model.current = b(a, o), e.update.rerender(), void r.resolve();
314
318
  }
315
- const d = i;
316
- t.model.current = d(t.model.current, o), t.update.rerender(), r.resolve();
319
+ e.model.current = i(e.model.current, o), e.update.rerender();
317
320
  }
318
321
  } catch (i) {
319
- D(t.model.current, o), t.update.rerender(), t.unicast.emit(h.Error, r, [I(i)]);
322
+ b(e.model.current, o), e.update.rerender(), e.unicast.emit(h.Error, r, [I(i)]);
320
323
  }
321
324
  };
322
325
  }
323
- function rt(t) {
324
- const e = $(), n = f(() => new k(), []), r = nt({ ...t, unicast: n });
326
+ function re(e) {
327
+ const t = $(), n = f(() => new M(), []), r = ne({ ...e, unicast: n });
325
328
  return f(() => ({
326
329
  attach(s, o) {
327
- const c = String(s);
328
- N(c) ? e.instance.on(c, r(s, o)) : n.on(c, r(s, o));
330
+ const u = String(s);
331
+ N(u) ? t.instance.on(u, r(s, o)) : n.on(u, r(s, o));
329
332
  },
330
- dispatch(s, o, c) {
333
+ dispatch(s, o, u) {
331
334
  const i = String(s);
332
- N(i) ? e.instance.emit(i, c, o) : n.emit(i, c, o);
335
+ N(i) ? t.instance.emit(i, u, o) : n.emit(i, u, o);
333
336
  }
334
337
  }), []);
335
338
  }
336
- function st() {
337
- const t = u.useRef(null);
338
- return f(() => ({ customElement: t }), []);
339
+ function se() {
340
+ const e = c.useRef(null);
341
+ return f(() => ({ customElement: e }), []);
339
342
  }
340
- function ot(t) {
341
- A(() => {
342
- t.dispatchers.dispatch(h.Derive, []);
343
- }, [t.options.using.props]), A(() => (t.dispatchers.dispatch(h.Mount, []), t.dispatchers.dispatch(h.Node, [
344
- t.elements.customElement.current
345
- ]), () => t.dispatchers.dispatch(h.Unmount, [])), []);
343
+ function oe(e) {
344
+ k(() => {
345
+ e.dispatchers.dispatch(h.Derive, []);
346
+ }, [e.options.using.props]), k(() => (e.dispatchers.dispatch(h.Mount, []), e.dispatchers.dispatch(h.Node, [
347
+ e.elements.customElement.current
348
+ ]), () => e.dispatchers.dispatch(h.Unmount, [])), []);
346
349
  }
347
- function ct(t) {
348
- const e = f(() => ({ ...t.options.using.model ?? {}, [E]: { boundary: M.Default } }), []);
349
- return u.useRef(new O(e, e));
350
+ function ue(e) {
351
+ const t = f(() => ({ ...e.options.using.model ?? {}, [E]: { boundary: O.Default } }), []);
352
+ return c.useRef(new U(t, t));
350
353
  }
351
- function ut() {
352
- return u.useRef(/* @__PURE__ */ new Set());
354
+ function ce() {
355
+ return c.useRef(/* @__PURE__ */ new Set());
353
356
  }
354
- function it() {
355
- const [t, e] = u.useReducer((n) => n + 1, 0);
356
- return f(() => ({ hash: t, rerender: e }), [t]);
357
+ function ie() {
358
+ const [e, t] = c.useReducer((n) => n + 1, 0);
359
+ return f(() => ({ hash: e, rerender: t }), [e]);
357
360
  }
358
- const at = {
361
+ const ae = {
359
362
  elementName: "x-chizu"
360
- }, J = u.createContext(
363
+ }, J = c.createContext(
361
364
  null
362
365
  );
363
- function St() {
364
- const t = u.useContext(J);
365
- if (!t)
366
+ function Se() {
367
+ const e = c.useContext(J);
368
+ if (!e)
366
369
  throw new Error("useScoped is not being used within a scoped module.");
367
- return t;
370
+ return e;
368
371
  }
369
- class lt extends u.Component {
370
- constructor(e) {
371
- super(e), this.state = { error: null };
372
+ class le extends c.Component {
373
+ constructor(t) {
374
+ super(t), this.state = { error: null };
372
375
  }
373
- componentDidCatch(e) {
376
+ componentDidCatch(t) {
374
377
  const n = Symbol("process"), r = q(this.props.model.current, n, (s, o) => {
375
- o.boundary = M.Error;
378
+ o.boundary = O.Error;
376
379
  });
377
- this.props.model.current = r, this.props.update.rerender(), this.props.dispatchers.dispatch(h.Error, [I(e)]);
380
+ this.props.model.current = r, this.props.update.rerender(), this.props.dispatchers.dispatch(h.Error, [I(t)]);
378
381
  }
379
382
  render() {
380
- return /* @__PURE__ */ C(et, { children: this.props.children });
383
+ return /* @__PURE__ */ C(te, { children: this.props.children });
381
384
  }
382
385
  }
383
- function dt() {
384
- const t = u.useRef({}), e = u.useRef({});
386
+ function de() {
387
+ const e = c.useRef({}), t = c.useRef({});
385
388
  function n() {
386
- e.current = Object.fromEntries(
387
- Object.entries(t.current).map(([r, s]) => [r, u.use(s)])
389
+ t.current = Object.fromEntries(
390
+ Object.entries(e.current).map(([r, s]) => [r, c.use(s)])
388
391
  );
389
392
  }
390
- return n(), f(() => ({ use: t, values: e, update: n }), []);
393
+ return n(), f(() => ({ use: e, values: t, update: n }), []);
391
394
  }
392
- function ft() {
395
+ function fe() {
393
396
  return B(0);
394
397
  }
395
- function ht({
396
- options: t
398
+ function he({
399
+ options: e
397
400
  }) {
398
- const e = it(), n = ut(), r = ft(), s = st(), o = $(), c = dt(), i = ct({ options: t }), l = rt({
401
+ const t = ie(), n = ce(), r = fe(), s = se(), o = $(), u = de(), i = ue({ options: e }), d = re({
399
402
  broadcast: o,
400
- options: t,
401
- update: e,
403
+ options: e,
404
+ update: t,
402
405
  model: i,
403
406
  queue: n
404
- }), d = L({
407
+ }), a = L({
405
408
  model: i,
406
- dispatchers: l,
407
- context: c
409
+ dispatchers: d,
410
+ context: u
408
411
  });
409
- return tt({ options: t, dispatchers: l, actions: d }), ot({ options: t, dispatchers: l, elements: s }), f(() => u.createElement(lt, {
412
+ return ee({ options: e, dispatchers: d, actions: a }), oe({ options: e, dispatchers: d, elements: s }), f(() => c.createElement(le, {
410
413
  model: i,
411
- dispatchers: l,
412
- update: e,
413
- module: d.view,
414
+ dispatchers: d,
415
+ update: t,
416
+ module: a.view,
414
417
  children() {
415
- return u.createElement(J.Provider, {
416
- value: d.view,
418
+ return c.createElement(J.Provider, {
419
+ value: a.view,
417
420
  // eslint-disable-next-line react/no-children-prop
418
- children: u.createElement(at.elementName, {
421
+ children: c.createElement(ae.elementName, {
419
422
  ref: s.customElement,
420
423
  style: { display: "contents" },
421
- children: t.children(d.view)
424
+ children: e.children(a.view)
422
425
  })
423
426
  });
424
427
  }
425
428
  }), [
426
- e.hash,
427
- b(t.using.props),
428
- t.passive ? r.current++ : 0
429
+ t.hash,
430
+ w(e.using.props),
431
+ e.passive ? r.current++ : 0
429
432
  ]);
430
433
  }
431
- function Dt(t) {
432
- return /* @__PURE__ */ C(ht, { options: t });
434
+ function Pe(e) {
435
+ return /* @__PURE__ */ C(he, { options: e });
433
436
  }
434
437
  export {
435
- M as Boundary,
436
- xt as Broadcaster,
438
+ O as Boundary,
439
+ xe as Broadcaster,
437
440
  h as Lifecycle,
438
- Dt as Scope,
441
+ Pe as Scope,
439
442
  V as State,
440
443
  F as TypedError,
441
- Rt as isTypedError,
442
- St as useScoped,
443
- gt as utils
444
+ Re as isTypedError,
445
+ Se as useScoped,
446
+ ge as utils
444
447
  };
@@ -1 +1 @@
1
- (function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react/jsx-runtime"),require("react"),require("eventemitter3"),require("immer"),require("lodash/get"),require("traverse")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","eventemitter3","immer","lodash/get","traverse"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.Chizu={},s.jsxRuntime,s.React,s.EventEmitter3,s.Immer,s.get,s.Traverse))})(this,function(s,c,l,y,U,b,O){"use strict";var be=Object.defineProperty;var W=s=>{throw TypeError(s)};var we=(s,c,l)=>c in s?be(s,c,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[c]=l;var k=(s,c,l)=>we(s,typeof c!="symbol"?c+"":c,l),G=(s,c,l)=>c.has(s)||W("Cannot "+l);var T=(s,c,l)=>(G(s,c,"read from private field"),l?l.call(s):c.get(s)),_=(s,c,l)=>c.has(s)?W("Cannot add the same private member more than once"):c instanceof WeakSet?c.add(s):c.set(s,l),q=(s,c,l,y)=>(G(s,c,"write to private field"),y?y.call(s,l):c.set(s,l),l);var w,E;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 a=K(l);class A{constructor(t){this.value=t}}class B{static Draft(t){return new A(t)}}k(B,"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="lifecycle/error",e.Unmount="lifecycle/unmount",e))(v||{}),g=(e=>(e[e.Default=0]="Default",e[e.Error=1]="Error",e))(g||{});function V(e){return new Promise(t=>setTimeout(t,e))}function X(e){return e?!!(e&&typeof e!="symbol"):Symbol(`pk.${Date.now()}.${crypto.randomUUID()}`)}function S(e){return JSON.stringify(e)}const j=Symbol("meta"),Y=Object.freeze(Object.defineProperty({__proto__:null,hash:S,meta:j,pk:X,sleep:V},Symbol.toStringTag,{value:"Module"}));function p(e,t){const n=a.useRef(null),r=a.useRef(null);return a.useMemo(()=>{const o=S(t);if(r.current!==o){r.current=o;const u=e();return n.current=u,u}return n.current},t)}function N(e,t){const n=a.useRef(null);a.useEffect(()=>{const r=S(t);if(n.current!==r)return n.current=r,e()},t)}const z=a.createContext({instance:new y});function H(){return a.useContext(z)}function Z({children:e}){const t=p(()=>({instance:new y}),[]);return c.jsx(z.Provider,{value:t,children:e})}const f={immer:new U.Immer,annotations:Symbol("annotations")};U.enablePatches(),f.immer.setAutoFreeze(!1);class R{constructor(t,n,r=null){k(this,"process");this.value=t,this.operations=n,this.field=r,this.process=null}attach(t){return this.process=t,this}}function L(e,t=[]){return new R(e,t)}class P{constructor(t,n=t){this.stateless=t,this.stateful=n}get validatable(){return $(this.stateful)}}function $(e,t=[]){return new Proxy(e,{get(n,r){switch(r){case"is":return o=>{const u=D(e,t);if(!u)return!1;const i=new Set(u.flatMap(h=>h.operations));return!!(Array.from(i).reduce((h,m)=>h|(m??0),0)&o)};case"pending":return()=>!!D(e,t);case"draft":return()=>{const o=D(e,t);if(!o)return b(e,t);const u=o.flatMap(i=>i.operations).find(i=>i instanceof A);return u?u.value:b(e,t)}}return $(e,[...t,String(r)])}})}function D(e,t){const r=typeof b(e,t)=="object"?t:t.slice(0,-1),o=r.length===0?e:b(e,r),u=(o==null?void 0:o[f.annotations])??[];return u.length>0?u:null}function I(e,t,n){function r(i){return O(i).forEach(function(){if(this.key===f.annotations){this.block();return}this.node instanceof R&&this.update(this.node.value)})}function o(i){return O(i).forEach(function(){if(this.key===f.annotations){this.block();return}if(this.node instanceof R){const d=typeof this.node.value=="object",h=[...d?this.path:this.path.slice(0,-1),f.annotations],m=b(e.stateful,h)??[],x=this.node.attach(t);d?this.update({...this.node.value,[f.annotations]:[x,...m]},!0):(this.parent&&(this.parent.node[f.annotations]=[x,...m]),this.update(this.node.value,!0))}})}const u=i=>n(i,i[j]);return new P(r(f.immer.produce(e.stateless,u)),o(f.immer.produce(e.stateful,u)))}function C(e,t){const n=O(e.stateful).forEach(function(){if(this.key===f.annotations){this.block();return}if(this.node&&this.node[f.annotations]){const r=this.node[f.annotations];this.update({...this.node,[f.annotations]:r.filter(o=>o.process!==t)},!0)}});return new P(e.stateless,n)}function ee(e){return p(()=>({controller:{get model(){return e.model.current.stateful},queue:[],actions:{annotate(t,n){return L(t,n)},produce(t){return(n,r)=>I(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},context(t){const n=Object.keys(t);return e.context.use.current=t,e.context.update(),n.reduce((r,o)=>({...r,get[o](){return e.context.values.current[o]}}),{})}}},view:{get model(){return e.model.current.stateless},get validate(){return e.model.current.validatable},boundary:{is(t){return e.model.current.stateless[j].boundary===t}},actions:{dispatch([t,...n]){if(t==null)return Promise.reject();const r=Promise.withResolvers();return e.dispatchers.dispatch(t,n,r),r.promise}}}}),[])}function te(e){const t=l.useRef(null);return t.current==null&&(t.current=e.options.using.actions(e.actions.controller)),p(()=>{if(t.current)return Object.entries(t.current).forEach(([r,o])=>e.dispatchers.attach(r,o)),t.current},[])}function F(e){return e.startsWith("distributed")}function ne(e){return e instanceof M}function J(e){return e instanceof M||e instanceof Error?e:new Error("Unknown error",{cause:e})}class M extends Error{constructor(n,r=null){super(String(r));_(this,w);_(this,E);q(this,w,n),q(this,E,r)}get type(){return T(this,w)}get message(){return T(this,E)||""}}w=new WeakMap,E=new WeakMap;function re({children:e}){return e()}function se(e){return(t,n)=>async(r=Promise.withResolvers(),o)=>{if(typeof n!="function")return;const u=Symbol("process"),i=n(...o);try{if(i==null)return;if(typeof i=="function"){const d=i(e.model.current,u);e.model.current=C(d,u),e.update.rerender(),r.resolve();return}for(;;){const{value:d,done:h}=await i.next();if(h){const x=d(e.model.current,u);e.model.current=C(x,u),e.update.rerender();break}const m=d;e.model.current=m(e.model.current,u),e.update.rerender(),r.resolve()}}catch(d){C(e.model.current,u),e.update.rerender(),e.unicast.emit(v.Error,r,[J(d)])}}}function oe(e){const t=H(),n=p(()=>new y,[]),r=se({...e,unicast:n});return p(()=>({attach(o,u){const i=String(o);F(i)?t.instance.on(i,r(o,u)):n.on(i,r(o,u))},dispatch(o,u,i){const d=String(o);F(d)?t.instance.emit(d,i,u):n.emit(d,i,u)}}),[])}function ue(){const e=a.useRef(null);return p(()=>({customElement:e}),[])}function ce(e){N(()=>{e.dispatchers.dispatch(v.Derive,[])},[e.options.using.props]),N(()=>(e.dispatchers.dispatch(v.Mount,[]),e.dispatchers.dispatch(v.Node,[e.elements.customElement.current]),()=>e.dispatchers.dispatch(v.Unmount,[])),[])}function ie(e){const t=p(()=>({...e.options.using.model??{},[j]:{boundary:g.Default}}),[]);return a.useRef(new P(t,t))}function ae(){return a.useRef(new Set)}function le(){const[e,t]=a.useReducer(n=>n+1,0);return p(()=>({hash:e,rerender:t}),[e])}const de={elementName:"x-chizu"},Q=a.createContext(null);function fe(){const e=a.useContext(Q);if(!e)throw new Error("useScoped is not being used within a scoped module.");return e}class he extends a.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){const n=Symbol("process"),r=I(this.props.model.current,n,(o,u)=>{u.boundary=g.Error});this.props.model.current=r,this.props.update.rerender(),this.props.dispatchers.dispatch(v.Error,[J(t)])}render(){return c.jsx(re,{children:this.props.children})}}function me(){const e=a.useRef({}),t=a.useRef({});function n(){t.current=Object.fromEntries(Object.entries(e.current).map(([r,o])=>[r,a.use(o)]))}return n(),p(()=>({use:e,values:t,update:n}),[])}function pe(){return l.useRef(0)}function ve({options:e}){const t=le(),n=ae(),r=pe(),o=ue(),u=H(),i=me(),d=ie({options:e}),h=oe({broadcast:u,options:e,update:t,model:d,queue:n}),m=ee({model:d,dispatchers:h,context:i});return te({options:e,dispatchers:h,actions:m}),ce({options:e,dispatchers:h,elements:o}),p(()=>a.createElement(he,{model:d,dispatchers:h,update:t,module:m.view,children(){return a.createElement(Q.Provider,{value:m.view,children:a.createElement(de.elementName,{ref:o.customElement,style:{display:"contents"},children:e.children(m.view)})})}}),[t.hash,S(e.using.props),e.passive?r.current++:0])}function ye(e){return c.jsx(ve,{options:e})}s.Boundary=g,s.Broadcaster=Z,s.Lifecycle=v,s.Scope=ye,s.State=B,s.TypedError=M,s.isTypedError=ne,s.useScoped=fe,s.utils=Y,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react/jsx-runtime"),require("react"),require("eventemitter3"),require("immer"),require("lodash/get"),require("traverse")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","eventemitter3","immer","lodash/get","traverse"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.Chizu={},s.jsxRuntime,s.React,s.EventEmitter3,s.Immer,s.get,s.Traverse))})(this,function(s,c,l,y,k,b,P){"use strict";var be=Object.defineProperty;var W=s=>{throw TypeError(s)};var we=(s,c,l)=>c in s?be(s,c,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[c]=l;var T=(s,c,l)=>we(s,typeof c!="symbol"?c+"":c,l),G=(s,c,l)=>c.has(s)||W("Cannot "+l);var _=(s,c,l)=>(G(s,c,"read from private field"),l?l.call(s):c.get(s)),q=(s,c,l)=>c.has(s)?W("Cannot add the same private member more than once"):c instanceof WeakSet?c.add(s):c.set(s,l),U=(s,c,l,y)=>(G(s,c,"write to private field"),y?y.call(s,l):c.set(s,l),l);var w,E;function K(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const a=K(l);class A{constructor(t){this.value=t}}class B{static Draft(t){return new A(t)}}T(B,"Op",{Add:1,Remove:2,Update:4,Move:8,Replace:16});var p=(e=>(e.Mount="lifecycle/mount",e.Node="lifecycle/node",e.Derive="lifecycle/derive",e.Error="lifecycle/error",e.Unmount="lifecycle/unmount",e))(p||{}),g=(e=>(e[e.Default=0]="Default",e[e.Error=1]="Error",e))(g||{});function V(e){return new Promise(t=>setTimeout(t,e))}function X(e){return e?!!(e&&typeof e!="symbol"):Symbol(`pk.${Date.now()}.${crypto.randomUUID()}`)}function S(e){return JSON.stringify(e)}const j=Symbol("meta"),Y=Object.freeze(Object.defineProperty({__proto__:null,hash:S,meta:j,pk:X,sleep:V},Symbol.toStringTag,{value:"Module"}));function v(e,t){const r=a.useRef(null),n=a.useRef(null);return a.useMemo(()=>{const o=S(t);if(n.current!==o){n.current=o;const u=e();return r.current=u,u}return r.current},t)}function N(e,t){const r=a.useRef(null);a.useEffect(()=>{const n=S(t);if(r.current!==n)return r.current=n,e()},t)}const z=a.createContext({instance:new y});function H(){return a.useContext(z)}function Z({children:e}){const t=v(()=>({instance:new y}),[]);return c.jsx(z.Provider,{value:t,children:e})}const h={immer:new k.Immer,annotations:Symbol("annotations")};k.enablePatches(),h.immer.setAutoFreeze(!1);class R{constructor(t,r,n=null){T(this,"process");this.value=t,this.operations=r,this.field=n,this.process=null}attach(t){return this.process=t,this}}function L(e,t=[]){return new R(e,t)}class D{constructor(t,r=t){this.stateless=t,this.stateful=r}get validatable(){return $(this.stateful)}}function $(e,t=[]){return new Proxy(e,{get(r,n){switch(n){case"is":return o=>{const u=C(e,t);if(!u)return!1;const i=new Set(u.flatMap(m=>m.operations));return!!(Array.from(i).reduce((m,f)=>m|(f??0),0)&o)};case"pending":return()=>!!C(e,t);case"draft":return()=>{const o=C(e,t);if(!o)return b(e,t);const u=o.flatMap(i=>i.operations).find(i=>i instanceof A);return u?u.value:b(e,t)}}return $(e,[...t,String(n)])}})}function C(e,t){const n=typeof b(e,t)=="object"?t:t.slice(0,-1),o=n.length===0?e:b(e,n),u=(o==null?void 0:o[h.annotations])??[];return u.length>0?u:null}function I(e,t,r){function n(i){return P(i).forEach(function(){if(this.key===h.annotations){this.block();return}this.node instanceof R&&this.update(this.node.value)})}function o(i){return P(i).forEach(function(){if(this.key===h.annotations){this.block();return}if(this.node instanceof R){const d=typeof this.node.value=="object",m=[...d?this.path:this.path.slice(0,-1),h.annotations],f=b(e.stateful,m)??[],O=this.node.attach(t);d?this.update({...this.node.value,[h.annotations]:[O,...f]},!0):(this.parent&&(this.parent.node[h.annotations]=[O,...f]),this.update(this.node.value,!0))}})}const u=i=>r(i,i[j]);return new D(n(h.immer.produce(e.stateless,u)),o(h.immer.produce(e.stateful,u)))}function x(e,t){const r=P(e.stateful).forEach(function(){if(this.key===h.annotations){this.block();return}if(this.node&&this.node[h.annotations]){const n=this.node[h.annotations];this.update({...this.node,[h.annotations]:n.filter(o=>o.process!==t)},!0)}});return new D(e.stateless,r)}function ee(e){return v(()=>({controller:{get model(){return e.model.current.stateful},queue:[],actions:{annotate(t,r){return L(t,r)},produce(t){return(r,n)=>I(r,n,t)},dispatch([t,...r]){if(t==null)return Promise.reject();const n=Promise.withResolvers();return e.dispatchers.dispatch(t,r,n),n.promise},context(t){const r=Object.keys(t);return e.context.use.current=t,e.context.update(),r.reduce((n,o)=>({...n,get[o](){return e.context.values.current[o]}}),{})}}},view:{get model(){return e.model.current.stateless},get validate(){return e.model.current.validatable},boundary:{is(t){return e.model.current.stateless[j].boundary===t}},actions:{dispatch([t,...r]){if(t==null)return Promise.reject();const n=Promise.withResolvers();return e.dispatchers.dispatch(t,r,n),n.promise}}}}),[])}function te(e){const t=l.useRef(null);return t.current==null&&(t.current=e.options.using.actions(e.actions.controller)),v(()=>{if(t.current)return Object.entries(t.current).forEach(([n,o])=>e.dispatchers.attach(n,o)),t.current},[])}function F(e){return e.startsWith("distributed")}function ne(e){return e instanceof M}function J(e){return e instanceof M||e instanceof Error?e:new Error("Unknown error",{cause:e})}class M extends Error{constructor(r,n=null){super(String(n));q(this,w);q(this,E);U(this,w,r),U(this,E,n)}get type(){return _(this,w)}get message(){return _(this,E)||""}}w=new WeakMap,E=new WeakMap;function re({children:e}){return e()}function se(e){return(t,r)=>async(n=Promise.withResolvers(),o)=>{if(typeof r!="function")return void n.resolve();const u=Symbol("process"),i=r(...o);try{if(i==null)return void n.resolve();if(typeof i=="function"){const d=i(e.model.current,u);return e.model.current=x(d,u),e.update.rerender(),void n.resolve()}for(;;){if(i instanceof Promise){const f=await i;if(f==null)return void n.resolve();const O=f(e.model.current,u);return e.model.current=x(O,u),e.update.rerender(),void n.resolve()}const{value:d,done:m}=await i.next();if(m){const f=d(e.model.current,u);return e.model.current=x(f,u),e.update.rerender(),void n.resolve()}e.model.current=d(e.model.current,u),e.update.rerender()}}catch(d){x(e.model.current,u),e.update.rerender(),e.unicast.emit(p.Error,n,[J(d)])}}}function oe(e){const t=H(),r=v(()=>new y,[]),n=se({...e,unicast:r});return v(()=>({attach(o,u){const i=String(o);F(i)?t.instance.on(i,n(o,u)):r.on(i,n(o,u))},dispatch(o,u,i){const d=String(o);F(d)?t.instance.emit(d,i,u):r.emit(d,i,u)}}),[])}function ue(){const e=a.useRef(null);return v(()=>({customElement:e}),[])}function ce(e){N(()=>{e.dispatchers.dispatch(p.Derive,[])},[e.options.using.props]),N(()=>(e.dispatchers.dispatch(p.Mount,[]),e.dispatchers.dispatch(p.Node,[e.elements.customElement.current]),()=>e.dispatchers.dispatch(p.Unmount,[])),[])}function ie(e){const t=v(()=>({...e.options.using.model??{},[j]:{boundary:g.Default}}),[]);return a.useRef(new D(t,t))}function ae(){return a.useRef(new Set)}function le(){const[e,t]=a.useReducer(r=>r+1,0);return v(()=>({hash:e,rerender:t}),[e])}const de={elementName:"x-chizu"},Q=a.createContext(null);function fe(){const e=a.useContext(Q);if(!e)throw new Error("useScoped is not being used within a scoped module.");return e}class he extends a.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){const r=Symbol("process"),n=I(this.props.model.current,r,(o,u)=>{u.boundary=g.Error});this.props.model.current=n,this.props.update.rerender(),this.props.dispatchers.dispatch(p.Error,[J(t)])}render(){return c.jsx(re,{children:this.props.children})}}function me(){const e=a.useRef({}),t=a.useRef({});function r(){t.current=Object.fromEntries(Object.entries(e.current).map(([n,o])=>[n,a.use(o)]))}return r(),v(()=>({use:e,values:t,update:r}),[])}function ve(){return l.useRef(0)}function pe({options:e}){const t=le(),r=ae(),n=ve(),o=ue(),u=H(),i=me(),d=ie({options:e}),m=oe({broadcast:u,options:e,update:t,model:d,queue:r}),f=ee({model:d,dispatchers:m,context:i});return te({options:e,dispatchers:m,actions:f}),ce({options:e,dispatchers:m,elements:o}),v(()=>a.createElement(he,{model:d,dispatchers:m,update:t,module:f.view,children(){return a.createElement(Q.Provider,{value:f.view,children:a.createElement(de.elementName,{ref:o.customElement,style:{display:"contents"},children:e.children(f.view)})})}}),[t.hash,S(e.using.props),e.passive?n.current++:0])}function ye(e){return c.jsx(pe,{options:e})}s.Boundary=g,s.Broadcaster=Z,s.Lifecycle=p,s.Scope=ye,s.State=B,s.TypedError=M,s.isTypedError=ne,s.useScoped=fe,s.utils=Y,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
@@ -17,7 +17,7 @@ export type ActionEvent<M extends ModuleDefinition> = (...args: M["Actions"][num
17
17
  type ActionEvents<M extends ModuleDefinition> = {
18
18
  [K in Head<M["Actions"]>]: (payload: Payload<M["Actions"], K>) => ActionGenerator<M>;
19
19
  };
20
- 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>;
20
+ export type ActionGenerator<M extends ModuleDefinition> = void | Promise<void> | ((models: Models<M["Model"]>, process: symbol) => Models<M["Model"]>) | Promise<(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>;
21
21
  export type ControllerDefinition<M extends ModuleDefinition> = (controller: ControllerArgs<M>) => ControllerInstance<M>;
22
22
  export type ControllerInstance<M extends ModuleDefinition> = {
23
23
  [Lifecycle.Mount]?(): ActionGenerator<M>;
@@ -3,6 +3,7 @@ import { ModuleDefinition, Task } from '../../../types/index.ts';
3
3
  import { Head, Tail } from '../types.ts';
4
4
  import { UseDispatchHandlerProps } from './types.ts';
5
5
  /**
6
+ * @function useDispatcher
6
7
  * @param props {UseDispatchHandlerProps<M>}
7
8
  * @returns {(name: Head<M["Actions"]>, ƒ: GeneratorFn<M>) => (payload: Tail<M["Actions"]>) => Promise<void>}
8
9
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chizu",
3
- "version": "0.2.24",
3
+ "version": "0.2.25",
4
4
  "type": "module",
5
5
  "main": "./dist/chizu.js",
6
6
  "types": "./dist/index.d.ts",