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