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
|
@@ -29,22 +29,29 @@ __export(dom_binding_handoff_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(dom_binding_handoff_exports);
|
|
31
31
|
var import_control_handoff = require("./signals/control-handoff.cjs");
|
|
32
|
+
function __octaneNoArgError(code) {
|
|
33
|
+
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.";
|
|
34
|
+
}
|
|
32
35
|
const events = /* @__PURE__ */ new WeakMap();
|
|
33
36
|
const delivered = /* @__PURE__ */ new WeakMap();
|
|
34
37
|
function registerBindingEvent(node, type) {
|
|
35
38
|
let counts = events.get(node);
|
|
36
|
-
if (counts === void 0)
|
|
39
|
+
if (counts === void 0)
|
|
40
|
+
events.set(node, counts = /* @__PURE__ */ new Map());
|
|
37
41
|
counts.set(type, (counts.get(type) ?? 0) + 1);
|
|
38
42
|
return () => {
|
|
39
43
|
const count = counts.get(type) - 1;
|
|
40
|
-
if (count === 0)
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
if (count === 0)
|
|
45
|
+
counts.delete(type);
|
|
46
|
+
else
|
|
47
|
+
counts.set(type, count);
|
|
48
|
+
if (counts.size === 0)
|
|
49
|
+
events.delete(node);
|
|
43
50
|
};
|
|
44
51
|
}
|
|
45
52
|
function claimBindingHandoff(lease, owner) {
|
|
46
53
|
if (!lease.active() || lease.owner !== void 0)
|
|
47
|
-
throw new Error("A DOM binding hydration lease must be active and have only one root owner.");
|
|
54
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "A DOM binding hydration lease must be active and have only one root owner." : __octaneNoArgError(277));
|
|
48
55
|
lease.owner = owner;
|
|
49
56
|
}
|
|
50
57
|
function releaseBindingHandoff(lease) {
|
|
@@ -52,7 +59,8 @@ function releaseBindingHandoff(lease) {
|
|
|
52
59
|
}
|
|
53
60
|
function hasBindingHandoffEvent(event) {
|
|
54
61
|
for (const node of event.composedPath()) {
|
|
55
|
-
if (events.get(node)?.has(event.type))
|
|
62
|
+
if (events.get(node)?.has(event.type))
|
|
63
|
+
return true;
|
|
56
64
|
}
|
|
57
65
|
return false;
|
|
58
66
|
}
|
|
@@ -61,10 +69,13 @@ function markBindingEvent(event, node, capture) {
|
|
|
61
69
|
if (nodes === void 0) {
|
|
62
70
|
delivered.set(event, nodes = /* @__PURE__ */ new Map());
|
|
63
71
|
const cleanup = () => {
|
|
64
|
-
if (delivered.get(event) === nodes)
|
|
72
|
+
if (delivered.get(event) === nodes)
|
|
73
|
+
delivered.delete(event);
|
|
65
74
|
};
|
|
66
|
-
if (event.isTrusted)
|
|
67
|
-
|
|
75
|
+
if (event.isTrusted)
|
|
76
|
+
setTimeout(cleanup, 0);
|
|
77
|
+
else
|
|
78
|
+
queueMicrotask(cleanup);
|
|
68
79
|
}
|
|
69
80
|
nodes.set(node, (nodes.get(node) ?? 0) | (capture ? 2 : 1));
|
|
70
81
|
}
|
|
@@ -72,9 +83,12 @@ function consumeBindingEvent(event, node, capture) {
|
|
|
72
83
|
const nodes = delivered.get(event);
|
|
73
84
|
const flags = nodes?.get(node) ?? 0;
|
|
74
85
|
const bit = capture ? 2 : 1;
|
|
75
|
-
if ((flags & bit) === 0)
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
if ((flags & bit) === 0)
|
|
87
|
+
return false;
|
|
88
|
+
if ((flags & ~bit) === 0)
|
|
89
|
+
nodes.delete(node);
|
|
90
|
+
else
|
|
91
|
+
nodes.set(node, flags & ~bit);
|
|
78
92
|
return true;
|
|
79
93
|
}
|
|
80
94
|
function beginBindingEvent(event) {
|
|
@@ -28,6 +28,9 @@ __export(dom_binding_protocol_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(dom_binding_protocol_exports);
|
|
30
30
|
var import_hydration_markers = require("./hydration-markers.cjs");
|
|
31
|
+
function __octaneNoArgError(code) {
|
|
32
|
+
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.";
|
|
33
|
+
}
|
|
31
34
|
const BINDING_OPEN_PREFIX = import_hydration_markers.HYDRATION_START + "b;";
|
|
32
35
|
const BINDING_RECEIPT = ";b;";
|
|
33
36
|
const BINDING_FOR_EMPTY_PREFIX = import_hydration_markers.HYDRATION_FOR_EMPTY + BINDING_RECEIPT;
|
|
@@ -42,25 +45,28 @@ function bindingRootMarker(id) {
|
|
|
42
45
|
function encodeBindingKey(key) {
|
|
43
46
|
if (typeof key === "string")
|
|
44
47
|
return "s:" + JSON.stringify(key).replace(/-/g, "\\u002d").replace(/</g, "\\u003c");
|
|
45
|
-
if (typeof key === "number" && Number.isFinite(key))
|
|
46
|
-
|
|
48
|
+
if (typeof key === "number" && Number.isFinite(key))
|
|
49
|
+
return "n:" + String(key);
|
|
50
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM presentation key must be a string or finite number." : __octaneNoArgError(306));
|
|
47
51
|
}
|
|
48
52
|
function decodeBindingKey(encoded) {
|
|
49
53
|
let key;
|
|
50
54
|
try {
|
|
51
55
|
key = JSON.parse(encoded.slice(2));
|
|
52
56
|
} catch {
|
|
53
|
-
throw new TypeError("A DOM presentation key has invalid serialized identity.");
|
|
57
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM presentation key has invalid serialized identity." : __octaneNoArgError(307));
|
|
54
58
|
}
|
|
55
59
|
if (encoded.startsWith("s:") && typeof key === "string" || encoded.startsWith("n:") && typeof key === "number" && Number.isFinite(key)) {
|
|
56
|
-
if (encodeBindingKey(key) === encoded)
|
|
60
|
+
if (encodeBindingKey(key) === encoded)
|
|
61
|
+
return key;
|
|
57
62
|
}
|
|
58
|
-
throw new TypeError("A DOM presentation key has invalid serialized identity.");
|
|
63
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM presentation key has invalid serialized identity." : __octaneNoArgError(307));
|
|
59
64
|
}
|
|
60
65
|
function parseBindingMarker(data) {
|
|
61
66
|
if (data.startsWith(BINDING_FOR_EMPTY_PREFIX) || data.startsWith(BINDING_FOR_ITEMS_PREFIX)) {
|
|
62
67
|
const separator = data.indexOf(";", BINDING_FOR_ID_START);
|
|
63
|
-
if (separator <= BINDING_FOR_ID_START || separator === data.length - 1)
|
|
68
|
+
if (separator <= BINDING_FOR_ID_START || separator === data.length - 1)
|
|
69
|
+
return null;
|
|
64
70
|
return {
|
|
65
71
|
id: data.slice(BINDING_FOR_ID_START, separator),
|
|
66
72
|
site: data.slice(separator + 1),
|
|
@@ -68,20 +74,27 @@ function parseBindingMarker(data) {
|
|
|
68
74
|
arm: data.charCodeAt(import_hydration_markers.HYDRATION_FOR_ARM_INDEX) - 48
|
|
69
75
|
};
|
|
70
76
|
}
|
|
71
|
-
if (!data.startsWith(BINDING_OPEN_PREFIX))
|
|
77
|
+
if (!data.startsWith(BINDING_OPEN_PREFIX))
|
|
78
|
+
return null;
|
|
72
79
|
const idEnd = data.indexOf(";", BINDING_ID_START);
|
|
73
|
-
if (idEnd <= BINDING_ID_START || idEnd === data.length - 1)
|
|
80
|
+
if (idEnd <= BINDING_ID_START || idEnd === data.length - 1)
|
|
81
|
+
return null;
|
|
74
82
|
const id = data.slice(BINDING_ID_START, idEnd);
|
|
75
83
|
if (data.slice(idEnd + 1) === BINDING_ROOT_SITE)
|
|
76
84
|
return { id, site: BINDING_ROOT_SITE, kind: "root" };
|
|
77
85
|
const siteEnd = data.indexOf(";", idEnd + 1);
|
|
78
|
-
if (siteEnd <= idEnd + 1 || siteEnd === data.length - 1)
|
|
86
|
+
if (siteEnd <= idEnd + 1 || siteEnd === data.length - 1)
|
|
87
|
+
return null;
|
|
79
88
|
const site = data.slice(idEnd + 1, siteEnd);
|
|
80
89
|
const kind = data.slice(siteEnd + 1);
|
|
81
|
-
if (kind === "t")
|
|
82
|
-
|
|
83
|
-
if (kind === "
|
|
84
|
-
|
|
90
|
+
if (kind === "t")
|
|
91
|
+
return { id, site, kind: "text" };
|
|
92
|
+
if (kind === "v")
|
|
93
|
+
return { id, site, kind: "view" };
|
|
94
|
+
if (kind === "s")
|
|
95
|
+
return { id, site, kind: "slot" };
|
|
96
|
+
if (kind === "o")
|
|
97
|
+
return { id, site, kind: "opaque" };
|
|
85
98
|
if (kind.startsWith("k;")) {
|
|
86
99
|
const key = kind.slice(2);
|
|
87
100
|
try {
|
|
@@ -93,21 +106,26 @@ function parseBindingMarker(data) {
|
|
|
93
106
|
}
|
|
94
107
|
if (/^(?:-1|0|[1-9]\d*)$/.test(kind)) {
|
|
95
108
|
const arm = Number(kind);
|
|
96
|
-
if (Number.isSafeInteger(arm))
|
|
109
|
+
if (Number.isSafeInteger(arm))
|
|
110
|
+
return { id, site, kind: "if", arm };
|
|
97
111
|
}
|
|
98
112
|
return null;
|
|
99
113
|
}
|
|
100
114
|
function isBindingOpenComment(data) {
|
|
101
115
|
const list = data.startsWith(BINDING_FOR_EMPTY_PREFIX) || data.startsWith(BINDING_FOR_ITEMS_PREFIX);
|
|
102
|
-
if (!list && !data.startsWith(BINDING_OPEN_PREFIX))
|
|
116
|
+
if (!list && !data.startsWith(BINDING_OPEN_PREFIX))
|
|
117
|
+
return false;
|
|
103
118
|
const idStart = list ? BINDING_FOR_ID_START : BINDING_ID_START;
|
|
104
119
|
const idEnd = data.indexOf(";", idStart);
|
|
105
|
-
if (idEnd <= idStart || idEnd === data.length - 1)
|
|
106
|
-
|
|
120
|
+
if (idEnd <= idStart || idEnd === data.length - 1)
|
|
121
|
+
return false;
|
|
122
|
+
if (list)
|
|
123
|
+
return data.indexOf(";", idEnd + 1) === -1;
|
|
107
124
|
if (data.length - idEnd === BINDING_ROOT_SUFFIX.length && data.endsWith(BINDING_ROOT_SUFFIX))
|
|
108
125
|
return true;
|
|
109
126
|
const siteEnd = data.indexOf(";", idEnd + 1);
|
|
110
|
-
if (siteEnd <= idEnd + 1 || siteEnd === data.length - 1)
|
|
127
|
+
if (siteEnd <= idEnd + 1 || siteEnd === data.length - 1)
|
|
128
|
+
return false;
|
|
111
129
|
const tail = siteEnd + 1;
|
|
112
130
|
if (data.length === tail + 1) {
|
|
113
131
|
const code = data.charCodeAt(tail);
|
|
@@ -115,11 +133,14 @@ function isBindingOpenComment(data) {
|
|
|
115
133
|
}
|
|
116
134
|
if (data.charCodeAt(tail) === 107 && data.charCodeAt(tail + 1) === 59)
|
|
117
135
|
return (data.charCodeAt(tail + 2) === 115 || data.charCodeAt(tail + 2) === 110) && data.charCodeAt(tail + 3) === 58 && data.length > tail + 4;
|
|
118
|
-
if (data.length === tail + 2 && data.endsWith("-1"))
|
|
119
|
-
|
|
136
|
+
if (data.length === tail + 2 && data.endsWith("-1"))
|
|
137
|
+
return true;
|
|
138
|
+
if (data.charCodeAt(tail) < 49 || data.charCodeAt(tail) > 57)
|
|
139
|
+
return false;
|
|
120
140
|
for (let index = tail + 1; index < data.length; index++) {
|
|
121
141
|
const code = data.charCodeAt(index);
|
|
122
|
-
if (code < 48 || code > 57)
|
|
142
|
+
if (code < 48 || code > 57)
|
|
143
|
+
return false;
|
|
123
144
|
}
|
|
124
145
|
return true;
|
|
125
146
|
}
|
|
@@ -27,6 +27,9 @@ var import_style_values = require("./style-values.cjs");
|
|
|
27
27
|
var import_dom_bindings = require("./dom-bindings.cjs");
|
|
28
28
|
var import_owner_context = require("./signals/owner-context.cjs");
|
|
29
29
|
var import_read_protocol = require("./signals/read-protocol.cjs");
|
|
30
|
+
function __octaneNoArgError(code) {
|
|
31
|
+
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.";
|
|
32
|
+
}
|
|
30
33
|
function __prepareBindingSources(reads, subscriptions, notify, active, run) {
|
|
31
34
|
const previous = new Map(subscriptions);
|
|
32
35
|
const acquired = /* @__PURE__ */ new Map();
|
|
@@ -35,50 +38,58 @@ function __prepareBindingSources(reads, subscriptions, notify, active, run) {
|
|
|
35
38
|
let invalid = false;
|
|
36
39
|
try {
|
|
37
40
|
for (const source of reads.keys()) {
|
|
38
|
-
if (previous.has(source))
|
|
41
|
+
if (previous.has(source))
|
|
42
|
+
continue;
|
|
39
43
|
let live = true;
|
|
40
|
-
const stop = run(
|
|
41
|
-
(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
44
|
+
const stop = run(() => source.subscribe((0, import_read_protocol.forwardNativeTransitionConsumer)(notify, () => {
|
|
45
|
+
if (!live || retired || !active())
|
|
46
|
+
return;
|
|
47
|
+
if (!accepted)
|
|
48
|
+
invalid = true;
|
|
49
|
+
else
|
|
50
|
+
notify();
|
|
51
|
+
})));
|
|
49
52
|
acquired.set(source, () => {
|
|
50
53
|
live = false;
|
|
51
54
|
stop();
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
57
|
} catch (error) {
|
|
55
|
-
for (const stop of acquired.values())
|
|
58
|
+
for (const stop of acquired.values())
|
|
59
|
+
stop();
|
|
56
60
|
throw error;
|
|
57
61
|
}
|
|
58
62
|
return {
|
|
59
63
|
validate: () => !retired && !invalid && active() && subscriptions.size === previous.size && [...previous].every(([source, stop]) => subscriptions.get(source) === stop) && [...reads].every(([source, version]) => source.getVersion() === version),
|
|
60
64
|
commit() {
|
|
61
|
-
if (accepted || retired || !active())
|
|
65
|
+
if (accepted || retired || !active())
|
|
66
|
+
return;
|
|
62
67
|
accepted = true;
|
|
63
|
-
for (const [source, stop] of acquired)
|
|
68
|
+
for (const [source, stop] of acquired)
|
|
69
|
+
subscriptions.set(source, stop);
|
|
64
70
|
for (const [source, stop] of previous) {
|
|
65
|
-
if (reads.has(source))
|
|
71
|
+
if (reads.has(source))
|
|
72
|
+
continue;
|
|
66
73
|
subscriptions.delete(source);
|
|
67
74
|
stop();
|
|
68
75
|
}
|
|
69
76
|
},
|
|
70
77
|
discard() {
|
|
71
|
-
if (accepted || retired)
|
|
78
|
+
if (accepted || retired)
|
|
79
|
+
return;
|
|
72
80
|
retired = true;
|
|
73
|
-
for (const stop of acquired.values())
|
|
81
|
+
for (const stop of acquired.values())
|
|
82
|
+
stop();
|
|
74
83
|
}
|
|
75
84
|
};
|
|
76
85
|
}
|
|
77
86
|
function __normalizeBindingStyle(value) {
|
|
78
|
-
if (value == null || value === false || value === "")
|
|
79
|
-
|
|
87
|
+
if (value == null || value === false || value === "")
|
|
88
|
+
return null;
|
|
89
|
+
if (typeof value === "string")
|
|
90
|
+
return value;
|
|
80
91
|
if (typeof value !== "object")
|
|
81
|
-
throw new TypeError("A whole-style DOM binding requires a style object, CSS text or null.");
|
|
92
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A whole-style DOM binding requires a style object, CSS text or null." : __octaneNoArgError(311));
|
|
82
93
|
const result = /* @__PURE__ */ Object.create(null);
|
|
83
94
|
for (const name in value) {
|
|
84
95
|
const property = value[name];
|
|
@@ -111,11 +122,10 @@ function __createBindingStyles() {
|
|
|
111
122
|
};
|
|
112
123
|
previous = snapshotDOM();
|
|
113
124
|
const get = () => {
|
|
114
|
-
if (disposed)
|
|
125
|
+
if (disposed)
|
|
126
|
+
return null;
|
|
115
127
|
const reads = /* @__PURE__ */ new Map();
|
|
116
|
-
const previousObserver = (0, import_read_protocol.setNativeReadObserver)(
|
|
117
|
-
(source, version) => reads.set(source, version)
|
|
118
|
-
);
|
|
128
|
+
const previousObserver = (0, import_read_protocol.setNativeReadObserver)((source, version) => reads.set(source, version));
|
|
119
129
|
const guard = (0, import_read_protocol.beginNativeWriteGuard)();
|
|
120
130
|
let value;
|
|
121
131
|
try {
|
|
@@ -125,36 +135,39 @@ function __createBindingStyles() {
|
|
|
125
135
|
(0, import_read_protocol.setNativeReadObserver)(previousObserver);
|
|
126
136
|
}
|
|
127
137
|
for (const [source, stop] of subscriptions) {
|
|
128
|
-
if (reads.has(source))
|
|
138
|
+
if (reads.has(source))
|
|
139
|
+
continue;
|
|
129
140
|
subscriptions.delete(source);
|
|
130
141
|
stop();
|
|
131
142
|
}
|
|
132
143
|
for (const [source, version] of reads) {
|
|
133
|
-
if (disposed)
|
|
144
|
+
if (disposed)
|
|
145
|
+
break;
|
|
134
146
|
if (!subscriptions.has(source)) {
|
|
135
147
|
let active = true;
|
|
136
|
-
const stop = run(
|
|
137
|
-
(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
})
|
|
141
|
-
)
|
|
142
|
-
);
|
|
148
|
+
const stop = run(() => source.subscribe((0, import_read_protocol.forwardNativeTransitionConsumer)(notify, () => {
|
|
149
|
+
if (active && !disposed)
|
|
150
|
+
notify();
|
|
151
|
+
})));
|
|
143
152
|
if (typeof stop !== "function")
|
|
144
|
-
throw new TypeError("A DOM style subscription must return cleanup.");
|
|
153
|
+
throw new TypeError(process.env.NODE_ENV !== "production" ? "A DOM style subscription must return cleanup." : __octaneNoArgError(312));
|
|
145
154
|
const disposeSource = () => {
|
|
146
155
|
active = false;
|
|
147
156
|
stop();
|
|
148
157
|
};
|
|
149
|
-
if (disposed)
|
|
150
|
-
|
|
158
|
+
if (disposed)
|
|
159
|
+
disposeSource();
|
|
160
|
+
else
|
|
161
|
+
subscriptions.set(source, disposeSource);
|
|
151
162
|
}
|
|
152
|
-
if (!disposed && source.getVersion() !== version)
|
|
163
|
+
if (!disposed && source.getVersion() !== version)
|
|
164
|
+
notify();
|
|
153
165
|
}
|
|
154
166
|
return value;
|
|
155
167
|
};
|
|
156
168
|
const writeProperty = (name, value) => {
|
|
157
|
-
if (disposed)
|
|
169
|
+
if (disposed)
|
|
170
|
+
return;
|
|
158
171
|
name = (0, import_style_values.hyphenateStyleName)(name);
|
|
159
172
|
const operation = [0, "styleProperty", name];
|
|
160
173
|
if (restoreStyles) {
|
|
@@ -170,17 +183,18 @@ function __createBindingStyles() {
|
|
|
170
183
|
(0, import_dom_bindings.__writeBinding)(node, operation, value);
|
|
171
184
|
};
|
|
172
185
|
const restore = () => {
|
|
173
|
-
if (!restorations)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
);
|
|
186
|
+
if (!restorations)
|
|
187
|
+
return;
|
|
188
|
+
const owned = [...restorations].filter((name) => style.getPropertyValue(name) === expected.style.getPropertyValue(name) && style.getPropertyPriority(name) === expected.style.getPropertyPriority(name));
|
|
177
189
|
let failed = false;
|
|
178
190
|
let failure;
|
|
179
191
|
for (const name of owned) {
|
|
180
192
|
try {
|
|
181
193
|
const value = baseline.style.getPropertyValue(name);
|
|
182
|
-
if (value === "")
|
|
183
|
-
|
|
194
|
+
if (value === "")
|
|
195
|
+
style.removeProperty(name);
|
|
196
|
+
else
|
|
197
|
+
style.setProperty(name, value, baseline.style.getPropertyPriority(name));
|
|
184
198
|
} catch (error) {
|
|
185
199
|
if (!failed) {
|
|
186
200
|
failed = true;
|
|
@@ -188,14 +202,16 @@ function __createBindingStyles() {
|
|
|
188
202
|
}
|
|
189
203
|
}
|
|
190
204
|
}
|
|
191
|
-
if (failed)
|
|
205
|
+
if (failed)
|
|
206
|
+
throw failure;
|
|
192
207
|
};
|
|
193
208
|
return {
|
|
194
209
|
get,
|
|
195
210
|
preview(value) {
|
|
196
211
|
const reads = /* @__PURE__ */ new Map();
|
|
197
212
|
const previousObserver = (0, import_read_protocol.setNativeReadObserver)((source, version) => {
|
|
198
|
-
if (!reads.has(source))
|
|
213
|
+
if (!reads.has(source))
|
|
214
|
+
reads.set(source, version);
|
|
199
215
|
});
|
|
200
216
|
const guard = (0, import_read_protocol.beginNativeWriteGuard)();
|
|
201
217
|
let projected;
|
|
@@ -205,13 +221,7 @@ function __createBindingStyles() {
|
|
|
205
221
|
(0, import_read_protocol.endNativeWriteGuard)(guard);
|
|
206
222
|
(0, import_read_protocol.setNativeReadObserver)(previousObserver);
|
|
207
223
|
}
|
|
208
|
-
const prepared = __prepareBindingSources(
|
|
209
|
-
reads,
|
|
210
|
-
subscriptions,
|
|
211
|
-
notify,
|
|
212
|
-
() => !disposed,
|
|
213
|
-
run
|
|
214
|
-
);
|
|
224
|
+
const prepared = __prepareBindingSources(reads, subscriptions, notify, () => !disposed, run);
|
|
215
225
|
return {
|
|
216
226
|
value: projected,
|
|
217
227
|
validate: prepared.validate,
|
|
@@ -227,7 +237,8 @@ function __createBindingStyles() {
|
|
|
227
237
|
return get();
|
|
228
238
|
},
|
|
229
239
|
write(value) {
|
|
230
|
-
if (disposed)
|
|
240
|
+
if (disposed)
|
|
241
|
+
return;
|
|
231
242
|
let next = value;
|
|
232
243
|
let old = typeof previous === "string" ? snapshotDOM() : previous;
|
|
233
244
|
const writeAll = firstWrite || typeof previous === "string" || typeof value === "string";
|
|
@@ -257,7 +268,8 @@ function __createBindingStyles() {
|
|
|
257
268
|
}
|
|
258
269
|
},
|
|
259
270
|
dispose(preservePresentation) {
|
|
260
|
-
if (disposed)
|
|
271
|
+
if (disposed)
|
|
272
|
+
return;
|
|
261
273
|
disposed = true;
|
|
262
274
|
raw = previous = null;
|
|
263
275
|
let failed = false;
|
|
@@ -278,7 +290,8 @@ function __createBindingStyles() {
|
|
|
278
290
|
subscriptions.clear();
|
|
279
291
|
restorations?.clear();
|
|
280
292
|
probe = baseline = expected = void 0;
|
|
281
|
-
if (failed)
|
|
293
|
+
if (failed)
|
|
294
|
+
throw failure;
|
|
282
295
|
}
|
|
283
296
|
};
|
|
284
297
|
}
|