@loomwork/ui-hydration 0.0.0-stage → 0.1.1
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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +398 -2
- package/dist/cache.d.ts +71 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +157 -0
- package/dist/cache.js.map +1 -0
- package/dist/chatSource.d.ts +105 -0
- package/dist/chatSource.d.ts.map +1 -0
- package/dist/chatSource.js +264 -0
- package/dist/chatSource.js.map +1 -0
- package/dist/client.d.ts +17 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +36 -0
- package/dist/client.js.map +1 -0
- package/dist/contentRefs.d.ts +78 -0
- package/dist/contentRefs.d.ts.map +1 -0
- package/dist/contentRefs.js +129 -0
- package/dist/contentRefs.js.map +1 -0
- package/dist/controller.d.ts +228 -0
- package/dist/controller.d.ts.map +1 -0
- package/dist/controller.js +454 -0
- package/dist/controller.js.map +1 -0
- package/dist/dataProvider.d.ts +53 -0
- package/dist/dataProvider.d.ts.map +1 -0
- package/dist/dataProvider.js +77 -0
- package/dist/dataProvider.js.map +1 -0
- package/dist/esm/cache.js +151 -0
- package/dist/esm/cache.js.map +1 -0
- package/dist/esm/chatSource.js +259 -0
- package/dist/esm/chatSource.js.map +1 -0
- package/dist/esm/client.js +15 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/contentRefs.js +119 -0
- package/dist/esm/contentRefs.js.map +1 -0
- package/dist/esm/controller.js +449 -0
- package/dist/esm/controller.js.map +1 -0
- package/dist/esm/dataProvider.js +72 -0
- package/dist/esm/dataProvider.js.map +1 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/invoker.js +2 -0
- package/dist/esm/invoker.js.map +1 -0
- package/dist/esm/invokers.js +310 -0
- package/dist/esm/invokers.js.map +1 -0
- package/dist/esm/loomEffectProvider.js +96 -0
- package/dist/esm/loomEffectProvider.js.map +1 -0
- package/dist/esm/params.js +207 -0
- package/dist/esm/params.js.map +1 -0
- package/dist/esm/path.js +24 -0
- package/dist/esm/path.js.map +1 -0
- package/dist/esm/plan.js +190 -0
- package/dist/esm/plan.js.map +1 -0
- package/dist/esm/projection.js +230 -0
- package/dist/esm/projection.js.map +1 -0
- package/dist/esm/provider.js +416 -0
- package/dist/esm/provider.js.map +1 -0
- package/dist/esm/repair.js +53 -0
- package/dist/esm/repair.js.map +1 -0
- package/dist/esm/reshape.js +156 -0
- package/dist/esm/reshape.js.map +1 -0
- package/dist/esm/restricted.js +54 -0
- package/dist/esm/restricted.js.map +1 -0
- package/dist/esm/scheduler.js +247 -0
- package/dist/esm/scheduler.js.map +1 -0
- package/dist/esm/select.js +18 -0
- package/dist/esm/select.js.map +1 -0
- package/dist/esm/shape.js +34 -0
- package/dist/esm/shape.js.map +1 -0
- package/dist/esm/split/client.js +312 -0
- package/dist/esm/split/client.js.map +1 -0
- package/dist/esm/split/index.js +3 -0
- package/dist/esm/split/index.js.map +1 -0
- package/dist/esm/split/server.js +488 -0
- package/dist/esm/split/server.js.map +1 -0
- package/dist/esm/split/shared.js +13 -0
- package/dist/esm/split/shared.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/invoker.d.ts +10 -0
- package/dist/invoker.d.ts.map +1 -0
- package/dist/invoker.js +3 -0
- package/dist/invoker.js.map +1 -0
- package/dist/invokers.d.ts +36 -0
- package/dist/invokers.d.ts.map +1 -0
- package/dist/invokers.js +315 -0
- package/dist/invokers.js.map +1 -0
- package/dist/loomEffectProvider.d.ts +67 -0
- package/dist/loomEffectProvider.d.ts.map +1 -0
- package/dist/loomEffectProvider.js +101 -0
- package/dist/loomEffectProvider.js.map +1 -0
- package/dist/params.d.ts +103 -0
- package/dist/params.d.ts.map +1 -0
- package/dist/params.js +221 -0
- package/dist/params.js.map +1 -0
- package/dist/path.d.ts +12 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +28 -0
- package/dist/path.js.map +1 -0
- package/dist/plan.d.ts +56 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +199 -0
- package/dist/plan.js.map +1 -0
- package/dist/projection.d.ts +122 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +238 -0
- package/dist/projection.js.map +1 -0
- package/dist/provider.d.ts +152 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +421 -0
- package/dist/provider.js.map +1 -0
- package/dist/repair.d.ts +18 -0
- package/dist/repair.d.ts.map +1 -0
- package/dist/repair.js +57 -0
- package/dist/repair.js.map +1 -0
- package/dist/reshape.d.ts +32 -0
- package/dist/reshape.d.ts.map +1 -0
- package/dist/reshape.js +164 -0
- package/dist/reshape.js.map +1 -0
- package/dist/restricted.d.ts +21 -0
- package/dist/restricted.d.ts.map +1 -0
- package/dist/restricted.js +61 -0
- package/dist/restricted.js.map +1 -0
- package/dist/scheduler.d.ts +82 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +254 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/select.d.ts +34 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +21 -0
- package/dist/select.js.map +1 -0
- package/dist/shape.d.ts +3 -0
- package/dist/shape.d.ts.map +1 -0
- package/dist/shape.js +37 -0
- package/dist/shape.js.map +1 -0
- package/dist/split/client.d.ts +135 -0
- package/dist/split/client.d.ts.map +1 -0
- package/dist/split/client.js +316 -0
- package/dist/split/client.js.map +1 -0
- package/dist/split/index.d.ts +5 -0
- package/dist/split/index.d.ts.map +1 -0
- package/dist/split/index.js +14 -0
- package/dist/split/index.js.map +1 -0
- package/dist/split/server.d.ts +160 -0
- package/dist/split/server.d.ts.map +1 -0
- package/dist/split/server.js +496 -0
- package/dist/split/server.js.map +1 -0
- package/dist/split/shared.d.ts +6 -0
- package/dist/split/shared.d.ts.map +1 -0
- package/dist/split/shared.js +19 -0
- package/dist/split/shared.js.map +1 -0
- package/package.json +77 -3
- package/src/cache.ts +211 -0
- package/src/chatSource.ts +378 -0
- package/src/client.ts +46 -0
- package/src/contentRefs.ts +195 -0
- package/src/controller.ts +708 -0
- package/src/dataProvider.ts +141 -0
- package/src/index.ts +86 -0
- package/src/invoker.ts +14 -0
- package/src/invokers.ts +348 -0
- package/src/loomEffectProvider.ts +136 -0
- package/src/params.ts +314 -0
- package/src/path.ts +26 -0
- package/src/plan.ts +197 -0
- package/src/projection.ts +297 -0
- package/src/provider.ts +657 -0
- package/src/repair.ts +70 -0
- package/src/reshape.ts +193 -0
- package/src/restricted.ts +69 -0
- package/src/scheduler.ts +284 -0
- package/src/select.ts +59 -0
- package/src/shape.ts +39 -0
- package/src/split/client.ts +452 -0
- package/src/split/index.ts +18 -0
- package/src/split/server.ts +746 -0
- package/src/split/shared.ts +18 -0
package/dist/plan.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":";;;AAsBA,8BAkDC;AAED,sCAGC;AAaD,4BAoBC;AAGD,kCAGC;AAWD,wCAWC;AAQD,4CAkDC;AAlMD,iFAAiF;AACjF,+FAA+F;AAC/F,iGAAiG;AACjG,iGAAiG;AACjG,4FAA4F;AAC5F,iGAAiG;AACjG,gGAAgG;AAChG,+FAA+F;AAC/F,uFAAuF;AAEvF;;;;;;;;;GASG;AACH,SAAgB,SAAS,CAAC,KAA6B;IAIrD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,KAAK,CAAS,KAAK,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,KAAK,CAAS,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI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O,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { Projection, ProjectionRuntime } from "@loomwork/projection-runtime";
|
|
2
|
+
import type { Audience, Finding } from "@loomwork/ui-core";
|
|
3
|
+
export declare const HYDRATION_PROJECTION_ID = "loom-ui.hydration";
|
|
4
|
+
/**
|
|
5
|
+
* Bump when the MEANING of `values`/`status` changes; the compiler pins this into every blueprint.
|
|
6
|
+
* 1.1.0: a status may be `empty` (loom ADR 0100), and the fold DROPS the handle's value with it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const HYDRATION_PROJECTION_VERSION = "1.1.0";
|
|
9
|
+
export declare const HYDRATION_SET_EVENT = "LOOM_UI_HYDRATION_SET";
|
|
10
|
+
/**
|
|
11
|
+
* `empty`: delivered, and the upstream has no such row — "no data", never an error (loom ADR
|
|
12
|
+
* 0100). It never carries a value: the fold drops `values[handle]` on it.
|
|
13
|
+
*/
|
|
14
|
+
export type HandleState = "pending" | "ready" | "stale" | "error" | "empty";
|
|
15
|
+
export interface HandleStatus {
|
|
16
|
+
readonly state: HandleState;
|
|
17
|
+
readonly seq: number;
|
|
18
|
+
readonly finding?: Finding;
|
|
19
|
+
}
|
|
20
|
+
export interface HydrationState {
|
|
21
|
+
readonly values: Record<string, unknown>;
|
|
22
|
+
readonly status: Record<string, HandleStatus>;
|
|
23
|
+
}
|
|
24
|
+
export declare function isReservedHandle(handle: string): boolean;
|
|
25
|
+
export declare function hydrationProjection(): Projection<HydrationState>;
|
|
26
|
+
export interface HandleSlice {
|
|
27
|
+
readonly value: unknown;
|
|
28
|
+
readonly status: HandleStatus | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What a store's state belongs to. Isolation is by (experience, principal, audience); two viewers
|
|
32
|
+
* of one experience must not share a store — `values` holds whatever the viewer's own principal chain
|
|
33
|
+
* was allowed to read, so a shared store is a cross-viewer data leak, not a cache win.
|
|
34
|
+
* Omit `principalId` only where there is genuinely one viewer (a single-user CLI, a test).
|
|
35
|
+
*/
|
|
36
|
+
export interface HydrationScope {
|
|
37
|
+
readonly experienceId: string;
|
|
38
|
+
readonly principalId?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The audience the store's surface is drawn for (`@loomwork/ui-core` `Audience`). A broadcast
|
|
41
|
+
* surface and a viewer surface of the same principal are DIFFERENT scopes: a broadcast bind
|
|
42
|
+
* removes the handles it withholds, and that must never erase the personal surface's values.
|
|
43
|
+
* The controller refuses a store whose audience differs from its own ({@link HydrationAudienceMismatchError}).
|
|
44
|
+
*/
|
|
45
|
+
readonly audience?: Audience;
|
|
46
|
+
}
|
|
47
|
+
/** A controller and its store disagree about the audience (one broadcast, the other not). */
|
|
48
|
+
export declare class HydrationAudienceMismatchError extends Error {
|
|
49
|
+
readonly controllerBroadcast: boolean;
|
|
50
|
+
readonly code: "hydration-audience-mismatch";
|
|
51
|
+
constructor(controllerBroadcast: boolean);
|
|
52
|
+
}
|
|
53
|
+
/** An `experienceId` or `principalId` contains NUL, the separator of the broadcast scope key. */
|
|
54
|
+
export declare class HydrationScopeError extends Error {
|
|
55
|
+
readonly field: "experienceId" | "principalId";
|
|
56
|
+
readonly code: "hydration-scope-invalid";
|
|
57
|
+
constructor(field: "experienceId" | "principalId");
|
|
58
|
+
}
|
|
59
|
+
export declare class HydrationStore {
|
|
60
|
+
private readonly runtime;
|
|
61
|
+
readonly scope: HydrationScope;
|
|
62
|
+
/** Open token streams by handle (see {@link append}). A replace/remove/empty ends the handle's. */
|
|
63
|
+
private readonly streams;
|
|
64
|
+
/**
|
|
65
|
+
* Installed by the controller that fronts this store: a refusal for a handle that may not take
|
|
66
|
+
* chunks (restricted for the viewer, unbound, not a streaming widget). Absent on a bare store.
|
|
67
|
+
*/
|
|
68
|
+
private appendGuard;
|
|
69
|
+
private seq;
|
|
70
|
+
private emitSeq;
|
|
71
|
+
/** The projection state key: the scope, flattened. Derived — never passed in. */
|
|
72
|
+
readonly executionId: string;
|
|
73
|
+
/**
|
|
74
|
+
* Isolation is by (experience, principal); two viewers of one experience must not share a
|
|
75
|
+
* store. The projection is keyed by `executionId`, so a per-viewer store is what keeps one
|
|
76
|
+
* viewer's values out of another's widgets even on a SHARED `ProjectionRuntime`.
|
|
77
|
+
*/
|
|
78
|
+
constructor(runtime: ProjectionRuntime, scope: HydrationScope, opts?: {
|
|
79
|
+
register?: boolean;
|
|
80
|
+
});
|
|
81
|
+
state(): HydrationState;
|
|
82
|
+
status(handle: string): HandleStatus | undefined;
|
|
83
|
+
value(handle: string): unknown;
|
|
84
|
+
handles(): string[];
|
|
85
|
+
setStatus(handle: string, status: Omit<HandleStatus, "seq">): void;
|
|
86
|
+
setValue(handle: string, value: unknown, status: Omit<HandleStatus, "seq">): void;
|
|
87
|
+
remove(handle: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Gate every {@link append} through `guard` (a refusal finding, or undefined to allow). A
|
|
90
|
+
* `HydrationController` installs one over the store it fronts, so a producer cannot write a
|
|
91
|
+
* viewer-restricted handle's text into the projected store behind the controller's back. A bare
|
|
92
|
+
* store (no controller) has no viewer and no experience to gate against and stays ungated.
|
|
93
|
+
*/
|
|
94
|
+
guardAppend(guard: ((handle: string) => Finding | undefined) | undefined): void;
|
|
95
|
+
/**
|
|
96
|
+
* Append one chunk of a token stream (`StreamingText`) to a handle. The handle's value is the
|
|
97
|
+
* accumulated string — widgets and the value contract are unchanged — and its status is
|
|
98
|
+
* `pending` while the stream is open and `ready` once a chunk carries `done`.
|
|
99
|
+
*
|
|
100
|
+
* ORDERING with a whole-value writer (`setValue`/`remove`, e.g. the controller superseding a
|
|
101
|
+
* load): they are synchronous and the last writer wins. A replace ENDS the stream; the
|
|
102
|
+
* producer's next chunk then refuses (`stream-gap`, `seq` no longer 0) rather than corrupt the
|
|
103
|
+
* replacement, and a producer that wants to stream again starts a new stream at `seq` 0, which
|
|
104
|
+
* replaces the value. The contract itself (idempotence, gap, close, bounds) is core's
|
|
105
|
+
* `appendChunk`. A refusal emits nothing; a duplicate is `applied: false` and emits nothing.
|
|
106
|
+
*/
|
|
107
|
+
append(handle: string, chunk: unknown): {
|
|
108
|
+
ok: true;
|
|
109
|
+
applied: boolean;
|
|
110
|
+
} | {
|
|
111
|
+
ok: false;
|
|
112
|
+
finding: Finding;
|
|
113
|
+
};
|
|
114
|
+
/** Whole-state subscription: fires on ANY handle's value or status change. For a surface that renders the full projection (e.g. a terminal `watch` loop) rather than one widget's slice. */
|
|
115
|
+
runtimeSubscribe(listener: (state: HydrationState) => void): () => void;
|
|
116
|
+
/** Slice-scoped: fires only when THIS handle's status seq or value changes. Change-only, like loom's subscribe. */
|
|
117
|
+
subscribe(handle: string, listener: (slice: HandleSlice) => void): () => void;
|
|
118
|
+
private assertValidHandle;
|
|
119
|
+
private stamp;
|
|
120
|
+
private emit;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAW3D,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAC3D;;;GAGG;AACH,eAAO,MAAM,4BAA4B,UAAU,CAAC;AACpD,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAC5E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,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E,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI;IAa7E,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,IAAI;CAab"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HydrationStore = exports.HydrationScopeError = exports.HydrationAudienceMismatchError = exports.HYDRATION_SET_EVENT = exports.HYDRATION_PROJECTION_VERSION = exports.HYDRATION_PROJECTION_ID = void 0;
|
|
4
|
+
exports.isReservedHandle = isReservedHandle;
|
|
5
|
+
exports.hydrationProjection = hydrationProjection;
|
|
6
|
+
const browser_1 = require("@loomwork/ui-core/browser");
|
|
7
|
+
// ── One projection, keyed by handle ───────────────────────────────────────────
|
|
8
|
+
// Compiled widgets bind to `values.<handle>` and declare `status.<handle>` as their status
|
|
9
|
+
// channel (core's `hydrationPath`/`hydrationStatusPath`), and the compiler pins
|
|
10
|
+
// HYDRATION_PROJECTION_VERSION into the blueprint (ADR 0095). Hydration is imperative and
|
|
11
|
+
// transient — nothing here is durable or replayed — so the projection is driven by ONE synthetic
|
|
12
|
+
// in-memory event type. `subscribeSelector` gives each handle its own slice, so a value resolving
|
|
13
|
+
// wakes one widget, not the surface.
|
|
14
|
+
exports.HYDRATION_PROJECTION_ID = "loom-ui.hydration";
|
|
15
|
+
/**
|
|
16
|
+
* Bump when the MEANING of `values`/`status` changes; the compiler pins this into every blueprint.
|
|
17
|
+
* 1.1.0: a status may be `empty` (loom ADR 0100), and the fold DROPS the handle's value with it.
|
|
18
|
+
*/
|
|
19
|
+
exports.HYDRATION_PROJECTION_VERSION = "1.1.0";
|
|
20
|
+
exports.HYDRATION_SET_EVENT = "LOOM_UI_HYDRATION_SET";
|
|
21
|
+
const RESERVED = new Set(["__proto__", "constructor", "prototype"]);
|
|
22
|
+
function isReservedHandle(handle) {
|
|
23
|
+
return RESERVED.has(handle);
|
|
24
|
+
}
|
|
25
|
+
// `Object.fromEntries` uses CreateDataProperty for each entry, so a `__proto__` key lands as
|
|
26
|
+
// an own property — never the prototype setter that a plain `out[k] = v` assignment would hit.
|
|
27
|
+
function without(rec, key) {
|
|
28
|
+
return Object.fromEntries(Object.entries(rec).filter(([k]) => k !== key));
|
|
29
|
+
}
|
|
30
|
+
function hydrationProjection() {
|
|
31
|
+
return {
|
|
32
|
+
id: exports.HYDRATION_PROJECTION_ID,
|
|
33
|
+
version: exports.HYDRATION_PROJECTION_VERSION,
|
|
34
|
+
initialState: { values: {}, status: {} },
|
|
35
|
+
handlers: {
|
|
36
|
+
[exports.HYDRATION_SET_EVENT]: (state, event) => {
|
|
37
|
+
const p = event.payload;
|
|
38
|
+
// Defense in depth: `HydrationStore` already refuses reserved handles before emitting,
|
|
39
|
+
// but this projection is registered on a SHARED runtime — any other holder of that
|
|
40
|
+
// runtime can call `handleEvent` directly with a forged envelope, bypassing the store.
|
|
41
|
+
// The fold itself must never write a reserved handle into state.
|
|
42
|
+
if (isReservedHandle(p.handle))
|
|
43
|
+
return state;
|
|
44
|
+
if (p.kind === "remove") {
|
|
45
|
+
if (!Object.hasOwn(state.status, p.handle) && !Object.hasOwn(state.values, p.handle))
|
|
46
|
+
return state;
|
|
47
|
+
return {
|
|
48
|
+
values: without(state.values, p.handle),
|
|
49
|
+
status: without(state.status, p.handle),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const status = { ...state.status, [p.handle]: p.status };
|
|
53
|
+
// loom ADR 0100 D1: a producer MUST clear the value beside `empty` — an older reader that
|
|
54
|
+
// cannot see `empty` would otherwise show an earlier `ready` value as current.
|
|
55
|
+
if (p.status?.state === "empty")
|
|
56
|
+
return {
|
|
57
|
+
values: Object.hasOwn(state.values, p.handle)
|
|
58
|
+
? without(state.values, p.handle)
|
|
59
|
+
: state.values,
|
|
60
|
+
status,
|
|
61
|
+
};
|
|
62
|
+
if (p.kind === "status")
|
|
63
|
+
return { values: state.values, status };
|
|
64
|
+
return { values: { ...state.values, [p.handle]: p.value }, status };
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** A controller and its store disagree about the audience (one broadcast, the other not). */
|
|
70
|
+
class HydrationAudienceMismatchError extends Error {
|
|
71
|
+
controllerBroadcast;
|
|
72
|
+
code = "hydration-audience-mismatch";
|
|
73
|
+
constructor(controllerBroadcast) {
|
|
74
|
+
super(controllerBroadcast
|
|
75
|
+
? 'HydrationController: a broadcast controller needs a store scoped { audience: "broadcast" }'
|
|
76
|
+
: "HydrationController: a store scoped to a broadcast audience needs a broadcast controller");
|
|
77
|
+
this.controllerBroadcast = controllerBroadcast;
|
|
78
|
+
this.name = "HydrationAudienceMismatchError";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.HydrationAudienceMismatchError = HydrationAudienceMismatchError;
|
|
82
|
+
/** An `experienceId` or `principalId` contains NUL, the separator of the broadcast scope key. */
|
|
83
|
+
class HydrationScopeError extends Error {
|
|
84
|
+
field;
|
|
85
|
+
code = "hydration-scope-invalid";
|
|
86
|
+
constructor(field) {
|
|
87
|
+
super(`HydrationStore: ${field} must not contain a NUL character (it separates the broadcast scope key)`);
|
|
88
|
+
this.field = field;
|
|
89
|
+
this.name = "HydrationScopeError";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.HydrationScopeError = HydrationScopeError;
|
|
93
|
+
class HydrationStore {
|
|
94
|
+
runtime;
|
|
95
|
+
scope;
|
|
96
|
+
/** Open token streams by handle (see {@link append}). A replace/remove/empty ends the handle's. */
|
|
97
|
+
streams = new Map();
|
|
98
|
+
/**
|
|
99
|
+
* Installed by the controller that fronts this store: a refusal for a handle that may not take
|
|
100
|
+
* chunks (restricted for the viewer, unbound, not a streaming widget). Absent on a bare store.
|
|
101
|
+
*/
|
|
102
|
+
appendGuard;
|
|
103
|
+
seq = 0; // status seq — monotone per store
|
|
104
|
+
emitSeq = 0; // envelope sequence — every emit, including remove
|
|
105
|
+
/** The projection state key: the scope, flattened. Derived — never passed in. */
|
|
106
|
+
executionId;
|
|
107
|
+
/**
|
|
108
|
+
* Isolation is by (experience, principal); two viewers of one experience must not share a
|
|
109
|
+
* store. The projection is keyed by `executionId`, so a per-viewer store is what keeps one
|
|
110
|
+
* viewer's values out of another's widgets even on a SHARED `ProjectionRuntime`.
|
|
111
|
+
*/
|
|
112
|
+
constructor(runtime, scope, opts = {}) {
|
|
113
|
+
this.runtime = runtime;
|
|
114
|
+
this.scope = scope;
|
|
115
|
+
// The key below joins with NUL; an id carrying one could forge another scope's key
|
|
116
|
+
// (principal "p\0broadcast" would land on the broadcast scope of "p").
|
|
117
|
+
if (scope.experienceId.includes("\u0000"))
|
|
118
|
+
throw new HydrationScopeError("experienceId");
|
|
119
|
+
if (scope.principalId?.includes("\u0000"))
|
|
120
|
+
throw new HydrationScopeError("principalId");
|
|
121
|
+
const base = scope.principalId === undefined
|
|
122
|
+
? scope.experienceId
|
|
123
|
+
: `${scope.experienceId}:${scope.principalId}`;
|
|
124
|
+
// NUL cannot appear in a typed id suffix a principal could forge, so a principal named
|
|
125
|
+
// "p:broadcast" never lands on the broadcast scope of "p".
|
|
126
|
+
this.executionId = (0, browser_1.isBroadcast)(scope.audience) ? `${base}\u0000broadcast` : base;
|
|
127
|
+
if (opts.register !== false)
|
|
128
|
+
runtime.register(hydrationProjection());
|
|
129
|
+
}
|
|
130
|
+
state() {
|
|
131
|
+
return this.runtime.getState(exports.HYDRATION_PROJECTION_ID, this.executionId);
|
|
132
|
+
}
|
|
133
|
+
status(handle) {
|
|
134
|
+
const s = this.state().status;
|
|
135
|
+
return Object.hasOwn(s, handle) ? s[handle] : undefined;
|
|
136
|
+
}
|
|
137
|
+
value(handle) {
|
|
138
|
+
const v = this.state().values;
|
|
139
|
+
return Object.hasOwn(v, handle) ? v[handle] : undefined;
|
|
140
|
+
}
|
|
141
|
+
handles() {
|
|
142
|
+
return Object.keys(this.state().status);
|
|
143
|
+
}
|
|
144
|
+
setStatus(handle, status) {
|
|
145
|
+
this.assertValidHandle(handle);
|
|
146
|
+
// `empty` drops the value, so a stream continuing onto it would resurrect a value the fold cleared.
|
|
147
|
+
if (status.state === "empty")
|
|
148
|
+
this.streams.delete(handle);
|
|
149
|
+
this.emit({ kind: "status", handle, status: this.stamp(status) });
|
|
150
|
+
}
|
|
151
|
+
setValue(handle, value, status) {
|
|
152
|
+
this.assertValidHandle(handle);
|
|
153
|
+
// A whole-value replace (a controller load, a supersede) ends the handle's token stream: the
|
|
154
|
+
// stream's accumulated text is no longer what the handle holds, so a producer's later chunks
|
|
155
|
+
// are refused (`stream-gap`) instead of being spliced onto the replacement.
|
|
156
|
+
this.streams.delete(handle);
|
|
157
|
+
this.emit({ kind: "value", handle, value, status: this.stamp(status) });
|
|
158
|
+
}
|
|
159
|
+
remove(handle) {
|
|
160
|
+
this.assertValidHandle(handle);
|
|
161
|
+
this.streams.delete(handle);
|
|
162
|
+
this.emit({ kind: "remove", handle });
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Gate every {@link append} through `guard` (a refusal finding, or undefined to allow). A
|
|
166
|
+
* `HydrationController` installs one over the store it fronts, so a producer cannot write a
|
|
167
|
+
* viewer-restricted handle's text into the projected store behind the controller's back. A bare
|
|
168
|
+
* store (no controller) has no viewer and no experience to gate against and stays ungated.
|
|
169
|
+
*/
|
|
170
|
+
guardAppend(guard) {
|
|
171
|
+
this.appendGuard = guard;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Append one chunk of a token stream (`StreamingText`) to a handle. The handle's value is the
|
|
175
|
+
* accumulated string — widgets and the value contract are unchanged — and its status is
|
|
176
|
+
* `pending` while the stream is open and `ready` once a chunk carries `done`.
|
|
177
|
+
*
|
|
178
|
+
* ORDERING with a whole-value writer (`setValue`/`remove`, e.g. the controller superseding a
|
|
179
|
+
* load): they are synchronous and the last writer wins. A replace ENDS the stream; the
|
|
180
|
+
* producer's next chunk then refuses (`stream-gap`, `seq` no longer 0) rather than corrupt the
|
|
181
|
+
* replacement, and a producer that wants to stream again starts a new stream at `seq` 0, which
|
|
182
|
+
* replaces the value. The contract itself (idempotence, gap, close, bounds) is core's
|
|
183
|
+
* `appendChunk`. A refusal emits nothing; a duplicate is `applied: false` and emits nothing.
|
|
184
|
+
*/
|
|
185
|
+
append(handle, chunk) {
|
|
186
|
+
this.assertValidHandle(handle);
|
|
187
|
+
const refusal = this.appendGuard?.(handle);
|
|
188
|
+
if (refusal !== undefined)
|
|
189
|
+
return { ok: false, finding: refusal };
|
|
190
|
+
const r = (0, browser_1.appendChunk)(this.streams.get(handle), chunk);
|
|
191
|
+
if (!r.ok)
|
|
192
|
+
return r;
|
|
193
|
+
if (!r.applied)
|
|
194
|
+
return { ok: true, applied: false };
|
|
195
|
+
this.streams.set(handle, r.state);
|
|
196
|
+
this.emit({
|
|
197
|
+
kind: "value",
|
|
198
|
+
handle,
|
|
199
|
+
value: r.state.text,
|
|
200
|
+
status: this.stamp({ state: r.state.done ? "ready" : "pending" }),
|
|
201
|
+
});
|
|
202
|
+
return { ok: true, applied: true };
|
|
203
|
+
}
|
|
204
|
+
/** Whole-state subscription: fires on ANY handle's value or status change. For a surface that renders the full projection (e.g. a terminal `watch` loop) rather than one widget's slice. */
|
|
205
|
+
runtimeSubscribe(listener) {
|
|
206
|
+
return this.runtime.subscribe(exports.HYDRATION_PROJECTION_ID, this.executionId, listener);
|
|
207
|
+
}
|
|
208
|
+
/** Slice-scoped: fires only when THIS handle's status seq or value changes. Change-only, like loom's subscribe. */
|
|
209
|
+
subscribe(handle, listener) {
|
|
210
|
+
return this.runtime.subscribeSelector(exports.HYDRATION_PROJECTION_ID, this.executionId, (s) => ({
|
|
211
|
+
value: Object.hasOwn(s.values, handle) ? s.values[handle] : undefined,
|
|
212
|
+
status: Object.hasOwn(s.status, handle) ? s.status[handle] : undefined,
|
|
213
|
+
}), listener, (a, b) => a.status?.seq === b.status?.seq && a.value === b.value);
|
|
214
|
+
}
|
|
215
|
+
assertValidHandle(handle) {
|
|
216
|
+
if (isReservedHandle(handle))
|
|
217
|
+
throw new Error(`handle "${handle}" is reserved`);
|
|
218
|
+
}
|
|
219
|
+
stamp(status) {
|
|
220
|
+
this.seq += 1;
|
|
221
|
+
return { ...status, seq: this.seq };
|
|
222
|
+
}
|
|
223
|
+
emit(payload) {
|
|
224
|
+
this.emitSeq += 1;
|
|
225
|
+
const envelope = {
|
|
226
|
+
id: `loom-ui-hydration-${this.executionId}-${this.emitSeq}`,
|
|
227
|
+
workflowId: "loom-ui.hydration",
|
|
228
|
+
executionId: this.executionId,
|
|
229
|
+
eventType: exports.HYDRATION_SET_EVENT,
|
|
230
|
+
sequence: this.emitSeq,
|
|
231
|
+
timestamp: 0, // transient; never persisted, never compared
|
|
232
|
+
payload,
|
|
233
|
+
};
|
|
234
|
+
this.runtime.handleEvent(envelope);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.HydrationStore = HydrationStore;
|
|
238
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":";;;AA0CA,4CAEC;AAQD,kDAoCC;AArFD,uDAAwF;AAExF,iFAAiF;AACjF,2FAA2F;AAC3F,gFAAgF;AAChF,0FAA0F;AAC1F,iGAAiG;AACjG,kGAAkG;AAClG,qCAAqC;AAExB,QAAA,uBAAuB,GAAG,mBAAmB,CAAC;AAC3D;;;GAGG;AACU,QAAA,4BAA4B,GAAG,OAAO,CAAC;AACvC,QAAA,mBAAmB,GAAG,uBAAuB,CAAC;AAsB3D,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AACpE,SAAgB,gBAAgB,CAAC,MAAc;IAC7C,OAAO,QAAQ,CAAC,GAAG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AEO,KAAK,CAAC,MAAiC;QAC7C,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACd,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;IAEO,IAAI,CAAC,OAAmB;QAC9B,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,MAAM,QAAQ,GAAkB;YAC9B,EAAE,EAAE,qBAAqB,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO,EAAE;YAC3D,UAAU,EAAE,mBAAmB;YAC/B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,2BAAmB;YAC9B,QAAQ,EAAE,IAAI,CAAC,OAAO;YACtB,SAAS,EAAE,CAAC,EAAE,6CAA6C;YAC3D,OAAO;SACR,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;CACF;AA/JD,wCA+JC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { type TaintedValue } from "@loomwork/classify";
|
|
2
|
+
import type { TransientInvokeOptions } from "@loomwork/effect-runtime";
|
|
3
|
+
import { type Shape } from "@loomwork/plugin-sandbox";
|
|
4
|
+
import { type ContentRefTable, type ContractRegistry, type Finding, type ProviderSpec } from "@loomwork/ui-core";
|
|
5
|
+
import { type ContentRefParamGate } from "./contentRefs";
|
|
6
|
+
import { type DataProviderRegistry } from "./dataProvider";
|
|
7
|
+
import type { TransientInvoker } from "./invoker";
|
|
8
|
+
import { type ArgumentHook, type LoadParams } from "./params";
|
|
9
|
+
import { type ReshapeFailureKind, type ReshaperRegistry } from "./reshape";
|
|
10
|
+
import type { HandleLoadResult } from "./scheduler";
|
|
11
|
+
export interface DriftRecord {
|
|
12
|
+
/**
|
|
13
|
+
* `input`: a step's input-schema pin moved — a pin move `remapOperation` can repair. `output`:
|
|
14
|
+
* the reshaping no longer works for the tool's output — the reshaped value fails its shape pin
|
|
15
|
+
* or value contract, OR the reshaping itself failed on it (`reshapeFailure`) — which only a
|
|
16
|
+
* re-authored binding (a planner) can repair.
|
|
17
|
+
*/
|
|
18
|
+
readonly kind: "input" | "output";
|
|
19
|
+
readonly handle: string;
|
|
20
|
+
/**
|
|
21
|
+
* The step that drifted. Input drift: the step whose schema pin drifted (always present).
|
|
22
|
+
* Output drift: the terminal step whose output was reshaped, set only when the graph has
|
|
23
|
+
* exactly one terminal — with several terminals the raw sample is a record keyed by stepId, not
|
|
24
|
+
* one step's output, so no single step identity applies.
|
|
25
|
+
*/
|
|
26
|
+
readonly stepId?: string;
|
|
27
|
+
readonly toolName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Input drift only, and ONLY for a step whose kind is not MCP: that kind (`step.kind`), so a
|
|
30
|
+
* repairer knows `toolName` is a target of that kind, not an MCP tool. Absent for MCP — a record
|
|
31
|
+
* for an MCP step is exactly what it was before kinds existed.
|
|
32
|
+
*/
|
|
33
|
+
readonly providerKind?: string;
|
|
34
|
+
readonly expected: string;
|
|
35
|
+
readonly observed: string;
|
|
36
|
+
/**
|
|
37
|
+
* Output drift under `outputCheck: "contract"` only: the kind whose value contract the reshaped
|
|
38
|
+
* value failed. `expected` is then `contract:<kind>` and `observed` the value's shape hash.
|
|
39
|
+
*/
|
|
40
|
+
readonly contractKind?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Output drift only, set when the RESHAPING ITSELF failed on the tool's output — and only when
|
|
43
|
+
* the output demonstrably caused it (`reshapeFailureKind`): the failure's finding code
|
|
44
|
+
* (`reshape-<channel>` / `reshape-failed`). `expected` is then `reshape` and `observed` that
|
|
45
|
+
* same code, and there is no reshaped value, so `observedShape` is absent — the raw output
|
|
46
|
+
* (`observedRawShape`, `observedSample`) is what a repair is authored against. Infrastructure
|
|
47
|
+
* and transient failures (a `wallClock` limit, an untyped throw, a denial, a missing script or
|
|
48
|
+
* reshaper, an abort) record no drift. The handle's status stays `error` (not `stale`) and the
|
|
49
|
+
* public finding is unchanged; the drift is reported for repair (`onDrift`).
|
|
50
|
+
*/
|
|
51
|
+
readonly reshapeFailure?: string;
|
|
52
|
+
/** Beside `reshapeFailure`: WHY, typed — so a consumer can exclude a kind without parsing findings. */
|
|
53
|
+
readonly reshapeFailureKind?: ReshapeFailureKind;
|
|
54
|
+
/**
|
|
55
|
+
* Output drift only: the structural shape loom's `shapeOf` saw of the RESHAPED value — the one
|
|
56
|
+
* that failed the check, so it explains the mismatch. Absent when the value could not be walked,
|
|
57
|
+
* and on a `reshapeFailure` (there is no reshaped value).
|
|
58
|
+
*/
|
|
59
|
+
readonly observedShape?: Shape;
|
|
60
|
+
/**
|
|
61
|
+
* Output drift only: the structural shape of the RAW terminal output the reshaping was applied
|
|
62
|
+
* to. A planner re-authors a `reshaping.scriptRef`, which is a path into the RAW output — so
|
|
63
|
+
* without this a record carrying no sample gives it nothing to author a path against.
|
|
64
|
+
* Absent when the raw value could not be walked.
|
|
65
|
+
*/
|
|
66
|
+
readonly observedRawShape?: Shape;
|
|
67
|
+
/**
|
|
68
|
+
* Output drift only, and ONLY when `ExecuteOptions.captureSample` is set: the RAW terminal
|
|
69
|
+
* output (the single terminal step's output, or the stepId-keyed record when there are several)
|
|
70
|
+
* — NOT the reshaped value, because the planner consumes a sample as a capability's
|
|
71
|
+
* `sampleOutput`, which is raw by contract and is what a `path` is authored against. ALWAYS
|
|
72
|
+
* wrapped as untrusted content (ADR 0085): it is tool-authored and will be shown to a model.
|
|
73
|
+
*/
|
|
74
|
+
readonly observedSample?: TaintedValue<unknown>;
|
|
75
|
+
}
|
|
76
|
+
export type ProviderOutcome =
|
|
77
|
+
/** `drift` only when an input drift was proceeded past (`inputDrift: "report-and-proceed"`). */
|
|
78
|
+
{
|
|
79
|
+
ok: true;
|
|
80
|
+
value: unknown;
|
|
81
|
+
findings: Finding[];
|
|
82
|
+
drift?: DriftRecord[];
|
|
83
|
+
} | {
|
|
84
|
+
ok: false;
|
|
85
|
+
finding: Finding;
|
|
86
|
+
drift: DriftRecord[];
|
|
87
|
+
findings: Finding[];
|
|
88
|
+
};
|
|
89
|
+
/** What a load does on an input-schema drift: go stale (`report`), or record it and retry once with the observed pin. */
|
|
90
|
+
export type InputDriftMode = "report" | "report-and-proceed";
|
|
91
|
+
export interface ExecuteOptions {
|
|
92
|
+
readonly invoker: TransientInvoker;
|
|
93
|
+
readonly signal?: AbortSignal;
|
|
94
|
+
readonly principal?: TransientInvokeOptions["principal"];
|
|
95
|
+
/** Parallel steps per wave. Default 4. */
|
|
96
|
+
readonly concurrency?: number;
|
|
97
|
+
/** Attach the RAW terminal output to an output-drift record as a tainted sample. Default false. */
|
|
98
|
+
readonly captureSample?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* The kinds the handle's bound nodes resolve to on the surface being hydrated (core's
|
|
101
|
+
* `handleKinds`). Read only when the spec's `outputCheck` is `"contract"` — which REFUSES to run
|
|
102
|
+
* without them: a contract check over no kinds would pass every value.
|
|
103
|
+
*/
|
|
104
|
+
readonly kinds?: readonly string[];
|
|
105
|
+
/**
|
|
106
|
+
* The host's value contracts for kinds outside the framework's (`SemanticCatalog.valueContracts`).
|
|
107
|
+
* A `"contract"` provider feeding a kind with neither contract is REFUSED (`output-contract-missing`).
|
|
108
|
+
*/
|
|
109
|
+
readonly contracts?: ContractRegistry;
|
|
110
|
+
/**
|
|
111
|
+
* Per-load params: applied only to arguments a step declares `overridable`, never to a
|
|
112
|
+
* `{{steps.…}}` template. A param no step declares is ignored with a `param-not-overridable` warn.
|
|
113
|
+
*/
|
|
114
|
+
readonly params?: LoadParams;
|
|
115
|
+
/** The instant relative-time tokens resolve against (epoch ms). Default: `Date.now()`, read once. */
|
|
116
|
+
readonly now?: number;
|
|
117
|
+
/** The host's last word on each step's arguments (after params, tokens, templates). */
|
|
118
|
+
readonly argumentHook?: ArgumentHook;
|
|
119
|
+
/**
|
|
120
|
+
* The marked content-reference argument paths per tool (`toolKey`; core `contentRefPaths`, the
|
|
121
|
+
* planner's `contentRefArgsFrom`). A step whose tool is listed is refused (`media-arg-literal`, the
|
|
122
|
+
* call not made) when a marked argument holds a literal. Absent = nothing is marked.
|
|
123
|
+
*/
|
|
124
|
+
readonly contentRefArgs?: ContentRefTable;
|
|
125
|
+
/** Who the load runs for, as the gate's `principalId` (the controller's `principal.id`, serve's `principalId`). */
|
|
126
|
+
readonly principalId?: string;
|
|
127
|
+
/** The host's gate on a param that fills a marked argument; absent = every such param is refused. */
|
|
128
|
+
readonly acceptContentRefParam?: ContentRefParamGate;
|
|
129
|
+
/** On an input-schema drift. Default `"report"`. */
|
|
130
|
+
readonly inputDrift?: InputDriftMode;
|
|
131
|
+
/** Where `reshaping.engine: "Named"` looks its reshaper up. */
|
|
132
|
+
readonly reshapers?: ReshaperRegistry;
|
|
133
|
+
/**
|
|
134
|
+
* The data-provider kinds this host composed (`defineDataProviders`). Default: MCP only, which is
|
|
135
|
+
* every step of an experience written before kinds existed. A step naming a kind not in here
|
|
136
|
+
* fails the whole provider as `provider-kind-unregistered`, before any step runs.
|
|
137
|
+
*/
|
|
138
|
+
readonly providers?: DataProviderRegistry;
|
|
139
|
+
}
|
|
140
|
+
/** The PUBLIC code of a step refused by the content-reference guard (literal, unproven ref, or a param the gate refused). */
|
|
141
|
+
export declare const CONTENT_REF_REFUSED = "content-ref-refused";
|
|
142
|
+
export declare function executeProvider(spec: ProviderSpec, opts: ExecuteOptions): Promise<ProviderOutcome>;
|
|
143
|
+
/**
|
|
144
|
+
* What an outcome publishes — the ONE mapping both the in-process controller and `serveHandle`
|
|
145
|
+
* use, so split and in-process hydration cannot disagree: a value is `ready` (carrying the first
|
|
146
|
+
* warning, e.g. a proceeded drift); an `upstream-empty` failure is `empty` — checked FIRST, and
|
|
147
|
+
* carrying no value (loom ADR 0100: a producer MUST clear the value beside `empty`); a failure
|
|
148
|
+
* with drift is `stale` — unless its only drift is a failed reshaping (`reshapeFailure`), which
|
|
149
|
+
* stays `error` as it always was — and any other failure `error`.
|
|
150
|
+
*/
|
|
151
|
+
export declare function outcomeResult(outcome: ProviderOutcome): HandleLoadResult;
|
|
152
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAW,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,KAAK,KAAK,EAAW,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,OAAO,EAEZ,KAAK,YAAY,EAIlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EAIhB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAItB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAepD,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QA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