@xmachines/play-dom 2.2.0 → 4.0.0
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 +97 -43
- package/dist/PlayRenderer.d.ts +101 -4
- package/dist/PlayRenderer.d.ts.map +1 -1
- package/dist/PlayRenderer.js +318 -20
- package/dist/PlayRenderer.js.map +1 -1
- package/dist/create-play-ui.d.ts +36 -9
- package/dist/create-play-ui.d.ts.map +1 -1
- package/dist/create-play-ui.js +30 -14
- package/dist/create-play-ui.js.map +1 -1
- package/dist/create-renderer.d.ts +3 -3
- package/dist/create-renderer.d.ts.map +1 -1
- package/dist/create-renderer.js +2 -1
- package/dist/create-renderer.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +103 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +26 -23
package/dist/create-play-ui.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* it returns a `disconnect` cleanup function.
|
|
7
7
|
*
|
|
8
8
|
* The factory holds the factory options (`functions`, `validationFunctions`,
|
|
9
|
-
* `navigate`, `onRenderError`, and `fallback`) from the moment of its
|
|
10
|
-
* it applies them on every `mount()` call. Give the mount options
|
|
11
|
-
* `loading`) to the `mount()` call itself, through `MountOptions`.
|
|
9
|
+
* `navigate`, `onRenderError`, `onError`, and `fallback`) from the moment of its
|
|
10
|
+
* creation, and it applies them on every `mount()` call. Give the mount options
|
|
11
|
+
* (`store` and `loading`) to the `mount()` call itself, through `MountOptions`.
|
|
12
12
|
*
|
|
13
13
|
* This factory is parallel to `<PlayUIProvider registryResult={...}>` in the
|
|
14
14
|
* framework renderers.
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
*
|
|
32
32
|
* @packageDocumentation
|
|
33
33
|
*/
|
|
34
|
+
import { asCleanup } from "@xmachines/play";
|
|
34
35
|
import { PlayRenderer } from "./PlayRenderer.js";
|
|
35
36
|
/**
|
|
36
37
|
* Creates the mount function of the complete DOM renderer.
|
|
@@ -47,11 +48,15 @@ import { PlayRenderer } from "./PlayRenderer.js";
|
|
|
47
48
|
* - `validationFunctions` — your own check functions. They are available at `ctx.ctx.validationFunctions`.
|
|
48
49
|
* - `navigate` — the navigation callback. The renderer calls it for `onSuccess: { navigate: "..." }`.
|
|
49
50
|
* - `onRenderError` — the `(error, name)` handler of a component render error and of an action handler rejection.
|
|
50
|
-
* - `
|
|
51
|
-
*
|
|
51
|
+
* - `onError` — the `(error, reset)` handler of a failure of a complete rebuild. The renderer
|
|
52
|
+
* contains such a failure always, and this option says where the report goes.
|
|
53
|
+
* - `fallback` — the content to show when the view of the actor is `null`, and after a contained
|
|
54
|
+
* failure of a rebuild. Give a FUNCTION when the factory mounts more than one
|
|
55
|
+
* time, so that each renderer owns its own element.
|
|
56
|
+
* @returns The {@link MountFn}: `(actor, container, mountOptions?) → disconnect`
|
|
52
57
|
*/
|
|
53
58
|
export function createPlayUI(registryResult, options = {}) {
|
|
54
|
-
const { onRenderError, fallback, functions, directives, validationFunctions, navigate, onConfirm, } = options;
|
|
59
|
+
const { onRenderError, onError, fallback, functions, directives, validationFunctions, navigate, onConfirm, } = options;
|
|
55
60
|
return function mount(actor, container, mountOptions) {
|
|
56
61
|
// Each option of UIProviderOptions (onRenderError, functions, validationFunctions,
|
|
57
62
|
// and navigate) goes directly through PlayDomOptions, then PlayRenderer, then
|
|
@@ -66,18 +71,29 @@ export function createPlayUI(registryResult, options = {}) {
|
|
|
66
71
|
...(navigate !== undefined && { navigate }),
|
|
67
72
|
...(onConfirm !== undefined && { onConfirm }),
|
|
68
73
|
...(onRenderError !== undefined && { onRenderError }),
|
|
74
|
+
// PlayRenderer owns both of them now. It contains a rebuild that throws always,
|
|
75
|
+
// and it shows the fallback for every null view and after each contained
|
|
76
|
+
// failure. The factory therefore forwards the two options, and it appends
|
|
77
|
+
// nothing itself.
|
|
78
|
+
...(onError !== undefined && { onError }),
|
|
79
|
+
// The producer travels UNCHANGED. PlayRenderer calls it at the first moment it
|
|
80
|
+
// needs the element, and it holds the memo — one mount builds one renderer, so
|
|
81
|
+
// a second memo here would hold the same element for the same lifetime. A
|
|
82
|
+
// producer gives every renderer its own element; a single element that every
|
|
83
|
+
// mount shares would pass from one container to the next on each null view,
|
|
84
|
+
// because appendChild moves a node.
|
|
85
|
+
...(fallback != null && { fallback }),
|
|
69
86
|
};
|
|
70
87
|
const renderer = new PlayRenderer(container, actor, registryResult.registry, rendererOptions);
|
|
88
|
+
// connect() renders the first view synchronously, and PlayRenderer appends the
|
|
89
|
+
// fallback itself when that view is null.
|
|
90
|
+
// It needs no `try`: PlayRenderer contains a failed rebuild AND a handler of the
|
|
91
|
+
// host that throws, so `connect()` returns for every view. `mount()` therefore
|
|
92
|
+
// always reaches the `return` below, and the caller always receives the release.
|
|
71
93
|
renderer.connect();
|
|
72
|
-
|
|
73
|
-
// connect() calls _render() synchronously. Therefore the container holds the view
|
|
74
|
-
// already at this point, when actor.currentView is not null.
|
|
75
|
-
if (fallback != null && container.childNodes.length === 0) {
|
|
76
|
-
container.appendChild(fallback);
|
|
77
|
-
}
|
|
78
|
-
return function disconnect() {
|
|
94
|
+
return asCleanup(function disconnect() {
|
|
79
95
|
renderer.disconnect();
|
|
80
|
-
};
|
|
96
|
+
});
|
|
81
97
|
};
|
|
82
98
|
}
|
|
83
99
|
//# sourceMappingURL=create-play-ui.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-play-ui.js","sourceRoot":"","sources":["../src/create-play-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;
|
|
1
|
+
{"version":3,"file":"create-play-ui.js","sourceRoot":"","sources":["../src/create-play-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,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E,0EAA0E;YAC1E,6EAA6E;YAC7E,4EAA4E;YAC5E,oCAAoC;YACpC,GAAG,CAAC,QAAQ,IAAI,IAAI,IAAI,EAAE,QAAQ,EAAE,CAAC;SACrC,CAAC;QAEF,MAAM,QAAQ,GAAG,IAAI,YAAY,CAChC,SAAS,EACT,KAAK,EACL,cAAc,CAAC,QAAQ,EACvB,eAAe,CACf,CAAC;QACF,+EAA+E;QAC/E,0CAA0C;QAC1C,iFAAiF;QACjF,+EAA+E;QAC/E,iFAAiF;QACjF,QAAQ,CAAC,OAAO,EAAE,CAAC;QAEnB,OAAO,SAAS,CAAC,SAAS,UAAU;YACnC,QAAQ,CAAC,UAAU,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
*
|
|
53
53
|
* @packageDocumentation
|
|
54
54
|
*/
|
|
55
|
-
import
|
|
56
|
-
import type {
|
|
55
|
+
import { type Cleanup } from "@xmachines/play";
|
|
56
|
+
import type { ViewActor } from "@xmachines/play-view";
|
|
57
57
|
import type { Catalog } from "@xmachines/json-render-core";
|
|
58
58
|
import type { ComponentRegistry } from "@xmachines/json-render-dom";
|
|
59
59
|
import type { PlayDomOptions } from "./types.js";
|
|
@@ -81,5 +81,5 @@ import type { PlayDomOptions } from "./types.js";
|
|
|
81
81
|
* `CreatePlayUIOptions`. You can also use `defineRegistry` with `PlayRenderer`
|
|
82
82
|
* directly.
|
|
83
83
|
*/
|
|
84
|
-
export declare function createRenderer<C extends Catalog>(catalog: C, componentMap: ComponentRegistry<C>): (actor:
|
|
84
|
+
export declare function createRenderer<C extends Catalog>(catalog: C, componentMap: ComponentRegistry<C>): (actor: ViewActor, container: HTMLElement, options?: Omit<PlayDomOptions, "registryResult">) => Cleanup;
|
|
85
85
|
//# sourceMappingURL=create-renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-renderer.d.ts","sourceRoot":"","sources":["../src/create-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"create-renderer.d.ts","sourceRoot":"","sources":["../src/create-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAC/C,OAAO,EAAE,CAAC,EACV,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAChC,CACF,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,WAAW,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAC5C,OAAO,CAWX"}
|
package/dist/create-renderer.js
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
*
|
|
53
53
|
* @packageDocumentation
|
|
54
54
|
*/
|
|
55
|
+
import { asCleanup } from "@xmachines/play";
|
|
55
56
|
import { PlayRenderer } from "./PlayRenderer.js";
|
|
56
57
|
import { defineRegistry } from "@xmachines/json-render-dom";
|
|
57
58
|
/**
|
|
@@ -86,7 +87,7 @@ export function createRenderer(catalog, componentMap) {
|
|
|
86
87
|
registryResult,
|
|
87
88
|
});
|
|
88
89
|
renderer.connect();
|
|
89
|
-
return () => renderer.disconnect();
|
|
90
|
+
return asCleanup(() => renderer.disconnect());
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
//# sourceMappingURL=create-renderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-renderer.js","sourceRoot":"","sources":["../src/create-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;
|
|
1
|
+
{"version":3,"file":"create-renderer.js","sourceRoot":"","sources":["../src/create-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,EAAE,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAK1D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,cAAc,CAC7B,OAAU,EACV,YAAkC;IAMlC,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC;IAE7E,OAAO,SAAS,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;QACnD,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,CAAC,QAAQ,EAAE;YAC5E,GAAG,OAAO;YACV,cAAc;SACd,CAAC,CAAC;QACH,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAC/C,CAAC,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -34,4 +34,5 @@ export { defineRegistry, renderSpec, schema, createValidationRegistry, } from "@
|
|
|
34
34
|
export type { ValidationRegistry, FieldValidationState } from "@xmachines/json-render-dom";
|
|
35
35
|
export type { RenderSpecOptions } from "@xmachines/json-render-dom";
|
|
36
36
|
export type { ConfirmHandler, EventHandle, SetState, RenderErrorHandler, UIProviderOptions, CatalogHasActions, BaseComponentProps, DomRenderContext, DomComponentRenderer, ComponentContext, ComponentFn, ComponentRegistry, Actions, ActionFn, DefineRegistryOptions, DefineRegistryResult, DomRegistry, DomSchema, } from "@xmachines/json-render-dom";
|
|
37
|
+
export { asCleanup, type Cleanup } from "@xmachines/play";
|
|
37
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGjE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGtE,OAAO,EACN,cAAc,EACd,UAAU,EACV,MAAM,EACN,wBAAwB,GACxB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EACX,cAAc,EACd,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,SAAS,GACT,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGjE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGtE,OAAO,EACN,cAAc,EACd,UAAU,EACV,MAAM,EACN,wBAAwB,GACxB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EACX,cAAc,EACd,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,SAAS,GACT,MAAM,4BAA4B,CAAC;AAQpC,OAAO,EAAE,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -31,4 +31,12 @@ export { createRenderer } from "./create-renderer.js";
|
|
|
31
31
|
export { createPlayUI } from "./create-play-ui.js";
|
|
32
32
|
// @xmachines/json-render-dom. This package re-exports it, for the convenience of a consumer
|
|
33
33
|
export { defineRegistry, renderSpec, schema, createValidationRegistry, } from "@xmachines/json-render-dom";
|
|
34
|
+
// The release protocol of @xmachines/play. This package's own published `.d.ts` names
|
|
35
|
+
// exactly these, so a consumer reads them from here and needs no second manifest entry.
|
|
36
|
+
//
|
|
37
|
+
// `asCleanup` is here because `MountFn` returns a `Cleanup`: a consumer that WRITES a
|
|
38
|
+
// mount — a wrapper, or a stand-in for one — BUILDS a release, and it therefore needs the
|
|
39
|
+
// one function that makes a plain release into one. A second type carried that narrowing
|
|
40
|
+
// before, and a consumer that wrote a `MountFn` reached none of it.
|
|
41
|
+
export { asCleanup } from "@xmachines/play";
|
|
34
42
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,qCAAqC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,4FAA4F;AAC5F,OAAO,EACN,cAAc,EACd,UAAU,EACV,MAAM,EACN,wBAAwB,GACxB,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,qCAAqC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,4FAA4F;AAC5F,OAAO,EACN,cAAc,EACd,UAAU,EACV,MAAM,EACN,wBAAwB,GACxB,MAAM,4BAA4B,CAAC;AAuBpC,sFAAsF;AACtF,wFAAwF;AACxF,EAAE;AACF,sFAAsF;AACtF,0FAA0F;AAC1F,yFAAyF;AACzF,oEAAoE;AACpE,OAAO,EAAE,SAAS,EAAgB,MAAM,iBAAiB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* types.ts — the type definitions of play-dom that belong to XMachines.
|
|
3
3
|
*
|
|
4
|
-
* These types depend on @xmachines/play-
|
|
4
|
+
* These types depend on @xmachines/play-view, and they stay in play-dom.
|
|
5
5
|
* Each pure json-render type is in @xmachines/json-render-dom.
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
@@ -47,6 +47,82 @@ export interface PlayDomOptions extends UIProviderOptions {
|
|
|
47
47
|
* This option matches the `loading` prop of the framework renderer providers.
|
|
48
48
|
*/
|
|
49
49
|
loading?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The optional handler of a failure of a complete rebuild of the view.
|
|
52
|
+
*
|
|
53
|
+
* This option is NOT the same as `onRenderError`, which {@link UIProviderOptions}
|
|
54
|
+
* gives: the inner renderer routes a render error of one component, and a rejection
|
|
55
|
+
* of one action handler, to `onRenderError`. It contains each of them per element,
|
|
56
|
+
* and the rebuild continues. `onError` receives the failure of the complete rebuild
|
|
57
|
+
* that no per-element boundary caught.
|
|
58
|
+
*
|
|
59
|
+
* The renderer CONTAINS a rebuild that throws, with this option and without it: it
|
|
60
|
+
* resets the state of the failed rebuild, so that the next emission makes a complete
|
|
61
|
+
* render again, and it clears the container. `connect()` renders the first view
|
|
62
|
+
* synchronously, so a bad initial view makes `connect()` throw no more.
|
|
63
|
+
*
|
|
64
|
+
* A WRITE of the store takes the same path. The renderer resolves the props of every
|
|
65
|
+
* element that the write touched, so a `$computed` function that throws on the new
|
|
66
|
+
* state aborts that render too. The renderer contains such a failure as well, and the
|
|
67
|
+
* action handler that wrote the state receives no exception.
|
|
68
|
+
*
|
|
69
|
+
* This option says WHERE the report goes. Without it, the renderer writes the
|
|
70
|
+
* contained failure to `console.error`.
|
|
71
|
+
*
|
|
72
|
+
* A handler that THROWS reaches no caller: the renderer contains that throw too, and
|
|
73
|
+
* it writes the throw to `console.error`. A host that must escalate a failure raises
|
|
74
|
+
* it from a task of its own — `queueMicrotask(() => { throw error; })` — which
|
|
75
|
+
* reaches the global handler of the page and leaves the containment whole. The five
|
|
76
|
+
* renderers hold this one rule.
|
|
77
|
+
*
|
|
78
|
+
* The second parameter is the RESET, for a retry that the host starts — a "Retry"
|
|
79
|
+
* button of its own. It renders the view that the actor holds at the MOMENT OF THE
|
|
80
|
+
* CALL, so a host that keeps the callback cannot rewind the screen to the view that
|
|
81
|
+
* failed. A reset that the host calls from inside this handler does nothing, because
|
|
82
|
+
* no input changed between the two attempts, and a reset after `disconnect()` does
|
|
83
|
+
* nothing.
|
|
84
|
+
*
|
|
85
|
+
* A reset belongs to ONE connection. `connect()` starts a connection, and the reset of
|
|
86
|
+
* a report of an older connection does nothing. A host that calls `connect()` again
|
|
87
|
+
* from inside this handler abandons the connection that reported. The "Retry" button
|
|
88
|
+
* of that report must not render into the connection that took its place. Call the
|
|
89
|
+
* reset of the newest report.
|
|
90
|
+
*
|
|
91
|
+
* This option matches the `onError` prop of the framework renderer providers, and the
|
|
92
|
+
* five renderers hold the same three rules for the reset.
|
|
93
|
+
*/
|
|
94
|
+
onError?: (error: unknown, reset: () => void) => void;
|
|
95
|
+
/**
|
|
96
|
+
* The optional element that the renderer shows when `currentView` is `null`, and
|
|
97
|
+
* after a failure of a rebuild that it contains.
|
|
98
|
+
*
|
|
99
|
+
* The renderer shows it for EVERY null view, and not for the first mount only: a view
|
|
100
|
+
* that returns to `null` after a view that was not `null` also shows it. The four
|
|
101
|
+
* framework providers hold the same rule for their placeholder content.
|
|
102
|
+
*
|
|
103
|
+
* The renderer shows it after a failure of a rebuild too. This option turns nothing
|
|
104
|
+
* on: the renderer contains such a failure always, and this option says only what the
|
|
105
|
+
* empty container shows. The next view that renders clears the container, which
|
|
106
|
+
* removes the element.
|
|
107
|
+
*
|
|
108
|
+
* **One element belongs to one renderer.** `appendChild` MOVES a node. Two renderers
|
|
109
|
+
* that hold the same element therefore take it from each other on every null view,
|
|
110
|
+
* and the container of the first one goes empty without a notice. Build one element
|
|
111
|
+
* for each `PlayRenderer`.
|
|
112
|
+
*
|
|
113
|
+
* A FUNCTION also works here. The renderer calls it at the first moment that it needs
|
|
114
|
+
* the element, and it keeps the result, so a renderer whose view is never null builds
|
|
115
|
+
* nothing. {@link CreatePlayUIOptions.fallback} passes such a function for each
|
|
116
|
+
* mount.
|
|
117
|
+
*
|
|
118
|
+
* A producer that THROWS is contained on BOTH paths — a null view, and a rebuild that
|
|
119
|
+
* failed — and the renderer writes it to `console.error` and NOT to
|
|
120
|
+
* {@link PlayDomOptions.onError}. On the second path the renderer calls the producer
|
|
121
|
+
* from inside the containment of the view, and a second trip through `onError` would
|
|
122
|
+
* report the failure of the fallback as a failure of the view. The container stays
|
|
123
|
+
* empty.
|
|
124
|
+
*/
|
|
125
|
+
fallback?: HTMLElement | (() => HTMLElement) | null;
|
|
50
126
|
}
|
|
51
127
|
/**
|
|
52
128
|
* The options of `createPlayUI()`, the complete DOM factory.
|
|
@@ -56,23 +132,39 @@ export interface PlayDomOptions extends UIProviderOptions {
|
|
|
56
132
|
* holds all of them from the moment of its creation, and it gives them to
|
|
57
133
|
* `PlayRenderer` on every `mount()` call.
|
|
58
134
|
*
|
|
135
|
+
* It also takes {@link PlayDomOptions.onError}, which the factory forwards without a
|
|
136
|
+
* change: `PlayRenderer` owns it, and it receives every failure of a rebuild that the
|
|
137
|
+
* renderer contains. Read that entry for the complete rule. `fallback` below says what
|
|
138
|
+
* the factory adds to {@link PlayDomOptions.fallback}.
|
|
139
|
+
*
|
|
59
140
|
* This type is parallel to the props of `PlayUIProvider` in the framework renderers.
|
|
60
141
|
*
|
|
61
142
|
* @see createPlayUI
|
|
62
143
|
*/
|
|
63
|
-
export interface CreatePlayUIOptions extends UIProviderOptions {
|
|
144
|
+
export interface CreatePlayUIOptions extends UIProviderOptions, Pick<PlayDomOptions, "onError"> {
|
|
64
145
|
/**
|
|
65
|
-
* The optional fallback
|
|
146
|
+
* The optional fallback content — see {@link PlayDomOptions.fallback} for what the
|
|
147
|
+
* renderer does with it. The factory shows it for every null view, and after a
|
|
148
|
+
* failure of a rebuild that the renderer contains.
|
|
149
|
+
*
|
|
150
|
+
* **Give a FUNCTION when the factory mounts more than one time.** ONE factory serves
|
|
151
|
+
* every `mount()` call, and `appendChild` MOVES a node. A single element therefore
|
|
152
|
+
* passes from one container to the next on every null view, and the container that
|
|
153
|
+
* loses it goes empty without a notice. A function runs one time for each mount, so
|
|
154
|
+
* every renderer owns its own element:
|
|
66
155
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const mount = createPlayUI(registryResult, {
|
|
158
|
+
* fallback: () => {
|
|
159
|
+
* const element = document.createElement("p");
|
|
160
|
+
* element.textContent = "Loading…";
|
|
161
|
+
* return element;
|
|
162
|
+
* },
|
|
163
|
+
* });
|
|
164
|
+
* ```
|
|
69
165
|
*
|
|
70
|
-
*
|
|
71
|
-
* renderer clears the container, and it does NOT append this fallback again. For a
|
|
72
|
-
* dynamic fallback, which follows a null view after a view that was not null, use
|
|
73
|
-
* `PlayRenderer` directly and wrap the `actor.currentView` signal to add the
|
|
74
|
-
* fallback content.
|
|
166
|
+
* An element stays correct for a factory that mounts one time.
|
|
75
167
|
*/
|
|
76
|
-
fallback?: HTMLElement | null;
|
|
168
|
+
fallback?: HTMLElement | (() => HTMLElement) | null;
|
|
77
169
|
}
|
|
78
170
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,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S,CAAC;IAC9F;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,GAAG,IAAI,CAAC;CACpD"}
|
package/dist/types.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* types.ts — the type definitions of play-dom that belong to XMachines.
|
|
3
3
|
*
|
|
4
|
-
* These types depend on @xmachines/play-
|
|
4
|
+
* These types depend on @xmachines/play-view, and they stay in play-dom.
|
|
5
5
|
* Each pure json-render type is in @xmachines/json-render-dom.
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/play-dom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Vanilla DOM renderer for XMachines Play architecture with signal-driven rendering",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actor",
|
|
@@ -41,39 +41,42 @@
|
|
|
41
41
|
"build": "vite build && tsc --build",
|
|
42
42
|
"clean": "rm -rf dist *.tsbuildinfo coverage .vitest-attachments test/browser/__screenshots__ node_modules/.svelte2tsx-* node_modules/.vite*",
|
|
43
43
|
"lint": "oxlint .",
|
|
44
|
+
"lint:security": "node ../../scripts/semgrep-scan.mjs",
|
|
44
45
|
"format": "oxfmt .",
|
|
45
46
|
"test": "vitest",
|
|
46
47
|
"test:coverage": "vitest run --coverage"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@xmachines/play": "
|
|
50
|
-
"@xmachines/play-actor": "2.2.0",
|
|
51
|
-
"@xmachines/play-signals": "2.2.0"
|
|
50
|
+
"@xmachines/play-view": "4.0.0"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@testing-library/jest-dom": "^
|
|
55
|
-
"@types/node": "^26.2
|
|
56
|
-
"@vitest/browser-playwright": "^
|
|
57
|
-
"@xmachines/json-render-core": "^0.20.0-xm.
|
|
58
|
-
"@xmachines/json-render-dom": "^0.20.0-xm.
|
|
59
|
-
"@xmachines/json-render-xstate": "^0.20.0-xm.
|
|
60
|
-
"@
|
|
61
|
-
"
|
|
62
|
-
"
|
|
53
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
54
|
+
"@types/node": "^26.6.2",
|
|
55
|
+
"@vitest/browser-playwright": "^5.0.1",
|
|
56
|
+
"@xmachines/json-render-core": "^0.20.0-xm.4",
|
|
57
|
+
"@xmachines/json-render-dom": "^0.20.0-xm.4",
|
|
58
|
+
"@xmachines/json-render-xstate": "^0.20.0-xm.4",
|
|
59
|
+
"@xmachines/play": "4.0.0",
|
|
60
|
+
"@xmachines/play-actor": "4.0.0",
|
|
61
|
+
"@xmachines/play-signals": "4.0.0",
|
|
62
|
+
"@xstate/store": "^3.17.5",
|
|
63
|
+
"oxfmt": "^0.68.0",
|
|
64
|
+
"oxlint": "^1.83.0",
|
|
63
65
|
"typescript": "^5.9.3 || ^6.0.3",
|
|
64
|
-
"vite": "^8.0
|
|
65
|
-
"vitest": "^
|
|
66
|
-
"xstate": "^5.
|
|
67
|
-
"zod": "^4.
|
|
66
|
+
"vite": "^8.3.0",
|
|
67
|
+
"vitest": "^5.0.1",
|
|
68
|
+
"xstate": "^5.33.0",
|
|
69
|
+
"zod": "^4.6.5"
|
|
68
70
|
},
|
|
69
71
|
"peerDependencies": {
|
|
70
|
-
"@xmachines/json-render-core": "^0.20.0-xm.
|
|
71
|
-
"@xmachines/json-render-dom": "^0.20.0-xm.
|
|
72
|
-
"@xmachines/json-render-xstate": "^0.20.0-xm.
|
|
73
|
-
"@
|
|
74
|
-
"
|
|
72
|
+
"@xmachines/json-render-core": "^0.20.0-xm.4",
|
|
73
|
+
"@xmachines/json-render-dom": "^0.20.0-xm.4",
|
|
74
|
+
"@xmachines/json-render-xstate": "^0.20.0-xm.4",
|
|
75
|
+
"@xmachines/play": "4.0.0",
|
|
76
|
+
"@xmachines/play-signals": "4.0.0",
|
|
77
|
+
"@xstate/store": "^3.17.0"
|
|
75
78
|
},
|
|
76
79
|
"engines": {
|
|
77
|
-
"node": ">=
|
|
80
|
+
"node": ">=24.0.0"
|
|
78
81
|
}
|
|
79
82
|
}
|