marko 6.0.164 → 6.0.166
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/accessor.d.ts +22 -0
- package/dist/common/accessor.debug.d.ts +22 -0
- package/dist/common/helpers.d.ts +3 -2
- package/dist/common/types.d.ts +1 -1
- package/dist/debug/dom.js +1613 -2426
- package/dist/debug/dom.mjs +1517 -2404
- package/dist/debug/html.js +2437 -3356
- package/dist/debug/html.mjs +2360 -3264
- package/dist/dom/compat.d.ts +2 -1
- package/dist/dom/queue.d.ts +6 -6
- package/dist/dom/renderer.d.ts +9 -9
- package/dist/dom/signals.d.ts +5 -9
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +844 -1413
- package/dist/dom.mjs +840 -1394
- package/dist/html/template.d.ts +3 -3
- package/dist/html.js +1447 -2112
- package/dist/html.mjs +1443 -2022
- package/dist/translator/index.js +8046 -13063
- package/dist/translator/util/normalize-string-expression.d.ts +1 -1
- package/package.json +2 -2
package/dist/dom.mjs
CHANGED
|
@@ -1,1663 +1,1109 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
|
|
2
|
+
let str = "", sep = "", part;
|
|
3
|
+
if (val) if (typeof val != "object") str += val;
|
|
4
|
+
else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
5
|
+
else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
6
|
+
return str;
|
|
7
|
+
}, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), defaultDelegator = /* @__PURE__ */ createDelegator(), R = /[^\p{L}\p{N}]/gu, parsers = {}, nextScopeId = 1e6, destroyNestedScopes = function destroyNestedScopes(scope) {
|
|
8
|
+
scope.I = 1, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(resetControllers);
|
|
9
|
+
}, isScheduled, channel, _return = (scope, value) => scope.T?.(value), _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), walker = /* @__PURE__ */ document.createTreeWalker(document), walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
10
|
+
let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
|
|
11
|
+
for (; currentWalkIndex < walkCodes.length;) if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32) {
|
|
12
|
+
let node = walker.currentNode;
|
|
13
|
+
scope[decodeAccessor(currentScopeIndex++)] = node;
|
|
14
|
+
} else if (value === 37 || value === 49) walker.currentNode.replaceWith(walker.currentNode = scope[decodeAccessor(currentScopeIndex++)] = new Text()), value === 49 && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
|
|
15
|
+
else if (value === 38) return currentWalkIndex;
|
|
16
|
+
else if (value === 47 || value === 48) currentWalkIndex = walkInternal(currentWalkIndex, walkCodes, scope[decodeAccessor(currentScopeIndex++)] = createScope(scope.$, scope.F)), value === 48 && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
|
|
17
|
+
else if (value < 92) for (value = 20 * currentMultiplier + value - 67; value--;) walker.nextNode();
|
|
18
|
+
else if (value < 107) for (value = 10 * currentMultiplier + value - 97; value--;) walker.nextSibling();
|
|
19
|
+
else if (value < 117) {
|
|
20
|
+
for (value = 10 * currentMultiplier + value - 107; value--;) walker.parentNode();
|
|
21
|
+
walker.nextSibling();
|
|
22
|
+
} else storedMultiplier = currentMultiplier * 10 + value - 117;
|
|
23
|
+
}, cloneCache = {}, registeredValues = {}, curRuntimeId, readyLookup, branchesEnabled, embedEnabled, ready = /* @__PURE__ */ ((_) => (id) => {
|
|
24
|
+
readyLookup[id]?.(), readyLookup[id] = 1;
|
|
25
|
+
})(readyLookup = {}), isResuming, inputType = "", controllableDelegate = /* @__PURE__ */ createDelegator(), _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
26
|
+
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
27
|
+
let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
|
|
28
|
+
return enableBranches(), (scope, newRenderer, getInput) => {
|
|
29
|
+
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
|
30
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.a || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) if (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer), getTagVar && (scope[childScopeAccessor].T = (value) => getTagVar()(scope, value)), typeof normalizedRenderer == "string") {
|
|
31
|
+
if (getContent) {
|
|
32
|
+
let content = getContent(scope);
|
|
33
|
+
setConditionalRenderer(scope[childScopeAccessor], "a", content, createAndSetupBranch), content.f && subscribeToScopeSet(content.e, content.f, scope[childScopeAccessor].Aa);
|
|
34
|
+
}
|
|
35
|
+
} else normalizedRenderer?.f && subscribeToScopeSet(normalizedRenderer.e, normalizedRenderer.f, scope[childScopeAccessor]);
|
|
36
|
+
if (normalizedRenderer) {
|
|
37
|
+
let childScope = scope[childScopeAccessor], args = getInput?.();
|
|
38
|
+
if (typeof normalizedRenderer == "string") (getContent ? _attrs : _attrs_content)(childScope, "a", (inputIsArgs ? args[0] : args) || {}), (childScope.Ia || childScope.Ea) && queueEffect(childScope, dynamicTagScript);
|
|
39
|
+
else {
|
|
40
|
+
for (let accessor in normalizedRenderer.g) normalizedRenderer.g[accessor](childScope, normalizedRenderer.h[accessor]);
|
|
41
|
+
if (normalizedRenderer.d) if (inputIsArgs) normalizedRenderer.d(childScope, normalizedRenderer._ ? args[0] : args);
|
|
42
|
+
else {
|
|
43
|
+
let inputWithContent = getContent ? {
|
|
44
|
+
...args,
|
|
45
|
+
content: getContent(scope)
|
|
46
|
+
} : args || {};
|
|
47
|
+
normalizedRenderer.d(childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}, _for_of = /* @__PURE__ */ loop(([all, by = bySecondArg], cb) => {
|
|
53
|
+
typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
54
|
+
}), _for_in = /* @__PURE__ */ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))), _for_to = /* @__PURE__ */ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))), _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))), pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), asyncRendersLookup, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, runEffects = ((effects) => {
|
|
55
|
+
for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
|
|
56
|
+
}), runRender = (render) => render.c(render.b, render.d), catchEnabled, classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
57
|
+
patchDynamicTag,
|
|
58
|
+
queueEffect,
|
|
59
|
+
init(warp10Noop) {
|
|
60
|
+
_resume("$C_s", (branch) => {
|
|
61
|
+
classIdToBranch.set(branch.m5c, branch);
|
|
62
|
+
}), _resume("$C_b", warp10Noop);
|
|
63
|
+
},
|
|
64
|
+
registerRenderer(fn) {
|
|
65
|
+
_resume("$C_r", fn);
|
|
66
|
+
},
|
|
67
|
+
isRenderer(renderer) {
|
|
68
|
+
return renderer.b;
|
|
69
|
+
},
|
|
70
|
+
getStartNode(branch) {
|
|
71
|
+
return branch.S;
|
|
72
|
+
},
|
|
73
|
+
setScopeNodes(branch, startNode, endNode) {
|
|
74
|
+
branch.S = startNode, branch.K = endNode;
|
|
75
|
+
},
|
|
76
|
+
runComponentEffects() {
|
|
77
|
+
this.effects && runEffects(this.effects);
|
|
78
|
+
},
|
|
79
|
+
runComponentDestroy() {
|
|
80
|
+
this.scope && destroyBranch(this.scope);
|
|
81
|
+
},
|
|
82
|
+
resolveRegistered(value, $global) {
|
|
83
|
+
return Array.isArray(value) && typeof value[0] == "string" ? getRegisteredWithScope(value[0], value.length === 2 && self[$global.runtimeId]?.[$global.renderId]?.s[value[1]]) : value;
|
|
84
|
+
},
|
|
85
|
+
createRenderer(params, clone) {
|
|
86
|
+
let renderer = _content("", 0, 0, 0, params)();
|
|
87
|
+
return renderer.b = (branch) => {
|
|
88
|
+
let cloned = clone();
|
|
89
|
+
branch.S = cloned.startNode, branch.K = cloned.endNode;
|
|
90
|
+
}, renderer;
|
|
91
|
+
},
|
|
92
|
+
render(out, component, renderer, args) {
|
|
93
|
+
let branch = component.scope, created = 0;
|
|
94
|
+
if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), typeof args[0] == "object" && "renderBody" in args[0]) {
|
|
95
|
+
let input = args[0], normalizedInput = args[0] = {};
|
|
96
|
+
for (let key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
|
97
|
+
}
|
|
98
|
+
if (component.effects = prepareEffects(() => {
|
|
99
|
+
branch ||= (created = 1, component.scope = createAndSetupBranch(out.global, renderer, renderer.e, document.body)), renderer.d?.(branch, renderer._ ? args[0] : args);
|
|
100
|
+
}), created) return toInsertNode(branch.S, branch.K);
|
|
101
|
+
}
|
|
102
|
+
}, _template = (id, template, walks, setup, inputSignal) => {
|
|
103
|
+
let renderer = _content(id, template, walks, setup, inputSignal)();
|
|
104
|
+
return renderer.mount = mount, renderer._ = renderer, _resume(id, renderer);
|
|
105
|
+
};
|
|
106
|
+
//#region src/common/attr-tag.ts
|
|
3
107
|
function attrTag(attrs) {
|
|
4
|
-
|
|
108
|
+
return attrs[Symbol.iterator] = attrTagIterator, attrs[rest] = empty, attrs;
|
|
5
109
|
}
|
|
6
110
|
function attrTags(first, attrs) {
|
|
7
|
-
|
|
111
|
+
return first ? (first[rest] === empty ? first[rest] = [attrs] : first[rest].push(attrs), first) : attrTag(attrs);
|
|
8
112
|
}
|
|
9
113
|
function* attrTagIterator() {
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// src/common/errors.ts
|
|
14
|
-
function _assert_hoist(value) {
|
|
114
|
+
yield this, yield* this[rest];
|
|
15
115
|
}
|
|
116
|
+
function _assert_hoist(value) {}
|
|
16
117
|
function _assert_init(scope, accessor) {
|
|
17
|
-
|
|
118
|
+
return scope[accessor];
|
|
18
119
|
}
|
|
19
|
-
|
|
20
|
-
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/common/for.ts
|
|
21
122
|
function forIn(obj, cb) {
|
|
22
|
-
|
|
23
|
-
cb(key, obj[key]);
|
|
123
|
+
for (let key in obj) cb(key, obj[key]);
|
|
24
124
|
}
|
|
25
125
|
function forOf(list, cb) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
126
|
+
if (list) {
|
|
127
|
+
let i = 0;
|
|
128
|
+
for (let item of list) cb(item, i++);
|
|
129
|
+
}
|
|
31
130
|
}
|
|
32
131
|
function forTo(to, from, step, cb) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
cb(start + i * delta);
|
|
132
|
+
let start = from || 0, delta = step || 1;
|
|
133
|
+
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
36
134
|
}
|
|
37
135
|
function forUntil(until, from, step, cb) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
cb(start + i * delta);
|
|
136
|
+
let start = from || 0, delta = step || 1;
|
|
137
|
+
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
41
138
|
}
|
|
42
|
-
|
|
43
|
-
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/common/helpers.ts
|
|
44
141
|
function _call(fn, v) {
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
function classValue(classValue2) {
|
|
48
|
-
return toDelimitedString(classValue2, " ", stringifyClassObject);
|
|
142
|
+
return fn(v), v;
|
|
49
143
|
}
|
|
50
144
|
function stringifyClassObject(name, value) {
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
function styleValue(styleValue2) {
|
|
54
|
-
return toDelimitedString(styleValue2, ";", stringifyStyleObject);
|
|
145
|
+
return value ? name : "";
|
|
55
146
|
}
|
|
56
147
|
function stringifyStyleObject(name, value) {
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
function toDelimitedString(val, delimiter, stringify) {
|
|
60
|
-
let str = "", sep = "", part;
|
|
61
|
-
if (val)
|
|
62
|
-
if (typeof val != "object")
|
|
63
|
-
str += val;
|
|
64
|
-
else if (Array.isArray(val))
|
|
65
|
-
for (let v of val)
|
|
66
|
-
part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
67
|
-
else
|
|
68
|
-
for (let name in val)
|
|
69
|
-
part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
70
|
-
return str;
|
|
148
|
+
return value || value === 0 ? name + ":" + value : "";
|
|
71
149
|
}
|
|
72
150
|
function isEventHandler(name) {
|
|
73
|
-
|
|
151
|
+
return /^on[A-Z-]/.test(name);
|
|
74
152
|
}
|
|
75
153
|
function getEventHandlerName(name) {
|
|
76
|
-
|
|
154
|
+
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
77
155
|
}
|
|
78
156
|
function normalizeDynamicRenderer(value) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// src/common/opt.ts
|
|
157
|
+
if (value) {
|
|
158
|
+
if (typeof value == "string") return value;
|
|
159
|
+
let normalized = value.content || value.default || value;
|
|
160
|
+
if ("a" in normalized) return normalized;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/common/opt.ts
|
|
89
165
|
function toArray(opt) {
|
|
90
|
-
|
|
166
|
+
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
91
167
|
}
|
|
92
168
|
function push(opt, item) {
|
|
93
|
-
|
|
169
|
+
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
94
170
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
var defaultDelegator = createDelegator();
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/dom/event.ts
|
|
98
173
|
function _on(element, type, handler) {
|
|
99
|
-
|
|
174
|
+
element["$" + type] === void 0 && defaultDelegator(element, type, handleDelegated), element["$" + type] = handler || null;
|
|
100
175
|
}
|
|
176
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
101
177
|
function createDelegator() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
178
|
+
let kEvents = Symbol();
|
|
179
|
+
return function(node, type, handler) {
|
|
180
|
+
((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, !0), 1);
|
|
181
|
+
};
|
|
106
182
|
}
|
|
107
183
|
function handleDelegated(ev) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
let count = before.replace(R, "").length, pos = 0;
|
|
127
|
-
for (; count && updatedValue[pos]; )
|
|
128
|
-
updatedValue[pos++].replace(R, "") && count--;
|
|
129
|
-
return pos;
|
|
130
|
-
}
|
|
131
|
-
return -1;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// src/dom/parse-html.ts
|
|
135
|
-
var parsers = {};
|
|
184
|
+
let target = !rendering && ev.target;
|
|
185
|
+
for (; target;) target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/dom/resolve-cursor-position.ts
|
|
189
|
+
function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
|
|
190
|
+
if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
|
|
191
|
+
let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
|
|
192
|
+
if (updatedValue.startsWith(before)) return initialPosition;
|
|
193
|
+
if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
|
|
194
|
+
let count = before.replace(R, "").length, pos = 0;
|
|
195
|
+
for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
|
|
196
|
+
return pos;
|
|
197
|
+
}
|
|
198
|
+
return -1;
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/dom/parse-html.ts
|
|
136
202
|
function parseHTML(html, ns) {
|
|
137
|
-
|
|
138
|
-
|
|
203
|
+
let parser = parsers[ns] ||= document.createElementNS(ns, "template");
|
|
204
|
+
return parser.innerHTML = html, parser.content || parser;
|
|
139
205
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
var nextScopeId = 1e6;
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/dom/scope.ts
|
|
143
208
|
function createScope($global, closestBranch) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
209
|
+
let scope = {
|
|
210
|
+
L: nextScopeId++,
|
|
211
|
+
H: 1,
|
|
212
|
+
F: closestBranch,
|
|
213
|
+
$: $global
|
|
214
|
+
};
|
|
215
|
+
return pendingScopes.push(scope), scope;
|
|
151
216
|
}
|
|
152
217
|
function skipScope() {
|
|
153
|
-
|
|
218
|
+
return nextScopeId++;
|
|
154
219
|
}
|
|
155
220
|
function findBranchWithKey(scope, key) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return branch;
|
|
221
|
+
let branch = scope.F;
|
|
222
|
+
for (; branch && branch[key] == null;) branch = branch.N;
|
|
223
|
+
return branch;
|
|
160
224
|
}
|
|
161
225
|
function destroyBranch(branch) {
|
|
162
|
-
|
|
163
|
-
branch
|
|
164
|
-
), destroyNestedScopes(branch);
|
|
226
|
+
branch.N?.D?.delete(branch), destroyNestedScopes(branch);
|
|
165
227
|
}
|
|
166
228
|
function destroyScope(scope) {
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
function destroyNestedScopes(scope) {
|
|
170
|
-
scope.I = 1, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(resetControllers);
|
|
229
|
+
scope.I || (destroyNestedScopes(scope), resetControllers(scope));
|
|
171
230
|
}
|
|
172
231
|
function resetControllers(scope) {
|
|
173
|
-
|
|
174
|
-
$signalReset(scope, id);
|
|
232
|
+
for (let id in scope.A) $signalReset(scope, id);
|
|
175
233
|
}
|
|
176
234
|
function removeAndDestroyBranch(branch) {
|
|
177
|
-
|
|
178
|
-
branch.S,
|
|
179
|
-
branch.K
|
|
180
|
-
);
|
|
235
|
+
destroyBranch(branch), removeChildNodes(branch.S, branch.K);
|
|
181
236
|
}
|
|
182
237
|
function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
183
|
-
|
|
184
|
-
parentNode,
|
|
185
|
-
nextSibling,
|
|
186
|
-
branch.S,
|
|
187
|
-
branch.K
|
|
188
|
-
);
|
|
238
|
+
insertChildNodes(parentNode, nextSibling, branch.S, branch.K);
|
|
189
239
|
}
|
|
190
240
|
function tempDetachBranch(branch) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
branch.K
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// src/dom/schedule.ts
|
|
201
|
-
var isScheduled, channel;
|
|
241
|
+
let fragment = new DocumentFragment();
|
|
242
|
+
fragment.namespaceURI = branch.S.parentNode.namespaceURI, insertChildNodes(fragment, null, branch.S, branch.K);
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/dom/schedule.ts
|
|
202
246
|
function schedule() {
|
|
203
|
-
|
|
247
|
+
isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
|
|
204
248
|
}
|
|
205
249
|
function flushAndWaitFrame() {
|
|
206
|
-
|
|
250
|
+
run(), requestAnimationFrame(triggerMacroTask);
|
|
207
251
|
}
|
|
208
252
|
function triggerMacroTask() {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
253
|
+
channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
|
|
254
|
+
isScheduled = 0, run();
|
|
255
|
+
}), channel.port2.postMessage(0);
|
|
212
256
|
}
|
|
213
|
-
|
|
214
|
-
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/dom/signals.ts
|
|
215
259
|
function _let(id, fn) {
|
|
216
|
-
|
|
217
|
-
|
|
260
|
+
let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" + valueAccessor;
|
|
261
|
+
return (scope, value, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value || scope.H) && (scope[valueAccessor] = value, fn?.(scope)) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value) : scope[valueAccessor] !== (scope[valueAccessor] = value) && fn && (schedule(), queueRender(scope, fn, id)), value);
|
|
218
262
|
}
|
|
219
263
|
function _const(valueAccessor, fn) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
264
|
+
return valueAccessor = decodeAccessor(valueAccessor), (scope, value) => {
|
|
265
|
+
(!(valueAccessor in scope) || scope[valueAccessor] !== value) && (scope[valueAccessor] = value, fn?.(scope));
|
|
266
|
+
};
|
|
223
267
|
}
|
|
224
|
-
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L"
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
268
|
+
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L") {
|
|
269
|
+
return scopeIdAccessor !== "L" && (scopeIdAccessor = decodeAccessor(scopeIdAccessor)), (scope) => {
|
|
270
|
+
scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
271
|
+
};
|
|
228
272
|
}
|
|
229
273
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
},
|
|
239
|
-
-1,
|
|
240
|
-
0,
|
|
241
|
-
scopes[0].L
|
|
242
|
-
);
|
|
243
|
-
};
|
|
244
|
-
return ownerSignal._ = fn, ownerSignal;
|
|
274
|
+
ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor);
|
|
275
|
+
let scopeAccessor = "A" + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
|
|
276
|
+
let scopes = toArray(ownerScope[scopeAccessor]);
|
|
277
|
+
scopes.length && queueRender(ownerScope, () => {
|
|
278
|
+
for (let scope of scopes) !scope.H && !scope.I && fn(scope);
|
|
279
|
+
}, -1, 0, scopes[0].L);
|
|
280
|
+
};
|
|
281
|
+
return ownerSignal._ = fn, ownerSignal;
|
|
245
282
|
}
|
|
246
283
|
function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
};
|
|
254
|
-
return ownerSignal._ = fn, ownerSignal;
|
|
284
|
+
ownerConditionalNodeAccessor = decodeAccessor(ownerConditionalNodeAccessor);
|
|
285
|
+
let scopeAccessor = "A" + ownerConditionalNodeAccessor, branchAccessor = "D" + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
|
286
|
+
let ifScope = scope[scopeAccessor];
|
|
287
|
+
ifScope && !ifScope.H && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
|
|
288
|
+
};
|
|
289
|
+
return ownerSignal._ = fn, ownerSignal;
|
|
255
290
|
}
|
|
256
291
|
function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
"abort",
|
|
260
|
-
() => ownerScope[accessor].delete(scope)
|
|
261
|
-
));
|
|
292
|
+
let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
|
|
293
|
+
subscribers.has(scope) || (subscribers.add(scope), $signal(scope, -1).addEventListener("abort", () => ownerScope[accessor].delete(scope)));
|
|
262
294
|
}
|
|
263
295
|
function _closure(...closureSignals) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
for (let childScope of scope[___scopeInstancesAccessor])
|
|
270
|
-
childScope.H || queueRender(
|
|
271
|
-
childScope,
|
|
272
|
-
closureSignals[childScope[___signalIndexAccessor] || 0],
|
|
273
|
-
-1
|
|
274
|
-
);
|
|
275
|
-
};
|
|
296
|
+
let [firstSignal] = closureSignals, scopeInstances = firstSignal.a, signalIndex = firstSignal.b;
|
|
297
|
+
for (let i = closureSignals.length; i--;) closureSignals[i].c = i;
|
|
298
|
+
return (scope) => {
|
|
299
|
+
if (scope[scopeInstances]) for (let childScope of scope[scopeInstances]) childScope.H || queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
|
|
300
|
+
};
|
|
276
301
|
}
|
|
277
302
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
scope
|
|
284
|
-
);
|
|
285
|
-
});
|
|
286
|
-
return closureSignal.o = "B" /* ClosureScopes */ + valueAccessor, closureSignal.q = "C" /* ClosureSignalIndex */ + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
|
|
303
|
+
valueAccessor = decodeAccessor(valueAccessor);
|
|
304
|
+
let closureSignal = ((scope) => {
|
|
305
|
+
scope[closureSignal.b] = closureSignal.c, fn(scope), subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope._, closureSignal.a, scope);
|
|
306
|
+
});
|
|
307
|
+
return closureSignal.a = "B" + valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
|
|
287
308
|
}
|
|
288
309
|
function _child_setup(setup) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
310
|
+
return setup._ = (scope, owner) => {
|
|
311
|
+
scope._ = owner, queueRender(scope, setup, -1);
|
|
312
|
+
}, setup;
|
|
292
313
|
}
|
|
293
314
|
function _var(scope, childAccessor, signal) {
|
|
294
|
-
|
|
315
|
+
scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
|
|
295
316
|
}
|
|
296
|
-
var _return = (scope, value) => scope.T?.(value);
|
|
297
317
|
function _return_change(scope, changeHandler) {
|
|
298
|
-
|
|
318
|
+
changeHandler && (scope.U = changeHandler);
|
|
299
319
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
|
320
|
+
function _id({ $: $global }) {
|
|
321
|
+
let id = tagIdsByGlobal.get($global) || 0;
|
|
322
|
+
return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
|
304
323
|
}
|
|
305
324
|
function _script(id, fn) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
325
|
+
return _resume(id, fn), (scope) => {
|
|
326
|
+
queueEffect(scope, fn);
|
|
327
|
+
};
|
|
309
328
|
}
|
|
310
329
|
function _el_read(value) {
|
|
311
|
-
|
|
330
|
+
return value;
|
|
312
331
|
}
|
|
313
332
|
function* traverse(scope, path, i = path.length - 1) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
let item = scope[path[i]];
|
|
320
|
-
i ? yield* traverse(item, path, i - 1) : yield typeof item == "function" ? item() : item;
|
|
321
|
-
}
|
|
333
|
+
if (scope) if (Symbol.iterator in scope) for (let childScope of scope.values()) yield* traverse(childScope, path, i);
|
|
334
|
+
else {
|
|
335
|
+
let item = scope[path[i]];
|
|
336
|
+
i ? yield* traverse(item, path, i - 1) : yield typeof item == "function" ? item() : item;
|
|
337
|
+
}
|
|
322
338
|
}
|
|
323
339
|
function _hoist(...path) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
340
|
+
return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
|
|
341
|
+
let fn = () => traverse(scope, path).next().value;
|
|
342
|
+
return fn[Symbol.iterator] = () => traverse(scope, path), fn;
|
|
343
|
+
};
|
|
328
344
|
}
|
|
329
345
|
function _hoist_resume(id, ...path) {
|
|
330
|
-
|
|
346
|
+
return _resume(id, _hoist(...path));
|
|
331
347
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/dom/walker.ts
|
|
335
350
|
function walk(startNode, walkCodes, branch) {
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
for (; currentWalkIndex < walkCodes.length; )
|
|
341
|
-
if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32 /* Get */) {
|
|
342
|
-
let node = walker.currentNode;
|
|
343
|
-
scope[decodeAccessor(currentScopeIndex++)] = node;
|
|
344
|
-
} else if (value === 37 /* Replace */ || value === 49 /* DynamicTagWithVar */)
|
|
345
|
-
walker.currentNode.replaceWith(
|
|
346
|
-
walker.currentNode = scope[decodeAccessor(currentScopeIndex++)] = new Text()
|
|
347
|
-
), value === 49 /* DynamicTagWithVar */ && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
|
|
348
|
-
else {
|
|
349
|
-
if (value === 38 /* EndChild */)
|
|
350
|
-
return currentWalkIndex;
|
|
351
|
-
if (value === 47 /* BeginChild */ || value === 48 /* BeginChildWithVar */)
|
|
352
|
-
currentWalkIndex = walkInternal(
|
|
353
|
-
currentWalkIndex,
|
|
354
|
-
walkCodes,
|
|
355
|
-
scope[decodeAccessor(currentScopeIndex++)] = createScope(
|
|
356
|
-
scope.$,
|
|
357
|
-
scope.F
|
|
358
|
-
)
|
|
359
|
-
), value === 48 /* BeginChildWithVar */ && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
|
|
360
|
-
else if (value < 92)
|
|
361
|
-
for (value = 20 /* Next */ * currentMultiplier + value - 67 /* Next */; value--; )
|
|
362
|
-
walker.nextNode();
|
|
363
|
-
else if (value < 107)
|
|
364
|
-
for (value = 10 /* Over */ * currentMultiplier + value - 97 /* Over */; value--; )
|
|
365
|
-
walker.nextSibling();
|
|
366
|
-
else if (value < 117) {
|
|
367
|
-
for (value = 10 /* Out */ * currentMultiplier + value - 107 /* Out */; value--; )
|
|
368
|
-
walker.parentNode();
|
|
369
|
-
walker.nextSibling();
|
|
370
|
-
} else
|
|
371
|
-
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value - 117 /* Multiplier */;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// src/dom/renderer.ts
|
|
351
|
+
walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
|
|
352
|
+
}
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/dom/renderer.ts
|
|
376
355
|
function createBranch($global, renderer, parentScope, parentNode) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
branch,
|
|
380
|
-
parentNode.namespaceURI
|
|
381
|
-
), branch;
|
|
356
|
+
let branch = createScope($global);
|
|
357
|
+
return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.b?.(branch, parentNode.namespaceURI), branch;
|
|
382
358
|
}
|
|
383
359
|
function setParentBranch(branch, parentBranch) {
|
|
384
|
-
|
|
360
|
+
parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
|
|
385
361
|
}
|
|
386
362
|
function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
387
|
-
|
|
388
|
-
renderer,
|
|
389
|
-
createBranch($global, renderer, parentScope, parentNode)
|
|
390
|
-
);
|
|
363
|
+
return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
|
|
391
364
|
}
|
|
392
365
|
function setupBranch(renderer, branch) {
|
|
393
|
-
|
|
366
|
+
return renderer.c && queueRender(branch, renderer.c, -1), branch;
|
|
394
367
|
}
|
|
395
368
|
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
g: id,
|
|
411
|
-
k: clone,
|
|
412
|
-
f: owner,
|
|
413
|
-
l: setup,
|
|
414
|
-
d: params,
|
|
415
|
-
e: dynamicScopesAccessor
|
|
416
|
-
});
|
|
369
|
+
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
|
|
370
|
+
let clone = template ? (branch, ns) => {
|
|
371
|
+
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
|
|
372
|
+
} : (branch) => {
|
|
373
|
+
walk(branch.S = branch.K = new Text(), walks, branch);
|
|
374
|
+
};
|
|
375
|
+
return (owner) => ({
|
|
376
|
+
a: id,
|
|
377
|
+
b: clone,
|
|
378
|
+
e: owner,
|
|
379
|
+
c: setup,
|
|
380
|
+
d: params,
|
|
381
|
+
f: dynamicScopesAccessor
|
|
382
|
+
});
|
|
417
383
|
}
|
|
418
384
|
function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
419
|
-
|
|
420
|
-
id,
|
|
421
|
-
_content(id, template, walks, setup, params, dynamicScopesAccessor)
|
|
422
|
-
);
|
|
385
|
+
return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
|
|
423
386
|
}
|
|
424
387
|
function _content_closures(renderer, closureFns) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
var cloneCache = {};
|
|
388
|
+
let closureSignals = {};
|
|
389
|
+
for (let key in closureFns) closureSignals[key] = _const(+key, closureFns[key]);
|
|
390
|
+
return (owner, closureValues) => {
|
|
391
|
+
let instance = renderer(owner);
|
|
392
|
+
return instance.g = closureSignals, instance.h = closureValues, instance;
|
|
393
|
+
};
|
|
394
|
+
}
|
|
434
395
|
function createCloneableHTML(html, ns) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
// src/dom/resume.ts
|
|
449
|
-
var registeredValues = {}, curRuntimeId, readyLookup, branchesEnabled, embedEnabled;
|
|
396
|
+
let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
|
|
397
|
+
return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
|
|
398
|
+
walk(branch.S = branch.K = firstChild.cloneNode(!0), walks, branch);
|
|
399
|
+
} : (branch, walks) => {
|
|
400
|
+
let clone = parent.cloneNode(!0);
|
|
401
|
+
walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/dom/resume.ts
|
|
450
406
|
function enableBranches() {
|
|
451
|
-
|
|
407
|
+
branchesEnabled = 1;
|
|
452
408
|
}
|
|
453
|
-
var ready = /* @__PURE__ */ ((_) => (id) => {
|
|
454
|
-
readyLookup[id]?.(), readyLookup[id] = 1;
|
|
455
|
-
})(readyLookup = {});
|
|
456
409
|
function initEmbedded(readyId, runtimeId) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
410
|
+
embedEnabled = 1, ready(readyId), init(runtimeId), new MutationObserver(() => {
|
|
411
|
+
let renders = self[curRuntimeId];
|
|
412
|
+
for (let renderId in renders) {
|
|
413
|
+
let { s, n } = renders[renderId];
|
|
414
|
+
if (n && !n.isConnected) {
|
|
415
|
+
delete renders[renderId];
|
|
416
|
+
for (let id in s) destroyScope(s[id]);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}).observe(document.body, {
|
|
420
|
+
childList: !0,
|
|
421
|
+
subtree: !0
|
|
422
|
+
});
|
|
468
423
|
}
|
|
469
424
|
function init(runtimeId = "M") {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
for (let serialized of resumes = render.r || [])
|
|
514
|
-
if (typeof serialized == "string")
|
|
515
|
-
for (lastTokenIndex = 0, visitText = serialized; nextToken(); )
|
|
516
|
-
/\D/.test(lastToken) ? lastEffect = registeredValues[lastToken] : effects.push(lastEffect, getScope(lastToken));
|
|
517
|
-
else
|
|
518
|
-
for (let scope of serialized(serializeContext))
|
|
519
|
-
$global ? typeof scope == "number" ? lastScopeId += scope : (scopeLookup[scope.L = ++lastScopeId] = scope, scope.$ = $global, branchesEnabled && (scope.F = getScope(
|
|
520
|
-
scope.G
|
|
521
|
-
))) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId);
|
|
522
|
-
for (visit of visits = render.v)
|
|
523
|
-
if (lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], visitScope = getScope(nextToken(
|
|
524
|
-
/* read scope id */
|
|
525
|
-
)), visitType === "*" /* Node */) {
|
|
526
|
-
let prev = visit.previousSibling;
|
|
527
|
-
visitScope[nextToken(
|
|
528
|
-
/* read accessor */
|
|
529
|
-
)] = prev && (prev.nodeType < 8 || prev.data) ? prev : visit.parentNode.insertBefore(new Text(), visit);
|
|
530
|
-
} else branchesEnabled && visitBranches();
|
|
531
|
-
return embedEnabled && (render.n ||= visit?.parentNode.insertBefore(
|
|
532
|
-
new Text(),
|
|
533
|
-
visit.nextSibling
|
|
534
|
-
)), visits.length = resumes.length = 0, effects;
|
|
535
|
-
}, render.w = () => {
|
|
536
|
-
walk2(), runResumeEffects(render);
|
|
537
|
-
}, render;
|
|
538
|
-
})
|
|
539
|
-
});
|
|
540
|
-
};
|
|
541
|
-
if (renders) {
|
|
542
|
-
initRuntime(renders);
|
|
543
|
-
for (let renderId in renders)
|
|
544
|
-
runResumeEffects(resumeRender(renderId));
|
|
545
|
-
} else
|
|
546
|
-
defineRuntime({
|
|
547
|
-
configurable: !0,
|
|
548
|
-
set: initRuntime
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
var isResuming;
|
|
425
|
+
if (curRuntimeId) return;
|
|
426
|
+
curRuntimeId = runtimeId;
|
|
427
|
+
let resumeRender, renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), initRuntime = (renders) => {
|
|
428
|
+
defineRuntime({ value: resumeRender = ((renderId) => {
|
|
429
|
+
let render = resumeRender[renderId] = renders[renderId] || renders(renderId), walk = render.w, scopeLookup = render.s = {}, getScope = (id) => scopeLookup[id] ||= { L: +id }, serializeContext = { _: registeredValues }, visitBranches = branchesEnabled && ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
430
|
+
for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
|
|
431
|
+
if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
|
|
432
|
+
for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
|
|
433
|
+
branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
|
|
434
|
+
} else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
435
|
+
for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
|
|
436
|
+
nextToken();
|
|
437
|
+
}
|
|
438
|
+
endedBranches && (orphanBranches.push(...endedBranches), singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0])), visitType === "[" && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
|
|
439
|
+
})(), nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1), $global, lastEffect, visits, resumes, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, lastScopeId = 0;
|
|
440
|
+
return render.m = (effects = []) => {
|
|
441
|
+
if (readyLookup) {
|
|
442
|
+
for (let readyId in render.b) if (readyLookup[readyId] !== 1) return readyLookup[readyId] = ((prev) => () => {
|
|
443
|
+
render.m(), prev?.();
|
|
444
|
+
})(readyLookup[readyId]), effects;
|
|
445
|
+
render.b = 0;
|
|
446
|
+
}
|
|
447
|
+
for (let serialized of resumes = render.r || []) if (typeof serialized == "string") for (lastTokenIndex = 0, visitText = serialized; nextToken();) /\D/.test(lastToken) ? lastEffect = registeredValues[lastToken] : effects.push(lastEffect, getScope(lastToken));
|
|
448
|
+
else for (let scope of serialized(serializeContext)) $global ? typeof scope == "number" ? lastScopeId += scope : (scopeLookup[scope.L = ++lastScopeId] = scope, scope.$ = $global, branchesEnabled && (scope.F = getScope(scope.G))) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId);
|
|
449
|
+
for (visit of visits = render.v) if (lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], visitScope = getScope(nextToken()), visitType === "*") {
|
|
450
|
+
let prev = visit.previousSibling;
|
|
451
|
+
visitScope[nextToken()] = prev && (prev.nodeType < 8 || prev.data) ? prev : visit.parentNode.insertBefore(new Text(), visit);
|
|
452
|
+
} else branchesEnabled && visitBranches();
|
|
453
|
+
return embedEnabled && (render.n ||= visit?.parentNode.insertBefore(new Text(), visit.nextSibling)), visits.length = resumes.length = 0, effects;
|
|
454
|
+
}, render.w = () => {
|
|
455
|
+
walk(), runResumeEffects(render);
|
|
456
|
+
}, render;
|
|
457
|
+
}) });
|
|
458
|
+
};
|
|
459
|
+
if (renders) {
|
|
460
|
+
initRuntime(renders);
|
|
461
|
+
for (let renderId in renders) runResumeEffects(resumeRender(renderId));
|
|
462
|
+
} else defineRuntime({
|
|
463
|
+
configurable: !0,
|
|
464
|
+
set: initRuntime
|
|
465
|
+
});
|
|
466
|
+
}
|
|
552
467
|
function runResumeEffects(render) {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
468
|
+
try {
|
|
469
|
+
isResuming = 1, runEffects(render.m(), 1);
|
|
470
|
+
} finally {
|
|
471
|
+
isResuming = 0;
|
|
472
|
+
}
|
|
558
473
|
}
|
|
559
474
|
function getRegisteredWithScope(id, scope) {
|
|
560
|
-
|
|
561
|
-
|
|
475
|
+
let val = registeredValues[id];
|
|
476
|
+
return scope ? val(scope) : val;
|
|
562
477
|
}
|
|
563
478
|
function _resume(id, obj) {
|
|
564
|
-
|
|
479
|
+
return registeredValues[id] = obj;
|
|
565
480
|
}
|
|
566
481
|
function _var_resume(id, signal) {
|
|
567
|
-
|
|
482
|
+
return _resume(id, (scope) => (value) => signal(scope, value)), signal;
|
|
568
483
|
}
|
|
569
484
|
function _el(id, accessor) {
|
|
570
|
-
|
|
485
|
+
return accessor = decodeAccessor(accessor), _resume(id, (scope) => () => scope[accessor]);
|
|
571
486
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
var inputType = "", controllableDelegate = createDelegator();
|
|
487
|
+
//#endregion
|
|
488
|
+
//#region src/dom/controllable.ts
|
|
575
489
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
490
|
+
let el = scope[nodeAccessor], normalizedChecked = normalizeBoolProp(checked);
|
|
491
|
+
if (el.defaultChecked !== normalizedChecked) {
|
|
492
|
+
let restoreValue = scope.H ? normalizedChecked : el.checked;
|
|
493
|
+
el.defaultChecked = normalizedChecked, restoreValue !== normalizedChecked && (el.checked = restoreValue);
|
|
494
|
+
}
|
|
581
495
|
}
|
|
582
496
|
function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
|
583
|
-
|
|
584
|
-
|
|
497
|
+
let el = scope[nodeAccessor], normalizedChecked = normalizeBoolProp(checked);
|
|
498
|
+
scope["E" + nodeAccessor] = checkedChange, scope["F" + nodeAccessor] = checkedChange ? 0 : 5, checkedChange && !scope.H ? el.checked = normalizedChecked : _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
|
|
585
499
|
}
|
|
586
500
|
function _attr_input_checked_script(scope, nodeAccessor) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
501
|
+
let el = scope[nodeAccessor];
|
|
502
|
+
syncControllableFormInput(el, hasCheckboxChanged, () => {
|
|
503
|
+
let checkedChange = scope["E" + nodeAccessor];
|
|
504
|
+
if (checkedChange) {
|
|
505
|
+
let newValue = el.checked;
|
|
506
|
+
el.checked = !newValue, checkedChange(newValue), run();
|
|
507
|
+
}
|
|
508
|
+
});
|
|
595
509
|
}
|
|
596
510
|
function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value) {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
scope,
|
|
600
|
-
nodeAccessor,
|
|
601
|
-
multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue
|
|
602
|
-
);
|
|
511
|
+
let multiple = Array.isArray(checkedValue), normalizedValue = normalizeStrProp(value), normalizedCheckedValue = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
512
|
+
_attr(scope[nodeAccessor], "value", normalizedValue), _attr_input_checked_default(scope, nodeAccessor, multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue);
|
|
603
513
|
}
|
|
604
514
|
function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
scope,
|
|
608
|
-
nodeAccessor,
|
|
609
|
-
normalizedCheckedValue,
|
|
610
|
-
normalizedValue
|
|
611
|
-
);
|
|
515
|
+
let el = scope[nodeAccessor], multiple = Array.isArray(checkedValue), normalizedValue = normalizeStrProp(value), normalizedCheckedValue = scope["G" + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
516
|
+
_attr(el, "value", normalizedValue), scope["E" + nodeAccessor] = checkedValueChange, scope["F" + nodeAccessor] = checkedValueChange ? 1 : 5, checkedValueChange && !scope.H ? el.checked = multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue : _attr_input_checkedValue_default(scope, nodeAccessor, normalizedCheckedValue, normalizedValue);
|
|
612
517
|
}
|
|
613
518
|
function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
))
|
|
625
|
-
radio.form === el.form && (radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value);
|
|
626
|
-
else
|
|
627
|
-
el.checked = !el.checked;
|
|
628
|
-
checkedValueChange(newValue), run();
|
|
629
|
-
}
|
|
630
|
-
});
|
|
519
|
+
let el = scope[nodeAccessor];
|
|
520
|
+
isResuming && el.defaultChecked && (scope["G" + nodeAccessor] ? scope["G" + nodeAccessor].push(el.value) : scope["G" + nodeAccessor] = el.value), syncControllableFormInput(el, hasCheckboxChanged, () => {
|
|
521
|
+
let checkedValueChange = scope["E" + nodeAccessor];
|
|
522
|
+
if (checkedValueChange) {
|
|
523
|
+
let oldValue = scope["G" + nodeAccessor], newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
|
|
524
|
+
if (el.name && el.type[0] === "r") for (let radio of el.getRootNode().querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) radio.form === el.form && (radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value);
|
|
525
|
+
else el.checked = !el.checked;
|
|
526
|
+
checkedValueChange(newValue), run();
|
|
527
|
+
}
|
|
528
|
+
});
|
|
631
529
|
}
|
|
632
530
|
function _attr_input_value_default(scope, nodeAccessor, value) {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
531
|
+
let el = scope[nodeAccessor], normalizedValue = normalizeStrProp(value);
|
|
532
|
+
if (el.defaultValue !== normalizedValue) {
|
|
533
|
+
let restoreValue = scope.H ? normalizedValue : el.value;
|
|
534
|
+
el.defaultValue = normalizedValue, setInputValue(el, restoreValue);
|
|
535
|
+
}
|
|
638
536
|
}
|
|
639
537
|
function _attr_input_value(scope, nodeAccessor, value, valueChange) {
|
|
640
|
-
|
|
641
|
-
|
|
538
|
+
let el = scope[nodeAccessor], normalizedValue = normalizeStrProp(value);
|
|
539
|
+
scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange && !scope.H ? setInputValue(el, normalizedValue) : _attr_input_value_default(scope, nodeAccessor, normalizedValue);
|
|
642
540
|
}
|
|
643
541
|
function _attr_input_value_script(scope, nodeAccessor) {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
542
|
+
let el = scope[nodeAccessor];
|
|
543
|
+
isResuming && (scope["G" + nodeAccessor] = el.defaultValue), syncControllableFormInput(el, hasValueChanged, (ev) => {
|
|
544
|
+
let valueChange = scope["E" + nodeAccessor];
|
|
545
|
+
valueChange && (inputType = ev?.inputType, valueChange(el.value), run(), setInputValue(el, scope["G" + nodeAccessor]), inputType = "");
|
|
546
|
+
});
|
|
649
547
|
}
|
|
650
548
|
function setInputValue(el, value) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
el.value,
|
|
656
|
-
el.value = value
|
|
657
|
-
);
|
|
658
|
-
~updatedPosition && el.setSelectionRange(updatedPosition, updatedPosition);
|
|
659
|
-
}
|
|
549
|
+
if (el.value !== value) {
|
|
550
|
+
let updatedPosition = resolveCursorPosition(inputType, el.getRootNode().activeElement === el && el.selectionStart, el.value, el.value = value);
|
|
551
|
+
~updatedPosition && el.setSelectionRange(updatedPosition, updatedPosition);
|
|
552
|
+
}
|
|
660
553
|
}
|
|
661
554
|
function _attr_select_value_default(scope, nodeAccessor, value) {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
555
|
+
let restoreValue, el = scope[nodeAccessor], existing = !scope.H, multiple = Array.isArray(value), normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
556
|
+
pendingEffects.unshift(() => {
|
|
557
|
+
for (let opt of el.options) {
|
|
558
|
+
let selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
|
|
559
|
+
opt.defaultSelected !== selected && (existing && (restoreValue ??= getSelectValue(el, multiple)), opt.defaultSelected = selected);
|
|
560
|
+
}
|
|
561
|
+
restoreValue !== void 0 && setSelectValue(el, restoreValue, multiple);
|
|
562
|
+
}, scope);
|
|
670
563
|
}
|
|
671
564
|
function _attr_select_value(scope, nodeAccessor, value, valueChange) {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
() => setSelectValue(el, normalizedValue, multiple),
|
|
675
|
-
scope
|
|
676
|
-
) : _attr_select_value_default(scope, nodeAccessor, normalizedValue);
|
|
565
|
+
let el = scope[nodeAccessor], existing = !scope.H, multiple = Array.isArray(value), normalizedValue = scope["G" + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
566
|
+
scope["E" + nodeAccessor] = valueChange, scope["F" + nodeAccessor] = valueChange ? 3 : 5, valueChange && existing ? pendingEffects.unshift(() => setSelectValue(el, normalizedValue, multiple), scope) : _attr_select_value_default(scope, nodeAccessor, normalizedValue);
|
|
677
567
|
}
|
|
678
568
|
function _attr_select_value_script(scope, nodeAccessor) {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
569
|
+
let el = scope[nodeAccessor], onChange = () => {
|
|
570
|
+
let valueChange = scope["E" + nodeAccessor];
|
|
571
|
+
if (valueChange) {
|
|
572
|
+
let oldValue = scope["G" + nodeAccessor], multiple = Array.isArray(oldValue), newValue = getSelectValue(el, multiple);
|
|
573
|
+
setSelectValue(el, oldValue, multiple), valueChange(newValue), run();
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
if (isResuming) if (el.multiple) {
|
|
577
|
+
scope["G" + nodeAccessor] = [];
|
|
578
|
+
for (let opt of el.options) opt.defaultSelected && scope["G" + nodeAccessor].push(opt.value);
|
|
579
|
+
} else {
|
|
580
|
+
scope["G" + nodeAccessor] = "";
|
|
581
|
+
for (let opt of el.options) if (opt.defaultSelected) {
|
|
582
|
+
scope["G" + nodeAccessor] = opt.value;
|
|
583
|
+
break;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
syncControllableFormInput(el, hasSelectChanged, onChange), new MutationObserver(() => {
|
|
587
|
+
let value = scope["G" + nodeAccessor];
|
|
588
|
+
(Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((value, i) => value != el.selectedOptions[i].value) : el.value !== value) && onChange();
|
|
589
|
+
}).observe(el, {
|
|
590
|
+
childList: !0,
|
|
591
|
+
subtree: !0
|
|
592
|
+
});
|
|
703
593
|
}
|
|
704
594
|
function setSelectValue(el, value, multiple) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
opt.selected = value.includes(opt.value);
|
|
708
|
-
else
|
|
709
|
-
el.value = value;
|
|
595
|
+
if (multiple) for (let opt of el.options) opt.selected = value.includes(opt.value);
|
|
596
|
+
else el.value = value;
|
|
710
597
|
}
|
|
711
598
|
function getSelectValue(el, multiple) {
|
|
712
|
-
|
|
599
|
+
return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
|
|
713
600
|
}
|
|
714
601
|
function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
|
|
715
|
-
|
|
602
|
+
scope.H && (scope[nodeAccessor].open = normalizeBoolProp(open));
|
|
716
603
|
}
|
|
717
604
|
function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
|
|
718
|
-
|
|
719
|
-
|
|
605
|
+
let normalizedOpen = scope["G" + nodeAccessor] = normalizeBoolProp(open);
|
|
606
|
+
scope["E" + nodeAccessor] = openChange, scope["F" + nodeAccessor] = openChange ? 4 : 5, openChange && !scope.H ? scope[nodeAccessor].open = normalizedOpen : _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
|
|
720
607
|
}
|
|
721
608
|
function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
609
|
+
let el = scope[nodeAccessor];
|
|
610
|
+
new MutationObserver(() => {
|
|
611
|
+
let openChange = scope["E" + nodeAccessor];
|
|
612
|
+
if (openChange && el.open === !scope["G" + nodeAccessor]) {
|
|
613
|
+
let newValue = el.open;
|
|
614
|
+
el.open = !newValue, openChange(newValue), run();
|
|
615
|
+
}
|
|
616
|
+
}).observe(el, {
|
|
617
|
+
attributes: !0,
|
|
618
|
+
attributeFilter: ["open"]
|
|
619
|
+
});
|
|
730
620
|
}
|
|
731
621
|
function syncControllableFormInput(el, hasChanged, onChange) {
|
|
732
|
-
|
|
622
|
+
el._ = onChange, controllableDelegate(el, "input", handleChange), el.form && controllableDelegate(el.form, "reset", handleFormReset), isResuming && hasChanged(el) && queueMicrotask(onChange);
|
|
733
623
|
}
|
|
734
624
|
function handleChange(ev) {
|
|
735
|
-
|
|
625
|
+
ev.target._?.(ev);
|
|
736
626
|
}
|
|
737
627
|
function handleFormReset(ev) {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
for (let change of handlers)
|
|
744
|
-
change();
|
|
745
|
-
});
|
|
628
|
+
let handlers = [];
|
|
629
|
+
for (let el of ev.target.elements) el._ && hasFormElementChanged(el) && handlers.push(el._);
|
|
630
|
+
requestAnimationFrame(() => {
|
|
631
|
+
if (!ev.defaultPrevented) for (let change of handlers) change();
|
|
632
|
+
});
|
|
746
633
|
}
|
|
747
634
|
function hasValueChanged(el) {
|
|
748
|
-
|
|
635
|
+
return el.value !== el.defaultValue;
|
|
749
636
|
}
|
|
750
637
|
function hasCheckboxChanged(el) {
|
|
751
|
-
|
|
638
|
+
return el.checked !== el.defaultChecked;
|
|
752
639
|
}
|
|
753
640
|
function hasSelectChanged(el) {
|
|
754
|
-
|
|
755
|
-
if (opt.selected !== opt.defaultSelected)
|
|
756
|
-
return !0;
|
|
641
|
+
for (let opt of el.options) if (opt.selected !== opt.defaultSelected) return !0;
|
|
757
642
|
}
|
|
758
643
|
function hasFormElementChanged(el) {
|
|
759
|
-
|
|
644
|
+
return el.options ? hasSelectChanged(el) : hasValueChanged(el) || hasCheckboxChanged(el);
|
|
760
645
|
}
|
|
761
646
|
function normalizeStrProp(value) {
|
|
762
|
-
|
|
647
|
+
return normalizeAttrValue(value) || "";
|
|
763
648
|
}
|
|
764
649
|
function normalizeBoolProp(value) {
|
|
765
|
-
|
|
650
|
+
return value != null && value !== !1;
|
|
766
651
|
}
|
|
767
|
-
function updateList(arr, val,
|
|
768
|
-
|
|
769
|
-
|
|
652
|
+
function updateList(arr, val, push) {
|
|
653
|
+
let index = arr.indexOf(val);
|
|
654
|
+
return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
|
|
770
655
|
}
|
|
771
|
-
|
|
772
|
-
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region src/dom/dom.ts
|
|
773
658
|
function _to_text(value) {
|
|
774
|
-
|
|
659
|
+
return value || value === 0 ? value + "" : "";
|
|
775
660
|
}
|
|
776
661
|
function _attr(element, name, value) {
|
|
777
|
-
|
|
662
|
+
setAttribute(element, name, normalizeAttrValue(value));
|
|
778
663
|
}
|
|
779
664
|
function setAttribute(element, name, value) {
|
|
780
|
-
|
|
665
|
+
element.getAttribute(name) != value && (value === void 0 ? element.removeAttribute(name) : element.setAttribute(name, value));
|
|
781
666
|
}
|
|
782
667
|
function _attr_class(element, value) {
|
|
783
|
-
|
|
668
|
+
setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
|
|
784
669
|
}
|
|
785
670
|
function _attr_class_items(element, items) {
|
|
786
|
-
|
|
787
|
-
_attr_class_item(element, key, items[key]);
|
|
671
|
+
for (let key in items) _attr_class_item(element, key, items[key]);
|
|
788
672
|
}
|
|
789
673
|
function _attr_class_item(element, name, value) {
|
|
790
|
-
|
|
674
|
+
element.classList.toggle(name, !!value);
|
|
791
675
|
}
|
|
792
676
|
function _attr_style(element, value) {
|
|
793
|
-
|
|
677
|
+
setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
|
|
794
678
|
}
|
|
795
679
|
function _attr_style_items(element, items) {
|
|
796
|
-
|
|
797
|
-
_attr_style_item(element, key, items[key]);
|
|
680
|
+
for (let key in items) _attr_style_item(element, key, items[key]);
|
|
798
681
|
}
|
|
799
682
|
function _attr_style_item(element, name, value) {
|
|
800
|
-
|
|
683
|
+
element.style.setProperty(name, _to_text(value));
|
|
801
684
|
}
|
|
802
685
|
function _attr_nonce(scope, nodeAccessor) {
|
|
803
|
-
|
|
686
|
+
_attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
|
|
804
687
|
}
|
|
805
688
|
function _text(node, value) {
|
|
806
|
-
|
|
807
|
-
|
|
689
|
+
let normalizedValue = _to_text(value);
|
|
690
|
+
node.data !== normalizedValue && (node.data = normalizedValue);
|
|
808
691
|
}
|
|
809
692
|
function _text_content(node, value) {
|
|
810
|
-
|
|
811
|
-
|
|
693
|
+
let normalizedValue = _to_text(value);
|
|
694
|
+
node.textContent !== normalizedValue && (node.textContent = normalizedValue);
|
|
812
695
|
}
|
|
813
696
|
function _attrs(scope, nodeAccessor, nextAttrs) {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
697
|
+
let el = scope[nodeAccessor];
|
|
698
|
+
for (let i = el.attributes.length; i--;) {
|
|
699
|
+
let { name } = el.attributes.item(i);
|
|
700
|
+
nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
|
|
701
|
+
}
|
|
702
|
+
attrsInternal(scope, nodeAccessor, nextAttrs);
|
|
820
703
|
}
|
|
821
704
|
function _attrs_content(scope, nodeAccessor, nextAttrs) {
|
|
822
|
-
|
|
705
|
+
_attrs(scope, nodeAccessor, nextAttrs), _attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
823
706
|
}
|
|
824
707
|
function hasAttrAlias(element, attr, nextAttrs) {
|
|
825
|
-
|
|
708
|
+
return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
|
|
826
709
|
}
|
|
827
710
|
function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
711
|
+
let el = scope[nodeAccessor], partial = {};
|
|
712
|
+
for (let i = el.attributes.length; i--;) {
|
|
713
|
+
let { name } = el.attributes.item(i);
|
|
714
|
+
!skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
|
|
715
|
+
}
|
|
716
|
+
for (let name in nextAttrs) {
|
|
717
|
+
let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
718
|
+
skip[key] || (partial[key] = nextAttrs[name]);
|
|
719
|
+
}
|
|
720
|
+
attrsInternal(scope, nodeAccessor, partial);
|
|
838
721
|
}
|
|
839
722
|
function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
|
|
840
|
-
|
|
723
|
+
_attrs_partial(scope, nodeAccessor, nextAttrs, skip), _attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
841
724
|
}
|
|
842
725
|
function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
nextAttrs.valueChange
|
|
878
|
-
), skip = /^value(?:Change)?$/);
|
|
879
|
-
break;
|
|
880
|
-
case "TEXTAREA":
|
|
881
|
-
("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_input_value(
|
|
882
|
-
scope,
|
|
883
|
-
nodeAccessor,
|
|
884
|
-
nextAttrs.value,
|
|
885
|
-
nextAttrs.valueChange
|
|
886
|
-
), skip = /^value(?:Change)?$/);
|
|
887
|
-
break;
|
|
888
|
-
case "DETAILS":
|
|
889
|
-
case "DIALOG":
|
|
890
|
-
("open" in nextAttrs || "openChange" in nextAttrs) && (_attr_details_or_dialog_open(
|
|
891
|
-
scope,
|
|
892
|
-
nodeAccessor,
|
|
893
|
-
nextAttrs.open,
|
|
894
|
-
nextAttrs.openChange
|
|
895
|
-
), skip = /^open(?:Change)?$/);
|
|
896
|
-
break;
|
|
897
|
-
}
|
|
898
|
-
for (let name in nextAttrs) {
|
|
899
|
-
let value = nextAttrs[name];
|
|
900
|
-
switch (name) {
|
|
901
|
-
case "class":
|
|
902
|
-
_attr_class(el, value);
|
|
903
|
-
break;
|
|
904
|
-
case "style":
|
|
905
|
-
_attr_style(el, value);
|
|
906
|
-
break;
|
|
907
|
-
default: {
|
|
908
|
-
isEventHandler(name) ? (events ||= scope["I" /* EventAttributes */ + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
|
|
909
|
-
break;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
}
|
|
726
|
+
let el = scope[nodeAccessor], events, skip;
|
|
727
|
+
switch (el.tagName) {
|
|
728
|
+
case "INPUT":
|
|
729
|
+
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
|
|
730
|
+
else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
|
|
731
|
+
else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
|
|
732
|
+
else break;
|
|
733
|
+
skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
|
|
734
|
+
break;
|
|
735
|
+
case "SELECT":
|
|
736
|
+
("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), skip = /^value(?:Change)?$/);
|
|
737
|
+
break;
|
|
738
|
+
case "TEXTAREA":
|
|
739
|
+
("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), skip = /^value(?:Change)?$/);
|
|
740
|
+
break;
|
|
741
|
+
case "DETAILS":
|
|
742
|
+
case "DIALOG":
|
|
743
|
+
("open" in nextAttrs || "openChange" in nextAttrs) && (_attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange), skip = /^open(?:Change)?$/);
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
for (let name in nextAttrs) {
|
|
747
|
+
let value = nextAttrs[name];
|
|
748
|
+
switch (name) {
|
|
749
|
+
case "class":
|
|
750
|
+
_attr_class(el, value);
|
|
751
|
+
break;
|
|
752
|
+
case "style":
|
|
753
|
+
_attr_style(el, value);
|
|
754
|
+
break;
|
|
755
|
+
default:
|
|
756
|
+
isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
|
|
757
|
+
break;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
913
760
|
}
|
|
914
761
|
function _attr_content(scope, nodeAccessor, value) {
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
content.e,
|
|
919
|
-
scope["A" /* BranchScopes */ + nodeAccessor]
|
|
920
|
-
));
|
|
921
|
-
for (let accessor in content?.h)
|
|
922
|
-
content.h[accessor](
|
|
923
|
-
scope["A" /* BranchScopes */ + nodeAccessor],
|
|
924
|
-
content.t[accessor]
|
|
925
|
-
);
|
|
762
|
+
let content = normalizeClientRender(value);
|
|
763
|
+
scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = content?.a) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
|
|
764
|
+
for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
|
|
926
765
|
}
|
|
927
766
|
function _attrs_script(scope, nodeAccessor) {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
_on(el, name, events[name]);
|
|
767
|
+
let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
|
|
768
|
+
switch (scope["F" + nodeAccessor]) {
|
|
769
|
+
case 0:
|
|
770
|
+
_attr_input_checked_script(scope, nodeAccessor);
|
|
771
|
+
break;
|
|
772
|
+
case 1:
|
|
773
|
+
_attr_input_checkedValue_script(scope, nodeAccessor);
|
|
774
|
+
break;
|
|
775
|
+
case 2:
|
|
776
|
+
_attr_input_value_script(scope, nodeAccessor);
|
|
777
|
+
break;
|
|
778
|
+
case 3:
|
|
779
|
+
_attr_select_value_script(scope, nodeAccessor);
|
|
780
|
+
break;
|
|
781
|
+
case 4:
|
|
782
|
+
_attr_details_or_dialog_open_script(scope, nodeAccessor);
|
|
783
|
+
break;
|
|
784
|
+
}
|
|
785
|
+
for (let name in events) _on(el, name, events[name]);
|
|
948
786
|
}
|
|
949
787
|
function _html(scope, value, accessor) {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
parentNode.namespaceURI
|
|
953
|
-
);
|
|
954
|
-
insertChildNodes(
|
|
955
|
-
parentNode,
|
|
956
|
-
firstChild,
|
|
957
|
-
scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()),
|
|
958
|
-
scope["H" /* DynamicHTMLLastChild */ + accessor] = newContent.lastChild
|
|
959
|
-
), removeChildNodes(firstChild, lastChild);
|
|
788
|
+
let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope["H" + accessor] || firstChild, newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
|
|
789
|
+
insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope["H" + accessor] = newContent.lastChild), removeChildNodes(firstChild, lastChild);
|
|
960
790
|
}
|
|
961
791
|
function normalizeClientRender(value) {
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
return renderer;
|
|
792
|
+
let renderer = normalizeDynamicRenderer(value);
|
|
793
|
+
if (renderer && renderer.a) return renderer;
|
|
965
794
|
}
|
|
966
795
|
function normalizeAttrValue(value) {
|
|
967
|
-
|
|
968
|
-
return value === !0 ? "" : value + "";
|
|
796
|
+
if (value || value === 0) return value === !0 ? "" : value + "";
|
|
969
797
|
}
|
|
970
798
|
function _lifecycle(scope, thisObj, index = 0) {
|
|
971
|
-
|
|
972
|
-
|
|
799
|
+
let accessor = "K" + index, instance = scope[accessor];
|
|
800
|
+
instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, thisObj.onMount?.(), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
|
|
973
801
|
}
|
|
974
802
|
function removeChildNodes(startNode, endNode) {
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
803
|
+
let stop = endNode.nextSibling, current = startNode;
|
|
804
|
+
for (; current !== stop;) {
|
|
805
|
+
let next = current.nextSibling;
|
|
806
|
+
current.remove(), current = next;
|
|
807
|
+
}
|
|
980
808
|
}
|
|
981
809
|
function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
|
|
982
|
-
|
|
810
|
+
parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
|
|
983
811
|
}
|
|
984
812
|
function toInsertNode(startNode, endNode) {
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
|
|
813
|
+
if (startNode === endNode) return startNode;
|
|
814
|
+
let parent = new DocumentFragment(), stop = endNode.nextSibling, current = startNode;
|
|
815
|
+
for (; current !== stop;) {
|
|
816
|
+
let next = current.nextSibling;
|
|
817
|
+
parent.appendChild(current), current = next;
|
|
818
|
+
}
|
|
819
|
+
return parent;
|
|
820
|
+
}
|
|
821
|
+
//#endregion
|
|
822
|
+
//#region src/dom/control-flow.ts
|
|
995
823
|
function _await_promise(nodeAccessor, params) {
|
|
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
|
-
-1
|
|
1041
|
-
)
|
|
1042
|
-
)
|
|
1043
|
-
)
|
|
1044
|
-
));
|
|
1045
|
-
let thisPromise = scope[promiseAccessor] = promise.then(
|
|
1046
|
-
(data) => {
|
|
1047
|
-
if (thisPromise === scope[promiseAccessor]) {
|
|
1048
|
-
let referenceNode = scope[nodeAccessor];
|
|
1049
|
-
scope[promiseAccessor] = 0, queueMicrotask(run), queueRender(
|
|
1050
|
-
scope,
|
|
1051
|
-
() => {
|
|
1052
|
-
(awaitBranch = scope[branchAccessor]).V && (pendingScopes.push(awaitBranch), setupBranch(
|
|
1053
|
-
awaitBranch.V,
|
|
1054
|
-
awaitBranch
|
|
1055
|
-
), awaitBranch.V = 0, insertBranchBefore(
|
|
1056
|
-
awaitBranch,
|
|
1057
|
-
scope[nodeAccessor].parentNode,
|
|
1058
|
-
scope[nodeAccessor]
|
|
1059
|
-
), referenceNode.remove()), params?.(awaitBranch, [data]);
|
|
1060
|
-
let pendingRenders2 = awaitBranch.W;
|
|
1061
|
-
if (awaitBranch.W = 0, pendingRenders2?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
|
|
1062
|
-
let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m();
|
|
1063
|
-
for (let i = 0; i < pendingEffects.length; ) {
|
|
1064
|
-
let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
|
|
1065
|
-
scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
|
|
1066
|
-
}
|
|
1067
|
-
for (let i = 0; i < effects.length; ) {
|
|
1068
|
-
let fn = effects[i++], scope2 = effects[i++];
|
|
1069
|
-
fnScopes.get(fn)?.has(scope2) || queueEffect(scope2, fn);
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
},
|
|
1073
|
-
-1
|
|
1074
|
-
);
|
|
1075
|
-
}
|
|
1076
|
-
},
|
|
1077
|
-
(error) => {
|
|
1078
|
-
thisPromise === scope[promiseAccessor] && (awaitCounter.i = scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
|
|
1079
|
-
}
|
|
1080
|
-
);
|
|
1081
|
-
};
|
|
824
|
+
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
825
|
+
let promiseAccessor = "L" + nodeAccessor, branchAccessor = "A" + nodeAccessor;
|
|
826
|
+
return _enable_catch(), (scope, promise) => {
|
|
827
|
+
let awaitBranch = scope[branchAccessor], tryBranch = findBranchWithKey(scope, "Q") || awaitBranch, awaitCounter = tryBranch.O;
|
|
828
|
+
awaitCounter?.i || (awaitCounter = tryBranch.O = {
|
|
829
|
+
i: 0,
|
|
830
|
+
c() {
|
|
831
|
+
if (--awaitCounter.i) return 1;
|
|
832
|
+
if (tryBranch === scope[branchAccessor]) scope[nodeAccessor].parentNode && scope[nodeAccessor].replaceWith(scope[branchAccessor].S.parentNode);
|
|
833
|
+
else {
|
|
834
|
+
let placeholderBranch = tryBranch.P;
|
|
835
|
+
placeholderBranch && (tryBranch.P = 0, placeholderBranch.S.parentNode.insertBefore(tryBranch.S.parentNode, placeholderBranch.S), removeAndDestroyBranch(placeholderBranch));
|
|
836
|
+
}
|
|
837
|
+
queueEffect(tryBranch, (scope) => {
|
|
838
|
+
let pendingEffects = scope.J;
|
|
839
|
+
pendingEffects && (scope.J = [], runEffects(pendingEffects, 1));
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
}), placeholderShown.add(pendingEffects), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch === awaitBranch ? scope : tryBranch, () => {
|
|
843
|
+
tryBranch.Q ? (insertBranchBefore(tryBranch.P = createAndSetupBranch(scope.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch)) : awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
|
|
844
|
+
}, -1)))));
|
|
845
|
+
let thisPromise = scope[promiseAccessor] = promise.then((data) => {
|
|
846
|
+
if (thisPromise === scope[promiseAccessor]) {
|
|
847
|
+
let referenceNode = scope[nodeAccessor];
|
|
848
|
+
scope[promiseAccessor] = 0, queueMicrotask(run), queueRender(scope, () => {
|
|
849
|
+
(awaitBranch = scope[branchAccessor]).V && (pendingScopes.push(awaitBranch), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [data]);
|
|
850
|
+
let pendingRenders = awaitBranch.W;
|
|
851
|
+
if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
|
|
852
|
+
let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m();
|
|
853
|
+
for (let i = 0; i < pendingEffects.length;) {
|
|
854
|
+
let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
|
|
855
|
+
scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
|
|
856
|
+
}
|
|
857
|
+
for (let i = 0; i < effects.length;) {
|
|
858
|
+
let fn = effects[i++], scope = effects[i++];
|
|
859
|
+
fnScopes.get(fn)?.has(scope) || queueEffect(scope, fn);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}, -1);
|
|
863
|
+
}
|
|
864
|
+
}, (error) => {
|
|
865
|
+
thisPromise === scope[promiseAccessor] && (awaitCounter.i = scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
|
|
866
|
+
});
|
|
867
|
+
};
|
|
1082
868
|
}
|
|
1083
869
|
function _await_content(nodeAccessor, template, walks, setup) {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
renderer,
|
|
1090
|
-
scope,
|
|
1091
|
-
scope[nodeAccessor].parentNode
|
|
1092
|
-
)).V = renderer, pendingScopes.pop();
|
|
1093
|
-
};
|
|
870
|
+
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
871
|
+
let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
872
|
+
return (scope) => {
|
|
873
|
+
(scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer, pendingScopes.pop();
|
|
874
|
+
};
|
|
1094
875
|
}
|
|
1095
876
|
function _try(nodeAccessor, template, walks, setup) {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
createAndSetupBranch
|
|
1104
|
-
);
|
|
1105
|
-
let branch = scope[branchAccessor];
|
|
1106
|
-
branch && (branch.C = nodeAccessor, branch.E = normalizeDynamicRenderer(input.catch), branch.Q = normalizeDynamicRenderer(
|
|
1107
|
-
input.placeholder
|
|
1108
|
-
));
|
|
1109
|
-
};
|
|
877
|
+
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
878
|
+
let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
879
|
+
return (scope, input) => {
|
|
880
|
+
scope[branchAccessor] || setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
|
|
881
|
+
let branch = scope[branchAccessor];
|
|
882
|
+
branch && (branch.C = nodeAccessor, branch.E = input.catch && (normalizeDynamicRenderer(input.catch) || 0), branch.Q = normalizeDynamicRenderer(input.placeholder));
|
|
883
|
+
};
|
|
1110
884
|
}
|
|
1111
885
|
function renderCatch(scope, error) {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
tryWithCatch.C,
|
|
1118
|
-
tryWithCatch.E,
|
|
1119
|
-
createAndSetupBranch
|
|
1120
|
-
), tryWithCatch.E.d?.(
|
|
1121
|
-
owner["A" /* BranchScopes */ + tryWithCatch.C],
|
|
1122
|
-
[error]
|
|
1123
|
-
);
|
|
1124
|
-
} else
|
|
1125
|
-
throw error;
|
|
886
|
+
let tryWithCatch = findBranchWithKey(scope, "E");
|
|
887
|
+
if (tryWithCatch) {
|
|
888
|
+
let owner = tryWithCatch._, placeholderBranch = tryWithCatch.P;
|
|
889
|
+
placeholderBranch && (tryWithCatch.O && (tryWithCatch.O.i = 0), owner["A" + tryWithCatch.C] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(owner, tryWithCatch.C, tryWithCatch.E, createAndSetupBranch), tryWithCatch.E?.d?.(owner["A" + tryWithCatch.C], [error]);
|
|
890
|
+
} else throw error;
|
|
1126
891
|
}
|
|
1127
892
|
function _if(nodeAccessor, ...branchesArgs) {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
branchesArgs[i++],
|
|
1135
|
-
branchesArgs[i++],
|
|
1136
|
-
branchesArgs[i++]
|
|
1137
|
-
)()
|
|
1138
|
-
);
|
|
1139
|
-
return enableBranches(), (scope, newBranch) => {
|
|
1140
|
-
newBranch !== scope[branchAccessor] && setConditionalRenderer(
|
|
1141
|
-
scope,
|
|
1142
|
-
nodeAccessor,
|
|
1143
|
-
branches[scope[branchAccessor] = newBranch],
|
|
1144
|
-
createAndSetupBranch
|
|
1145
|
-
);
|
|
1146
|
-
};
|
|
893
|
+
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
894
|
+
let branchAccessor = "D" + nodeAccessor, branches = [], i = 0;
|
|
895
|
+
for (; i < branchesArgs.length;) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
|
|
896
|
+
return enableBranches(), (scope, newBranch) => {
|
|
897
|
+
newBranch !== scope[branchAccessor] && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
898
|
+
};
|
|
1147
899
|
}
|
|
1148
900
|
function patchDynamicTag(fn) {
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1151
|
-
var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1152
|
-
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1153
|
-
let childScopeAccessor = "A" /* BranchScopes */ + nodeAccessor, rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
|
|
1154
|
-
return enableBranches(), (scope, newRenderer, getInput) => {
|
|
1155
|
-
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
|
1156
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.g || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
|
1157
|
-
if (setConditionalRenderer(
|
|
1158
|
-
scope,
|
|
1159
|
-
nodeAccessor,
|
|
1160
|
-
normalizedRenderer || (getContent ? getContent(scope) : void 0),
|
|
1161
|
-
createBranchWithTagNameOrRenderer
|
|
1162
|
-
), getTagVar && (scope[childScopeAccessor].T = (value) => getTagVar()(scope, value)), typeof normalizedRenderer == "string") {
|
|
1163
|
-
if (getContent) {
|
|
1164
|
-
let content = getContent(scope);
|
|
1165
|
-
setConditionalRenderer(
|
|
1166
|
-
scope[childScopeAccessor],
|
|
1167
|
-
"a",
|
|
1168
|
-
content,
|
|
1169
|
-
createAndSetupBranch
|
|
1170
|
-
), content.e && subscribeToScopeSet(
|
|
1171
|
-
content.f,
|
|
1172
|
-
content.e,
|
|
1173
|
-
scope[childScopeAccessor]["Aa"]
|
|
1174
|
-
);
|
|
1175
|
-
}
|
|
1176
|
-
} else normalizedRenderer?.e && subscribeToScopeSet(
|
|
1177
|
-
normalizedRenderer.f,
|
|
1178
|
-
normalizedRenderer.e,
|
|
1179
|
-
scope[childScopeAccessor]
|
|
1180
|
-
);
|
|
1181
|
-
if (normalizedRenderer) {
|
|
1182
|
-
let childScope = scope[childScopeAccessor], args = getInput?.();
|
|
1183
|
-
if (typeof normalizedRenderer == "string")
|
|
1184
|
-
(getContent ? _attrs : _attrs_content)(
|
|
1185
|
-
childScope,
|
|
1186
|
-
"a",
|
|
1187
|
-
(inputIsArgs ? args[0] : args) || {}
|
|
1188
|
-
), (childScope["Ia"] || childScope["Ea"]) && queueEffect(childScope, dynamicTagScript);
|
|
1189
|
-
else {
|
|
1190
|
-
for (let accessor in normalizedRenderer.h)
|
|
1191
|
-
normalizedRenderer.h[accessor](
|
|
1192
|
-
childScope,
|
|
1193
|
-
normalizedRenderer.t[accessor]
|
|
1194
|
-
);
|
|
1195
|
-
if (normalizedRenderer.d)
|
|
1196
|
-
if (inputIsArgs)
|
|
1197
|
-
normalizedRenderer.d(
|
|
1198
|
-
childScope,
|
|
1199
|
-
normalizedRenderer._ ? args[0] : args
|
|
1200
|
-
);
|
|
1201
|
-
else {
|
|
1202
|
-
let inputWithContent = getContent ? { ...args, content: getContent(scope) } : args || {};
|
|
1203
|
-
normalizedRenderer.d(
|
|
1204
|
-
childScope,
|
|
1205
|
-
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
|
1206
|
-
);
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
};
|
|
1211
|
-
};
|
|
901
|
+
_dynamic_tag = fn(_dynamic_tag);
|
|
902
|
+
}
|
|
1212
903
|
function _resume_dynamic_tag() {
|
|
1213
|
-
|
|
904
|
+
_resume("d", dynamicTagScript);
|
|
1214
905
|
}
|
|
1215
906
|
function dynamicTagScript(branch) {
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(
|
|
1224
|
-
newBranch,
|
|
1225
|
-
parentNode,
|
|
1226
|
-
prevBranch.S
|
|
1227
|
-
) : parentNode.insertBefore(
|
|
1228
|
-
referenceNode,
|
|
1229
|
-
prevBranch.S
|
|
1230
|
-
), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
|
|
1231
|
-
}
|
|
1232
|
-
var _for_of = loop(([all, by = bySecondArg], cb) => {
|
|
1233
|
-
typeof by == "string" ? forOf(
|
|
1234
|
-
all,
|
|
1235
|
-
(item, i) => cb(item[by], [item, i])
|
|
1236
|
-
) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
1237
|
-
}), _for_in = loop(
|
|
1238
|
-
([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))
|
|
1239
|
-
), _for_to = loop(
|
|
1240
|
-
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
|
1241
|
-
), _for_until = loop(
|
|
1242
|
-
([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
|
|
1243
|
-
);
|
|
907
|
+
_attrs_script(branch, "a");
|
|
908
|
+
}
|
|
909
|
+
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch) {
|
|
910
|
+
let referenceNode = scope[nodeAccessor], prevBranch = scope["A" + nodeAccessor], parentNode = referenceNode.nodeType > 1 ? (prevBranch?.S || referenceNode).parentNode : referenceNode, newBranch = scope["A" + nodeAccessor] = newRenderer && createBranch(scope.$, newRenderer, scope, parentNode);
|
|
911
|
+
referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.S) : parentNode.insertBefore(referenceNode, prevBranch.S), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
|
|
912
|
+
}
|
|
913
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1244
914
|
function loop(forEach) {
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
if (oldEnd + 1 < oldLen && (afterReference = oldScopes[oldEnd + 1].S), start > oldEnd) {
|
|
1280
|
-
if (start <= newEnd)
|
|
1281
|
-
for (let i = start; i <= newEnd; i++)
|
|
1282
|
-
insertBranchBefore(newScopes[i], parentNode, afterReference);
|
|
1283
|
-
return;
|
|
1284
|
-
} else if (start > newEnd)
|
|
1285
|
-
return;
|
|
1286
|
-
let diffLen = newEnd - start + 1, oldPos = /* @__PURE__ */ new Map(), sources = new Array(diffLen), pred = new Array(diffLen), tails = [], tail = -1, lo, hi, mid;
|
|
1287
|
-
for (let i = start; i <= oldEnd; i++)
|
|
1288
|
-
oldPos.set(oldScopes[i], i);
|
|
1289
|
-
for (let i = diffLen; i--; )
|
|
1290
|
-
sources[i] = oldPos.get(newScopes[start + i]) ?? -1;
|
|
1291
|
-
for (let i = 0; i < diffLen; i++)
|
|
1292
|
-
if (~sources[i])
|
|
1293
|
-
if (tail < 0 || sources[tails[tail]] < sources[i])
|
|
1294
|
-
~tail && (pred[i] = tails[tail]), tails[++tail] = i;
|
|
1295
|
-
else {
|
|
1296
|
-
for (lo = 0, hi = tail; lo < hi; )
|
|
1297
|
-
mid = (lo + hi) / 2 | 0, sources[tails[mid]] < sources[i] ? lo = mid + 1 : hi = mid;
|
|
1298
|
-
sources[i] < sources[tails[lo]] && (lo > 0 && (pred[i] = tails[lo - 1]), tails[lo] = i);
|
|
1299
|
-
}
|
|
1300
|
-
for (hi = tails[tail], lo = tail + 1; lo-- > 0; )
|
|
1301
|
-
tails[lo] = hi, hi = pred[hi];
|
|
1302
|
-
for (let i = diffLen; i--; )
|
|
1303
|
-
~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
|
|
1304
|
-
};
|
|
1305
|
-
};
|
|
915
|
+
return (nodeAccessor, template, walks, setup, params) => {
|
|
916
|
+
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
917
|
+
let scopesAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
918
|
+
return enableBranches(), (scope, value) => {
|
|
919
|
+
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), newScopes = scope[scopesAccessor] = [], oldLen = oldScopes.length, parentNode = referenceNode.nodeType > 1 ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode, oldScopesByKey, hasPotentialMoves;
|
|
920
|
+
forEach(value, (key, args) => {
|
|
921
|
+
let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce((map, scope, i) => map.set(scope.M ?? i, scope), /* @__PURE__ */ new Map())).get(key);
|
|
922
|
+
branch ? hasPotentialMoves = oldScopesByKey.delete(key) : branch = createAndSetupBranch(scope.$, renderer, scope, parentNode), branch.M = key, newScopes.push(branch), params?.(branch, args);
|
|
923
|
+
});
|
|
924
|
+
let newLen = newScopes.length, hasSiblings = referenceNode !== parentNode, afterReference = null, oldEnd = oldLen - 1, newEnd = newLen - 1, start = 0;
|
|
925
|
+
if (hasSiblings && (oldLen ? (afterReference = oldScopes[oldEnd].K.nextSibling, newLen || parentNode.insertBefore(referenceNode, afterReference)) : newLen && (afterReference = referenceNode.nextSibling, referenceNode.remove())), !hasPotentialMoves) {
|
|
926
|
+
oldLen && (oldScopes.forEach(hasSiblings ? removeAndDestroyBranch : destroyBranch), hasSiblings || (parentNode.textContent = ""));
|
|
927
|
+
for (let newScope of newScopes) insertBranchBefore(newScope, parentNode, afterReference);
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
for (let branch of oldScopesByKey.values()) removeAndDestroyBranch(branch);
|
|
931
|
+
for (; start < oldLen && start < newLen && oldScopes[start] === newScopes[start];) start++;
|
|
932
|
+
for (; oldEnd >= start && newEnd >= start && oldScopes[oldEnd] === newScopes[newEnd];) oldEnd--, newEnd--;
|
|
933
|
+
if (oldEnd + 1 < oldLen && (afterReference = oldScopes[oldEnd + 1].S), start > oldEnd) {
|
|
934
|
+
if (start <= newEnd) for (let i = start; i <= newEnd; i++) insertBranchBefore(newScopes[i], parentNode, afterReference);
|
|
935
|
+
return;
|
|
936
|
+
} else if (start > newEnd) return;
|
|
937
|
+
let diffLen = newEnd - start + 1, oldPos = /* @__PURE__ */ new Map(), sources = Array(diffLen), pred = Array(diffLen), tails = [], tail = -1, lo, hi, mid;
|
|
938
|
+
for (let i = start; i <= oldEnd; i++) oldPos.set(oldScopes[i], i);
|
|
939
|
+
for (let i = diffLen; i--;) sources[i] = oldPos.get(newScopes[start + i]) ?? -1;
|
|
940
|
+
for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) ~tail && (pred[i] = tails[tail]), tails[++tail] = i;
|
|
941
|
+
else {
|
|
942
|
+
for (lo = 0, hi = tail; lo < hi;) mid = (lo + hi) / 2 | 0, sources[tails[mid]] < sources[i] ? lo = mid + 1 : hi = mid;
|
|
943
|
+
sources[i] < sources[tails[lo]] && (lo > 0 && (pred[i] = tails[lo - 1]), tails[lo] = i);
|
|
944
|
+
}
|
|
945
|
+
for (hi = tails[tail], lo = tail + 1; lo-- > 0;) tails[lo] = hi, hi = pred[hi];
|
|
946
|
+
for (let i = diffLen; i--;) ~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
|
|
947
|
+
};
|
|
948
|
+
};
|
|
1306
949
|
}
|
|
1307
950
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
tagNameOrRenderer,
|
|
1311
|
-
parentScope,
|
|
1312
|
-
parentNode
|
|
1313
|
-
);
|
|
1314
|
-
return typeof tagNameOrRenderer == "string" ? branch.a = branch.S = branch.K = document.createElementNS(
|
|
1315
|
-
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
|
1316
|
-
tagNameOrRenderer
|
|
1317
|
-
) : setupBranch(tagNameOrRenderer, branch), branch;
|
|
951
|
+
let branch = createBranch($global, tagNameOrRenderer, parentScope, parentNode);
|
|
952
|
+
return typeof tagNameOrRenderer == "string" ? branch.a = branch.S = branch.K = document.createElementNS(tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI, tagNameOrRenderer) : setupBranch(tagNameOrRenderer, branch), branch;
|
|
1318
953
|
}
|
|
1319
954
|
function bySecondArg(_item, index) {
|
|
1320
|
-
|
|
955
|
+
return index;
|
|
1321
956
|
}
|
|
1322
957
|
function byFirstArg(name) {
|
|
1323
|
-
|
|
958
|
+
return name;
|
|
1324
959
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), asyncRendersLookup, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, scopeKeyOffset = 1e3;
|
|
960
|
+
//#endregion
|
|
961
|
+
//#region src/dom/queue.ts
|
|
1328
962
|
function queueRender(scope, signal, signalKey, value, scopeKey = scope.L) {
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
}
|
|
1337
|
-
), signalKey >= 0 && pendingRendersLookup.set(key, render));
|
|
963
|
+
let key = scopeKey * 1e3 + signalKey, render = signalKey >= 0 && pendingRendersLookup.get(key);
|
|
964
|
+
render ? render.d = value : (queuePendingRender(render = {
|
|
965
|
+
a: key,
|
|
966
|
+
b: scope,
|
|
967
|
+
c: signal,
|
|
968
|
+
d: value
|
|
969
|
+
}), signalKey >= 0 && pendingRendersLookup.set(key, render));
|
|
1338
970
|
}
|
|
1339
971
|
function queuePendingRender(render) {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
972
|
+
let i = pendingRenders.push(render) - 1;
|
|
973
|
+
for (; i;) {
|
|
974
|
+
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
|
975
|
+
if (render.a - parent.a >= 0) break;
|
|
976
|
+
pendingRenders[i] = parent, i = parentIndex;
|
|
977
|
+
}
|
|
978
|
+
pendingRenders[i] = render;
|
|
1347
979
|
}
|
|
1348
980
|
function queueEffect(scope, fn) {
|
|
1349
|
-
|
|
981
|
+
pendingEffects.push(fn, scope);
|
|
1350
982
|
}
|
|
1351
983
|
function run() {
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
984
|
+
let effects = pendingEffects;
|
|
985
|
+
asyncRendersLookup = /* @__PURE__ */ new Map();
|
|
986
|
+
try {
|
|
987
|
+
rendering = 1, runRenders();
|
|
988
|
+
} finally {
|
|
989
|
+
pendingRendersLookup = asyncRendersLookup, asyncRendersLookup = rendering = 0, pendingRenders = [], pendingEffects = [];
|
|
990
|
+
}
|
|
991
|
+
runEffects(effects);
|
|
1360
992
|
}
|
|
1361
993
|
function prepareEffects(fn) {
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
}
|
|
1371
|
-
var runEffects = ((effects) => {
|
|
1372
|
-
for (let i = 0; i < effects.length; )
|
|
1373
|
-
effects[i++](effects[i++]);
|
|
1374
|
-
});
|
|
994
|
+
let prevRenders = pendingRenders, prevEffects = pendingEffects, prevLookup = asyncRendersLookup, preparedEffects = pendingEffects = [];
|
|
995
|
+
pendingRenders = [], asyncRendersLookup = pendingRendersLookup, pendingRendersLookup = /* @__PURE__ */ new Map();
|
|
996
|
+
try {
|
|
997
|
+
rendering = 1, fn(), runRenders();
|
|
998
|
+
} finally {
|
|
999
|
+
rendering = 0, pendingRendersLookup = asyncRendersLookup, asyncRendersLookup = prevLookup, pendingRenders = prevRenders, pendingEffects = prevEffects;
|
|
1000
|
+
}
|
|
1001
|
+
return preparedEffects;
|
|
1002
|
+
}
|
|
1375
1003
|
function runRenders() {
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
runRender2(render);
|
|
1423
|
-
} catch (error) {
|
|
1424
|
-
renderCatch(render.j, error);
|
|
1425
|
-
}
|
|
1426
|
-
})(runRender);
|
|
1427
|
-
};
|
|
1428
|
-
|
|
1429
|
-
// src/dom/abort-signal.ts
|
|
1004
|
+
for (; pendingRenders.length;) {
|
|
1005
|
+
let render = pendingRenders[0], item = pendingRenders.pop();
|
|
1006
|
+
if (render !== item) {
|
|
1007
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).a;
|
|
1008
|
+
for (; i < mid;) {
|
|
1009
|
+
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
|
1010
|
+
if (right < pendingRenders.length && pendingRenders[right].a - pendingRenders[bestChild].a < 0 && (bestChild = right), pendingRenders[bestChild].a - key >= 0) break;
|
|
1011
|
+
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
|
1012
|
+
}
|
|
1013
|
+
pendingRenders[i] = item;
|
|
1014
|
+
}
|
|
1015
|
+
render.b.F?.I || runRender(render);
|
|
1016
|
+
}
|
|
1017
|
+
for (let scope of pendingScopes) scope.H = 0;
|
|
1018
|
+
pendingScopes = [];
|
|
1019
|
+
}
|
|
1020
|
+
function _enable_catch() {
|
|
1021
|
+
if (!catchEnabled) {
|
|
1022
|
+
catchEnabled = 1, enableBranches();
|
|
1023
|
+
let handlePendingTry = (fn, scope, branch) => {
|
|
1024
|
+
for (; branch;) {
|
|
1025
|
+
if (branch.O?.i) return (branch.J ||= []).push(fn, scope);
|
|
1026
|
+
branch = branch.N;
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
runEffects = ((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
|
|
1030
|
+
if (checkPending || caughtError.has(effects)) {
|
|
1031
|
+
let i = 0, fn, scope, branch;
|
|
1032
|
+
for (; i < effects.length;) fn = effects[i++], scope = effects[i++], branch = scope.F, !branch?.I && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope);
|
|
1033
|
+
} else runEffects(effects);
|
|
1034
|
+
})(runEffects), runRender = ((runRender) => (render) => {
|
|
1035
|
+
try {
|
|
1036
|
+
let branch = render.b.F;
|
|
1037
|
+
for (; branch;) {
|
|
1038
|
+
if (branch.W) return asyncRendersLookup.set(render.a, render), branch.W.push(render);
|
|
1039
|
+
branch = branch.N;
|
|
1040
|
+
}
|
|
1041
|
+
runRender(render);
|
|
1042
|
+
} catch (error) {
|
|
1043
|
+
renderCatch(render.b, error);
|
|
1044
|
+
}
|
|
1045
|
+
})(runRender);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
//#endregion
|
|
1049
|
+
//#region src/dom/abort-signal.ts
|
|
1430
1050
|
function $signalReset(scope, id) {
|
|
1431
|
-
|
|
1432
|
-
|
|
1051
|
+
let ctrl = scope.A?.[id];
|
|
1052
|
+
ctrl && (queueEffect(ctrl, abort), scope.A[id] = void 0);
|
|
1433
1053
|
}
|
|
1434
1054
|
function $signal(scope, id) {
|
|
1435
|
-
|
|
1055
|
+
return scope.F && (scope.F.B ||= /* @__PURE__ */ new Set()).add(scope), ((scope.A ||= {})[id] ||= new AbortController()).signal;
|
|
1436
1056
|
}
|
|
1437
1057
|
function abort(ctrl) {
|
|
1438
|
-
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
patchDynamicTag,
|
|
1447
|
-
queueEffect,
|
|
1448
|
-
init(warp10Noop) {
|
|
1449
|
-
_resume(SET_SCOPE_REGISTER_ID, (branch) => {
|
|
1450
|
-
classIdToBranch.set(branch.m5c, branch);
|
|
1451
|
-
}), _resume(RENDER_BODY_ID, warp10Noop);
|
|
1452
|
-
},
|
|
1453
|
-
registerRenderer(fn) {
|
|
1454
|
-
_resume(RENDERER_REGISTER_ID, fn);
|
|
1455
|
-
},
|
|
1456
|
-
isRenderer(renderer) {
|
|
1457
|
-
return renderer.k;
|
|
1458
|
-
},
|
|
1459
|
-
getStartNode(branch) {
|
|
1460
|
-
return branch.S;
|
|
1461
|
-
},
|
|
1462
|
-
setScopeNodes(branch, startNode, endNode) {
|
|
1463
|
-
branch.S = startNode, branch.K = endNode;
|
|
1464
|
-
},
|
|
1465
|
-
runComponentEffects() {
|
|
1466
|
-
this.effects && runEffects(this.effects);
|
|
1467
|
-
},
|
|
1468
|
-
runComponentDestroy() {
|
|
1469
|
-
this.scope && destroyBranch(this.scope);
|
|
1470
|
-
},
|
|
1471
|
-
resolveRegistered(value, $global) {
|
|
1472
|
-
return Array.isArray(value) && typeof value[0] == "string" ? getRegisteredWithScope(
|
|
1473
|
-
value[0],
|
|
1474
|
-
value.length === 2 && self[$global.runtimeId]?.[$global.renderId]?.s[value[1]]
|
|
1475
|
-
) : value;
|
|
1476
|
-
},
|
|
1477
|
-
createRenderer(params, clone) {
|
|
1478
|
-
let renderer = _content("", 0, 0, 0, params)();
|
|
1479
|
-
return renderer.k = (branch) => {
|
|
1480
|
-
let cloned = clone();
|
|
1481
|
-
branch.S = cloned.startNode, branch.K = cloned.endNode;
|
|
1482
|
-
}, renderer;
|
|
1483
|
-
},
|
|
1484
|
-
render(out, component, renderer, args) {
|
|
1485
|
-
let branch = component.scope, created = 0;
|
|
1486
|
-
if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), typeof args[0] == "object" && "renderBody" in args[0]) {
|
|
1487
|
-
let input = args[0], normalizedInput = args[0] = {};
|
|
1488
|
-
for (let key in input)
|
|
1489
|
-
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
|
1490
|
-
}
|
|
1491
|
-
if (component.effects = prepareEffects(() => {
|
|
1492
|
-
branch || (created = 1, branch = component.scope = createAndSetupBranch(
|
|
1493
|
-
out.global,
|
|
1494
|
-
renderer,
|
|
1495
|
-
renderer.f,
|
|
1496
|
-
document.body
|
|
1497
|
-
)), renderer.d?.(branch, renderer._ ? args[0] : args);
|
|
1498
|
-
}), created)
|
|
1499
|
-
return toInsertNode(
|
|
1500
|
-
branch.S,
|
|
1501
|
-
branch.K
|
|
1502
|
-
);
|
|
1503
|
-
}
|
|
1504
|
-
};
|
|
1505
|
-
|
|
1506
|
-
// src/dom/template.ts
|
|
1507
|
-
var _template = (id, template, walks, setup, inputSignal) => {
|
|
1508
|
-
let renderer = _content(
|
|
1509
|
-
id,
|
|
1510
|
-
template,
|
|
1511
|
-
walks,
|
|
1512
|
-
setup,
|
|
1513
|
-
inputSignal
|
|
1514
|
-
)();
|
|
1515
|
-
return renderer.mount = mount, renderer._ = renderer, _resume(id, renderer);
|
|
1516
|
-
};
|
|
1058
|
+
ctrl.abort();
|
|
1059
|
+
}
|
|
1060
|
+
//#endregion
|
|
1061
|
+
//#region src/common/compat-meta.ts
|
|
1062
|
+
//#endregion
|
|
1063
|
+
//#region src/dom/compat.ts
|
|
1064
|
+
//#endregion
|
|
1065
|
+
//#region src/dom/template.ts
|
|
1517
1066
|
function mount(input = {}, reference, position) {
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
prepareEffects(() => {
|
|
1562
|
-
args(branch, newInput);
|
|
1563
|
-
})
|
|
1564
|
-
);
|
|
1565
|
-
},
|
|
1566
|
-
destroy() {
|
|
1567
|
-
removeAndDestroyBranch(branch);
|
|
1568
|
-
}
|
|
1569
|
-
};
|
|
1570
|
-
}
|
|
1571
|
-
export {
|
|
1572
|
-
$signal,
|
|
1573
|
-
$signalReset,
|
|
1574
|
-
_assert_hoist,
|
|
1575
|
-
_assert_init,
|
|
1576
|
-
_attr,
|
|
1577
|
-
_attr_class,
|
|
1578
|
-
_attr_class_item,
|
|
1579
|
-
_attr_class_items,
|
|
1580
|
-
_attr_content,
|
|
1581
|
-
_attr_details_or_dialog_open as _attr_details_open,
|
|
1582
|
-
_attr_details_or_dialog_open_default as _attr_details_open_default,
|
|
1583
|
-
_attr_details_or_dialog_open_script as _attr_details_open_script,
|
|
1584
|
-
_attr_details_or_dialog_open as _attr_dialog_open,
|
|
1585
|
-
_attr_details_or_dialog_open_default as _attr_dialog_open_default,
|
|
1586
|
-
_attr_details_or_dialog_open_script as _attr_dialog_open_script,
|
|
1587
|
-
_attr_input_checked,
|
|
1588
|
-
_attr_input_checkedValue,
|
|
1589
|
-
_attr_input_checkedValue_default,
|
|
1590
|
-
_attr_input_checkedValue_script,
|
|
1591
|
-
_attr_input_checked_default,
|
|
1592
|
-
_attr_input_checked_script,
|
|
1593
|
-
_attr_input_value,
|
|
1594
|
-
_attr_input_value_default,
|
|
1595
|
-
_attr_input_value_script,
|
|
1596
|
-
_attr_nonce,
|
|
1597
|
-
_attr_select_value,
|
|
1598
|
-
_attr_select_value_default,
|
|
1599
|
-
_attr_select_value_script,
|
|
1600
|
-
_attr_style,
|
|
1601
|
-
_attr_style_item,
|
|
1602
|
-
_attr_style_items,
|
|
1603
|
-
_attr_input_value as _attr_textarea_value,
|
|
1604
|
-
_attr_input_value_default as _attr_textarea_value_default,
|
|
1605
|
-
_attr_input_value_script as _attr_textarea_value_script,
|
|
1606
|
-
_attrs,
|
|
1607
|
-
_attrs_content,
|
|
1608
|
-
_attrs_partial,
|
|
1609
|
-
_attrs_partial_content,
|
|
1610
|
-
_attrs_script,
|
|
1611
|
-
_await_content,
|
|
1612
|
-
_await_promise,
|
|
1613
|
-
_call,
|
|
1614
|
-
_child_setup,
|
|
1615
|
-
_closure,
|
|
1616
|
-
_closure_get,
|
|
1617
|
-
_const,
|
|
1618
|
-
_content,
|
|
1619
|
-
_content_closures,
|
|
1620
|
-
_content_resume,
|
|
1621
|
-
_dynamic_tag,
|
|
1622
|
-
_el,
|
|
1623
|
-
_el_read,
|
|
1624
|
-
_enable_catch,
|
|
1625
|
-
_for_closure,
|
|
1626
|
-
_for_in,
|
|
1627
|
-
_for_of,
|
|
1628
|
-
_for_to,
|
|
1629
|
-
_for_until,
|
|
1630
|
-
_hoist,
|
|
1631
|
-
_hoist_resume,
|
|
1632
|
-
_html,
|
|
1633
|
-
_id,
|
|
1634
|
-
_if,
|
|
1635
|
-
_if_closure,
|
|
1636
|
-
_let,
|
|
1637
|
-
_lifecycle,
|
|
1638
|
-
_on,
|
|
1639
|
-
_or,
|
|
1640
|
-
_resume,
|
|
1641
|
-
_resume_dynamic_tag,
|
|
1642
|
-
_return,
|
|
1643
|
-
_return_change,
|
|
1644
|
-
_script,
|
|
1645
|
-
_template,
|
|
1646
|
-
_text,
|
|
1647
|
-
_text_content,
|
|
1648
|
-
_to_text,
|
|
1649
|
-
_try,
|
|
1650
|
-
_var,
|
|
1651
|
-
_var_change,
|
|
1652
|
-
_var_resume,
|
|
1653
|
-
attrTag,
|
|
1654
|
-
attrTags,
|
|
1655
|
-
compat,
|
|
1656
|
-
forIn,
|
|
1657
|
-
forOf,
|
|
1658
|
-
forTo,
|
|
1659
|
-
forUntil,
|
|
1660
|
-
init,
|
|
1661
|
-
initEmbedded,
|
|
1662
|
-
run
|
|
1663
|
-
};
|
|
1067
|
+
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
|
1068
|
+
switch ($global ? ({$global, ...input} = input, $global = {
|
|
1069
|
+
runtimeId: "M",
|
|
1070
|
+
renderId: "_",
|
|
1071
|
+
...$global
|
|
1072
|
+
}) : $global = {
|
|
1073
|
+
runtimeId: "M",
|
|
1074
|
+
renderId: "_"
|
|
1075
|
+
}, position) {
|
|
1076
|
+
case "beforebegin":
|
|
1077
|
+
parentNode = reference.parentNode, nextSibling = reference;
|
|
1078
|
+
break;
|
|
1079
|
+
case "afterbegin":
|
|
1080
|
+
nextSibling = reference.firstChild;
|
|
1081
|
+
break;
|
|
1082
|
+
case "afterend":
|
|
1083
|
+
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
|
1084
|
+
break;
|
|
1085
|
+
}
|
|
1086
|
+
let curValue, args = this.d, effects = prepareEffects(() => {
|
|
1087
|
+
branch = createBranch($global, this, void 0, parentNode), branch.T = (newValue) => {
|
|
1088
|
+
curValue = newValue;
|
|
1089
|
+
}, this.c?.(branch), args?.(branch, input);
|
|
1090
|
+
});
|
|
1091
|
+
return insertChildNodes(parentNode, nextSibling, branch.S, branch.K), runEffects(effects), {
|
|
1092
|
+
get value() {
|
|
1093
|
+
return curValue;
|
|
1094
|
+
},
|
|
1095
|
+
set value(newValue) {
|
|
1096
|
+
_var_change(branch, newValue);
|
|
1097
|
+
},
|
|
1098
|
+
update(newInput) {
|
|
1099
|
+
args && runEffects(prepareEffects(() => {
|
|
1100
|
+
args(branch, newInput);
|
|
1101
|
+
}));
|
|
1102
|
+
},
|
|
1103
|
+
destroy() {
|
|
1104
|
+
removeAndDestroyBranch(branch);
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
//#endregion
|
|
1109
|
+
export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _dynamic_tag, _el, _el_read, _enable_catch, _for_closure, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _lifecycle, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, run };
|