chizu 0.2.31 → 0.2.33
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 +14 -13
- package/dist/chizu.umd.cjs +2 -2
- package/dist/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/chizu.js
CHANGED
|
@@ -3,16 +3,16 @@ import * as n from "react";
|
|
|
3
3
|
import { createContext as A, useContext as O } from "react";
|
|
4
4
|
import p from "eventemitter3";
|
|
5
5
|
import { State as P } from "immertation";
|
|
6
|
-
import {
|
|
7
|
-
const
|
|
6
|
+
import { Box as Q, Op as V, Operation as X, State as Y } from "immertation";
|
|
7
|
+
const x = A(void 0);
|
|
8
8
|
function k() {
|
|
9
|
-
return O(
|
|
9
|
+
return O(x);
|
|
10
10
|
}
|
|
11
11
|
function F({
|
|
12
12
|
handler: t,
|
|
13
13
|
children: e
|
|
14
14
|
}) {
|
|
15
|
-
return /* @__PURE__ */ h(
|
|
15
|
+
return /* @__PURE__ */ h(x.Provider, { value: t, children: e });
|
|
16
16
|
}
|
|
17
17
|
function T(t = "anonymous") {
|
|
18
18
|
return Symbol(`chizu.action/${t}`);
|
|
@@ -33,21 +33,21 @@ class v {
|
|
|
33
33
|
function M(t) {
|
|
34
34
|
return new Promise((e) => setTimeout(e, t));
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function E(t) {
|
|
37
37
|
return t ? !!(t && typeof t != "symbol") : Symbol(`pk.${Date.now()}.${crypto.randomUUID()}`);
|
|
38
38
|
}
|
|
39
|
-
const j =
|
|
40
|
-
function
|
|
39
|
+
const j = E;
|
|
40
|
+
function g(t) {
|
|
41
41
|
return (e, r) => {
|
|
42
42
|
e.actions.produce((s) => {
|
|
43
43
|
s[t] = r;
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
const z =
|
|
47
|
+
const z = g, N = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
48
48
|
__proto__: null,
|
|
49
|
-
pk:
|
|
50
|
-
set:
|
|
49
|
+
pk: E,
|
|
50
|
+
set: g,
|
|
51
51
|
sleep: M,
|
|
52
52
|
κ: j,
|
|
53
53
|
λ: z
|
|
@@ -152,11 +152,12 @@ function _(t) {
|
|
|
152
152
|
}
|
|
153
153
|
export {
|
|
154
154
|
F as ActionError,
|
|
155
|
+
Q as Box,
|
|
155
156
|
W as Broadcaster,
|
|
156
157
|
v as Lifecycle,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
V as Op,
|
|
159
|
+
X as Operation,
|
|
160
|
+
Y as State,
|
|
160
161
|
T as createAction,
|
|
161
162
|
I as createDistributedAction,
|
|
162
163
|
q as useAction,
|
package/dist/chizu.umd.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(t,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react/jsx-runtime"),require("react"),require("eventemitter3"),require("immertation")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","eventemitter3","immertation"],d):(t=typeof globalThis<"u"?globalThis:t||self,d(t.Chizu={},t.jsxRuntime,t.React,t.EventEmitter3,t.Immertation))})(this,(function(t,d,S,p,b){"use strict";function k(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const c=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,c.get?c:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const o=k(S),
|
|
1
|
+
(function(t,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react/jsx-runtime"),require("react"),require("eventemitter3"),require("immertation")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","eventemitter3","immertation"],d):(t=typeof globalThis<"u"?globalThis:t||self,d(t.Chizu={},t.jsxRuntime,t.React,t.EventEmitter3,t.Immertation))})(this,(function(t,d,S,p,b){"use strict";function k(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const c=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,c.get?c:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const o=k(S),w=S.createContext(void 0);function z(){return S.useContext(w)}function D({handler:e,children:n}){return d.jsx(w.Provider,{value:e,children:n})}function _(e="anonymous"){return Symbol(`chizu.action/${e}`)}function B(e="anonymous"){return Symbol(`chizu.action/distributed/${e}`)}function O(e){return e.toString().startsWith("Symbol(chizu.action/distributed/")}class g{static Mount=Symbol("lifecycle/mount");static Node=Symbol("lifecycle/node");static Derive=Symbol("lifecycle/derive");static Error=Symbol("lifecycle/error");static Unmount=Symbol("lifecycle/unmount")}function T(e){return new Promise(n=>setTimeout(n,e))}function v(e){return e?!!(e&&typeof e!="symbol"):Symbol(`pk.${Date.now()}.${crypto.randomUUID()}`)}const x=v;function P(e){return(n,r)=>{n.actions.produce(c=>{c[e]=r})}}const G=Object.freeze(Object.defineProperty({__proto__:null,pk:v,set:P,sleep:T,κ:x,λ:P},Symbol.toStringTag,{value:"Module"})),A=o.createContext({instance:new p});function L(){return o.useContext(A)}function q({children:e}){const n=o.useMemo(()=>({instance:new p}),[]);return d.jsx(A.Provider,{value:n,children:e})}function R(e,n){return Object.keys(e).reduce((r,c)=>(Object.defineProperty(r,c,{get(){return n.current[c]},enumerable:!0}),r),{})}const U=Symbol("chizu.action.context");function $(e){const n=z();return o.useCallback(async(r,c)=>{try{if(e.constructor.name==="GeneratorFunction"||e.constructor.name==="AsyncGeneratorFunction"){const f=e(r,c);for await(const E of f);}else await e(r,c)}catch(y){console.error(`Chizu
|
|
2
2
|
|
|
3
|
-
`,y),n?.(y)}},[e,n])}function F(e,n){const r=
|
|
3
|
+
`,y),n?.(y)}},[e,n])}function F(e,n){const r=L(),[c,y]=o.useState(e),f=o.useRef(new b.State(e)),E=C({model:c}),l=o.useMemo(()=>new p,[]),M=o.useCallback(a=>{const s=new AbortController;return{signal:s.signal,actions:{produce(u){if(s.signal.aborted)return;const i=f.current.mutate(m=>u(m));y(f.current.model),a.processes.add(i)},dispatch(...[u,i]){s.signal.aborted||(O(u)?r.instance.emit(u,i):l.emit(u,i))},annotate(u,i){return f.current.annotate(u,i)}},[U]:{controller:s}}},[E.model]);return o.useLayoutEffect(()=>{const a=new n;Object.getOwnPropertySymbols(a).forEach(s=>{const u=s;if(O(s))return void r.instance.on(s,async i=>{const m={processes:new Set},h=Promise.withResolvers();await a[u](M(m),i),m.processes.forEach(j=>f.current.prune(j)),h.resolve()});l.on(s,async i=>{const m={processes:new Set},h=Promise.withResolvers();await a[u](M(m),i),m.processes.forEach(j=>f.current.prune(j)),h.resolve()})})},[l]),o.useLayoutEffect(()=>(l.emit(g.Mount),()=>void l.emit(g.Unmount)),[]),o.useMemo(()=>[c,{dispatch(...[a,s]){O(a)?r.instance.emit(a,s):l.emit(a,s)},consume(){},get inspect(){return f.current.inspect}}],[c,l])}function C(e){const n=o.useRef(e);return o.useLayoutEffect(()=>{n.current=e},[e]),o.useMemo(()=>R(e,n),[e])}Object.defineProperty(t,"Box",{enumerable:!0,get:()=>b.Box}),Object.defineProperty(t,"Op",{enumerable:!0,get:()=>b.Op}),Object.defineProperty(t,"Operation",{enumerable:!0,get:()=>b.Operation}),Object.defineProperty(t,"State",{enumerable:!0,get:()=>b.State}),t.ActionError=D,t.Broadcaster=q,t.Lifecycle=g,t.createAction=_,t.createDistributedAction=B,t.useAction=$,t.useActions=F,t.useSnapshot=C,t.utils=G,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { Lifecycle } from './types/index.ts';
|
|
|
5
5
|
export * as utils from './utils/index.ts';
|
|
6
6
|
export { Broadcaster } from './broadcast/index.tsx';
|
|
7
7
|
export { useActions, useAction, useSnapshot } from './hooks/index.ts';
|
|
8
|
-
export { Operation, Op, State } from 'immertation';
|
|
8
|
+
export { Operation, Op, State, Box } from 'immertation';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chizu",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.33",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/chizu.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"eventemitter3": "^5.0.1",
|
|
17
|
-
"immertation": "^0.1.
|
|
17
|
+
"immertation": "^0.1.17",
|
|
18
18
|
"lodash": "^4.17.21",
|
|
19
19
|
"traverse": "0.6.11"
|
|
20
20
|
},
|