marko 6.0.164 → 6.0.166
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/common/accessor.d.ts +22 -0
- package/dist/common/accessor.debug.d.ts +22 -0
- package/dist/common/helpers.d.ts +3 -2
- package/dist/common/types.d.ts +1 -1
- package/dist/debug/dom.js +1613 -2426
- package/dist/debug/dom.mjs +1517 -2404
- package/dist/debug/html.js +2437 -3356
- package/dist/debug/html.mjs +2360 -3264
- package/dist/dom/compat.d.ts +2 -1
- package/dist/dom/queue.d.ts +6 -6
- package/dist/dom/renderer.d.ts +9 -9
- package/dist/dom/signals.d.ts +5 -9
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +844 -1413
- package/dist/dom.mjs +840 -1394
- package/dist/html/template.d.ts +3 -3
- package/dist/html.js +1447 -2112
- package/dist/html.mjs +1443 -2022
- package/dist/translator/index.js +8046 -13063
- package/dist/translator/util/normalize-string-expression.d.ts +1 -1
- package/package.json +2 -2
package/dist/debug/dom.mjs
CHANGED
|
@@ -1,2682 +1,1795 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/common/attr-tag.ts
|
|
2
|
+
const empty = [];
|
|
3
|
+
const rest = Symbol("Attribute Tag");
|
|
4
4
|
function attrTag(attrs) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
attrs[Symbol.iterator] = attrTagIterator;
|
|
6
|
+
attrs[rest] = empty;
|
|
7
|
+
return attrs;
|
|
8
8
|
}
|
|
9
9
|
function attrTags(first, attrs) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return first;
|
|
17
|
-
}
|
|
18
|
-
return attrTag(attrs);
|
|
10
|
+
if (first) {
|
|
11
|
+
if (first[rest] === empty) first[rest] = [attrs];
|
|
12
|
+
else first[rest].push(attrs);
|
|
13
|
+
return first;
|
|
14
|
+
}
|
|
15
|
+
return attrTag(attrs);
|
|
19
16
|
}
|
|
20
17
|
function* attrTagIterator() {
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
yield this;
|
|
19
|
+
yield* this[rest];
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/common/errors.ts
|
|
26
23
|
function _el_read_error() {
|
|
27
|
-
|
|
28
|
-
throw new Error(
|
|
29
|
-
"Element references can only be read in scripts and event handlers."
|
|
30
|
-
);
|
|
31
|
-
}
|
|
24
|
+
throw new Error("Element references can only be read in scripts and event handlers.");
|
|
32
25
|
}
|
|
33
26
|
function _hoist_read_error() {
|
|
34
|
-
|
|
35
|
-
throw new Error(
|
|
36
|
-
"Hoisted values can only be read in scripts and event handlers."
|
|
37
|
-
);
|
|
38
|
-
}
|
|
27
|
+
throw new Error("Hoisted values can only be read in scripts and event handlers.");
|
|
39
28
|
}
|
|
40
29
|
function _assert_hoist(value) {
|
|
41
|
-
|
|
42
|
-
throw new Error(
|
|
43
|
-
`Hoisted values must be functions, received type "${typeof value}".`
|
|
44
|
-
);
|
|
45
|
-
}
|
|
30
|
+
if (typeof value !== "function") throw new Error(`Hoisted values must be functions, received type "${typeof value}".`);
|
|
46
31
|
}
|
|
47
32
|
function _assert_init(scope, accessor) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
__UNINITIALIZED__;
|
|
51
|
-
const __UNINITIALIZED__ = 1;
|
|
52
|
-
} catch (err) {
|
|
53
|
-
err.message = err.message.replaceAll("__UNINITIALIZED__", accessor);
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
throw new ReferenceError(
|
|
57
|
-
`Cannot access "${accessor}" before initialization.`
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
return scope[accessor];
|
|
33
|
+
if (scope["#Creating"] || !(accessor in scope)) throw new ReferenceError(`Cannot access "${accessor}" before initialization.`);
|
|
34
|
+
return scope[accessor];
|
|
61
35
|
}
|
|
62
36
|
function assertExclusiveAttrs(attrs, onError = throwErr) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
exclusiveAttrs.push("checked");
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (attrs.valueChange) {
|
|
80
|
-
(exclusiveAttrs ||= []).push("valueChange");
|
|
81
|
-
}
|
|
82
|
-
if (exclusiveAttrs && exclusiveAttrs.length > 1) {
|
|
83
|
-
onError(
|
|
84
|
-
`The attributes ${joinWithAnd(exclusiveAttrs)} are mutually exclusive.`
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
37
|
+
if (attrs) {
|
|
38
|
+
let exclusiveAttrs;
|
|
39
|
+
if (attrs.checkedChange) (exclusiveAttrs ||= []).push("checkedChange");
|
|
40
|
+
if (attrs.checkedValue) {
|
|
41
|
+
(exclusiveAttrs ||= []).push("checkedValue");
|
|
42
|
+
if (attrs.checked) exclusiveAttrs.push("checked");
|
|
43
|
+
} else if (attrs.checkedValueChange) {
|
|
44
|
+
(exclusiveAttrs ||= []).push("checkedValueChange");
|
|
45
|
+
if (attrs.checked) exclusiveAttrs.push("checked");
|
|
46
|
+
}
|
|
47
|
+
if (attrs.valueChange) (exclusiveAttrs ||= []).push("valueChange");
|
|
48
|
+
if (exclusiveAttrs && exclusiveAttrs.length > 1) onError(`The attributes ${joinWithAnd(exclusiveAttrs)} are mutually exclusive.`);
|
|
49
|
+
}
|
|
88
50
|
}
|
|
89
51
|
function assertValidTagName(tagName) {
|
|
90
|
-
|
|
91
|
-
throw new Error(
|
|
92
|
-
`Invalid tag name: "${tagName}". Tag names must start with a letter and contain only letters, numbers, periods, hyphens, and underscores.`
|
|
93
|
-
);
|
|
94
|
-
}
|
|
52
|
+
if (!/^[a-z][a-z0-9._-]*$/i.test(tagName)) throw new Error(`Invalid tag name: "${tagName}". Tag names must start with a letter and contain only letters, numbers, periods, hyphens, and underscores.`);
|
|
95
53
|
}
|
|
96
54
|
function throwErr(msg) {
|
|
97
|
-
|
|
55
|
+
throw new Error(msg);
|
|
98
56
|
}
|
|
99
57
|
function joinWithAnd(a) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// src/common/for.ts
|
|
58
|
+
switch (a.length) {
|
|
59
|
+
case 0: return "";
|
|
60
|
+
case 1: return a[0];
|
|
61
|
+
case 2: return `${a[0]} and ${a[1]}`;
|
|
62
|
+
default: return `${a.slice(0, -1).join(", ")}, and ${a[a.length - 1]}`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/common/for.ts
|
|
113
67
|
function forIn(obj, cb) {
|
|
114
|
-
|
|
115
|
-
cb(key, obj[key]);
|
|
116
|
-
}
|
|
68
|
+
for (const key in obj) cb(key, obj[key]);
|
|
117
69
|
}
|
|
118
70
|
function forOf(list, cb) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
}
|
|
71
|
+
if (list) {
|
|
72
|
+
let i = 0;
|
|
73
|
+
for (const item of list) cb(item, i++);
|
|
74
|
+
}
|
|
125
75
|
}
|
|
126
76
|
function forTo(to, from, step, cb) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
cb(start + i * delta);
|
|
131
|
-
}
|
|
77
|
+
const start = from || 0;
|
|
78
|
+
const delta = step || 1;
|
|
79
|
+
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
132
80
|
}
|
|
133
81
|
function forUntil(until, from, step, cb) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
cb(start + i * delta);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// src/common/helpers.ts
|
|
142
|
-
var htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
143
|
-
function _call(fn, v) {
|
|
144
|
-
fn(v);
|
|
145
|
-
return v;
|
|
82
|
+
const start = from || 0;
|
|
83
|
+
const delta = step || 1;
|
|
84
|
+
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
146
85
|
}
|
|
147
|
-
|
|
148
|
-
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/common/helpers.ts
|
|
88
|
+
const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
89
|
+
function _call(fn, v) {
|
|
90
|
+
fn(v);
|
|
91
|
+
return v;
|
|
149
92
|
}
|
|
150
93
|
function stringifyClassObject(name, value) {
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
function styleValue(styleValue2) {
|
|
154
|
-
return toDelimitedString(styleValue2, ";", stringifyStyleObject);
|
|
94
|
+
return value ? name : "";
|
|
155
95
|
}
|
|
156
96
|
function stringifyStyleObject(name, value) {
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
function toDelimitedString(val, delimiter, stringify) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return str;
|
|
185
|
-
}
|
|
97
|
+
return value || value === 0 ? name + ":" + value : "";
|
|
98
|
+
}
|
|
99
|
+
const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
|
|
100
|
+
let str = "";
|
|
101
|
+
let sep = "";
|
|
102
|
+
let part;
|
|
103
|
+
if (val) if (typeof val !== "object") str += val;
|
|
104
|
+
else if (Array.isArray(val)) for (const v of val) {
|
|
105
|
+
part = toDelimitedString(v, delimiter, stringify);
|
|
106
|
+
if (part) {
|
|
107
|
+
str += sep + part;
|
|
108
|
+
sep = delimiter;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else for (const name in val) {
|
|
112
|
+
part = stringify(name, val[name]);
|
|
113
|
+
if (part) {
|
|
114
|
+
str += sep + part;
|
|
115
|
+
sep = delimiter;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return str;
|
|
119
|
+
};
|
|
186
120
|
function isEventHandler(name) {
|
|
187
|
-
|
|
121
|
+
return /^on[A-Z-]/.test(name);
|
|
188
122
|
}
|
|
189
123
|
function getEventHandlerName(name) {
|
|
190
|
-
|
|
124
|
+
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
191
125
|
}
|
|
192
126
|
function normalizeDynamicRenderer(value) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
var DEFAULT_RENDER_ID = "_";
|
|
205
|
-
var DYNAMIC_TAG_SCRIPT_REGISTER_ID = true ? "_dynamicTagScript" : "d";
|
|
206
|
-
|
|
207
|
-
// src/common/opt.ts
|
|
127
|
+
if (value) {
|
|
128
|
+
if (typeof value === "string") return value;
|
|
129
|
+
const normalized = value.content || value.default || value;
|
|
130
|
+
if ("id" in normalized) return normalized;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/common/meta.ts
|
|
135
|
+
const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/common/opt.ts
|
|
208
138
|
function toArray(opt) {
|
|
209
|
-
|
|
139
|
+
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
210
140
|
}
|
|
211
141
|
function push(opt, item) {
|
|
212
|
-
|
|
142
|
+
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
213
143
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/dom/event.ts
|
|
146
|
+
const defaultDelegator = /* @__PURE__ */ createDelegator();
|
|
217
147
|
function _on(element, type, handler) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
element["$" + type] = handler || null;
|
|
148
|
+
if (element["$" + type] === void 0) defaultDelegator(element, type, handleDelegated);
|
|
149
|
+
element["$" + type] = handler || null;
|
|
222
150
|
}
|
|
151
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
223
152
|
function createDelegator() {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
153
|
+
const kEvents = Symbol();
|
|
154
|
+
return function ensureDelegated(node, type, handler) {
|
|
155
|
+
((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, true), 1);
|
|
156
|
+
};
|
|
228
157
|
}
|
|
229
158
|
function handleDelegated(ev) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (updatedValue.startsWith(before)) return initialPosition;
|
|
264
|
-
if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
|
|
265
|
-
let count = before.replace(R, "").length;
|
|
266
|
-
let pos = 0;
|
|
267
|
-
while (count && updatedValue[pos]) {
|
|
268
|
-
if (updatedValue[pos++].replace(R, "")) count--;
|
|
269
|
-
}
|
|
270
|
-
return pos;
|
|
271
|
-
}
|
|
272
|
-
return -1;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// src/dom/parse-html.ts
|
|
276
|
-
var parsers = {};
|
|
159
|
+
let target = !rendering && ev.target;
|
|
160
|
+
Object.defineProperty(ev, "currentTarget", {
|
|
161
|
+
configurable: true,
|
|
162
|
+
get() {
|
|
163
|
+
console.error("Event.currentTarget is not supported in Marko's delegated events. Instead use an element reference or the second parameter of the event handler.");
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
while (target) {
|
|
168
|
+
target["$" + ev.type]?.(ev, target);
|
|
169
|
+
target = ev.bubbles && !ev.cancelBubble && target.parentNode;
|
|
170
|
+
}
|
|
171
|
+
delete ev.currentTarget;
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/dom/resolve-cursor-position.ts
|
|
175
|
+
const R = /[^\p{L}\p{N}]/gu;
|
|
176
|
+
function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
|
|
177
|
+
if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
|
|
178
|
+
const before = initialValue.slice(0, initialPosition);
|
|
179
|
+
const after = initialValue.slice(initialPosition);
|
|
180
|
+
if (updatedValue.startsWith(before)) return initialPosition;
|
|
181
|
+
if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
|
|
182
|
+
let count = before.replace(R, "").length;
|
|
183
|
+
let pos = 0;
|
|
184
|
+
while (count && updatedValue[pos]) if (updatedValue[pos++].replace(R, "")) count--;
|
|
185
|
+
return pos;
|
|
186
|
+
}
|
|
187
|
+
return -1;
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/dom/parse-html.ts
|
|
191
|
+
const parsers = {};
|
|
277
192
|
function parseHTML(html, ns) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
193
|
+
const parser = parsers[ns] ||= document.createElementNS(ns, "template");
|
|
194
|
+
parser.innerHTML = html;
|
|
195
|
+
return parser.content || parser;
|
|
281
196
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/dom/scope.ts
|
|
199
|
+
let nextScopeId = 1e6;
|
|
285
200
|
function createScope($global, closestBranch) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
201
|
+
const scope = {
|
|
202
|
+
["#Id"]: nextScopeId++,
|
|
203
|
+
["#Creating"]: 1,
|
|
204
|
+
["#ClosestBranch"]: closestBranch,
|
|
205
|
+
["$global"]: $global
|
|
206
|
+
};
|
|
207
|
+
pendingScopes.push(scope);
|
|
208
|
+
return scope;
|
|
294
209
|
}
|
|
295
210
|
function skipScope() {
|
|
296
|
-
|
|
211
|
+
return nextScopeId++;
|
|
297
212
|
}
|
|
298
213
|
function findBranchWithKey(scope, key) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
return branch;
|
|
214
|
+
let branch = scope["#ClosestBranch"];
|
|
215
|
+
while (branch && branch[key] == null) branch = branch["#ParentBranch"];
|
|
216
|
+
return branch;
|
|
304
217
|
}
|
|
305
218
|
function destroyBranch(branch) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
);
|
|
309
|
-
destroyNestedScopes(branch);
|
|
219
|
+
branch["#ParentBranch"]?.["#BranchScopes"]?.delete(branch);
|
|
220
|
+
destroyNestedScopes(branch);
|
|
310
221
|
}
|
|
311
222
|
function destroyScope(scope) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
function destroyNestedScopes(scope) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
223
|
+
if (!scope["#Destroyed"]) {
|
|
224
|
+
destroyNestedScopes(scope);
|
|
225
|
+
resetControllers(scope);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const destroyNestedScopes = function destroyNestedScopes(scope) {
|
|
229
|
+
scope["#Destroyed"] = 1;
|
|
230
|
+
scope["#BranchScopes"]?.forEach(destroyNestedScopes);
|
|
231
|
+
scope["#AbortScopes"]?.forEach(resetControllers);
|
|
232
|
+
};
|
|
322
233
|
function resetControllers(scope) {
|
|
323
|
-
|
|
324
|
-
$signalReset(scope, id);
|
|
325
|
-
}
|
|
234
|
+
for (const id in scope["#AbortControllers"]) $signalReset(scope, id);
|
|
326
235
|
}
|
|
327
236
|
function removeAndDestroyBranch(branch) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
branch["#StartNode" /* StartNode */],
|
|
331
|
-
branch["#EndNode" /* EndNode */]
|
|
332
|
-
);
|
|
237
|
+
destroyBranch(branch);
|
|
238
|
+
removeChildNodes(branch["#StartNode"], branch["#EndNode"]);
|
|
333
239
|
}
|
|
334
240
|
function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
335
|
-
|
|
336
|
-
parentNode,
|
|
337
|
-
nextSibling,
|
|
338
|
-
branch["#StartNode" /* StartNode */],
|
|
339
|
-
branch["#EndNode" /* EndNode */]
|
|
340
|
-
);
|
|
241
|
+
insertChildNodes(parentNode, nextSibling, branch["#StartNode"], branch["#EndNode"]);
|
|
341
242
|
}
|
|
342
243
|
function tempDetachBranch(branch) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
// src/dom/schedule.ts
|
|
354
|
-
var runTask;
|
|
355
|
-
var isScheduled;
|
|
356
|
-
var channel;
|
|
244
|
+
const fragment = new DocumentFragment();
|
|
245
|
+
fragment.namespaceURI = branch["#StartNode"].parentNode.namespaceURI;
|
|
246
|
+
insertChildNodes(fragment, null, branch["#StartNode"], branch["#EndNode"]);
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/dom/schedule.ts
|
|
250
|
+
let runTask;
|
|
251
|
+
let isScheduled;
|
|
252
|
+
let channel;
|
|
357
253
|
function schedule() {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
isScheduled = 1;
|
|
368
|
-
queueMicrotask(flushAndWaitFrame);
|
|
369
|
-
}
|
|
254
|
+
if (!isScheduled) {
|
|
255
|
+
if (console.createTask) {
|
|
256
|
+
const task = console.createTask("queue");
|
|
257
|
+
runTask = () => task.run(run);
|
|
258
|
+
} else runTask = run;
|
|
259
|
+
isScheduled = 1;
|
|
260
|
+
queueMicrotask(flushAndWaitFrame);
|
|
261
|
+
}
|
|
370
262
|
}
|
|
371
263
|
function flushAndWaitFrame() {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
} else {
|
|
375
|
-
run();
|
|
376
|
-
}
|
|
377
|
-
requestAnimationFrame(triggerMacroTask);
|
|
264
|
+
runTask();
|
|
265
|
+
requestAnimationFrame(triggerMacroTask);
|
|
378
266
|
}
|
|
379
267
|
function triggerMacroTask() {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
// src/dom/signals.ts
|
|
268
|
+
if (!channel) {
|
|
269
|
+
channel = new MessageChannel();
|
|
270
|
+
channel.port1.onmessage = () => {
|
|
271
|
+
isScheduled = 0;
|
|
272
|
+
{
|
|
273
|
+
const run = runTask;
|
|
274
|
+
runTask = void 0;
|
|
275
|
+
run();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
channel.port2.postMessage(0);
|
|
280
|
+
}
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/dom/signals.ts
|
|
397
283
|
function _let(id, fn) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
return value;
|
|
416
|
-
};
|
|
284
|
+
const valueAccessor = id.slice(0, id.lastIndexOf("/"));
|
|
285
|
+
const valueChangeAccessor = "TagVariableChange:" + valueAccessor;
|
|
286
|
+
id = +id.slice(id.lastIndexOf("/") + 1);
|
|
287
|
+
return (scope, value, valueChange) => {
|
|
288
|
+
if (rendering) {
|
|
289
|
+
if ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value || scope["#Creating"]) {
|
|
290
|
+
scope[valueAccessor] = value;
|
|
291
|
+
fn?.(scope);
|
|
292
|
+
}
|
|
293
|
+
} else if (scope[valueChangeAccessor]) scope[valueChangeAccessor](value);
|
|
294
|
+
else if (scope[valueAccessor] !== (scope[valueAccessor] = value) && fn) {
|
|
295
|
+
schedule();
|
|
296
|
+
queueRender(scope, fn, id);
|
|
297
|
+
}
|
|
298
|
+
return value;
|
|
299
|
+
};
|
|
417
300
|
}
|
|
418
301
|
function _const(valueAccessor, fn) {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
if (id in scope) {
|
|
434
|
-
if (!--scope[id]) {
|
|
435
|
-
fn(scope);
|
|
436
|
-
}
|
|
437
|
-
} else {
|
|
438
|
-
scope[id] = defaultPending;
|
|
439
|
-
}
|
|
440
|
-
} else {
|
|
441
|
-
queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
442
|
-
}
|
|
443
|
-
};
|
|
302
|
+
return (scope, value) => {
|
|
303
|
+
if (!(valueAccessor in scope) || scope[valueAccessor] !== value) {
|
|
304
|
+
scope[valueAccessor] = value;
|
|
305
|
+
fn?.(scope);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
|
|
310
|
+
return (scope) => {
|
|
311
|
+
if (scope["#Creating"]) if (id in scope) {
|
|
312
|
+
if (!--scope[id]) fn(scope);
|
|
313
|
+
} else scope[id] = defaultPending;
|
|
314
|
+
else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
315
|
+
};
|
|
444
316
|
}
|
|
445
317
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
for (const scope of scopes) {
|
|
456
|
-
if (!scope["#Creating" /* Creating */] && !scope["#Destroyed" /* Destroyed */]) {
|
|
457
|
-
fn(scope);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
},
|
|
461
|
-
-1,
|
|
462
|
-
0,
|
|
463
|
-
scopes[0]["#Id" /* Id */]
|
|
464
|
-
);
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
ownerSignal._ = fn;
|
|
468
|
-
return ownerSignal;
|
|
318
|
+
const scopeAccessor = "BranchScopes:" + ownerLoopNodeAccessor;
|
|
319
|
+
const ownerSignal = (ownerScope) => {
|
|
320
|
+
const scopes = toArray(ownerScope[scopeAccessor]);
|
|
321
|
+
if (scopes.length) queueRender(ownerScope, () => {
|
|
322
|
+
for (const scope of scopes) if (!scope["#Creating"] && !scope["#Destroyed"]) fn(scope);
|
|
323
|
+
}, -1, 0, scopes[0]["#Id"]);
|
|
324
|
+
};
|
|
325
|
+
ownerSignal._ = fn;
|
|
326
|
+
return ownerSignal;
|
|
469
327
|
}
|
|
470
328
|
function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
if (ifScope && !ifScope["#Creating" /* Creating */] && (scope[branchAccessor] || 0) === branch) {
|
|
480
|
-
queueRender(ifScope, fn, -1);
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
ownerSignal._ = fn;
|
|
484
|
-
return ownerSignal;
|
|
329
|
+
const scopeAccessor = "BranchScopes:" + ownerConditionalNodeAccessor;
|
|
330
|
+
const branchAccessor = "ConditionalRenderer:" + ownerConditionalNodeAccessor;
|
|
331
|
+
const ownerSignal = (scope) => {
|
|
332
|
+
const ifScope = scope[scopeAccessor];
|
|
333
|
+
if (ifScope && !ifScope["#Creating"] && (scope[branchAccessor] || 0) === branch) queueRender(ifScope, fn, -1);
|
|
334
|
+
};
|
|
335
|
+
ownerSignal._ = fn;
|
|
336
|
+
return ownerSignal;
|
|
485
337
|
}
|
|
486
338
|
function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
() => ownerScope[accessor].delete(scope)
|
|
493
|
-
);
|
|
494
|
-
}
|
|
339
|
+
const subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
|
|
340
|
+
if (!subscribers.has(scope)) {
|
|
341
|
+
subscribers.add(scope);
|
|
342
|
+
$signal(scope, -1).addEventListener("abort", () => ownerScope[accessor].delete(scope));
|
|
343
|
+
}
|
|
495
344
|
}
|
|
496
345
|
function _closure(...closureSignals) {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
childScope,
|
|
507
|
-
closureSignals[childScope[___signalIndexAccessor] || 0],
|
|
508
|
-
-1
|
|
509
|
-
);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
};
|
|
346
|
+
const [firstSignal] = closureSignals;
|
|
347
|
+
const scopeInstances = firstSignal["scopeInstancesAccessor"];
|
|
348
|
+
const signalIndex = firstSignal["signalIndexAccessor"];
|
|
349
|
+
for (let i = closureSignals.length; i--;) closureSignals[i]["index"] = i;
|
|
350
|
+
return (scope) => {
|
|
351
|
+
if (scope[scopeInstances]) {
|
|
352
|
+
for (const childScope of scope[scopeInstances]) if (!childScope["#Creating"]) queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
514
355
|
}
|
|
515
356
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
});
|
|
526
|
-
closureSignal.___scopeInstancesAccessor = "ClosureScopes:" /* ClosureScopes */ + valueAccessor;
|
|
527
|
-
closureSignal.___signalIndexAccessor = "ClosureSignalIndex:" /* ClosureSignalIndex */ + valueAccessor;
|
|
528
|
-
resumeId && _resume(resumeId, closureSignal);
|
|
529
|
-
return closureSignal;
|
|
357
|
+
const closureSignal = ((scope) => {
|
|
358
|
+
scope[closureSignal["signalIndexAccessor"]] = closureSignal["index"];
|
|
359
|
+
fn(scope);
|
|
360
|
+
subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope["_"], closureSignal["scopeInstancesAccessor"], scope);
|
|
361
|
+
});
|
|
362
|
+
closureSignal["scopeInstancesAccessor"] = "ClosureScopes:" + valueAccessor;
|
|
363
|
+
closureSignal["signalIndexAccessor"] = "ClosureSignalIndex:" + valueAccessor;
|
|
364
|
+
resumeId && _resume(resumeId, closureSignal);
|
|
365
|
+
return closureSignal;
|
|
530
366
|
}
|
|
531
367
|
function _child_setup(setup) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
368
|
+
setup._ = (scope, owner) => {
|
|
369
|
+
scope["_"] = owner;
|
|
370
|
+
queueRender(scope, setup, -1);
|
|
371
|
+
};
|
|
372
|
+
return setup;
|
|
537
373
|
}
|
|
538
374
|
function _var(scope, childAccessor, signal) {
|
|
539
|
-
|
|
375
|
+
scope[childAccessor]["#TagVariable"] = (value) => signal(scope, value);
|
|
540
376
|
}
|
|
541
|
-
|
|
377
|
+
const _return = (scope, value) => scope["#TagVariable"]?.(value);
|
|
542
378
|
function _return_change(scope, changeHandler) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
function _id({ ["$global" /* Global */]: $global }) {
|
|
555
|
-
const id = tagIdsByGlobal.get($global) || 0;
|
|
556
|
-
tagIdsByGlobal.set($global, id + 1);
|
|
557
|
-
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
|
379
|
+
if (changeHandler) scope["#TagVariableChange"] = changeHandler;
|
|
380
|
+
}
|
|
381
|
+
const _var_change = (scope, value, name = "This") => {
|
|
382
|
+
if (typeof scope["#TagVariableChange"] !== "function") throw new TypeError(`${name} is a readonly tag variable.`);
|
|
383
|
+
scope["#TagVariableChange"](value);
|
|
384
|
+
};
|
|
385
|
+
const tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
|
386
|
+
function _id({ ["$global"]: $global }) {
|
|
387
|
+
const id = tagIdsByGlobal.get($global) || 0;
|
|
388
|
+
tagIdsByGlobal.set($global, id + 1);
|
|
389
|
+
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
|
558
390
|
}
|
|
559
391
|
function _script(id, fn) {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
392
|
+
_resume(id, fn);
|
|
393
|
+
return (scope) => {
|
|
394
|
+
queueEffect(scope, fn);
|
|
395
|
+
};
|
|
564
396
|
}
|
|
565
397
|
function _el_read(value) {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
return value;
|
|
398
|
+
if (rendering) _el_read_error();
|
|
399
|
+
return value;
|
|
570
400
|
}
|
|
571
401
|
function* traverse(scope, path, i = path.length - 1) {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
580
|
-
} else {
|
|
581
|
-
const item = scope[path[i]];
|
|
582
|
-
if (i) {
|
|
583
|
-
yield* traverse(item, path, i - 1);
|
|
584
|
-
} else {
|
|
585
|
-
yield typeof item === "function" ? item() : item;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
402
|
+
if (rendering) _hoist_read_error();
|
|
403
|
+
if (scope) if (Symbol.iterator in scope) for (const childScope of scope.values()) yield* traverse(childScope, path, i);
|
|
404
|
+
else {
|
|
405
|
+
const item = scope[path[i]];
|
|
406
|
+
if (i) yield* traverse(item, path, i - 1);
|
|
407
|
+
else yield typeof item === "function" ? item() : item;
|
|
408
|
+
}
|
|
589
409
|
}
|
|
590
410
|
function _hoist(...path) {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
return fn;
|
|
597
|
-
};
|
|
411
|
+
return (scope) => {
|
|
412
|
+
const fn = () => traverse(scope, path).next().value;
|
|
413
|
+
fn[Symbol.iterator] = () => traverse(scope, path);
|
|
414
|
+
return fn;
|
|
415
|
+
};
|
|
598
416
|
}
|
|
599
417
|
function _hoist_resume(id, ...path) {
|
|
600
|
-
|
|
418
|
+
return _resume(id, _hoist(...path));
|
|
601
419
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/dom/walker.ts
|
|
422
|
+
const walker = /* @__PURE__ */ document.createTreeWalker(document);
|
|
605
423
|
function walk(startNode, walkCodes, branch) {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
while (value--) {
|
|
645
|
-
walker.nextNode();
|
|
646
|
-
}
|
|
647
|
-
} else if (value < 106 /* OverEnd */ + 1) {
|
|
648
|
-
value = 10 /* Over */ * currentMultiplier + value - 97 /* Over */;
|
|
649
|
-
while (value--) {
|
|
650
|
-
walker.nextSibling();
|
|
651
|
-
}
|
|
652
|
-
} else if (value < 116 /* OutEnd */ + 1) {
|
|
653
|
-
value = 10 /* Out */ * currentMultiplier + value - 107 /* Out */;
|
|
654
|
-
while (value--) {
|
|
655
|
-
walker.parentNode();
|
|
656
|
-
}
|
|
657
|
-
walker.nextSibling();
|
|
658
|
-
} else {
|
|
659
|
-
if (value < 117 /* Multiplier */ || value > 126 /* MultiplierEnd */) {
|
|
660
|
-
throw new Error(`Unknown walk code: ${value}`);
|
|
661
|
-
}
|
|
662
|
-
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value - 117 /* Multiplier */;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
424
|
+
walker.currentNode = startNode;
|
|
425
|
+
walkInternal(0, walkCodes, branch);
|
|
426
|
+
}
|
|
427
|
+
const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
428
|
+
let value;
|
|
429
|
+
let currentMultiplier;
|
|
430
|
+
let storedMultiplier = 0;
|
|
431
|
+
let currentScopeIndex = 0;
|
|
432
|
+
for (; currentWalkIndex < walkCodes.length;) {
|
|
433
|
+
value = walkCodes.charCodeAt(currentWalkIndex++);
|
|
434
|
+
currentMultiplier = storedMultiplier;
|
|
435
|
+
storedMultiplier = 0;
|
|
436
|
+
if (value === 32) {
|
|
437
|
+
const node = walker.currentNode;
|
|
438
|
+
scope[getDebugKey(currentScopeIndex++, node)] = node;
|
|
439
|
+
} else if (value === 37 || value === 49) {
|
|
440
|
+
walker.currentNode.replaceWith(walker.currentNode = scope[getDebugKey(currentScopeIndex++, "#text")] = new Text());
|
|
441
|
+
if (value === 49) scope[getDebugKey(currentScopeIndex++, "#scopeOffset")] = skipScope();
|
|
442
|
+
} else if (value === 38) return currentWalkIndex;
|
|
443
|
+
else if (value === 47 || value === 48) {
|
|
444
|
+
currentWalkIndex = walkInternal(currentWalkIndex, walkCodes, scope[getDebugKey(currentScopeIndex++, "#childScope")] = createScope(scope["$global"], scope["#ClosestBranch"]));
|
|
445
|
+
if (value === 48) scope[getDebugKey(currentScopeIndex++, "#scopeOffset")] = skipScope();
|
|
446
|
+
} else if (value < 92) {
|
|
447
|
+
value = 20 * currentMultiplier + value - 67;
|
|
448
|
+
while (value--) walker.nextNode();
|
|
449
|
+
} else if (value < 107) {
|
|
450
|
+
value = 10 * currentMultiplier + value - 97;
|
|
451
|
+
while (value--) walker.nextSibling();
|
|
452
|
+
} else if (value < 117) {
|
|
453
|
+
value = 10 * currentMultiplier + value - 107;
|
|
454
|
+
while (value--) walker.parentNode();
|
|
455
|
+
walker.nextSibling();
|
|
456
|
+
} else {
|
|
457
|
+
if (value < 117 || value > 126) throw new Error(`Unknown walk code: ${value}`);
|
|
458
|
+
storedMultiplier = currentMultiplier * 10 + value - 117;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
};
|
|
666
462
|
function getDebugKey(index, node) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
}
|
|
676
|
-
return index;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
// src/dom/renderer.ts
|
|
463
|
+
if (typeof node === "string") return `${node}/${index}`;
|
|
464
|
+
else if (node.nodeType === 3) return `#text/${index}`;
|
|
465
|
+
else if (node.nodeType === 8) return `#comment/${index}`;
|
|
466
|
+
else if (node.nodeType === 1) return `#${node.tagName.toLowerCase()}/${index}`;
|
|
467
|
+
return index;
|
|
468
|
+
}
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/dom/renderer.ts
|
|
680
471
|
function createBranch($global, renderer, parentScope, parentNode) {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
renderer.___clone?.(
|
|
688
|
-
branch,
|
|
689
|
-
parentNode.namespaceURI
|
|
690
|
-
);
|
|
691
|
-
return branch;
|
|
472
|
+
const branch = createScope($global);
|
|
473
|
+
branch["_"] = renderer["owner"] || parentScope;
|
|
474
|
+
setParentBranch(branch, parentScope?.["#ClosestBranch"]);
|
|
475
|
+
branch["#Renderer"] = renderer;
|
|
476
|
+
renderer["clone"]?.(branch, parentNode.namespaceURI);
|
|
477
|
+
return branch;
|
|
692
478
|
}
|
|
693
479
|
function setParentBranch(branch, parentBranch) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
480
|
+
if (parentBranch) {
|
|
481
|
+
branch["#ParentBranch"] = parentBranch;
|
|
482
|
+
(parentBranch["#BranchScopes"] ||= /* @__PURE__ */ new Set()).add(branch);
|
|
483
|
+
}
|
|
484
|
+
branch["#ClosestBranch"] = branch;
|
|
699
485
|
}
|
|
700
486
|
function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
701
|
-
|
|
702
|
-
renderer,
|
|
703
|
-
createBranch($global, renderer, parentScope, parentNode)
|
|
704
|
-
);
|
|
487
|
+
return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
|
|
705
488
|
}
|
|
706
489
|
function setupBranch(renderer, branch) {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
}
|
|
710
|
-
return branch;
|
|
490
|
+
if (renderer["setup"]) queueRender(branch, renderer["setup"], -1);
|
|
491
|
+
return branch;
|
|
711
492
|
}
|
|
712
493
|
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
___clone: clone,
|
|
732
|
-
___owner: owner,
|
|
733
|
-
___setup: setup,
|
|
734
|
-
___params: params,
|
|
735
|
-
___accessor: dynamicScopesAccessor
|
|
736
|
-
};
|
|
737
|
-
};
|
|
494
|
+
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
|
495
|
+
setup = setup ? setup._ || setup : void 0;
|
|
496
|
+
params ||= void 0;
|
|
497
|
+
const clone = template ? (branch, ns) => {
|
|
498
|
+
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
|
|
499
|
+
} : (branch) => {
|
|
500
|
+
walk(branch["#StartNode"] = branch["#EndNode"] = new Text(), walks, branch);
|
|
501
|
+
};
|
|
502
|
+
return (owner) => {
|
|
503
|
+
return {
|
|
504
|
+
["id"]: id,
|
|
505
|
+
["clone"]: clone,
|
|
506
|
+
["owner"]: owner,
|
|
507
|
+
["setup"]: setup,
|
|
508
|
+
["params"]: params,
|
|
509
|
+
["accessor"]: dynamicScopesAccessor
|
|
510
|
+
};
|
|
511
|
+
};
|
|
738
512
|
}
|
|
739
513
|
function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
740
|
-
|
|
741
|
-
id,
|
|
742
|
-
_content(id, template, walks, setup, params, dynamicScopesAccessor)
|
|
743
|
-
);
|
|
514
|
+
return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
|
|
744
515
|
}
|
|
745
516
|
function _content_closures(renderer, closureFns) {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
}
|
|
757
|
-
var cloneCache = {};
|
|
517
|
+
const closureSignals = {};
|
|
518
|
+
for (const key in closureFns) closureSignals[key] = _const(key, closureFns[key]);
|
|
519
|
+
return (owner, closureValues) => {
|
|
520
|
+
const instance = renderer(owner);
|
|
521
|
+
instance["localClosures"] = closureSignals;
|
|
522
|
+
instance["localClosureValues"] = closureValues;
|
|
523
|
+
return instance;
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
const cloneCache = {};
|
|
758
527
|
function createCloneableHTML(html, ns) {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
var curRuntimeId;
|
|
779
|
-
var readyLookup;
|
|
780
|
-
var branchesEnabled;
|
|
781
|
-
var embedEnabled;
|
|
528
|
+
const { firstChild, lastChild } = parseHTML(html, ns);
|
|
529
|
+
const parent = document.createElementNS(ns, "t");
|
|
530
|
+
insertChildNodes(parent, null, firstChild, lastChild);
|
|
531
|
+
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
|
|
532
|
+
walk(branch["#StartNode"] = branch["#EndNode"] = firstChild.cloneNode(true), walks, branch);
|
|
533
|
+
} : (branch, walks) => {
|
|
534
|
+
const clone = parent.cloneNode(true);
|
|
535
|
+
walk(clone.firstChild, walks, branch);
|
|
536
|
+
branch["#StartNode"] = clone.firstChild;
|
|
537
|
+
branch["#EndNode"] = clone.lastChild;
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
//#endregion
|
|
541
|
+
//#region src/dom/resume.ts
|
|
542
|
+
const registeredValues = {};
|
|
543
|
+
let curRuntimeId;
|
|
544
|
+
let readyLookup;
|
|
545
|
+
let branchesEnabled;
|
|
546
|
+
let embedEnabled;
|
|
782
547
|
function enableBranches() {
|
|
783
|
-
|
|
548
|
+
branchesEnabled = 1;
|
|
784
549
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
550
|
+
const ready = /* @__PURE__ */ ((_) => (id) => {
|
|
551
|
+
readyLookup[id]?.();
|
|
552
|
+
readyLookup[id] = 1;
|
|
788
553
|
})(readyLookup = {});
|
|
789
554
|
function initEmbedded(readyId, runtimeId) {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
lastEffect = registeredValues[lastToken];
|
|
936
|
-
} else {
|
|
937
|
-
effects.push(lastEffect, getScope(lastToken));
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
} else {
|
|
941
|
-
for (const scope of serialized(serializeContext)) {
|
|
942
|
-
if (!$global) {
|
|
943
|
-
$global = scope || {};
|
|
944
|
-
$global.runtimeId = runtimeId;
|
|
945
|
-
$global.renderId = renderId;
|
|
946
|
-
} else if (typeof scope === "number") {
|
|
947
|
-
lastScopeId += scope;
|
|
948
|
-
} else {
|
|
949
|
-
scopeLookup[scope["#Id" /* Id */] = ++lastScopeId] = scope;
|
|
950
|
-
scope["$global" /* Global */] = $global;
|
|
951
|
-
if (branchesEnabled) {
|
|
952
|
-
scope["#ClosestBranch" /* ClosestBranch */] = getScope(
|
|
953
|
-
scope["#ClosestBranchId" /* ClosestBranchId */]
|
|
954
|
-
);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
for (visit of visits = render.v) {
|
|
961
|
-
lastTokenIndex = render.i.length;
|
|
962
|
-
visitText = visit.data;
|
|
963
|
-
visitType = visitText[lastTokenIndex++];
|
|
964
|
-
visitScope = getScope(nextToken(
|
|
965
|
-
/* read scope id */
|
|
966
|
-
));
|
|
967
|
-
if (visitType === "*" /* Node */) {
|
|
968
|
-
const prev = visit.previousSibling;
|
|
969
|
-
visitScope[nextToken(
|
|
970
|
-
/* read accessor */
|
|
971
|
-
)] = prev && (prev.nodeType < 8 || prev.data) ? prev : visit.parentNode.insertBefore(new Text(), visit);
|
|
972
|
-
} else if (branchesEnabled) {
|
|
973
|
-
visitBranches();
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
if (embedEnabled) {
|
|
977
|
-
render.n ||= visit?.parentNode.insertBefore(
|
|
978
|
-
new Text(),
|
|
979
|
-
visit.nextSibling
|
|
980
|
-
);
|
|
981
|
-
}
|
|
982
|
-
visits.length = resumes.length = 0;
|
|
983
|
-
return effects;
|
|
984
|
-
};
|
|
985
|
-
render.w = () => {
|
|
986
|
-
walk2();
|
|
987
|
-
runResumeEffects(render);
|
|
988
|
-
};
|
|
989
|
-
return render;
|
|
990
|
-
})
|
|
991
|
-
});
|
|
992
|
-
};
|
|
993
|
-
if (renders) {
|
|
994
|
-
initRuntime(renders);
|
|
995
|
-
for (const renderId in renders) {
|
|
996
|
-
runResumeEffects(resumeRender(renderId));
|
|
997
|
-
}
|
|
998
|
-
} else {
|
|
999
|
-
defineRuntime({
|
|
1000
|
-
configurable: true,
|
|
1001
|
-
set: initRuntime
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
var isResuming;
|
|
555
|
+
embedEnabled = 1;
|
|
556
|
+
ready(readyId);
|
|
557
|
+
init(runtimeId);
|
|
558
|
+
new MutationObserver(() => {
|
|
559
|
+
const renders = self[curRuntimeId];
|
|
560
|
+
for (const renderId in renders) {
|
|
561
|
+
const { s, n } = renders[renderId];
|
|
562
|
+
if (n && !n.isConnected) {
|
|
563
|
+
delete renders[renderId];
|
|
564
|
+
for (const id in s) destroyScope(s[id]);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}).observe(document.body, {
|
|
568
|
+
childList: true,
|
|
569
|
+
subtree: true
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
function init(runtimeId = "M") {
|
|
573
|
+
if (curRuntimeId) {
|
|
574
|
+
if (curRuntimeId !== runtimeId) throw new Error(`Marko initialized multiple times with different $global.runtimeId's of ${JSON.stringify(runtimeId)} and ${JSON.stringify(curRuntimeId)}.`);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
curRuntimeId = runtimeId;
|
|
578
|
+
let resumeRender;
|
|
579
|
+
const renders = self[runtimeId];
|
|
580
|
+
const defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc);
|
|
581
|
+
const initRuntime = (renders) => {
|
|
582
|
+
defineRuntime({ value: resumeRender = ((renderId) => {
|
|
583
|
+
const render = resumeRender[renderId] = renders[renderId] || renders(renderId);
|
|
584
|
+
const walk = render.w;
|
|
585
|
+
const scopeLookup = render.s = {};
|
|
586
|
+
const getScope = (id) => scopeLookup[id] ||= { ["#Id"]: +id };
|
|
587
|
+
const serializeContext = { _: registeredValues };
|
|
588
|
+
const visitBranches = branchesEnabled && ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => {
|
|
589
|
+
return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
590
|
+
if (visitType !== "[") {
|
|
591
|
+
visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
|
|
592
|
+
accessor = "BranchScopes:" + lastToken;
|
|
593
|
+
singleNode = visitType !== "]" && visitType !== ")";
|
|
594
|
+
nextToken();
|
|
595
|
+
}
|
|
596
|
+
while (branchId = +lastToken) {
|
|
597
|
+
(endedBranches ||= []).push(branch = getScope(branchId));
|
|
598
|
+
setParentBranch(branch, branch["#ClosestBranch"]);
|
|
599
|
+
if (branch["#AwaitCounter"] = render.p?.[branchId]) branch["#AwaitCounter"].m = render.m;
|
|
600
|
+
if (singleNode) {
|
|
601
|
+
while (startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling));
|
|
602
|
+
branch["#EndNode"] = branch["#StartNode"] = startVisit;
|
|
603
|
+
if (visitType === "'") branch[getDebugKey(0, startVisit)] = startVisit;
|
|
604
|
+
} else {
|
|
605
|
+
curBranchScopes = push(curBranchScopes, branch);
|
|
606
|
+
if (accessor) {
|
|
607
|
+
visitScope[accessor] = curBranchScopes;
|
|
608
|
+
curBranchScopes = branchScopesStack.pop();
|
|
609
|
+
}
|
|
610
|
+
startVisit = branchStarts.pop();
|
|
611
|
+
if (parent !== startVisit.parentNode) parent.prepend(startVisit);
|
|
612
|
+
branch["#StartNode"] = startVisit;
|
|
613
|
+
branch["#EndNode"] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
614
|
+
}
|
|
615
|
+
while (i && orphanBranches[--i]["#Id"] > branchId) setParentBranch(orphanBranches.pop(), branch);
|
|
616
|
+
nextToken();
|
|
617
|
+
}
|
|
618
|
+
if (endedBranches) {
|
|
619
|
+
orphanBranches.push(...endedBranches);
|
|
620
|
+
if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
|
|
621
|
+
}
|
|
622
|
+
if (visitType === "[") {
|
|
623
|
+
if (!endedBranches) {
|
|
624
|
+
branchScopesStack.push(curBranchScopes);
|
|
625
|
+
curBranchScopes = void 0;
|
|
626
|
+
}
|
|
627
|
+
branchStarts.push(visit);
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
})();
|
|
631
|
+
const nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
|
|
632
|
+
let $global;
|
|
633
|
+
let lastEffect;
|
|
634
|
+
let visits;
|
|
635
|
+
let resumes;
|
|
636
|
+
let visit;
|
|
637
|
+
let visitText;
|
|
638
|
+
let visitType;
|
|
639
|
+
let visitScope;
|
|
640
|
+
let lastToken;
|
|
641
|
+
let lastTokenIndex;
|
|
642
|
+
let lastScopeId = 0;
|
|
643
|
+
if (render.m) throw new Error(`Marko rendered multiple times with $global.runtimeId as ${JSON.stringify(runtimeId)} and $global.renderId as ${JSON.stringify(renderId)}. Ensure each render into a page has a unique $global.renderId.`);
|
|
644
|
+
render.m = (effects = []) => {
|
|
645
|
+
if (readyLookup) {
|
|
646
|
+
for (const readyId in render.b) if (readyLookup[readyId] !== 1) {
|
|
647
|
+
readyLookup[readyId] = ((prev) => () => {
|
|
648
|
+
render.m();
|
|
649
|
+
prev?.();
|
|
650
|
+
})(readyLookup[readyId]);
|
|
651
|
+
return effects;
|
|
652
|
+
}
|
|
653
|
+
render.b = 0;
|
|
654
|
+
}
|
|
655
|
+
for (const serialized of resumes = render.r || []) if (typeof serialized === "string") {
|
|
656
|
+
lastTokenIndex = 0;
|
|
657
|
+
visitText = serialized;
|
|
658
|
+
while (nextToken()) if (/\D/.test(lastToken)) lastEffect = registeredValues[lastToken];
|
|
659
|
+
else effects.push(lastEffect, getScope(lastToken));
|
|
660
|
+
} else for (const scope of serialized(serializeContext)) if (!$global) {
|
|
661
|
+
$global = scope || {};
|
|
662
|
+
$global.runtimeId = runtimeId;
|
|
663
|
+
$global.renderId = renderId;
|
|
664
|
+
} else if (typeof scope === "number") lastScopeId += scope;
|
|
665
|
+
else {
|
|
666
|
+
scopeLookup[scope["#Id"] = ++lastScopeId] = scope;
|
|
667
|
+
scope["$global"] = $global;
|
|
668
|
+
if (branchesEnabled) scope["#ClosestBranch"] = getScope(scope["#ClosestBranchId"]);
|
|
669
|
+
}
|
|
670
|
+
for (visit of visits = render.v) {
|
|
671
|
+
lastTokenIndex = render.i.length;
|
|
672
|
+
visitText = visit.data;
|
|
673
|
+
visitType = visitText[lastTokenIndex++];
|
|
674
|
+
visitScope = getScope(nextToken());
|
|
675
|
+
if (visitType === "*") {
|
|
676
|
+
const prev = visit.previousSibling;
|
|
677
|
+
visitScope[nextToken()] = prev && (prev.nodeType < 8 || prev.data) ? prev : visit.parentNode.insertBefore(new Text(), visit);
|
|
678
|
+
} else if (branchesEnabled) visitBranches();
|
|
679
|
+
}
|
|
680
|
+
if (embedEnabled) render.n ||= visit?.parentNode.insertBefore(new Text(), visit.nextSibling);
|
|
681
|
+
visits.length = resumes.length = 0;
|
|
682
|
+
return effects;
|
|
683
|
+
};
|
|
684
|
+
render.w = () => {
|
|
685
|
+
walk();
|
|
686
|
+
runResumeEffects(render);
|
|
687
|
+
};
|
|
688
|
+
return render;
|
|
689
|
+
}) });
|
|
690
|
+
};
|
|
691
|
+
if (renders) {
|
|
692
|
+
initRuntime(renders);
|
|
693
|
+
for (const renderId in renders) runResumeEffects(resumeRender(renderId));
|
|
694
|
+
} else defineRuntime({
|
|
695
|
+
configurable: true,
|
|
696
|
+
set: initRuntime
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
let isResuming;
|
|
1006
700
|
function runResumeEffects(render) {
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
701
|
+
try {
|
|
702
|
+
isResuming = 1;
|
|
703
|
+
runEffects(render.m(), 1);
|
|
704
|
+
} finally {
|
|
705
|
+
isResuming = 0;
|
|
706
|
+
}
|
|
1013
707
|
}
|
|
1014
708
|
function getRegisteredWithScope(id, scope) {
|
|
1015
|
-
|
|
1016
|
-
|
|
709
|
+
const val = registeredValues[id];
|
|
710
|
+
return scope ? val(scope) : val;
|
|
1017
711
|
}
|
|
1018
712
|
function _resume(id, obj) {
|
|
1019
|
-
|
|
713
|
+
return registeredValues[id] = obj;
|
|
1020
714
|
}
|
|
1021
715
|
function _var_resume(id, signal) {
|
|
1022
|
-
|
|
1023
|
-
|
|
716
|
+
_resume(id, (scope) => (value) => signal(scope, value));
|
|
717
|
+
return signal;
|
|
1024
718
|
}
|
|
1025
719
|
function _el(id, accessor) {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
// src/dom/controllable.ts
|
|
1035
|
-
var inputType = "";
|
|
1036
|
-
var controllableDelegate = createDelegator();
|
|
720
|
+
return _resume(id, (scope) => () => _el_read(scope[accessor]));
|
|
721
|
+
}
|
|
722
|
+
//#endregion
|
|
723
|
+
//#region src/dom/controllable.ts
|
|
724
|
+
let inputType = "";
|
|
725
|
+
const controllableDelegate = /* @__PURE__ */ createDelegator();
|
|
1037
726
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
727
|
+
const el = scope[nodeAccessor];
|
|
728
|
+
const normalizedChecked = normalizeBoolProp(checked);
|
|
729
|
+
if (el.defaultChecked !== normalizedChecked) {
|
|
730
|
+
const restoreValue = scope["#Creating"] ? normalizedChecked : el.checked;
|
|
731
|
+
el.defaultChecked = normalizedChecked;
|
|
732
|
+
if (restoreValue !== normalizedChecked) el.checked = restoreValue;
|
|
733
|
+
}
|
|
1047
734
|
}
|
|
1048
735
|
function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
} else {
|
|
1056
|
-
_attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
|
|
1057
|
-
}
|
|
736
|
+
const el = scope[nodeAccessor];
|
|
737
|
+
const normalizedChecked = normalizeBoolProp(checked);
|
|
738
|
+
scope["ControlledHandler:" + nodeAccessor] = checkedChange;
|
|
739
|
+
scope["ControlledType:" + nodeAccessor] = checkedChange ? 0 : 5;
|
|
740
|
+
if (checkedChange && !scope["#Creating"]) el.checked = normalizedChecked;
|
|
741
|
+
else _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
|
|
1058
742
|
}
|
|
1059
743
|
function _attr_input_checked_script(scope, nodeAccessor) {
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
744
|
+
const el = scope[nodeAccessor];
|
|
745
|
+
syncControllableFormInput(el, hasCheckboxChanged, () => {
|
|
746
|
+
const checkedChange = scope["ControlledHandler:" + nodeAccessor];
|
|
747
|
+
if (checkedChange) {
|
|
748
|
+
const newValue = el.checked;
|
|
749
|
+
el.checked = !newValue;
|
|
750
|
+
checkedChange(newValue);
|
|
751
|
+
run();
|
|
752
|
+
}
|
|
753
|
+
});
|
|
1070
754
|
}
|
|
1071
755
|
function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value) {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
scope,
|
|
1078
|
-
nodeAccessor,
|
|
1079
|
-
multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue
|
|
1080
|
-
);
|
|
756
|
+
const multiple = Array.isArray(checkedValue);
|
|
757
|
+
const normalizedValue = normalizeStrProp(value);
|
|
758
|
+
const normalizedCheckedValue = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
759
|
+
_attr(scope[nodeAccessor], "value", normalizedValue);
|
|
760
|
+
_attr_input_checked_default(scope, nodeAccessor, multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue);
|
|
1081
761
|
}
|
|
1082
762
|
function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
} else {
|
|
1093
|
-
_attr_input_checkedValue_default(
|
|
1094
|
-
scope,
|
|
1095
|
-
nodeAccessor,
|
|
1096
|
-
normalizedCheckedValue,
|
|
1097
|
-
normalizedValue
|
|
1098
|
-
);
|
|
1099
|
-
}
|
|
763
|
+
const el = scope[nodeAccessor];
|
|
764
|
+
const multiple = Array.isArray(checkedValue);
|
|
765
|
+
const normalizedValue = normalizeStrProp(value);
|
|
766
|
+
const normalizedCheckedValue = scope["ControlledValue:" + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
767
|
+
_attr(el, "value", normalizedValue);
|
|
768
|
+
scope["ControlledHandler:" + nodeAccessor] = checkedValueChange;
|
|
769
|
+
scope["ControlledType:" + nodeAccessor] = checkedValueChange ? 1 : 5;
|
|
770
|
+
if (checkedValueChange && !scope["#Creating"]) el.checked = multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue;
|
|
771
|
+
else _attr_input_checkedValue_default(scope, nodeAccessor, normalizedCheckedValue, normalizedValue);
|
|
1100
772
|
}
|
|
1101
773
|
function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
if (el.name && el.type[0] === "r") {
|
|
1118
|
-
for (const radio of el.getRootNode().querySelectorAll(
|
|
1119
|
-
`[type=radio][name=${CSS.escape(el.name)}]`
|
|
1120
|
-
)) {
|
|
1121
|
-
if (radio.form === el.form) {
|
|
1122
|
-
radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value;
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
} else {
|
|
1126
|
-
el.checked = !el.checked;
|
|
1127
|
-
}
|
|
1128
|
-
checkedValueChange(newValue);
|
|
1129
|
-
run();
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
774
|
+
const el = scope[nodeAccessor];
|
|
775
|
+
if (isResuming && el.defaultChecked) if (scope["ControlledValue:" + nodeAccessor]) scope["ControlledValue:" + nodeAccessor].push(el.value);
|
|
776
|
+
else scope["ControlledValue:" + nodeAccessor] = el.value;
|
|
777
|
+
syncControllableFormInput(el, hasCheckboxChanged, () => {
|
|
778
|
+
const checkedValueChange = scope["ControlledHandler:" + nodeAccessor];
|
|
779
|
+
if (checkedValueChange) {
|
|
780
|
+
const oldValue = scope["ControlledValue:" + nodeAccessor];
|
|
781
|
+
const newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
|
|
782
|
+
if (el.name && el.type[0] === "r") {
|
|
783
|
+
for (const radio of el.getRootNode().querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) if (radio.form === el.form) radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value;
|
|
784
|
+
} else el.checked = !el.checked;
|
|
785
|
+
checkedValueChange(newValue);
|
|
786
|
+
run();
|
|
787
|
+
}
|
|
788
|
+
});
|
|
1132
789
|
}
|
|
1133
790
|
function _attr_input_value_default(scope, nodeAccessor, value) {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
791
|
+
const el = scope[nodeAccessor];
|
|
792
|
+
const normalizedValue = normalizeStrProp(value);
|
|
793
|
+
if (el.defaultValue !== normalizedValue) {
|
|
794
|
+
const restoreValue = scope["#Creating"] ? normalizedValue : el.value;
|
|
795
|
+
el.defaultValue = normalizedValue;
|
|
796
|
+
setInputValue(el, restoreValue);
|
|
797
|
+
}
|
|
1141
798
|
}
|
|
1142
799
|
function _attr_input_value(scope, nodeAccessor, value, valueChange) {
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
} else {
|
|
1151
|
-
_attr_input_value_default(scope, nodeAccessor, normalizedValue);
|
|
1152
|
-
}
|
|
800
|
+
const el = scope[nodeAccessor];
|
|
801
|
+
const normalizedValue = normalizeStrProp(value);
|
|
802
|
+
scope["ControlledHandler:" + nodeAccessor] = valueChange;
|
|
803
|
+
scope["ControlledValue:" + nodeAccessor] = normalizedValue;
|
|
804
|
+
scope["ControlledType:" + nodeAccessor] = valueChange ? 2 : 5;
|
|
805
|
+
if (valueChange && !scope["#Creating"]) setInputValue(el, normalizedValue);
|
|
806
|
+
else _attr_input_value_default(scope, nodeAccessor, normalizedValue);
|
|
1153
807
|
}
|
|
1154
808
|
function _attr_input_value_script(scope, nodeAccessor) {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
}
|
|
1168
|
-
});
|
|
809
|
+
const el = scope[nodeAccessor];
|
|
810
|
+
if (isResuming) scope["ControlledValue:" + nodeAccessor] = el.defaultValue;
|
|
811
|
+
syncControllableFormInput(el, hasValueChanged, (ev) => {
|
|
812
|
+
const valueChange = scope["ControlledHandler:" + nodeAccessor];
|
|
813
|
+
if (valueChange) {
|
|
814
|
+
inputType = ev?.inputType;
|
|
815
|
+
valueChange(el.value);
|
|
816
|
+
run();
|
|
817
|
+
setInputValue(el, scope["ControlledValue:" + nodeAccessor]);
|
|
818
|
+
inputType = "";
|
|
819
|
+
}
|
|
820
|
+
});
|
|
1169
821
|
}
|
|
1170
822
|
function setInputValue(el, value) {
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
el.value,
|
|
1176
|
-
el.value = value
|
|
1177
|
-
);
|
|
1178
|
-
if (~updatedPosition) {
|
|
1179
|
-
el.setSelectionRange(updatedPosition, updatedPosition);
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
823
|
+
if (el.value !== value) {
|
|
824
|
+
const updatedPosition = resolveCursorPosition(inputType, el.getRootNode().activeElement === el && el.selectionStart, el.value, el.value = value);
|
|
825
|
+
if (~updatedPosition) el.setSelectionRange(updatedPosition, updatedPosition);
|
|
826
|
+
}
|
|
1182
827
|
}
|
|
1183
828
|
function _attr_select_value_default(scope, nodeAccessor, value) {
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
if (restoreValue !== void 0) {
|
|
1200
|
-
setSelectValue(el, restoreValue, multiple);
|
|
1201
|
-
}
|
|
1202
|
-
}, scope);
|
|
829
|
+
let restoreValue;
|
|
830
|
+
const el = scope[nodeAccessor];
|
|
831
|
+
const existing = !scope["#Creating"];
|
|
832
|
+
const multiple = Array.isArray(value);
|
|
833
|
+
const normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
834
|
+
pendingEffects.unshift(() => {
|
|
835
|
+
for (const opt of el.options) {
|
|
836
|
+
const selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
|
|
837
|
+
if (opt.defaultSelected !== selected) {
|
|
838
|
+
if (existing) restoreValue ??= getSelectValue(el, multiple);
|
|
839
|
+
opt.defaultSelected = selected;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
if (restoreValue !== void 0) setSelectValue(el, restoreValue, multiple);
|
|
843
|
+
}, scope);
|
|
1203
844
|
}
|
|
1204
845
|
function _attr_select_value(scope, nodeAccessor, value, valueChange) {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
() => setSelectValue(el, normalizedValue, multiple),
|
|
1214
|
-
scope
|
|
1215
|
-
);
|
|
1216
|
-
} else {
|
|
1217
|
-
_attr_select_value_default(scope, nodeAccessor, normalizedValue);
|
|
1218
|
-
}
|
|
846
|
+
const el = scope[nodeAccessor];
|
|
847
|
+
const existing = !scope["#Creating"];
|
|
848
|
+
const multiple = Array.isArray(value);
|
|
849
|
+
const normalizedValue = scope["ControlledValue:" + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
850
|
+
scope["ControlledHandler:" + nodeAccessor] = valueChange;
|
|
851
|
+
scope["ControlledType:" + nodeAccessor] = valueChange ? 3 : 5;
|
|
852
|
+
if (valueChange && existing) pendingEffects.unshift(() => setSelectValue(el, normalizedValue, multiple), scope);
|
|
853
|
+
else _attr_select_value_default(scope, nodeAccessor, normalizedValue);
|
|
1219
854
|
}
|
|
1220
855
|
function _attr_select_value_script(scope, nodeAccessor) {
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
syncControllableFormInput(el, hasSelectChanged, onChange);
|
|
1252
|
-
new MutationObserver(() => {
|
|
1253
|
-
const value = scope["ControlledValue:" /* ControlledValue */ + nodeAccessor];
|
|
1254
|
-
if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((value2, i) => value2 != el.selectedOptions[i].value) : el.value !== value) {
|
|
1255
|
-
onChange();
|
|
1256
|
-
}
|
|
1257
|
-
}).observe(el, { childList: true, subtree: true });
|
|
856
|
+
const el = scope[nodeAccessor];
|
|
857
|
+
const onChange = () => {
|
|
858
|
+
const valueChange = scope["ControlledHandler:" + nodeAccessor];
|
|
859
|
+
if (valueChange) {
|
|
860
|
+
const oldValue = scope["ControlledValue:" + nodeAccessor];
|
|
861
|
+
const multiple = Array.isArray(oldValue);
|
|
862
|
+
const newValue = getSelectValue(el, multiple);
|
|
863
|
+
setSelectValue(el, oldValue, multiple);
|
|
864
|
+
valueChange(newValue);
|
|
865
|
+
run();
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
if (isResuming) if (el.multiple) {
|
|
869
|
+
scope["ControlledValue:" + nodeAccessor] = [];
|
|
870
|
+
for (const opt of el.options) if (opt.defaultSelected) scope["ControlledValue:" + nodeAccessor].push(opt.value);
|
|
871
|
+
} else {
|
|
872
|
+
scope["ControlledValue:" + nodeAccessor] = "";
|
|
873
|
+
for (const opt of el.options) if (opt.defaultSelected) {
|
|
874
|
+
scope["ControlledValue:" + nodeAccessor] = opt.value;
|
|
875
|
+
break;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
syncControllableFormInput(el, hasSelectChanged, onChange);
|
|
879
|
+
new MutationObserver(() => {
|
|
880
|
+
const value = scope["ControlledValue:" + nodeAccessor];
|
|
881
|
+
if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((value, i) => value != el.selectedOptions[i].value) : el.value !== value) onChange();
|
|
882
|
+
}).observe(el, {
|
|
883
|
+
childList: true,
|
|
884
|
+
subtree: true
|
|
885
|
+
});
|
|
1258
886
|
}
|
|
1259
887
|
function setSelectValue(el, value, multiple) {
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
opt.selected = value.includes(opt.value);
|
|
1263
|
-
}
|
|
1264
|
-
} else {
|
|
1265
|
-
el.value = value;
|
|
1266
|
-
}
|
|
888
|
+
if (multiple) for (const opt of el.options) opt.selected = value.includes(opt.value);
|
|
889
|
+
else el.value = value;
|
|
1267
890
|
}
|
|
1268
891
|
function getSelectValue(el, multiple) {
|
|
1269
|
-
|
|
892
|
+
return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
|
|
1270
893
|
}
|
|
1271
894
|
function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
|
|
1272
|
-
|
|
1273
|
-
scope[nodeAccessor].open = normalizeBoolProp(open);
|
|
1274
|
-
}
|
|
895
|
+
if (scope["#Creating"]) scope[nodeAccessor].open = normalizeBoolProp(open);
|
|
1275
896
|
}
|
|
1276
897
|
function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
} else {
|
|
1283
|
-
_attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
|
|
1284
|
-
}
|
|
898
|
+
const normalizedOpen = scope["ControlledValue:" + nodeAccessor] = normalizeBoolProp(open);
|
|
899
|
+
scope["ControlledHandler:" + nodeAccessor] = openChange;
|
|
900
|
+
scope["ControlledType:" + nodeAccessor] = openChange ? 4 : 5;
|
|
901
|
+
if (openChange && !scope["#Creating"]) scope[nodeAccessor].open = normalizedOpen;
|
|
902
|
+
else _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
|
|
1285
903
|
}
|
|
1286
904
|
function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
905
|
+
const el = scope[nodeAccessor];
|
|
906
|
+
new MutationObserver(() => {
|
|
907
|
+
const openChange = scope["ControlledHandler:" + nodeAccessor];
|
|
908
|
+
if (openChange && el.open === !scope["ControlledValue:" + nodeAccessor]) {
|
|
909
|
+
const newValue = el.open;
|
|
910
|
+
el.open = !newValue;
|
|
911
|
+
openChange(newValue);
|
|
912
|
+
run();
|
|
913
|
+
}
|
|
914
|
+
}).observe(el, {
|
|
915
|
+
attributes: true,
|
|
916
|
+
attributeFilter: ["open"]
|
|
917
|
+
});
|
|
1297
918
|
}
|
|
1298
919
|
function syncControllableFormInput(el, hasChanged, onChange) {
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
}
|
|
1304
|
-
if (isResuming && hasChanged(el)) {
|
|
1305
|
-
queueMicrotask(onChange);
|
|
1306
|
-
}
|
|
920
|
+
el._ = onChange;
|
|
921
|
+
controllableDelegate(el, "input", handleChange);
|
|
922
|
+
if (el.form) controllableDelegate(el.form, "reset", handleFormReset);
|
|
923
|
+
if (isResuming && hasChanged(el)) queueMicrotask(onChange);
|
|
1307
924
|
}
|
|
1308
925
|
function handleChange(ev) {
|
|
1309
|
-
|
|
926
|
+
ev.target._?.(ev);
|
|
1310
927
|
}
|
|
1311
928
|
function handleFormReset(ev) {
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
}
|
|
1318
|
-
requestAnimationFrame(() => {
|
|
1319
|
-
if (!ev.defaultPrevented) {
|
|
1320
|
-
for (const change of handlers) {
|
|
1321
|
-
change();
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
});
|
|
929
|
+
const handlers = [];
|
|
930
|
+
for (const el of ev.target.elements) if (el._ && hasFormElementChanged(el)) handlers.push(el._);
|
|
931
|
+
requestAnimationFrame(() => {
|
|
932
|
+
if (!ev.defaultPrevented) for (const change of handlers) change();
|
|
933
|
+
});
|
|
1325
934
|
}
|
|
1326
935
|
function hasValueChanged(el) {
|
|
1327
|
-
|
|
936
|
+
return el.value !== el.defaultValue;
|
|
1328
937
|
}
|
|
1329
938
|
function hasCheckboxChanged(el) {
|
|
1330
|
-
|
|
939
|
+
return el.checked !== el.defaultChecked;
|
|
1331
940
|
}
|
|
1332
941
|
function hasSelectChanged(el) {
|
|
1333
|
-
|
|
1334
|
-
if (opt.selected !== opt.defaultSelected) {
|
|
1335
|
-
return true;
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
942
|
+
for (const opt of el.options) if (opt.selected !== opt.defaultSelected) return true;
|
|
1338
943
|
}
|
|
1339
944
|
function hasFormElementChanged(el) {
|
|
1340
|
-
|
|
945
|
+
return el.options ? hasSelectChanged(el) : hasValueChanged(el) || hasCheckboxChanged(el);
|
|
1341
946
|
}
|
|
1342
947
|
function normalizeStrProp(value) {
|
|
1343
|
-
|
|
948
|
+
return normalizeAttrValue(value) || "";
|
|
1344
949
|
}
|
|
1345
950
|
function normalizeBoolProp(value) {
|
|
1346
|
-
|
|
951
|
+
return value != null && value !== false;
|
|
1347
952
|
}
|
|
1348
|
-
function updateList(arr, val,
|
|
1349
|
-
|
|
1350
|
-
|
|
953
|
+
function updateList(arr, val, push) {
|
|
954
|
+
const index = arr.indexOf(val);
|
|
955
|
+
return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
|
|
1351
956
|
}
|
|
1352
|
-
|
|
1353
|
-
|
|
957
|
+
//#endregion
|
|
958
|
+
//#region src/dom/dom.ts
|
|
1354
959
|
function _to_text(value) {
|
|
1355
|
-
|
|
960
|
+
return value || value === 0 ? value + "" : "";
|
|
1356
961
|
}
|
|
1357
962
|
function _attr(element, name, value) {
|
|
1358
|
-
|
|
963
|
+
setAttribute(element, name, normalizeAttrValue(value));
|
|
1359
964
|
}
|
|
1360
965
|
function setAttribute(element, name, value) {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
element.removeAttribute(name);
|
|
1364
|
-
} else {
|
|
1365
|
-
element.setAttribute(name, value);
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
966
|
+
if (element.getAttribute(name) != value) if (value === void 0) element.removeAttribute(name);
|
|
967
|
+
else element.setAttribute(name, value);
|
|
1368
968
|
}
|
|
1369
969
|
function _attr_class(element, value) {
|
|
1370
|
-
|
|
970
|
+
setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
|
|
1371
971
|
}
|
|
1372
972
|
function _attr_class_items(element, items) {
|
|
1373
|
-
|
|
1374
|
-
_attr_class_item(element, key, items[key]);
|
|
1375
|
-
}
|
|
973
|
+
for (const key in items) _attr_class_item(element, key, items[key]);
|
|
1376
974
|
}
|
|
1377
975
|
function _attr_class_item(element, name, value) {
|
|
1378
|
-
|
|
976
|
+
element.classList.toggle(name, !!value);
|
|
1379
977
|
}
|
|
1380
978
|
function _attr_style(element, value) {
|
|
1381
|
-
|
|
979
|
+
setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
|
|
1382
980
|
}
|
|
1383
981
|
function _attr_style_items(element, items) {
|
|
1384
|
-
|
|
1385
|
-
_attr_style_item(element, key, items[key]);
|
|
1386
|
-
}
|
|
982
|
+
for (const key in items) _attr_style_item(element, key, items[key]);
|
|
1387
983
|
}
|
|
1388
984
|
function _attr_style_item(element, name, value) {
|
|
1389
|
-
|
|
985
|
+
element.style.setProperty(name, _to_text(value));
|
|
1390
986
|
}
|
|
1391
987
|
function _attr_nonce(scope, nodeAccessor) {
|
|
1392
|
-
|
|
988
|
+
_attr(scope[nodeAccessor], "nonce", scope["$global"].cspNonce);
|
|
1393
989
|
}
|
|
1394
990
|
function _text(node, value) {
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
node.data = normalizedValue;
|
|
1398
|
-
}
|
|
991
|
+
const normalizedValue = _to_text(value);
|
|
992
|
+
if (node.data !== normalizedValue) node.data = normalizedValue;
|
|
1399
993
|
}
|
|
1400
994
|
function _text_content(node, value) {
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
node.textContent = normalizedValue;
|
|
1404
|
-
}
|
|
995
|
+
const normalizedValue = _to_text(value);
|
|
996
|
+
if (node.textContent !== normalizedValue) node.textContent = normalizedValue;
|
|
1405
997
|
}
|
|
1406
998
|
function _attrs(scope, nodeAccessor, nextAttrs) {
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
if (true) {
|
|
1415
|
-
assertExclusiveAttrs(nextAttrs);
|
|
1416
|
-
}
|
|
1417
|
-
attrsInternal(scope, nodeAccessor, nextAttrs);
|
|
999
|
+
const el = scope[nodeAccessor];
|
|
1000
|
+
for (let i = el.attributes.length; i--;) {
|
|
1001
|
+
const { name } = el.attributes.item(i);
|
|
1002
|
+
if (!(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)))) el.removeAttribute(name);
|
|
1003
|
+
}
|
|
1004
|
+
assertExclusiveAttrs(nextAttrs);
|
|
1005
|
+
attrsInternal(scope, nodeAccessor, nextAttrs);
|
|
1418
1006
|
}
|
|
1419
1007
|
function _attrs_content(scope, nodeAccessor, nextAttrs) {
|
|
1420
|
-
|
|
1421
|
-
|
|
1008
|
+
_attrs(scope, nodeAccessor, nextAttrs);
|
|
1009
|
+
_attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
1422
1010
|
}
|
|
1423
1011
|
function hasAttrAlias(element, attr, nextAttrs) {
|
|
1424
|
-
|
|
1012
|
+
return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
|
|
1425
1013
|
}
|
|
1426
1014
|
function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
attrsInternal(scope, nodeAccessor, partial);
|
|
1015
|
+
const el = scope[nodeAccessor];
|
|
1016
|
+
const partial = {};
|
|
1017
|
+
for (let i = el.attributes.length; i--;) {
|
|
1018
|
+
const { name } = el.attributes.item(i);
|
|
1019
|
+
if (!skip[name] && !(nextAttrs && name in nextAttrs)) el.removeAttribute(name);
|
|
1020
|
+
}
|
|
1021
|
+
for (const name in nextAttrs) {
|
|
1022
|
+
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
1023
|
+
if (!skip[key]) partial[key] = nextAttrs[name];
|
|
1024
|
+
}
|
|
1025
|
+
assertExclusiveAttrs({
|
|
1026
|
+
...nextAttrs,
|
|
1027
|
+
...skip
|
|
1028
|
+
});
|
|
1029
|
+
attrsInternal(scope, nodeAccessor, partial);
|
|
1443
1030
|
}
|
|
1444
1031
|
function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
|
|
1445
|
-
|
|
1446
|
-
|
|
1032
|
+
_attrs_partial(scope, nodeAccessor, nextAttrs, skip);
|
|
1033
|
+
_attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
1447
1034
|
}
|
|
1448
1035
|
function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
nodeAccessor,
|
|
1497
|
-
nextAttrs.value,
|
|
1498
|
-
nextAttrs.valueChange
|
|
1499
|
-
);
|
|
1500
|
-
skip = /^value(?:Change)?$/;
|
|
1501
|
-
}
|
|
1502
|
-
break;
|
|
1503
|
-
case "DETAILS":
|
|
1504
|
-
case "DIALOG":
|
|
1505
|
-
if ("open" in nextAttrs || "openChange" in nextAttrs) {
|
|
1506
|
-
_attr_details_or_dialog_open(
|
|
1507
|
-
scope,
|
|
1508
|
-
nodeAccessor,
|
|
1509
|
-
nextAttrs.open,
|
|
1510
|
-
nextAttrs.openChange
|
|
1511
|
-
);
|
|
1512
|
-
skip = /^open(?:Change)?$/;
|
|
1513
|
-
}
|
|
1514
|
-
break;
|
|
1515
|
-
}
|
|
1516
|
-
for (const name in nextAttrs) {
|
|
1517
|
-
const value = nextAttrs[name];
|
|
1518
|
-
switch (name) {
|
|
1519
|
-
case "class":
|
|
1520
|
-
_attr_class(el, value);
|
|
1521
|
-
break;
|
|
1522
|
-
case "style":
|
|
1523
|
-
_attr_style(el, value);
|
|
1524
|
-
break;
|
|
1525
|
-
default: {
|
|
1526
|
-
if (true) {
|
|
1527
|
-
if (htmlAttrNameReg.test(name)) {
|
|
1528
|
-
throw new Error(`Invalid attribute name: ${JSON.stringify(name)}`);
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
if (isEventHandler(name)) {
|
|
1532
|
-
(events ||= scope["EventAttributes:" /* EventAttributes */ + nodeAccessor] = {})[getEventHandlerName(name)] = value;
|
|
1533
|
-
} else if (!(skip?.test(name) || name === "content" && el.tagName !== "META")) {
|
|
1534
|
-
_attr(el, name, value);
|
|
1535
|
-
}
|
|
1536
|
-
break;
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1036
|
+
const el = scope[nodeAccessor];
|
|
1037
|
+
let events;
|
|
1038
|
+
let skip;
|
|
1039
|
+
switch (el.tagName) {
|
|
1040
|
+
case "INPUT":
|
|
1041
|
+
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
|
|
1042
|
+
else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
|
|
1043
|
+
else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
|
|
1044
|
+
else break;
|
|
1045
|
+
skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
|
|
1046
|
+
break;
|
|
1047
|
+
case "SELECT":
|
|
1048
|
+
if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
1049
|
+
_attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
|
|
1050
|
+
skip = /^value(?:Change)?$/;
|
|
1051
|
+
}
|
|
1052
|
+
break;
|
|
1053
|
+
case "TEXTAREA":
|
|
1054
|
+
if ("value" in nextAttrs || "valueChange" in nextAttrs) {
|
|
1055
|
+
_attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
|
|
1056
|
+
skip = /^value(?:Change)?$/;
|
|
1057
|
+
}
|
|
1058
|
+
break;
|
|
1059
|
+
case "DETAILS":
|
|
1060
|
+
case "DIALOG":
|
|
1061
|
+
if ("open" in nextAttrs || "openChange" in nextAttrs) {
|
|
1062
|
+
_attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange);
|
|
1063
|
+
skip = /^open(?:Change)?$/;
|
|
1064
|
+
}
|
|
1065
|
+
break;
|
|
1066
|
+
}
|
|
1067
|
+
for (const name in nextAttrs) {
|
|
1068
|
+
const value = nextAttrs[name];
|
|
1069
|
+
switch (name) {
|
|
1070
|
+
case "class":
|
|
1071
|
+
_attr_class(el, value);
|
|
1072
|
+
break;
|
|
1073
|
+
case "style":
|
|
1074
|
+
_attr_style(el, value);
|
|
1075
|
+
break;
|
|
1076
|
+
default:
|
|
1077
|
+
if (htmlAttrNameReg.test(name)) throw new Error(`Invalid attribute name: ${JSON.stringify(name)}`);
|
|
1078
|
+
if (isEventHandler(name)) (events ||= scope["EventAttributes:" + nodeAccessor] = {})[getEventHandlerName(name)] = value;
|
|
1079
|
+
else if (!(skip?.test(name) || name === "content" && el.tagName !== "META")) _attr(el, name, value);
|
|
1080
|
+
break;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1540
1083
|
}
|
|
1541
1084
|
function _attr_content(scope, nodeAccessor, value) {
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
content.___accessor,
|
|
1549
|
-
scope["BranchScopes:" /* BranchScopes */ + nodeAccessor]
|
|
1550
|
-
);
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
for (const accessor in content?.___localClosures) {
|
|
1554
|
-
content.___localClosures[accessor](
|
|
1555
|
-
scope["BranchScopes:" /* BranchScopes */ + nodeAccessor],
|
|
1556
|
-
content.___localClosureValues[accessor]
|
|
1557
|
-
);
|
|
1558
|
-
}
|
|
1085
|
+
const content = normalizeClientRender(value);
|
|
1086
|
+
if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = content?.["id"])) {
|
|
1087
|
+
setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
|
|
1088
|
+
if (content?.["accessor"]) subscribeToScopeSet(content["owner"], content["accessor"], scope["BranchScopes:" + nodeAccessor]);
|
|
1089
|
+
}
|
|
1090
|
+
for (const accessor in content?.["localClosures"]) content["localClosures"][accessor](scope["BranchScopes:" + nodeAccessor], content["localClosureValues"][accessor]);
|
|
1559
1091
|
}
|
|
1560
1092
|
function _attrs_script(scope, nodeAccessor) {
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
_on(el, name, events[name]);
|
|
1582
|
-
}
|
|
1093
|
+
const el = scope[nodeAccessor];
|
|
1094
|
+
const events = scope["EventAttributes:" + nodeAccessor];
|
|
1095
|
+
switch (scope["ControlledType:" + nodeAccessor]) {
|
|
1096
|
+
case 0:
|
|
1097
|
+
_attr_input_checked_script(scope, nodeAccessor);
|
|
1098
|
+
break;
|
|
1099
|
+
case 1:
|
|
1100
|
+
_attr_input_checkedValue_script(scope, nodeAccessor);
|
|
1101
|
+
break;
|
|
1102
|
+
case 2:
|
|
1103
|
+
_attr_input_value_script(scope, nodeAccessor);
|
|
1104
|
+
break;
|
|
1105
|
+
case 3:
|
|
1106
|
+
_attr_select_value_script(scope, nodeAccessor);
|
|
1107
|
+
break;
|
|
1108
|
+
case 4:
|
|
1109
|
+
_attr_details_or_dialog_open_script(scope, nodeAccessor);
|
|
1110
|
+
break;
|
|
1111
|
+
}
|
|
1112
|
+
for (const name in events) _on(el, name, events[name]);
|
|
1583
1113
|
}
|
|
1584
1114
|
function _html(scope, value, accessor) {
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
);
|
|
1592
|
-
insertChildNodes(
|
|
1593
|
-
parentNode,
|
|
1594
|
-
firstChild,
|
|
1595
|
-
scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()),
|
|
1596
|
-
scope["DynamicHTMLLastChild:" /* DynamicHTMLLastChild */ + accessor] = newContent.lastChild
|
|
1597
|
-
);
|
|
1598
|
-
removeChildNodes(firstChild, lastChild);
|
|
1115
|
+
const firstChild = scope[accessor];
|
|
1116
|
+
const parentNode = firstChild.parentNode;
|
|
1117
|
+
const lastChild = scope["DynamicHTMLLastChild:" + accessor] || firstChild;
|
|
1118
|
+
const newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
|
|
1119
|
+
insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope["DynamicHTMLLastChild:" + accessor] = newContent.lastChild);
|
|
1120
|
+
removeChildNodes(firstChild, lastChild);
|
|
1599
1121
|
}
|
|
1600
1122
|
function normalizeClientRender(value) {
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
return renderer;
|
|
1605
|
-
} else if (true) {
|
|
1606
|
-
throw new Error(
|
|
1607
|
-
`Invalid \`content\` attribute. Received ${typeof value}`
|
|
1608
|
-
);
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1123
|
+
const renderer = normalizeDynamicRenderer(value);
|
|
1124
|
+
if (renderer) if (renderer["id"]) return renderer;
|
|
1125
|
+
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1611
1126
|
}
|
|
1612
1127
|
function normalizeAttrValue(value) {
|
|
1613
|
-
|
|
1614
|
-
return value === true ? "" : value + "";
|
|
1615
|
-
}
|
|
1128
|
+
if (value || value === 0) return value === true ? "" : value + "";
|
|
1616
1129
|
}
|
|
1617
1130
|
function _lifecycle(scope, thisObj, index = 0) {
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1131
|
+
const accessor = "Lifecycle:" + index;
|
|
1132
|
+
const instance = scope[accessor];
|
|
1133
|
+
if (instance) {
|
|
1134
|
+
Object.assign(instance, thisObj);
|
|
1135
|
+
instance.onUpdate?.();
|
|
1136
|
+
} else {
|
|
1137
|
+
scope[accessor] = thisObj;
|
|
1138
|
+
thisObj.onMount?.();
|
|
1139
|
+
$signal(scope, accessor).onabort = () => thisObj.onDestroy?.();
|
|
1140
|
+
}
|
|
1628
1141
|
}
|
|
1629
1142
|
function removeChildNodes(startNode, endNode) {
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1143
|
+
const stop = endNode.nextSibling;
|
|
1144
|
+
let current = startNode;
|
|
1145
|
+
while (current !== stop) {
|
|
1146
|
+
const next = current.nextSibling;
|
|
1147
|
+
current.remove();
|
|
1148
|
+
current = next;
|
|
1149
|
+
}
|
|
1637
1150
|
}
|
|
1638
1151
|
function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
|
|
1639
|
-
|
|
1152
|
+
parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
|
|
1640
1153
|
}
|
|
1641
1154
|
function toInsertNode(startNode, endNode) {
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
}
|
|
1653
|
-
|
|
1654
|
-
|
|
1155
|
+
if (startNode === endNode) return startNode;
|
|
1156
|
+
const parent = new DocumentFragment();
|
|
1157
|
+
const stop = endNode.nextSibling;
|
|
1158
|
+
let current = startNode;
|
|
1159
|
+
while (current !== stop) {
|
|
1160
|
+
const next = current.nextSibling;
|
|
1161
|
+
parent.appendChild(current);
|
|
1162
|
+
current = next;
|
|
1163
|
+
}
|
|
1164
|
+
return parent;
|
|
1165
|
+
}
|
|
1166
|
+
//#endregion
|
|
1167
|
+
//#region src/dom/control-flow.ts
|
|
1655
1168
|
function _await_promise(nodeAccessor, params) {
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
() => {
|
|
1744
|
-
if ((awaitBranch = scope[branchAccessor])["#DetachedAwait" /* DetachedAwait */]) {
|
|
1745
|
-
pendingScopes.push(awaitBranch);
|
|
1746
|
-
setupBranch(
|
|
1747
|
-
awaitBranch["#DetachedAwait" /* DetachedAwait */],
|
|
1748
|
-
awaitBranch
|
|
1749
|
-
);
|
|
1750
|
-
awaitBranch["#DetachedAwait" /* DetachedAwait */] = 0;
|
|
1751
|
-
insertBranchBefore(
|
|
1752
|
-
awaitBranch,
|
|
1753
|
-
scope[nodeAccessor].parentNode,
|
|
1754
|
-
scope[nodeAccessor]
|
|
1755
|
-
);
|
|
1756
|
-
referenceNode.remove();
|
|
1757
|
-
}
|
|
1758
|
-
params?.(awaitBranch, [data]);
|
|
1759
|
-
const pendingRenders2 = awaitBranch["#PendingRenders" /* PendingRenders */];
|
|
1760
|
-
awaitBranch["#PendingRenders" /* PendingRenders */] = 0;
|
|
1761
|
-
pendingRenders2?.forEach(queuePendingRender);
|
|
1762
|
-
placeholderShown.add(pendingEffects);
|
|
1763
|
-
awaitCounter.c();
|
|
1764
|
-
if (awaitCounter.m) {
|
|
1765
|
-
const fnScopes = /* @__PURE__ */ new Map();
|
|
1766
|
-
const effects = awaitCounter.m();
|
|
1767
|
-
for (let i = 0; i < pendingEffects.length; ) {
|
|
1768
|
-
const fn = pendingEffects[i++];
|
|
1769
|
-
let scopes = fnScopes.get(fn);
|
|
1770
|
-
if (!scopes) {
|
|
1771
|
-
fnScopes.set(fn, scopes = /* @__PURE__ */ new Set());
|
|
1772
|
-
}
|
|
1773
|
-
scopes.add(pendingEffects[i++]);
|
|
1774
|
-
}
|
|
1775
|
-
for (let i = 0; i < effects.length; ) {
|
|
1776
|
-
const fn = effects[i++];
|
|
1777
|
-
const scope2 = effects[i++];
|
|
1778
|
-
if (!fnScopes.get(fn)?.has(scope2)) {
|
|
1779
|
-
queueEffect(scope2, fn);
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
},
|
|
1784
|
-
-1
|
|
1785
|
-
);
|
|
1786
|
-
}
|
|
1787
|
-
},
|
|
1788
|
-
(error) => {
|
|
1789
|
-
if (thisPromise === scope[promiseAccessor]) {
|
|
1790
|
-
awaitCounter.i = scope[promiseAccessor] = 0;
|
|
1791
|
-
schedule();
|
|
1792
|
-
queueRender(scope, renderCatch, -1, error);
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
);
|
|
1796
|
-
};
|
|
1169
|
+
const promiseAccessor = "Promise:" + nodeAccessor;
|
|
1170
|
+
const branchAccessor = "BranchScopes:" + nodeAccessor;
|
|
1171
|
+
_enable_catch();
|
|
1172
|
+
return (scope, promise) => {
|
|
1173
|
+
let awaitBranch = scope[branchAccessor];
|
|
1174
|
+
const tryBranch = findBranchWithKey(scope, "#PlaceholderContent") || awaitBranch;
|
|
1175
|
+
let awaitCounter = tryBranch["#AwaitCounter"];
|
|
1176
|
+
if (!awaitCounter?.i) awaitCounter = tryBranch["#AwaitCounter"] = {
|
|
1177
|
+
i: 0,
|
|
1178
|
+
c() {
|
|
1179
|
+
if (--awaitCounter.i) return 1;
|
|
1180
|
+
if (tryBranch === scope[branchAccessor]) {
|
|
1181
|
+
if (scope[nodeAccessor].parentNode) scope[nodeAccessor].replaceWith(scope[branchAccessor]["#StartNode"].parentNode);
|
|
1182
|
+
} else {
|
|
1183
|
+
const placeholderBranch = tryBranch["#PlaceholderBranch"];
|
|
1184
|
+
if (placeholderBranch) {
|
|
1185
|
+
tryBranch["#PlaceholderBranch"] = 0;
|
|
1186
|
+
placeholderBranch["#StartNode"].parentNode.insertBefore(tryBranch["#StartNode"].parentNode, placeholderBranch["#StartNode"]);
|
|
1187
|
+
removeAndDestroyBranch(placeholderBranch);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
queueEffect(tryBranch, (scope) => {
|
|
1191
|
+
const pendingEffects = scope["#PendingEffects"];
|
|
1192
|
+
if (pendingEffects) {
|
|
1193
|
+
scope["#PendingEffects"] = [];
|
|
1194
|
+
runEffects(pendingEffects, 1);
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
placeholderShown.add(pendingEffects);
|
|
1200
|
+
if (!scope[promiseAccessor]) {
|
|
1201
|
+
if (awaitBranch) awaitBranch["#PendingRenders"] ||= [];
|
|
1202
|
+
if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch === awaitBranch ? scope : tryBranch, () => {
|
|
1203
|
+
if (tryBranch["#PlaceholderContent"]) {
|
|
1204
|
+
insertBranchBefore(tryBranch["#PlaceholderBranch"] = createAndSetupBranch(scope["$global"], tryBranch["#PlaceholderContent"], tryBranch["_"], tryBranch["#StartNode"].parentNode), tryBranch["#StartNode"].parentNode, tryBranch["#StartNode"]);
|
|
1205
|
+
tempDetachBranch(tryBranch);
|
|
1206
|
+
} else if (!awaitBranch["#DetachedAwait"]) {
|
|
1207
|
+
awaitBranch["#StartNode"].parentNode.insertBefore(scope[nodeAccessor], awaitBranch["#StartNode"]);
|
|
1208
|
+
tempDetachBranch(tryBranch);
|
|
1209
|
+
}
|
|
1210
|
+
}, -1))));
|
|
1211
|
+
}
|
|
1212
|
+
const thisPromise = scope[promiseAccessor] = promise.then((data) => {
|
|
1213
|
+
if (thisPromise === scope[promiseAccessor]) {
|
|
1214
|
+
const referenceNode = scope[nodeAccessor];
|
|
1215
|
+
scope[promiseAccessor] = 0;
|
|
1216
|
+
queueMicrotask(run);
|
|
1217
|
+
queueRender(scope, () => {
|
|
1218
|
+
if ((awaitBranch = scope[branchAccessor])["#DetachedAwait"]) {
|
|
1219
|
+
pendingScopes.push(awaitBranch);
|
|
1220
|
+
setupBranch(awaitBranch["#DetachedAwait"], awaitBranch);
|
|
1221
|
+
awaitBranch["#DetachedAwait"] = 0;
|
|
1222
|
+
insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
|
|
1223
|
+
referenceNode.remove();
|
|
1224
|
+
}
|
|
1225
|
+
params?.(awaitBranch, [data]);
|
|
1226
|
+
const pendingRenders = awaitBranch["#PendingRenders"];
|
|
1227
|
+
awaitBranch["#PendingRenders"] = 0;
|
|
1228
|
+
pendingRenders?.forEach(queuePendingRender);
|
|
1229
|
+
placeholderShown.add(pendingEffects);
|
|
1230
|
+
awaitCounter.c();
|
|
1231
|
+
if (awaitCounter.m) {
|
|
1232
|
+
const fnScopes = /* @__PURE__ */ new Map();
|
|
1233
|
+
const effects = awaitCounter.m();
|
|
1234
|
+
for (let i = 0; i < pendingEffects.length;) {
|
|
1235
|
+
const fn = pendingEffects[i++];
|
|
1236
|
+
let scopes = fnScopes.get(fn);
|
|
1237
|
+
if (!scopes) fnScopes.set(fn, scopes = /* @__PURE__ */ new Set());
|
|
1238
|
+
scopes.add(pendingEffects[i++]);
|
|
1239
|
+
}
|
|
1240
|
+
for (let i = 0; i < effects.length;) {
|
|
1241
|
+
const fn = effects[i++];
|
|
1242
|
+
const scope = effects[i++];
|
|
1243
|
+
if (!fnScopes.get(fn)?.has(scope)) queueEffect(scope, fn);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}, -1);
|
|
1247
|
+
}
|
|
1248
|
+
}, (error) => {
|
|
1249
|
+
if (thisPromise === scope[promiseAccessor]) {
|
|
1250
|
+
awaitCounter.i = scope[promiseAccessor] = 0;
|
|
1251
|
+
schedule();
|
|
1252
|
+
queueRender(scope, renderCatch, -1, error);
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
};
|
|
1797
1256
|
}
|
|
1798
1257
|
function _await_content(nodeAccessor, template, walks, setup) {
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
renderer,
|
|
1806
|
-
scope,
|
|
1807
|
-
scope[nodeAccessor].parentNode
|
|
1808
|
-
))["#DetachedAwait" /* DetachedAwait */] = renderer;
|
|
1809
|
-
pendingScopes.pop();
|
|
1810
|
-
};
|
|
1258
|
+
const branchAccessor = "BranchScopes:" + nodeAccessor;
|
|
1259
|
+
const renderer = _content("", template, walks, setup)();
|
|
1260
|
+
return (scope) => {
|
|
1261
|
+
(scope[branchAccessor] = createBranch(scope["$global"], renderer, scope, scope[nodeAccessor].parentNode))["#DetachedAwait"] = renderer;
|
|
1262
|
+
pendingScopes.pop();
|
|
1263
|
+
};
|
|
1811
1264
|
}
|
|
1812
1265
|
function _try(nodeAccessor, template, walks, setup) {
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
}
|
|
1825
|
-
const branch = scope[branchAccessor];
|
|
1826
|
-
if (branch) {
|
|
1827
|
-
branch["#BranchAccessor" /* BranchAccessor */] = nodeAccessor;
|
|
1828
|
-
branch["#CatchContent" /* CatchContent */] = normalizeDynamicRenderer(input.catch);
|
|
1829
|
-
branch["#PlaceholderContent" /* PlaceholderContent */] = normalizeDynamicRenderer(
|
|
1830
|
-
input.placeholder
|
|
1831
|
-
);
|
|
1832
|
-
}
|
|
1833
|
-
};
|
|
1266
|
+
const branchAccessor = "BranchScopes:" + nodeAccessor;
|
|
1267
|
+
const renderer = _content("", template, walks, setup)();
|
|
1268
|
+
return (scope, input) => {
|
|
1269
|
+
if (!scope[branchAccessor]) setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
|
|
1270
|
+
const branch = scope[branchAccessor];
|
|
1271
|
+
if (branch) {
|
|
1272
|
+
branch["#BranchAccessor"] = nodeAccessor;
|
|
1273
|
+
branch["#CatchContent"] = input.catch && (normalizeDynamicRenderer(input.catch) || 0);
|
|
1274
|
+
branch["#PlaceholderContent"] = normalizeDynamicRenderer(input.placeholder);
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1834
1277
|
}
|
|
1835
1278
|
function renderCatch(scope, error) {
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
owner,
|
|
1851
|
-
tryWithCatch["#BranchAccessor" /* BranchAccessor */],
|
|
1852
|
-
tryWithCatch["#CatchContent" /* CatchContent */],
|
|
1853
|
-
createAndSetupBranch
|
|
1854
|
-
);
|
|
1855
|
-
tryWithCatch["#CatchContent" /* CatchContent */].___params?.(
|
|
1856
|
-
owner["BranchScopes:" /* BranchScopes */ + tryWithCatch["#BranchAccessor" /* BranchAccessor */]],
|
|
1857
|
-
[error]
|
|
1858
|
-
);
|
|
1859
|
-
}
|
|
1279
|
+
const tryWithCatch = findBranchWithKey(scope, "#CatchContent");
|
|
1280
|
+
if (!tryWithCatch) throw error;
|
|
1281
|
+
else {
|
|
1282
|
+
const owner = tryWithCatch["_"];
|
|
1283
|
+
const placeholderBranch = tryWithCatch["#PlaceholderBranch"];
|
|
1284
|
+
if (placeholderBranch) {
|
|
1285
|
+
if (tryWithCatch["#AwaitCounter"]) tryWithCatch["#AwaitCounter"].i = 0;
|
|
1286
|
+
owner["BranchScopes:" + tryWithCatch["#BranchAccessor"]] = placeholderBranch;
|
|
1287
|
+
destroyBranch(tryWithCatch);
|
|
1288
|
+
}
|
|
1289
|
+
caughtError.add(pendingEffects);
|
|
1290
|
+
setConditionalRenderer(owner, tryWithCatch["#BranchAccessor"], tryWithCatch["#CatchContent"], createAndSetupBranch);
|
|
1291
|
+
tryWithCatch["#CatchContent"]?.["params"]?.(owner["BranchScopes:" + tryWithCatch["#BranchAccessor"]], [error]);
|
|
1292
|
+
}
|
|
1860
1293
|
}
|
|
1861
1294
|
function _if(nodeAccessor, ...branchesArgs) {
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
branchesArgs[i++],
|
|
1871
|
-
branchesArgs[i++],
|
|
1872
|
-
branchesArgs[i++]
|
|
1873
|
-
)()
|
|
1874
|
-
);
|
|
1875
|
-
}
|
|
1876
|
-
enableBranches();
|
|
1877
|
-
return (scope, newBranch) => {
|
|
1878
|
-
if (newBranch !== scope[branchAccessor]) {
|
|
1879
|
-
setConditionalRenderer(
|
|
1880
|
-
scope,
|
|
1881
|
-
nodeAccessor,
|
|
1882
|
-
branches[scope[branchAccessor] = newBranch],
|
|
1883
|
-
createAndSetupBranch
|
|
1884
|
-
);
|
|
1885
|
-
}
|
|
1886
|
-
};
|
|
1295
|
+
const branchAccessor = "ConditionalRenderer:" + nodeAccessor;
|
|
1296
|
+
const branches = [];
|
|
1297
|
+
let i = 0;
|
|
1298
|
+
while (i < branchesArgs.length) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
|
|
1299
|
+
enableBranches();
|
|
1300
|
+
return (scope, newBranch) => {
|
|
1301
|
+
if (newBranch !== scope[branchAccessor]) setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
1302
|
+
};
|
|
1887
1303
|
}
|
|
1888
1304
|
function patchDynamicTag(fn) {
|
|
1889
|
-
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
normalizedRenderer.___owner,
|
|
1928
|
-
normalizedRenderer.___accessor,
|
|
1929
|
-
scope[childScopeAccessor]
|
|
1930
|
-
);
|
|
1931
|
-
}
|
|
1932
|
-
}
|
|
1933
|
-
if (normalizedRenderer) {
|
|
1934
|
-
const childScope = scope[childScopeAccessor];
|
|
1935
|
-
const args = getInput?.();
|
|
1936
|
-
if (typeof normalizedRenderer === "string") {
|
|
1937
|
-
(getContent ? _attrs : _attrs_content)(
|
|
1938
|
-
childScope,
|
|
1939
|
-
true ? `#${normalizedRenderer}/0` : "a",
|
|
1940
|
-
(inputIsArgs ? args[0] : args) || {}
|
|
1941
|
-
);
|
|
1942
|
-
if (childScope["EventAttributes:" /* EventAttributes */ + (true ? `#${normalizedRenderer}/0` : "a")] || childScope["ControlledHandler:" /* ControlledHandler */ + (true ? `#${normalizedRenderer}/0` : "a")]) {
|
|
1943
|
-
queueEffect(childScope, dynamicTagScript);
|
|
1944
|
-
}
|
|
1945
|
-
} else {
|
|
1946
|
-
for (const accessor in normalizedRenderer.___localClosures) {
|
|
1947
|
-
normalizedRenderer.___localClosures[accessor](
|
|
1948
|
-
childScope,
|
|
1949
|
-
normalizedRenderer.___localClosureValues[accessor]
|
|
1950
|
-
);
|
|
1951
|
-
}
|
|
1952
|
-
if (normalizedRenderer.___params) {
|
|
1953
|
-
if (inputIsArgs) {
|
|
1954
|
-
normalizedRenderer.___params(
|
|
1955
|
-
childScope,
|
|
1956
|
-
normalizedRenderer._ ? args[0] : args
|
|
1957
|
-
);
|
|
1958
|
-
} else {
|
|
1959
|
-
const inputWithContent = getContent ? { ...args, content: getContent(scope) } : args || {};
|
|
1960
|
-
normalizedRenderer.___params(
|
|
1961
|
-
childScope,
|
|
1962
|
-
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
|
1963
|
-
);
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
};
|
|
1305
|
+
_dynamic_tag = fn(_dynamic_tag);
|
|
1306
|
+
}
|
|
1307
|
+
let _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1308
|
+
const childScopeAccessor = "BranchScopes:" + nodeAccessor;
|
|
1309
|
+
const rendererAccessor = "ConditionalRenderer:" + nodeAccessor;
|
|
1310
|
+
enableBranches();
|
|
1311
|
+
return (scope, newRenderer, getInput) => {
|
|
1312
|
+
const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
|
1313
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.["id"] || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
|
|
1314
|
+
setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer);
|
|
1315
|
+
if (getTagVar) scope[childScopeAccessor]["#TagVariable"] = (value) => getTagVar()(scope, value);
|
|
1316
|
+
if (typeof normalizedRenderer === "string") {
|
|
1317
|
+
if (getContent) {
|
|
1318
|
+
const content = getContent(scope);
|
|
1319
|
+
setConditionalRenderer(scope[childScopeAccessor], `#${normalizedRenderer}/0`, content, createAndSetupBranch);
|
|
1320
|
+
if (content["accessor"]) subscribeToScopeSet(content["owner"], content["accessor"], scope[childScopeAccessor][`BranchScopes:#${normalizedRenderer}/0`]);
|
|
1321
|
+
}
|
|
1322
|
+
} else if (normalizedRenderer?.["accessor"]) subscribeToScopeSet(normalizedRenderer["owner"], normalizedRenderer["accessor"], scope[childScopeAccessor]);
|
|
1323
|
+
}
|
|
1324
|
+
if (normalizedRenderer) {
|
|
1325
|
+
const childScope = scope[childScopeAccessor];
|
|
1326
|
+
const args = getInput?.();
|
|
1327
|
+
if (typeof normalizedRenderer === "string") {
|
|
1328
|
+
(getContent ? _attrs : _attrs_content)(childScope, `#${normalizedRenderer}/0`, (inputIsArgs ? args[0] : args) || {});
|
|
1329
|
+
if (childScope[`EventAttributes:#${normalizedRenderer}/0`] || childScope[`ControlledHandler:#${normalizedRenderer}/0`]) queueEffect(childScope, dynamicTagScript);
|
|
1330
|
+
} else {
|
|
1331
|
+
for (const accessor in normalizedRenderer["localClosures"]) normalizedRenderer["localClosures"][accessor](childScope, normalizedRenderer["localClosureValues"][accessor]);
|
|
1332
|
+
if (normalizedRenderer["params"]) if (inputIsArgs) normalizedRenderer["params"](childScope, normalizedRenderer._ ? args[0] : args);
|
|
1333
|
+
else {
|
|
1334
|
+
const inputWithContent = getContent ? {
|
|
1335
|
+
...args,
|
|
1336
|
+
content: getContent(scope)
|
|
1337
|
+
} : args || {};
|
|
1338
|
+
normalizedRenderer["params"](childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1969
1343
|
};
|
|
1970
1344
|
function _resume_dynamic_tag() {
|
|
1971
|
-
|
|
1345
|
+
_resume(DYNAMIC_TAG_SCRIPT_REGISTER_ID, dynamicTagScript);
|
|
1972
1346
|
}
|
|
1973
1347
|
function dynamicTagScript(branch) {
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
} else {
|
|
2000
|
-
parentNode.insertBefore(
|
|
2001
|
-
referenceNode,
|
|
2002
|
-
prevBranch["#StartNode" /* StartNode */]
|
|
2003
|
-
);
|
|
2004
|
-
}
|
|
2005
|
-
removeAndDestroyBranch(prevBranch);
|
|
2006
|
-
} else if (newBranch) {
|
|
2007
|
-
insertBranchBefore(newBranch, parentNode, referenceNode);
|
|
2008
|
-
referenceNode.remove();
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
var _for_of = loop(([all, by = bySecondArg], cb) => {
|
|
2012
|
-
if (typeof by === "string") {
|
|
2013
|
-
forOf(
|
|
2014
|
-
all,
|
|
2015
|
-
(item, i) => cb(item[by], [item, i])
|
|
2016
|
-
);
|
|
2017
|
-
} else {
|
|
2018
|
-
forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
2019
|
-
}
|
|
1348
|
+
_attrs_script(branch, `#${branch["#Renderer"]}/0`);
|
|
1349
|
+
}
|
|
1350
|
+
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch) {
|
|
1351
|
+
const referenceNode = scope[nodeAccessor];
|
|
1352
|
+
const prevBranch = scope["BranchScopes:" + nodeAccessor];
|
|
1353
|
+
const parentNode = referenceNode.nodeType > 1 ? (prevBranch?.["#StartNode"] || referenceNode).parentNode : referenceNode;
|
|
1354
|
+
const newBranch = scope["BranchScopes:" + nodeAccessor] = newRenderer && createBranch(scope["$global"], newRenderer, scope, parentNode);
|
|
1355
|
+
if (referenceNode === parentNode) {
|
|
1356
|
+
if (prevBranch) {
|
|
1357
|
+
destroyBranch(prevBranch);
|
|
1358
|
+
referenceNode.textContent = "";
|
|
1359
|
+
}
|
|
1360
|
+
if (newBranch) insertBranchBefore(newBranch, parentNode, null);
|
|
1361
|
+
} else if (prevBranch) {
|
|
1362
|
+
if (newBranch) insertBranchBefore(newBranch, parentNode, prevBranch["#StartNode"]);
|
|
1363
|
+
else parentNode.insertBefore(referenceNode, prevBranch["#StartNode"]);
|
|
1364
|
+
removeAndDestroyBranch(prevBranch);
|
|
1365
|
+
} else if (newBranch) {
|
|
1366
|
+
insertBranchBefore(newBranch, parentNode, referenceNode);
|
|
1367
|
+
referenceNode.remove();
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
const _for_of = /* @__PURE__ */ loop(([all, by = bySecondArg], cb) => {
|
|
1371
|
+
if (typeof by === "string") forOf(all, (item, i) => cb(item[by], [item, i]));
|
|
1372
|
+
else forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
2020
1373
|
});
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
);
|
|
2024
|
-
|
|
2025
|
-
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
|
2026
|
-
);
|
|
2027
|
-
var _for_until = loop(
|
|
2028
|
-
([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
|
|
2029
|
-
);
|
|
1374
|
+
const _for_in = /* @__PURE__ */ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value])));
|
|
1375
|
+
const _for_to = /* @__PURE__ */ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v])));
|
|
1376
|
+
const _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v])));
|
|
1377
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2030
1378
|
function loop(forEach) {
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
return;
|
|
2129
|
-
}
|
|
2130
|
-
const diffLen = newEnd - start + 1;
|
|
2131
|
-
const oldPos = /* @__PURE__ */ new Map();
|
|
2132
|
-
const sources = new Array(diffLen);
|
|
2133
|
-
const pred = new Array(diffLen);
|
|
2134
|
-
const tails = [];
|
|
2135
|
-
let tail = -1;
|
|
2136
|
-
let lo;
|
|
2137
|
-
let hi;
|
|
2138
|
-
let mid;
|
|
2139
|
-
for (let i = start; i <= oldEnd; i++) {
|
|
2140
|
-
oldPos.set(oldScopes[i], i);
|
|
2141
|
-
}
|
|
2142
|
-
for (let i = diffLen; i--; ) {
|
|
2143
|
-
sources[i] = oldPos.get(newScopes[start + i]) ?? -1;
|
|
2144
|
-
}
|
|
2145
|
-
for (let i = 0; i < diffLen; i++) {
|
|
2146
|
-
if (~sources[i]) {
|
|
2147
|
-
if (tail < 0 || sources[tails[tail]] < sources[i]) {
|
|
2148
|
-
if (~tail) pred[i] = tails[tail];
|
|
2149
|
-
tails[++tail] = i;
|
|
2150
|
-
} else {
|
|
2151
|
-
lo = 0;
|
|
2152
|
-
hi = tail;
|
|
2153
|
-
while (lo < hi) {
|
|
2154
|
-
mid = (lo + hi) / 2 | 0;
|
|
2155
|
-
if (sources[tails[mid]] < sources[i]) lo = mid + 1;
|
|
2156
|
-
else hi = mid;
|
|
2157
|
-
}
|
|
2158
|
-
if (sources[i] < sources[tails[lo]]) {
|
|
2159
|
-
if (lo > 0) pred[i] = tails[lo - 1];
|
|
2160
|
-
tails[lo] = i;
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
hi = tails[tail];
|
|
2166
|
-
lo = tail + 1;
|
|
2167
|
-
while (lo-- > 0) {
|
|
2168
|
-
tails[lo] = hi;
|
|
2169
|
-
hi = pred[hi];
|
|
2170
|
-
}
|
|
2171
|
-
for (let i = diffLen; i--; ) {
|
|
2172
|
-
if (~tail && i === tails[tail]) {
|
|
2173
|
-
tail--;
|
|
2174
|
-
} else {
|
|
2175
|
-
insertBranchBefore(newScopes[start + i], parentNode, afterReference);
|
|
2176
|
-
}
|
|
2177
|
-
afterReference = newScopes[start + i]["#StartNode" /* StartNode */];
|
|
2178
|
-
}
|
|
2179
|
-
};
|
|
2180
|
-
};
|
|
1379
|
+
return (nodeAccessor, template, walks, setup, params) => {
|
|
1380
|
+
const scopesAccessor = "BranchScopes:" + nodeAccessor;
|
|
1381
|
+
const renderer = _content("", template, walks, setup)();
|
|
1382
|
+
enableBranches();
|
|
1383
|
+
return (scope, value) => {
|
|
1384
|
+
const referenceNode = scope[nodeAccessor];
|
|
1385
|
+
const oldScopes = toArray(scope[scopesAccessor]);
|
|
1386
|
+
const newScopes = scope[scopesAccessor] = [];
|
|
1387
|
+
const oldLen = oldScopes.length;
|
|
1388
|
+
const parentNode = referenceNode.nodeType > 1 ? referenceNode.parentNode || oldScopes[0]?.["#StartNode"].parentNode : referenceNode;
|
|
1389
|
+
let oldScopesByKey;
|
|
1390
|
+
let hasPotentialMoves;
|
|
1391
|
+
var seenKeys = /* @__PURE__ */ new Set();
|
|
1392
|
+
forEach(value, (key, args) => {
|
|
1393
|
+
if (seenKeys.has(key)) console.error(`A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`, key);
|
|
1394
|
+
else seenKeys.add(key);
|
|
1395
|
+
let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce((map, scope, i) => map.set(scope["#LoopKey"] ?? i, scope), /* @__PURE__ */ new Map())).get(key);
|
|
1396
|
+
if (branch) hasPotentialMoves = oldScopesByKey.delete(key);
|
|
1397
|
+
else branch = createAndSetupBranch(scope["$global"], renderer, scope, parentNode);
|
|
1398
|
+
branch["#LoopKey"] = key;
|
|
1399
|
+
newScopes.push(branch);
|
|
1400
|
+
params?.(branch, args);
|
|
1401
|
+
});
|
|
1402
|
+
const newLen = newScopes.length;
|
|
1403
|
+
const hasSiblings = referenceNode !== parentNode;
|
|
1404
|
+
let afterReference = null;
|
|
1405
|
+
let oldEnd = oldLen - 1;
|
|
1406
|
+
let newEnd = newLen - 1;
|
|
1407
|
+
let start = 0;
|
|
1408
|
+
if (hasSiblings) {
|
|
1409
|
+
if (oldLen) {
|
|
1410
|
+
afterReference = oldScopes[oldEnd]["#EndNode"].nextSibling;
|
|
1411
|
+
if (!newLen) parentNode.insertBefore(referenceNode, afterReference);
|
|
1412
|
+
} else if (newLen) {
|
|
1413
|
+
afterReference = referenceNode.nextSibling;
|
|
1414
|
+
referenceNode.remove();
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
if (!hasPotentialMoves) {
|
|
1418
|
+
if (oldLen) {
|
|
1419
|
+
oldScopes.forEach(hasSiblings ? removeAndDestroyBranch : destroyBranch);
|
|
1420
|
+
if (!hasSiblings) parentNode.textContent = "";
|
|
1421
|
+
}
|
|
1422
|
+
for (const newScope of newScopes) insertBranchBefore(newScope, parentNode, afterReference);
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
for (const branch of oldScopesByKey.values()) removeAndDestroyBranch(branch);
|
|
1426
|
+
while (start < oldLen && start < newLen && oldScopes[start] === newScopes[start]) start++;
|
|
1427
|
+
while (oldEnd >= start && newEnd >= start && oldScopes[oldEnd] === newScopes[newEnd]) {
|
|
1428
|
+
oldEnd--;
|
|
1429
|
+
newEnd--;
|
|
1430
|
+
}
|
|
1431
|
+
if (oldEnd + 1 < oldLen) afterReference = oldScopes[oldEnd + 1]["#StartNode"];
|
|
1432
|
+
if (start > oldEnd) {
|
|
1433
|
+
if (start <= newEnd) for (let i = start; i <= newEnd; i++) insertBranchBefore(newScopes[i], parentNode, afterReference);
|
|
1434
|
+
return;
|
|
1435
|
+
} else if (start > newEnd) return;
|
|
1436
|
+
const diffLen = newEnd - start + 1;
|
|
1437
|
+
const oldPos = /* @__PURE__ */ new Map();
|
|
1438
|
+
const sources = new Array(diffLen);
|
|
1439
|
+
const pred = new Array(diffLen);
|
|
1440
|
+
const tails = [];
|
|
1441
|
+
let tail = -1;
|
|
1442
|
+
let lo;
|
|
1443
|
+
let hi;
|
|
1444
|
+
let mid;
|
|
1445
|
+
for (let i = start; i <= oldEnd; i++) oldPos.set(oldScopes[i], i);
|
|
1446
|
+
for (let i = diffLen; i--;) sources[i] = oldPos.get(newScopes[start + i]) ?? -1;
|
|
1447
|
+
for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) {
|
|
1448
|
+
if (~tail) pred[i] = tails[tail];
|
|
1449
|
+
tails[++tail] = i;
|
|
1450
|
+
} else {
|
|
1451
|
+
lo = 0;
|
|
1452
|
+
hi = tail;
|
|
1453
|
+
while (lo < hi) {
|
|
1454
|
+
mid = (lo + hi) / 2 | 0;
|
|
1455
|
+
if (sources[tails[mid]] < sources[i]) lo = mid + 1;
|
|
1456
|
+
else hi = mid;
|
|
1457
|
+
}
|
|
1458
|
+
if (sources[i] < sources[tails[lo]]) {
|
|
1459
|
+
if (lo > 0) pred[i] = tails[lo - 1];
|
|
1460
|
+
tails[lo] = i;
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
hi = tails[tail];
|
|
1464
|
+
lo = tail + 1;
|
|
1465
|
+
while (lo-- > 0) {
|
|
1466
|
+
tails[lo] = hi;
|
|
1467
|
+
hi = pred[hi];
|
|
1468
|
+
}
|
|
1469
|
+
for (let i = diffLen; i--;) {
|
|
1470
|
+
if (~tail && i === tails[tail]) tail--;
|
|
1471
|
+
else insertBranchBefore(newScopes[start + i], parentNode, afterReference);
|
|
1472
|
+
afterReference = newScopes[start + i]["#StartNode"];
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
};
|
|
2181
1476
|
}
|
|
2182
1477
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
tagNameOrRenderer,
|
|
2189
|
-
parentScope,
|
|
2190
|
-
parentNode
|
|
2191
|
-
);
|
|
2192
|
-
if (typeof tagNameOrRenderer === "string") {
|
|
2193
|
-
branch[true ? `#${tagNameOrRenderer}/0` : "a"] = branch["#StartNode" /* StartNode */] = branch["#EndNode" /* EndNode */] = document.createElementNS(
|
|
2194
|
-
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
|
2195
|
-
tagNameOrRenderer
|
|
2196
|
-
);
|
|
2197
|
-
} else {
|
|
2198
|
-
setupBranch(tagNameOrRenderer, branch);
|
|
2199
|
-
}
|
|
2200
|
-
return branch;
|
|
1478
|
+
if (typeof tagNameOrRenderer === "string") assertValidTagName(tagNameOrRenderer);
|
|
1479
|
+
const branch = createBranch($global, tagNameOrRenderer, parentScope, parentNode);
|
|
1480
|
+
if (typeof tagNameOrRenderer === "string") branch[`#${tagNameOrRenderer}/0`] = branch["#StartNode"] = branch["#EndNode"] = document.createElementNS(tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI, tagNameOrRenderer);
|
|
1481
|
+
else setupBranch(tagNameOrRenderer, branch);
|
|
1482
|
+
return branch;
|
|
2201
1483
|
}
|
|
2202
1484
|
function bySecondArg(_item, index) {
|
|
2203
|
-
|
|
1485
|
+
return index;
|
|
2204
1486
|
}
|
|
2205
1487
|
function byFirstArg(name) {
|
|
2206
|
-
|
|
2207
|
-
}
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
function queueRender(scope, signal, signalKey, value, scopeKey = scope["#Id"
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
);
|
|
2233
|
-
signalKey >= 0 && pendingRendersLookup.set(key, render);
|
|
2234
|
-
}
|
|
1488
|
+
return name;
|
|
1489
|
+
}
|
|
1490
|
+
//#endregion
|
|
1491
|
+
//#region src/dom/queue.ts
|
|
1492
|
+
let pendingRenders = [];
|
|
1493
|
+
let pendingRendersLookup = /* @__PURE__ */ new Map();
|
|
1494
|
+
let asyncRendersLookup;
|
|
1495
|
+
const caughtError = /* @__PURE__ */ new WeakSet();
|
|
1496
|
+
const placeholderShown = /* @__PURE__ */ new WeakSet();
|
|
1497
|
+
let pendingEffects = [];
|
|
1498
|
+
let pendingScopes = [];
|
|
1499
|
+
let rendering;
|
|
1500
|
+
const scopeKeyOffset = 1e3;
|
|
1501
|
+
function queueRender(scope, signal, signalKey, value, scopeKey = scope["#Id"]) {
|
|
1502
|
+
const key = scopeKey * scopeKeyOffset + signalKey;
|
|
1503
|
+
let render = signalKey >= 0 && pendingRendersLookup.get(key);
|
|
1504
|
+
if (render) render["value"] = value;
|
|
1505
|
+
else {
|
|
1506
|
+
queuePendingRender(render = {
|
|
1507
|
+
["key"]: key,
|
|
1508
|
+
["scope"]: scope,
|
|
1509
|
+
["signal"]: signal,
|
|
1510
|
+
["value"]: value
|
|
1511
|
+
});
|
|
1512
|
+
signalKey >= 0 && pendingRendersLookup.set(key, render);
|
|
1513
|
+
}
|
|
2235
1514
|
}
|
|
2236
1515
|
function queuePendingRender(render) {
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
1516
|
+
let i = pendingRenders.push(render) - 1;
|
|
1517
|
+
while (i) {
|
|
1518
|
+
const parentIndex = i - 1 >> 1;
|
|
1519
|
+
const parent = pendingRenders[parentIndex];
|
|
1520
|
+
if (render["key"] - parent["key"] >= 0) break;
|
|
1521
|
+
pendingRenders[i] = parent;
|
|
1522
|
+
i = parentIndex;
|
|
1523
|
+
}
|
|
1524
|
+
pendingRenders[i] = render;
|
|
2246
1525
|
}
|
|
2247
1526
|
function queueEffect(scope, fn) {
|
|
2248
|
-
|
|
1527
|
+
pendingEffects.push(fn, scope);
|
|
2249
1528
|
}
|
|
2250
1529
|
function run() {
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
1530
|
+
const effects = pendingEffects;
|
|
1531
|
+
asyncRendersLookup = /* @__PURE__ */ new Map();
|
|
1532
|
+
try {
|
|
1533
|
+
rendering = 1;
|
|
1534
|
+
runRenders();
|
|
1535
|
+
} finally {
|
|
1536
|
+
pendingRendersLookup = asyncRendersLookup;
|
|
1537
|
+
asyncRendersLookup = rendering = 0;
|
|
1538
|
+
pendingRenders = [];
|
|
1539
|
+
pendingEffects = [];
|
|
1540
|
+
}
|
|
1541
|
+
runEffects(effects);
|
|
2263
1542
|
}
|
|
2264
1543
|
function prepareEffects(fn) {
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
effects[i++](effects[i++]);
|
|
2288
|
-
}
|
|
1544
|
+
const prevRenders = pendingRenders;
|
|
1545
|
+
const prevEffects = pendingEffects;
|
|
1546
|
+
const prevLookup = asyncRendersLookup;
|
|
1547
|
+
const preparedEffects = pendingEffects = [];
|
|
1548
|
+
pendingRenders = [];
|
|
1549
|
+
asyncRendersLookup = pendingRendersLookup;
|
|
1550
|
+
pendingRendersLookup = /* @__PURE__ */ new Map();
|
|
1551
|
+
try {
|
|
1552
|
+
rendering = 1;
|
|
1553
|
+
fn();
|
|
1554
|
+
runRenders();
|
|
1555
|
+
} finally {
|
|
1556
|
+
rendering = 0;
|
|
1557
|
+
pendingRendersLookup = asyncRendersLookup;
|
|
1558
|
+
asyncRendersLookup = prevLookup;
|
|
1559
|
+
pendingRenders = prevRenders;
|
|
1560
|
+
pendingEffects = prevEffects;
|
|
1561
|
+
}
|
|
1562
|
+
return preparedEffects;
|
|
1563
|
+
}
|
|
1564
|
+
let runEffects = ((effects) => {
|
|
1565
|
+
for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
|
|
2289
1566
|
});
|
|
2290
1567
|
function runRenders() {
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
render
|
|
2361
|
-
);
|
|
2362
|
-
return branch["#PendingRenders" /* PendingRenders */].push(render);
|
|
2363
|
-
}
|
|
2364
|
-
branch = branch["#ParentBranch" /* ParentBranch */];
|
|
2365
|
-
}
|
|
2366
|
-
runRender2(render);
|
|
2367
|
-
} catch (error) {
|
|
2368
|
-
renderCatch(render.___scope, error);
|
|
2369
|
-
}
|
|
2370
|
-
})(runRender);
|
|
2371
|
-
};
|
|
2372
|
-
|
|
2373
|
-
// src/dom/abort-signal.ts
|
|
1568
|
+
while (pendingRenders.length) {
|
|
1569
|
+
const render = pendingRenders[0];
|
|
1570
|
+
const item = pendingRenders.pop();
|
|
1571
|
+
if (render !== item) {
|
|
1572
|
+
let i = 0;
|
|
1573
|
+
const mid = pendingRenders.length >> 1;
|
|
1574
|
+
const key = (pendingRenders[0] = item)["key"];
|
|
1575
|
+
while (i < mid) {
|
|
1576
|
+
let bestChild = (i << 1) + 1;
|
|
1577
|
+
const right = bestChild + 1;
|
|
1578
|
+
if (right < pendingRenders.length && pendingRenders[right]["key"] - pendingRenders[bestChild]["key"] < 0) bestChild = right;
|
|
1579
|
+
if (pendingRenders[bestChild]["key"] - key >= 0) break;
|
|
1580
|
+
else {
|
|
1581
|
+
pendingRenders[i] = pendingRenders[bestChild];
|
|
1582
|
+
i = bestChild;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
pendingRenders[i] = item;
|
|
1586
|
+
}
|
|
1587
|
+
if (!render["scope"]["#ClosestBranch"]?.["#Destroyed"]) runRender(render);
|
|
1588
|
+
}
|
|
1589
|
+
for (const scope of pendingScopes) scope["#Creating"] = 0;
|
|
1590
|
+
pendingScopes = [];
|
|
1591
|
+
}
|
|
1592
|
+
let runRender = (render) => render["signal"](render["scope"], render["value"]);
|
|
1593
|
+
let catchEnabled;
|
|
1594
|
+
function _enable_catch() {
|
|
1595
|
+
if (!catchEnabled) {
|
|
1596
|
+
catchEnabled = 1;
|
|
1597
|
+
enableBranches();
|
|
1598
|
+
const handlePendingTry = (fn, scope, branch) => {
|
|
1599
|
+
while (branch) {
|
|
1600
|
+
if (branch["#AwaitCounter"]?.i) return (branch["#PendingEffects"] ||= []).push(fn, scope);
|
|
1601
|
+
branch = branch["#ParentBranch"];
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1604
|
+
runEffects = ((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
|
|
1605
|
+
if (checkPending || caughtError.has(effects)) {
|
|
1606
|
+
let i = 0;
|
|
1607
|
+
let fn;
|
|
1608
|
+
let scope;
|
|
1609
|
+
let branch;
|
|
1610
|
+
for (; i < effects.length;) {
|
|
1611
|
+
fn = effects[i++];
|
|
1612
|
+
scope = effects[i++];
|
|
1613
|
+
branch = scope["#ClosestBranch"];
|
|
1614
|
+
if (!branch?.["#Destroyed"] && !(checkPending && handlePendingTry(fn, scope, branch))) fn(scope);
|
|
1615
|
+
}
|
|
1616
|
+
} else runEffects(effects);
|
|
1617
|
+
})(runEffects);
|
|
1618
|
+
runRender = ((runRender) => (render) => {
|
|
1619
|
+
try {
|
|
1620
|
+
let branch = render["scope"]["#ClosestBranch"];
|
|
1621
|
+
while (branch) {
|
|
1622
|
+
if (branch["#PendingRenders"]) {
|
|
1623
|
+
asyncRendersLookup.set(render["key"], render);
|
|
1624
|
+
return branch["#PendingRenders"].push(render);
|
|
1625
|
+
}
|
|
1626
|
+
branch = branch["#ParentBranch"];
|
|
1627
|
+
}
|
|
1628
|
+
runRender(render);
|
|
1629
|
+
} catch (error) {
|
|
1630
|
+
renderCatch(render["scope"], error);
|
|
1631
|
+
}
|
|
1632
|
+
})(runRender);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
//#endregion
|
|
1636
|
+
//#region src/dom/abort-signal.ts
|
|
2374
1637
|
function $signalReset(scope, id) {
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
1638
|
+
const ctrl = scope["#AbortControllers"]?.[id];
|
|
1639
|
+
if (ctrl) {
|
|
1640
|
+
queueEffect(ctrl, abort);
|
|
1641
|
+
scope["#AbortControllers"][id] = void 0;
|
|
1642
|
+
}
|
|
2380
1643
|
}
|
|
2381
1644
|
function $signal(scope, id) {
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
}
|
|
2385
|
-
return ((scope["#AbortControllers" /* AbortControllers */] ||= {})[id] ||= new AbortController()).signal;
|
|
1645
|
+
if (scope["#ClosestBranch"]) (scope["#ClosestBranch"]["#AbortScopes"] ||= /* @__PURE__ */ new Set()).add(scope);
|
|
1646
|
+
return ((scope["#AbortControllers"] ||= {})[id] ||= new AbortController()).signal;
|
|
2386
1647
|
}
|
|
2387
1648
|
function abort(ctrl) {
|
|
2388
|
-
|
|
2389
|
-
}
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
}
|
|
2462
|
-
}
|
|
2463
|
-
component.effects = prepareEffects(() => {
|
|
2464
|
-
if (!branch) {
|
|
2465
|
-
created = 1;
|
|
2466
|
-
branch = component.scope = createAndSetupBranch(
|
|
2467
|
-
out.global,
|
|
2468
|
-
renderer,
|
|
2469
|
-
renderer.___owner,
|
|
2470
|
-
document.body
|
|
2471
|
-
);
|
|
2472
|
-
}
|
|
2473
|
-
renderer.___params?.(branch, renderer._ ? args[0] : args);
|
|
2474
|
-
});
|
|
2475
|
-
if (created) {
|
|
2476
|
-
return toInsertNode(
|
|
2477
|
-
branch["#StartNode" /* StartNode */],
|
|
2478
|
-
branch["#EndNode" /* EndNode */]
|
|
2479
|
-
);
|
|
2480
|
-
}
|
|
2481
|
-
}
|
|
1649
|
+
ctrl.abort();
|
|
1650
|
+
}
|
|
1651
|
+
//#endregion
|
|
1652
|
+
//#region src/common/compat-meta.ts
|
|
1653
|
+
const prefix = "$compat_";
|
|
1654
|
+
const RENDERER_REGISTER_ID = prefix + "renderer";
|
|
1655
|
+
const SET_SCOPE_REGISTER_ID = prefix + "setScope";
|
|
1656
|
+
const RENDER_BODY_ID = prefix + "renderBody";
|
|
1657
|
+
//#endregion
|
|
1658
|
+
//#region src/dom/compat.ts
|
|
1659
|
+
const classIdToBranch = /* @__PURE__ */ new Map();
|
|
1660
|
+
const compat = {
|
|
1661
|
+
patchDynamicTag,
|
|
1662
|
+
queueEffect,
|
|
1663
|
+
init(warp10Noop) {
|
|
1664
|
+
_resume(SET_SCOPE_REGISTER_ID, (branch) => {
|
|
1665
|
+
classIdToBranch.set(branch.m5c, branch);
|
|
1666
|
+
});
|
|
1667
|
+
_resume(RENDER_BODY_ID, warp10Noop);
|
|
1668
|
+
},
|
|
1669
|
+
registerRenderer(fn) {
|
|
1670
|
+
_resume(RENDERER_REGISTER_ID, fn);
|
|
1671
|
+
},
|
|
1672
|
+
isRenderer(renderer) {
|
|
1673
|
+
return renderer["clone"];
|
|
1674
|
+
},
|
|
1675
|
+
getStartNode(branch) {
|
|
1676
|
+
return branch["#StartNode"];
|
|
1677
|
+
},
|
|
1678
|
+
setScopeNodes(branch, startNode, endNode) {
|
|
1679
|
+
branch["#StartNode"] = startNode;
|
|
1680
|
+
branch["#EndNode"] = endNode;
|
|
1681
|
+
},
|
|
1682
|
+
runComponentEffects() {
|
|
1683
|
+
if (this.effects) runEffects(this.effects);
|
|
1684
|
+
},
|
|
1685
|
+
runComponentDestroy() {
|
|
1686
|
+
if (this.scope) destroyBranch(this.scope);
|
|
1687
|
+
},
|
|
1688
|
+
resolveRegistered(value, $global) {
|
|
1689
|
+
if (Array.isArray(value) && typeof value[0] === "string") return getRegisteredWithScope(value[0], value.length === 2 && self[$global.runtimeId]?.[$global.renderId]?.s[value[1]]);
|
|
1690
|
+
return value;
|
|
1691
|
+
},
|
|
1692
|
+
createRenderer(params, clone) {
|
|
1693
|
+
const renderer = _content("", 0, 0, 0, params)();
|
|
1694
|
+
renderer["clone"] = (branch) => {
|
|
1695
|
+
const cloned = clone();
|
|
1696
|
+
branch["#StartNode"] = cloned.startNode;
|
|
1697
|
+
branch["#EndNode"] = cloned.endNode;
|
|
1698
|
+
};
|
|
1699
|
+
return renderer;
|
|
1700
|
+
},
|
|
1701
|
+
render(out, component, renderer, args) {
|
|
1702
|
+
let branch = component.scope;
|
|
1703
|
+
let created = 0;
|
|
1704
|
+
if (!branch && (branch = classIdToBranch.get(component.id))) {
|
|
1705
|
+
component.scope = branch;
|
|
1706
|
+
classIdToBranch.delete(component.id);
|
|
1707
|
+
}
|
|
1708
|
+
if (typeof args[0] === "object" && "renderBody" in args[0]) {
|
|
1709
|
+
const input = args[0];
|
|
1710
|
+
const normalizedInput = args[0] = {};
|
|
1711
|
+
for (const key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
|
1712
|
+
}
|
|
1713
|
+
component.effects = prepareEffects(() => {
|
|
1714
|
+
if (!branch) {
|
|
1715
|
+
created = 1;
|
|
1716
|
+
branch = component.scope = createAndSetupBranch(out.global, renderer, renderer["owner"], document.body);
|
|
1717
|
+
}
|
|
1718
|
+
renderer["params"]?.(branch, renderer._ ? args[0] : args);
|
|
1719
|
+
});
|
|
1720
|
+
if (created) return toInsertNode(branch["#StartNode"], branch["#EndNode"]);
|
|
1721
|
+
}
|
|
2482
1722
|
};
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
renderer.mount = mount;
|
|
2494
|
-
renderer._ = renderer;
|
|
2495
|
-
if (true) {
|
|
2496
|
-
renderer.render = () => {
|
|
2497
|
-
throw new Error(
|
|
2498
|
-
`render() is not implemented for the DOM compilation of a Marko template`
|
|
2499
|
-
);
|
|
2500
|
-
};
|
|
2501
|
-
}
|
|
2502
|
-
return _resume(id, renderer);
|
|
1723
|
+
//#endregion
|
|
1724
|
+
//#region src/dom/template.ts
|
|
1725
|
+
const _template = (id, template, walks, setup, inputSignal) => {
|
|
1726
|
+
const renderer = _content(id, template, walks, setup, inputSignal)();
|
|
1727
|
+
renderer.mount = mount;
|
|
1728
|
+
renderer._ = renderer;
|
|
1729
|
+
renderer.render = () => {
|
|
1730
|
+
throw new Error(`render() is not implemented for the DOM compilation of a Marko template`);
|
|
1731
|
+
};
|
|
1732
|
+
return _resume(id, renderer);
|
|
2503
1733
|
};
|
|
2504
1734
|
function mount(input = {}, reference, position) {
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
branch["#EndNode" /* EndNode */]
|
|
2567
|
-
);
|
|
2568
|
-
runEffects(effects);
|
|
2569
|
-
return {
|
|
2570
|
-
get value() {
|
|
2571
|
-
return curValue;
|
|
2572
|
-
},
|
|
2573
|
-
set value(newValue) {
|
|
2574
|
-
_var_change(branch, newValue);
|
|
2575
|
-
},
|
|
2576
|
-
update(newInput) {
|
|
2577
|
-
if (args) {
|
|
2578
|
-
runEffects(
|
|
2579
|
-
prepareEffects(() => {
|
|
2580
|
-
args(branch, newInput);
|
|
2581
|
-
})
|
|
2582
|
-
);
|
|
2583
|
-
}
|
|
2584
|
-
},
|
|
2585
|
-
destroy() {
|
|
2586
|
-
removeAndDestroyBranch(branch);
|
|
2587
|
-
}
|
|
2588
|
-
};
|
|
2589
|
-
}
|
|
2590
|
-
export {
|
|
2591
|
-
$signal,
|
|
2592
|
-
$signalReset,
|
|
2593
|
-
_assert_hoist,
|
|
2594
|
-
_assert_init,
|
|
2595
|
-
_attr,
|
|
2596
|
-
_attr_class,
|
|
2597
|
-
_attr_class_item,
|
|
2598
|
-
_attr_class_items,
|
|
2599
|
-
_attr_content,
|
|
2600
|
-
_attr_details_or_dialog_open as _attr_details_open,
|
|
2601
|
-
_attr_details_or_dialog_open_default as _attr_details_open_default,
|
|
2602
|
-
_attr_details_or_dialog_open_script as _attr_details_open_script,
|
|
2603
|
-
_attr_details_or_dialog_open as _attr_dialog_open,
|
|
2604
|
-
_attr_details_or_dialog_open_default as _attr_dialog_open_default,
|
|
2605
|
-
_attr_details_or_dialog_open_script as _attr_dialog_open_script,
|
|
2606
|
-
_attr_input_checked,
|
|
2607
|
-
_attr_input_checkedValue,
|
|
2608
|
-
_attr_input_checkedValue_default,
|
|
2609
|
-
_attr_input_checkedValue_script,
|
|
2610
|
-
_attr_input_checked_default,
|
|
2611
|
-
_attr_input_checked_script,
|
|
2612
|
-
_attr_input_value,
|
|
2613
|
-
_attr_input_value_default,
|
|
2614
|
-
_attr_input_value_script,
|
|
2615
|
-
_attr_nonce,
|
|
2616
|
-
_attr_select_value,
|
|
2617
|
-
_attr_select_value_default,
|
|
2618
|
-
_attr_select_value_script,
|
|
2619
|
-
_attr_style,
|
|
2620
|
-
_attr_style_item,
|
|
2621
|
-
_attr_style_items,
|
|
2622
|
-
_attr_input_value as _attr_textarea_value,
|
|
2623
|
-
_attr_input_value_default as _attr_textarea_value_default,
|
|
2624
|
-
_attr_input_value_script as _attr_textarea_value_script,
|
|
2625
|
-
_attrs,
|
|
2626
|
-
_attrs_content,
|
|
2627
|
-
_attrs_partial,
|
|
2628
|
-
_attrs_partial_content,
|
|
2629
|
-
_attrs_script,
|
|
2630
|
-
_await_content,
|
|
2631
|
-
_await_promise,
|
|
2632
|
-
_call,
|
|
2633
|
-
_child_setup,
|
|
2634
|
-
_closure,
|
|
2635
|
-
_closure_get,
|
|
2636
|
-
_const,
|
|
2637
|
-
_content,
|
|
2638
|
-
_content_closures,
|
|
2639
|
-
_content_resume,
|
|
2640
|
-
_dynamic_tag,
|
|
2641
|
-
_el,
|
|
2642
|
-
_el_read,
|
|
2643
|
-
_enable_catch,
|
|
2644
|
-
_for_closure,
|
|
2645
|
-
_for_in,
|
|
2646
|
-
_for_of,
|
|
2647
|
-
_for_to,
|
|
2648
|
-
_for_until,
|
|
2649
|
-
_hoist,
|
|
2650
|
-
_hoist_resume,
|
|
2651
|
-
_html,
|
|
2652
|
-
_id,
|
|
2653
|
-
_if,
|
|
2654
|
-
_if_closure,
|
|
2655
|
-
_let,
|
|
2656
|
-
_lifecycle,
|
|
2657
|
-
_on,
|
|
2658
|
-
_or,
|
|
2659
|
-
_resume,
|
|
2660
|
-
_resume_dynamic_tag,
|
|
2661
|
-
_return,
|
|
2662
|
-
_return_change,
|
|
2663
|
-
_script,
|
|
2664
|
-
_template,
|
|
2665
|
-
_text,
|
|
2666
|
-
_text_content,
|
|
2667
|
-
_to_text,
|
|
2668
|
-
_try,
|
|
2669
|
-
_var,
|
|
2670
|
-
_var_change,
|
|
2671
|
-
_var_resume,
|
|
2672
|
-
attrTag,
|
|
2673
|
-
attrTags,
|
|
2674
|
-
compat,
|
|
2675
|
-
forIn,
|
|
2676
|
-
forOf,
|
|
2677
|
-
forTo,
|
|
2678
|
-
forUntil,
|
|
2679
|
-
init,
|
|
2680
|
-
initEmbedded,
|
|
2681
|
-
run
|
|
2682
|
-
};
|
|
1735
|
+
let branch;
|
|
1736
|
+
let parentNode = reference;
|
|
1737
|
+
let nextSibling = null;
|
|
1738
|
+
let { $global } = input;
|
|
1739
|
+
if ($global) {
|
|
1740
|
+
({$global, ...input} = input);
|
|
1741
|
+
$global = {
|
|
1742
|
+
runtimeId: "M",
|
|
1743
|
+
renderId: "_",
|
|
1744
|
+
...$global
|
|
1745
|
+
};
|
|
1746
|
+
if (!String($global.runtimeId).match(/^[_$a-z][_$a-z0-9]*$/i)) throw new Error(`Invalid runtimeId: "${$global.runtimeId}". The runtimeId must be a valid JavaScript identifier.`);
|
|
1747
|
+
if (!String($global.renderId).match(/^[_$a-z][_$a-z0-9]*$/i)) throw new Error(`Invalid renderId: "${$global.renderId}". The renderId must be a valid JavaScript identifier.`);
|
|
1748
|
+
} else $global = {
|
|
1749
|
+
runtimeId: "M",
|
|
1750
|
+
renderId: "_"
|
|
1751
|
+
};
|
|
1752
|
+
switch (position) {
|
|
1753
|
+
case "beforebegin":
|
|
1754
|
+
parentNode = reference.parentNode;
|
|
1755
|
+
nextSibling = reference;
|
|
1756
|
+
break;
|
|
1757
|
+
case "afterbegin":
|
|
1758
|
+
nextSibling = reference.firstChild;
|
|
1759
|
+
break;
|
|
1760
|
+
case "afterend":
|
|
1761
|
+
parentNode = reference.parentNode;
|
|
1762
|
+
nextSibling = reference.nextSibling;
|
|
1763
|
+
break;
|
|
1764
|
+
}
|
|
1765
|
+
let curValue;
|
|
1766
|
+
const args = this["params"];
|
|
1767
|
+
const effects = prepareEffects(() => {
|
|
1768
|
+
branch = createBranch($global, this, void 0, parentNode);
|
|
1769
|
+
branch["#TagVariable"] = (newValue) => {
|
|
1770
|
+
curValue = newValue;
|
|
1771
|
+
};
|
|
1772
|
+
this["setup"]?.(branch);
|
|
1773
|
+
args?.(branch, input);
|
|
1774
|
+
});
|
|
1775
|
+
insertChildNodes(parentNode, nextSibling, branch["#StartNode"], branch["#EndNode"]);
|
|
1776
|
+
runEffects(effects);
|
|
1777
|
+
return {
|
|
1778
|
+
get value() {
|
|
1779
|
+
return curValue;
|
|
1780
|
+
},
|
|
1781
|
+
set value(newValue) {
|
|
1782
|
+
_var_change(branch, newValue);
|
|
1783
|
+
},
|
|
1784
|
+
update(newInput) {
|
|
1785
|
+
if (args) runEffects(prepareEffects(() => {
|
|
1786
|
+
args(branch, newInput);
|
|
1787
|
+
}));
|
|
1788
|
+
},
|
|
1789
|
+
destroy() {
|
|
1790
|
+
removeAndDestroyBranch(branch);
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
}
|
|
1794
|
+
//#endregion
|
|
1795
|
+
export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _dynamic_tag, _el, _el_read, _enable_catch, _for_closure, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _lifecycle, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, run };
|