@xmachines/play-dom 2.0.0 → 2.1.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 +99 -65
- package/dist/PlayRenderer.d.ts +82 -77
- package/dist/PlayRenderer.d.ts.map +1 -1
- package/dist/PlayRenderer.js +173 -161
- package/dist/PlayRenderer.js.map +1 -1
- package/dist/create-play-ui.d.ts +38 -36
- package/dist/create-play-ui.d.ts.map +1 -1
- package/dist/create-play-ui.js +30 -28
- package/dist/create-play-ui.js.map +1 -1
- package/dist/create-renderer.d.ts +26 -22
- package/dist/create-renderer.d.ts.map +1 -1
- package/dist/create-renderer.js +26 -22
- package/dist/create-renderer.js.map +1 -1
- package/dist/index.d.ts +19 -19
- package/dist/index.js +21 -21
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +38 -35
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/package.json +6 -5
- package/dist/errors.d.ts +0 -46
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -52
- package/dist/errors.js.map +0 -1
package/dist/create-play-ui.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* createPlayUI —
|
|
2
|
+
* createPlayUI — the complete DOM factory.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* It takes a `DefineRegistryResult`, and the caller calls `defineRegistry` itself.
|
|
5
|
+
* It returns a `MountFn`. A `mount(actor, container)` call starts the renderer, and
|
|
6
|
+
* it returns a `disconnect` cleanup function.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* `onRenderError`, `fallback`)
|
|
10
|
-
* every `mount()` call.
|
|
11
|
-
* to the `mount()` call itself
|
|
8
|
+
* The factory holds the factory options (`functions`, `validationFunctions`,
|
|
9
|
+
* `navigate`, `onRenderError`, and `fallback`) from the moment of its creation, and
|
|
10
|
+
* it applies them on every `mount()` call. Give the mount options (`store` and
|
|
11
|
+
* `loading`) to the `mount()` call itself, through `MountOptions`.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* This factory is parallel to `<PlayUIProvider registryResult={...}>` in the
|
|
14
|
+
* framework renderers.
|
|
14
15
|
*
|
|
15
16
|
* @example
|
|
16
17
|
* ```typescript
|
|
@@ -36,50 +37,51 @@ import type { StateStore } from "@xmachines/json-render-core";
|
|
|
36
37
|
import type { DefineRegistryResult } from "@xmachines/json-render-dom";
|
|
37
38
|
import type { CreatePlayUIOptions } from "./types.js";
|
|
38
39
|
/**
|
|
39
|
-
*
|
|
40
|
+
* The mount options of the `MountFn` that `createPlayUI` returns.
|
|
40
41
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* `onRenderError`, `fallback`)
|
|
42
|
+
* They replace or complete the factory options, for one actor and one container.
|
|
43
|
+
* The `createPlayUI` call sets the factory options (`functions`,
|
|
44
|
+
* `validationFunctions`, `navigate`, `onRenderError`, and `fallback`) one time.
|
|
44
45
|
*/
|
|
45
46
|
export interface MountOptions {
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
48
|
+
* The optional external `StateStore`, which is the controlled mode.
|
|
49
|
+
* Without it, the renderer makes a new `@xstate/store` atom for each view
|
|
50
|
+
* transition, with the values of `spec.state`.
|
|
50
51
|
*/
|
|
51
52
|
store?: StateStore;
|
|
52
53
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
54
|
+
* With the value `true`, the renderer stops each warning about an absent child
|
|
55
|
+
* during the ingestion of a streaming spec. It also gives `ctx.ctx.loading` to each
|
|
56
|
+
* component implementation.
|
|
55
57
|
*/
|
|
56
58
|
loading?: boolean;
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
|
-
* The mount function
|
|
61
|
+
* The mount function that `createPlayUI` returns.
|
|
60
62
|
*
|
|
61
|
-
* Call with `(actor, container, mountOptions?)` to start the renderer.
|
|
62
|
-
*
|
|
63
|
-
* the container.
|
|
63
|
+
* Call it with `(actor, container, mountOptions?)` to start the renderer.
|
|
64
|
+
* It returns a `disconnect` cleanup function. That function stops the render and
|
|
65
|
+
* clears the container.
|
|
64
66
|
*/
|
|
65
67
|
export type MountFn = (actor: AbstractActor<AnyActorLogic> & Viewable, container: HTMLElement, options?: MountOptions) => () => void;
|
|
66
68
|
/**
|
|
67
|
-
*
|
|
69
|
+
* Creates the mount function of the complete DOM renderer.
|
|
68
70
|
*
|
|
69
|
-
* The caller
|
|
70
|
-
*
|
|
71
|
-
*
|
|
71
|
+
* The caller makes `registryResult` with `defineRegistry`. `createPlayUI` holds it,
|
|
72
|
+
* and it returns a `MountFn`. Call that function one time for each pair of an actor
|
|
73
|
+
* and a container.
|
|
72
74
|
*
|
|
73
|
-
* @param registryResult -
|
|
74
|
-
* and the
|
|
75
|
-
* @param options -
|
|
76
|
-
* - `functions` — named compute functions
|
|
77
|
-
* - `directives` —
|
|
78
|
-
* - `validationFunctions` —
|
|
79
|
-
* - `navigate` — navigation callback
|
|
80
|
-
* - `onRenderError` — `(error, name)` handler
|
|
81
|
-
* - `fallback` — element
|
|
82
|
-
* @returns `MountFn`: `(actor, container, mountOptions?) → disconnect`
|
|
75
|
+
* @param registryResult - The result of `defineRegistry()`. It gives the registry
|
|
76
|
+
* and the factory of the handlers, which it builds late.
|
|
77
|
+
* @param options - The factory configuration. See {@link CreatePlayUIOptions}:
|
|
78
|
+
* - `functions` — the named compute functions of a `$computed` prop expression.
|
|
79
|
+
* - `directives` — your own dynamic values with a `$` prefix. The renderer resolves them with the props.
|
|
80
|
+
* - `validationFunctions` — your own check functions. They are available at `ctx.ctx.validationFunctions`.
|
|
81
|
+
* - `navigate` — the navigation callback. The renderer calls it for `onSuccess: { navigate: "..." }`.
|
|
82
|
+
* - `onRenderError` — the `(error, name)` handler of a component render error and of an action handler rejection.
|
|
83
|
+
* - `fallback` — the element to show when the first view of the actor is `null`.
|
|
84
|
+
* @returns The `MountFn`: `(actor, container, mountOptions?) → disconnect`
|
|
83
85
|
*/
|
|
84
86
|
export declare function createPlayUI(registryResult: DefineRegistryResult, options?: CreatePlayUIOptions): MountFn;
|
|
85
87
|
//# sourceMappingURL=create-play-ui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-play-ui.d.ts","sourceRoot":"","sources":["../src/create-play-ui.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"create-play-ui.d.ts","sourceRoot":"","sources":["../src/create-play-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG,CACrB,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,QAAQ,EAC9C,SAAS,EAAE,WAAW,EACtB,OAAO,CAAC,EAAE,YAAY,KAClB,MAAM,IAAI,CAAC;AAEhB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAC3B,cAAc,EAAE,oBAAoB,EACpC,OAAO,GAAE,mBAAwB,GAC/B,OAAO,CA8CT"}
|
package/dist/create-play-ui.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* createPlayUI —
|
|
2
|
+
* createPlayUI — the complete DOM factory.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* It takes a `DefineRegistryResult`, and the caller calls `defineRegistry` itself.
|
|
5
|
+
* It returns a `MountFn`. A `mount(actor, container)` call starts the renderer, and
|
|
6
|
+
* it returns a `disconnect` cleanup function.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* `onRenderError`, `fallback`)
|
|
10
|
-
* every `mount()` call.
|
|
11
|
-
* to the `mount()` call itself
|
|
8
|
+
* The factory holds the factory options (`functions`, `validationFunctions`,
|
|
9
|
+
* `navigate`, `onRenderError`, and `fallback`) from the moment of its creation, and
|
|
10
|
+
* it applies them on every `mount()` call. Give the mount options (`store` and
|
|
11
|
+
* `loading`) to the `mount()` call itself, through `MountOptions`.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* This factory is parallel to `<PlayUIProvider registryResult={...}>` in the
|
|
14
|
+
* framework renderers.
|
|
14
15
|
*
|
|
15
16
|
* @example
|
|
16
17
|
* ```typescript
|
|
@@ -32,28 +33,29 @@
|
|
|
32
33
|
*/
|
|
33
34
|
import { PlayRenderer } from "./PlayRenderer.js";
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
+
* Creates the mount function of the complete DOM renderer.
|
|
36
37
|
*
|
|
37
|
-
* The caller
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* The caller makes `registryResult` with `defineRegistry`. `createPlayUI` holds it,
|
|
39
|
+
* and it returns a `MountFn`. Call that function one time for each pair of an actor
|
|
40
|
+
* and a container.
|
|
40
41
|
*
|
|
41
|
-
* @param registryResult -
|
|
42
|
-
* and the
|
|
43
|
-
* @param options -
|
|
44
|
-
* - `functions` — named compute functions
|
|
45
|
-
* - `directives` —
|
|
46
|
-
* - `validationFunctions` —
|
|
47
|
-
* - `navigate` — navigation callback
|
|
48
|
-
* - `onRenderError` — `(error, name)` handler
|
|
49
|
-
* - `fallback` — element
|
|
50
|
-
* @returns `MountFn`: `(actor, container, mountOptions?) → disconnect`
|
|
42
|
+
* @param registryResult - The result of `defineRegistry()`. It gives the registry
|
|
43
|
+
* and the factory of the handlers, which it builds late.
|
|
44
|
+
* @param options - The factory configuration. See {@link CreatePlayUIOptions}:
|
|
45
|
+
* - `functions` — the named compute functions of a `$computed` prop expression.
|
|
46
|
+
* - `directives` — your own dynamic values with a `$` prefix. The renderer resolves them with the props.
|
|
47
|
+
* - `validationFunctions` — your own check functions. They are available at `ctx.ctx.validationFunctions`.
|
|
48
|
+
* - `navigate` — the navigation callback. The renderer calls it for `onSuccess: { navigate: "..." }`.
|
|
49
|
+
* - `onRenderError` — the `(error, name)` handler of a component render error and of an action handler rejection.
|
|
50
|
+
* - `fallback` — the element to show when the first view of the actor is `null`.
|
|
51
|
+
* @returns The `MountFn`: `(actor, container, mountOptions?) → disconnect`
|
|
51
52
|
*/
|
|
52
53
|
export function createPlayUI(registryResult, options = {}) {
|
|
53
54
|
const { onRenderError, fallback, functions, directives, validationFunctions, navigate, onConfirm, } = options;
|
|
54
55
|
return function mount(actor, container, mountOptions) {
|
|
55
|
-
//
|
|
56
|
-
//
|
|
56
|
+
// Each option of UIProviderOptions (onRenderError, functions, validationFunctions,
|
|
57
|
+
// and navigate) goes directly through PlayDomOptions, then PlayRenderer, then
|
|
58
|
+
// renderSpec, then DomRenderContext.
|
|
57
59
|
const rendererOptions = {
|
|
58
60
|
registryResult,
|
|
59
61
|
...(mountOptions?.store !== undefined && { store: mountOptions.store }),
|
|
@@ -67,9 +69,9 @@ export function createPlayUI(registryResult, options = {}) {
|
|
|
67
69
|
};
|
|
68
70
|
const renderer = new PlayRenderer(container, actor, registryResult.registry, rendererOptions);
|
|
69
71
|
renderer.connect();
|
|
70
|
-
// Handle fallback
|
|
71
|
-
// connect() calls _render() synchronously
|
|
72
|
-
// at this point
|
|
72
|
+
// Handle the fallback of a null view on the first mount.
|
|
73
|
+
// connect() calls _render() synchronously. Therefore the container holds the view
|
|
74
|
+
// already at this point, when actor.currentView is not null.
|
|
73
75
|
if (fallback != null && container.childNodes.length === 0) {
|
|
74
76
|
container.appendChild(fallback);
|
|
75
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-play-ui.js","sourceRoot":"","sources":["../src/create-play-ui.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"create-play-ui.js","sourceRoot":"","sources":["../src/create-play-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAuCjD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAC3B,cAAoC,EACpC,UAA+B,EAAE;IAEjC,MAAM,EACL,aAAa,EACb,QAAQ,EACR,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,QAAQ,EACR,SAAS,GACT,GAAG,OAAO,CAAC;IAEZ,OAAO,SAAS,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,YAAY;QACnD,mFAAmF;QACnF,8EAA8E;QAC9E,qCAAqC;QACrC,MAAM,eAAe,GAAG;YACvB,cAAc;YACd,GAAG,CAAC,YAAY,EAAE,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC;YACvE,GAAG,CAAC,YAAY,EAAE,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC;YAC7E,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC;YAC7C,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,CAAC;YAC/C,GAAG,CAAC,mBAAmB,KAAK,SAAS,IAAI,EAAE,mBAAmB,EAAE,CAAC;YACjE,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC3C,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC;YAC7C,GAAG,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,aAAa,EAAE,CAAC;SACrD,CAAC;QAEF,MAAM,QAAQ,GAAG,IAAI,YAAY,CAChC,SAAS,EACT,KAAK,EACL,cAAc,CAAC,QAAQ,EACvB,eAAe,CACf,CAAC;QACF,QAAQ,CAAC,OAAO,EAAE,CAAC;QAEnB,yDAAyD;QACzD,kFAAkF;QAClF,6DAA6D;QAC7D,IAAI,QAAQ,IAAI,IAAI,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3D,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;QAED,OAAO,SAAS,UAAU;YACzB,QAAQ,CAAC,UAAU,EAAE,CAAC;QACvB,CAAC,CAAC;IACH,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* create-renderer.ts — createRenderer
|
|
2
|
+
* create-renderer.ts — the createRenderer factory of @xmachines/play-dom.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `mount(actor, container, options?)` function
|
|
7
|
-
* returns a `disconnect` cleanup function.
|
|
4
|
+
* It matches the `createRenderer` export of @xmachines/json-render-react, of /vue,
|
|
5
|
+
* of /solid, and of /svelte. It calls `defineRegistry` one time, at the creation of
|
|
6
|
+
* the factory. It then returns a `mount(actor, container, options?)` function. That
|
|
7
|
+
* function connects a PlayRenderer, and it returns a `disconnect` cleanup function.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* The consumer therefore writes one call, and not three or four steps.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
* return el;
|
|
41
41
|
* };
|
|
42
42
|
*
|
|
43
|
-
* // Build the factory
|
|
43
|
+
* // Build the factory one time, at module scope
|
|
44
44
|
* const mount = createRenderer(catalog, { Home, Login });
|
|
45
45
|
*
|
|
46
|
-
* // Mount when actor
|
|
46
|
+
* // Mount when the actor and the container are ready
|
|
47
47
|
* const disconnect = mount(actor, document.getElementById("app")!);
|
|
48
48
|
*
|
|
49
|
-
* //
|
|
49
|
+
* // Clean up:
|
|
50
50
|
* disconnect();
|
|
51
51
|
* ```
|
|
52
52
|
*
|
|
@@ -58,24 +58,28 @@ 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";
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Creates a DOM renderer factory from a catalog and a component map. You can use
|
|
62
|
+
* the factory more than one time.
|
|
62
63
|
*
|
|
63
|
-
*
|
|
64
|
-
* PlayRenderer in one call and returns a `disconnect` cleanup function.
|
|
64
|
+
* It returns a `mount(actor, container, options?)` function. That function connects
|
|
65
|
+
* the PlayRenderer in one call, and it returns a `disconnect` cleanup function.
|
|
65
66
|
*
|
|
66
|
-
* @param catalog - The json-render Catalog
|
|
67
|
-
* @param componentMap -
|
|
68
|
-
* @returns A `mount` function
|
|
67
|
+
* @param catalog - The json-render Catalog. It describes the schema of each component and of each action.
|
|
68
|
+
* @param componentMap - The component implementations, with the catalog component name as the key.
|
|
69
|
+
* @returns A `mount` function. It accepts `(actor, container, options?)`, and it returns `disconnect`.
|
|
69
70
|
*
|
|
70
71
|
* @remarks
|
|
71
|
-
* `createRenderer` manages `registryResult` internally
|
|
72
|
-
*
|
|
73
|
-
* `
|
|
72
|
+
* `createRenderer` manages `registryResult` internally. It calls `defineRegistry`
|
|
73
|
+
* one time, and it uses that result in every `mount()` call. Therefore the options
|
|
74
|
+
* type of `mount` holds no `registryResult`: `createRenderer` always gives it, and
|
|
75
|
+
* you cannot replace it.
|
|
74
76
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* `
|
|
77
|
+
* Two situations need a different function. In the first, your code calls
|
|
78
|
+
* `registryResult.executeAction()` itself, outside the emit and on flow. In the
|
|
79
|
+
* second, you give more provider options, such as `navigate`, `onRenderError`, or
|
|
80
|
+
* `functions`. Use `createPlayUI`, which accepts the complete
|
|
81
|
+
* `CreatePlayUIOptions`. You can also use `defineRegistry` with `PlayRenderer`
|
|
82
|
+
* directly.
|
|
79
83
|
*/
|
|
80
84
|
export declare function createRenderer<C extends Catalog>(catalog: C, componentMap: ComponentRegistry<C>): (actor: AbstractActor<AnyActorLogic> & Viewable, container: HTMLElement, options?: Omit<PlayDomOptions, "registryResult">) => () => void;
|
|
81
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,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,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
|
|
1
|
+
{"version":3,"file":"create-renderer.d.ts","sourceRoot":"","sources":["../src/create-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,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,aAAa,CAAC,aAAa,CAAC,GAAG,QAAQ,EAC9C,SAAS,EAAE,WAAW,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAC5C,MAAM,IAAI,CAWd"}
|
package/dist/create-renderer.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* create-renderer.ts — createRenderer
|
|
2
|
+
* create-renderer.ts — the createRenderer factory of @xmachines/play-dom.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `mount(actor, container, options?)` function
|
|
7
|
-
* returns a `disconnect` cleanup function.
|
|
4
|
+
* It matches the `createRenderer` export of @xmachines/json-render-react, of /vue,
|
|
5
|
+
* of /solid, and of /svelte. It calls `defineRegistry` one time, at the creation of
|
|
6
|
+
* the factory. It then returns a `mount(actor, container, options?)` function. That
|
|
7
|
+
* function connects a PlayRenderer, and it returns a `disconnect` cleanup function.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* The consumer therefore writes one call, and not three or four steps.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
* return el;
|
|
41
41
|
* };
|
|
42
42
|
*
|
|
43
|
-
* // Build the factory
|
|
43
|
+
* // Build the factory one time, at module scope
|
|
44
44
|
* const mount = createRenderer(catalog, { Home, Login });
|
|
45
45
|
*
|
|
46
|
-
* // Mount when actor
|
|
46
|
+
* // Mount when the actor and the container are ready
|
|
47
47
|
* const disconnect = mount(actor, document.getElementById("app")!);
|
|
48
48
|
*
|
|
49
|
-
* //
|
|
49
|
+
* // Clean up:
|
|
50
50
|
* disconnect();
|
|
51
51
|
* ```
|
|
52
52
|
*
|
|
@@ -55,24 +55,28 @@
|
|
|
55
55
|
import { PlayRenderer } from "./PlayRenderer.js";
|
|
56
56
|
import { defineRegistry } from "@xmachines/json-render-dom";
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* Creates a DOM renderer factory from a catalog and a component map. You can use
|
|
59
|
+
* the factory more than one time.
|
|
59
60
|
*
|
|
60
|
-
*
|
|
61
|
-
* PlayRenderer in one call and returns a `disconnect` cleanup function.
|
|
61
|
+
* It returns a `mount(actor, container, options?)` function. That function connects
|
|
62
|
+
* the PlayRenderer in one call, and it returns a `disconnect` cleanup function.
|
|
62
63
|
*
|
|
63
|
-
* @param catalog - The json-render Catalog
|
|
64
|
-
* @param componentMap -
|
|
65
|
-
* @returns A `mount` function
|
|
64
|
+
* @param catalog - The json-render Catalog. It describes the schema of each component and of each action.
|
|
65
|
+
* @param componentMap - The component implementations, with the catalog component name as the key.
|
|
66
|
+
* @returns A `mount` function. It accepts `(actor, container, options?)`, and it returns `disconnect`.
|
|
66
67
|
*
|
|
67
68
|
* @remarks
|
|
68
|
-
* `createRenderer` manages `registryResult` internally
|
|
69
|
-
*
|
|
70
|
-
* `
|
|
69
|
+
* `createRenderer` manages `registryResult` internally. It calls `defineRegistry`
|
|
70
|
+
* one time, and it uses that result in every `mount()` call. Therefore the options
|
|
71
|
+
* type of `mount` holds no `registryResult`: `createRenderer` always gives it, and
|
|
72
|
+
* you cannot replace it.
|
|
71
73
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* `
|
|
74
|
+
* Two situations need a different function. In the first, your code calls
|
|
75
|
+
* `registryResult.executeAction()` itself, outside the emit and on flow. In the
|
|
76
|
+
* second, you give more provider options, such as `navigate`, `onRenderError`, or
|
|
77
|
+
* `functions`. Use `createPlayUI`, which accepts the complete
|
|
78
|
+
* `CreatePlayUIOptions`. You can also use `defineRegistry` with `PlayRenderer`
|
|
79
|
+
* directly.
|
|
76
80
|
*/
|
|
77
81
|
export function createRenderer(catalog, componentMap) {
|
|
78
82
|
const registryResult = defineRegistry(catalog, { components: componentMap });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-renderer.js","sourceRoot":"","sources":["../src/create-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D
|
|
1
|
+
{"version":3,"file":"create-renderer.js","sourceRoot":"","sources":["../src/create-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAOH,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,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @xmachines/play-dom —
|
|
2
|
+
* @xmachines/play-dom — the vanilla DOM renderer of the XMachines Play architecture.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The public API has two layers:
|
|
5
5
|
*
|
|
6
|
-
* **XMachines layer
|
|
7
|
-
* - `createRenderer()` — one-call factory
|
|
8
|
-
* - `createPlayUI()` —
|
|
9
|
-
* - `PlayRenderer` —
|
|
6
|
+
* **The XMachines layer**, in this package:
|
|
7
|
+
* - `createRenderer()` — the one-call factory. It returns `mount(actor, container, options?) → disconnect`
|
|
8
|
+
* - `createPlayUI()` — the complete factory, with every option. It returns a `MountFn`
|
|
9
|
+
* - `PlayRenderer` — the renderer class, with a `connect()` and `disconnect()` lifecycle
|
|
10
10
|
* - `PlayDomOptions`, `CreatePlayUIOptions`, `MountFn`, `MountOptions`
|
|
11
11
|
*
|
|
12
|
-
* **json-render layer
|
|
13
|
-
* - `defineRegistry` —
|
|
14
|
-
* - `renderSpec` — pure Spec → DOM renderer
|
|
15
|
-
* - `ComponentFn` — catalog-typed component function
|
|
16
|
-
* - `ComponentContext` — catalog-typed render context
|
|
17
|
-
* - `ComponentRegistry` — catalog-typed
|
|
18
|
-
* - `DomComponentRenderer` — raw
|
|
19
|
-
* - `DomRegistry` — raw registry type
|
|
20
|
-
* - `DomRenderContext` — raw render context
|
|
21
|
-
* - `EventHandle` — event handle
|
|
22
|
-
* - `SetState` — state updater function
|
|
23
|
-
* - `CatalogHasActions` — conditional type
|
|
24
|
-
* - `BaseComponentProps` — base props type
|
|
12
|
+
* **The json-render layer**, re-exported from @xmachines/json-render-dom:
|
|
13
|
+
* - `defineRegistry` — it builds a catalog-typed DomRegistry
|
|
14
|
+
* - `renderSpec` — the pure Spec → DOM renderer. It uses resolveElementProps of the core
|
|
15
|
+
* - `ComponentFn` — the catalog-typed type of a component function
|
|
16
|
+
* - `ComponentContext` — the catalog-typed render context: props, emit, on, children, bindings
|
|
17
|
+
* - `ComponentRegistry` — the catalog-typed input type of the registry
|
|
18
|
+
* - `DomComponentRenderer` — the raw renderer type of one element
|
|
19
|
+
* - `DomRegistry` — the raw registry type
|
|
20
|
+
* - `DomRenderContext` — the raw render context
|
|
21
|
+
* - `EventHandle` — the event handle that on() returns
|
|
22
|
+
* - `SetState` — the state updater function of an ActionFn
|
|
23
|
+
* - `CatalogHasActions` — the conditional type. It is true when the catalog declares an action
|
|
24
|
+
* - `BaseComponentProps` — the base props type of a catalog component definition
|
|
25
25
|
*
|
|
26
26
|
* @packageDocumentation
|
|
27
27
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @xmachines/play-dom —
|
|
2
|
+
* @xmachines/play-dom — the vanilla DOM renderer of the XMachines Play architecture.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The public API has two layers:
|
|
5
5
|
*
|
|
6
|
-
* **XMachines layer
|
|
7
|
-
* - `createRenderer()` — one-call factory
|
|
8
|
-
* - `createPlayUI()` —
|
|
9
|
-
* - `PlayRenderer` —
|
|
6
|
+
* **The XMachines layer**, in this package:
|
|
7
|
+
* - `createRenderer()` — the one-call factory. It returns `mount(actor, container, options?) → disconnect`
|
|
8
|
+
* - `createPlayUI()` — the complete factory, with every option. It returns a `MountFn`
|
|
9
|
+
* - `PlayRenderer` — the renderer class, with a `connect()` and `disconnect()` lifecycle
|
|
10
10
|
* - `PlayDomOptions`, `CreatePlayUIOptions`, `MountFn`, `MountOptions`
|
|
11
11
|
*
|
|
12
|
-
* **json-render layer
|
|
13
|
-
* - `defineRegistry` —
|
|
14
|
-
* - `renderSpec` — pure Spec → DOM renderer
|
|
15
|
-
* - `ComponentFn` — catalog-typed component function
|
|
16
|
-
* - `ComponentContext` — catalog-typed render context
|
|
17
|
-
* - `ComponentRegistry` — catalog-typed
|
|
18
|
-
* - `DomComponentRenderer` — raw
|
|
19
|
-
* - `DomRegistry` — raw registry type
|
|
20
|
-
* - `DomRenderContext` — raw render context
|
|
21
|
-
* - `EventHandle` — event handle
|
|
22
|
-
* - `SetState` — state updater function
|
|
23
|
-
* - `CatalogHasActions` — conditional type
|
|
24
|
-
* - `BaseComponentProps` — base props type
|
|
12
|
+
* **The json-render layer**, re-exported from @xmachines/json-render-dom:
|
|
13
|
+
* - `defineRegistry` — it builds a catalog-typed DomRegistry
|
|
14
|
+
* - `renderSpec` — the pure Spec → DOM renderer. It uses resolveElementProps of the core
|
|
15
|
+
* - `ComponentFn` — the catalog-typed type of a component function
|
|
16
|
+
* - `ComponentContext` — the catalog-typed render context: props, emit, on, children, bindings
|
|
17
|
+
* - `ComponentRegistry` — the catalog-typed input type of the registry
|
|
18
|
+
* - `DomComponentRenderer` — the raw renderer type of one element
|
|
19
|
+
* - `DomRegistry` — the raw registry type
|
|
20
|
+
* - `DomRenderContext` — the raw render context
|
|
21
|
+
* - `EventHandle` — the event handle that on() returns
|
|
22
|
+
* - `SetState` — the state updater function of an ActionFn
|
|
23
|
+
* - `CatalogHasActions` — the conditional type. It is true when the catalog declares an action
|
|
24
|
+
* - `BaseComponentProps` — the base props type of a catalog component definition
|
|
25
25
|
*
|
|
26
26
|
* @packageDocumentation
|
|
27
27
|
*/
|
|
28
|
-
//
|
|
28
|
+
// The integration layer of XMachines
|
|
29
29
|
export { PlayRenderer } from "./PlayRenderer.js";
|
|
30
30
|
export { createRenderer } from "./create-renderer.js";
|
|
31
31
|
export { createPlayUI } from "./create-play-ui.js";
|
|
32
|
-
// @xmachines/json-render-dom
|
|
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
34
|
//# 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,
|
|
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"}
|