@xmachines/play-react 1.0.0-beta.43 → 1.0.0-beta.45
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 +8 -2
- package/dist/ActorProvider.d.ts.map +1 -1
- package/dist/ActorProvider.js +18 -6
- package/dist/ActorProvider.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -303,7 +303,7 @@ const registryResult = defineRegistry(catalog, {
|
|
|
303
303
|
});
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
-
`onRenderError` is typed as `RenderErrorHandler` and exported from
|
|
306
|
+
`onRenderError` is typed as `RenderErrorHandler` and exported from.
|
|
307
307
|
|
|
308
308
|
---
|
|
309
309
|
|
|
@@ -395,4 +395,10 @@ Priority: **route param fills `undefined` slots; explicit non-`undefined` spec p
|
|
|
395
395
|
- React `useState` is **only** used to trigger re-renders — never for business logic
|
|
396
396
|
- `actor.currentView` (TC39 Signal) is the sole render trigger; `PlayRenderer` is a passive observer
|
|
397
397
|
- Per-view UI state lives in an `@xstate/store` atom, not in React state
|
|
398
|
-
- `@json-render/react` drives rendering; `PlayRenderer` is the signal bridge — import `defineRegistry`, `ComponentFn`, `ComponentContext`, and `useBoundProp` from
|
|
398
|
+
- `@json-render/react` drives rendering; `PlayRenderer` is the signal bridge — import `defineRegistry`, `ComponentFn`, `ComponentContext`, and `useBoundProp` from
|
|
399
|
+
|
|
400
|
+
## Learn More
|
|
401
|
+
|
|
402
|
+
- [Demo](examples/demo/README.md)
|
|
403
|
+
- [React Router adapter](../play-react-router/README.md)
|
|
404
|
+
- [TanStack React Router adapter](../play-tanstack-react-router/README.md)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorProvider.d.ts","sourceRoot":"","sources":["../src/ActorProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"ActorProvider.d.ts","sourceRoot":"","sources":["../src/ActorProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAA+D,MAAM,OAAO,CAAC;AAEpF,OAAO,KAAK,EAAE,oBAAoB,EAAY,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAO5F,OAAO,KAAK,EAAY,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIpG;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,sBAAsB,CAAC,oBAAoB,CAAC;IACvF,sFAAsF;IACtF,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,4FAA4F;IAC5F,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,KAAK,IAAI,CAAC;IACxD,0DAA0D;IAC1D,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;CAAG;AAQpF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,IAAI,gBAAgB,CAE9C;AAoED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA0FtD,CAAC"}
|
package/dist/ActorProvider.js
CHANGED
|
@@ -10,7 +10,7 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
10
10
|
*
|
|
11
11
|
* @packageDocumentation
|
|
12
12
|
*/
|
|
13
|
-
import React, { useState, useRef, createContext, useContext } from "react";
|
|
13
|
+
import React, { useState, useRef, useMemo, createContext, useContext } from "react";
|
|
14
14
|
import { StateProvider, useStateStore } from "@json-render/react";
|
|
15
15
|
import { createAtom } from "@xstate/store";
|
|
16
16
|
import { xstateStoreStateStore } from "@json-render/xstate";
|
|
@@ -59,14 +59,26 @@ function createViewStore(initialState) {
|
|
|
59
59
|
*/
|
|
60
60
|
function ActorProviderInner({ registryResult, spec, store, children, }) {
|
|
61
61
|
const stateCtx = useStateStore();
|
|
62
|
+
// Stable refs for stateCtx methods so the useMemo below doesn't need to depend
|
|
63
|
+
// on stateCtx identity (useStateStore() may return a new object each render even
|
|
64
|
+
// when the underlying store hasn't changed). The handlers factory passes these as
|
|
65
|
+
// getter functions and calls them at action-execution time, not at creation time,
|
|
66
|
+
// so reading from a ref is always correct.
|
|
67
|
+
const stateCtxRef = useRef(stateCtx);
|
|
68
|
+
stateCtxRef.current = stateCtx;
|
|
62
69
|
// Build a SetState adapter: the handlers factory expects an updater-function pattern
|
|
63
70
|
// ((prev) => next), while stateCtx provides path-based set/update. This adapter
|
|
64
71
|
// bridges the two so action functions can use setState if needed.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
// Stable function reference — reads stateCtxRef.current at invocation time.
|
|
73
|
+
const setStateAdapterRef = useRef((updater) => {
|
|
74
|
+
const prev = stateCtxRef.current.getSnapshot();
|
|
75
|
+
stateCtxRef.current.update(updater(prev));
|
|
76
|
+
});
|
|
77
|
+
// Memoize handlers keyed to registryResult identity. The getter functions are
|
|
78
|
+
// stable refs so they do not contribute to invalidation. Handlers are only
|
|
79
|
+
// recreated when the registry definition itself changes (e.g. a new defineRegistry
|
|
80
|
+
// call), not on every render cycle.
|
|
81
|
+
const handlers = useMemo(() => registryResult.handlers(() => setStateAdapterRef.current, () => stateCtxRef.current.getSnapshot()), [registryResult]);
|
|
70
82
|
const viewValue = {
|
|
71
83
|
spec,
|
|
72
84
|
handlers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorProvider.js","sourceRoot":"","sources":["../src/ActorProvider.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,M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BACjB,QAAQ,KAAK,SAAS;gBACtB,OAAO,QAAQ,KAAK,QAAQ;gBAC5B,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;gBACxB,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,MAAM,CAAC,SAAS;oBACpD,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;gBACzC,CAAC,CAAE,QAAoC;gBACvC,CAAC,CAAC,EAAE,CAAC;YACP,gBAAgB,CAAC,OAAO,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;YACzD,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,OAAO,CACN,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAkB,YAC/C,KAAC,iBAAiB,IAAC,QAAQ,EAAE,QAAQ,KAAM,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC,YAClE,KAAC,aAAa,IAAC,KAAK,EAAE,KAAK,YAC1B,KAAC,kBAAkB,IAClB,cAAc,EAAE,oBAAoB,EACpC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,YAEX,QAAQ,GACW,GACN,GACG,GACG,CACxB,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/play-react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.45",
|
|
4
4
|
"description": "React renderer for XMachines Play architecture with signal-driven rendering",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actor",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"prepublishOnly": "npm run build"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@xmachines/play": "1.0.0-beta.
|
|
49
|
-
"@xmachines/play-actor": "1.0.0-beta.
|
|
50
|
-
"@xmachines/play-signals": "1.0.0-beta.
|
|
48
|
+
"@xmachines/play": "1.0.0-beta.45",
|
|
49
|
+
"@xmachines/play-actor": "1.0.0-beta.45",
|
|
50
|
+
"@xmachines/play-signals": "1.0.0-beta.45"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@json-render/core": "^0.18.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@types/node": "^25.6.0",
|
|
59
59
|
"@types/react": "^19.2.14",
|
|
60
60
|
"@types/react-dom": "^19.2.3",
|
|
61
|
-
"@xmachines/shared": "1.0.0-beta.
|
|
61
|
+
"@xmachines/shared": "1.0.0-beta.45",
|
|
62
62
|
"@xstate/store": "^3.17.0",
|
|
63
63
|
"jsdom": "^29.0.2",
|
|
64
64
|
"oxfmt": "^0.45.0",
|