@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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Vanilla DOM renderer for XMachines Play architecture with signal-driven rendering.
|
|
4
4
|
|
|
5
|
-
[](https://opensource.org/licenses/MIT) [](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-dom)
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -13,14 +13,15 @@ pnpm add @xmachines/play-dom
|
|
|
13
13
|
**Peer dependencies:**
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
pnpm add
|
|
16
|
+
pnpm add @xstate/store @xmachines/json-render-core @xmachines/json-render-dom @xmachines/json-render-xstate
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Quick Start
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
22
|
import { createRenderer, schema } from "@xmachines/play-dom";
|
|
23
|
-
import { definePlayer } from "@xmachines/play-xstate";
|
|
23
|
+
import { definePlayer, compose, PlayerActor } from "@xmachines/play-xstate";
|
|
24
|
+
import { withView } from "@xmachines/play-xstate/view";
|
|
24
25
|
import { defineCatalog } from "@xmachines/json-render-core";
|
|
25
26
|
import { createMachine } from "xstate";
|
|
26
27
|
import { z } from "zod";
|
|
@@ -80,7 +81,8 @@ const machine = createMachine({
|
|
|
80
81
|
},
|
|
81
82
|
},
|
|
82
83
|
});
|
|
83
|
-
|
|
84
|
+
// `mount` needs the view capability
|
|
85
|
+
const actor = definePlayer({ machine, actor: compose(PlayerActor, withView) })();
|
|
84
86
|
actor.start();
|
|
85
87
|
|
|
86
88
|
// 5. Mount when actor and container are ready
|
|
@@ -114,7 +116,7 @@ disconnect();
|
|
|
114
116
|
|
|
115
117
|
Use `createPlayUI` when you need a render error handler, a fallback element, a navigation integration, a computed function, or a custom check. Use it also when your code needs the `registryResult` value, for example for `executeAction`.
|
|
116
118
|
|
|
117
|
-
The factory holds the factory options (`functions`, `validationFunctions`, `navigate`, `onRenderError`, and `fallback`) from the moment of its creation, and it applies them on every `mount()` call. Give the mount options (`store` and `loading`) to `mount()` itself.
|
|
119
|
+
The factory holds the factory options (`functions`, `validationFunctions`, `navigate`, `onRenderError`, `onError`, and `fallback`) from the moment of its creation, and it applies them on every `mount()` call. Give the mount options (`store` and `loading`) to `mount()` itself.
|
|
118
120
|
|
|
119
121
|
```typescript
|
|
120
122
|
import { defineRegistry, createPlayUI, schema } from "@xmachines/play-dom";
|
|
@@ -277,6 +279,69 @@ The order of the arguments is the same as in the `RenderErrorHandler` type of `@
|
|
|
277
279
|
|
|
278
280
|
Without `onRenderError`, the renderer writes all three types of error to `console.error`, then stops them. No exception goes to the caller, and no promise rejection stays unhandled.
|
|
279
281
|
|
|
282
|
+
### The renderer contains a failed rebuild — a change of behaviour in 2.3.0
|
|
283
|
+
|
|
284
|
+
**Read this if you catch what `mount()` or `connect()` throws.**
|
|
285
|
+
|
|
286
|
+
In 2.2.0 the renderer had no containment. A view that failed the rebuild threw out of
|
|
287
|
+
`mount()` and out of the callback of the signal watcher, so a `try` of the host, an error
|
|
288
|
+
boundary of the framework around it, or the global handler of the page received it.
|
|
289
|
+
|
|
290
|
+
In 2.3.0 the renderer contains such a failure ALWAYS. No option turns the containment on,
|
|
291
|
+
and no option turns it off. The renderer clears the container, it shows the `fallback`,
|
|
292
|
+
and `mount()` returns normally. A host that shows its own error page from a `catch` around
|
|
293
|
+
`mount()` sees that `catch` never again.
|
|
294
|
+
|
|
295
|
+
The four framework renderers contain a failed render always, because an error boundary of
|
|
296
|
+
a framework is not an option that a caller turns off. This change puts play-dom on the
|
|
297
|
+
same rule.
|
|
298
|
+
|
|
299
|
+
**To escalate a failure, raise it from a task of your own:**
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
const mount = createPlayUI(registryResult, {
|
|
303
|
+
onError: (err) => {
|
|
304
|
+
reportToSentry(err);
|
|
305
|
+
queueMicrotask(() => {
|
|
306
|
+
throw err; // the page keeps its own global handler
|
|
307
|
+
});
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
A throw that leaves the handler itself reaches no caller. The renderer contains it and
|
|
313
|
+
writes it to `console.error`, exactly as the four framework renderers do. The five hold
|
|
314
|
+
this one rule, so a host learns it one time and writes the same handler for each of them.
|
|
315
|
+
|
|
316
|
+
### `onError` — the failure of a complete rebuild
|
|
317
|
+
|
|
318
|
+
`onRenderError` covers one element: the inner renderer contains a render error of a component, and a rejection of an action handler, per element, and the rebuild continues. Some failures escape that boundary — a `$computed` function that throws during the resolution of a prop, for example — and they abort the complete rebuild.
|
|
319
|
+
|
|
320
|
+
`onError` receives such a failure. The renderer contains it with this option and without it: it resets the state of the failed rebuild, so that the next emission makes a complete render again, and it clears the container. `connect()` renders the first view synchronously, so a bad initial view makes `connect()` throw no more.
|
|
321
|
+
|
|
322
|
+
A write of the store takes the same path. The renderer resolves the props of every element that the write touched, so a `$computed` function that throws on the new state aborts that render too. The renderer contains such a failure as well, and the action handler that wrote the state receives no exception.
|
|
323
|
+
|
|
324
|
+
The second parameter is the **reset**, for a retry that the host starts. It renders the view that the actor holds at the moment of the call, so a retry cannot rewind the screen to the view that failed. A reset that the host calls from inside the handler does nothing, because no input changed between the two attempts, and a reset after the provider goes away does nothing. The five renderers hold the same three rules.
|
|
325
|
+
|
|
326
|
+
A reset of `PlayRenderer` belongs to ONE connection. `connect()` starts a connection, and the reset of a report of an older connection does nothing. A host that calls `connect()` again from inside the handler abandons the connection that reported. The "Retry" button of that report must not render into the connection that took its place. Call the reset of the newest report.
|
|
327
|
+
|
|
328
|
+
A fourth rule holds in all five: each of them CONTAINS a handler that throws, and writes the throw to `console.error`. A host that must escalate raises the failure from a task of its own, as the section above shows.
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
const mount = createPlayUI(registryResult, {
|
|
332
|
+
onError: (err) => reportToSentry(err),
|
|
333
|
+
fallback: document.getElementById("crashed")!,
|
|
334
|
+
});
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
`createPlayUI` adds the parity with the framework providers: the renderer contains the failure, and it appends the `fallback` to the container that the failed rebuild left clear. A later view that renders clears the container again, which removes the fallback.
|
|
338
|
+
|
|
339
|
+
`onError` says WHERE the report goes, and `fallback` says what the empty container shows. Neither option turns the containment on. Without `onError` the renderer writes the contained error to `console.error`, in the same way as it does for a component that throws without an `onRenderError` handler. Give `onError` to send the failure to your own observability tool instead.
|
|
340
|
+
|
|
341
|
+
**One fallback element belongs to one mount.** `appendChild` moves a node. Two mounts of the same factory therefore take the element from each other on every null view, and the container of the first one goes empty without a notice. Build one element for each `mount()` call.
|
|
342
|
+
|
|
343
|
+
**A `fallback` producer that throws is contained too — on a null view and after a failed rebuild alike — and it reports to `console.error` and NOT to `onError`.** After a failed rebuild the renderer calls the producer from inside the containment of the view, so a second trip through `onError` would report the failure of your fallback as a failure of the view. The container stays empty, and the renderer renders the next view that works.
|
|
344
|
+
|
|
280
345
|
A component implementation can also read the handler at `ctx.ctx.onRenderError`. A component therefore sends its own internal errors through the same channel:
|
|
281
346
|
|
|
282
347
|
```typescript
|
|
@@ -296,51 +361,40 @@ const Home: ComponentFn<typeof catalog, "Home"> = ({ ctx }) => {
|
|
|
296
361
|
|
|
297
362
|
### XMachines Layer
|
|
298
363
|
|
|
299
|
-
| Export | Kind | Description
|
|
300
|
-
| ---------------------------------------- | -------- |
|
|
301
|
-
| `createRenderer(catalog, components)` | function | The one-call factory.
|
|
302
|
-
| `createPlayUI(registryResult, options?)` | function | The complete factory. It returns a `MountFn`
|
|
303
|
-
| `PlayRenderer` | class | The renderer class, with a `connect()` and `disconnect()` lifecycle
|
|
304
|
-
| `defineRegistry(catalog, options)` | function | Build a catalog-typed `DomRegistry` with typed handlers
|
|
305
|
-
| `renderSpec(...)` | function | The pure low-level Spec → DOM renderer
|
|
306
|
-
| `schema` | const | The `@xmachines/json-render-dom` schema — pass to `defineCatalog()`
|
|
364
|
+
| Export | Kind | Description |
|
|
365
|
+
| ---------------------------------------- | -------- | ------------------------------------------------------------------- |
|
|
366
|
+
| `createRenderer(catalog, components)` | function | The one-call factory. Its `mount` hands a `Cleanup` back |
|
|
367
|
+
| `createPlayUI(registryResult, options?)` | function | The complete factory. It returns a `MountFn` |
|
|
368
|
+
| `PlayRenderer` | class | The renderer class, with a `connect()` and `disconnect()` lifecycle |
|
|
369
|
+
| `defineRegistry(catalog, options)` | function | Build a catalog-typed `DomRegistry` with typed handlers |
|
|
370
|
+
| `renderSpec(...)` | function | The pure low-level Spec → DOM renderer |
|
|
371
|
+
| `schema` | const | The `@xmachines/json-render-dom` schema — pass to `defineCatalog()` |
|
|
372
|
+
| `asCleanup`, `Cleanup` | — | The release a mount returns, re-exported from `@xmachines/play` |
|
|
307
373
|
|
|
308
374
|
### Key Types
|
|
309
375
|
|
|
310
|
-
| Type | Description
|
|
311
|
-
| ------------------------ |
|
|
312
|
-
| `ComponentFn<C, K>` | Catalog-typed component function — returns `HTMLElement \| Text \| null`
|
|
313
|
-
| `ComponentContext<C, K>` | The context of each component: `props`, `children`, `emit`, `on`, `bindings`, and `ctx`
|
|
314
|
-
| `ActionFn<C, K>` | Catalog-typed action function — receives `(params, setState, state)`
|
|
315
|
-
| `EventHandle` | The handle that `on(eventName)` returns. It has `emit()`, `shouldPreventDefault`, and `bound`
|
|
316
|
-
| `SetState` | State updater: `(prev => next) => void`
|
|
317
|
-
| `DefineRegistryResult` | The result of `defineRegistry`. It has `registry`, `handlers`, and `executeAction`
|
|
318
|
-
| `PlayDomOptions` | Options for `PlayRenderer` — extends `UIProviderOptions`
|
|
319
|
-
| `CreatePlayUIOptions` | Options for `createPlayUI` — extends `UIProviderOptions`, adds `fallback`
|
|
320
|
-
| `MountOptions` | Per-mount options for `MountFn`: `store`, `loading`
|
|
321
|
-
| `MountFn` | The mount
|
|
322
|
-
| `UIProviderOptions` | Shared options: `functions`, `validationFunctions`, `navigate`, `onRenderError`
|
|
323
|
-
| `BaseComponentProps<P>` | Catalog-agnostic component props for shared component libraries
|
|
324
|
-
| `DomRegistry` | Raw registry type: `Record<string, DomComponentRenderer>`
|
|
325
|
-
| `DomSchema` | Type of the `schema` export
|
|
326
|
-
| `
|
|
376
|
+
| Type | Description |
|
|
377
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------------------- |
|
|
378
|
+
| `ComponentFn<C, K>` | Catalog-typed component function — returns `HTMLElement \| Text \| null` |
|
|
379
|
+
| `ComponentContext<C, K>` | The context of each component: `props`, `children`, `emit`, `on`, `bindings`, and `ctx` |
|
|
380
|
+
| `ActionFn<C, K>` | Catalog-typed action function — receives `(params, setState, state)` |
|
|
381
|
+
| `EventHandle` | The handle that `on(eventName)` returns. It has `emit()`, `shouldPreventDefault`, and `bound` |
|
|
382
|
+
| `SetState` | State updater: `(prev => next) => void` |
|
|
383
|
+
| `DefineRegistryResult` | The result of `defineRegistry`. It has `registry`, `handlers`, and `executeAction` |
|
|
384
|
+
| `PlayDomOptions` | Options for `PlayRenderer` — extends `UIProviderOptions`, adds `fallback` and `onError` |
|
|
385
|
+
| `CreatePlayUIOptions` | Options for `createPlayUI` — extends `UIProviderOptions`, adds `fallback` and `onError` |
|
|
386
|
+
| `MountOptions` | Per-mount options for `MountFn`: `store`, `loading` |
|
|
387
|
+
| `MountFn` | The mount: `(actor, container, options?) → Cleanup`. `createPlayUI` returns one, and a consumer may write one |
|
|
388
|
+
| `UIProviderOptions` | Shared options: `functions`, `validationFunctions`, `navigate`, `onRenderError` |
|
|
389
|
+
| `BaseComponentProps<P>` | Catalog-agnostic component props for shared component libraries |
|
|
390
|
+
| `DomRegistry` | Raw registry type: `Record<string, DomComponentRenderer>` |
|
|
391
|
+
| `DomSchema` | Type of the `schema` export |
|
|
392
|
+
| `Cleanup` | The release of a mount, re-exported from `@xmachines/play` |
|
|
327
393
|
|
|
328
394
|
## Rendering Behavior
|
|
329
395
|
|
|
330
396
|
- **The first render is synchronous** — the renderer fills the container before `connect()` returns.
|
|
331
397
|
- **A signal-driven render waits for a microtask** — `watchSignal` puts each update on the next tick of the microtask queue.
|
|
332
|
-
- **A null view** clears the container
|
|
398
|
+
- **A null view** clears the container, and the renderer then shows the `fallback` element when you give one. It shows it for every null view, and not for the first mount only — the four framework providers hold the same rule for their placeholder content.
|
|
333
399
|
- **A second `connect()` is safe** — a `connect()` call on a connected renderer disconnects it first.
|
|
334
400
|
- **`disconnect()` clears the container** and cancels every signal watcher and store watcher.
|
|
335
|
-
|
|
336
|
-
## Testing
|
|
337
|
-
|
|
338
|
-
```bash
|
|
339
|
-
# Run all tests (jsdom environment)
|
|
340
|
-
pnpm test
|
|
341
|
-
|
|
342
|
-
# Run with coverage
|
|
343
|
-
pnpm run test:coverage
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
The tests are in `test/`. They use [Vitest](https://vitest.dev/) in a jsdom environment. The coverage thresholds are 80% for lines, functions, branches, and statements.
|
package/dist/PlayRenderer.d.ts
CHANGED
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
* gives one, and this is the controlled mode. Without that option, it makes a new
|
|
11
11
|
* @xstate/store atom for each view transition, with the values of spec.state.
|
|
12
12
|
*/
|
|
13
|
-
import type {
|
|
14
|
-
import type { AnyActorLogic } from "xstate";
|
|
13
|
+
import type { ViewActor } from "@xmachines/play-view";
|
|
15
14
|
import type { DomRegistry } from "@xmachines/json-render-dom";
|
|
16
15
|
import type { PlayDomOptions } from "./types.js";
|
|
17
16
|
/**
|
|
@@ -64,6 +63,15 @@ export declare class PlayRenderer {
|
|
|
64
63
|
private readonly actor;
|
|
65
64
|
private readonly registry;
|
|
66
65
|
private readonly options;
|
|
66
|
+
/**
|
|
67
|
+
* True from the start of `connect()` to the end of `disconnect()`.
|
|
68
|
+
*
|
|
69
|
+
* The watcher cannot answer this question. `connect()` installs it AFTER the
|
|
70
|
+
* synchronous first render, so a host that calls `connect()` again from the `onError`
|
|
71
|
+
* of that render finds no watcher, and a test of the watcher alone would skip the
|
|
72
|
+
* `disconnect()` and leave the guard of the abandoned connection alive for ever.
|
|
73
|
+
*/
|
|
74
|
+
private connected;
|
|
67
75
|
private unwatch;
|
|
68
76
|
private storeUnsubscribe;
|
|
69
77
|
/**
|
|
@@ -88,8 +96,10 @@ export declare class PlayRenderer {
|
|
|
88
96
|
*/
|
|
89
97
|
private lastViewKey;
|
|
90
98
|
private currentStore;
|
|
99
|
+
/** The fallback element, built at the first moment that the renderer shows it. */
|
|
100
|
+
private fallbackElement;
|
|
91
101
|
/**
|
|
92
|
-
* The shared coordinator of the store lifecycle, from @xmachines/play-
|
|
102
|
+
* The shared coordinator of the store lifecycle, from @xmachines/play-view. It
|
|
93
103
|
* seeds the store again on a change of the viewKey, it refreshes /context in place
|
|
94
104
|
* in every other case, and it guards the identity cache. The two fields above,
|
|
95
105
|
* lastViewKey and currentStore, stay as the DOM-side record for the fast path of a
|
|
@@ -104,6 +114,25 @@ export declare class PlayRenderer {
|
|
|
104
114
|
* call, which is rare but correct, changes no detached DOM tree.
|
|
105
115
|
*/
|
|
106
116
|
private alive;
|
|
117
|
+
/**
|
|
118
|
+
* The report guard, from @xmachines/play-view.
|
|
119
|
+
*
|
|
120
|
+
* It blocks a reset that the host calls from INSIDE the report, and every reset once
|
|
121
|
+
* the renderer is disconnected. The five renderers share the one implementation.
|
|
122
|
+
*
|
|
123
|
+
* `alive` cannot answer the second half. A contained failure sets that flag to `false`
|
|
124
|
+
* and the next emission sets it back, because it guards the callback of the store
|
|
125
|
+
* subscription — a reset that a host keeps outlives both.
|
|
126
|
+
*/
|
|
127
|
+
private guard;
|
|
128
|
+
/**
|
|
129
|
+
* The retry that every report of THIS connection hands the host.
|
|
130
|
+
*
|
|
131
|
+
* `connect()` builds one, beside the guard that it belongs to. The four framework
|
|
132
|
+
* renderers hand the host one reset for the life of the provider, and this field holds
|
|
133
|
+
* the same rule for the life of the connection.
|
|
134
|
+
*/
|
|
135
|
+
private retry;
|
|
107
136
|
/**
|
|
108
137
|
* @param container - The `HTMLElement` to render into. Each view transition clears it and fills it again.
|
|
109
138
|
* @param actor - The actor with the `currentView` signal. It must implement `Viewable`.
|
|
@@ -117,8 +146,10 @@ export declare class PlayRenderer {
|
|
|
117
146
|
* - `validationFunctions` — your own check functions. They are available at `ctx.ctx.validationFunctions`.
|
|
118
147
|
* - `navigate` — the navigation callback. The renderer calls it for `onSuccess: { navigate: "..." }`.
|
|
119
148
|
* - `onRenderError` — the `(error, name)` handler of a component render error and of an action handler rejection. It stops the `console.error` fallback.
|
|
149
|
+
* - `onError` — the `(error, reset)` handler of a failure of a complete rebuild. The renderer contains such a failure always, and this option says where the report goes.
|
|
150
|
+
* - `fallback` — the element to show for every null view, and after a contained failure.
|
|
120
151
|
*/
|
|
121
|
-
constructor(container: HTMLElement, actor:
|
|
152
|
+
constructor(container: HTMLElement, actor: ViewActor, registry: DomRegistry, options?: PlayDomOptions);
|
|
122
153
|
/**
|
|
123
154
|
* Starts the watch of actor.currentView, and renders into the container.
|
|
124
155
|
* It renders the first view synchronously, then it subscribes to the signal changes.
|
|
@@ -142,11 +173,77 @@ export declare class PlayRenderer {
|
|
|
142
173
|
*/
|
|
143
174
|
get watchCleanupCount(): number;
|
|
144
175
|
private render;
|
|
176
|
+
/**
|
|
177
|
+
* The end of a render that failed, in ONE place.
|
|
178
|
+
*
|
|
179
|
+
* Three paths render — the fast path of a slice, the complete rebuild, and the write
|
|
180
|
+
* of the store — and each one ends here. The ORDER is load-bearing: the reset takes
|
|
181
|
+
* the registrations of the dead tree down BEFORE the report, so a handler of the host
|
|
182
|
+
* that renders again meets a renderer that holds nothing of the failed attempt. A
|
|
183
|
+
* second copy of the pair is a second chance to put the two in the other order.
|
|
184
|
+
*
|
|
185
|
+
* @param error - The failure that the renderer contains.
|
|
186
|
+
*/
|
|
187
|
+
private failView;
|
|
188
|
+
/**
|
|
189
|
+
* Clears the screen of the failed view, shows the fallback, and reports the failure.
|
|
190
|
+
*
|
|
191
|
+
* The renderer contains such a failure ALWAYS. No option turns the containment on,
|
|
192
|
+
* and none turns it off: `onError` says where the report goes, and `fallback` says
|
|
193
|
+
* what the empty container shows. The four framework renderers hold the same rule,
|
|
194
|
+
* because an error boundary of a framework is not an option that a caller turns off.
|
|
195
|
+
* A host that must escalate a failure raises it from a task of its own —
|
|
196
|
+
* `queueMicrotask(() => { throw error; })` — because the guard contains a handler
|
|
197
|
+
* that throws, exactly as the four framework renderers do.
|
|
198
|
+
*
|
|
199
|
+
* The container is cleared FIRST. The fast path of a slice holds the live tree of the
|
|
200
|
+
* previous emission, and that tree is dead as soon as the refresh throws, so the
|
|
201
|
+
* renderer must not keep it on the screen. A clear container also lets the fallback
|
|
202
|
+
* stand alone.
|
|
203
|
+
*
|
|
204
|
+
* The SCREEN comes first, and the report second: a handler that throws — a reporter
|
|
205
|
+
* that fails, or one that re-raises to escalate — must not defeat the containment
|
|
206
|
+
* that it was given to observe. With the order reversed the container stays empty AND
|
|
207
|
+
* the error escapes, which is both outcomes that the containment exists to prevent.
|
|
208
|
+
*/
|
|
209
|
+
private contain;
|
|
210
|
+
/**
|
|
211
|
+
* Builds the retry that one report hands the host.
|
|
212
|
+
*
|
|
213
|
+
* The read of the signal happens at the moment of the CALL: a retry that held the view
|
|
214
|
+
* that failed would take a host off the healthy screen and back onto the one that
|
|
215
|
+
* threw.
|
|
216
|
+
*
|
|
217
|
+
* The retry belongs to the guard of ITS connection, and it asks that guard alone. A
|
|
218
|
+
* host may KEEP the callback — a "Retry" button of a toast outlives the route that
|
|
219
|
+
* opened it — and `disconnect()` disposes the guard that was live then. `connect()`
|
|
220
|
+
* disconnects a connected renderer first, so every guard that leaves the field is a
|
|
221
|
+
* disposed guard, and a retry of an older connection stays dead. The rule of the prop
|
|
222
|
+
* is one rule: a reset after `disconnect()` does nothing.
|
|
223
|
+
*
|
|
224
|
+
* @param guard - The guard of the connection that this retry belongs to.
|
|
225
|
+
*/
|
|
226
|
+
private retryOf;
|
|
227
|
+
/**
|
|
228
|
+
* Appends the fallback element to the container, which the caller cleared already.
|
|
229
|
+
* The renderer calls it for a null view, and after a failure of a rebuild that it
|
|
230
|
+
* contains. Both callers clear the container first. `appendChild` moves the node.
|
|
231
|
+
* Therefore a second call adds no copy.
|
|
232
|
+
*/
|
|
233
|
+
private showFallback;
|
|
145
234
|
/**
|
|
146
235
|
* A rebuild that fails must not leave the guard of the fast path armed on a dead
|
|
147
236
|
* tree, because the container is empty already. Therefore this code resets the view
|
|
148
237
|
* identity. The next emission, also one with the same viewKey, then makes a
|
|
149
238
|
* complete render again. It does not patch a store that nothing shows.
|
|
239
|
+
*
|
|
240
|
+
* It releases the watch subscriptions of the dead tree too. A complete rebuild
|
|
241
|
+
* releases them before it builds again, and disconnect() releases them at the end of
|
|
242
|
+
* the life of the renderer — but a failure takes the DOM down HERE, between those two
|
|
243
|
+
* moments. Without this step one update of the store of the host runs every watch
|
|
244
|
+
* action of a tree that nothing shows, against detached elements, with `send` still
|
|
245
|
+
* bound to the actor. The fast path of a slice leaves a live tree of its own, and it
|
|
246
|
+
* reaches this code only when it fails.
|
|
150
247
|
*/
|
|
151
248
|
private resetFailedRebuild;
|
|
152
249
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlayRenderer.d.ts","sourceRoot":"","sources":["../src/PlayRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"PlayRenderer.d.ts","sourceRoot":"","sources":["../src/PlayRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH,OAAO,KAAK,EAAmC,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIvF,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAyDjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,qBAAa,YAAY;IA+FvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAjGzB;;;;;;;OAOG;IACH,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,gBAAgB,CAA6B;IACrD;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa,CAAyB;IAC9C;;;;;;;;;;OAUG;IACH,OAAO,CAAC,WAAW,CAAiC;IACpD,OAAO,CAAC,YAAY,CAA2B;IAC/C,kFAAkF;IAClF,OAAO,CAAC,eAAe,CAA4B;IACnD;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAE7B;IACF;;;;;OAKG;IACH,OAAO,CAAC,KAAK,CAAQ;IAErB;;;;;;;;;OASG;IAGH,OAAO,CAAC,KAAK,CAAkD;IAE/D;;;;;;OAMG;IACH,OAAO,CAAC,KAAK,CAAwC;IAErD;;;;;;;;;;;;;;;OAeG;gBAEe,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE,cAAmB;IAG9C;;;;;;;;OAQG;IACH,OAAO,IAAI,IAAI;IAyCf;;OAEG;IACH,UAAU,IAAI,IAAI;IA4BlB;;;;;;OAMG;IACH,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,OAAO,CAAC,MAAM;IAmGd;;;;;;;;;;OAUG;IACH,OAAO,CAAC,QAAQ;IAKhB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAC,OAAO;IAiBf;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,OAAO;IAOf;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IA4BpB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,kBAAkB;IAuB1B;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;CA6HlB"}
|