octane 0.2.12 → 0.2.13
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 +5 -0
- package/dist/behavior-root.d.ts +13 -3
- package/dist/behavior-root.js +28 -5
- package/dist/cjs/behavior-root.cjs +32 -6
- package/dist/cjs/class-names.cjs +49 -0
- package/dist/cjs/constants.cjs +9 -0
- package/dist/cjs/css.cjs +6 -27
- package/dist/cjs/data-encoding.cjs +160 -0
- package/dist/cjs/dom-binding-handoff.cjs +93 -0
- package/dist/cjs/dom-binding-protocol.cjs +115 -0
- package/dist/cjs/dom-binding-styles.cjs +292 -0
- package/dist/cjs/dom-bindings.cjs +700 -0
- package/dist/cjs/dom-focused-move.cjs +66 -0
- package/dist/cjs/dom-tables.cjs +4 -94
- package/dist/cjs/error-codes.client.generated.cjs +33 -0
- package/dist/cjs/error-codes.server.generated.cjs +19 -0
- package/dist/cjs/hydration/control-capture.cjs +244 -0
- package/dist/cjs/hydration/event-capture.cjs +125 -43
- package/dist/cjs/hydration/interaction-config.cjs +50 -2
- package/dist/cjs/hydration-markers.cjs +37 -0
- package/dist/cjs/independent-hydration-protocol.cjs +106 -0
- package/dist/cjs/index.cjs +6 -0
- package/dist/cjs/runtime.cjs +2791 -215
- package/dist/cjs/runtime.server.cjs +716 -76
- package/dist/cjs/server/early-signals.cjs +45 -0
- package/dist/cjs/server/index.cjs +44 -0
- package/dist/cjs/server/rpc-batch.cjs +149 -0
- package/dist/cjs/server/rpc-stream.cjs +146 -0
- package/dist/cjs/server/rpc.cjs +34 -15
- package/dist/cjs/server/signal-query-observation.cjs +158 -0
- package/dist/cjs/server/streamed-region.cjs +52 -0
- package/dist/cjs/server/streamed-signals.cjs +512 -0
- package/dist/cjs/server-call.cjs +103 -0
- package/dist/cjs/server-rpc-batch-client.cjs +141 -0
- package/dist/cjs/server-rpc-client.cjs +94 -27
- package/dist/cjs/server-rpc-protocol.cjs +141 -0
- package/dist/cjs/server-rpc-stream-client.cjs +118 -0
- package/dist/cjs/signals/actions.cjs +474 -0
- package/dist/cjs/signals/client.cjs +4 -1
- package/dist/cjs/signals/computations.cjs +460 -0
- package/dist/cjs/signals/control-binding.cjs +368 -0
- package/dist/cjs/signals/derived-facade.cjs +50 -0
- package/dist/cjs/signals/document-owner.cjs +71 -0
- package/dist/cjs/signals/early-values.cjs +155 -0
- package/dist/cjs/signals/encoding.cjs +6 -95
- package/dist/cjs/signals/engine.cjs +276 -12
- package/dist/cjs/signals/errors.cjs +18 -0
- package/dist/cjs/signals/facade.cjs +477 -0
- package/dist/cjs/signals/graph.cjs +163 -20
- package/dist/cjs/signals/handle-protocol.cjs +36 -0
- package/dist/cjs/signals/index.cjs +81 -2
- package/dist/cjs/signals/native-read-client.cjs +10 -0
- package/dist/cjs/signals/owner-context.cjs +112 -0
- package/dist/cjs/signals/query-attempt-observer.cjs +68 -0
- package/dist/cjs/signals/query-facade.cjs +72 -0
- package/dist/cjs/signals/read-protocol.cjs +32 -0
- package/dist/cjs/signals/requests.cjs +287 -14
- package/dist/cjs/signals/scalar-computations.cjs +76 -0
- package/dist/cjs/signals/server.cjs +4 -1
- package/dist/cjs/signals/transition-candidate.cjs +567 -0
- package/dist/cjs/signals/transition-state.cjs +106 -0
- package/dist/cjs/signals/types.cjs +50 -0
- package/dist/cjs/stream-protocol.cjs +3 -0
- package/dist/cjs/streamed-signals-protocol.cjs +159 -0
- package/dist/cjs/style-values.cjs +122 -0
- package/dist/cjs/version.cjs +1 -1
- package/dist/class-names.d.ts +5 -0
- package/dist/class-names.js +25 -0
- package/dist/compiler/bundler.js +34 -6
- package/dist/compiler/compile.js +2234 -559
- package/dist/compiler/dom-binding-program.js +935 -0
- package/dist/compiler/dom-binding-request.js +57 -0
- package/dist/compiler/dom-bindings.js +2245 -0
- package/dist/compiler/hook-deps.js +26 -0
- package/dist/compiler/hydrate-boundaries.js +358 -15
- package/dist/compiler/index.d.ts +38 -1
- package/dist/compiler/index.js +1 -0
- package/dist/compiler/native-attribute-reads.js +127 -0
- package/dist/compiler/native-read-diagnostics.js +48 -9
- package/dist/compiler/native-read-types.js +55 -32
- package/dist/compiler/server-context.js +118 -0
- package/dist/compiler/signal-attempt-reads.js +479 -0
- package/dist/compiler/signal-declarations.js +557 -0
- package/dist/compiler/signal-start-reads.js +413 -0
- package/dist/compiler/slot-hooks.js +57 -10
- package/dist/compiler/template-ir.js +200 -0
- package/dist/compiler/typescript.d.ts +2 -0
- package/dist/compiler/typescript.js +2 -0
- package/dist/compiler/vite.d.ts +3 -1
- package/dist/compiler/vite.js +122 -4
- package/dist/compiler/volar.d.ts +6 -1
- package/dist/compiler/volar.js +674 -143
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +10 -0
- package/dist/css.d.ts +2 -5
- package/dist/css.js +2 -23
- package/dist/data-encoding.d.ts +9 -0
- package/dist/data-encoding.js +134 -0
- package/dist/dom-binding-classes.d.ts +15 -0
- package/dist/dom-binding-classes.js +129 -0
- package/dist/dom-binding-controls.d.ts +2 -0
- package/dist/dom-binding-controls.js +6 -0
- package/dist/dom-binding-handoff.d.ts +55 -0
- package/dist/dom-binding-handoff.js +62 -0
- package/dist/dom-binding-program.d.ts +300 -0
- package/dist/dom-binding-program.js +1625 -0
- package/dist/dom-binding-projections.d.ts +15 -0
- package/dist/dom-binding-projections.js +187 -0
- package/dist/dom-binding-protocol.d.ts +13 -0
- package/dist/dom-binding-protocol.js +88 -0
- package/dist/dom-binding-signals.d.ts +21 -0
- package/dist/dom-binding-signals.js +109 -0
- package/dist/dom-binding-styles.d.ts +17 -0
- package/dist/dom-binding-styles.js +272 -0
- package/dist/dom-bindings.d.ts +89 -0
- package/dist/dom-bindings.js +670 -0
- package/dist/dom-focused-move.d.ts +6 -0
- package/dist/dom-focused-move.js +42 -0
- package/dist/dom-tables.d.ts +1 -3
- package/dist/dom-tables.js +1 -91
- package/dist/error-codes.client.generated.d.ts +9 -0
- package/dist/error-codes.client.generated.js +33 -0
- package/dist/error-codes.server.generated.d.ts +5 -0
- package/dist/error-codes.server.generated.js +19 -0
- package/dist/hydration/control-capture.d.ts +62 -0
- package/dist/hydration/control-capture.js +223 -0
- package/dist/hydration/document-lifecycle.d.ts +23 -0
- package/dist/hydration/document-lifecycle.js +80 -0
- package/dist/hydration/event-capture.d.ts +20 -1
- package/dist/hydration/event-capture.js +128 -42
- package/dist/hydration/independent-island.d.ts +45 -0
- package/dist/hydration/independent-island.js +233 -0
- package/dist/hydration/index.d.ts +8 -1
- package/dist/hydration/index.js +55 -1
- package/dist/hydration/interaction-config.d.ts +5 -0
- package/dist/hydration/interaction-config.js +44 -1
- package/dist/hydration/stream-delivery.d.ts +32 -0
- package/dist/hydration/stream-delivery.js +333 -0
- package/dist/hydration/stream-receiver.d.ts +26 -0
- package/dist/hydration/stream-receiver.js +204 -0
- package/dist/hydration/stream-result-receiver.d.ts +70 -0
- package/dist/hydration/stream-result-receiver.js +246 -0
- package/dist/hydration/streamed-signals.d.ts +44 -0
- package/dist/hydration/streamed-signals.js +186 -0
- package/dist/hydration/types.d.ts +6 -0
- package/dist/hydration-markers.d.ts +7 -0
- package/dist/hydration-markers.js +10 -0
- package/dist/independent-hydration-protocol.d.ts +31 -0
- package/dist/independent-hydration-protocol.js +80 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/internal/signal-read.d.ts +1 -0
- package/dist/internal/signal-read.js +4 -0
- package/dist/jsx-runtime.d.ts +45 -6
- package/dist/public-types.d.ts +15 -1
- package/dist/runtime.d.ts +259 -21
- package/dist/runtime.js +2812 -220
- package/dist/runtime.server.d.ts +86 -6
- package/dist/runtime.server.js +712 -76
- package/dist/server/early-signals.d.ts +14 -0
- package/dist/server/early-signals.js +34 -0
- package/dist/server/index.d.ts +10 -2
- package/dist/server/index.js +48 -1
- package/dist/server/rpc-batch.d.ts +17 -0
- package/dist/server/rpc-batch.js +129 -0
- package/dist/server/rpc-stream.d.ts +9 -0
- package/dist/server/rpc-stream.js +125 -0
- package/dist/server/rpc.d.ts +5 -1
- package/dist/server/rpc.js +37 -13
- package/dist/server/signal-query-observation.d.ts +3 -0
- package/dist/server/signal-query-observation.js +134 -0
- package/dist/server/streamed-region.d.ts +15 -0
- package/dist/server/streamed-region.js +30 -0
- package/dist/server/streamed-signals.d.ts +45 -0
- package/dist/server/streamed-signals.js +488 -0
- package/dist/server-call.d.ts +41 -0
- package/dist/server-call.js +75 -0
- package/dist/server-rpc-batch-client.d.ts +7 -0
- package/dist/server-rpc-batch-client.js +119 -0
- package/dist/server-rpc-client.d.ts +3 -1
- package/dist/server-rpc-client.js +99 -27
- package/dist/server-rpc-protocol.d.ts +47 -0
- package/dist/server-rpc-protocol.js +109 -0
- package/dist/server-rpc-stream-client.d.ts +5 -0
- package/dist/server-rpc-stream-client.js +98 -0
- package/dist/signals/actions.d.ts +12 -0
- package/dist/signals/actions.js +466 -0
- package/dist/signals/client.d.ts +2 -0
- package/dist/signals/client.js +1 -0
- package/dist/signals/computations.d.ts +37 -0
- package/dist/signals/computations.js +455 -0
- package/dist/signals/control-binding.d.ts +31 -0
- package/dist/signals/control-binding.js +353 -0
- package/dist/signals/derived-facade.d.ts +3 -0
- package/dist/signals/derived-facade.js +25 -0
- package/dist/signals/document-owner.d.ts +10 -0
- package/dist/signals/document-owner.js +43 -0
- package/dist/signals/early-values.d.ts +24 -0
- package/dist/signals/early-values.js +124 -0
- package/dist/signals/encoding.d.ts +1 -3
- package/dist/signals/encoding.js +3 -93
- package/dist/signals/engine.d.ts +53 -4
- package/dist/signals/engine.js +275 -16
- package/dist/signals/errors.d.ts +7 -0
- package/dist/signals/errors.js +16 -0
- package/dist/signals/facade.d.ts +74 -0
- package/dist/signals/facade.js +452 -0
- package/dist/signals/graph.d.ts +50 -5
- package/dist/signals/graph.js +170 -19
- package/dist/signals/handle-protocol.d.ts +4 -0
- package/dist/signals/handle-protocol.js +11 -0
- package/dist/signals/index.d.ts +12 -3
- package/dist/signals/index.js +71 -2
- package/dist/signals/native-read-client.d.ts +3 -0
- package/dist/signals/native-read-client.js +10 -0
- package/dist/signals/owner-context.d.ts +22 -0
- package/dist/signals/owner-context.js +77 -0
- package/dist/signals/query-attempt-observer.d.ts +49 -0
- package/dist/signals/query-attempt-observer.js +41 -0
- package/dist/signals/query-facade.d.ts +3 -0
- package/dist/signals/query-facade.js +49 -0
- package/dist/signals/read-protocol.d.ts +32 -3
- package/dist/signals/read-protocol.js +26 -0
- package/dist/signals/requests.d.ts +38 -5
- package/dist/signals/requests.js +298 -15
- package/dist/signals/scalar-computations.d.ts +2 -0
- package/dist/signals/scalar-computations.js +60 -0
- package/dist/signals/server.d.ts +2 -0
- package/dist/signals/server.js +1 -0
- package/dist/signals/transition-candidate.d.ts +71 -0
- package/dist/signals/transition-candidate.js +557 -0
- package/dist/signals/transition-state.d.ts +51 -0
- package/dist/signals/transition-state.js +70 -0
- package/dist/signals/types.d.ts +95 -5
- package/dist/signals/types.js +20 -0
- package/dist/stream-protocol.d.ts +0 -5
- package/dist/stream-protocol.js +3 -0
- package/dist/streamed-signals-protocol.d.ts +60 -0
- package/dist/streamed-signals-protocol.js +130 -0
- package/dist/style-values.d.ts +3 -0
- package/dist/style-values.js +96 -0
- package/dist/version.js +1 -1
- package/package.json +37 -1
|
@@ -0,0 +1,1625 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__claimBinding,
|
|
3
|
+
__createBindingStyleRestoration,
|
|
4
|
+
__normalizeBinding,
|
|
5
|
+
__releaseBinding,
|
|
6
|
+
__writeBinding
|
|
7
|
+
} from "./dom-bindings.js";
|
|
8
|
+
import { encodeBindingKey, parseBindingMarker } from "./dom-binding-protocol.js";
|
|
9
|
+
import { moveNativeNodeBefore } from "./dom-focused-move.js";
|
|
10
|
+
import { rendererRangeClose } from "./stream-protocol.js";
|
|
11
|
+
import {
|
|
12
|
+
BINDING_HANDOFF,
|
|
13
|
+
registerBindingEvent,
|
|
14
|
+
markBindingEvent
|
|
15
|
+
} from "./dom-binding-handoff.js";
|
|
16
|
+
import { captureSignalOwner, currentSignalOwner } from "./signals/owner-context.js";
|
|
17
|
+
import {
|
|
18
|
+
NATIVE_TRANSITION_CONSUMER,
|
|
19
|
+
forwardNativeTransitionConsumer
|
|
20
|
+
} from "./signals/read-protocol.js";
|
|
21
|
+
import { __methodDep } from "./method-dep.js";
|
|
22
|
+
function __activateBindingAdapters(nodes, context, definitions) {
|
|
23
|
+
const cleanups = [];
|
|
24
|
+
const refs = [];
|
|
25
|
+
let disposed = false;
|
|
26
|
+
let cleaned = false;
|
|
27
|
+
const drain = (callbacks) => {
|
|
28
|
+
let failed = false;
|
|
29
|
+
let failure;
|
|
30
|
+
for (const cleanup of callbacks) {
|
|
31
|
+
try {
|
|
32
|
+
cleanup();
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (!failed) {
|
|
35
|
+
failed = true;
|
|
36
|
+
failure = error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
callbacks.length = 0;
|
|
41
|
+
if (failed) throw failure;
|
|
42
|
+
};
|
|
43
|
+
const abort = () => {
|
|
44
|
+
disposed = true;
|
|
45
|
+
};
|
|
46
|
+
const dispose = () => {
|
|
47
|
+
if (cleaned) return;
|
|
48
|
+
cleaned = true;
|
|
49
|
+
disposed = true;
|
|
50
|
+
context.signal.removeEventListener("abort", abort);
|
|
51
|
+
for (const ref of refs) {
|
|
52
|
+
if (ref.cleanup) cleanups.push(ref.cleanup);
|
|
53
|
+
ref.cleanup = void 0;
|
|
54
|
+
}
|
|
55
|
+
drain(cleanups);
|
|
56
|
+
};
|
|
57
|
+
const own = (cleanup) => {
|
|
58
|
+
if (disposed) cleanup();
|
|
59
|
+
else cleanups.push(cleanup);
|
|
60
|
+
};
|
|
61
|
+
const attachRef = (value, node, ownRef) => {
|
|
62
|
+
if (value == null || disposed) return;
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
for (const ref of value) attachRef(ref, node, ownRef);
|
|
65
|
+
} else if (typeof value === "function") {
|
|
66
|
+
const cleanup = value(node);
|
|
67
|
+
ownRef(typeof cleanup === "function" ? cleanup : () => value(null));
|
|
68
|
+
} else if (typeof value === "object") {
|
|
69
|
+
const ref = value;
|
|
70
|
+
ref.current = node;
|
|
71
|
+
ownRef(() => {
|
|
72
|
+
if (ref.current === node) ref.current = null;
|
|
73
|
+
});
|
|
74
|
+
} else throw new TypeError("A DOM presentation ref must be a callback, object, or ref array.");
|
|
75
|
+
};
|
|
76
|
+
const replaceRef = (ref, value) => {
|
|
77
|
+
const cleanup = ref.cleanup;
|
|
78
|
+
ref.cleanup = void 0;
|
|
79
|
+
ref.value = value;
|
|
80
|
+
cleanup?.();
|
|
81
|
+
if (disposed || value == null) return;
|
|
82
|
+
const attached = [];
|
|
83
|
+
let detached = false;
|
|
84
|
+
ref.cleanup = () => {
|
|
85
|
+
if (detached) return;
|
|
86
|
+
detached = true;
|
|
87
|
+
drain(attached);
|
|
88
|
+
};
|
|
89
|
+
attachRef(value, ref.node, (stop) => {
|
|
90
|
+
if (disposed || detached) stop();
|
|
91
|
+
else attached.push(stop);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const handle = dispose;
|
|
95
|
+
if (context.signal.aborted) {
|
|
96
|
+
dispose();
|
|
97
|
+
return handle;
|
|
98
|
+
}
|
|
99
|
+
context.signal.addEventListener("abort", abort, { once: true });
|
|
100
|
+
try {
|
|
101
|
+
for (const definition of definitions) {
|
|
102
|
+
if (disposed) break;
|
|
103
|
+
const node = nodes[definition.node];
|
|
104
|
+
if (node?.nodeType !== 1) mismatch();
|
|
105
|
+
if (definition.kind === "ref") {
|
|
106
|
+
const ref = {
|
|
107
|
+
definition,
|
|
108
|
+
node,
|
|
109
|
+
value: void 0,
|
|
110
|
+
dependencies: definition.dependencies?.(context.getEnvironment())
|
|
111
|
+
};
|
|
112
|
+
refs.push(ref);
|
|
113
|
+
replaceRef(ref, definition.read(context.getEnvironment()));
|
|
114
|
+
} else {
|
|
115
|
+
const listener = (event) => {
|
|
116
|
+
if (disposed) return;
|
|
117
|
+
const handler = definition.read(context.getEnvironment());
|
|
118
|
+
if (handler == null || handler === false) return;
|
|
119
|
+
if (typeof handler !== "function")
|
|
120
|
+
throw new TypeError("A native event binding must resolve to a function.");
|
|
121
|
+
markBindingEvent(event, node, !!definition.capture);
|
|
122
|
+
handler.call(node, event);
|
|
123
|
+
};
|
|
124
|
+
node.addEventListener(definition.name, listener, !!definition.capture);
|
|
125
|
+
own(registerBindingEvent(node, definition.name));
|
|
126
|
+
own(() => node.removeEventListener(definition.name, listener, !!definition.capture));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (refs.some((ref) => !ref.definition.stable))
|
|
130
|
+
handle.prepare = (environment) => {
|
|
131
|
+
const next = refs.map((ref) => {
|
|
132
|
+
const dependencies = ref.definition.dependencies?.(environment);
|
|
133
|
+
const unchanged = ref.definition.stable || dependencies !== void 0 && ref.dependencies !== void 0 && dependencies.length === ref.dependencies.length && dependencies.every((value, index) => Object.is(value, ref.dependencies[index]));
|
|
134
|
+
return { value: unchanged ? ref.value : ref.definition.read(environment), dependencies };
|
|
135
|
+
});
|
|
136
|
+
return () => {
|
|
137
|
+
for (let index = 0; index < refs.length && !disposed; index++) {
|
|
138
|
+
const ref = refs[index];
|
|
139
|
+
ref.dependencies = next[index].dependencies;
|
|
140
|
+
if (!Object.is(ref.value, next[index].value)) replaceRef(ref, next[index].value);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
return handle;
|
|
145
|
+
} catch (error) {
|
|
146
|
+
try {
|
|
147
|
+
dispose();
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const bindingSlot = /* @__PURE__ */ Symbol("octane.compiled-binding-slot");
|
|
154
|
+
function __bindingSlot(id, fragment, environment, site) {
|
|
155
|
+
return {
|
|
156
|
+
[bindingSlot]: true,
|
|
157
|
+
id,
|
|
158
|
+
fragment,
|
|
159
|
+
environment,
|
|
160
|
+
...site === void 0 ? {} : { site }
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function __createStructuralBindingHandoff(instance, transaction, dispose, ready) {
|
|
164
|
+
let revision = 0;
|
|
165
|
+
let rangeRevision = -1;
|
|
166
|
+
let ranges;
|
|
167
|
+
let views;
|
|
168
|
+
let rest;
|
|
169
|
+
let retries;
|
|
170
|
+
const currentRanges = () => {
|
|
171
|
+
if (rangeRevision === revision && ranges !== void 0) return ranges;
|
|
172
|
+
const next = /* @__PURE__ */ new Map();
|
|
173
|
+
let nextViews;
|
|
174
|
+
let nextRest;
|
|
175
|
+
const collect = (current, closed = false) => {
|
|
176
|
+
if (current.definition.conditionalRest === true) {
|
|
177
|
+
if (current.definition.closedProps === void 0)
|
|
178
|
+
throw new Error("Conditional hydration requires a compiler-proven caller shape.");
|
|
179
|
+
(nextViews ??= /* @__PURE__ */ new Map()).set(current.range.start, {
|
|
180
|
+
id: current.id,
|
|
181
|
+
closedProps: current.definition.closedProps
|
|
182
|
+
});
|
|
183
|
+
closed = true;
|
|
184
|
+
}
|
|
185
|
+
if (current.definition.constructible === false || current.definition.bindings.some((binding) => binding[1] === "control") || current.definition.nodes.some((node) => node[1] === "element" && node[4] === null))
|
|
186
|
+
throw new Error("Structural hydration leases require compiler-owned native nodes.");
|
|
187
|
+
for (const site of current.definition.restSites ?? []) {
|
|
188
|
+
const element = current.nodes[site.node];
|
|
189
|
+
if (!closed || element?.nodeType !== 1)
|
|
190
|
+
throw new Error("Native rest hydration requires an eligible closed child view.");
|
|
191
|
+
const sites = (nextRest ??= /* @__PURE__ */ new Map()).get(element) ?? /* @__PURE__ */ new Map();
|
|
192
|
+
sites.set(site.site, {
|
|
193
|
+
id: current.id,
|
|
194
|
+
node: site.node,
|
|
195
|
+
spread: site.spread,
|
|
196
|
+
keys: site.keys
|
|
197
|
+
});
|
|
198
|
+
nextRest.set(element, sites);
|
|
199
|
+
}
|
|
200
|
+
for (const region of current.regions) {
|
|
201
|
+
const definition = region.definition;
|
|
202
|
+
if (definition.kind === "for" || definition.kind === "opaque")
|
|
203
|
+
throw new Error("Structural hydration leases do not support lists or opaque regions.");
|
|
204
|
+
if (definition.kind === "text" && definition.generic)
|
|
205
|
+
throw new Error("Structural hydration leases require primitive text.");
|
|
206
|
+
if (definition.kind === "view" && definition.view.root.handoff !== true && definition.view.root.handoff !== "structural" && definition.view.root.conditionalRest !== true)
|
|
207
|
+
throw new Error("Structural hydration leases require a supported child view.");
|
|
208
|
+
next.set(region.range.start, {
|
|
209
|
+
kind: definition.kind,
|
|
210
|
+
end: region.range.end,
|
|
211
|
+
...definition.kind === "if" ? { arm: region.arm } : {},
|
|
212
|
+
...definition.kind === "view" ? { view: definition.view.id } : {},
|
|
213
|
+
...definition.kind === "slot" ? { slot: region.slot } : {}
|
|
214
|
+
});
|
|
215
|
+
if (region.child !== null)
|
|
216
|
+
collect(
|
|
217
|
+
region.child,
|
|
218
|
+
definition.kind !== "view" && region.child.id === current.id && closed
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
collect(instance);
|
|
223
|
+
ranges = next;
|
|
224
|
+
views = nextViews;
|
|
225
|
+
rest = nextRest;
|
|
226
|
+
rangeRevision = revision;
|
|
227
|
+
return next;
|
|
228
|
+
};
|
|
229
|
+
currentRanges();
|
|
230
|
+
transaction.published = () => {
|
|
231
|
+
revision++;
|
|
232
|
+
if (retries?.size) {
|
|
233
|
+
const pending = [...retries];
|
|
234
|
+
retries.clear();
|
|
235
|
+
for (const retry of pending)
|
|
236
|
+
queueMicrotask(() => {
|
|
237
|
+
if (!transaction.disposed) retry();
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const valid = (current) => {
|
|
242
|
+
const parent = current.range.start.parentNode;
|
|
243
|
+
if (parent === null || current.range.end.parentNode !== parent) return false;
|
|
244
|
+
const cursors = /* @__PURE__ */ new Map([[-1, current.range.start.nextSibling]]);
|
|
245
|
+
for (let index = 0; index < current.definition.nodes.length; index++) {
|
|
246
|
+
const proof = current.definition.nodes[index];
|
|
247
|
+
const node = current.nodes[index];
|
|
248
|
+
if (cursors.get(proof[0]) !== node || node.parentNode !== (proof[0] === -1 ? parent : current.nodes[proof[0]]))
|
|
249
|
+
return false;
|
|
250
|
+
let next = node.nextSibling;
|
|
251
|
+
if (proof[1] === "element") cursors.set(index, node.firstChild);
|
|
252
|
+
else if (proof[1] === "text") {
|
|
253
|
+
if (node.nodeValue !== proof[2]) return false;
|
|
254
|
+
} else {
|
|
255
|
+
const region = current.regions.find((item) => item.range.start === node);
|
|
256
|
+
if (region.range.end.parentNode !== node.parentNode || region.child !== null && !valid(region.child))
|
|
257
|
+
return false;
|
|
258
|
+
if (region.definition.kind === "text" && (node.nextSibling !== (region.text ?? region.range.end) || region.text !== null && region.text.nextSibling !== region.range.end))
|
|
259
|
+
return false;
|
|
260
|
+
next = region.range.end.nextSibling;
|
|
261
|
+
}
|
|
262
|
+
cursors.set(proof[0], next);
|
|
263
|
+
}
|
|
264
|
+
for (const [index, cursor] of cursors)
|
|
265
|
+
if (cursor !== (index === -1 ? current.range.end : null)) return false;
|
|
266
|
+
return true;
|
|
267
|
+
};
|
|
268
|
+
return {
|
|
269
|
+
id: instance.id,
|
|
270
|
+
root: instance.range.start,
|
|
271
|
+
anchor: instance.range.start,
|
|
272
|
+
end: instance.range.end,
|
|
273
|
+
revision: () => ready() ? revision : -1,
|
|
274
|
+
ranges: currentRanges,
|
|
275
|
+
view: (root) => {
|
|
276
|
+
currentRanges();
|
|
277
|
+
return views?.get(root);
|
|
278
|
+
},
|
|
279
|
+
rest: (element, site) => {
|
|
280
|
+
currentRanges();
|
|
281
|
+
return rest?.get(element)?.get(site);
|
|
282
|
+
},
|
|
283
|
+
valid: () => {
|
|
284
|
+
if (!ready()) return false;
|
|
285
|
+
try {
|
|
286
|
+
currentRanges();
|
|
287
|
+
} catch {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
return valid(instance);
|
|
291
|
+
},
|
|
292
|
+
afterPublication: (callback) => {
|
|
293
|
+
(retries ??= /* @__PURE__ */ new Set()).add(callback);
|
|
294
|
+
return () => retries.delete(callback);
|
|
295
|
+
},
|
|
296
|
+
active: () => !transaction.disposed,
|
|
297
|
+
retire: (publish) => {
|
|
298
|
+
retries?.clear();
|
|
299
|
+
transaction.published = void 0;
|
|
300
|
+
transaction.preservePresentation = true;
|
|
301
|
+
dispose(void 0, publish);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
const stopped = {};
|
|
306
|
+
const programRoots = /* @__PURE__ */ new WeakSet();
|
|
307
|
+
function requireActive(transaction) {
|
|
308
|
+
if (transaction.disposed) throw stopped;
|
|
309
|
+
}
|
|
310
|
+
function mismatch() {
|
|
311
|
+
throw new Error("DOM presentation cannot adopt mismatched compiler-owned ranges or nodes.");
|
|
312
|
+
}
|
|
313
|
+
function rangeAt(node, end) {
|
|
314
|
+
if (node?.nodeType !== 8) return mismatch();
|
|
315
|
+
const close = rendererRangeClose(node);
|
|
316
|
+
if (close === null) return mismatch();
|
|
317
|
+
for (let cursor = node; cursor !== close; cursor = cursor.nextSibling)
|
|
318
|
+
if (cursor === null || cursor === end) return mismatch();
|
|
319
|
+
if (close === end) return mismatch();
|
|
320
|
+
return { start: node, end: close };
|
|
321
|
+
}
|
|
322
|
+
function rootRange(root, id) {
|
|
323
|
+
if (root.nodeType === 1) {
|
|
324
|
+
let start = root;
|
|
325
|
+
let end = start;
|
|
326
|
+
let match;
|
|
327
|
+
while (start.previousSibling?.nodeType === 8) {
|
|
328
|
+
const open = start.previousSibling;
|
|
329
|
+
const marker2 = parseBindingMarker(open.data);
|
|
330
|
+
if (marker2?.kind !== "root" && marker2?.kind !== "view") break;
|
|
331
|
+
const close = rendererRangeClose(open);
|
|
332
|
+
if (close === null || close.previousSibling !== end) break;
|
|
333
|
+
if (marker2.kind === "root" && marker2.id === id) {
|
|
334
|
+
if (match !== void 0) mismatch();
|
|
335
|
+
match = { start: open, end: close };
|
|
336
|
+
}
|
|
337
|
+
start = open;
|
|
338
|
+
end = close;
|
|
339
|
+
}
|
|
340
|
+
return match ?? mismatch();
|
|
341
|
+
}
|
|
342
|
+
const range = root;
|
|
343
|
+
if (range?.start?.nodeType !== 8 || range?.end?.nodeType !== 8) mismatch();
|
|
344
|
+
const marker = parseBindingMarker(range.start.data);
|
|
345
|
+
if (marker?.kind !== "root" || marker.id !== id || rendererRangeClose(range.start) !== range.end)
|
|
346
|
+
mismatch();
|
|
347
|
+
return range;
|
|
348
|
+
}
|
|
349
|
+
function releaseInstance(instance, transaction) {
|
|
350
|
+
if (instance.disposed) return;
|
|
351
|
+
instance.disposed = true;
|
|
352
|
+
transaction.all.delete(instance);
|
|
353
|
+
transaction.candidates.delete(instance);
|
|
354
|
+
let failed = false;
|
|
355
|
+
let failure;
|
|
356
|
+
const attempt = (callback) => {
|
|
357
|
+
try {
|
|
358
|
+
callback();
|
|
359
|
+
} catch (error) {
|
|
360
|
+
if (!failed) {
|
|
361
|
+
failed = true;
|
|
362
|
+
failure = error;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
transaction.hostOperations?.releaseControls(instance, attempt);
|
|
367
|
+
attempt(() => instance.controller?.abort());
|
|
368
|
+
attempt(() => instance.cleanup?.());
|
|
369
|
+
instance.cleanup = void 0;
|
|
370
|
+
instance.updateAdapters = void 0;
|
|
371
|
+
for (const connection of instance.signals?.values() ?? [])
|
|
372
|
+
attempt(() => connection.dispose(transaction.preservePresentation));
|
|
373
|
+
instance.signals?.clear();
|
|
374
|
+
transaction.hostOperations?.releaseProjections(instance, transaction, attempt);
|
|
375
|
+
instance.signalPlan = void 0;
|
|
376
|
+
for (const region of instance.regions) {
|
|
377
|
+
if (region.signal) attempt(() => region.signal.dispose());
|
|
378
|
+
region.signalPlan = void 0;
|
|
379
|
+
if (region.child) attempt(() => releaseInstance(region.child, transaction));
|
|
380
|
+
if (region.items)
|
|
381
|
+
for (const child of region.items.values()) attempt(() => releaseInstance(child, transaction));
|
|
382
|
+
}
|
|
383
|
+
for (let i = 0; i < instance.owned.length; i++) {
|
|
384
|
+
const [node, channel] = instance.owned[i];
|
|
385
|
+
const binding = instance.definition.bindings[i];
|
|
386
|
+
if (instance.groups.has(i))
|
|
387
|
+
attempt(() => instance.groups.get(i).dispose(transaction.preservePresentation));
|
|
388
|
+
if (instance.styles?.has(i))
|
|
389
|
+
attempt(() => instance.styles.get(i).dispose(transaction.preservePresentation));
|
|
390
|
+
if (!transaction.preservePresentation && binding[1] === "classToken" && instance.previous[i] === "")
|
|
391
|
+
attempt(() => node.classList.remove(binding[2]));
|
|
392
|
+
__releaseBinding(node, channel);
|
|
393
|
+
}
|
|
394
|
+
instance.owned.length = 0;
|
|
395
|
+
instance.previous.length = 0;
|
|
396
|
+
instance.groups.clear();
|
|
397
|
+
instance.styles?.clear();
|
|
398
|
+
if (failed) throw failure;
|
|
399
|
+
}
|
|
400
|
+
function resolveFragment(definition, id, range, fresh, transaction) {
|
|
401
|
+
requireActive(transaction);
|
|
402
|
+
const instance = {
|
|
403
|
+
id,
|
|
404
|
+
definition,
|
|
405
|
+
range,
|
|
406
|
+
nodes: [],
|
|
407
|
+
regions: [],
|
|
408
|
+
owned: [],
|
|
409
|
+
previous: [],
|
|
410
|
+
groups: /* @__PURE__ */ new Map(),
|
|
411
|
+
environment: [],
|
|
412
|
+
fresh,
|
|
413
|
+
disposed: false,
|
|
414
|
+
activated: false
|
|
415
|
+
};
|
|
416
|
+
transaction.all.add(instance);
|
|
417
|
+
if (fresh) {
|
|
418
|
+
transaction.candidates.add(instance);
|
|
419
|
+
transaction.preview?.fragments.add(instance);
|
|
420
|
+
}
|
|
421
|
+
const cursors = /* @__PURE__ */ new Map([[-1, range.start.nextSibling]]);
|
|
422
|
+
const counts = /* @__PURE__ */ new Map();
|
|
423
|
+
const regions = /* @__PURE__ */ new Map();
|
|
424
|
+
for (const region of definition.regions) {
|
|
425
|
+
if (regions.has(region.node) || definition.nodes[region.node]?.[1] !== "region") mismatch();
|
|
426
|
+
regions.set(region.node, region);
|
|
427
|
+
}
|
|
428
|
+
for (let index = 0; index < definition.nodes.length; index++) {
|
|
429
|
+
const proof = definition.nodes[index];
|
|
430
|
+
const parent = proof[0];
|
|
431
|
+
if (parent !== -1 && (parent < 0 || parent >= index || definition.nodes[parent]?.[1] !== "element" || definition.nodes[parent]?.[4] === null))
|
|
432
|
+
mismatch();
|
|
433
|
+
const node = cursors.get(parent);
|
|
434
|
+
if (node == null || node === range.end) mismatch();
|
|
435
|
+
counts.set(parent, (counts.get(parent) ?? 0) + 1);
|
|
436
|
+
instance.nodes[index] = node;
|
|
437
|
+
let next = node.nextSibling;
|
|
438
|
+
if (proof[1] === "element") {
|
|
439
|
+
if (node.nodeType !== 1 || node.localName !== proof[2] || node.namespaceURI !== (proof[3] === 0 ? "http://www.w3.org/1999/xhtml" : "http://www.w3.org/2000/svg"))
|
|
440
|
+
mismatch();
|
|
441
|
+
if (proof[4] !== null) cursors.set(index, node.firstChild);
|
|
442
|
+
} else if (proof[1] === "text") {
|
|
443
|
+
if (node.nodeType !== 3 || node.nodeValue !== proof[2]) mismatch();
|
|
444
|
+
} else {
|
|
445
|
+
const childRange = rangeAt(node, parent === -1 ? range.end : null);
|
|
446
|
+
const marker = parseBindingMarker(childRange.start.data);
|
|
447
|
+
const region = regions.get(index);
|
|
448
|
+
if (!region || marker?.id !== id || marker.site !== proof[2] || marker.kind !== region.kind)
|
|
449
|
+
mismatch();
|
|
450
|
+
const state = {
|
|
451
|
+
definition: region,
|
|
452
|
+
range: childRange,
|
|
453
|
+
site: proof[2],
|
|
454
|
+
arm: marker.arm ?? -1,
|
|
455
|
+
child: null,
|
|
456
|
+
items: null,
|
|
457
|
+
text: null,
|
|
458
|
+
unresolvedSlot: region.kind === "slot" && !fresh
|
|
459
|
+
};
|
|
460
|
+
instance.regions.push(state);
|
|
461
|
+
next = childRange.end.nextSibling;
|
|
462
|
+
if (!fresh) adoptRegion(state, id, transaction);
|
|
463
|
+
}
|
|
464
|
+
cursors.set(parent, next);
|
|
465
|
+
}
|
|
466
|
+
if (cursors.get(-1) !== range.end) mismatch();
|
|
467
|
+
for (let index = 0; index < definition.nodes.length; index++) {
|
|
468
|
+
const proof = definition.nodes[index];
|
|
469
|
+
if (proof[1] === "element" && proof[4] !== null && (cursors.get(index) !== null || (counts.get(index) ?? 0) !== proof[4]))
|
|
470
|
+
mismatch();
|
|
471
|
+
}
|
|
472
|
+
for (let index = 0; index < definition.bindings.length; index++) {
|
|
473
|
+
const binding = definition.bindings[index];
|
|
474
|
+
const node = instance.nodes[binding[0]];
|
|
475
|
+
if (node?.nodeType !== 1) mismatch();
|
|
476
|
+
instance.owned.push([node, __claimBinding(node, binding)]);
|
|
477
|
+
if (binding[1] === "control")
|
|
478
|
+
transaction.hostOperations.claimControl(instance, index, node, transaction);
|
|
479
|
+
if (!fresh && binding[1] === "classGroup")
|
|
480
|
+
instance.groups.set(
|
|
481
|
+
index,
|
|
482
|
+
definition.createClassGroup(node, binding[2], binding[3])
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
return instance;
|
|
486
|
+
}
|
|
487
|
+
function adoptRegion(region, id, transaction) {
|
|
488
|
+
const definition = region.definition;
|
|
489
|
+
const range = region.range;
|
|
490
|
+
if (definition.kind === "if") {
|
|
491
|
+
if (region.arm === -1) {
|
|
492
|
+
if (range.start.nextSibling !== range.end) mismatch();
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
const arm = definition.arms[region.arm];
|
|
496
|
+
if (!arm) mismatch();
|
|
497
|
+
let body = range;
|
|
498
|
+
if (definition.armRange) {
|
|
499
|
+
body = rangeAt(range.start.nextSibling, range.end);
|
|
500
|
+
if (body.start.data !== "[" || body.end.nextSibling !== range.end) mismatch();
|
|
501
|
+
}
|
|
502
|
+
region.child = resolveFragment(arm, id, body, false, transaction);
|
|
503
|
+
} else if (definition.kind === "for") {
|
|
504
|
+
transaction.list.adopt(region, id, transaction);
|
|
505
|
+
} else if (definition.kind === "view") {
|
|
506
|
+
region.child = resolveFragment(
|
|
507
|
+
definition.view.root,
|
|
508
|
+
definition.view.id,
|
|
509
|
+
range,
|
|
510
|
+
false,
|
|
511
|
+
transaction
|
|
512
|
+
);
|
|
513
|
+
} else if (definition.kind === "text") {
|
|
514
|
+
const text = range.start.nextSibling;
|
|
515
|
+
if (text !== range.end) {
|
|
516
|
+
if (text?.nodeType !== 3 || text.nextSibling !== range.end) mismatch();
|
|
517
|
+
region.text = text;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function createFragment(definition, id, document, transaction) {
|
|
522
|
+
requireActive(transaction);
|
|
523
|
+
if (definition.constructible === false)
|
|
524
|
+
throw new Error(
|
|
525
|
+
definition.constructionError ?? "This opaque view cannot be constructed without its external owner."
|
|
526
|
+
);
|
|
527
|
+
const template = document.createElement("template");
|
|
528
|
+
template.innerHTML = definition.ns === 1 ? `<svg>${definition.html}</svg>` : definition.html;
|
|
529
|
+
const content = document.createDocumentFragment();
|
|
530
|
+
const start = document.createComment(`[b;${id};root`);
|
|
531
|
+
const end = document.createComment("]");
|
|
532
|
+
content.appendChild(start);
|
|
533
|
+
if (definition.ns === 1) {
|
|
534
|
+
const svg = template.content.firstChild;
|
|
535
|
+
while (svg.firstChild) content.appendChild(svg.firstChild);
|
|
536
|
+
} else content.appendChild(template.content);
|
|
537
|
+
content.appendChild(end);
|
|
538
|
+
return resolveFragment(definition, id, { start, end }, true, transaction);
|
|
539
|
+
}
|
|
540
|
+
function projectValues(values, instance, transaction, controls) {
|
|
541
|
+
const operations = instance.definition.bindings;
|
|
542
|
+
if (!Array.isArray(values) || values.length !== operations.length)
|
|
543
|
+
throw new TypeError("A DOM presentation projection must return its synchronous scalar values.");
|
|
544
|
+
values = transaction.hostOperations?.project(values, instance, transaction) ?? values;
|
|
545
|
+
if (transaction.signals || transaction.styles) {
|
|
546
|
+
let copied = false;
|
|
547
|
+
const indices = instance.definition.styleIndices ? [...instance.definition.signalIndices ?? [], ...instance.definition.styleIndices] : instance.definition.signalIndices ?? [];
|
|
548
|
+
for (const index of indices) {
|
|
549
|
+
requireActive(transaction);
|
|
550
|
+
let connection = (transaction.preview?.signals.get(instance) ?? instance.signals)?.get(index);
|
|
551
|
+
const style = operations[index][1] === "styleObject";
|
|
552
|
+
if (!connection && (style || transaction.signals?.isSignal(values[index]))) {
|
|
553
|
+
const prepare = () => {
|
|
554
|
+
if (instance.disposed || transaction.preparing && instance.signalFrame !== transaction.frame)
|
|
555
|
+
return () => {
|
|
556
|
+
};
|
|
557
|
+
const value = __normalizeBinding(operations[index], connection.get());
|
|
558
|
+
const group = instance.groups.get(index)?.prepare(value ?? "");
|
|
559
|
+
if (transaction.preparing && instance.signalPlan) {
|
|
560
|
+
instance.signalPlan.values[index] = value;
|
|
561
|
+
if (group) instance.signalPlan.groups.set(index, group);
|
|
562
|
+
return () => {
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
return () => writeOperation(instance, index, value, group, transaction);
|
|
566
|
+
};
|
|
567
|
+
const notify = forwardNativeTransitionConsumer(
|
|
568
|
+
transaction.consumer,
|
|
569
|
+
() => transaction.notifySignal(prepare)
|
|
570
|
+
);
|
|
571
|
+
connection = style ? transaction.styles.connect(
|
|
572
|
+
instance.nodes[operations[index][0]],
|
|
573
|
+
notify,
|
|
574
|
+
transaction.restoreStyles
|
|
575
|
+
) : transaction.signals.connect(notify);
|
|
576
|
+
if (transaction.preview) {
|
|
577
|
+
let signals = transaction.preview.signals.get(instance);
|
|
578
|
+
if (!signals)
|
|
579
|
+
transaction.preview.signals.set(instance, signals = new Map(instance.signals));
|
|
580
|
+
signals.set(index, connection);
|
|
581
|
+
const created = connection;
|
|
582
|
+
transaction.preview.disposals.push(() => created.dispose(true));
|
|
583
|
+
} else (instance.signals ??= /* @__PURE__ */ new Map()).set(index, connection);
|
|
584
|
+
}
|
|
585
|
+
if (connection) {
|
|
586
|
+
if (!copied) {
|
|
587
|
+
values = [...values];
|
|
588
|
+
copied = true;
|
|
589
|
+
}
|
|
590
|
+
if (transaction.preview) {
|
|
591
|
+
const receipt = connection.preview(values[index]);
|
|
592
|
+
transaction.preview.receipts.push(receipt);
|
|
593
|
+
values[index] = receipt.value;
|
|
594
|
+
} else values[index] = connection.read(values[index]);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return values.map((value, index) => {
|
|
599
|
+
if (operations[index][1] === "control") {
|
|
600
|
+
const control = transaction.preview ? instance.controls.get(index).preview(value) : instance.controls.get(index).prepare(value);
|
|
601
|
+
transaction.preview?.controls.push(control);
|
|
602
|
+
controls.set(index, control);
|
|
603
|
+
return null;
|
|
604
|
+
}
|
|
605
|
+
return __normalizeBinding(operations[index], value);
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
function textValue(value, generic) {
|
|
609
|
+
if (generic) {
|
|
610
|
+
if (value == null || typeof value === "boolean") return "";
|
|
611
|
+
if (!["string", "number", "bigint"].includes(typeof value))
|
|
612
|
+
throw new TypeError("A DOM presentation signal text requires a primitive value.");
|
|
613
|
+
}
|
|
614
|
+
return value == null || value === false ? "" : String(value);
|
|
615
|
+
}
|
|
616
|
+
function initialValues(instance, environment) {
|
|
617
|
+
const definition = instance.definition;
|
|
618
|
+
if (!instance.fresh || !definition.initializers?.length) return null;
|
|
619
|
+
const values = definition.initialize?.(environment);
|
|
620
|
+
if (!Array.isArray(values) || values.length !== definition.initializers.length)
|
|
621
|
+
throw new TypeError(
|
|
622
|
+
"A DOM presentation initializer must return its synchronous scalar values."
|
|
623
|
+
);
|
|
624
|
+
return definition.initializers.map((operation, index) => {
|
|
625
|
+
if (instance.nodes[operation[0]]?.nodeType !== 1) mismatch();
|
|
626
|
+
const value = values[index];
|
|
627
|
+
switch (operation[1]) {
|
|
628
|
+
case "classGroupInitial": {
|
|
629
|
+
const baseline = __normalizeBinding([operation[0], "class", "class"], value) ?? "";
|
|
630
|
+
const groups = [];
|
|
631
|
+
for (const binding of definition.bindings)
|
|
632
|
+
if (binding[0] === operation[0] && binding[1] === "classGroup" && binding[2] === operation[2])
|
|
633
|
+
groups[binding[3]] = "";
|
|
634
|
+
return JSON.stringify([baseline, groups]);
|
|
635
|
+
}
|
|
636
|
+
case "checked":
|
|
637
|
+
case "defaultChecked":
|
|
638
|
+
case "selected":
|
|
639
|
+
return Boolean(value);
|
|
640
|
+
case "value":
|
|
641
|
+
case "defaultValue":
|
|
642
|
+
if (instance.nodes[operation[0]].localName === "select" && Array.isArray(value))
|
|
643
|
+
return value.map(String);
|
|
644
|
+
return value == null ? "" : String(value);
|
|
645
|
+
default:
|
|
646
|
+
return __normalizeBinding(operation, value);
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
function prepareFragment(instance, environment, transaction) {
|
|
651
|
+
requireActive(transaction);
|
|
652
|
+
const definition = instance.definition;
|
|
653
|
+
const controls = instance.controls && /* @__PURE__ */ new Map();
|
|
654
|
+
const plan = {
|
|
655
|
+
instance,
|
|
656
|
+
environment,
|
|
657
|
+
values: projectValues(definition.project(environment), instance, transaction, controls),
|
|
658
|
+
initial: transaction.hostOperations?.initial(instance, environment) ?? null,
|
|
659
|
+
regions: [],
|
|
660
|
+
groups: /* @__PURE__ */ new Map(),
|
|
661
|
+
controls,
|
|
662
|
+
adapters: instance.cleanup?.prepare?.(environment)
|
|
663
|
+
};
|
|
664
|
+
if (!transaction.preview && (instance.signals || instance.controls || instance.projections)) {
|
|
665
|
+
instance.signalPlan = plan;
|
|
666
|
+
instance.signalFrame = transaction.frame;
|
|
667
|
+
}
|
|
668
|
+
requireActive(transaction);
|
|
669
|
+
transaction.hostOperations?.groups(plan);
|
|
670
|
+
const document = instance.range.start.ownerDocument;
|
|
671
|
+
requireActive(transaction);
|
|
672
|
+
for (const region of instance.regions) {
|
|
673
|
+
const descriptor = region.definition;
|
|
674
|
+
const candidate = {
|
|
675
|
+
instance: region,
|
|
676
|
+
arm: -1,
|
|
677
|
+
child: null,
|
|
678
|
+
items: null,
|
|
679
|
+
text: null
|
|
680
|
+
};
|
|
681
|
+
plan.regions.push(candidate);
|
|
682
|
+
if (descriptor.kind === "text") {
|
|
683
|
+
let value = descriptor.read(environment);
|
|
684
|
+
if (descriptor.signal && transaction.signals) {
|
|
685
|
+
let connection = transaction.preview?.text.get(region) ?? region.signal;
|
|
686
|
+
if (!connection && transaction.signals.isSignal(value)) {
|
|
687
|
+
const prepare = () => {
|
|
688
|
+
if (instance.disposed || transaction.preparing && region.signalFrame !== transaction.frame)
|
|
689
|
+
return () => {
|
|
690
|
+
};
|
|
691
|
+
const next = textValue(region.signal.get(), descriptor.generic);
|
|
692
|
+
if (transaction.preparing && region.signalPlan) {
|
|
693
|
+
region.signalPlan.text = next;
|
|
694
|
+
return () => {
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
return () => {
|
|
698
|
+
if (!instance.disposed && !transaction.disposed) writeText(region, next);
|
|
699
|
+
};
|
|
700
|
+
};
|
|
701
|
+
connection = transaction.signals.connect(
|
|
702
|
+
forwardNativeTransitionConsumer(
|
|
703
|
+
transaction.consumer,
|
|
704
|
+
() => transaction.notifySignal(prepare)
|
|
705
|
+
)
|
|
706
|
+
);
|
|
707
|
+
if (transaction.preview) {
|
|
708
|
+
transaction.preview.text.set(region, connection);
|
|
709
|
+
const created = connection;
|
|
710
|
+
transaction.preview.disposals.push(() => created.dispose());
|
|
711
|
+
} else region.signal = connection;
|
|
712
|
+
}
|
|
713
|
+
if (connection) {
|
|
714
|
+
if (transaction.preview) {
|
|
715
|
+
const receipt = connection.preview(value);
|
|
716
|
+
transaction.preview.receipts.push(receipt);
|
|
717
|
+
value = receipt.value;
|
|
718
|
+
} else {
|
|
719
|
+
region.signalPlan = candidate;
|
|
720
|
+
region.signalFrame = transaction.frame;
|
|
721
|
+
value = connection.read(value);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
candidate.text = textValue(value, descriptor.generic);
|
|
726
|
+
} else if (descriptor.kind === "if") {
|
|
727
|
+
const arm = descriptor.select(environment);
|
|
728
|
+
if (!Number.isSafeInteger(arm) || arm < -1 || arm >= descriptor.arms.length)
|
|
729
|
+
throw new TypeError("A DOM presentation branch projection returned an unknown arm.");
|
|
730
|
+
candidate.arm = arm;
|
|
731
|
+
if (arm !== -1)
|
|
732
|
+
candidate.child = prepareFragment(
|
|
733
|
+
region.arm === arm && region.child ? region.child : createFragment(descriptor.arms[arm], instance.id, document, transaction),
|
|
734
|
+
environment,
|
|
735
|
+
transaction
|
|
736
|
+
);
|
|
737
|
+
} else if (descriptor.kind === "for") {
|
|
738
|
+
transaction.list.prepare(instance, region, candidate, environment, document, transaction);
|
|
739
|
+
} else if (descriptor.kind === "view") {
|
|
740
|
+
candidate.child = prepareFragment(
|
|
741
|
+
region.child ?? createFragment(descriptor.view.root, descriptor.view.id, document, transaction),
|
|
742
|
+
descriptor.view.prepareProps ? descriptor.view.prepareProps(descriptor.props(environment)) : [descriptor.props(environment)],
|
|
743
|
+
transaction
|
|
744
|
+
);
|
|
745
|
+
} else if (descriptor.kind === "slot") {
|
|
746
|
+
const value = descriptor.read(environment);
|
|
747
|
+
if (value != null && (typeof value !== "object" || value[bindingSlot] !== true))
|
|
748
|
+
throw new TypeError("A DOM presentation child slot requires a compiler-owned fragment.");
|
|
749
|
+
const slot = value;
|
|
750
|
+
if (slot?.site !== void 0) candidate.slot = slot.id + ";" + slot.site;
|
|
751
|
+
if (region.unresolvedSlot) {
|
|
752
|
+
if (slot)
|
|
753
|
+
region.child = resolveFragment(slot.fragment, slot.id, region.range, false, transaction);
|
|
754
|
+
else if (region.range.start.nextSibling !== region.range.end) mismatch();
|
|
755
|
+
region.unresolvedSlot = false;
|
|
756
|
+
}
|
|
757
|
+
if (slot)
|
|
758
|
+
candidate.child = prepareFragment(
|
|
759
|
+
region.child?.definition === slot.fragment && region.child.id === slot.id ? region.child : createFragment(slot.fragment, slot.id, document, transaction),
|
|
760
|
+
slot.environment,
|
|
761
|
+
transaction
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
requireActive(transaction);
|
|
766
|
+
return plan;
|
|
767
|
+
}
|
|
768
|
+
function removeRange(range, interior, transaction) {
|
|
769
|
+
let node = interior ? range.start.nextSibling : range.start;
|
|
770
|
+
const stop = interior ? range.end : range.end.nextSibling;
|
|
771
|
+
while (node !== stop && node !== null && !transaction?.disposed) {
|
|
772
|
+
const next = node.nextSibling;
|
|
773
|
+
node.parentNode.removeChild(node);
|
|
774
|
+
node = next;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function moveRange(range, parent, anchor, transaction) {
|
|
778
|
+
if (range.end.nextSibling === anchor && range.start.parentNode === parent) return;
|
|
779
|
+
const nodes = [];
|
|
780
|
+
for (let node = range.start; node !== null; node = node.nextSibling) {
|
|
781
|
+
nodes.push(node);
|
|
782
|
+
if (node === range.end) break;
|
|
783
|
+
}
|
|
784
|
+
for (const node of nodes) {
|
|
785
|
+
if (transaction.disposed) return;
|
|
786
|
+
moveNativeNodeBefore(parent, node, anchor, transaction.focused, transaction.contentEditable);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
function insertBody(instance, range, armRange, transaction) {
|
|
790
|
+
if (armRange) {
|
|
791
|
+
instance.range.start.data = "[";
|
|
792
|
+
moveRange(instance.range, range.end.parentNode, range.end, transaction);
|
|
793
|
+
} else {
|
|
794
|
+
let node = instance.range.start.nextSibling;
|
|
795
|
+
while (node !== instance.range.end && !transaction.disposed) {
|
|
796
|
+
const next = node.nextSibling;
|
|
797
|
+
range.end.parentNode.insertBefore(node, range.end);
|
|
798
|
+
node = next;
|
|
799
|
+
}
|
|
800
|
+
instance.range = range;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
function initializeProperties(plan, afterChildren, transaction) {
|
|
804
|
+
if (!plan.initial) return;
|
|
805
|
+
const instance = plan.instance;
|
|
806
|
+
const operations = instance.definition.initializers;
|
|
807
|
+
for (let index = 0; index < operations.length && !transaction.disposed; index++) {
|
|
808
|
+
const operation = operations[index];
|
|
809
|
+
const node = instance.nodes[operation[0]];
|
|
810
|
+
const value = plan.initial[index];
|
|
811
|
+
const deferred = node.localName === "select" && (operation[1] === "value" || operation[1] === "defaultValue");
|
|
812
|
+
if (deferred !== afterChildren) continue;
|
|
813
|
+
switch (operation[1]) {
|
|
814
|
+
case "classGroupInitial": {
|
|
815
|
+
const baseline = JSON.parse(value)[0];
|
|
816
|
+
__writeBinding(node, [operation[0], "class", "class"], baseline);
|
|
817
|
+
if (!transaction.disposed) node.setAttribute(operation[2], value);
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
case "value":
|
|
821
|
+
case "defaultValue":
|
|
822
|
+
if (node.localName === "select") {
|
|
823
|
+
const select = node;
|
|
824
|
+
if (Array.isArray(value)) {
|
|
825
|
+
const selected = new Set(value);
|
|
826
|
+
for (const option of select.options) option.selected = selected.has(option.value);
|
|
827
|
+
} else select.value = value;
|
|
828
|
+
if (operation[1] === "defaultValue")
|
|
829
|
+
for (const option of select.options) option.defaultSelected = option.selected;
|
|
830
|
+
} else node[operation[1]] = value;
|
|
831
|
+
break;
|
|
832
|
+
case "checked":
|
|
833
|
+
case "defaultChecked":
|
|
834
|
+
node[operation[1]] = value;
|
|
835
|
+
break;
|
|
836
|
+
case "selected":
|
|
837
|
+
node.selected = value;
|
|
838
|
+
break;
|
|
839
|
+
default:
|
|
840
|
+
__writeBinding(node, operation, value);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
function commitRegion(plan, id, transaction) {
|
|
845
|
+
const region = plan.instance;
|
|
846
|
+
const definition = region.definition;
|
|
847
|
+
if (definition.kind === "opaque") return;
|
|
848
|
+
if (definition.kind === "text") {
|
|
849
|
+
region.signalPlan = void 0;
|
|
850
|
+
writeText(region, plan.text);
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
if (definition.kind === "for") {
|
|
854
|
+
transaction.list.commit(plan, id, transaction);
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
const oldChild = region.child;
|
|
858
|
+
const child = plan.child?.instance ?? null;
|
|
859
|
+
region.child = child;
|
|
860
|
+
region.arm = plan.arm;
|
|
861
|
+
if (definition.kind === "slot") region.slot = plan.slot;
|
|
862
|
+
if (oldChild !== child) {
|
|
863
|
+
if (oldChild) releaseInstance(oldChild, transaction);
|
|
864
|
+
if (transaction.disposed) return;
|
|
865
|
+
removeRange(region.range, true, transaction);
|
|
866
|
+
}
|
|
867
|
+
if (plan.child) {
|
|
868
|
+
commitFragment(plan.child, transaction);
|
|
869
|
+
if (transaction.disposed) return;
|
|
870
|
+
if (oldChild !== child)
|
|
871
|
+
insertBody(
|
|
872
|
+
child,
|
|
873
|
+
region.range,
|
|
874
|
+
definition.kind === "if" && !!definition.armRange,
|
|
875
|
+
transaction
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
if (definition.kind === "if") region.range.start.data = `[b;${id};${region.site};${plan.arm}`;
|
|
879
|
+
}
|
|
880
|
+
function writeText(region, value) {
|
|
881
|
+
if (region.text === null) {
|
|
882
|
+
if (value !== "") {
|
|
883
|
+
region.text = region.range.start.ownerDocument.createTextNode(value);
|
|
884
|
+
region.range.end.parentNode.insertBefore(region.text, region.range.end);
|
|
885
|
+
}
|
|
886
|
+
} else if (region.text.data !== value) region.text.data = value;
|
|
887
|
+
}
|
|
888
|
+
function writeOperation(instance, index, value, group, transaction) {
|
|
889
|
+
if (transaction.disposed || instance.disposed || value === instance.previous[index]) return;
|
|
890
|
+
const operation = instance.definition.bindings[index];
|
|
891
|
+
if (operation[1] === "classToken") instance.previous[index] = value;
|
|
892
|
+
if (operation[1] === "styleObject") {
|
|
893
|
+
const projection = instance.projections?.get(index);
|
|
894
|
+
if (projection) projection.writeStyle(index, value);
|
|
895
|
+
else instance.signals.get(index).write(value);
|
|
896
|
+
} else if (operation[1] === "classGroup") group.commit();
|
|
897
|
+
else if ((operation[1] === "styleProperty" || operation[1] === "styleAttribute") && transaction.restoreStyles) {
|
|
898
|
+
instance.styles ??= /* @__PURE__ */ new Map();
|
|
899
|
+
let style = instance.styles.get(index);
|
|
900
|
+
if (!style)
|
|
901
|
+
instance.styles.set(
|
|
902
|
+
index,
|
|
903
|
+
style = __createBindingStyleRestoration(
|
|
904
|
+
instance.nodes[operation[0]],
|
|
905
|
+
operation
|
|
906
|
+
)
|
|
907
|
+
);
|
|
908
|
+
style.write(value);
|
|
909
|
+
} else __writeBinding(instance.nodes[operation[0]], operation, value);
|
|
910
|
+
if (!transaction.disposed && !instance.disposed) instance.previous[index] = value;
|
|
911
|
+
}
|
|
912
|
+
function commitFragment(plan, transaction) {
|
|
913
|
+
const instance = plan.instance;
|
|
914
|
+
if (transaction.disposed) return;
|
|
915
|
+
instance.signalPlan = void 0;
|
|
916
|
+
instance.environment = plan.environment;
|
|
917
|
+
instance.updateAdapters = plan.adapters;
|
|
918
|
+
transaction.hostOperations?.initialize(plan, false, transaction);
|
|
919
|
+
for (let index = 0; index < plan.values.length && !transaction.disposed; index++) {
|
|
920
|
+
if (instance.definition.bindings[index][1] === "control") continue;
|
|
921
|
+
writeOperation(instance, index, plan.values[index], plan.groups.get(index), transaction);
|
|
922
|
+
}
|
|
923
|
+
for (const region of plan.regions) {
|
|
924
|
+
if (transaction.disposed) return;
|
|
925
|
+
commitRegion(region, instance.id, transaction);
|
|
926
|
+
}
|
|
927
|
+
transaction.hostOperations?.initialize(plan, true, transaction);
|
|
928
|
+
for (const control of plan.controls?.values() ?? []) {
|
|
929
|
+
if (transaction.disposed) return;
|
|
930
|
+
control.commit();
|
|
931
|
+
}
|
|
932
|
+
if (!transaction.disposed) instance.fresh = false;
|
|
933
|
+
}
|
|
934
|
+
function publishControls(plan, transaction) {
|
|
935
|
+
if (transaction.disposed) return;
|
|
936
|
+
for (const control of plan.controls?.values() ?? []) {
|
|
937
|
+
if (transaction.disposed) return;
|
|
938
|
+
control.publish();
|
|
939
|
+
}
|
|
940
|
+
for (const region of plan.regions) {
|
|
941
|
+
if (region.child) publishControls(region.child, transaction);
|
|
942
|
+
if (region.items)
|
|
943
|
+
for (const child of region.items.values()) publishControls(child, transaction);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
function activateInstance(instance, transaction) {
|
|
947
|
+
if (transaction.disposed || instance.disposed) return;
|
|
948
|
+
if (!instance.activated) {
|
|
949
|
+
instance.activated = true;
|
|
950
|
+
if (instance.definition.activate) {
|
|
951
|
+
const controller = new AbortController();
|
|
952
|
+
instance.controller = controller;
|
|
953
|
+
const cleanup = instance.definition.activate(instance.nodes, {
|
|
954
|
+
signal: controller.signal,
|
|
955
|
+
getEnvironment: () => instance.environment
|
|
956
|
+
});
|
|
957
|
+
if (cleanup !== void 0 && typeof cleanup !== "function")
|
|
958
|
+
throw new TypeError("A DOM presentation activation must return cleanup or undefined.");
|
|
959
|
+
if (instance.disposed) cleanup?.();
|
|
960
|
+
else if (cleanup) instance.cleanup = cleanup;
|
|
961
|
+
}
|
|
962
|
+
} else {
|
|
963
|
+
const update = instance.updateAdapters;
|
|
964
|
+
instance.updateAdapters = void 0;
|
|
965
|
+
update?.();
|
|
966
|
+
}
|
|
967
|
+
for (const region of instance.regions) {
|
|
968
|
+
if (region.child) activateInstance(region.child, transaction);
|
|
969
|
+
if (region.items)
|
|
970
|
+
for (const child of region.items.values()) activateInstance(child, transaction);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
function bindProgram(root, descriptor, source, options, mount, list = descriptor.list, hostOperations = descriptor.hostOperations) {
|
|
974
|
+
if (!source || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function")
|
|
975
|
+
throw new TypeError(
|
|
976
|
+
"DOM presentation requires synchronous getSnapshot() and subscribe() methods."
|
|
977
|
+
);
|
|
978
|
+
const target = mount ? root : null;
|
|
979
|
+
if (target && (!target.parent || target.before != null && target.before.parentNode !== target.parent))
|
|
980
|
+
throw new TypeError(
|
|
981
|
+
"A DOM presentation mount requires a parent and its optional insertion anchor."
|
|
982
|
+
);
|
|
983
|
+
const transaction = {
|
|
984
|
+
disposed: false,
|
|
985
|
+
all: /* @__PURE__ */ new Set(),
|
|
986
|
+
candidates: /* @__PURE__ */ new Set(),
|
|
987
|
+
focused: null,
|
|
988
|
+
contentEditable: false,
|
|
989
|
+
restoreStyles: options?.restoreStyles === true,
|
|
990
|
+
signals: descriptor.connectSignal?.(),
|
|
991
|
+
styles: descriptor.connectStyle?.(),
|
|
992
|
+
projections: descriptor.connectProjection?.(),
|
|
993
|
+
controls: descriptor.createControls?.(),
|
|
994
|
+
list,
|
|
995
|
+
hostOperations,
|
|
996
|
+
frame: 0
|
|
997
|
+
};
|
|
998
|
+
const signalUpdates = transaction.signals || transaction.styles || transaction.projections || transaction.controls ? /* @__PURE__ */ new Set() : void 0;
|
|
999
|
+
let instance;
|
|
1000
|
+
let ownedRoot;
|
|
1001
|
+
let busy = true;
|
|
1002
|
+
let dirty = false;
|
|
1003
|
+
let revision = 0;
|
|
1004
|
+
let mounted = !mount;
|
|
1005
|
+
let unsubscribe;
|
|
1006
|
+
const signal = options?.signal;
|
|
1007
|
+
const dispose = (disposal, publish) => {
|
|
1008
|
+
if (transaction.disposed) {
|
|
1009
|
+
publish?.();
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
transaction.disposed = true;
|
|
1013
|
+
signalUpdates?.clear();
|
|
1014
|
+
signal?.removeEventListener("abort", abort);
|
|
1015
|
+
let failed = false;
|
|
1016
|
+
let failure;
|
|
1017
|
+
if (publish !== void 0) {
|
|
1018
|
+
for (const owned of transaction.all) owned.controller?.abort();
|
|
1019
|
+
try {
|
|
1020
|
+
publish();
|
|
1021
|
+
} catch (error) {
|
|
1022
|
+
failed = true;
|
|
1023
|
+
failure = error;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
for (const owned of [...transaction.all]) {
|
|
1027
|
+
try {
|
|
1028
|
+
releaseInstance(owned, transaction);
|
|
1029
|
+
} catch (error) {
|
|
1030
|
+
if (!failed) {
|
|
1031
|
+
failed = true;
|
|
1032
|
+
failure = error;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
const stop = unsubscribe;
|
|
1037
|
+
unsubscribe = void 0;
|
|
1038
|
+
try {
|
|
1039
|
+
stop?.();
|
|
1040
|
+
} catch (error) {
|
|
1041
|
+
if (!failed) {
|
|
1042
|
+
failed = true;
|
|
1043
|
+
failure = error;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
try {
|
|
1047
|
+
if (disposal?.preserveDOM === false && mounted && instance)
|
|
1048
|
+
removeRange(instance.range, false);
|
|
1049
|
+
} catch (error) {
|
|
1050
|
+
if (!failed) {
|
|
1051
|
+
failed = true;
|
|
1052
|
+
failure = error;
|
|
1053
|
+
}
|
|
1054
|
+
} finally {
|
|
1055
|
+
if (ownedRoot) programRoots.delete(ownedRoot);
|
|
1056
|
+
}
|
|
1057
|
+
if (failed) throw failure;
|
|
1058
|
+
};
|
|
1059
|
+
const abort = () => dispose();
|
|
1060
|
+
const drain = () => {
|
|
1061
|
+
if (transaction.disposed) return;
|
|
1062
|
+
if (busy) return;
|
|
1063
|
+
busy = true;
|
|
1064
|
+
try {
|
|
1065
|
+
while ((dirty || signalUpdates?.size) && !transaction.disposed) {
|
|
1066
|
+
if (!dirty) {
|
|
1067
|
+
if (transaction.projections) {
|
|
1068
|
+
const writes2 = /* @__PURE__ */ new Map();
|
|
1069
|
+
while (signalUpdates.size && !dirty && !transaction.disposed) {
|
|
1070
|
+
const pending2 = [...signalUpdates];
|
|
1071
|
+
signalUpdates.clear();
|
|
1072
|
+
for (const prepare of pending2) writes2.set(prepare, prepare());
|
|
1073
|
+
}
|
|
1074
|
+
if (!dirty && !transaction.disposed) {
|
|
1075
|
+
for (const write of writes2.values()) write();
|
|
1076
|
+
transaction.published?.();
|
|
1077
|
+
}
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
const pending = [...signalUpdates];
|
|
1081
|
+
signalUpdates.clear();
|
|
1082
|
+
const writes = pending.map((prepare) => prepare());
|
|
1083
|
+
if (!dirty && !transaction.disposed) {
|
|
1084
|
+
for (const write of writes) write();
|
|
1085
|
+
transaction.published?.();
|
|
1086
|
+
}
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
dirty = false;
|
|
1090
|
+
signalUpdates?.clear();
|
|
1091
|
+
const snapshot = source.getSnapshot();
|
|
1092
|
+
if (dirty || transaction.disposed) continue;
|
|
1093
|
+
if (snapshot !== null && (typeof snapshot === "object" || typeof snapshot === "function") && typeof snapshot.then === "function")
|
|
1094
|
+
throw new TypeError("DOM presentation requires a synchronous snapshot, not a thenable.");
|
|
1095
|
+
transaction.preparing = true;
|
|
1096
|
+
transaction.frame++;
|
|
1097
|
+
const plan = prepareFragment(
|
|
1098
|
+
instance,
|
|
1099
|
+
descriptor.prepareProps ? descriptor.prepareProps(snapshot) : [snapshot],
|
|
1100
|
+
transaction
|
|
1101
|
+
);
|
|
1102
|
+
if (!dirty && !transaction.disposed && transaction.controls)
|
|
1103
|
+
transaction.hostOperations.publish(plan, transaction);
|
|
1104
|
+
while (signalUpdates?.size && !dirty && !transaction.disposed) {
|
|
1105
|
+
const pending = [...signalUpdates];
|
|
1106
|
+
signalUpdates.clear();
|
|
1107
|
+
for (const prepare of pending) prepare();
|
|
1108
|
+
}
|
|
1109
|
+
transaction.preparing = false;
|
|
1110
|
+
if (dirty || transaction.disposed) {
|
|
1111
|
+
for (const candidate of [...transaction.candidates])
|
|
1112
|
+
if (candidate !== instance) releaseInstance(candidate, transaction);
|
|
1113
|
+
if (instance.fresh) {
|
|
1114
|
+
for (const group of instance.groups.values()) group.dispose();
|
|
1115
|
+
instance.groups.clear();
|
|
1116
|
+
}
|
|
1117
|
+
continue;
|
|
1118
|
+
}
|
|
1119
|
+
const document = instance.range.start.ownerDocument;
|
|
1120
|
+
const tree = instance.range.start.getRootNode();
|
|
1121
|
+
let focused = "activeElement" in tree ? tree.activeElement : document.activeElement;
|
|
1122
|
+
while (focused?.shadowRoot?.activeElement) focused = focused.shadowRoot.activeElement;
|
|
1123
|
+
transaction.focused = focused;
|
|
1124
|
+
transaction.contentEditable = !!transaction.focused?.isContentEditable;
|
|
1125
|
+
commitFragment(plan, transaction);
|
|
1126
|
+
if (transaction.disposed) break;
|
|
1127
|
+
transaction.published?.();
|
|
1128
|
+
if (!mounted) {
|
|
1129
|
+
moveRange(instance.range, target.parent, target.before ?? null, transaction);
|
|
1130
|
+
mounted = true;
|
|
1131
|
+
}
|
|
1132
|
+
transaction.candidates.clear();
|
|
1133
|
+
activateInstance(instance, transaction);
|
|
1134
|
+
}
|
|
1135
|
+
} catch (error) {
|
|
1136
|
+
if (error === stopped) return;
|
|
1137
|
+
try {
|
|
1138
|
+
dispose();
|
|
1139
|
+
} catch {
|
|
1140
|
+
}
|
|
1141
|
+
throw error;
|
|
1142
|
+
} finally {
|
|
1143
|
+
transaction.preparing = false;
|
|
1144
|
+
busy = false;
|
|
1145
|
+
}
|
|
1146
|
+
};
|
|
1147
|
+
if (signalUpdates)
|
|
1148
|
+
transaction.notifySignal = (prepare) => {
|
|
1149
|
+
if (!transaction.disposed) {
|
|
1150
|
+
revision++;
|
|
1151
|
+
signalUpdates.add(prepare);
|
|
1152
|
+
drain();
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
const refresh = () => {
|
|
1156
|
+
if (transaction.disposed) return;
|
|
1157
|
+
revision++;
|
|
1158
|
+
dirty = true;
|
|
1159
|
+
drain();
|
|
1160
|
+
};
|
|
1161
|
+
transaction.consumer = refresh;
|
|
1162
|
+
const owner = currentSignalOwner();
|
|
1163
|
+
const run = owner === null ? (callback) => callback() : captureSignalOwner(owner);
|
|
1164
|
+
refresh[NATIVE_TRANSITION_CONSUMER] = {
|
|
1165
|
+
active: () => !transaction.disposed,
|
|
1166
|
+
prepare: () => run(() => {
|
|
1167
|
+
const version = revision;
|
|
1168
|
+
const preview = {
|
|
1169
|
+
receipts: [],
|
|
1170
|
+
controls: [],
|
|
1171
|
+
fragments: /* @__PURE__ */ new Set(),
|
|
1172
|
+
signals: /* @__PURE__ */ new Map(),
|
|
1173
|
+
projections: /* @__PURE__ */ new Map(),
|
|
1174
|
+
text: /* @__PURE__ */ new Map(),
|
|
1175
|
+
disposals: []
|
|
1176
|
+
};
|
|
1177
|
+
let accepted = false;
|
|
1178
|
+
let retired = false;
|
|
1179
|
+
const discard = () => {
|
|
1180
|
+
if (accepted || retired) return;
|
|
1181
|
+
retired = true;
|
|
1182
|
+
for (const receipt of preview.receipts) receipt.discard();
|
|
1183
|
+
for (const control of preview.controls) control.discard();
|
|
1184
|
+
for (const dispose2 of preview.disposals) dispose2();
|
|
1185
|
+
for (const fragment of preview.fragments) releaseInstance(fragment, transaction);
|
|
1186
|
+
};
|
|
1187
|
+
let plan;
|
|
1188
|
+
transaction.preview = preview;
|
|
1189
|
+
const previousBusy = busy;
|
|
1190
|
+
busy = true;
|
|
1191
|
+
try {
|
|
1192
|
+
const snapshot = source.getSnapshot();
|
|
1193
|
+
if (snapshot != null && typeof snapshot.then === "function")
|
|
1194
|
+
throw new TypeError(
|
|
1195
|
+
"DOM presentation requires a synchronous snapshot, not a thenable."
|
|
1196
|
+
);
|
|
1197
|
+
plan = prepareFragment(
|
|
1198
|
+
instance,
|
|
1199
|
+
descriptor.prepareProps ? descriptor.prepareProps(snapshot) : [snapshot],
|
|
1200
|
+
transaction
|
|
1201
|
+
);
|
|
1202
|
+
} catch (error) {
|
|
1203
|
+
discard();
|
|
1204
|
+
throw error;
|
|
1205
|
+
} finally {
|
|
1206
|
+
transaction.preview = void 0;
|
|
1207
|
+
busy = previousBusy;
|
|
1208
|
+
}
|
|
1209
|
+
return {
|
|
1210
|
+
validate: () => !retired && !transaction.disposed && !busy && version === revision && preview.receipts.every((receipt) => receipt.validate()) && preview.controls.every((control) => control.validate()),
|
|
1211
|
+
discard,
|
|
1212
|
+
commit() {
|
|
1213
|
+
if (retired || accepted || transaction.disposed) return;
|
|
1214
|
+
accepted = true;
|
|
1215
|
+
busy = true;
|
|
1216
|
+
try {
|
|
1217
|
+
for (const [fragment, signals] of preview.signals) fragment.signals = signals;
|
|
1218
|
+
for (const [fragment, projections] of preview.projections)
|
|
1219
|
+
fragment.projections = projections;
|
|
1220
|
+
for (const [region, signal2] of preview.text) region.signal = signal2;
|
|
1221
|
+
for (const receipt of preview.receipts) receipt.commit();
|
|
1222
|
+
transaction.hostOperations?.publish(plan, transaction);
|
|
1223
|
+
const document = instance.range.start.ownerDocument;
|
|
1224
|
+
const tree = instance.range.start.getRootNode();
|
|
1225
|
+
transaction.focused = "activeElement" in tree ? tree.activeElement : document.activeElement;
|
|
1226
|
+
while (transaction.focused?.shadowRoot?.activeElement)
|
|
1227
|
+
transaction.focused = transaction.focused.shadowRoot.activeElement;
|
|
1228
|
+
transaction.contentEditable = !!transaction.focused?.isContentEditable;
|
|
1229
|
+
commitFragment(plan, transaction);
|
|
1230
|
+
transaction.published?.();
|
|
1231
|
+
for (const fragment of preview.fragments) transaction.candidates.delete(fragment);
|
|
1232
|
+
activateInstance(instance, transaction);
|
|
1233
|
+
} finally {
|
|
1234
|
+
busy = false;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
})
|
|
1239
|
+
};
|
|
1240
|
+
let handoff;
|
|
1241
|
+
const handle = {
|
|
1242
|
+
refresh,
|
|
1243
|
+
dispose,
|
|
1244
|
+
[BINDING_HANDOFF]() {
|
|
1245
|
+
const structural = descriptor.root.handoff === "structural" || descriptor.root.conditionalRest === true;
|
|
1246
|
+
if (structural && !mount && instance && descriptor.root.createHandoff)
|
|
1247
|
+
return handoff ??= descriptor.root.createHandoff(
|
|
1248
|
+
instance,
|
|
1249
|
+
transaction,
|
|
1250
|
+
dispose,
|
|
1251
|
+
() => !busy
|
|
1252
|
+
);
|
|
1253
|
+
if (mount || descriptor.root.handoff !== true || !instance || descriptor.root.regions.length !== 0 || descriptor.root.bindings.some((binding) => binding[1] === "control") || descriptor.root.nodes.some((node) => node[1] === "element" && node[4] === null))
|
|
1254
|
+
throw new Error(
|
|
1255
|
+
"Hydration binding leases require an adopted fixed native view without structural regions or controls."
|
|
1256
|
+
);
|
|
1257
|
+
return handoff ??= {
|
|
1258
|
+
id: descriptor.id,
|
|
1259
|
+
root: instance.range.start,
|
|
1260
|
+
anchor: instance.nodes.find((node) => node.nodeType === 1) ?? instance.range.start,
|
|
1261
|
+
active: () => !transaction.disposed,
|
|
1262
|
+
retire: (publish) => {
|
|
1263
|
+
transaction.preservePresentation = true;
|
|
1264
|
+
dispose(void 0, publish);
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
if (signal?.aborted) {
|
|
1270
|
+
dispose();
|
|
1271
|
+
return handle;
|
|
1272
|
+
}
|
|
1273
|
+
try {
|
|
1274
|
+
if (mount) {
|
|
1275
|
+
instance = createFragment(
|
|
1276
|
+
descriptor.root,
|
|
1277
|
+
descriptor.id,
|
|
1278
|
+
target.parent.ownerDocument ?? target.parent,
|
|
1279
|
+
transaction
|
|
1280
|
+
);
|
|
1281
|
+
ownedRoot = instance.range.start;
|
|
1282
|
+
programRoots.add(ownedRoot);
|
|
1283
|
+
} else {
|
|
1284
|
+
const range = rootRange(root, descriptor.id);
|
|
1285
|
+
if (programRoots.has(range.start))
|
|
1286
|
+
throw new Error(
|
|
1287
|
+
"This DOM presentation range already has a binding. Dispose it before rebinding."
|
|
1288
|
+
);
|
|
1289
|
+
ownedRoot = range.start;
|
|
1290
|
+
programRoots.add(ownedRoot);
|
|
1291
|
+
instance = resolveFragment(descriptor.root, descriptor.id, range, false, transaction);
|
|
1292
|
+
}
|
|
1293
|
+
if (signal?.aborted) {
|
|
1294
|
+
dispose();
|
|
1295
|
+
return handle;
|
|
1296
|
+
}
|
|
1297
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
1298
|
+
const stop = source.subscribe(refresh);
|
|
1299
|
+
if (typeof stop !== "function")
|
|
1300
|
+
throw new TypeError("A DOM presentation subscription must return cleanup.");
|
|
1301
|
+
if (transaction.disposed) stop();
|
|
1302
|
+
else unsubscribe = stop;
|
|
1303
|
+
busy = false;
|
|
1304
|
+
refresh();
|
|
1305
|
+
return handle;
|
|
1306
|
+
} catch (error) {
|
|
1307
|
+
try {
|
|
1308
|
+
dispose();
|
|
1309
|
+
} catch {
|
|
1310
|
+
}
|
|
1311
|
+
throw error;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
function adoptProgram(root, descriptor, source, options, list, hostOperations) {
|
|
1315
|
+
if (root.nodeType === 1 && descriptor.scalar?.id === descriptor.id && descriptor.adoptScalar) {
|
|
1316
|
+
const element = root;
|
|
1317
|
+
const previous = element.previousSibling;
|
|
1318
|
+
const marker = previous?.nodeType === 8 ? parseBindingMarker(previous.data) : null;
|
|
1319
|
+
if (marker?.kind !== "root" && element.getAttribute("data-octane-bindings") === descriptor.id)
|
|
1320
|
+
return descriptor.adoptScalar(element, descriptor.scalar, source, options);
|
|
1321
|
+
}
|
|
1322
|
+
return bindProgram(root, descriptor, source, options, false, list, hostOperations);
|
|
1323
|
+
}
|
|
1324
|
+
function __adoptLeanBindingProgram(root, descriptor, source, options) {
|
|
1325
|
+
return adoptProgram(root, descriptor, source, options);
|
|
1326
|
+
}
|
|
1327
|
+
function __mountLeanBindingProgram(target, descriptor, source, options) {
|
|
1328
|
+
return bindProgram(target, descriptor, source, options, true);
|
|
1329
|
+
}
|
|
1330
|
+
const __bindingList = { adopt: adoptList, prepare: prepareList, commit: commitList };
|
|
1331
|
+
const __bindingProgramHostOperations = {
|
|
1332
|
+
claimControl: claimProgramControl,
|
|
1333
|
+
project: projectHostValues,
|
|
1334
|
+
initial: initialValues,
|
|
1335
|
+
groups: prepareHostGroups,
|
|
1336
|
+
initialize: initializeProperties,
|
|
1337
|
+
publish: publishControls,
|
|
1338
|
+
releaseControls: releaseHostControls,
|
|
1339
|
+
releaseProjections: releaseHostProjections
|
|
1340
|
+
};
|
|
1341
|
+
const __adoptBindingProgram = /* @__PURE__ */ Object.assign(
|
|
1342
|
+
function __adoptBindingProgram2(root, descriptor, source, options) {
|
|
1343
|
+
return adoptProgram(
|
|
1344
|
+
root,
|
|
1345
|
+
descriptor,
|
|
1346
|
+
source,
|
|
1347
|
+
options,
|
|
1348
|
+
__bindingList,
|
|
1349
|
+
__bindingProgramHostOperations
|
|
1350
|
+
);
|
|
1351
|
+
},
|
|
1352
|
+
{ list: __bindingList, hostOperations: __bindingProgramHostOperations }
|
|
1353
|
+
);
|
|
1354
|
+
function __mountBindingProgram(target, descriptor, source, options) {
|
|
1355
|
+
return bindProgram(
|
|
1356
|
+
target,
|
|
1357
|
+
descriptor,
|
|
1358
|
+
source,
|
|
1359
|
+
options,
|
|
1360
|
+
true,
|
|
1361
|
+
__bindingList,
|
|
1362
|
+
__bindingProgramHostOperations
|
|
1363
|
+
);
|
|
1364
|
+
}
|
|
1365
|
+
function adoptList(region, id, transaction) {
|
|
1366
|
+
const definition = region.definition;
|
|
1367
|
+
const range = region.range;
|
|
1368
|
+
if (region.arm === 0) {
|
|
1369
|
+
if (definition.empty)
|
|
1370
|
+
region.child = resolveFragment(definition.empty, id, range, false, transaction);
|
|
1371
|
+
else if (range.start.nextSibling !== range.end) mismatch();
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
region.items = /* @__PURE__ */ new Map();
|
|
1375
|
+
let cursor = range.start.nextSibling;
|
|
1376
|
+
while (cursor !== range.end) {
|
|
1377
|
+
const itemRange = rangeAt(cursor, range.end);
|
|
1378
|
+
const marker = parseBindingMarker(itemRange.start.data);
|
|
1379
|
+
if (marker?.id !== id || marker.site !== region.site || marker.kind !== "item" || region.items.has(marker.key))
|
|
1380
|
+
mismatch();
|
|
1381
|
+
region.items.set(
|
|
1382
|
+
marker.key,
|
|
1383
|
+
resolveFragment(definition.item, id, itemRange, false, transaction)
|
|
1384
|
+
);
|
|
1385
|
+
cursor = itemRange.end.nextSibling;
|
|
1386
|
+
}
|
|
1387
|
+
if (region.items.size === 0) mismatch();
|
|
1388
|
+
}
|
|
1389
|
+
function prepareList(instance, region, candidate, environment, document, transaction) {
|
|
1390
|
+
const descriptor = region.definition;
|
|
1391
|
+
const input = descriptor.items(environment);
|
|
1392
|
+
if (input == null || typeof input[Symbol.iterator] !== "function")
|
|
1393
|
+
throw new TypeError("A DOM presentation list requires a synchronous iterable.");
|
|
1394
|
+
const items = Array.from(input);
|
|
1395
|
+
const keys = items.map(
|
|
1396
|
+
(item, index) => encodeBindingKey(descriptor.key(item, index, environment))
|
|
1397
|
+
);
|
|
1398
|
+
if (new Set(keys).size !== keys.length)
|
|
1399
|
+
throw new Error("A DOM presentation list cannot contain duplicate keys.");
|
|
1400
|
+
candidate.arm = items.length === 0 ? 0 : 1;
|
|
1401
|
+
if (items.length === 0) {
|
|
1402
|
+
if (descriptor.empty)
|
|
1403
|
+
candidate.child = prepareFragment(
|
|
1404
|
+
region.arm === 0 && region.child ? region.child : createFragment(descriptor.empty, instance.id, document, transaction),
|
|
1405
|
+
environment,
|
|
1406
|
+
transaction
|
|
1407
|
+
);
|
|
1408
|
+
} else {
|
|
1409
|
+
candidate.items = /* @__PURE__ */ new Map();
|
|
1410
|
+
for (let index = 0; index < items.length; index++) {
|
|
1411
|
+
const key = keys[index];
|
|
1412
|
+
const child = region.items?.get(key) ?? createFragment(descriptor.item, instance.id, document, transaction);
|
|
1413
|
+
candidate.items.set(
|
|
1414
|
+
key,
|
|
1415
|
+
prepareFragment(child, [...environment, items[index], index], transaction)
|
|
1416
|
+
);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
function commitList(plan, id, transaction) {
|
|
1421
|
+
const region = plan.instance;
|
|
1422
|
+
const oldChild = region.child;
|
|
1423
|
+
const oldItems = region.items;
|
|
1424
|
+
const child = plan.child?.instance ?? null;
|
|
1425
|
+
const items = plan.items ? new Map([...plan.items].map(([key, item]) => [key, item.instance])) : null;
|
|
1426
|
+
region.child = child;
|
|
1427
|
+
region.items = items;
|
|
1428
|
+
region.arm = plan.arm;
|
|
1429
|
+
if (oldChild && oldChild !== child) {
|
|
1430
|
+
releaseInstance(oldChild, transaction);
|
|
1431
|
+
if (transaction.disposed) return;
|
|
1432
|
+
removeRange(region.range, true, transaction);
|
|
1433
|
+
}
|
|
1434
|
+
if (oldItems)
|
|
1435
|
+
for (const [key, item] of oldItems) {
|
|
1436
|
+
if (items?.get(key) === item) continue;
|
|
1437
|
+
releaseInstance(item, transaction);
|
|
1438
|
+
if (transaction.disposed) return;
|
|
1439
|
+
removeRange(item.range, false, transaction);
|
|
1440
|
+
}
|
|
1441
|
+
if (plan.child) {
|
|
1442
|
+
commitFragment(plan.child, transaction);
|
|
1443
|
+
if (transaction.disposed) return;
|
|
1444
|
+
if (child !== oldChild) insertBody(child, region.range, false, transaction);
|
|
1445
|
+
} else if (plan.items) {
|
|
1446
|
+
for (const item of plan.items.values()) {
|
|
1447
|
+
commitFragment(item, transaction);
|
|
1448
|
+
if (transaction.disposed) return;
|
|
1449
|
+
}
|
|
1450
|
+
let anchor = region.range.end;
|
|
1451
|
+
for (const [key, item] of [...plan.items].reverse()) {
|
|
1452
|
+
item.instance.range.start.data = `[b;${id};${region.site};k;${key}`;
|
|
1453
|
+
moveRange(item.instance.range, region.range.end.parentNode, anchor, transaction);
|
|
1454
|
+
if (transaction.disposed) return;
|
|
1455
|
+
anchor = item.instance.range.start;
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
region.range.start.data = `[f${plan.arm};b;${id};${region.site}`;
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
function claimProgramControl(instance, index, node, transaction) {
|
|
1462
|
+
if (!transaction.controls)
|
|
1463
|
+
throw new TypeError("A DOM control binding requires its compiler-selected adapter.");
|
|
1464
|
+
const prepare = () => {
|
|
1465
|
+
if (instance.disposed || transaction.preparing && instance.signalFrame !== transaction.frame)
|
|
1466
|
+
return () => {
|
|
1467
|
+
};
|
|
1468
|
+
const prepared = instance.controls.get(index).prepareCurrent();
|
|
1469
|
+
prepared.publish();
|
|
1470
|
+
if (transaction.preparing && instance.signalPlan) {
|
|
1471
|
+
instance.signalPlan.controls.set(index, prepared);
|
|
1472
|
+
return () => {
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
return prepared.commit;
|
|
1476
|
+
};
|
|
1477
|
+
(instance.controls ??= /* @__PURE__ */ new Map()).set(
|
|
1478
|
+
index,
|
|
1479
|
+
transaction.controls.claim(
|
|
1480
|
+
node,
|
|
1481
|
+
instance.definition.bindings[index][2],
|
|
1482
|
+
forwardNativeTransitionConsumer(
|
|
1483
|
+
transaction.consumer,
|
|
1484
|
+
() => transaction.notifySignal(prepare)
|
|
1485
|
+
)
|
|
1486
|
+
)
|
|
1487
|
+
);
|
|
1488
|
+
}
|
|
1489
|
+
function projectHostValues(values, instance, transaction) {
|
|
1490
|
+
const operations = instance.definition.bindings;
|
|
1491
|
+
if (transaction.projections && instance.definition.projectionGroups) {
|
|
1492
|
+
values = [...values];
|
|
1493
|
+
for (const group of instance.definition.projectionGroups) {
|
|
1494
|
+
requireActive(transaction);
|
|
1495
|
+
const first = group[0][0];
|
|
1496
|
+
let connection = (transaction.preview?.projections.get(instance) ?? instance.projections)?.get(first);
|
|
1497
|
+
if (!connection) {
|
|
1498
|
+
const prepare = () => {
|
|
1499
|
+
if (instance.disposed || transaction.preparing && instance.signalFrame !== transaction.frame)
|
|
1500
|
+
return () => {
|
|
1501
|
+
};
|
|
1502
|
+
const projected2 = connection.get();
|
|
1503
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1504
|
+
for (const [index] of group) {
|
|
1505
|
+
const classGroup = instance.groups.get(index)?.prepare(projected2[index] ?? "");
|
|
1506
|
+
if (classGroup) groups.set(index, classGroup);
|
|
1507
|
+
}
|
|
1508
|
+
if (transaction.preparing && instance.signalPlan) {
|
|
1509
|
+
for (const [index] of group) {
|
|
1510
|
+
instance.signalPlan.values[index] = projected2[index];
|
|
1511
|
+
const classGroup = groups.get(index);
|
|
1512
|
+
if (classGroup) instance.signalPlan.groups.set(index, classGroup);
|
|
1513
|
+
}
|
|
1514
|
+
return () => {
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
return () => {
|
|
1518
|
+
for (const [index] of group)
|
|
1519
|
+
writeOperation(instance, index, projected2[index], groups.get(index), transaction);
|
|
1520
|
+
};
|
|
1521
|
+
};
|
|
1522
|
+
connection = transaction.projections.connect(
|
|
1523
|
+
group,
|
|
1524
|
+
operations,
|
|
1525
|
+
instance.nodes,
|
|
1526
|
+
forwardNativeTransitionConsumer(
|
|
1527
|
+
transaction.consumer,
|
|
1528
|
+
() => transaction.notifySignal(prepare)
|
|
1529
|
+
),
|
|
1530
|
+
transaction.restoreStyles
|
|
1531
|
+
);
|
|
1532
|
+
if (transaction.preview) {
|
|
1533
|
+
let projections = transaction.preview.projections.get(instance);
|
|
1534
|
+
if (!projections)
|
|
1535
|
+
transaction.preview.projections.set(
|
|
1536
|
+
instance,
|
|
1537
|
+
projections = new Map(instance.projections)
|
|
1538
|
+
);
|
|
1539
|
+
for (const [index] of group) projections.set(index, connection);
|
|
1540
|
+
const created = connection;
|
|
1541
|
+
transaction.preview.disposals.push(() => created.dispose(true));
|
|
1542
|
+
} else {
|
|
1543
|
+
instance.projections ??= /* @__PURE__ */ new Map();
|
|
1544
|
+
for (const [index] of group) instance.projections.set(index, connection);
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
const receipt = transaction.preview ? connection.preview(values[first]) : void 0;
|
|
1548
|
+
if (receipt) transaction.preview.receipts.push(receipt);
|
|
1549
|
+
const projected = receipt ? receipt.value : connection.read(values[first]);
|
|
1550
|
+
for (const [index] of group) values[index] = projected[index];
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
return values;
|
|
1554
|
+
}
|
|
1555
|
+
function prepareHostGroups(plan) {
|
|
1556
|
+
const instance = plan.instance;
|
|
1557
|
+
const definition = instance.definition;
|
|
1558
|
+
for (let index = 0; index < definition.bindings.length; index++) {
|
|
1559
|
+
const operation = definition.bindings[index];
|
|
1560
|
+
if (operation[1] !== "classGroup") continue;
|
|
1561
|
+
let group = instance.groups.get(index);
|
|
1562
|
+
if (!group) {
|
|
1563
|
+
const receipt = definition.initializers?.findIndex(
|
|
1564
|
+
(initializer) => initializer[0] === operation[0] && initializer[1] === "classGroupInitial" && initializer[2] === operation[2]
|
|
1565
|
+
);
|
|
1566
|
+
if (receipt === void 0 || receipt < 0 || typeof plan.initial?.[receipt] !== "string")
|
|
1567
|
+
throw new Error("A constructible class group requires its compiler baseline initializer.");
|
|
1568
|
+
group = definition.createClassGroup(
|
|
1569
|
+
instance.nodes[operation[0]],
|
|
1570
|
+
operation[2],
|
|
1571
|
+
operation[3],
|
|
1572
|
+
plan.initial[receipt]
|
|
1573
|
+
);
|
|
1574
|
+
instance.groups.set(index, group);
|
|
1575
|
+
}
|
|
1576
|
+
plan.groups.set(index, group.prepare(plan.values[index] ?? ""));
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
function releaseHostControls(instance, attempt) {
|
|
1580
|
+
for (const control of instance.controls?.values() ?? []) attempt(() => control.dispose());
|
|
1581
|
+
instance.controls?.clear();
|
|
1582
|
+
}
|
|
1583
|
+
function releaseHostProjections(instance, transaction, attempt) {
|
|
1584
|
+
for (const connection of instance.projections ? new Set(instance.projections.values()) : [])
|
|
1585
|
+
attempt(() => connection.dispose(transaction.preservePresentation));
|
|
1586
|
+
instance.projections?.clear();
|
|
1587
|
+
}
|
|
1588
|
+
const __adoptSelectedBindingProgram = /* @__PURE__ */ Object.assign(
|
|
1589
|
+
function __adoptSelectedBindingProgram2(root, descriptor, source, options) {
|
|
1590
|
+
return adoptProgram(
|
|
1591
|
+
root,
|
|
1592
|
+
descriptor,
|
|
1593
|
+
source,
|
|
1594
|
+
options,
|
|
1595
|
+
descriptor.list,
|
|
1596
|
+
__bindingProgramHostOperations
|
|
1597
|
+
);
|
|
1598
|
+
},
|
|
1599
|
+
{ hostOperations: __bindingProgramHostOperations }
|
|
1600
|
+
);
|
|
1601
|
+
function __mountSelectedBindingProgram(target, descriptor, source, options) {
|
|
1602
|
+
return bindProgram(
|
|
1603
|
+
target,
|
|
1604
|
+
descriptor,
|
|
1605
|
+
source,
|
|
1606
|
+
options,
|
|
1607
|
+
true,
|
|
1608
|
+
descriptor.list,
|
|
1609
|
+
__bindingProgramHostOperations
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1612
|
+
export {
|
|
1613
|
+
__activateBindingAdapters,
|
|
1614
|
+
__adoptBindingProgram,
|
|
1615
|
+
__adoptLeanBindingProgram,
|
|
1616
|
+
__adoptSelectedBindingProgram,
|
|
1617
|
+
__bindingList,
|
|
1618
|
+
__bindingProgramHostOperations,
|
|
1619
|
+
__bindingSlot,
|
|
1620
|
+
__createStructuralBindingHandoff,
|
|
1621
|
+
__methodDep,
|
|
1622
|
+
__mountBindingProgram,
|
|
1623
|
+
__mountLeanBindingProgram,
|
|
1624
|
+
__mountSelectedBindingProgram
|
|
1625
|
+
};
|