chizu 0.2.25 → 0.2.27

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