marko 6.0.0-next.3.25 → 6.0.0-next.3.27
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/types.d.ts +4 -3
- package/dist/debug/dom.js +360 -340
- package/dist/debug/dom.mjs +360 -340
- package/dist/debug/html.js +7 -7
- package/dist/debug/html.mjs +7 -7
- package/dist/dom/compat.d.ts +3 -3
- package/dist/dom/dom.d.ts +2 -1
- package/dist/dom/reconcile.d.ts +1 -1
- package/dist/dom/renderer.d.ts +1 -1
- package/dist/dom/scope.d.ts +2 -2
- package/dist/dom/signals.d.ts +1 -1
- package/dist/dom/walker.d.ts +2 -2
- package/dist/dom.js +257 -249
- package/dist/dom.mjs +257 -249
- package/dist/html/writer.d.ts +3 -3
- package/dist/html.js +7 -7
- package/dist/html.mjs +7 -7
- package/dist/translator/index.js +40 -46
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/dom.js
CHANGED
@@ -129,46 +129,6 @@ function triggerMacroTask() {
|
|
129
129
|
port2.postMessage(0);
|
130
130
|
}
|
131
131
|
|
132
|
-
// src/dom/scope.ts
|
133
|
-
var pendingScopes = [];
|
134
|
-
function createScope($global) {
|
135
|
-
let scope = {
|
136
|
-
e: 1,
|
137
|
-
$global
|
138
|
-
};
|
139
|
-
return pendingScopes.push(scope), scope;
|
140
|
-
}
|
141
|
-
function finishPendingScopes() {
|
142
|
-
for (let scope of pendingScopes)
|
143
|
-
scope.e = 0;
|
144
|
-
pendingScopes = [];
|
145
|
-
}
|
146
|
-
var emptyScope = createScope({});
|
147
|
-
function getEmptyScope(marker) {
|
148
|
-
return emptyScope.a = emptyScope.c = marker, emptyScope;
|
149
|
-
}
|
150
|
-
function destroyBranch(branch) {
|
151
|
-
if (branch.y = 1, branch.m?.forEach(destroyBranch), branch.n)
|
152
|
-
for (let scope of branch.n)
|
153
|
-
for (let id in scope.j)
|
154
|
-
scope.j[id]?.abort();
|
155
|
-
}
|
156
|
-
function removeAndDestroyBranch(branch) {
|
157
|
-
destroyBranch(branch);
|
158
|
-
let current = branch.a, stop = branch.c.nextSibling;
|
159
|
-
for (; current !== stop; ) {
|
160
|
-
let next = current.nextSibling;
|
161
|
-
current.remove(), current = next;
|
162
|
-
}
|
163
|
-
}
|
164
|
-
function insertBefore(scope, parent, nextSibling) {
|
165
|
-
let current = scope.a, stop = scope.c.nextSibling;
|
166
|
-
for (; current !== stop; ) {
|
167
|
-
let next = current.nextSibling;
|
168
|
-
parent.insertBefore(current, nextSibling), current = next;
|
169
|
-
}
|
170
|
-
}
|
171
|
-
|
172
132
|
// src/common/helpers.ts
|
173
133
|
function classValue(value2) {
|
174
134
|
return toDelimitedString(value2, " ", stringifyClassObject);
|
@@ -215,83 +175,6 @@ function normalizeDynamicRenderer(value2) {
|
|
215
175
|
if (value2) return value2.content || value2.default || value2;
|
216
176
|
}
|
217
177
|
|
218
|
-
// src/dom/reconcile.ts
|
219
|
-
var WRONG_POS = 2147483647;
|
220
|
-
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
221
|
-
let oldStart = 0, newStart = 0, oldEnd = oldBranches.length - 1, newEnd = newBranches.length - 1, oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart], oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd], i, j, k, nextSibling, oldBranch, newBranch;
|
222
|
-
outer: {
|
223
|
-
for (; oldStartBranch === newStartBranch; ) {
|
224
|
-
if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
|
225
|
-
break outer;
|
226
|
-
oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
|
227
|
-
}
|
228
|
-
for (; oldEndBranch === newEndBranch; ) {
|
229
|
-
if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
|
230
|
-
break outer;
|
231
|
-
oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
|
232
|
-
}
|
233
|
-
}
|
234
|
-
if (oldStart > oldEnd) {
|
235
|
-
if (newStart <= newEnd) {
|
236
|
-
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
|
237
|
-
do
|
238
|
-
insertBefore(newBranches[newStart++], parent, nextSibling);
|
239
|
-
while (newStart <= newEnd);
|
240
|
-
}
|
241
|
-
} else if (newStart > newEnd)
|
242
|
-
do
|
243
|
-
removeAndDestroyBranch(oldBranches[oldStart++]);
|
244
|
-
while (oldStart <= oldEnd);
|
245
|
-
else {
|
246
|
-
let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
|
247
|
-
for (i = 0; i < newLength; ++i)
|
248
|
-
sources[i] = -1;
|
249
|
-
let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
|
250
|
-
for (j = newStart; j <= newEnd; ++j)
|
251
|
-
keyIndex.set(newBranches[j], j);
|
252
|
-
for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
|
253
|
-
oldBranch = oldBranches[i], j = keyIndex.get(oldBranch), j !== void 0 && (pos = pos > j ? WRONG_POS : j, ++synced, newBranch = newBranches[j], sources[j - newStart] = i, aNullable[i] = null);
|
254
|
-
if (oldLength === oldBranches.length && synced === 0) {
|
255
|
-
for (; newStart < newLength; ++newStart)
|
256
|
-
insertBefore(newBranches[newStart], parent, afterReference);
|
257
|
-
for (; oldStart < oldLength; ++oldStart)
|
258
|
-
removeAndDestroyBranch(oldBranches[oldStart]);
|
259
|
-
} else {
|
260
|
-
for (i = oldLength - synced; i > 0; )
|
261
|
-
oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
|
262
|
-
if (pos === WRONG_POS) {
|
263
|
-
let seq = longestIncreasingSubsequence(sources);
|
264
|
-
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
265
|
-
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling)) : --j;
|
266
|
-
} else if (synced !== newLength)
|
267
|
-
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
268
|
-
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling));
|
269
|
-
}
|
270
|
-
}
|
271
|
-
}
|
272
|
-
function longestIncreasingSubsequence(a) {
|
273
|
-
let p = a.slice(), result = [];
|
274
|
-
result.push(0);
|
275
|
-
let u, v;
|
276
|
-
for (let i = 0, il = a.length; i < il; ++i) {
|
277
|
-
if (a[i] === -1)
|
278
|
-
continue;
|
279
|
-
let j = result[result.length - 1];
|
280
|
-
if (a[j] < a[i]) {
|
281
|
-
p[i] = j, result.push(i);
|
282
|
-
continue;
|
283
|
-
}
|
284
|
-
for (u = 0, v = result.length - 1; u < v; ) {
|
285
|
-
let c = (u + v) / 2 | 0;
|
286
|
-
a[result[c]] < a[i] ? u = c + 1 : v = c;
|
287
|
-
}
|
288
|
-
a[i] < a[result[u]] && (u > 0 && (p[i] = result[u - 1]), result[u] = i);
|
289
|
-
}
|
290
|
-
for (u = result.length, v = result[u - 1]; u-- > 0; )
|
291
|
-
result[u] = v, v = p[v];
|
292
|
-
return result;
|
293
|
-
}
|
294
|
-
|
295
178
|
// src/dom/event.ts
|
296
179
|
var elementHandlersByEvent = /* @__PURE__ */ new Map(), defaultDelegator = createDelegator();
|
297
180
|
function on(element, type, handler) {
|
@@ -306,7 +189,7 @@ function createDelegator() {
|
|
306
189
|
};
|
307
190
|
}
|
308
191
|
function handleDelegated(ev) {
|
309
|
-
let target = ev.target;
|
192
|
+
let target = !rendering && ev.target;
|
310
193
|
if (target) {
|
311
194
|
let handlersByElement = elementHandlersByEvent.get(ev.type);
|
312
195
|
if (handlersByElement.get(target)?.(ev, target), ev.bubbles)
|
@@ -342,28 +225,28 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
342
225
|
|
343
226
|
// src/dom/resume.ts
|
344
227
|
var registeredValues = {}, Render = class {
|
345
|
-
|
346
|
-
|
228
|
+
n = [];
|
229
|
+
o = {};
|
347
230
|
z = {
|
348
231
|
_: registeredValues
|
349
232
|
};
|
350
233
|
constructor(renders, runtimeId, renderId) {
|
351
|
-
this.A = renders, this.B = runtimeId, this.
|
234
|
+
this.A = renders, this.B = runtimeId, this.p = renderId, this.q = renders[renderId], this.s();
|
352
235
|
}
|
353
236
|
w() {
|
354
|
-
this.
|
237
|
+
this.q.w(), this.s();
|
355
238
|
}
|
356
|
-
|
357
|
-
let data2 = this.
|
239
|
+
s() {
|
240
|
+
let data2 = this.q, serializeContext = this.z, scopeLookup = this.o, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
358
241
|
if (visits.length) {
|
359
|
-
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map();
|
242
|
+
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
|
360
243
|
data2.v = [];
|
361
|
-
let branchEnd = (branchId, visit,
|
362
|
-
let branch = scopeLookup[branchId] ||= {}, endNode =
|
363
|
-
for (; (endNode = endNode.previousSibling)
|
364
|
-
branch.
|
244
|
+
let branchEnd = (branchId, visit, reference) => {
|
245
|
+
let branch = scopeLookup[branchId] ||= {}, endNode = reference;
|
246
|
+
for (; visitNodes.has(endNode = endNode.previousSibling); ) ;
|
247
|
+
endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(new Text(), reference)), branch.b = lastEndNode = endNode, branch.a ||= endNode;
|
365
248
|
for (let [markerScopeId, markerNode] of closestBranchMarkers)
|
366
|
-
branch.a.compareDocumentPosition(markerNode) & 4 &&
|
249
|
+
branch.a.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
|
367
250
|
return branchIds.add(branchId), closestBranchMarkers.set(branchId, visit), branch;
|
368
251
|
};
|
369
252
|
for (let visit of visits) {
|
@@ -376,22 +259,22 @@ var registeredValues = {}, Render = class {
|
|
376
259
|
else if (token === "$" /* ClosestBranch */)
|
377
260
|
closestBranchMarkers.set(scopeId, visit);
|
378
261
|
else if (token === "[" /* BranchStart */)
|
379
|
-
this.
|
262
|
+
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.n.push(this.e)), this.e = scopeId, scope.a = visit;
|
380
263
|
else if (token === "]" /* BranchEnd */) {
|
381
264
|
scope[data3] = visit;
|
382
265
|
let curParent = visit.parentNode, startNode = branchEnd(
|
383
|
-
this.
|
266
|
+
this.e,
|
384
267
|
visit,
|
385
268
|
visit
|
386
269
|
).a;
|
387
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), this.
|
270
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.n.pop();
|
388
271
|
} else if (token === "|" /* BranchSingleNode */) {
|
389
272
|
let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
|
390
273
|
for (; ~next; ) {
|
391
274
|
let start = next + 1;
|
392
275
|
next = data3.indexOf(" ", start);
|
393
276
|
let childScopeId = data3.slice(start, ~next ? next : data3.length);
|
394
|
-
curNode = branchEnd(childScopeId, visit, curNode).
|
277
|
+
curNode = branchEnd(childScopeId, visit, curNode).b;
|
395
278
|
}
|
396
279
|
}
|
397
280
|
}
|
@@ -405,7 +288,7 @@ var registeredValues = {}, Render = class {
|
|
405
288
|
let resumeData = resumes[i++];
|
406
289
|
if (typeof resumeData == "function") {
|
407
290
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
408
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.B, $global.renderId = this.
|
291
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.B, $global.renderId = this.p);
|
409
292
|
for (let scopeId in scopes)
|
410
293
|
if (scopeId !== "$") {
|
411
294
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -414,12 +297,12 @@ var registeredValues = {}, Render = class {
|
|
414
297
|
prevScope
|
415
298
|
));
|
416
299
|
let parentBranchId = parentBranchIds.get(scopeId);
|
417
|
-
if (parentBranchId && (scope.
|
418
|
-
let branch = scope, parentBranch = branch.
|
419
|
-
scope.
|
300
|
+
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
301
|
+
let branch = scope, parentBranch = branch.c;
|
302
|
+
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.t = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch));
|
420
303
|
}
|
421
304
|
}
|
422
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.A[this.
|
305
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.A[this.p] : registeredValues[resumes[i++]](
|
423
306
|
scopeLookup[resumeData],
|
424
307
|
scopeLookup[resumeData]
|
425
308
|
);
|
@@ -457,7 +340,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
457
340
|
}
|
458
341
|
}
|
459
342
|
function registerSubscriber(id, signal) {
|
460
|
-
return register(id, signal.
|
343
|
+
return register(id, signal.C), signal;
|
461
344
|
}
|
462
345
|
function nodeRef(id, key) {
|
463
346
|
return register(id, (scope) => () => scope[key]);
|
@@ -636,7 +519,7 @@ function toValueProp(it) {
|
|
636
519
|
}
|
637
520
|
|
638
521
|
// src/dom/parse-html.ts
|
639
|
-
var
|
522
|
+
var parser = /* @__PURE__ */ document.createElement("template");
|
640
523
|
function parseHTML(html2) {
|
641
524
|
return parser.innerHTML = html2, parser.content;
|
642
525
|
}
|
@@ -651,7 +534,7 @@ function parseHTMLOrSingleNode(html2) {
|
|
651
534
|
let fragment = new DocumentFragment();
|
652
535
|
return fragment.appendChild(content), fragment;
|
653
536
|
}
|
654
|
-
return
|
537
|
+
return new Text();
|
655
538
|
}
|
656
539
|
|
657
540
|
// src/dom/dom.ts
|
@@ -790,14 +673,12 @@ function attrsEvents(scope, nodeAccessor) {
|
|
790
673
|
for (let name in events)
|
791
674
|
on(el, name, events[name]);
|
792
675
|
}
|
793
|
-
function html(scope, value2,
|
794
|
-
let firstChild = scope[
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
current.remove(), current = next;
|
800
|
-
}
|
676
|
+
function html(scope, value2, accessor) {
|
677
|
+
let firstChild = scope[accessor], lastChild = scope[accessor + "-" /* DynamicPlaceholderLastChild */] || firstChild, newContent = parseHTML(
|
678
|
+
value2 || value2 === 0 ? value2 + "" : "<!>"
|
679
|
+
// TODO: is the comment needed
|
680
|
+
);
|
681
|
+
scope[accessor] = newContent.firstChild, scope[accessor + "-" /* DynamicPlaceholderLastChild */] = newContent.lastChild, firstChild.parentNode.insertBefore(newContent, firstChild), removeChildNodes(firstChild, lastChild);
|
801
682
|
}
|
802
683
|
function props(scope, nodeIndex, index) {
|
803
684
|
let nextProps = scope[index], prevProps = scope[index + "-"], node = scope[nodeIndex];
|
@@ -822,6 +703,128 @@ function lifecycle(scope, index, thisObj) {
|
|
822
703
|
"-" /* LifecycleAbortController */ + index
|
823
704
|
).onabort = () => thisObj.onDestroy?.());
|
824
705
|
}
|
706
|
+
function removeChildNodes(startNode, endNode) {
|
707
|
+
let stop = endNode.nextSibling, current = startNode;
|
708
|
+
for (; current !== stop; ) {
|
709
|
+
let next = current.nextSibling;
|
710
|
+
current.remove(), current = next;
|
711
|
+
}
|
712
|
+
}
|
713
|
+
|
714
|
+
// src/dom/scope.ts
|
715
|
+
var pendingScopes = [];
|
716
|
+
function createScope($global) {
|
717
|
+
let scope = {
|
718
|
+
g: 1,
|
719
|
+
$global
|
720
|
+
};
|
721
|
+
return pendingScopes.push(scope), scope;
|
722
|
+
}
|
723
|
+
function finishPendingScopes() {
|
724
|
+
for (let scope of pendingScopes)
|
725
|
+
scope.g = 0;
|
726
|
+
pendingScopes = [];
|
727
|
+
}
|
728
|
+
var emptyBranch = createScope({});
|
729
|
+
function getEmptyBranch(marker) {
|
730
|
+
return emptyBranch.a = emptyBranch.b = marker, emptyBranch;
|
731
|
+
}
|
732
|
+
function destroyBranch(branch) {
|
733
|
+
branch.t?.k?.delete(branch), destroyNestedBranches(branch);
|
734
|
+
}
|
735
|
+
function destroyNestedBranches(branch) {
|
736
|
+
branch.D = 1, branch.k?.forEach(destroyNestedBranches), branch.E?.forEach((scope) => {
|
737
|
+
for (let id in scope.h)
|
738
|
+
scope.h[id]?.abort();
|
739
|
+
});
|
740
|
+
}
|
741
|
+
function removeAndDestroyBranch(branch) {
|
742
|
+
destroyBranch(branch), removeChildNodes(branch.a, branch.b);
|
743
|
+
}
|
744
|
+
function insertBranchBefore(branch, parentNode, nextSibling) {
|
745
|
+
let current = branch.a, stop = branch.b.nextSibling;
|
746
|
+
for (; current !== stop; ) {
|
747
|
+
let next = current.nextSibling;
|
748
|
+
parentNode.insertBefore(current, nextSibling), current = next;
|
749
|
+
}
|
750
|
+
}
|
751
|
+
|
752
|
+
// src/dom/reconcile.ts
|
753
|
+
var WRONG_POS = 2147483647;
|
754
|
+
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
755
|
+
let oldStart = 0, newStart = 0, oldEnd = oldBranches.length - 1, newEnd = newBranches.length - 1, oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart], oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd], i, j, k, nextSibling, oldBranch, newBranch;
|
756
|
+
outer: {
|
757
|
+
for (; oldStartBranch === newStartBranch; ) {
|
758
|
+
if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
|
759
|
+
break outer;
|
760
|
+
oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
|
761
|
+
}
|
762
|
+
for (; oldEndBranch === newEndBranch; ) {
|
763
|
+
if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
|
764
|
+
break outer;
|
765
|
+
oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
|
766
|
+
}
|
767
|
+
}
|
768
|
+
if (oldStart > oldEnd) {
|
769
|
+
if (newStart <= newEnd) {
|
770
|
+
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
|
771
|
+
do
|
772
|
+
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
773
|
+
while (newStart <= newEnd);
|
774
|
+
}
|
775
|
+
} else if (newStart > newEnd)
|
776
|
+
do
|
777
|
+
removeAndDestroyBranch(oldBranches[oldStart++]);
|
778
|
+
while (oldStart <= oldEnd);
|
779
|
+
else {
|
780
|
+
let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
|
781
|
+
for (i = 0; i < newLength; ++i)
|
782
|
+
sources[i] = -1;
|
783
|
+
let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
|
784
|
+
for (j = newStart; j <= newEnd; ++j)
|
785
|
+
keyIndex.set(newBranches[j], j);
|
786
|
+
for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
|
787
|
+
oldBranch = oldBranches[i], j = keyIndex.get(oldBranch), j !== void 0 && (pos = pos > j ? WRONG_POS : j, ++synced, newBranch = newBranches[j], sources[j - newStart] = i, aNullable[i] = null);
|
788
|
+
if (oldLength === oldBranches.length && synced === 0) {
|
789
|
+
for (; newStart < newLength; ++newStart)
|
790
|
+
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
791
|
+
for (; oldStart < oldLength; ++oldStart)
|
792
|
+
removeAndDestroyBranch(oldBranches[oldStart]);
|
793
|
+
} else {
|
794
|
+
for (i = oldLength - synced; i > 0; )
|
795
|
+
oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
|
796
|
+
if (pos === WRONG_POS) {
|
797
|
+
let seq = longestIncreasingSubsequence(sources);
|
798
|
+
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
799
|
+
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : --j;
|
800
|
+
} else if (synced !== newLength)
|
801
|
+
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
802
|
+
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
|
803
|
+
}
|
804
|
+
}
|
805
|
+
}
|
806
|
+
function longestIncreasingSubsequence(a) {
|
807
|
+
let p = a.slice(), result = [];
|
808
|
+
result.push(0);
|
809
|
+
let u, v;
|
810
|
+
for (let i = 0, il = a.length; i < il; ++i) {
|
811
|
+
if (a[i] === -1)
|
812
|
+
continue;
|
813
|
+
let j = result[result.length - 1];
|
814
|
+
if (a[j] < a[i]) {
|
815
|
+
p[i] = j, result.push(i);
|
816
|
+
continue;
|
817
|
+
}
|
818
|
+
for (u = 0, v = result.length - 1; u < v; ) {
|
819
|
+
let c = (u + v) / 2 | 0;
|
820
|
+
a[result[c]] < a[i] ? u = c + 1 : v = c;
|
821
|
+
}
|
822
|
+
a[i] < a[result[u]] && (u > 0 && (p[i] = result[u - 1]), result[u] = i);
|
823
|
+
}
|
824
|
+
for (u = result.length, v = result[u - 1]; u-- > 0; )
|
825
|
+
result[u] = v, v = p[v];
|
826
|
+
return result;
|
827
|
+
}
|
825
828
|
|
826
829
|
// src/dom/walker.ts
|
827
830
|
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
@@ -830,8 +833,8 @@ function trimWalkString(walkString) {
|
|
830
833
|
for (; walkString.charCodeAt(--end) > 47 /* BeginChild */; ) ;
|
831
834
|
return walkString.slice(0, end + 1);
|
832
835
|
}
|
833
|
-
function walk(startNode, walkCodes,
|
834
|
-
walker.currentNode = startNode, walkInternal(walkCodes,
|
836
|
+
function walk(startNode, walkCodes, branch) {
|
837
|
+
walker.currentNode = startNode, walkInternal(walkCodes, branch, 0), walker.currentNode = document;
|
835
838
|
}
|
836
839
|
function walkInternal(walkCodes, scope, currentWalkIndex) {
|
837
840
|
let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
@@ -850,7 +853,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
|
|
850
853
|
walker.nextNode();
|
851
854
|
else if (value2 === 47 /* BeginChild */) {
|
852
855
|
let childScope = scope[currentScopeIndex++] = createScope(scope.$global);
|
853
|
-
childScope.
|
856
|
+
childScope.c = scope.c, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
|
854
857
|
} else {
|
855
858
|
if (value2 === 38 /* EndChild */)
|
856
859
|
return currentWalkIndex;
|
@@ -871,7 +874,7 @@ function createBranchScopeWithRenderer(renderer, $global, parentScope) {
|
|
871
874
|
renderer.u || parentScope,
|
872
875
|
parentScope
|
873
876
|
);
|
874
|
-
return
|
877
|
+
return initBranch(renderer, branch), branch;
|
875
878
|
}
|
876
879
|
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope) {
|
877
880
|
if (typeof tagNameOrRenderer != "string")
|
@@ -881,19 +884,19 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
|
|
881
884
|
parentScope
|
882
885
|
);
|
883
886
|
let branch = createBranch($global, parentScope, parentScope);
|
884
|
-
return branch[0] = branch.a = branch.
|
887
|
+
return branch[0] = branch.a = branch.b = document.createElement(tagNameOrRenderer), branch;
|
885
888
|
}
|
886
889
|
function createBranch($global, ownerScope, parentScope) {
|
887
|
-
let branch = createScope($global), parentBranch = parentScope.
|
888
|
-
return branch._ = ownerScope, branch.
|
890
|
+
let branch = createScope($global), parentBranch = parentScope.c;
|
891
|
+
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.t = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch)) : branch.f = 1, branch;
|
889
892
|
}
|
890
|
-
function
|
893
|
+
function initBranch(renderer, branch) {
|
891
894
|
let dom = renderer.l();
|
892
895
|
return walk(
|
893
896
|
dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom,
|
894
|
-
renderer.
|
895
|
-
|
896
|
-
),
|
897
|
+
renderer.F,
|
898
|
+
branch
|
899
|
+
), branch.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, branch.b = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.x && queueRender(branch, renderer.x), dom;
|
897
900
|
}
|
898
901
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
899
902
|
return (scope, attrsOrOp) => {
|
@@ -902,13 +905,13 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
902
905
|
return;
|
903
906
|
let childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
|
904
907
|
if (attrsOrOp === MARK || attrsOrOp === CLEAN)
|
905
|
-
return renderer.
|
908
|
+
return renderer.d?.(childScope, attrsOrOp);
|
906
909
|
let content = getContent?.(scope);
|
907
910
|
if (typeof renderer == "string")
|
908
911
|
setConditionalRendererOnlyChild(childScope, 0, content), attrs(childScope, 0, attrsOrOp());
|
909
|
-
else if (renderer.
|
912
|
+
else if (renderer.d) {
|
910
913
|
let attributes = attrsOrOp();
|
911
|
-
renderer.
|
914
|
+
renderer.d(
|
912
915
|
childScope,
|
913
916
|
inputIsArgs ? attributes : [
|
914
917
|
content ? {
|
@@ -923,14 +926,14 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
923
926
|
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
924
927
|
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
925
928
|
return (owner) => ({
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
+
j: id,
|
930
|
+
G: template,
|
931
|
+
F: walks,
|
929
932
|
x: setup,
|
930
933
|
l: _clone,
|
931
934
|
u: owner,
|
932
|
-
|
933
|
-
get
|
935
|
+
H: void 0,
|
936
|
+
get d() {
|
934
937
|
return args ||= getArgs?.();
|
935
938
|
}
|
936
939
|
});
|
@@ -939,8 +942,8 @@ function createRenderer(template, walks, setup, getArgs) {
|
|
939
942
|
return createRendererWithOwner(template, walks, setup, getArgs)();
|
940
943
|
}
|
941
944
|
function _clone() {
|
942
|
-
return (this.
|
943
|
-
this.
|
945
|
+
return (this.H ||= parseHTMLOrSingleNode(
|
946
|
+
this.G
|
944
947
|
)).cloneNode(!0);
|
945
948
|
}
|
946
949
|
|
@@ -955,18 +958,18 @@ var conditional = function(nodeAccessor, fn, getIntersection) {
|
|
955
958
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
956
959
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
957
960
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
958
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
961
|
+
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
959
962
|
}
|
960
963
|
intersection2?.(scope, op);
|
961
964
|
};
|
962
965
|
};
|
963
966
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
964
|
-
let
|
965
|
-
|
966
|
-
newBranch
|
967
|
-
prevBranch.
|
968
|
-
prevBranch.
|
969
|
-
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "
|
967
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : getEmptyBranch(scope[nodeAccessor]);
|
968
|
+
insertBranchBefore(
|
969
|
+
newBranch,
|
970
|
+
prevBranch.b.parentNode,
|
971
|
+
prevBranch.b.nextSibling
|
972
|
+
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
970
973
|
}
|
971
974
|
var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
972
975
|
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
@@ -986,12 +989,12 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
|
986
989
|
};
|
987
990
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
988
991
|
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
|
989
|
-
referenceNode.textContent = "", newBranch &&
|
992
|
+
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
990
993
|
}
|
991
994
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
992
|
-
[Symbol(),
|
995
|
+
[Symbol(), getEmptyBranch(void 0)]
|
993
996
|
]), emptyMarkerArray = [
|
994
|
-
/* @__PURE__ */
|
997
|
+
/* @__PURE__ */ getEmptyBranch(void 0)
|
995
998
|
], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
|
996
999
|
function loopOf(nodeAccessor, renderer) {
|
997
1000
|
return loop(
|
@@ -1020,7 +1023,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1020
1023
|
);
|
1021
1024
|
}
|
1022
1025
|
function loop(nodeAccessor, renderer, forEach) {
|
1023
|
-
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.
|
1026
|
+
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.d;
|
1024
1027
|
return (scope, valueOrOp) => {
|
1025
1028
|
if (valueOrOp === DIRTY) return;
|
1026
1029
|
if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
@@ -1034,11 +1037,11 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1034
1037
|
if (forEach(valueOrOp, (key, args) => {
|
1035
1038
|
let branch = oldMap.get(key);
|
1036
1039
|
branch || (branch = createBranchScopeWithRenderer(renderer, scope.$global, scope)), params && params(branch, args), newMap ? (newMap.set(key, branch), newArray.push(branch)) : (newMap = /* @__PURE__ */ new Map([[key, branch]]), newArray = [branch]);
|
1037
|
-
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray,
|
1040
|
+
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyBranch(referenceNode)) : (oldArray.forEach(destroyBranch), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
|
1038
1041
|
if (referenceIsMarker) {
|
1039
|
-
oldMap === emptyMarkerMap &&
|
1042
|
+
oldMap === emptyMarkerMap && getEmptyBranch(referenceNode);
|
1040
1043
|
let oldLastChild = oldArray[oldArray.length - 1];
|
1041
|
-
afterReference = oldLastChild.
|
1044
|
+
afterReference = oldLastChild.b.nextSibling, parentNode = oldLastChild.a.parentNode;
|
1042
1045
|
} else
|
1043
1046
|
afterReference = null, parentNode = referenceNode;
|
1044
1047
|
reconcile(parentNode, oldArray, newArray, afterReference);
|
@@ -1053,7 +1056,7 @@ function byFirstArg(name) {
|
|
1053
1056
|
return name;
|
1054
1057
|
}
|
1055
1058
|
function isDifferentRenderer(a, b) {
|
1056
|
-
return a !== b && (a?.
|
1059
|
+
return a !== b && (a?.j || 0) !== b?.j;
|
1057
1060
|
}
|
1058
1061
|
|
1059
1062
|
// src/dom/signals.ts
|
@@ -1094,24 +1097,24 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
|
1094
1097
|
let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1095
1098
|
if (loopScopes !== emptyMarkerArray)
|
1096
1099
|
for (let scope of loopScopes)
|
1097
|
-
scope.
|
1100
|
+
scope.g || queueSource(scope, signal, value2);
|
1098
1101
|
};
|
1099
1102
|
return helperSignal._ = signal, helperSignal;
|
1100
1103
|
}
|
1101
1104
|
function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
|
1102
1105
|
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1103
1106
|
let conditionalScope = scope[scopeAccessor];
|
1104
|
-
conditionalScope && !conditionalScope.
|
1107
|
+
conditionalScope && !conditionalScope.g && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
|
1105
1108
|
};
|
1106
1109
|
return helperSignal._ = signal, helperSignal;
|
1107
1110
|
}
|
1108
1111
|
var defaultGetOwnerScope = (scope) => scope._;
|
1109
|
-
function dynamicClosure(
|
1110
|
-
let ownerSubscribersAccessor =
|
1112
|
+
function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
1113
|
+
let ownerSubscribersAccessor = "?" /* Dynamic */ + accessorId++, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
|
1111
1114
|
let subscribers = ownerScope[ownerSubscribersAccessor];
|
1112
1115
|
if (subscribers)
|
1113
1116
|
for (let subscriber of subscribers)
|
1114
|
-
subscriber.
|
1117
|
+
subscriber.g || queueSource(subscriber, _signal, value2);
|
1115
1118
|
}, setupSignal = (scope, value2) => {
|
1116
1119
|
_signal(scope, value2), subscribe(scope);
|
1117
1120
|
}, subscribe = (scope) => {
|
@@ -1119,7 +1122,7 @@ function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerS
|
|
1119
1122
|
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1120
1123
|
});
|
1121
1124
|
};
|
1122
|
-
return helperSignal._ = setupSignal, helperSignal.
|
1125
|
+
return helperSignal._ = setupSignal, helperSignal.C = subscribe, helperSignal;
|
1123
1126
|
}
|
1124
1127
|
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1125
1128
|
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
@@ -1152,29 +1155,25 @@ function effect(id, fn) {
|
|
1152
1155
|
}
|
1153
1156
|
|
1154
1157
|
// src/dom/queue.ts
|
1155
|
-
var
|
1158
|
+
var pendingRenders = [], pendingEffects = [], rendering = !1;
|
1156
1159
|
function queueSource(scope, signal, value2) {
|
1157
1160
|
schedule();
|
1158
1161
|
let prevRendering = rendering;
|
1159
1162
|
return rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2), value2;
|
1160
1163
|
}
|
1161
1164
|
function queueRender(scope, signal, value2) {
|
1162
|
-
let
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1165
|
+
let i = pendingRenders.length, render = {
|
1166
|
+
m: scope,
|
1167
|
+
I: signal,
|
1168
|
+
J: value2,
|
1169
|
+
y: i
|
1167
1170
|
};
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
else {
|
1173
|
-
let curRender = pendingRender;
|
1174
|
-
for (; curRender.d && comparePendingRenders(curRender.d, nextRender) >= 0; )
|
1175
|
-
curRender = curRender.d;
|
1176
|
-
nextRender.d = curRender.d, curRender.d = nextRender;
|
1171
|
+
for (pendingRenders.push(render); i; ) {
|
1172
|
+
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1173
|
+
if (comparePendingRenders(render, parent) >= 0) break;
|
1174
|
+
pendingRenders[i] = parent, i = parentIndex;
|
1177
1175
|
}
|
1176
|
+
pendingRenders[i] = render;
|
1178
1177
|
}
|
1179
1178
|
function queueEffect(scope, fn) {
|
1180
1179
|
pendingEffects.push(scope, fn);
|
@@ -1184,17 +1183,17 @@ function run() {
|
|
1184
1183
|
try {
|
1185
1184
|
rendering = !0, runRenders();
|
1186
1185
|
} finally {
|
1187
|
-
|
1186
|
+
pendingRenders = [], pendingEffects = [], rendering = !1;
|
1188
1187
|
}
|
1189
|
-
|
1188
|
+
runEffects(effects);
|
1190
1189
|
}
|
1191
1190
|
function prepareEffects(fn) {
|
1192
|
-
let
|
1193
|
-
|
1191
|
+
let prevRenders = pendingRenders, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
1192
|
+
pendingRenders = [];
|
1194
1193
|
try {
|
1195
1194
|
rendering = !0, fn(), runRenders();
|
1196
1195
|
} finally {
|
1197
|
-
rendering = !1,
|
1196
|
+
rendering = !1, pendingRenders = prevRenders, pendingEffects = prevEffects;
|
1198
1197
|
}
|
1199
1198
|
return preparedEffects;
|
1200
1199
|
}
|
@@ -1205,26 +1204,39 @@ function runEffects(effects = pendingEffects) {
|
|
1205
1204
|
}
|
1206
1205
|
}
|
1207
1206
|
function runRenders() {
|
1208
|
-
for (;
|
1209
|
-
|
1207
|
+
for (; pendingRenders.length; ) {
|
1208
|
+
let render = pendingRenders[0], next = pendingRenders.pop();
|
1209
|
+
if (render !== next) {
|
1210
|
+
let i = 0, mid = pendingRenders.length >> 1, item = pendingRenders[0] = next;
|
1211
|
+
for (; i < mid; ) {
|
1212
|
+
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1213
|
+
if (right < pendingRenders.length && comparePendingRenders(
|
1214
|
+
pendingRenders[right],
|
1215
|
+
pendingRenders[bestChild]
|
1216
|
+
) < 0 && (bestChild = right), comparePendingRenders(pendingRenders[bestChild], item) >= 0)
|
1217
|
+
break;
|
1218
|
+
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1219
|
+
}
|
1220
|
+
pendingRenders[i] = item;
|
1221
|
+
}
|
1222
|
+
render.m.c?.D || render.I(render.m, render.J);
|
1223
|
+
}
|
1210
1224
|
finishPendingScopes();
|
1211
1225
|
}
|
1212
1226
|
function comparePendingRenders(a, b) {
|
1213
|
-
|
1214
|
-
let aStart = ownerStartNode(a.g), bStart = ownerStartNode(b.g);
|
1215
|
-
return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
|
1227
|
+
return getBranchDepth(a) - getBranchDepth(b) || a.y - b.y;
|
1216
1228
|
}
|
1217
|
-
function
|
1218
|
-
return
|
1229
|
+
function getBranchDepth(render) {
|
1230
|
+
return render.m.c?.f || 0;
|
1219
1231
|
}
|
1220
1232
|
|
1221
1233
|
// src/dom/abort-signal.ts
|
1222
1234
|
function resetAbortSignal(scope, id) {
|
1223
|
-
let ctrl = scope.
|
1224
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1235
|
+
let ctrl = scope.h?.[id];
|
1236
|
+
ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
|
1225
1237
|
}
|
1226
1238
|
function getAbortSignal(scope, id) {
|
1227
|
-
return scope.
|
1239
|
+
return scope.c && (scope.c.E ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
|
1228
1240
|
}
|
1229
1241
|
function abort(ctrl) {
|
1230
1242
|
ctrl.abort();
|
@@ -1234,12 +1246,12 @@ function abort(ctrl) {
|
|
1234
1246
|
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
|
1235
1247
|
|
1236
1248
|
// src/dom/compat.ts
|
1237
|
-
var
|
1249
|
+
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
1238
1250
|
patchConditionals,
|
1239
1251
|
queueEffect,
|
1240
1252
|
init() {
|
1241
|
-
register(SET_SCOPE_REGISTER_ID, (
|
1242
|
-
|
1253
|
+
register(SET_SCOPE_REGISTER_ID, (branch) => {
|
1254
|
+
classIdToBranch.set(branch.m5c, branch);
|
1243
1255
|
});
|
1244
1256
|
},
|
1245
1257
|
registerRenderer(fn) {
|
@@ -1251,11 +1263,11 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1251
1263
|
isRenderer(renderer) {
|
1252
1264
|
return renderer.l !== void 0;
|
1253
1265
|
},
|
1254
|
-
getStartNode(
|
1255
|
-
return
|
1266
|
+
getStartNode(branch) {
|
1267
|
+
return branch.a;
|
1256
1268
|
},
|
1257
|
-
setScopeNodes(
|
1258
|
-
|
1269
|
+
setScopeNodes(branch, startNode, endNode) {
|
1270
|
+
branch.a = startNode, branch.b = endNode;
|
1259
1271
|
},
|
1260
1272
|
runComponentEffects() {
|
1261
1273
|
runEffects(this.effects);
|
@@ -1269,7 +1281,7 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1269
1281
|
}) {
|
1270
1282
|
return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
|
1271
1283
|
value2[0],
|
1272
|
-
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.
|
1284
|
+
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.o[value2[1]]
|
1273
1285
|
) : value2;
|
1274
1286
|
},
|
1275
1287
|
createRenderer(setup, clone, args) {
|
@@ -1277,18 +1289,18 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1277
1289
|
return renderer.l = clone, renderer;
|
1278
1290
|
},
|
1279
1291
|
render(out, component, renderer, args) {
|
1280
|
-
let
|
1281
|
-
|
1282
|
-
let applyArgs = renderer.
|
1292
|
+
let branch = component.scope;
|
1293
|
+
branch || (branch = classIdToBranch.get(component.id), branch && (component.scope = branch, classIdToBranch.delete(component.id)));
|
1294
|
+
let applyArgs = renderer.d || noop, existing = !1;
|
1283
1295
|
if (typeof args[0] == "object" && "renderBody" in args[0]) {
|
1284
1296
|
let input = args[0], normalizedInput = args[0] = {};
|
1285
1297
|
for (let key in input)
|
1286
1298
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1287
1299
|
}
|
1288
1300
|
if (component.effects = prepareEffects(() => {
|
1289
|
-
|
1301
|
+
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.u, initBranch(renderer, branch)), applyArgs(branch, args);
|
1290
1302
|
}), !existing)
|
1291
|
-
return
|
1303
|
+
return branch.a === branch.b ? branch.a : branch.a.parentNode;
|
1292
1304
|
}
|
1293
1305
|
};
|
1294
1306
|
function noop() {
|
@@ -1300,33 +1312,29 @@ var createTemplate = (templateId, ...rendererArgs) => {
|
|
1300
1312
|
return renderer.mount = mount, renderer._ = renderer, register(templateId, renderer);
|
1301
1313
|
};
|
1302
1314
|
function mount(input = {}, reference, position) {
|
1303
|
-
let branch, dom, { $global } = input;
|
1304
|
-
$global ? ({ $global, ...input } = input, $global = {
|
1315
|
+
let branch, dom, parentNode = reference, nextSibling = null, { $global } = input;
|
1316
|
+
switch ($global ? ({ $global, ...input } = input, $global = {
|
1305
1317
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1306
1318
|
renderId: DEFAULT_RENDER_ID,
|
1307
1319
|
...$global
|
1308
1320
|
}) : $global = {
|
1309
1321
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1310
1322
|
renderId: DEFAULT_RENDER_ID
|
1311
|
-
}
|
1312
|
-
let args = this.f, effects = prepareEffects(() => {
|
1313
|
-
branch = createScope($global), dom = initRenderer(this, branch), args && args(branch, [input]);
|
1314
|
-
});
|
1315
|
-
switch (position) {
|
1323
|
+
}, position) {
|
1316
1324
|
case "beforebegin":
|
1317
|
-
reference.parentNode
|
1325
|
+
parentNode = reference.parentNode, nextSibling = reference;
|
1318
1326
|
break;
|
1319
1327
|
case "afterbegin":
|
1320
|
-
|
1328
|
+
nextSibling = reference.firstChild;
|
1321
1329
|
break;
|
1322
1330
|
case "afterend":
|
1323
|
-
reference.parentNode
|
1324
|
-
break;
|
1325
|
-
default:
|
1326
|
-
reference.appendChild(dom);
|
1331
|
+
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
1327
1332
|
break;
|
1328
1333
|
}
|
1329
|
-
|
1334
|
+
let args = this.d, effects = prepareEffects(() => {
|
1335
|
+
branch = createScope($global), dom = initBranch(this, branch), args?.(branch, [input]);
|
1336
|
+
});
|
1337
|
+
return parentNode.insertBefore(dom, nextSibling), runEffects(effects), {
|
1330
1338
|
update: (newInput) => {
|
1331
1339
|
args && runEffects(
|
1332
1340
|
prepareEffects(() => {
|