marko 6.0.0-next.3.26 → 6.0.0-next.3.28
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/compat-meta.d.ts +1 -0
- package/dist/common/types.d.ts +3 -3
- package/dist/debug/dom.js +279 -275
- package/dist/debug/dom.mjs +279 -275
- package/dist/debug/html.js +107 -32
- package/dist/debug/html.mjs +106 -32
- package/dist/dom/compat.d.ts +4 -4
- package/dist/dom/dom.d.ts +2 -1
- package/dist/dom/reconcile.d.ts +1 -1
- package/dist/dom/scope.d.ts +1 -1
- package/dist/dom/walker.d.ts +2 -2
- package/dist/dom.js +187 -187
- package/dist/dom.mjs +187 -187
- package/dist/html/compat.d.ts +1 -0
- package/dist/html/serializer.d.ts +2 -0
- package/dist/html.d.ts +1 -0
- package/dist/html.js +26 -17
- package/dist/html.mjs +25 -17
- package/dist/translator/index.js +56 -13
- package/dist/translator/util/references.d.ts +2 -1
- package/dist/translator/util/sections.d.ts +1 -0
- package/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/dom.js
CHANGED
@@ -129,49 +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
|
-
f: 1,
|
137
|
-
$global
|
138
|
-
};
|
139
|
-
return pendingScopes.push(scope), scope;
|
140
|
-
}
|
141
|
-
function finishPendingScopes() {
|
142
|
-
for (let scope of pendingScopes)
|
143
|
-
scope.f = 0;
|
144
|
-
pendingScopes = [];
|
145
|
-
}
|
146
|
-
var emptyBranch = createScope({});
|
147
|
-
function getEmptyBranch(marker) {
|
148
|
-
return emptyBranch.a = emptyBranch.c = marker, emptyBranch;
|
149
|
-
}
|
150
|
-
function destroyBranch(branch) {
|
151
|
-
branch.n?.k?.delete(branch), destroyNestedBranches(branch);
|
152
|
-
}
|
153
|
-
function destroyNestedBranches(branch) {
|
154
|
-
branch.z = 1, branch.k?.forEach(destroyNestedBranches), branch.A?.forEach((scope) => {
|
155
|
-
for (let id in scope.g)
|
156
|
-
scope.g[id]?.abort();
|
157
|
-
});
|
158
|
-
}
|
159
|
-
function removeAndDestroyBranch(branch) {
|
160
|
-
destroyBranch(branch);
|
161
|
-
let current = branch.a, stop = branch.c.nextSibling;
|
162
|
-
for (; current !== stop; ) {
|
163
|
-
let next = current.nextSibling;
|
164
|
-
current.remove(), current = next;
|
165
|
-
}
|
166
|
-
}
|
167
|
-
function insertBranchBefore(branch, parent, nextSibling) {
|
168
|
-
let current = branch.a, stop = branch.c.nextSibling;
|
169
|
-
for (; current !== stop; ) {
|
170
|
-
let next = current.nextSibling;
|
171
|
-
parent.insertBefore(current, nextSibling), current = next;
|
172
|
-
}
|
173
|
-
}
|
174
|
-
|
175
132
|
// src/common/helpers.ts
|
176
133
|
function classValue(value2) {
|
177
134
|
return toDelimitedString(value2, " ", stringifyClassObject);
|
@@ -218,83 +175,6 @@ function normalizeDynamicRenderer(value2) {
|
|
218
175
|
if (value2) return value2.content || value2.default || value2;
|
219
176
|
}
|
220
177
|
|
221
|
-
// src/dom/reconcile.ts
|
222
|
-
var WRONG_POS = 2147483647;
|
223
|
-
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
224
|
-
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;
|
225
|
-
outer: {
|
226
|
-
for (; oldStartBranch === newStartBranch; ) {
|
227
|
-
if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
|
228
|
-
break outer;
|
229
|
-
oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
|
230
|
-
}
|
231
|
-
for (; oldEndBranch === newEndBranch; ) {
|
232
|
-
if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
|
233
|
-
break outer;
|
234
|
-
oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
|
235
|
-
}
|
236
|
-
}
|
237
|
-
if (oldStart > oldEnd) {
|
238
|
-
if (newStart <= newEnd) {
|
239
|
-
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
|
240
|
-
do
|
241
|
-
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
242
|
-
while (newStart <= newEnd);
|
243
|
-
}
|
244
|
-
} else if (newStart > newEnd)
|
245
|
-
do
|
246
|
-
removeAndDestroyBranch(oldBranches[oldStart++]);
|
247
|
-
while (oldStart <= oldEnd);
|
248
|
-
else {
|
249
|
-
let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
|
250
|
-
for (i = 0; i < newLength; ++i)
|
251
|
-
sources[i] = -1;
|
252
|
-
let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
|
253
|
-
for (j = newStart; j <= newEnd; ++j)
|
254
|
-
keyIndex.set(newBranches[j], j);
|
255
|
-
for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
|
256
|
-
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);
|
257
|
-
if (oldLength === oldBranches.length && synced === 0) {
|
258
|
-
for (; newStart < newLength; ++newStart)
|
259
|
-
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
260
|
-
for (; oldStart < oldLength; ++oldStart)
|
261
|
-
removeAndDestroyBranch(oldBranches[oldStart]);
|
262
|
-
} else {
|
263
|
-
for (i = oldLength - synced; i > 0; )
|
264
|
-
oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
|
265
|
-
if (pos === WRONG_POS) {
|
266
|
-
let seq = longestIncreasingSubsequence(sources);
|
267
|
-
for (j = seq.length - 1, 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, 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;
|
269
|
-
} else if (synced !== newLength)
|
270
|
-
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
271
|
-
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
|
272
|
-
}
|
273
|
-
}
|
274
|
-
}
|
275
|
-
function longestIncreasingSubsequence(a) {
|
276
|
-
let p = a.slice(), result = [];
|
277
|
-
result.push(0);
|
278
|
-
let u, v;
|
279
|
-
for (let i = 0, il = a.length; i < il; ++i) {
|
280
|
-
if (a[i] === -1)
|
281
|
-
continue;
|
282
|
-
let j = result[result.length - 1];
|
283
|
-
if (a[j] < a[i]) {
|
284
|
-
p[i] = j, result.push(i);
|
285
|
-
continue;
|
286
|
-
}
|
287
|
-
for (u = 0, v = result.length - 1; u < v; ) {
|
288
|
-
let c = (u + v) / 2 | 0;
|
289
|
-
a[result[c]] < a[i] ? u = c + 1 : v = c;
|
290
|
-
}
|
291
|
-
a[i] < a[result[u]] && (u > 0 && (p[i] = result[u - 1]), result[u] = i);
|
292
|
-
}
|
293
|
-
for (u = result.length, v = result[u - 1]; u-- > 0; )
|
294
|
-
result[u] = v, v = p[v];
|
295
|
-
return result;
|
296
|
-
}
|
297
|
-
|
298
178
|
// src/dom/event.ts
|
299
179
|
var elementHandlersByEvent = /* @__PURE__ */ new Map(), defaultDelegator = createDelegator();
|
300
180
|
function on(element, type, handler) {
|
@@ -309,7 +189,7 @@ function createDelegator() {
|
|
309
189
|
};
|
310
190
|
}
|
311
191
|
function handleDelegated(ev) {
|
312
|
-
let target = ev.target;
|
192
|
+
let target = !rendering && ev.target;
|
313
193
|
if (target) {
|
314
194
|
let handlersByElement = elementHandlersByEvent.get(ev.type);
|
315
195
|
if (handlersByElement.get(target)?.(ev, target), ev.bubbles)
|
@@ -345,28 +225,28 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
345
225
|
|
346
226
|
// src/dom/resume.ts
|
347
227
|
var registeredValues = {}, Render = class {
|
348
|
-
|
349
|
-
|
350
|
-
|
228
|
+
n = [];
|
229
|
+
o = {};
|
230
|
+
z = {
|
351
231
|
_: registeredValues
|
352
232
|
};
|
353
233
|
constructor(renders, runtimeId, renderId) {
|
354
|
-
this.
|
234
|
+
this.A = renders, this.B = runtimeId, this.p = renderId, this.q = renders[renderId], this.s();
|
355
235
|
}
|
356
236
|
w() {
|
357
|
-
this.
|
237
|
+
this.q.w(), this.s();
|
358
238
|
}
|
359
|
-
|
360
|
-
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();
|
361
241
|
if (visits.length) {
|
362
|
-
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map();
|
242
|
+
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
|
363
243
|
data2.v = [];
|
364
|
-
let branchEnd = (branchId, visit,
|
365
|
-
let branch = scopeLookup[branchId] ||= {}, endNode =
|
366
|
-
for (; (endNode = endNode.previousSibling)
|
367
|
-
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;
|
368
248
|
for (let [markerScopeId, markerNode] of closestBranchMarkers)
|
369
|
-
branch.a.compareDocumentPosition(markerNode) & 4 &&
|
249
|
+
branch.a.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
|
370
250
|
return branchIds.add(branchId), closestBranchMarkers.set(branchId, visit), branch;
|
371
251
|
};
|
372
252
|
for (let visit of visits) {
|
@@ -379,7 +259,7 @@ var registeredValues = {}, Render = class {
|
|
379
259
|
else if (token === "$" /* ClosestBranch */)
|
380
260
|
closestBranchMarkers.set(scopeId, visit);
|
381
261
|
else if (token === "[" /* BranchStart */)
|
382
|
-
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.
|
262
|
+
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.n.push(this.e)), this.e = scopeId, scope.a = visit;
|
383
263
|
else if (token === "]" /* BranchEnd */) {
|
384
264
|
scope[data3] = visit;
|
385
265
|
let curParent = visit.parentNode, startNode = branchEnd(
|
@@ -387,14 +267,14 @@ var registeredValues = {}, Render = class {
|
|
387
267
|
visit,
|
388
268
|
visit
|
389
269
|
).a;
|
390
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.
|
270
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.n.pop();
|
391
271
|
} else if (token === "|" /* BranchSingleNode */) {
|
392
272
|
let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
|
393
273
|
for (; ~next; ) {
|
394
274
|
let start = next + 1;
|
395
275
|
next = data3.indexOf(" ", start);
|
396
276
|
let childScopeId = data3.slice(start, ~next ? next : data3.length);
|
397
|
-
curNode = branchEnd(childScopeId, visit, curNode).
|
277
|
+
curNode = branchEnd(childScopeId, visit, curNode).b;
|
398
278
|
}
|
399
279
|
}
|
400
280
|
}
|
@@ -408,7 +288,7 @@ var registeredValues = {}, Render = class {
|
|
408
288
|
let resumeData = resumes[i++];
|
409
289
|
if (typeof resumeData == "function") {
|
410
290
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
411
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.
|
291
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.B, $global.renderId = this.p);
|
412
292
|
for (let scopeId in scopes)
|
413
293
|
if (scopeId !== "$") {
|
414
294
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -417,12 +297,12 @@ var registeredValues = {}, Render = class {
|
|
417
297
|
prevScope
|
418
298
|
));
|
419
299
|
let parentBranchId = parentBranchIds.get(scopeId);
|
420
|
-
if (parentBranchId && (scope.
|
421
|
-
let branch = scope, parentBranch = branch.
|
422
|
-
branch.
|
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));
|
423
303
|
}
|
424
304
|
}
|
425
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.
|
305
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.A[this.p] : registeredValues[resumes[i++]](
|
426
306
|
scopeLookup[resumeData],
|
427
307
|
scopeLookup[resumeData]
|
428
308
|
);
|
@@ -460,7 +340,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
460
340
|
}
|
461
341
|
}
|
462
342
|
function registerSubscriber(id, signal) {
|
463
|
-
return register(id, signal.
|
343
|
+
return register(id, signal.C), signal;
|
464
344
|
}
|
465
345
|
function nodeRef(id, key) {
|
466
346
|
return register(id, (scope) => () => scope[key]);
|
@@ -639,7 +519,7 @@ function toValueProp(it) {
|
|
639
519
|
}
|
640
520
|
|
641
521
|
// src/dom/parse-html.ts
|
642
|
-
var
|
522
|
+
var parser = /* @__PURE__ */ document.createElement("template");
|
643
523
|
function parseHTML(html2) {
|
644
524
|
return parser.innerHTML = html2, parser.content;
|
645
525
|
}
|
@@ -654,7 +534,7 @@ function parseHTMLOrSingleNode(html2) {
|
|
654
534
|
let fragment = new DocumentFragment();
|
655
535
|
return fragment.appendChild(content), fragment;
|
656
536
|
}
|
657
|
-
return
|
537
|
+
return new Text();
|
658
538
|
}
|
659
539
|
|
660
540
|
// src/dom/dom.ts
|
@@ -793,14 +673,12 @@ function attrsEvents(scope, nodeAccessor) {
|
|
793
673
|
for (let name in events)
|
794
674
|
on(el, name, events[name]);
|
795
675
|
}
|
796
|
-
function html(scope, value2,
|
797
|
-
let firstChild = scope[
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
current.remove(), current = next;
|
803
|
-
}
|
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);
|
804
682
|
}
|
805
683
|
function props(scope, nodeIndex, index) {
|
806
684
|
let nextProps = scope[index], prevProps = scope[index + "-"], node = scope[nodeIndex];
|
@@ -825,6 +703,128 @@ function lifecycle(scope, index, thisObj) {
|
|
825
703
|
"-" /* LifecycleAbortController */ + index
|
826
704
|
).onabort = () => thisObj.onDestroy?.());
|
827
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
|
+
}
|
828
828
|
|
829
829
|
// src/dom/walker.ts
|
830
830
|
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
@@ -833,8 +833,8 @@ function trimWalkString(walkString) {
|
|
833
833
|
for (; walkString.charCodeAt(--end) > 47 /* BeginChild */; ) ;
|
834
834
|
return walkString.slice(0, end + 1);
|
835
835
|
}
|
836
|
-
function walk(startNode, walkCodes,
|
837
|
-
walker.currentNode = startNode, walkInternal(walkCodes,
|
836
|
+
function walk(startNode, walkCodes, branch) {
|
837
|
+
walker.currentNode = startNode, walkInternal(walkCodes, branch, 0), walker.currentNode = document;
|
838
838
|
}
|
839
839
|
function walkInternal(walkCodes, scope, currentWalkIndex) {
|
840
840
|
let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
@@ -853,7 +853,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
|
|
853
853
|
walker.nextNode();
|
854
854
|
else if (value2 === 47 /* BeginChild */) {
|
855
855
|
let childScope = scope[currentScopeIndex++] = createScope(scope.$global);
|
856
|
-
childScope.
|
856
|
+
childScope.c = scope.c, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
|
857
857
|
} else {
|
858
858
|
if (value2 === 38 /* EndChild */)
|
859
859
|
return currentWalkIndex;
|
@@ -884,11 +884,11 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
|
|
884
884
|
parentScope
|
885
885
|
);
|
886
886
|
let branch = createBranch($global, parentScope, parentScope);
|
887
|
-
return branch[0] = branch.a = branch.
|
887
|
+
return branch[0] = branch.a = branch.b = document.createElement(tagNameOrRenderer), branch;
|
888
888
|
}
|
889
889
|
function createBranch($global, ownerScope, parentScope) {
|
890
|
-
let branch = createScope($global), parentBranch = parentScope.
|
891
|
-
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;
|
892
892
|
}
|
893
893
|
function initBranch(renderer, branch) {
|
894
894
|
let dom = renderer.l();
|
@@ -896,7 +896,7 @@ function initBranch(renderer, branch) {
|
|
896
896
|
dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom,
|
897
897
|
renderer.F,
|
898
898
|
branch
|
899
|
-
), branch.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, 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;
|
900
900
|
}
|
901
901
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
902
902
|
return (scope, attrsOrOp) => {
|
@@ -967,8 +967,8 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
|
967
967
|
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : getEmptyBranch(scope[nodeAccessor]);
|
968
968
|
insertBranchBefore(
|
969
969
|
newBranch,
|
970
|
-
prevBranch.
|
971
|
-
prevBranch.
|
970
|
+
prevBranch.b.parentNode,
|
971
|
+
prevBranch.b.nextSibling
|
972
972
|
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
973
973
|
}
|
974
974
|
var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
@@ -1041,7 +1041,7 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1041
1041
|
if (referenceIsMarker) {
|
1042
1042
|
oldMap === emptyMarkerMap && getEmptyBranch(referenceNode);
|
1043
1043
|
let oldLastChild = oldArray[oldArray.length - 1];
|
1044
|
-
afterReference = oldLastChild.
|
1044
|
+
afterReference = oldLastChild.b.nextSibling, parentNode = oldLastChild.a.parentNode;
|
1045
1045
|
} else
|
1046
1046
|
afterReference = null, parentNode = referenceNode;
|
1047
1047
|
reconcile(parentNode, oldArray, newArray, afterReference);
|
@@ -1097,14 +1097,14 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
|
1097
1097
|
let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1098
1098
|
if (loopScopes !== emptyMarkerArray)
|
1099
1099
|
for (let scope of loopScopes)
|
1100
|
-
scope.
|
1100
|
+
scope.g || queueSource(scope, signal, value2);
|
1101
1101
|
};
|
1102
1102
|
return helperSignal._ = signal, helperSignal;
|
1103
1103
|
}
|
1104
1104
|
function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
|
1105
1105
|
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1106
1106
|
let conditionalScope = scope[scopeAccessor];
|
1107
|
-
conditionalScope && !conditionalScope.
|
1107
|
+
conditionalScope && !conditionalScope.g && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
|
1108
1108
|
};
|
1109
1109
|
return helperSignal._ = signal, helperSignal;
|
1110
1110
|
}
|
@@ -1114,7 +1114,7 @@ function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersectio
|
|
1114
1114
|
let subscribers = ownerScope[ownerSubscribersAccessor];
|
1115
1115
|
if (subscribers)
|
1116
1116
|
for (let subscriber of subscribers)
|
1117
|
-
subscriber.
|
1117
|
+
subscriber.g || queueSource(subscriber, _signal, value2);
|
1118
1118
|
}, setupSignal = (scope, value2) => {
|
1119
1119
|
_signal(scope, value2), subscribe(scope);
|
1120
1120
|
}, subscribe = (scope) => {
|
@@ -1122,7 +1122,7 @@ function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersectio
|
|
1122
1122
|
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1123
1123
|
});
|
1124
1124
|
};
|
1125
|
-
return helperSignal._ = setupSignal, helperSignal.
|
1125
|
+
return helperSignal._ = setupSignal, helperSignal.C = subscribe, helperSignal;
|
1126
1126
|
}
|
1127
1127
|
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1128
1128
|
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
@@ -1219,7 +1219,7 @@ function runRenders() {
|
|
1219
1219
|
}
|
1220
1220
|
pendingRenders[i] = item;
|
1221
1221
|
}
|
1222
|
-
render.m.
|
1222
|
+
render.m.c?.D || render.I(render.m, render.J);
|
1223
1223
|
}
|
1224
1224
|
finishPendingScopes();
|
1225
1225
|
}
|
@@ -1227,32 +1227,32 @@ function comparePendingRenders(a, b) {
|
|
1227
1227
|
return getBranchDepth(a) - getBranchDepth(b) || a.y - b.y;
|
1228
1228
|
}
|
1229
1229
|
function getBranchDepth(render) {
|
1230
|
-
return render.m.
|
1230
|
+
return render.m.c?.f || 0;
|
1231
1231
|
}
|
1232
1232
|
|
1233
1233
|
// src/dom/abort-signal.ts
|
1234
1234
|
function resetAbortSignal(scope, id) {
|
1235
|
-
let ctrl = scope.
|
1236
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1235
|
+
let ctrl = scope.h?.[id];
|
1236
|
+
ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
|
1237
1237
|
}
|
1238
1238
|
function getAbortSignal(scope, id) {
|
1239
|
-
return scope.
|
1239
|
+
return scope.c && (scope.c.E ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
|
1240
1240
|
}
|
1241
1241
|
function abort(ctrl) {
|
1242
1242
|
ctrl.abort();
|
1243
1243
|
}
|
1244
1244
|
|
1245
1245
|
// src/common/compat-meta.ts
|
1246
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
|
1246
|
+
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
1247
1247
|
|
1248
1248
|
// src/dom/compat.ts
|
1249
|
-
var
|
1249
|
+
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
1250
1250
|
patchConditionals,
|
1251
1251
|
queueEffect,
|
1252
|
-
init() {
|
1253
|
-
register(SET_SCOPE_REGISTER_ID, (
|
1254
|
-
|
1255
|
-
});
|
1252
|
+
init(warp10Noop) {
|
1253
|
+
register(SET_SCOPE_REGISTER_ID, (branch) => {
|
1254
|
+
classIdToBranch.set(branch.m5c, branch);
|
1255
|
+
}), register(RENDER_BODY_ID, warp10Noop);
|
1256
1256
|
},
|
1257
1257
|
registerRenderer(fn) {
|
1258
1258
|
register(RENDERER_REGISTER_ID, fn);
|
@@ -1263,11 +1263,11 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1263
1263
|
isRenderer(renderer) {
|
1264
1264
|
return renderer.l !== void 0;
|
1265
1265
|
},
|
1266
|
-
getStartNode(
|
1267
|
-
return
|
1266
|
+
getStartNode(branch) {
|
1267
|
+
return branch.a;
|
1268
1268
|
},
|
1269
|
-
setScopeNodes(
|
1270
|
-
|
1269
|
+
setScopeNodes(branch, startNode, endNode) {
|
1270
|
+
branch.a = startNode, branch.b = endNode;
|
1271
1271
|
},
|
1272
1272
|
runComponentEffects() {
|
1273
1273
|
runEffects(this.effects);
|
@@ -1281,7 +1281,7 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1281
1281
|
}) {
|
1282
1282
|
return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
|
1283
1283
|
value2[0],
|
1284
|
-
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.
|
1284
|
+
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.o[value2[1]]
|
1285
1285
|
) : value2;
|
1286
1286
|
},
|
1287
1287
|
createRenderer(setup, clone, args) {
|
@@ -1289,8 +1289,8 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1289
1289
|
return renderer.l = clone, renderer;
|
1290
1290
|
},
|
1291
1291
|
render(out, component, renderer, args) {
|
1292
|
-
let
|
1293
|
-
|
1292
|
+
let branch = component.scope;
|
1293
|
+
branch || (branch = classIdToBranch.get(component.id), branch && (component.scope = branch, classIdToBranch.delete(component.id)));
|
1294
1294
|
let applyArgs = renderer.d || noop, existing = !1;
|
1295
1295
|
if (typeof args[0] == "object" && "renderBody" in args[0]) {
|
1296
1296
|
let input = args[0], normalizedInput = args[0] = {};
|
@@ -1298,9 +1298,9 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1298
1298
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1299
1299
|
}
|
1300
1300
|
if (component.effects = prepareEffects(() => {
|
1301
|
-
|
1301
|
+
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.u, initBranch(renderer, branch)), applyArgs(branch, args);
|
1302
1302
|
}), !existing)
|
1303
|
-
return
|
1303
|
+
return branch.a === branch.b ? branch.a : branch.a.parentNode;
|
1304
1304
|
}
|
1305
1305
|
};
|
1306
1306
|
function noop() {
|