octane 0.6.0 → 0.6.2
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/dist/cjs/dom-binding-handoff.cjs +26 -12
- package/dist/cjs/dom-binding-protocol.cjs +42 -21
- package/dist/cjs/dom-binding-styles.cjs +68 -55
- package/dist/cjs/dom-bindings.cjs +308 -227
- package/dist/cjs/error-codes.client.generated.cjs +829 -0
- package/dist/cjs/error-codes.server.generated.cjs +565 -0
- package/dist/cjs/hydration/event-capture.cjs +81 -44
- package/dist/cjs/independent-hydration-protocol.cjs +19 -9
- package/dist/cjs/runtime.cjs +222 -52
- package/dist/cjs/runtime.server.cjs +45 -1
- package/dist/cjs/server/streamed-signals.cjs +2 -4
- package/dist/cjs/signals/actions.cjs +31 -34
- package/dist/cjs/signals/computations.cjs +10 -13
- package/dist/cjs/signals/control-binding.cjs +120 -101
- package/dist/cjs/signals/derived-facade.cjs +9 -10
- package/dist/cjs/signals/document-owner.cjs +13 -9
- package/dist/cjs/signals/engine.cjs +29 -42
- package/dist/cjs/signals/errors.cjs +6 -5
- package/dist/cjs/signals/facade.cjs +91 -87
- package/dist/cjs/signals/graph.cjs +138 -78
- package/dist/cjs/signals/native-read-client.cjs +77 -37
- package/dist/cjs/signals/native-read-seeds.cjs +21 -28
- package/dist/cjs/signals/owner-context.cjs +19 -9
- package/dist/cjs/signals/query-attempt-observer.cjs +9 -9
- package/dist/cjs/signals/query-facade.cjs +8 -15
- package/dist/cjs/signals/read-protocol.cjs +2 -1
- package/dist/cjs/signals/requests.cjs +13 -18
- package/dist/cjs/signals/scalar-computations.cjs +6 -2
- package/dist/cjs/signals/transition-action.cjs +187 -116
- package/dist/cjs/signals/transition-candidate.cjs +29 -16
- package/dist/cjs/version.cjs +1 -1
- package/dist/compiler/native-read-codegen.js +4 -0
- package/dist/dom-binding-classes.js +45 -23
- package/dist/dom-binding-handoff.js +26 -12
- package/dist/dom-binding-program.js +356 -393
- package/dist/dom-binding-projections.js +58 -42
- package/dist/dom-binding-protocol.js +43 -28
- package/dist/dom-binding-signals.js +38 -42
- package/dist/dom-binding-styles.js +69 -62
- package/dist/dom-bindings.js +309 -231
- package/dist/error-codes.client.generated.d.ts +251 -0
- package/dist/error-codes.client.generated.js +829 -0
- package/dist/error-codes.server.generated.d.ts +191 -0
- package/dist/error-codes.server.generated.js +565 -0
- package/dist/hydration/document-lifecycle.js +14 -6
- package/dist/hydration/event-capture.js +85 -67
- package/dist/hydration/independent-island.js +155 -150
- package/dist/hydration/stream-delivery.js +83 -79
- package/dist/hydration/stream-receiver.js +12 -26
- package/dist/hydration/stream-result-receiver.js +60 -47
- package/dist/hydration/streamed-signals.js +51 -54
- package/dist/independent-hydration-protocol.js +19 -9
- package/dist/index.d.ts +1 -1
- package/dist/react/react-compat-server.js +1 -0
- package/dist/react/react-compat.js +1 -0
- package/dist/runtime.d.ts +30 -9
- package/dist/runtime.js +222 -52
- package/dist/runtime.server.d.ts +2 -1
- package/dist/runtime.server.js +45 -1
- package/dist/server/streamed-signals.js +2 -4
- package/dist/signals/actions.js +31 -34
- package/dist/signals/computations.js +10 -13
- package/dist/signals/control-binding.js +125 -125
- package/dist/signals/derived-facade.js +9 -10
- package/dist/signals/document-owner.js +13 -9
- package/dist/signals/engine.js +29 -42
- package/dist/signals/errors.js +6 -5
- package/dist/signals/facade.js +94 -108
- package/dist/signals/graph.js +143 -116
- package/dist/signals/native-read-client.js +78 -41
- package/dist/signals/native-read-seeds.js +21 -28
- package/dist/signals/owner-context.js +19 -9
- package/dist/signals/query-attempt-observer.js +9 -9
- package/dist/signals/query-facade.js +9 -18
- package/dist/signals/read-protocol.js +2 -1
- package/dist/signals/requests.js +13 -18
- package/dist/signals/scalar-computations.js +7 -11
- package/dist/signals/transition-action.js +189 -132
- package/dist/signals/transition-candidate.js +30 -19
- package/dist/universal-core.d.ts +1 -1
- package/dist/universal-core.js +2 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -39,16 +39,17 @@ var import_native_read_seeds = require("./signals/native-read-seeds.cjs");
|
|
|
39
39
|
var import_control_handoff = require("./signals/control-handoff.cjs");
|
|
40
40
|
var import_owner_context = require("./signals/owner-context.cjs");
|
|
41
41
|
var import_read_protocol = require("./signals/read-protocol.cjs");
|
|
42
|
+
function __octaneNoArgError(code) {
|
|
43
|
+
return "Minified Octane error #" + code + "; visit https://octanejs.dev/errors/" + code + " for the full message or use a development build for full errors and additional helpful warnings.";
|
|
44
|
+
}
|
|
42
45
|
function unbound(value) {
|
|
43
46
|
return value;
|
|
44
47
|
}
|
|
45
48
|
function adoptBindings(_root, _view, _source, _options) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
"adoptBindings() requires an Octane-compiled .tsrx or .tsx call and a supported static view."
|
|
48
|
-
);
|
|
49
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "adoptBindings() requires an Octane-compiled .tsrx or .tsx call and a supported static view." : __octaneNoArgError(313));
|
|
49
50
|
}
|
|
50
51
|
function mountBindings(_target, _view, _source, _options) {
|
|
51
|
-
throw new Error("mountBindings() requires an Octane-compiled .tsrx or .tsx call.");
|
|
52
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "mountBindings() requires an Octane-compiled .tsrx or .tsx call." : __octaneNoArgError(314));
|
|
52
53
|
}
|
|
53
54
|
function __mountBindings(target, descriptor, source, options) {
|
|
54
55
|
return descriptor.mount(target, descriptor, source, options);
|
|
@@ -59,49 +60,63 @@ function channel(binding) {
|
|
|
59
60
|
return binding[1] === "styleProperty" ? `style:${binding[2]}` : binding[1] === "classToken" ? `class:${binding[2]}` : binding[1] === "classGroup" ? `classGroup:${binding[2]}:${binding[3]}` : binding[2];
|
|
60
61
|
}
|
|
61
62
|
function conflicts(channels, binding, name) {
|
|
62
|
-
if (channels.has(name))
|
|
63
|
-
|
|
63
|
+
if (channels.has(name))
|
|
64
|
+
return true;
|
|
65
|
+
if (binding[1] === "styleProperty" && channels.has("style"))
|
|
66
|
+
return true;
|
|
64
67
|
if (name === "style") {
|
|
65
|
-
for (const claimed of channels)
|
|
68
|
+
for (const claimed of channels)
|
|
69
|
+
if (claimed.startsWith("style:"))
|
|
70
|
+
return true;
|
|
66
71
|
}
|
|
67
72
|
if (binding[1] === "classToken") {
|
|
68
|
-
if (channels.has("class"))
|
|
69
|
-
|
|
73
|
+
if (channels.has("class"))
|
|
74
|
+
return true;
|
|
75
|
+
for (const claimed of channels)
|
|
76
|
+
if (claimed.startsWith("classGroup:"))
|
|
77
|
+
return true;
|
|
70
78
|
}
|
|
71
79
|
if (binding[1] === "classGroup") {
|
|
72
|
-
if (channels.has("class"))
|
|
73
|
-
|
|
80
|
+
if (channels.has("class"))
|
|
81
|
+
return true;
|
|
82
|
+
for (const claimed of channels)
|
|
83
|
+
if (claimed.startsWith("class:"))
|
|
84
|
+
return true;
|
|
74
85
|
}
|
|
75
86
|
if (name === "class") {
|
|
76
87
|
for (const claimed of channels)
|
|
77
|
-
if (claimed.startsWith("class:") || claimed.startsWith("classGroup:"))
|
|
88
|
+
if (claimed.startsWith("class:") || claimed.startsWith("classGroup:"))
|
|
89
|
+
return true;
|
|
78
90
|
}
|
|
79
91
|
return false;
|
|
80
92
|
}
|
|
81
93
|
function __claimBinding(node, binding) {
|
|
82
94
|
if (binding[1] === "classToken" && !/^\S+$/.test(binding[2]))
|
|
83
|
-
throw new TypeError("A DOM class token binding requires one nonempty class token.");
|
|
95
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM class token binding requires one nonempty class token." : __octaneNoArgError(315));
|
|
84
96
|
const name = channel(binding);
|
|
85
97
|
let channels = claims.get(node);
|
|
86
98
|
if (channels !== void 0 && conflicts(channels, binding, name))
|
|
87
|
-
throw new Error("This DOM property already has a binding. Dispose it before rebinding.");
|
|
88
|
-
if (channels === void 0)
|
|
99
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "This DOM property already has a binding. Dispose it before rebinding." : __octaneNoArgError(316));
|
|
100
|
+
if (channels === void 0)
|
|
101
|
+
claims.set(node, channels = /* @__PURE__ */ new Set());
|
|
89
102
|
channels.add(name);
|
|
90
103
|
return name;
|
|
91
104
|
}
|
|
92
105
|
function __releaseBinding(node, name) {
|
|
93
106
|
const channels = claims.get(node);
|
|
94
107
|
channels.delete(name);
|
|
95
|
-
if (channels.size === 0)
|
|
108
|
+
if (channels.size === 0)
|
|
109
|
+
claims.delete(node);
|
|
96
110
|
const published = import_dom_binding_claims.domBindingClaims.get(node);
|
|
97
111
|
if (published) {
|
|
98
112
|
published.delete(name);
|
|
99
|
-
if (published.size === 0)
|
|
113
|
+
if (published.size === 0)
|
|
114
|
+
import_dom_binding_claims.domBindingClaims.delete(node);
|
|
100
115
|
}
|
|
101
116
|
}
|
|
102
117
|
function assertBindingRoot(root, descriptor) {
|
|
103
118
|
if (root?.nodeType !== 1 || root.getAttribute("data-octane-bindings") !== descriptor.id || descriptor.nodes.length === 0) {
|
|
104
|
-
throw new Error("DOM bindings require the matching compiler-stamped root.");
|
|
119
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "DOM bindings require the matching compiler-stamped root." : __octaneNoArgError(317));
|
|
105
120
|
}
|
|
106
121
|
return root;
|
|
107
122
|
}
|
|
@@ -113,14 +128,14 @@ function resolveFixedNodes(root, descriptor) {
|
|
|
113
128
|
const [parent, tag, namespace, children, , text] = descriptor.nodes[i];
|
|
114
129
|
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;
|
|
115
130
|
if (node === void 0 || descriptor.nodes[i][4] === true || node.localName !== tag || node.namespaceURI !== namespaces[namespace] || (text ? node.childNodes.length > 1 || node.firstChild !== null && node.firstChild.nodeType !== 3 : children !== null && (node.childNodes.length !== children || node.children.length !== children))) {
|
|
116
|
-
throw new Error("DOM bindings cannot adopt a mismatched static element topology.");
|
|
131
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "DOM bindings cannot adopt a mismatched static element topology." : __octaneNoArgError(318));
|
|
117
132
|
}
|
|
118
133
|
nodes.push(node);
|
|
119
134
|
childIndices.push(0);
|
|
120
135
|
}
|
|
121
136
|
for (let i = 0; i < nodes.length; i++) {
|
|
122
137
|
if (childIndices[i] !== (descriptor.nodes[i][3] ?? 0)) {
|
|
123
|
-
throw new Error("DOM bindings cannot adopt an incomplete static element topology.");
|
|
138
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "DOM bindings cannot adopt an incomplete static element topology." : __octaneNoArgError(319));
|
|
124
139
|
}
|
|
125
140
|
}
|
|
126
141
|
return nodes;
|
|
@@ -136,10 +151,11 @@ function resolveAddressedNodes(root, descriptor) {
|
|
|
136
151
|
if (marker?.startsWith(prefix)) {
|
|
137
152
|
const index = Number(marker.slice(prefix.length));
|
|
138
153
|
if (!Number.isSafeInteger(index) || index < 0 || index >= descriptor.nodes.length || marker !== `${prefix}${index}` || nodes[index] !== void 0) {
|
|
139
|
-
throw new Error("DOM bindings require unique compiler-issued target addresses.");
|
|
154
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "DOM bindings require unique compiler-issued target addresses." : __octaneNoArgError(320));
|
|
140
155
|
}
|
|
141
156
|
nodes[index] = current;
|
|
142
|
-
if (descriptor.nodes[index][3] === null)
|
|
157
|
+
if (descriptor.nodes[index][3] === null)
|
|
158
|
+
descend = false;
|
|
143
159
|
}
|
|
144
160
|
}
|
|
145
161
|
if (descend && current.firstElementChild !== null) {
|
|
@@ -148,7 +164,8 @@ function resolveAddressedNodes(root, descriptor) {
|
|
|
148
164
|
}
|
|
149
165
|
while (current !== root && current.nextElementSibling === null)
|
|
150
166
|
current = current.parentElement;
|
|
151
|
-
if (current === root)
|
|
167
|
+
if (current === root)
|
|
168
|
+
break;
|
|
152
169
|
current = current.nextElementSibling;
|
|
153
170
|
}
|
|
154
171
|
const childCounts = new Array(descriptor.nodes.length).fill(0);
|
|
@@ -156,13 +173,14 @@ function resolveAddressedNodes(root, descriptor) {
|
|
|
156
173
|
const [parent, tag, namespace, children, openChildren, text] = descriptor.nodes[i];
|
|
157
174
|
const node = nodes[i];
|
|
158
175
|
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 || (text ? node.childNodes.length > 1 || node.firstChild !== null && node.firstChild.nodeType !== 3 : children !== null && !openChildren && (node.childNodes.length !== children || node.children.length !== children))) {
|
|
159
|
-
throw new Error("DOM bindings cannot adopt a mismatched addressed element topology.");
|
|
176
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "DOM bindings cannot adopt a mismatched addressed element topology." : __octaneNoArgError(321));
|
|
160
177
|
}
|
|
161
|
-
if (parent !== -1)
|
|
178
|
+
if (parent !== -1)
|
|
179
|
+
childCounts[parent]++;
|
|
162
180
|
}
|
|
163
181
|
for (let i = 0; i < descriptor.nodes.length; i++) {
|
|
164
182
|
if (childCounts[i] !== (descriptor.nodes[i][3] ?? 0)) {
|
|
165
|
-
throw new Error("DOM bindings cannot adopt an incomplete addressed element topology.");
|
|
183
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "DOM bindings cannot adopt an incomplete addressed element topology." : __octaneNoArgError(322));
|
|
166
184
|
}
|
|
167
185
|
}
|
|
168
186
|
return nodes;
|
|
@@ -175,9 +193,10 @@ function normalizeFixedScalar(binding, value) {
|
|
|
175
193
|
const type = typeof value;
|
|
176
194
|
switch (binding[1]) {
|
|
177
195
|
case "text":
|
|
178
|
-
if (value == null || value === false)
|
|
196
|
+
if (value == null || value === false)
|
|
197
|
+
return "";
|
|
179
198
|
if (type !== "string" && type !== "number" && type !== "bigint" && type !== "boolean")
|
|
180
|
-
throw new TypeError("DOM binding text must be a synchronous scalar.");
|
|
199
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "DOM binding text must be a synchronous scalar." : __octaneNoArgError(323));
|
|
181
200
|
return String(value);
|
|
182
201
|
case "class":
|
|
183
202
|
return value == null || value === false ? null : (0, import_class_names.normalizeClass)(value);
|
|
@@ -191,10 +210,13 @@ function writeFixedScalar(node, binding, value) {
|
|
|
191
210
|
const name = binding[2];
|
|
192
211
|
if (binding[1] === "text") {
|
|
193
212
|
const text = node.firstChild;
|
|
194
|
-
if (text === null)
|
|
195
|
-
|
|
213
|
+
if (text === null)
|
|
214
|
+
node.appendChild(node.ownerDocument.createTextNode(value));
|
|
215
|
+
else if (text.nodeValue !== value)
|
|
216
|
+
text.nodeValue = value;
|
|
196
217
|
} else if (value === null) {
|
|
197
|
-
if (node.hasAttribute(name))
|
|
218
|
+
if (node.hasAttribute(name))
|
|
219
|
+
node.removeAttribute(name);
|
|
198
220
|
} else if (node.getAttribute(name) !== value) {
|
|
199
221
|
node.setAttribute(name, value);
|
|
200
222
|
}
|
|
@@ -207,16 +229,18 @@ function normalize(binding, value) {
|
|
|
207
229
|
case "classGroup":
|
|
208
230
|
return value == null || value === false ? "" : (0, import_class_names.normalizeClass)(value);
|
|
209
231
|
case "styleAttribute":
|
|
210
|
-
if (value == null || value === false || value === "")
|
|
232
|
+
if (value == null || value === false || value === "")
|
|
233
|
+
return null;
|
|
211
234
|
if (type !== "string")
|
|
212
|
-
throw new TypeError("A whole-style DOM binding requires serialized CSS text or null.");
|
|
235
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A whole-style DOM binding requires serialized CSS text or null." : __octaneNoArgError(324));
|
|
213
236
|
return value;
|
|
214
237
|
case "classToken":
|
|
215
238
|
return value ? "" : null;
|
|
216
239
|
case "url":
|
|
217
240
|
return value == null || type === "boolean" || type === "function" || type === "symbol" ? null : (0, import_sanitize_url.sanitizeURL)(String(value));
|
|
218
241
|
case "styleProperty": {
|
|
219
|
-
if (value == null || type === "boolean")
|
|
242
|
+
if (value == null || type === "boolean")
|
|
243
|
+
return null;
|
|
220
244
|
return type === "number" && value !== 0 && !binding[3] ? value + "px" : type === "string" ? value.trim() : "" + value;
|
|
221
245
|
}
|
|
222
246
|
default:
|
|
@@ -228,14 +252,18 @@ function write(node, binding, value) {
|
|
|
228
252
|
if (binding[1] === "classToken") {
|
|
229
253
|
node.classList.toggle(name, value !== null);
|
|
230
254
|
} else if (binding[1] === "url") {
|
|
231
|
-
if (value === "" && !(name === "href" && node.localName === "a"))
|
|
255
|
+
if (value === "" && !(name === "href" && node.localName === "a"))
|
|
256
|
+
value = null;
|
|
232
257
|
if (name === "xlink:href") {
|
|
233
|
-
if (value === null)
|
|
258
|
+
if (value === null)
|
|
259
|
+
node.removeAttributeNS("http://www.w3.org/1999/xlink", "href");
|
|
234
260
|
else if (node.getAttributeNS("http://www.w3.org/1999/xlink", "href") !== value)
|
|
235
261
|
node.setAttributeNS("http://www.w3.org/1999/xlink", name, value);
|
|
236
262
|
} else if (value === null) {
|
|
237
|
-
if (node.hasAttribute(name))
|
|
238
|
-
|
|
263
|
+
if (node.hasAttribute(name))
|
|
264
|
+
node.removeAttribute(name);
|
|
265
|
+
} else if (node.getAttribute(name) !== value)
|
|
266
|
+
node.setAttribute(name, value);
|
|
239
267
|
} else if (binding[1] === "styleProperty") {
|
|
240
268
|
const style = node.style;
|
|
241
269
|
if (value === null) {
|
|
@@ -248,7 +276,8 @@ function write(node, binding, value) {
|
|
|
248
276
|
if (style.getPropertyValue(name) !== text || style.getPropertyPriority(name) !== priority)
|
|
249
277
|
style.setProperty(name, text, priority);
|
|
250
278
|
}
|
|
251
|
-
} else
|
|
279
|
+
} else
|
|
280
|
+
writeFixedScalar(node, binding, value);
|
|
252
281
|
}
|
|
253
282
|
function __createBindingStyleRestoration(node, binding) {
|
|
254
283
|
if (binding[1] === "styleAttribute") {
|
|
@@ -257,13 +286,16 @@ function __createBindingStyleRestoration(node, binding) {
|
|
|
257
286
|
let disposed2 = false;
|
|
258
287
|
return {
|
|
259
288
|
write(value) {
|
|
260
|
-
if (disposed2)
|
|
261
|
-
|
|
289
|
+
if (disposed2)
|
|
290
|
+
return;
|
|
291
|
+
if (baseline2 === void 0)
|
|
292
|
+
baseline2 = node.getAttribute("style");
|
|
262
293
|
expected2 = value;
|
|
263
294
|
write(node, binding, value);
|
|
264
295
|
},
|
|
265
296
|
dispose(preservePresentation) {
|
|
266
|
-
if (disposed2)
|
|
297
|
+
if (disposed2)
|
|
298
|
+
return;
|
|
267
299
|
disposed2 = true;
|
|
268
300
|
if (!preservePresentation && baseline2 !== void 0 && node.getAttribute("style") === expected2)
|
|
269
301
|
write(node, binding, baseline2);
|
|
@@ -278,7 +310,8 @@ function __createBindingStyleRestoration(node, binding) {
|
|
|
278
310
|
let disposed = false;
|
|
279
311
|
return {
|
|
280
312
|
write(value) {
|
|
281
|
-
if (disposed)
|
|
313
|
+
if (disposed)
|
|
314
|
+
return;
|
|
282
315
|
baseline ??= [style.getPropertyValue(name), style.getPropertyPriority(name)];
|
|
283
316
|
probe ??= node.ownerDocument.createElement("i");
|
|
284
317
|
probe.style.cssText = "";
|
|
@@ -288,19 +321,23 @@ function __createBindingStyleRestoration(node, binding) {
|
|
|
288
321
|
write(node, binding, value);
|
|
289
322
|
},
|
|
290
323
|
dispose(preservePresentation) {
|
|
291
|
-
if (disposed)
|
|
324
|
+
if (disposed)
|
|
325
|
+
return;
|
|
292
326
|
disposed = true;
|
|
293
327
|
if (!preservePresentation && baseline && expected && style.getPropertyValue(name) === expected[0] && style.getPropertyPriority(name) === expected[1]) {
|
|
294
|
-
if (baseline[0] === "")
|
|
295
|
-
|
|
328
|
+
if (baseline[0] === "")
|
|
329
|
+
style.removeProperty(name);
|
|
330
|
+
else
|
|
331
|
+
style.setProperty(name, baseline[0], baseline[1]);
|
|
296
332
|
}
|
|
297
333
|
}
|
|
298
334
|
};
|
|
299
335
|
}
|
|
300
336
|
function __adoptBindings(root, descriptor, source, options) {
|
|
301
|
-
if ("root" in descriptor)
|
|
337
|
+
if ("root" in descriptor)
|
|
338
|
+
return descriptor.adopt(root, descriptor, source, options);
|
|
302
339
|
if (!source || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function")
|
|
303
|
-
throw new TypeError("DOM bindings require synchronous getSnapshot() and subscribe() methods.");
|
|
340
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "DOM bindings require synchronous getSnapshot() and subscribe() methods." : __octaneNoArgError(325));
|
|
304
341
|
const nodes = descriptor.addressed ? resolveAddressedNodes(assertBindingRoot(root, descriptor), descriptor) : resolveFixedNodes(root, descriptor);
|
|
305
342
|
const bindings = descriptor.bindings;
|
|
306
343
|
const owned = [];
|
|
@@ -396,18 +433,22 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
396
433
|
try {
|
|
397
434
|
stop?.();
|
|
398
435
|
} catch (error) {
|
|
399
|
-
if (!failed)
|
|
436
|
+
if (!failed)
|
|
437
|
+
throw error;
|
|
400
438
|
}
|
|
401
|
-
if (failed)
|
|
439
|
+
if (failed)
|
|
440
|
+
throw failure;
|
|
402
441
|
};
|
|
403
442
|
const prepareProjection = projections ? (index, next, indices) => {
|
|
404
443
|
const projection = projections.get(index);
|
|
405
|
-
if (!projection)
|
|
444
|
+
if (!projection)
|
|
445
|
+
return;
|
|
406
446
|
if (index === projection.group[0][0]) {
|
|
407
447
|
const values = projection.get();
|
|
408
448
|
for (const [fieldIndex] of projection.group) {
|
|
409
449
|
next[fieldIndex] = values[fieldIndex];
|
|
410
|
-
if (indices && !indices.includes(fieldIndex))
|
|
450
|
+
if (indices && !indices.includes(fieldIndex))
|
|
451
|
+
indices.push(fieldIndex);
|
|
411
452
|
}
|
|
412
453
|
}
|
|
413
454
|
return projection.group;
|
|
@@ -419,21 +460,27 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
419
460
|
preparedControls.get(i).commit();
|
|
420
461
|
continue;
|
|
421
462
|
}
|
|
422
|
-
if (next[i] === previous[i])
|
|
463
|
+
if (next[i] === previous[i])
|
|
464
|
+
continue;
|
|
423
465
|
const binding = bindings[i];
|
|
424
|
-
if (binding[1] === "classToken")
|
|
466
|
+
if (binding[1] === "classToken")
|
|
467
|
+
previous[i] = next[i];
|
|
425
468
|
if (binding[1] === "styleObject") {
|
|
426
469
|
const projection = projections?.get(i);
|
|
427
|
-
if (projection)
|
|
428
|
-
|
|
429
|
-
|
|
470
|
+
if (projection)
|
|
471
|
+
projection.writeStyle(i, next[i]);
|
|
472
|
+
else
|
|
473
|
+
signalConnections.get(i).write(next[i]);
|
|
474
|
+
} else if (binding[1] === "classGroup")
|
|
475
|
+
preparedGroups.get(i).commit();
|
|
430
476
|
else if ((binding[1] === "styleProperty" || binding[1] === "styleAttribute") && options?.restoreStyles) {
|
|
431
477
|
styles ??= /* @__PURE__ */ new Map();
|
|
432
478
|
let style = styles.get(i);
|
|
433
479
|
if (!style)
|
|
434
480
|
styles.set(i, style = __createBindingStyleRestoration(nodes[binding[0]], binding));
|
|
435
481
|
style.write(next[i]);
|
|
436
|
-
} else
|
|
482
|
+
} else
|
|
483
|
+
write(nodes[binding[0]], binding, next[i]);
|
|
437
484
|
if (!disposed) {
|
|
438
485
|
previous[i] = next[i];
|
|
439
486
|
if (binding[1] === "attr" || binding[1] === "boolean" || binding[1] === "aria" || binding[1] === "class" || binding[1] === "styleProperty" || binding[1] === "text") {
|
|
@@ -445,17 +492,20 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
445
492
|
published2 = value === "" ? null : value + (style.getPropertyPriority(binding[2]) ? " !important" : "");
|
|
446
493
|
}
|
|
447
494
|
let claims2 = import_dom_binding_claims.domBindingClaims.get(node);
|
|
448
|
-
if (claims2 === void 0)
|
|
495
|
+
if (claims2 === void 0)
|
|
496
|
+
import_dom_binding_claims.domBindingClaims.set(node, claims2 = /* @__PURE__ */ new Map());
|
|
449
497
|
claims2.set(name, published2);
|
|
450
498
|
}
|
|
451
499
|
}
|
|
452
500
|
}
|
|
453
501
|
};
|
|
454
502
|
const drain = (preview = false) => {
|
|
455
|
-
if (disposed)
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
503
|
+
if (disposed)
|
|
504
|
+
return;
|
|
505
|
+
if (busy)
|
|
506
|
+
return preview ? { validate: () => false, commit() {
|
|
507
|
+
}, discard() {
|
|
508
|
+
} } : void 0;
|
|
459
509
|
const version = revision;
|
|
460
510
|
const previousDirty = dirty;
|
|
461
511
|
const previousUpdates = preview && signalUpdates ? [...signalUpdates] : void 0;
|
|
@@ -466,16 +516,22 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
466
516
|
let accepted = false;
|
|
467
517
|
let retired = false;
|
|
468
518
|
const discard = preview ? () => {
|
|
469
|
-
if (accepted || retired)
|
|
519
|
+
if (accepted || retired)
|
|
520
|
+
return;
|
|
470
521
|
retired = true;
|
|
471
|
-
for (const receipt of receipts)
|
|
472
|
-
|
|
522
|
+
for (const receipt of receipts)
|
|
523
|
+
receipt.discard();
|
|
524
|
+
for (const control of controlReceipts)
|
|
525
|
+
control.discard();
|
|
473
526
|
for (const [index, connection] of preparedSignals ?? [])
|
|
474
|
-
if (connection !== signalConnections?.get(index))
|
|
527
|
+
if (connection !== signalConnections?.get(index))
|
|
528
|
+
connection.dispose(true);
|
|
475
529
|
for (const [index, connection] of preparedProjections ?? [])
|
|
476
|
-
if (connection !== projections?.get(index))
|
|
530
|
+
if (connection !== projections?.get(index))
|
|
531
|
+
connection.dispose(true);
|
|
477
532
|
} : void 0;
|
|
478
|
-
if (preview)
|
|
533
|
+
if (preview)
|
|
534
|
+
dirty = true;
|
|
479
535
|
busy = true;
|
|
480
536
|
try {
|
|
481
537
|
while ((dirty || signalUpdates?.size) && !disposed) {
|
|
@@ -486,89 +542,89 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
486
542
|
dirty = false;
|
|
487
543
|
signalUpdates?.clear();
|
|
488
544
|
const snapshot = source.getSnapshot();
|
|
489
|
-
if (dirty || disposed)
|
|
545
|
+
if (dirty || disposed)
|
|
546
|
+
continue;
|
|
490
547
|
if (snapshot !== null && (typeof snapshot === "object" || typeof snapshot === "function") && typeof snapshot.then === "function" && !dirty && !disposed)
|
|
491
|
-
throw new TypeError("DOM bindings require a synchronous snapshot, not a thenable.");
|
|
492
|
-
if (dirty || disposed)
|
|
548
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "DOM bindings require a synchronous snapshot, not a thenable." : __octaneNoArgError(326));
|
|
549
|
+
if (dirty || disposed)
|
|
550
|
+
continue;
|
|
493
551
|
const values = descriptor.project(snapshot);
|
|
494
|
-
if (dirty || disposed)
|
|
552
|
+
if (dirty || disposed)
|
|
553
|
+
continue;
|
|
495
554
|
if (!Array.isArray(values) || values.length !== bindings.length)
|
|
496
|
-
throw new TypeError(
|
|
497
|
-
"A DOM binding projection must return its synchronous scalar values."
|
|
498
|
-
);
|
|
555
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM binding projection must return its synchronous scalar values." : __octaneNoArgError(327));
|
|
499
556
|
let resolved = values;
|
|
500
557
|
if (projectionFactory && descriptor.projectionGroups) {
|
|
501
558
|
for (const group of descriptor.projectionGroups) {
|
|
502
|
-
if (disposed || dirty)
|
|
559
|
+
if (disposed || dirty)
|
|
560
|
+
break;
|
|
503
561
|
const first = group[0][0];
|
|
504
562
|
let connection = preparedProjections.get(first);
|
|
505
563
|
if (!connection) {
|
|
506
|
-
connection = projectionFactory.connect(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
}),
|
|
517
|
-
options?.restoreStyles
|
|
518
|
-
);
|
|
519
|
-
for (const [index] of group) preparedProjections.set(index, connection);
|
|
564
|
+
connection = projectionFactory.connect(group, bindings, nodes, (0, import_read_protocol.forwardNativeTransitionConsumer)(refresh, () => {
|
|
565
|
+
if (!disposed) {
|
|
566
|
+
revision++;
|
|
567
|
+
signalUpdates.add(first);
|
|
568
|
+
drain();
|
|
569
|
+
}
|
|
570
|
+
}), options?.restoreStyles);
|
|
571
|
+
for (const [index] of group)
|
|
572
|
+
preparedProjections.set(index, connection);
|
|
520
573
|
}
|
|
521
574
|
const receipt = preview ? connection.preview(values[first]) : void 0;
|
|
522
|
-
if (receipt)
|
|
575
|
+
if (receipt)
|
|
576
|
+
receipts.push(receipt);
|
|
523
577
|
const projected = receipt ? receipt.value : connection.read(values[first]);
|
|
524
|
-
if (resolved === values)
|
|
525
|
-
|
|
578
|
+
if (resolved === values)
|
|
579
|
+
resolved = [...values];
|
|
580
|
+
for (const [index] of group)
|
|
581
|
+
resolved[index] = projected[index];
|
|
526
582
|
}
|
|
527
583
|
}
|
|
528
584
|
if (styleFactory && descriptor.styleIndices) {
|
|
529
585
|
for (const index of descriptor.styleIndices) {
|
|
530
|
-
if (disposed || dirty)
|
|
586
|
+
if (disposed || dirty)
|
|
587
|
+
break;
|
|
531
588
|
let connection = preparedSignals.get(index);
|
|
532
589
|
if (!connection) {
|
|
533
|
-
connection = styleFactory.connect(
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
}
|
|
541
|
-
}),
|
|
542
|
-
options?.restoreStyles
|
|
543
|
-
);
|
|
590
|
+
connection = styleFactory.connect(nodes[bindings[index][0]], (0, import_read_protocol.forwardNativeTransitionConsumer)(refresh, () => {
|
|
591
|
+
if (!disposed) {
|
|
592
|
+
revision++;
|
|
593
|
+
signalUpdates.add(index);
|
|
594
|
+
drain();
|
|
595
|
+
}
|
|
596
|
+
}), options?.restoreStyles);
|
|
544
597
|
preparedSignals.set(index, connection);
|
|
545
598
|
}
|
|
546
|
-
if (resolved === values)
|
|
599
|
+
if (resolved === values)
|
|
600
|
+
resolved = [...values];
|
|
547
601
|
const receipt = preview ? connection.preview(values[index]) : void 0;
|
|
548
|
-
if (receipt)
|
|
602
|
+
if (receipt)
|
|
603
|
+
receipts.push(receipt);
|
|
549
604
|
resolved[index] = receipt ? receipt.value : connection.read(values[index]);
|
|
550
605
|
}
|
|
551
606
|
}
|
|
552
607
|
if (signalFactory && descriptor.signalIndices) {
|
|
553
608
|
for (const index of descriptor.signalIndices) {
|
|
554
|
-
if (disposed || dirty)
|
|
609
|
+
if (disposed || dirty)
|
|
610
|
+
break;
|
|
555
611
|
let connection = preparedSignals.get(index);
|
|
556
612
|
if (!connection && signalFactory.isSignal(values[index])) {
|
|
557
|
-
connection = signalFactory.connect(
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
})
|
|
565
|
-
);
|
|
613
|
+
connection = signalFactory.connect((0, import_read_protocol.forwardNativeTransitionConsumer)(refresh, () => {
|
|
614
|
+
if (!disposed) {
|
|
615
|
+
revision++;
|
|
616
|
+
signalUpdates.add(index);
|
|
617
|
+
drain();
|
|
618
|
+
}
|
|
619
|
+
}));
|
|
566
620
|
preparedSignals.set(index, connection);
|
|
567
621
|
}
|
|
568
622
|
if (connection) {
|
|
569
|
-
if (resolved === values)
|
|
623
|
+
if (resolved === values)
|
|
624
|
+
resolved = [...values];
|
|
570
625
|
const receipt = preview ? connection.preview(values[index]) : void 0;
|
|
571
|
-
if (receipt)
|
|
626
|
+
if (receipt)
|
|
627
|
+
receipts.push(receipt);
|
|
572
628
|
resolved[index] = receipt ? receipt.value : connection.read(values[index]);
|
|
573
629
|
}
|
|
574
630
|
}
|
|
@@ -588,36 +644,43 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
588
644
|
signalUpdates.clear();
|
|
589
645
|
next = [];
|
|
590
646
|
for (const index of indices) {
|
|
591
|
-
if (prepareProjection?.(index, next, indices))
|
|
647
|
+
if (prepareProjection?.(index, next, indices))
|
|
648
|
+
continue;
|
|
592
649
|
const control = controls?.get(index);
|
|
593
|
-
if (control)
|
|
594
|
-
|
|
650
|
+
if (control)
|
|
651
|
+
preparedControls.set(index, control.prepareCurrent());
|
|
652
|
+
else
|
|
653
|
+
next[index] = normalize(bindings[index], signalConnections.get(index).get());
|
|
595
654
|
}
|
|
596
655
|
}
|
|
597
656
|
while (!preview && signalUpdates?.size && !dirty && !disposed) {
|
|
598
657
|
const pending = [...signalUpdates];
|
|
599
658
|
signalUpdates.clear();
|
|
600
659
|
for (const index of pending) {
|
|
601
|
-
if (prepareProjection?.(index, next, indices))
|
|
660
|
+
if (prepareProjection?.(index, next, indices))
|
|
661
|
+
continue;
|
|
602
662
|
const control = controls?.get(index);
|
|
603
|
-
if (control)
|
|
604
|
-
|
|
605
|
-
|
|
663
|
+
if (control)
|
|
664
|
+
preparedControls.set(index, control.prepareCurrent());
|
|
665
|
+
else
|
|
666
|
+
next[index] = normalize(bindings[index], signalConnections.get(index).get());
|
|
667
|
+
if (indices && !indices.includes(index))
|
|
668
|
+
indices.push(index);
|
|
606
669
|
}
|
|
607
670
|
}
|
|
608
|
-
const preparedGroups = groups && new Map(
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
])
|
|
613
|
-
);
|
|
671
|
+
const preparedGroups = groups && new Map([...groups].filter(([index]) => !indices || indices.includes(index)).map(([index, group]) => [
|
|
672
|
+
index,
|
|
673
|
+
group.prepare(next[index] ?? "")
|
|
674
|
+
]));
|
|
614
675
|
if (preparedControls && !preview) {
|
|
615
676
|
while (!dirty && !disposed) {
|
|
616
677
|
for (const control of preparedControls.values()) {
|
|
617
678
|
control.publish();
|
|
618
|
-
if (dirty || disposed)
|
|
679
|
+
if (dirty || disposed)
|
|
680
|
+
break;
|
|
619
681
|
}
|
|
620
|
-
if (!signalUpdates?.size || dirty || disposed)
|
|
682
|
+
if (!signalUpdates?.size || dirty || disposed)
|
|
683
|
+
break;
|
|
621
684
|
const pending = [...signalUpdates];
|
|
622
685
|
signalUpdates.clear();
|
|
623
686
|
for (const index of pending) {
|
|
@@ -626,22 +689,21 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
626
689
|
for (const [fieldIndex] of projection) {
|
|
627
690
|
const group = groups?.get(fieldIndex);
|
|
628
691
|
if (group)
|
|
629
|
-
preparedGroups.set(
|
|
630
|
-
fieldIndex,
|
|
631
|
-
group.prepare(next[fieldIndex] ?? "")
|
|
632
|
-
);
|
|
692
|
+
preparedGroups.set(fieldIndex, group.prepare(next[fieldIndex] ?? ""));
|
|
633
693
|
}
|
|
634
694
|
continue;
|
|
635
695
|
}
|
|
636
696
|
const control = controls?.get(index);
|
|
637
|
-
if (control)
|
|
697
|
+
if (control)
|
|
698
|
+
preparedControls.set(index, control.prepareCurrent());
|
|
638
699
|
else {
|
|
639
700
|
next[index] = normalize(bindings[index], signalConnections.get(index).get());
|
|
640
701
|
const group = groups?.get(index);
|
|
641
702
|
if (group)
|
|
642
703
|
preparedGroups.set(index, group.prepare(next[index] ?? ""));
|
|
643
704
|
}
|
|
644
|
-
if (indices && !indices.includes(index))
|
|
705
|
+
if (indices && !indices.includes(index))
|
|
706
|
+
indices.push(index);
|
|
645
707
|
}
|
|
646
708
|
}
|
|
647
709
|
}
|
|
@@ -650,7 +712,8 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
650
712
|
validate: () => !retired && !disposed && revision === version && receipts.every((receipt) => receipt.validate()) && controlReceipts.every((control) => control.validate()),
|
|
651
713
|
discard,
|
|
652
714
|
commit() {
|
|
653
|
-
if (disposed || retired || accepted)
|
|
715
|
+
if (disposed || retired || accepted)
|
|
716
|
+
return;
|
|
654
717
|
accepted = true;
|
|
655
718
|
busy = true;
|
|
656
719
|
try {
|
|
@@ -658,8 +721,10 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
658
721
|
signalConnections.set(index, connection);
|
|
659
722
|
for (const [index, connection] of preparedProjections ?? [])
|
|
660
723
|
projections.set(index, connection);
|
|
661
|
-
for (const receipt of receipts)
|
|
662
|
-
|
|
724
|
+
for (const receipt of receipts)
|
|
725
|
+
receipt.commit();
|
|
726
|
+
for (const control of preparedControls?.values() ?? [])
|
|
727
|
+
control.publish();
|
|
663
728
|
writePrepared(next, indices, preparedControls, preparedGroups);
|
|
664
729
|
} finally {
|
|
665
730
|
busy = false;
|
|
@@ -667,7 +732,8 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
667
732
|
}
|
|
668
733
|
}
|
|
669
734
|
};
|
|
670
|
-
if (dirty || disposed)
|
|
735
|
+
if (dirty || disposed)
|
|
736
|
+
continue;
|
|
671
737
|
writePrepared(next, indices, preparedControls, preparedGroups);
|
|
672
738
|
}
|
|
673
739
|
} catch (error) {
|
|
@@ -683,14 +749,17 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
683
749
|
} finally {
|
|
684
750
|
if (preview) {
|
|
685
751
|
dirty ||= previousDirty;
|
|
686
|
-
for (const index of previousUpdates ?? [])
|
|
752
|
+
for (const index of previousUpdates ?? [])
|
|
753
|
+
signalUpdates.add(index);
|
|
687
754
|
}
|
|
688
755
|
busy = false;
|
|
689
|
-
if (!preview)
|
|
756
|
+
if (!preview)
|
|
757
|
+
published?.();
|
|
690
758
|
}
|
|
691
759
|
};
|
|
692
760
|
const refresh = () => {
|
|
693
|
-
if (disposed)
|
|
761
|
+
if (disposed)
|
|
762
|
+
return;
|
|
694
763
|
revision++;
|
|
695
764
|
dirty = true;
|
|
696
765
|
drain();
|
|
@@ -704,12 +773,14 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
704
773
|
const handle = { refresh, dispose };
|
|
705
774
|
if (descriptor.handoff === "host") {
|
|
706
775
|
published = () => {
|
|
707
|
-
if (!publicationRetries?.size)
|
|
776
|
+
if (!publicationRetries?.size)
|
|
777
|
+
return;
|
|
708
778
|
const pending = [...publicationRetries];
|
|
709
779
|
publicationRetries.clear();
|
|
710
780
|
for (const retry of pending)
|
|
711
781
|
queueMicrotask(() => {
|
|
712
|
-
if (!disposed)
|
|
782
|
+
if (!disposed)
|
|
783
|
+
retry();
|
|
713
784
|
});
|
|
714
785
|
};
|
|
715
786
|
const host = root;
|
|
@@ -727,16 +798,13 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
727
798
|
const nextSibling = sibling(host, false);
|
|
728
799
|
let handoff;
|
|
729
800
|
handle[import_control_handoff.BINDING_HANDOFF] = () => {
|
|
730
|
-
if (handoff !== void 0)
|
|
801
|
+
if (handoff !== void 0)
|
|
802
|
+
return handoff;
|
|
731
803
|
return handoff = {
|
|
732
804
|
id: descriptor.id,
|
|
733
805
|
root: host,
|
|
734
806
|
anchor: host,
|
|
735
|
-
host: new Set(
|
|
736
|
-
bindings.map(
|
|
737
|
-
(binding) => binding[1] === "styleProperty" ? "style:" + binding[2] : binding[1].startsWith("style") ? "style" : binding[2]
|
|
738
|
-
)
|
|
739
|
-
),
|
|
807
|
+
host: new Set(bindings.map((binding) => binding[1] === "styleProperty" ? "style:" + binding[2] : binding[1].startsWith("style") ? "style" : binding[2])),
|
|
740
808
|
revision: () => busy ? -1 : revision,
|
|
741
809
|
afterPublication: (callback) => {
|
|
742
810
|
(publicationRetries ??= /* @__PURE__ */ new Set()).add(callback);
|
|
@@ -756,23 +824,17 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
756
824
|
for (let index = 0; index < bindings.length; index++) {
|
|
757
825
|
const binding = bindings[index];
|
|
758
826
|
const node = nodes[binding[0]];
|
|
759
|
-
if (node === void 0)
|
|
827
|
+
if (node === void 0)
|
|
828
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM binding targets an unknown element." : __octaneNoArgError(328));
|
|
760
829
|
owned.push([node, __claimBinding(node, binding)]);
|
|
761
830
|
if (binding[1] === "control") {
|
|
762
|
-
controls.set(
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
revision++;
|
|
770
|
-
signalUpdates.add(index);
|
|
771
|
-
drain();
|
|
772
|
-
}
|
|
773
|
-
})
|
|
774
|
-
)
|
|
775
|
-
);
|
|
831
|
+
controls.set(index, controlFactory.claim(node, binding[2], (0, import_read_protocol.forwardNativeTransitionConsumer)(refresh, () => {
|
|
832
|
+
if (!disposed) {
|
|
833
|
+
revision++;
|
|
834
|
+
signalUpdates.add(index);
|
|
835
|
+
drain();
|
|
836
|
+
}
|
|
837
|
+
})));
|
|
776
838
|
}
|
|
777
839
|
if (binding[1] === "classGroup") {
|
|
778
840
|
groups ??= /* @__PURE__ */ new Map();
|
|
@@ -782,9 +844,11 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
782
844
|
signal?.addEventListener("abort", dispose, { once: true });
|
|
783
845
|
const stop = source.subscribe(refresh);
|
|
784
846
|
if (typeof stop !== "function")
|
|
785
|
-
throw new TypeError("A DOM binding subscription must return a cleanup function.");
|
|
786
|
-
if (disposed)
|
|
787
|
-
|
|
847
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM binding subscription must return a cleanup function." : __octaneNoArgError(329));
|
|
848
|
+
if (disposed)
|
|
849
|
+
stop();
|
|
850
|
+
else
|
|
851
|
+
unsubscribe = stop;
|
|
788
852
|
busy = false;
|
|
789
853
|
refresh();
|
|
790
854
|
return handle;
|
|
@@ -798,9 +862,9 @@ function __adoptBindings(root, descriptor, source, options) {
|
|
|
798
862
|
}
|
|
799
863
|
function __adoptScalarBindings(root, descriptor, source, options) {
|
|
800
864
|
if (descriptor.addressed || descriptor.handoff || descriptor.connectProjection || !descriptor.bindings.every(isFixedScalarChannel))
|
|
801
|
-
throw new TypeError("This DOM binding view requires the general adopter.");
|
|
865
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "This DOM binding view requires the general adopter." : __octaneNoArgError(330));
|
|
802
866
|
if (!source || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function")
|
|
803
|
-
throw new TypeError("DOM bindings require synchronous getSnapshot() and subscribe() methods.");
|
|
867
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "DOM bindings require synchronous getSnapshot() and subscribe() methods." : __octaneNoArgError(325));
|
|
804
868
|
const nodes = resolveFixedNodes(root, descriptor);
|
|
805
869
|
const bindings = descriptor.bindings;
|
|
806
870
|
const owned = [];
|
|
@@ -815,7 +879,8 @@ function __adoptScalarBindings(root, descriptor, source, options) {
|
|
|
815
879
|
let unsubscribe;
|
|
816
880
|
const signal = options?.signal;
|
|
817
881
|
const dispose = () => {
|
|
818
|
-
if (disposed)
|
|
882
|
+
if (disposed)
|
|
883
|
+
return;
|
|
819
884
|
disposed = true;
|
|
820
885
|
signal?.removeEventListener("abort", dispose);
|
|
821
886
|
let failed = false;
|
|
@@ -832,37 +897,44 @@ function __adoptScalarBindings(root, descriptor, source, options) {
|
|
|
832
897
|
}
|
|
833
898
|
signalConnections?.clear();
|
|
834
899
|
signalUpdates?.clear();
|
|
835
|
-
for (let i = 0; i < owned.length; i++)
|
|
900
|
+
for (let i = 0; i < owned.length; i++)
|
|
901
|
+
__releaseBinding(owned[i][0], owned[i][1]);
|
|
836
902
|
owned.length = nodes.length = previous.length = 0;
|
|
837
903
|
const stop = unsubscribe;
|
|
838
904
|
unsubscribe = void 0;
|
|
839
905
|
try {
|
|
840
906
|
stop?.();
|
|
841
907
|
} catch (error) {
|
|
842
|
-
if (!failed)
|
|
908
|
+
if (!failed)
|
|
909
|
+
throw error;
|
|
843
910
|
}
|
|
844
|
-
if (failed)
|
|
911
|
+
if (failed)
|
|
912
|
+
throw failure;
|
|
845
913
|
};
|
|
846
914
|
const writePrepared = (next, indices) => {
|
|
847
915
|
for (let position = 0; position < (indices?.length ?? bindings.length) && !dirty && !disposed; position++) {
|
|
848
916
|
const i = indices ? indices[position] : position;
|
|
849
|
-
if (next[i] === previous[i])
|
|
917
|
+
if (next[i] === previous[i])
|
|
918
|
+
continue;
|
|
850
919
|
const binding = bindings[i];
|
|
851
920
|
writeFixedScalar(nodes[binding[0]], binding, next[i]);
|
|
852
921
|
if (!disposed) {
|
|
853
922
|
previous[i] = next[i];
|
|
854
923
|
const node = owned[i][0];
|
|
855
924
|
let claims2 = import_dom_binding_claims.domBindingClaims.get(node);
|
|
856
|
-
if (claims2 === void 0)
|
|
925
|
+
if (claims2 === void 0)
|
|
926
|
+
import_dom_binding_claims.domBindingClaims.set(node, claims2 = /* @__PURE__ */ new Map());
|
|
857
927
|
claims2.set(owned[i][1], next[i]);
|
|
858
928
|
}
|
|
859
929
|
}
|
|
860
930
|
};
|
|
861
931
|
const drain = (preview = false) => {
|
|
862
|
-
if (disposed)
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
932
|
+
if (disposed)
|
|
933
|
+
return;
|
|
934
|
+
if (busy)
|
|
935
|
+
return preview ? { validate: () => false, commit() {
|
|
936
|
+
}, discard() {
|
|
937
|
+
} } : void 0;
|
|
866
938
|
const version = revision;
|
|
867
939
|
const previousDirty = dirty;
|
|
868
940
|
const previousUpdates = preview && signalUpdates ? [...signalUpdates] : void 0;
|
|
@@ -871,13 +943,17 @@ function __adoptScalarBindings(root, descriptor, source, options) {
|
|
|
871
943
|
let accepted = false;
|
|
872
944
|
let retired = false;
|
|
873
945
|
const discard = preview ? () => {
|
|
874
|
-
if (accepted || retired)
|
|
946
|
+
if (accepted || retired)
|
|
947
|
+
return;
|
|
875
948
|
retired = true;
|
|
876
|
-
for (const receipt of receipts)
|
|
949
|
+
for (const receipt of receipts)
|
|
950
|
+
receipt.discard();
|
|
877
951
|
for (const [index, connection] of preparedSignals ?? [])
|
|
878
|
-
if (connection !== signalConnections?.get(index))
|
|
952
|
+
if (connection !== signalConnections?.get(index))
|
|
953
|
+
connection.dispose();
|
|
879
954
|
} : void 0;
|
|
880
|
-
if (preview)
|
|
955
|
+
if (preview)
|
|
956
|
+
dirty = true;
|
|
881
957
|
busy = true;
|
|
882
958
|
try {
|
|
883
959
|
while ((dirty || signalUpdates?.size) && !disposed) {
|
|
@@ -887,37 +963,39 @@ function __adoptScalarBindings(root, descriptor, source, options) {
|
|
|
887
963
|
dirty = false;
|
|
888
964
|
signalUpdates?.clear();
|
|
889
965
|
const snapshot = source.getSnapshot();
|
|
890
|
-
if (dirty || disposed)
|
|
966
|
+
if (dirty || disposed)
|
|
967
|
+
continue;
|
|
891
968
|
if (snapshot !== null && (typeof snapshot === "object" || typeof snapshot === "function") && typeof snapshot.then === "function" && !dirty && !disposed)
|
|
892
|
-
throw new TypeError("DOM bindings require a synchronous snapshot, not a thenable.");
|
|
893
|
-
if (dirty || disposed)
|
|
969
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "DOM bindings require a synchronous snapshot, not a thenable." : __octaneNoArgError(326));
|
|
970
|
+
if (dirty || disposed)
|
|
971
|
+
continue;
|
|
894
972
|
const values = descriptor.project(snapshot);
|
|
895
|
-
if (dirty || disposed)
|
|
973
|
+
if (dirty || disposed)
|
|
974
|
+
continue;
|
|
896
975
|
if (!Array.isArray(values) || values.length !== bindings.length)
|
|
897
|
-
throw new TypeError(
|
|
898
|
-
"A DOM binding projection must return its synchronous scalar values."
|
|
899
|
-
);
|
|
976
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM binding projection must return its synchronous scalar values." : __octaneNoArgError(327));
|
|
900
977
|
let resolved = values;
|
|
901
978
|
if (signalFactory && descriptor.signalIndices) {
|
|
902
979
|
for (const index of descriptor.signalIndices) {
|
|
903
|
-
if (disposed || dirty)
|
|
980
|
+
if (disposed || dirty)
|
|
981
|
+
break;
|
|
904
982
|
let connection = preparedSignals.get(index);
|
|
905
983
|
if (!connection && signalFactory.isSignal(values[index])) {
|
|
906
|
-
connection = signalFactory.connect(
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
})
|
|
914
|
-
);
|
|
984
|
+
connection = signalFactory.connect((0, import_read_protocol.forwardNativeTransitionConsumer)(refresh, () => {
|
|
985
|
+
if (!disposed) {
|
|
986
|
+
revision++;
|
|
987
|
+
signalUpdates.add(index);
|
|
988
|
+
drain();
|
|
989
|
+
}
|
|
990
|
+
}));
|
|
915
991
|
preparedSignals.set(index, connection);
|
|
916
992
|
}
|
|
917
993
|
if (connection) {
|
|
918
|
-
if (resolved === values)
|
|
994
|
+
if (resolved === values)
|
|
995
|
+
resolved = [...values];
|
|
919
996
|
const receipt = preview ? connection.preview(values[index]) : void 0;
|
|
920
|
-
if (receipt)
|
|
997
|
+
if (receipt)
|
|
998
|
+
receipts.push(receipt);
|
|
921
999
|
resolved[index] = receipt ? receipt.value : connection.read(values[index]);
|
|
922
1000
|
}
|
|
923
1001
|
}
|
|
@@ -928,20 +1006,15 @@ function __adoptScalarBindings(root, descriptor, source, options) {
|
|
|
928
1006
|
signalUpdates.clear();
|
|
929
1007
|
next = [];
|
|
930
1008
|
for (const index of indices)
|
|
931
|
-
next[index] = normalizeFixedScalar(
|
|
932
|
-
bindings[index],
|
|
933
|
-
signalConnections.get(index).get()
|
|
934
|
-
);
|
|
1009
|
+
next[index] = normalizeFixedScalar(bindings[index], signalConnections.get(index).get());
|
|
935
1010
|
}
|
|
936
1011
|
while (!preview && signalUpdates?.size && !dirty && !disposed) {
|
|
937
1012
|
const pending = [...signalUpdates];
|
|
938
1013
|
signalUpdates.clear();
|
|
939
1014
|
for (const index of pending) {
|
|
940
|
-
next[index] = normalizeFixedScalar(
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
);
|
|
944
|
-
if (indices && !indices.includes(index)) indices.push(index);
|
|
1015
|
+
next[index] = normalizeFixedScalar(bindings[index], signalConnections.get(index).get());
|
|
1016
|
+
if (indices && !indices.includes(index))
|
|
1017
|
+
indices.push(index);
|
|
945
1018
|
}
|
|
946
1019
|
}
|
|
947
1020
|
if (preview)
|
|
@@ -949,20 +1022,23 @@ function __adoptScalarBindings(root, descriptor, source, options) {
|
|
|
949
1022
|
validate: () => !retired && !disposed && revision === version && receipts.every((receipt) => receipt.validate()),
|
|
950
1023
|
discard,
|
|
951
1024
|
commit() {
|
|
952
|
-
if (disposed || retired || accepted)
|
|
1025
|
+
if (disposed || retired || accepted)
|
|
1026
|
+
return;
|
|
953
1027
|
accepted = true;
|
|
954
1028
|
busy = true;
|
|
955
1029
|
try {
|
|
956
1030
|
for (const [index, connection] of preparedSignals ?? [])
|
|
957
1031
|
signalConnections.set(index, connection);
|
|
958
|
-
for (const receipt of receipts)
|
|
1032
|
+
for (const receipt of receipts)
|
|
1033
|
+
receipt.commit();
|
|
959
1034
|
writePrepared(next, indices);
|
|
960
1035
|
} finally {
|
|
961
1036
|
busy = false;
|
|
962
1037
|
}
|
|
963
1038
|
}
|
|
964
1039
|
};
|
|
965
|
-
if (dirty || disposed)
|
|
1040
|
+
if (dirty || disposed)
|
|
1041
|
+
continue;
|
|
966
1042
|
writePrepared(next, indices);
|
|
967
1043
|
}
|
|
968
1044
|
} catch (error) {
|
|
@@ -978,13 +1054,15 @@ function __adoptScalarBindings(root, descriptor, source, options) {
|
|
|
978
1054
|
} finally {
|
|
979
1055
|
if (preview) {
|
|
980
1056
|
dirty ||= previousDirty;
|
|
981
|
-
for (const index of previousUpdates ?? [])
|
|
1057
|
+
for (const index of previousUpdates ?? [])
|
|
1058
|
+
signalUpdates.add(index);
|
|
982
1059
|
}
|
|
983
1060
|
busy = false;
|
|
984
1061
|
}
|
|
985
1062
|
};
|
|
986
1063
|
const refresh = () => {
|
|
987
|
-
if (disposed)
|
|
1064
|
+
if (disposed)
|
|
1065
|
+
return;
|
|
988
1066
|
revision++;
|
|
989
1067
|
dirty = true;
|
|
990
1068
|
drain();
|
|
@@ -1003,15 +1081,18 @@ function __adoptScalarBindings(root, descriptor, source, options) {
|
|
|
1003
1081
|
try {
|
|
1004
1082
|
for (let index = 0; index < bindings.length; index++) {
|
|
1005
1083
|
const node = nodes[bindings[index][0]];
|
|
1006
|
-
if (node === void 0)
|
|
1084
|
+
if (node === void 0)
|
|
1085
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM binding targets an unknown element." : __octaneNoArgError(328));
|
|
1007
1086
|
owned.push([node, __claimBinding(node, bindings[index])]);
|
|
1008
1087
|
}
|
|
1009
1088
|
signal?.addEventListener("abort", dispose, { once: true });
|
|
1010
1089
|
const stop = source.subscribe(refresh);
|
|
1011
1090
|
if (typeof stop !== "function")
|
|
1012
|
-
throw new TypeError("A DOM binding subscription must return a cleanup function.");
|
|
1013
|
-
if (disposed)
|
|
1014
|
-
|
|
1091
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM binding subscription must return a cleanup function." : __octaneNoArgError(329));
|
|
1092
|
+
if (disposed)
|
|
1093
|
+
stop();
|
|
1094
|
+
else
|
|
1095
|
+
unsubscribe = stop;
|
|
1015
1096
|
busy = false;
|
|
1016
1097
|
refresh();
|
|
1017
1098
|
return handle;
|