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,700 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var dom_bindings_exports = {};
|
|
20
|
+
__export(dom_bindings_exports, {
|
|
21
|
+
__adoptBindings: () => __adoptBindings,
|
|
22
|
+
__claimBinding: () => __claimBinding,
|
|
23
|
+
__createBindingStyleRestoration: () => __createBindingStyleRestoration,
|
|
24
|
+
__mountBindings: () => __mountBindings,
|
|
25
|
+
__normalizeBinding: () => normalize,
|
|
26
|
+
__releaseBinding: () => __releaseBinding,
|
|
27
|
+
__writeBinding: () => write,
|
|
28
|
+
adoptBindings: () => adoptBindings,
|
|
29
|
+
mountBindings: () => mountBindings,
|
|
30
|
+
unbound: () => unbound
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(dom_bindings_exports);
|
|
33
|
+
var import_class_names = require("./class-names.cjs");
|
|
34
|
+
var import_sanitize_url = require("./sanitize-url.cjs");
|
|
35
|
+
var import_owner_context = require("./signals/owner-context.cjs");
|
|
36
|
+
var import_read_protocol = require("./signals/read-protocol.cjs");
|
|
37
|
+
function unbound(value) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function adoptBindings(_root, _view, _source, _options) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"adoptBindings() requires an Octane-compiled .tsrx or .tsx call and a supported static view."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function mountBindings(_target, _view, _source, _options) {
|
|
46
|
+
throw new Error("mountBindings() requires an Octane-compiled .tsrx or .tsx call.");
|
|
47
|
+
}
|
|
48
|
+
function __mountBindings(target, descriptor, source, options) {
|
|
49
|
+
return descriptor.mount(target, descriptor, source, options);
|
|
50
|
+
}
|
|
51
|
+
const claims = /* @__PURE__ */ new WeakMap();
|
|
52
|
+
const namespaces = ["http://www.w3.org/1999/xhtml", "http://www.w3.org/2000/svg"];
|
|
53
|
+
function channel(binding) {
|
|
54
|
+
return binding[1] === "styleProperty" ? `style:${binding[2]}` : binding[1] === "classToken" ? `class:${binding[2]}` : binding[1] === "classGroup" ? `classGroup:${binding[2]}:${binding[3]}` : binding[2];
|
|
55
|
+
}
|
|
56
|
+
function conflicts(channels, binding, name) {
|
|
57
|
+
if (channels.has(name)) return true;
|
|
58
|
+
if (binding[1] === "styleProperty" && channels.has("style")) return true;
|
|
59
|
+
if (name === "style") {
|
|
60
|
+
for (const claimed of channels) if (claimed.startsWith("style:")) return true;
|
|
61
|
+
}
|
|
62
|
+
if (binding[1] === "classToken") {
|
|
63
|
+
if (channels.has("class")) return true;
|
|
64
|
+
for (const claimed of channels) if (claimed.startsWith("classGroup:")) return true;
|
|
65
|
+
}
|
|
66
|
+
if (binding[1] === "classGroup") {
|
|
67
|
+
if (channels.has("class")) return true;
|
|
68
|
+
for (const claimed of channels) if (claimed.startsWith("class:")) return true;
|
|
69
|
+
}
|
|
70
|
+
if (name === "class") {
|
|
71
|
+
for (const claimed of channels)
|
|
72
|
+
if (claimed.startsWith("class:") || claimed.startsWith("classGroup:")) return true;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
function __claimBinding(node, binding) {
|
|
77
|
+
if (binding[1] === "classToken" && !/^\S+$/.test(binding[2]))
|
|
78
|
+
throw new TypeError("A DOM class token binding requires one nonempty class token.");
|
|
79
|
+
const name = channel(binding);
|
|
80
|
+
let channels = claims.get(node);
|
|
81
|
+
if (channels !== void 0 && conflicts(channels, binding, name))
|
|
82
|
+
throw new Error("This DOM property already has a binding. Dispose it before rebinding.");
|
|
83
|
+
if (channels === void 0) claims.set(node, channels = /* @__PURE__ */ new Set());
|
|
84
|
+
channels.add(name);
|
|
85
|
+
return name;
|
|
86
|
+
}
|
|
87
|
+
function __releaseBinding(node, name) {
|
|
88
|
+
const channels = claims.get(node);
|
|
89
|
+
channels.delete(name);
|
|
90
|
+
if (channels.size === 0) claims.delete(node);
|
|
91
|
+
}
|
|
92
|
+
function resolveNodes(root, descriptor) {
|
|
93
|
+
if (root?.nodeType !== 1 || root.getAttribute("data-octane-bindings") !== descriptor.id || descriptor.nodes.length === 0) {
|
|
94
|
+
throw new Error("DOM bindings require the matching compiler-stamped root.");
|
|
95
|
+
}
|
|
96
|
+
if (descriptor.addressed) return resolveAddressedNodes(root, descriptor);
|
|
97
|
+
const nodes = [];
|
|
98
|
+
const childIndices = [];
|
|
99
|
+
for (let i = 0; i < descriptor.nodes.length; i++) {
|
|
100
|
+
const [parent, tag, namespace, children] = descriptor.nodes[i];
|
|
101
|
+
const node = i === 0 ? parent === -1 ? root : void 0 : parent >= 0 && parent < i && descriptor.nodes[parent][3] !== null ? nodes[parent]?.children[childIndices[parent]++] : void 0;
|
|
102
|
+
if (node === void 0 || descriptor.nodes[i][4] === true || node.localName !== tag || node.namespaceURI !== namespaces[namespace] || children !== null && (node.childNodes.length !== children || node.children.length !== children)) {
|
|
103
|
+
throw new Error("DOM bindings cannot adopt a mismatched static element topology.");
|
|
104
|
+
}
|
|
105
|
+
nodes.push(node);
|
|
106
|
+
childIndices.push(0);
|
|
107
|
+
}
|
|
108
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
109
|
+
if (childIndices[i] !== (descriptor.nodes[i][3] ?? 0)) {
|
|
110
|
+
throw new Error("DOM bindings cannot adopt an incomplete static element topology.");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return nodes;
|
|
114
|
+
}
|
|
115
|
+
function resolveAddressedNodes(root, descriptor) {
|
|
116
|
+
const nodes = [];
|
|
117
|
+
const prefix = `${descriptor.id}:`;
|
|
118
|
+
let current = root;
|
|
119
|
+
while (current !== null) {
|
|
120
|
+
let descend = current === root || !current.hasAttribute("data-octane-bindings");
|
|
121
|
+
if (descend) {
|
|
122
|
+
const marker = current.getAttribute("data-octane-binding-node");
|
|
123
|
+
if (marker?.startsWith(prefix)) {
|
|
124
|
+
const index = Number(marker.slice(prefix.length));
|
|
125
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= descriptor.nodes.length || marker !== `${prefix}${index}` || nodes[index] !== void 0) {
|
|
126
|
+
throw new Error("DOM bindings require unique compiler-issued target addresses.");
|
|
127
|
+
}
|
|
128
|
+
nodes[index] = current;
|
|
129
|
+
if (descriptor.nodes[index][3] === null) descend = false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (descend && current.firstElementChild !== null) {
|
|
133
|
+
current = current.firstElementChild;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
while (current !== root && current.nextElementSibling === null)
|
|
137
|
+
current = current.parentElement;
|
|
138
|
+
if (current === root) break;
|
|
139
|
+
current = current.nextElementSibling;
|
|
140
|
+
}
|
|
141
|
+
const childCounts = new Array(descriptor.nodes.length).fill(0);
|
|
142
|
+
for (let i = 0; i < descriptor.nodes.length; i++) {
|
|
143
|
+
const [parent, tag, namespace, children, openChildren] = descriptor.nodes[i];
|
|
144
|
+
const node = nodes[i];
|
|
145
|
+
if (node === void 0 || node.localName !== tag || node.namespaceURI !== namespaces[namespace] || (i === 0 ? parent !== -1 || node !== root : parent < 0 || parent >= i || descriptor.nodes[parent][3] === null || node.parentElement !== nodes[parent] || descriptor.nodes[parent][4] !== true && nodes[parent].children[childCounts[parent]] !== node) || openChildren && children === null || children !== null && !openChildren && (node.childNodes.length !== children || node.children.length !== children)) {
|
|
146
|
+
throw new Error("DOM bindings cannot adopt a mismatched addressed element topology.");
|
|
147
|
+
}
|
|
148
|
+
if (parent !== -1) childCounts[parent]++;
|
|
149
|
+
}
|
|
150
|
+
for (let i = 0; i < descriptor.nodes.length; i++) {
|
|
151
|
+
if (childCounts[i] !== (descriptor.nodes[i][3] ?? 0)) {
|
|
152
|
+
throw new Error("DOM bindings cannot adopt an incomplete addressed element topology.");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return nodes;
|
|
156
|
+
}
|
|
157
|
+
function normalize(binding, value) {
|
|
158
|
+
const type = typeof value;
|
|
159
|
+
switch (binding[1]) {
|
|
160
|
+
case "styleObject":
|
|
161
|
+
return value;
|
|
162
|
+
case "class":
|
|
163
|
+
return value == null || value === false ? null : (0, import_class_names.normalizeClass)(value);
|
|
164
|
+
case "classGroup":
|
|
165
|
+
return value == null || value === false ? "" : (0, import_class_names.normalizeClass)(value);
|
|
166
|
+
case "styleAttribute":
|
|
167
|
+
if (value == null || value === false || value === "") return null;
|
|
168
|
+
if (type !== "string")
|
|
169
|
+
throw new TypeError("A whole-style DOM binding requires serialized CSS text or null.");
|
|
170
|
+
return value;
|
|
171
|
+
case "classToken":
|
|
172
|
+
return value ? "" : null;
|
|
173
|
+
case "url":
|
|
174
|
+
return value == null || type === "boolean" || type === "function" || type === "symbol" ? null : (0, import_sanitize_url.sanitizeURL)(String(value));
|
|
175
|
+
case "boolean":
|
|
176
|
+
return !value || type === "function" || type === "symbol" ? null : "";
|
|
177
|
+
case "styleProperty": {
|
|
178
|
+
if (value == null || type === "boolean") return null;
|
|
179
|
+
return type === "number" && value !== 0 && !binding[3] ? value + "px" : type === "string" ? value.trim() : "" + value;
|
|
180
|
+
}
|
|
181
|
+
default:
|
|
182
|
+
return value == null || type === "function" || type === "symbol" || binding[1] === "attr" && type === "boolean" ? null : String(value);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function write(node, binding, value) {
|
|
186
|
+
const name = binding[2];
|
|
187
|
+
if (binding[1] === "classToken") {
|
|
188
|
+
node.classList.toggle(name, value !== null);
|
|
189
|
+
} else if (binding[1] === "url") {
|
|
190
|
+
if (value === "" && !(name === "href" && node.localName === "a")) value = null;
|
|
191
|
+
if (name === "xlink:href") {
|
|
192
|
+
if (value === null) node.removeAttributeNS("http://www.w3.org/1999/xlink", "href");
|
|
193
|
+
else if (node.getAttributeNS("http://www.w3.org/1999/xlink", "href") !== value)
|
|
194
|
+
node.setAttributeNS("http://www.w3.org/1999/xlink", name, value);
|
|
195
|
+
} else if (value === null) {
|
|
196
|
+
if (node.hasAttribute(name)) node.removeAttribute(name);
|
|
197
|
+
} else if (node.getAttribute(name) !== value) node.setAttribute(name, value);
|
|
198
|
+
} else if (binding[1] === "styleProperty") {
|
|
199
|
+
const style = node.style;
|
|
200
|
+
if (value === null) {
|
|
201
|
+
style.removeProperty(name);
|
|
202
|
+
} else {
|
|
203
|
+
const tail = value.trimEnd();
|
|
204
|
+
const important = tail.endsWith("!important");
|
|
205
|
+
const text = important ? tail.slice(0, -10).trimEnd() : value;
|
|
206
|
+
const priority = important ? "important" : "";
|
|
207
|
+
if (style.getPropertyValue(name) !== text || style.getPropertyPriority(name) !== priority)
|
|
208
|
+
style.setProperty(name, text, priority);
|
|
209
|
+
}
|
|
210
|
+
} else if (value === null) {
|
|
211
|
+
if (node.hasAttribute(name)) node.removeAttribute(name);
|
|
212
|
+
} else if (node.getAttribute(name) !== value) {
|
|
213
|
+
node.setAttribute(name, value);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function __createBindingStyleRestoration(node, binding) {
|
|
217
|
+
if (binding[1] === "styleAttribute") {
|
|
218
|
+
let baseline2;
|
|
219
|
+
let expected2;
|
|
220
|
+
let disposed2 = false;
|
|
221
|
+
return {
|
|
222
|
+
write(value) {
|
|
223
|
+
if (disposed2) return;
|
|
224
|
+
if (baseline2 === void 0) baseline2 = node.getAttribute("style");
|
|
225
|
+
expected2 = value;
|
|
226
|
+
write(node, binding, value);
|
|
227
|
+
},
|
|
228
|
+
dispose(preservePresentation) {
|
|
229
|
+
if (disposed2) return;
|
|
230
|
+
disposed2 = true;
|
|
231
|
+
if (!preservePresentation && baseline2 !== void 0 && node.getAttribute("style") === expected2)
|
|
232
|
+
write(node, binding, baseline2);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
const style = node.style;
|
|
237
|
+
const name = binding[2];
|
|
238
|
+
let baseline;
|
|
239
|
+
let expected;
|
|
240
|
+
let probe;
|
|
241
|
+
let disposed = false;
|
|
242
|
+
return {
|
|
243
|
+
write(value) {
|
|
244
|
+
if (disposed) return;
|
|
245
|
+
baseline ??= [style.getPropertyValue(name), style.getPropertyPriority(name)];
|
|
246
|
+
probe ??= node.ownerDocument.createElement("i");
|
|
247
|
+
probe.style.cssText = "";
|
|
248
|
+
probe.style.setProperty(name, style.getPropertyValue(name), style.getPropertyPriority(name));
|
|
249
|
+
write(probe, binding, value);
|
|
250
|
+
expected = [probe.style.getPropertyValue(name), probe.style.getPropertyPriority(name)];
|
|
251
|
+
write(node, binding, value);
|
|
252
|
+
},
|
|
253
|
+
dispose(preservePresentation) {
|
|
254
|
+
if (disposed) return;
|
|
255
|
+
disposed = true;
|
|
256
|
+
if (!preservePresentation && baseline && expected && style.getPropertyValue(name) === expected[0] && style.getPropertyPriority(name) === expected[1]) {
|
|
257
|
+
if (baseline[0] === "") style.removeProperty(name);
|
|
258
|
+
else style.setProperty(name, baseline[0], baseline[1]);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function __adoptBindings(root, descriptor, source, options) {
|
|
264
|
+
if ("root" in descriptor) return descriptor.adopt(root, descriptor, source, options);
|
|
265
|
+
if (!source || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function")
|
|
266
|
+
throw new TypeError("DOM bindings require synchronous getSnapshot() and subscribe() methods.");
|
|
267
|
+
const nodes = resolveNodes(root, descriptor);
|
|
268
|
+
const bindings = descriptor.bindings;
|
|
269
|
+
const owned = [];
|
|
270
|
+
const previous = [];
|
|
271
|
+
let groups;
|
|
272
|
+
let styles;
|
|
273
|
+
const signalFactory = descriptor.connectSignal?.();
|
|
274
|
+
const styleFactory = descriptor.connectStyle?.();
|
|
275
|
+
const projectionFactory = descriptor.connectProjection?.();
|
|
276
|
+
const projections = projectionFactory ? /* @__PURE__ */ new Map() : void 0;
|
|
277
|
+
const controlFactory = descriptor.createControls?.();
|
|
278
|
+
const controls = controlFactory ? /* @__PURE__ */ new Map() : void 0;
|
|
279
|
+
const signalConnections = signalFactory || styleFactory ? /* @__PURE__ */ new Map() : void 0;
|
|
280
|
+
const signalUpdates = signalFactory || styleFactory || projectionFactory || controlFactory ? /* @__PURE__ */ new Set() : void 0;
|
|
281
|
+
let disposed = false;
|
|
282
|
+
let busy = true;
|
|
283
|
+
let dirty = false;
|
|
284
|
+
let revision = 0;
|
|
285
|
+
let unsubscribe;
|
|
286
|
+
const signal = options?.signal;
|
|
287
|
+
const dispose = () => {
|
|
288
|
+
if (disposed) return;
|
|
289
|
+
disposed = true;
|
|
290
|
+
signal?.removeEventListener("abort", dispose);
|
|
291
|
+
let failed = false;
|
|
292
|
+
let failure;
|
|
293
|
+
for (const connection of signalConnections?.values() ?? []) {
|
|
294
|
+
try {
|
|
295
|
+
connection.dispose();
|
|
296
|
+
} catch (error) {
|
|
297
|
+
if (!failed) {
|
|
298
|
+
failed = true;
|
|
299
|
+
failure = error;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
for (const connection of projections ? new Set(projections.values()) : []) {
|
|
304
|
+
try {
|
|
305
|
+
connection.dispose();
|
|
306
|
+
} catch (error) {
|
|
307
|
+
if (!failed) {
|
|
308
|
+
failed = true;
|
|
309
|
+
failure = error;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
projections?.clear();
|
|
314
|
+
for (const control of controls?.values() ?? []) {
|
|
315
|
+
try {
|
|
316
|
+
control.dispose();
|
|
317
|
+
} catch (error) {
|
|
318
|
+
if (!failed) {
|
|
319
|
+
failed = true;
|
|
320
|
+
failure = error;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
controls?.clear();
|
|
325
|
+
signalConnections?.clear();
|
|
326
|
+
signalUpdates?.clear();
|
|
327
|
+
for (let i = 0; i < owned.length; i++) {
|
|
328
|
+
const [node, name] = owned[i];
|
|
329
|
+
try {
|
|
330
|
+
groups?.get(i)?.dispose();
|
|
331
|
+
styles?.get(i)?.dispose();
|
|
332
|
+
if (bindings[i][1] === "classToken" && previous[i] === "")
|
|
333
|
+
node.classList.remove(bindings[i][2]);
|
|
334
|
+
} catch (error) {
|
|
335
|
+
if (!failed) {
|
|
336
|
+
failed = true;
|
|
337
|
+
failure = error;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
__releaseBinding(node, name);
|
|
341
|
+
}
|
|
342
|
+
owned.length = nodes.length = previous.length = 0;
|
|
343
|
+
groups?.clear();
|
|
344
|
+
styles?.clear();
|
|
345
|
+
const stop = unsubscribe;
|
|
346
|
+
unsubscribe = void 0;
|
|
347
|
+
try {
|
|
348
|
+
stop?.();
|
|
349
|
+
} catch (error) {
|
|
350
|
+
if (!failed) throw error;
|
|
351
|
+
}
|
|
352
|
+
if (failed) throw failure;
|
|
353
|
+
};
|
|
354
|
+
const prepareProjection = projections ? (index, next, indices) => {
|
|
355
|
+
const projection = projections.get(index);
|
|
356
|
+
if (!projection) return;
|
|
357
|
+
if (index === projection.group[0][0]) {
|
|
358
|
+
const values = projection.get();
|
|
359
|
+
for (const [fieldIndex] of projection.group) {
|
|
360
|
+
next[fieldIndex] = values[fieldIndex];
|
|
361
|
+
if (indices && !indices.includes(fieldIndex)) indices.push(fieldIndex);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return projection.group;
|
|
365
|
+
} : void 0;
|
|
366
|
+
const writePrepared = (next, indices, preparedControls, preparedGroups) => {
|
|
367
|
+
for (let position = 0; position < (indices?.length ?? bindings.length) && !dirty && !disposed; position++) {
|
|
368
|
+
const i = indices ? indices[position] : position;
|
|
369
|
+
if (bindings[i][1] === "control") {
|
|
370
|
+
preparedControls.get(i).commit();
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (next[i] === previous[i]) continue;
|
|
374
|
+
const binding = bindings[i];
|
|
375
|
+
if (binding[1] === "classToken") previous[i] = next[i];
|
|
376
|
+
if (binding[1] === "styleObject") {
|
|
377
|
+
const projection = projections?.get(i);
|
|
378
|
+
if (projection) projection.writeStyle(i, next[i]);
|
|
379
|
+
else signalConnections.get(i).write(next[i]);
|
|
380
|
+
} else if (binding[1] === "classGroup") preparedGroups.get(i).commit();
|
|
381
|
+
else if ((binding[1] === "styleProperty" || binding[1] === "styleAttribute") && options?.restoreStyles) {
|
|
382
|
+
styles ??= /* @__PURE__ */ new Map();
|
|
383
|
+
let style = styles.get(i);
|
|
384
|
+
if (!style)
|
|
385
|
+
styles.set(i, style = __createBindingStyleRestoration(nodes[binding[0]], binding));
|
|
386
|
+
style.write(next[i]);
|
|
387
|
+
} else write(nodes[binding[0]], binding, next[i]);
|
|
388
|
+
if (!disposed) previous[i] = next[i];
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
const drain = (preview = false) => {
|
|
392
|
+
if (disposed) return;
|
|
393
|
+
if (busy) return preview ? { validate: () => false, commit() {
|
|
394
|
+
}, discard() {
|
|
395
|
+
} } : void 0;
|
|
396
|
+
const version = revision;
|
|
397
|
+
const previousDirty = dirty;
|
|
398
|
+
const previousUpdates = preview && signalUpdates ? [...signalUpdates] : void 0;
|
|
399
|
+
const preparedSignals = preview && signalConnections ? new Map(signalConnections) : signalConnections;
|
|
400
|
+
const preparedProjections = preview && projections ? new Map(projections) : projections;
|
|
401
|
+
const receipts = preview ? [] : void 0;
|
|
402
|
+
const controlReceipts = preview ? [] : void 0;
|
|
403
|
+
let accepted = false;
|
|
404
|
+
let retired = false;
|
|
405
|
+
const discard = preview ? () => {
|
|
406
|
+
if (accepted || retired) return;
|
|
407
|
+
retired = true;
|
|
408
|
+
for (const receipt of receipts) receipt.discard();
|
|
409
|
+
for (const control of controlReceipts) control.discard();
|
|
410
|
+
for (const [index, connection] of preparedSignals ?? [])
|
|
411
|
+
if (connection !== signalConnections?.get(index)) connection.dispose(true);
|
|
412
|
+
for (const [index, connection] of preparedProjections ?? [])
|
|
413
|
+
if (connection !== projections?.get(index)) connection.dispose(true);
|
|
414
|
+
} : void 0;
|
|
415
|
+
if (preview) dirty = true;
|
|
416
|
+
busy = true;
|
|
417
|
+
try {
|
|
418
|
+
while ((dirty || signalUpdates?.size) && !disposed) {
|
|
419
|
+
let next;
|
|
420
|
+
let indices;
|
|
421
|
+
const preparedControls = controls ? /* @__PURE__ */ new Map() : void 0;
|
|
422
|
+
if (dirty) {
|
|
423
|
+
dirty = false;
|
|
424
|
+
signalUpdates?.clear();
|
|
425
|
+
const snapshot = source.getSnapshot();
|
|
426
|
+
if (dirty || disposed) continue;
|
|
427
|
+
if (snapshot !== null && (typeof snapshot === "object" || typeof snapshot === "function") && typeof snapshot.then === "function" && !dirty && !disposed)
|
|
428
|
+
throw new TypeError("DOM bindings require a synchronous snapshot, not a thenable.");
|
|
429
|
+
if (dirty || disposed) continue;
|
|
430
|
+
const values = descriptor.project(snapshot);
|
|
431
|
+
if (dirty || disposed) continue;
|
|
432
|
+
if (!Array.isArray(values) || values.length !== bindings.length)
|
|
433
|
+
throw new TypeError(
|
|
434
|
+
"A DOM binding projection must return its synchronous scalar values."
|
|
435
|
+
);
|
|
436
|
+
let resolved = values;
|
|
437
|
+
if (projectionFactory && descriptor.projectionGroups) {
|
|
438
|
+
for (const group of descriptor.projectionGroups) {
|
|
439
|
+
if (disposed || dirty) break;
|
|
440
|
+
const first = group[0][0];
|
|
441
|
+
let connection = preparedProjections.get(first);
|
|
442
|
+
if (!connection) {
|
|
443
|
+
connection = projectionFactory.connect(
|
|
444
|
+
group,
|
|
445
|
+
bindings,
|
|
446
|
+
nodes,
|
|
447
|
+
(0, import_read_protocol.forwardNativeTransitionConsumer)(refresh, () => {
|
|
448
|
+
if (!disposed) {
|
|
449
|
+
revision++;
|
|
450
|
+
signalUpdates.add(first);
|
|
451
|
+
drain();
|
|
452
|
+
}
|
|
453
|
+
}),
|
|
454
|
+
options?.restoreStyles
|
|
455
|
+
);
|
|
456
|
+
for (const [index] of group) preparedProjections.set(index, connection);
|
|
457
|
+
}
|
|
458
|
+
const receipt = preview ? connection.preview(values[first]) : void 0;
|
|
459
|
+
if (receipt) receipts.push(receipt);
|
|
460
|
+
const projected = receipt ? receipt.value : connection.read(values[first]);
|
|
461
|
+
if (resolved === values) resolved = [...values];
|
|
462
|
+
for (const [index] of group) resolved[index] = projected[index];
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (styleFactory && descriptor.styleIndices) {
|
|
466
|
+
for (const index of descriptor.styleIndices) {
|
|
467
|
+
if (disposed || dirty) break;
|
|
468
|
+
let connection = preparedSignals.get(index);
|
|
469
|
+
if (!connection) {
|
|
470
|
+
connection = styleFactory.connect(
|
|
471
|
+
nodes[bindings[index][0]],
|
|
472
|
+
(0, import_read_protocol.forwardNativeTransitionConsumer)(refresh, () => {
|
|
473
|
+
if (!disposed) {
|
|
474
|
+
revision++;
|
|
475
|
+
signalUpdates.add(index);
|
|
476
|
+
drain();
|
|
477
|
+
}
|
|
478
|
+
}),
|
|
479
|
+
options?.restoreStyles
|
|
480
|
+
);
|
|
481
|
+
preparedSignals.set(index, connection);
|
|
482
|
+
}
|
|
483
|
+
if (resolved === values) resolved = [...values];
|
|
484
|
+
const receipt = preview ? connection.preview(values[index]) : void 0;
|
|
485
|
+
if (receipt) receipts.push(receipt);
|
|
486
|
+
resolved[index] = receipt ? receipt.value : connection.read(values[index]);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
if (signalFactory && descriptor.signalIndices) {
|
|
490
|
+
for (const index of descriptor.signalIndices) {
|
|
491
|
+
if (disposed || dirty) break;
|
|
492
|
+
let connection = preparedSignals.get(index);
|
|
493
|
+
if (!connection && signalFactory.isSignal(values[index])) {
|
|
494
|
+
connection = signalFactory.connect(
|
|
495
|
+
(0, import_read_protocol.forwardNativeTransitionConsumer)(refresh, () => {
|
|
496
|
+
if (!disposed) {
|
|
497
|
+
revision++;
|
|
498
|
+
signalUpdates.add(index);
|
|
499
|
+
drain();
|
|
500
|
+
}
|
|
501
|
+
})
|
|
502
|
+
);
|
|
503
|
+
preparedSignals.set(index, connection);
|
|
504
|
+
}
|
|
505
|
+
if (connection) {
|
|
506
|
+
if (resolved === values) resolved = [...values];
|
|
507
|
+
const receipt = preview ? connection.preview(values[index]) : void 0;
|
|
508
|
+
if (receipt) receipts.push(receipt);
|
|
509
|
+
resolved[index] = receipt ? receipt.value : connection.read(values[index]);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
next = resolved.map((value, index) => {
|
|
514
|
+
const control = controls?.get(index);
|
|
515
|
+
if (control) {
|
|
516
|
+
const prepared = preview ? control.preview(value) : control.prepare(value);
|
|
517
|
+
controlReceipts?.push(prepared);
|
|
518
|
+
preparedControls.set(index, prepared);
|
|
519
|
+
return null;
|
|
520
|
+
}
|
|
521
|
+
return normalize(bindings[index], value);
|
|
522
|
+
});
|
|
523
|
+
} else {
|
|
524
|
+
indices = [...signalUpdates];
|
|
525
|
+
signalUpdates.clear();
|
|
526
|
+
next = [];
|
|
527
|
+
for (const index of indices) {
|
|
528
|
+
if (prepareProjection?.(index, next, indices)) continue;
|
|
529
|
+
const control = controls?.get(index);
|
|
530
|
+
if (control) preparedControls.set(index, control.prepareCurrent());
|
|
531
|
+
else next[index] = normalize(bindings[index], signalConnections.get(index).get());
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
while (!preview && signalUpdates?.size && !dirty && !disposed) {
|
|
535
|
+
const pending = [...signalUpdates];
|
|
536
|
+
signalUpdates.clear();
|
|
537
|
+
for (const index of pending) {
|
|
538
|
+
if (prepareProjection?.(index, next, indices)) continue;
|
|
539
|
+
const control = controls?.get(index);
|
|
540
|
+
if (control) preparedControls.set(index, control.prepareCurrent());
|
|
541
|
+
else next[index] = normalize(bindings[index], signalConnections.get(index).get());
|
|
542
|
+
if (indices && !indices.includes(index)) indices.push(index);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
const preparedGroups = groups && new Map(
|
|
546
|
+
[...groups].filter(([index]) => !indices || indices.includes(index)).map(([index, group]) => [
|
|
547
|
+
index,
|
|
548
|
+
group.prepare(next[index] ?? "")
|
|
549
|
+
])
|
|
550
|
+
);
|
|
551
|
+
if (preparedControls && !preview) {
|
|
552
|
+
while (!dirty && !disposed) {
|
|
553
|
+
for (const control of preparedControls.values()) {
|
|
554
|
+
control.publish();
|
|
555
|
+
if (dirty || disposed) break;
|
|
556
|
+
}
|
|
557
|
+
if (!signalUpdates?.size || dirty || disposed) break;
|
|
558
|
+
const pending = [...signalUpdates];
|
|
559
|
+
signalUpdates.clear();
|
|
560
|
+
for (const index of pending) {
|
|
561
|
+
const projection = prepareProjection?.(index, next, indices);
|
|
562
|
+
if (projection) {
|
|
563
|
+
for (const [fieldIndex] of projection) {
|
|
564
|
+
const group = groups?.get(fieldIndex);
|
|
565
|
+
if (group)
|
|
566
|
+
preparedGroups.set(
|
|
567
|
+
fieldIndex,
|
|
568
|
+
group.prepare(next[fieldIndex] ?? "")
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
const control = controls?.get(index);
|
|
574
|
+
if (control) preparedControls.set(index, control.prepareCurrent());
|
|
575
|
+
else {
|
|
576
|
+
next[index] = normalize(bindings[index], signalConnections.get(index).get());
|
|
577
|
+
const group = groups?.get(index);
|
|
578
|
+
if (group)
|
|
579
|
+
preparedGroups.set(index, group.prepare(next[index] ?? ""));
|
|
580
|
+
}
|
|
581
|
+
if (indices && !indices.includes(index)) indices.push(index);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (preview)
|
|
586
|
+
return {
|
|
587
|
+
validate: () => !retired && !disposed && revision === version && receipts.every((receipt) => receipt.validate()) && controlReceipts.every((control) => control.validate()),
|
|
588
|
+
discard,
|
|
589
|
+
commit() {
|
|
590
|
+
if (disposed || retired || accepted) return;
|
|
591
|
+
accepted = true;
|
|
592
|
+
busy = true;
|
|
593
|
+
try {
|
|
594
|
+
for (const [index, connection] of preparedSignals ?? [])
|
|
595
|
+
signalConnections.set(index, connection);
|
|
596
|
+
for (const [index, connection] of preparedProjections ?? [])
|
|
597
|
+
projections.set(index, connection);
|
|
598
|
+
for (const receipt of receipts) receipt.commit();
|
|
599
|
+
for (const control of preparedControls?.values() ?? []) control.publish();
|
|
600
|
+
writePrepared(next, indices, preparedControls, preparedGroups);
|
|
601
|
+
} finally {
|
|
602
|
+
busy = false;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
if (dirty || disposed) continue;
|
|
607
|
+
writePrepared(next, indices, preparedControls, preparedGroups);
|
|
608
|
+
}
|
|
609
|
+
} catch (error) {
|
|
610
|
+
if (preview) {
|
|
611
|
+
discard();
|
|
612
|
+
throw error;
|
|
613
|
+
}
|
|
614
|
+
try {
|
|
615
|
+
dispose();
|
|
616
|
+
} catch {
|
|
617
|
+
}
|
|
618
|
+
throw error;
|
|
619
|
+
} finally {
|
|
620
|
+
if (preview) {
|
|
621
|
+
dirty ||= previousDirty;
|
|
622
|
+
for (const index of previousUpdates ?? []) signalUpdates.add(index);
|
|
623
|
+
}
|
|
624
|
+
busy = false;
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
const refresh = () => {
|
|
628
|
+
if (disposed) return;
|
|
629
|
+
revision++;
|
|
630
|
+
dirty = true;
|
|
631
|
+
drain();
|
|
632
|
+
};
|
|
633
|
+
const owner = (0, import_owner_context.currentSignalOwner)();
|
|
634
|
+
const run = owner === null ? (callback) => callback() : (0, import_owner_context.captureSignalOwner)(owner);
|
|
635
|
+
refresh[import_read_protocol.NATIVE_TRANSITION_CONSUMER] = {
|
|
636
|
+
active: () => !disposed,
|
|
637
|
+
prepare: () => run(() => drain(true))
|
|
638
|
+
};
|
|
639
|
+
const handle = { refresh, dispose };
|
|
640
|
+
if (signal?.aborted) {
|
|
641
|
+
dispose();
|
|
642
|
+
return handle;
|
|
643
|
+
}
|
|
644
|
+
try {
|
|
645
|
+
for (let index = 0; index < bindings.length; index++) {
|
|
646
|
+
const binding = bindings[index];
|
|
647
|
+
const node = nodes[binding[0]];
|
|
648
|
+
if (node === void 0) throw new TypeError("A DOM binding targets an unknown element.");
|
|
649
|
+
owned.push([node, __claimBinding(node, binding)]);
|
|
650
|
+
if (binding[1] === "control") {
|
|
651
|
+
controls.set(
|
|
652
|
+
index,
|
|
653
|
+
controlFactory.claim(
|
|
654
|
+
node,
|
|
655
|
+
binding[2],
|
|
656
|
+
(0, import_read_protocol.forwardNativeTransitionConsumer)(refresh, () => {
|
|
657
|
+
if (!disposed) {
|
|
658
|
+
revision++;
|
|
659
|
+
signalUpdates.add(index);
|
|
660
|
+
drain();
|
|
661
|
+
}
|
|
662
|
+
})
|
|
663
|
+
)
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
if (binding[1] === "classGroup") {
|
|
667
|
+
groups ??= /* @__PURE__ */ new Map();
|
|
668
|
+
groups.set(index, descriptor.createClassGroup(node, binding[2], binding[3]));
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
signal?.addEventListener("abort", dispose, { once: true });
|
|
672
|
+
const stop = source.subscribe(refresh);
|
|
673
|
+
if (typeof stop !== "function")
|
|
674
|
+
throw new TypeError("A DOM binding subscription must return a cleanup function.");
|
|
675
|
+
if (disposed) stop();
|
|
676
|
+
else unsubscribe = stop;
|
|
677
|
+
busy = false;
|
|
678
|
+
refresh();
|
|
679
|
+
return handle;
|
|
680
|
+
} catch (error) {
|
|
681
|
+
try {
|
|
682
|
+
dispose();
|
|
683
|
+
} catch {
|
|
684
|
+
}
|
|
685
|
+
throw error;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
689
|
+
0 && (module.exports = {
|
|
690
|
+
__adoptBindings,
|
|
691
|
+
__claimBinding,
|
|
692
|
+
__createBindingStyleRestoration,
|
|
693
|
+
__mountBindings,
|
|
694
|
+
__normalizeBinding,
|
|
695
|
+
__releaseBinding,
|
|
696
|
+
__writeBinding,
|
|
697
|
+
adoptBindings,
|
|
698
|
+
mountBindings,
|
|
699
|
+
unbound
|
|
700
|
+
});
|