marko 6.0.0-next.3.26 → 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 +3 -3
- package/dist/debug/dom.js +276 -274
- package/dist/debug/dom.mjs +276 -274
- 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/scope.d.ts +1 -1
- package/dist/dom/walker.d.ts +2 -2
- package/dist/dom.js +184 -184
- package/dist/dom.mjs +184 -184
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/debug/dom.mjs
CHANGED
@@ -87,64 +87,6 @@ function triggerMacroTask() {
|
|
87
87
|
port2.postMessage(0);
|
88
88
|
}
|
89
89
|
|
90
|
-
// src/dom/scope.ts
|
91
|
-
var pendingScopes = [];
|
92
|
-
var debugID = 0;
|
93
|
-
function createScope($global) {
|
94
|
-
const scope = {
|
95
|
-
___pending: 1,
|
96
|
-
$global
|
97
|
-
};
|
98
|
-
if (true) {
|
99
|
-
scope.___debugId = "client-" + debugID++;
|
100
|
-
}
|
101
|
-
pendingScopes.push(scope);
|
102
|
-
return scope;
|
103
|
-
}
|
104
|
-
function finishPendingScopes() {
|
105
|
-
for (const scope of pendingScopes) {
|
106
|
-
scope.___pending = 0;
|
107
|
-
}
|
108
|
-
pendingScopes = [];
|
109
|
-
}
|
110
|
-
var emptyBranch = createScope({});
|
111
|
-
function getEmptyBranch(marker) {
|
112
|
-
emptyBranch.___startNode = emptyBranch.___endNode = marker;
|
113
|
-
return emptyBranch;
|
114
|
-
}
|
115
|
-
function destroyBranch(branch) {
|
116
|
-
branch.___parentBranch?.___branchScopes?.delete(branch);
|
117
|
-
destroyNestedBranches(branch);
|
118
|
-
}
|
119
|
-
function destroyNestedBranches(branch) {
|
120
|
-
branch.___destroyed = 1;
|
121
|
-
branch.___branchScopes?.forEach(destroyNestedBranches);
|
122
|
-
branch.___abortScopes?.forEach((scope) => {
|
123
|
-
for (const id in scope.___abortControllers) {
|
124
|
-
scope.___abortControllers[id]?.abort();
|
125
|
-
}
|
126
|
-
});
|
127
|
-
}
|
128
|
-
function removeAndDestroyBranch(branch) {
|
129
|
-
destroyBranch(branch);
|
130
|
-
let current = branch.___startNode;
|
131
|
-
const stop = branch.___endNode.nextSibling;
|
132
|
-
while (current !== stop) {
|
133
|
-
const next = current.nextSibling;
|
134
|
-
current.remove();
|
135
|
-
current = next;
|
136
|
-
}
|
137
|
-
}
|
138
|
-
function insertBranchBefore(branch, parent, nextSibling) {
|
139
|
-
let current = branch.___startNode;
|
140
|
-
const stop = branch.___endNode.nextSibling;
|
141
|
-
while (current !== stop) {
|
142
|
-
const next = current.nextSibling;
|
143
|
-
parent.insertBefore(current, nextSibling);
|
144
|
-
current = next;
|
145
|
-
}
|
146
|
-
}
|
147
|
-
|
148
90
|
// src/common/helpers.ts
|
149
91
|
function classValue(value2) {
|
150
92
|
return toDelimitedString(value2, " ", stringifyClassObject);
|
@@ -200,173 +142,6 @@ function normalizeDynamicRenderer(value2) {
|
|
200
142
|
if (value2) return value2.content || value2.default || value2;
|
201
143
|
}
|
202
144
|
|
203
|
-
// src/dom/reconcile.ts
|
204
|
-
var WRONG_POS = 2147483647;
|
205
|
-
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
206
|
-
let oldStart = 0;
|
207
|
-
let newStart = 0;
|
208
|
-
let oldEnd = oldBranches.length - 1;
|
209
|
-
let newEnd = newBranches.length - 1;
|
210
|
-
let oldStartBranch = oldBranches[oldStart];
|
211
|
-
let newStartBranch = newBranches[newStart];
|
212
|
-
let oldEndBranch = oldBranches[oldEnd];
|
213
|
-
let newEndBranch = newBranches[newEnd];
|
214
|
-
let i;
|
215
|
-
let j;
|
216
|
-
let k;
|
217
|
-
let nextSibling;
|
218
|
-
let oldBranch;
|
219
|
-
let newBranch;
|
220
|
-
outer: {
|
221
|
-
while (oldStartBranch === newStartBranch) {
|
222
|
-
++oldStart;
|
223
|
-
++newStart;
|
224
|
-
if (oldStart > oldEnd || newStart > newEnd) {
|
225
|
-
break outer;
|
226
|
-
}
|
227
|
-
oldStartBranch = oldBranches[oldStart];
|
228
|
-
newStartBranch = newBranches[newStart];
|
229
|
-
}
|
230
|
-
while (oldEndBranch === newEndBranch) {
|
231
|
-
--oldEnd;
|
232
|
-
--newEnd;
|
233
|
-
if (oldStart > oldEnd || newStart > newEnd) {
|
234
|
-
break outer;
|
235
|
-
}
|
236
|
-
oldEndBranch = oldBranches[oldEnd];
|
237
|
-
newEndBranch = newBranches[newEnd];
|
238
|
-
}
|
239
|
-
}
|
240
|
-
if (oldStart > oldEnd) {
|
241
|
-
if (newStart <= newEnd) {
|
242
|
-
k = newEnd + 1;
|
243
|
-
nextSibling = k < newBranches.length ? newBranches[k].___startNode : afterReference;
|
244
|
-
do {
|
245
|
-
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
246
|
-
} while (newStart <= newEnd);
|
247
|
-
}
|
248
|
-
} else if (newStart > newEnd) {
|
249
|
-
do {
|
250
|
-
removeAndDestroyBranch(oldBranches[oldStart++]);
|
251
|
-
} while (oldStart <= oldEnd);
|
252
|
-
} else {
|
253
|
-
const oldLength = oldEnd - oldStart + 1;
|
254
|
-
const newLength = newEnd - newStart + 1;
|
255
|
-
const aNullable = oldBranches;
|
256
|
-
const sources = new Array(newLength);
|
257
|
-
for (i = 0; i < newLength; ++i) {
|
258
|
-
sources[i] = -1;
|
259
|
-
}
|
260
|
-
let pos = 0;
|
261
|
-
let synced = 0;
|
262
|
-
const keyIndex = /* @__PURE__ */ new Map();
|
263
|
-
for (j = newStart; j <= newEnd; ++j) {
|
264
|
-
keyIndex.set(newBranches[j], j);
|
265
|
-
}
|
266
|
-
for (i = oldStart; i <= oldEnd && synced < newLength; ++i) {
|
267
|
-
oldBranch = oldBranches[i];
|
268
|
-
j = keyIndex.get(oldBranch);
|
269
|
-
if (j !== void 0) {
|
270
|
-
pos = pos > j ? WRONG_POS : j;
|
271
|
-
++synced;
|
272
|
-
newBranch = newBranches[j];
|
273
|
-
sources[j - newStart] = i;
|
274
|
-
aNullable[i] = null;
|
275
|
-
}
|
276
|
-
}
|
277
|
-
if (oldLength === oldBranches.length && synced === 0) {
|
278
|
-
for (; newStart < newLength; ++newStart) {
|
279
|
-
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
280
|
-
}
|
281
|
-
for (; oldStart < oldLength; ++oldStart) {
|
282
|
-
removeAndDestroyBranch(oldBranches[oldStart]);
|
283
|
-
}
|
284
|
-
} else {
|
285
|
-
i = oldLength - synced;
|
286
|
-
while (i > 0) {
|
287
|
-
oldBranch = aNullable[oldStart++];
|
288
|
-
if (oldBranch !== null) {
|
289
|
-
removeAndDestroyBranch(oldBranch);
|
290
|
-
i--;
|
291
|
-
}
|
292
|
-
}
|
293
|
-
if (pos === WRONG_POS) {
|
294
|
-
const seq = longestIncreasingSubsequence(sources);
|
295
|
-
j = seq.length - 1;
|
296
|
-
k = newBranches.length;
|
297
|
-
for (i = newLength - 1; i >= 0; --i) {
|
298
|
-
if (sources[i] === -1) {
|
299
|
-
pos = i + newStart;
|
300
|
-
newBranch = newBranches[pos++];
|
301
|
-
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
302
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
303
|
-
} else {
|
304
|
-
if (j < 0 || i !== seq[j]) {
|
305
|
-
pos = i + newStart;
|
306
|
-
newBranch = newBranches[pos++];
|
307
|
-
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
308
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
309
|
-
} else {
|
310
|
-
--j;
|
311
|
-
}
|
312
|
-
}
|
313
|
-
}
|
314
|
-
} else if (synced !== newLength) {
|
315
|
-
k = newBranches.length;
|
316
|
-
for (i = newLength - 1; i >= 0; --i) {
|
317
|
-
if (sources[i] === -1) {
|
318
|
-
pos = i + newStart;
|
319
|
-
newBranch = newBranches[pos++];
|
320
|
-
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
321
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
322
|
-
}
|
323
|
-
}
|
324
|
-
}
|
325
|
-
}
|
326
|
-
}
|
327
|
-
}
|
328
|
-
function longestIncreasingSubsequence(a) {
|
329
|
-
const p = a.slice();
|
330
|
-
const result = [];
|
331
|
-
result.push(0);
|
332
|
-
let u;
|
333
|
-
let v;
|
334
|
-
for (let i = 0, il = a.length; i < il; ++i) {
|
335
|
-
if (a[i] === -1) {
|
336
|
-
continue;
|
337
|
-
}
|
338
|
-
const j = result[result.length - 1];
|
339
|
-
if (a[j] < a[i]) {
|
340
|
-
p[i] = j;
|
341
|
-
result.push(i);
|
342
|
-
continue;
|
343
|
-
}
|
344
|
-
u = 0;
|
345
|
-
v = result.length - 1;
|
346
|
-
while (u < v) {
|
347
|
-
const c = (u + v) / 2 | 0;
|
348
|
-
if (a[result[c]] < a[i]) {
|
349
|
-
u = c + 1;
|
350
|
-
} else {
|
351
|
-
v = c;
|
352
|
-
}
|
353
|
-
}
|
354
|
-
if (a[i] < a[result[u]]) {
|
355
|
-
if (u > 0) {
|
356
|
-
p[i] = result[u - 1];
|
357
|
-
}
|
358
|
-
result[u] = i;
|
359
|
-
}
|
360
|
-
}
|
361
|
-
u = result.length;
|
362
|
-
v = result[u - 1];
|
363
|
-
while (u-- > 0) {
|
364
|
-
result[u] = v;
|
365
|
-
v = p[v];
|
366
|
-
}
|
367
|
-
return result;
|
368
|
-
}
|
369
|
-
|
370
145
|
// src/dom/event.ts
|
371
146
|
var elementHandlersByEvent = /* @__PURE__ */ new Map();
|
372
147
|
var defaultDelegator = createDelegator();
|
@@ -395,7 +170,7 @@ function createDelegator() {
|
|
395
170
|
};
|
396
171
|
}
|
397
172
|
function handleDelegated(ev) {
|
398
|
-
let target = ev.target;
|
173
|
+
let target = !rendering && ev.target;
|
399
174
|
if (target) {
|
400
175
|
const handlersByElement = elementHandlersByEvent.get(ev.type);
|
401
176
|
handlersByElement.get(target)?.(ev, target);
|
@@ -468,15 +243,20 @@ var Render = class {
|
|
468
243
|
const commentPrefix = data2.i;
|
469
244
|
const commentPrefixLen = commentPrefix.length;
|
470
245
|
const closestBranchMarkers = /* @__PURE__ */ new Map();
|
246
|
+
const visitNodes = new Set(visits);
|
247
|
+
let lastEndNode;
|
471
248
|
data2.v = [];
|
472
|
-
const branchEnd = (branchId, visit,
|
249
|
+
const branchEnd = (branchId, visit, reference) => {
|
473
250
|
const branch = scopeLookup[branchId] ||= {};
|
474
|
-
let endNode =
|
475
|
-
while ((endNode = endNode.previousSibling)
|
476
|
-
|
251
|
+
let endNode = reference;
|
252
|
+
while (visitNodes.has(endNode = endNode.previousSibling)) ;
|
253
|
+
if (endNode === lastEndNode) {
|
254
|
+
endNode = reference.parentNode.insertBefore(new Text(), reference);
|
255
|
+
}
|
256
|
+
branch.___endNode = lastEndNode = endNode;
|
477
257
|
branch.___startNode ||= endNode;
|
478
258
|
for (const [markerScopeId, markerNode] of closestBranchMarkers) {
|
479
|
-
if (branch.___startNode.compareDocumentPosition(markerNode) & 4 &&
|
259
|
+
if (branch.___startNode.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2) {
|
480
260
|
parentBranchIds.set(markerScopeId, branchId);
|
481
261
|
closestBranchMarkers.delete(markerScopeId);
|
482
262
|
}
|
@@ -922,7 +702,6 @@ function toValueProp(it) {
|
|
922
702
|
}
|
923
703
|
|
924
704
|
// src/dom/parse-html.ts
|
925
|
-
var fallback = /* @__PURE__ */ new Text();
|
926
705
|
var parser = /* @__PURE__ */ document.createElement("template");
|
927
706
|
function parseHTML(html2) {
|
928
707
|
parser.innerHTML = html2;
|
@@ -941,7 +720,7 @@ function parseHTMLOrSingleNode(html2) {
|
|
941
720
|
fragment.appendChild(content);
|
942
721
|
return fragment;
|
943
722
|
}
|
944
|
-
return
|
723
|
+
return new Text();
|
945
724
|
}
|
946
725
|
|
947
726
|
// src/dom/dom.ts
|
@@ -1115,21 +894,17 @@ function attrsEvents(scope, nodeAccessor) {
|
|
1115
894
|
on(el, name, events[name]);
|
1116
895
|
}
|
1117
896
|
}
|
1118
|
-
function html(scope, value2,
|
1119
|
-
const firstChild = scope[
|
1120
|
-
const lastChild = scope[
|
1121
|
-
const
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
scope[
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
const next = current.nextSibling;
|
1130
|
-
current.remove();
|
1131
|
-
current = next;
|
1132
|
-
}
|
897
|
+
function html(scope, value2, accessor) {
|
898
|
+
const firstChild = scope[accessor];
|
899
|
+
const lastChild = scope[accessor + "-" /* DynamicPlaceholderLastChild */] || firstChild;
|
900
|
+
const newContent = parseHTML(
|
901
|
+
value2 || value2 === 0 ? value2 + "" : "<!>"
|
902
|
+
// TODO: is the comment needed
|
903
|
+
);
|
904
|
+
scope[accessor] = newContent.firstChild;
|
905
|
+
scope[accessor + "-" /* DynamicPlaceholderLastChild */] = newContent.lastChild;
|
906
|
+
firstChild.parentNode.insertBefore(newContent, firstChild);
|
907
|
+
removeChildNodes(firstChild, lastChild);
|
1133
908
|
}
|
1134
909
|
function props(scope, nodeIndex, index) {
|
1135
910
|
const nextProps = scope[index];
|
@@ -1169,6 +944,234 @@ function lifecycle(scope, index, thisObj) {
|
|
1169
944
|
).onabort = () => thisObj.onDestroy?.();
|
1170
945
|
}
|
1171
946
|
}
|
947
|
+
function removeChildNodes(startNode, endNode) {
|
948
|
+
const stop = endNode.nextSibling;
|
949
|
+
let current = startNode;
|
950
|
+
while (current !== stop) {
|
951
|
+
const next = current.nextSibling;
|
952
|
+
current.remove();
|
953
|
+
current = next;
|
954
|
+
}
|
955
|
+
}
|
956
|
+
|
957
|
+
// src/dom/scope.ts
|
958
|
+
var pendingScopes = [];
|
959
|
+
var debugID = 0;
|
960
|
+
function createScope($global) {
|
961
|
+
const scope = {
|
962
|
+
___pending: 1,
|
963
|
+
$global
|
964
|
+
};
|
965
|
+
if (true) {
|
966
|
+
scope.___debugId = "client-" + debugID++;
|
967
|
+
}
|
968
|
+
pendingScopes.push(scope);
|
969
|
+
return scope;
|
970
|
+
}
|
971
|
+
function finishPendingScopes() {
|
972
|
+
for (const scope of pendingScopes) {
|
973
|
+
scope.___pending = 0;
|
974
|
+
}
|
975
|
+
pendingScopes = [];
|
976
|
+
}
|
977
|
+
var emptyBranch = createScope({});
|
978
|
+
function getEmptyBranch(marker) {
|
979
|
+
emptyBranch.___startNode = emptyBranch.___endNode = marker;
|
980
|
+
return emptyBranch;
|
981
|
+
}
|
982
|
+
function destroyBranch(branch) {
|
983
|
+
branch.___parentBranch?.___branchScopes?.delete(branch);
|
984
|
+
destroyNestedBranches(branch);
|
985
|
+
}
|
986
|
+
function destroyNestedBranches(branch) {
|
987
|
+
branch.___destroyed = 1;
|
988
|
+
branch.___branchScopes?.forEach(destroyNestedBranches);
|
989
|
+
branch.___abortScopes?.forEach((scope) => {
|
990
|
+
for (const id in scope.___abortControllers) {
|
991
|
+
scope.___abortControllers[id]?.abort();
|
992
|
+
}
|
993
|
+
});
|
994
|
+
}
|
995
|
+
function removeAndDestroyBranch(branch) {
|
996
|
+
destroyBranch(branch);
|
997
|
+
removeChildNodes(branch.___startNode, branch.___endNode);
|
998
|
+
}
|
999
|
+
function insertBranchBefore(branch, parentNode, nextSibling) {
|
1000
|
+
let current = branch.___startNode;
|
1001
|
+
const stop = branch.___endNode.nextSibling;
|
1002
|
+
while (current !== stop) {
|
1003
|
+
const next = current.nextSibling;
|
1004
|
+
parentNode.insertBefore(current, nextSibling);
|
1005
|
+
current = next;
|
1006
|
+
}
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
// src/dom/reconcile.ts
|
1010
|
+
var WRONG_POS = 2147483647;
|
1011
|
+
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
1012
|
+
let oldStart = 0;
|
1013
|
+
let newStart = 0;
|
1014
|
+
let oldEnd = oldBranches.length - 1;
|
1015
|
+
let newEnd = newBranches.length - 1;
|
1016
|
+
let oldStartBranch = oldBranches[oldStart];
|
1017
|
+
let newStartBranch = newBranches[newStart];
|
1018
|
+
let oldEndBranch = oldBranches[oldEnd];
|
1019
|
+
let newEndBranch = newBranches[newEnd];
|
1020
|
+
let i;
|
1021
|
+
let j;
|
1022
|
+
let k;
|
1023
|
+
let nextSibling;
|
1024
|
+
let oldBranch;
|
1025
|
+
let newBranch;
|
1026
|
+
outer: {
|
1027
|
+
while (oldStartBranch === newStartBranch) {
|
1028
|
+
++oldStart;
|
1029
|
+
++newStart;
|
1030
|
+
if (oldStart > oldEnd || newStart > newEnd) {
|
1031
|
+
break outer;
|
1032
|
+
}
|
1033
|
+
oldStartBranch = oldBranches[oldStart];
|
1034
|
+
newStartBranch = newBranches[newStart];
|
1035
|
+
}
|
1036
|
+
while (oldEndBranch === newEndBranch) {
|
1037
|
+
--oldEnd;
|
1038
|
+
--newEnd;
|
1039
|
+
if (oldStart > oldEnd || newStart > newEnd) {
|
1040
|
+
break outer;
|
1041
|
+
}
|
1042
|
+
oldEndBranch = oldBranches[oldEnd];
|
1043
|
+
newEndBranch = newBranches[newEnd];
|
1044
|
+
}
|
1045
|
+
}
|
1046
|
+
if (oldStart > oldEnd) {
|
1047
|
+
if (newStart <= newEnd) {
|
1048
|
+
k = newEnd + 1;
|
1049
|
+
nextSibling = k < newBranches.length ? newBranches[k].___startNode : afterReference;
|
1050
|
+
do {
|
1051
|
+
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
1052
|
+
} while (newStart <= newEnd);
|
1053
|
+
}
|
1054
|
+
} else if (newStart > newEnd) {
|
1055
|
+
do {
|
1056
|
+
removeAndDestroyBranch(oldBranches[oldStart++]);
|
1057
|
+
} while (oldStart <= oldEnd);
|
1058
|
+
} else {
|
1059
|
+
const oldLength = oldEnd - oldStart + 1;
|
1060
|
+
const newLength = newEnd - newStart + 1;
|
1061
|
+
const aNullable = oldBranches;
|
1062
|
+
const sources = new Array(newLength);
|
1063
|
+
for (i = 0; i < newLength; ++i) {
|
1064
|
+
sources[i] = -1;
|
1065
|
+
}
|
1066
|
+
let pos = 0;
|
1067
|
+
let synced = 0;
|
1068
|
+
const keyIndex = /* @__PURE__ */ new Map();
|
1069
|
+
for (j = newStart; j <= newEnd; ++j) {
|
1070
|
+
keyIndex.set(newBranches[j], j);
|
1071
|
+
}
|
1072
|
+
for (i = oldStart; i <= oldEnd && synced < newLength; ++i) {
|
1073
|
+
oldBranch = oldBranches[i];
|
1074
|
+
j = keyIndex.get(oldBranch);
|
1075
|
+
if (j !== void 0) {
|
1076
|
+
pos = pos > j ? WRONG_POS : j;
|
1077
|
+
++synced;
|
1078
|
+
newBranch = newBranches[j];
|
1079
|
+
sources[j - newStart] = i;
|
1080
|
+
aNullable[i] = null;
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
if (oldLength === oldBranches.length && synced === 0) {
|
1084
|
+
for (; newStart < newLength; ++newStart) {
|
1085
|
+
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
1086
|
+
}
|
1087
|
+
for (; oldStart < oldLength; ++oldStart) {
|
1088
|
+
removeAndDestroyBranch(oldBranches[oldStart]);
|
1089
|
+
}
|
1090
|
+
} else {
|
1091
|
+
i = oldLength - synced;
|
1092
|
+
while (i > 0) {
|
1093
|
+
oldBranch = aNullable[oldStart++];
|
1094
|
+
if (oldBranch !== null) {
|
1095
|
+
removeAndDestroyBranch(oldBranch);
|
1096
|
+
i--;
|
1097
|
+
}
|
1098
|
+
}
|
1099
|
+
if (pos === WRONG_POS) {
|
1100
|
+
const seq = longestIncreasingSubsequence(sources);
|
1101
|
+
j = seq.length - 1;
|
1102
|
+
k = newBranches.length;
|
1103
|
+
for (i = newLength - 1; i >= 0; --i) {
|
1104
|
+
if (sources[i] === -1) {
|
1105
|
+
pos = i + newStart;
|
1106
|
+
newBranch = newBranches[pos++];
|
1107
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1108
|
+
insertBranchBefore(newBranch, parent, nextSibling);
|
1109
|
+
} else {
|
1110
|
+
if (j < 0 || i !== seq[j]) {
|
1111
|
+
pos = i + newStart;
|
1112
|
+
newBranch = newBranches[pos++];
|
1113
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1114
|
+
insertBranchBefore(newBranch, parent, nextSibling);
|
1115
|
+
} else {
|
1116
|
+
--j;
|
1117
|
+
}
|
1118
|
+
}
|
1119
|
+
}
|
1120
|
+
} else if (synced !== newLength) {
|
1121
|
+
k = newBranches.length;
|
1122
|
+
for (i = newLength - 1; i >= 0; --i) {
|
1123
|
+
if (sources[i] === -1) {
|
1124
|
+
pos = i + newStart;
|
1125
|
+
newBranch = newBranches[pos++];
|
1126
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
1127
|
+
insertBranchBefore(newBranch, parent, nextSibling);
|
1128
|
+
}
|
1129
|
+
}
|
1130
|
+
}
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
}
|
1134
|
+
function longestIncreasingSubsequence(a) {
|
1135
|
+
const p = a.slice();
|
1136
|
+
const result = [];
|
1137
|
+
result.push(0);
|
1138
|
+
let u;
|
1139
|
+
let v;
|
1140
|
+
for (let i = 0, il = a.length; i < il; ++i) {
|
1141
|
+
if (a[i] === -1) {
|
1142
|
+
continue;
|
1143
|
+
}
|
1144
|
+
const j = result[result.length - 1];
|
1145
|
+
if (a[j] < a[i]) {
|
1146
|
+
p[i] = j;
|
1147
|
+
result.push(i);
|
1148
|
+
continue;
|
1149
|
+
}
|
1150
|
+
u = 0;
|
1151
|
+
v = result.length - 1;
|
1152
|
+
while (u < v) {
|
1153
|
+
const c = (u + v) / 2 | 0;
|
1154
|
+
if (a[result[c]] < a[i]) {
|
1155
|
+
u = c + 1;
|
1156
|
+
} else {
|
1157
|
+
v = c;
|
1158
|
+
}
|
1159
|
+
}
|
1160
|
+
if (a[i] < a[result[u]]) {
|
1161
|
+
if (u > 0) {
|
1162
|
+
p[i] = result[u - 1];
|
1163
|
+
}
|
1164
|
+
result[u] = i;
|
1165
|
+
}
|
1166
|
+
}
|
1167
|
+
u = result.length;
|
1168
|
+
v = result[u - 1];
|
1169
|
+
while (u-- > 0) {
|
1170
|
+
result[u] = v;
|
1171
|
+
v = p[v];
|
1172
|
+
}
|
1173
|
+
return result;
|
1174
|
+
}
|
1172
1175
|
|
1173
1176
|
// src/dom/walker.ts
|
1174
1177
|
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
@@ -1177,9 +1180,9 @@ function trimWalkString(walkString) {
|
|
1177
1180
|
while (walkString.charCodeAt(--end) > 47 /* BeginChild */) ;
|
1178
1181
|
return walkString.slice(0, end + 1);
|
1179
1182
|
}
|
1180
|
-
function walk(startNode, walkCodes,
|
1183
|
+
function walk(startNode, walkCodes, branch) {
|
1181
1184
|
walker.currentNode = startNode;
|
1182
|
-
walkInternal(walkCodes,
|
1185
|
+
walkInternal(walkCodes, branch, 0);
|
1183
1186
|
walker.currentNode = document;
|
1184
1187
|
}
|
1185
1188
|
function walkInternal(walkCodes, scope, currentWalkIndex) {
|
@@ -1210,7 +1213,6 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
|
|
1210
1213
|
}
|
1211
1214
|
} else if (value2 === 47 /* BeginChild */) {
|
1212
1215
|
const childScope = scope[true ? getDebugKey(currentScopeIndex++, "#childScope") : currentScopeIndex++] = createScope(scope.$global);
|
1213
|
-
childScope.___startNode = walker.currentNode;
|
1214
1216
|
childScope.___closestBranch = scope.___closestBranch;
|
1215
1217
|
currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
|
1216
1218
|
} else if (value2 === 38 /* EndChild */) {
|
@@ -1389,8 +1391,8 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
|
1389
1391
|
const newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : getEmptyBranch(scope[nodeAccessor]);
|
1390
1392
|
insertBranchBefore(
|
1391
1393
|
newBranch,
|
1392
|
-
prevBranch.
|
1393
|
-
prevBranch.
|
1394
|
+
prevBranch.___endNode.parentNode,
|
1395
|
+
prevBranch.___endNode.nextSibling
|
1394
1396
|
);
|
1395
1397
|
removeAndDestroyBranch(prevBranch);
|
1396
1398
|
scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
@@ -1856,13 +1858,13 @@ var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
|
1856
1858
|
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
1857
1859
|
|
1858
1860
|
// src/dom/compat.ts
|
1859
|
-
var
|
1861
|
+
var classIdToBranch = /* @__PURE__ */ new Map();
|
1860
1862
|
var compat = {
|
1861
1863
|
patchConditionals,
|
1862
1864
|
queueEffect,
|
1863
1865
|
init() {
|
1864
|
-
register(SET_SCOPE_REGISTER_ID, (
|
1865
|
-
|
1866
|
+
register(SET_SCOPE_REGISTER_ID, (branch) => {
|
1867
|
+
classIdToBranch.set(branch.m5c, branch);
|
1866
1868
|
});
|
1867
1869
|
},
|
1868
1870
|
registerRenderer(fn) {
|
@@ -1874,12 +1876,12 @@ var compat = {
|
|
1874
1876
|
isRenderer(renderer) {
|
1875
1877
|
return renderer.___clone !== void 0;
|
1876
1878
|
},
|
1877
|
-
getStartNode(
|
1878
|
-
return
|
1879
|
+
getStartNode(branch) {
|
1880
|
+
return branch.___startNode;
|
1879
1881
|
},
|
1880
|
-
setScopeNodes(
|
1881
|
-
|
1882
|
-
|
1882
|
+
setScopeNodes(branch, startNode, endNode) {
|
1883
|
+
branch.___startNode = startNode;
|
1884
|
+
branch.___endNode = endNode;
|
1883
1885
|
},
|
1884
1886
|
runComponentEffects() {
|
1885
1887
|
runEffects(this.effects);
|
@@ -1907,12 +1909,12 @@ var compat = {
|
|
1907
1909
|
return renderer;
|
1908
1910
|
},
|
1909
1911
|
render(out, component, renderer, args) {
|
1910
|
-
let
|
1911
|
-
if (!
|
1912
|
-
|
1913
|
-
if (
|
1914
|
-
component.scope =
|
1915
|
-
|
1912
|
+
let branch = component.scope;
|
1913
|
+
if (!branch) {
|
1914
|
+
branch = classIdToBranch.get(component.id);
|
1915
|
+
if (branch) {
|
1916
|
+
component.scope = branch;
|
1917
|
+
classIdToBranch.delete(component.id);
|
1916
1918
|
}
|
1917
1919
|
}
|
1918
1920
|
const applyArgs = renderer.___args || noop;
|
@@ -1925,18 +1927,18 @@ var compat = {
|
|
1925
1927
|
}
|
1926
1928
|
}
|
1927
1929
|
component.effects = prepareEffects(() => {
|
1928
|
-
if (!
|
1929
|
-
|
1930
|
-
|
1931
|
-
initBranch(renderer,
|
1930
|
+
if (!branch) {
|
1931
|
+
branch = component.scope = createScope(out.global);
|
1932
|
+
branch._ = renderer.___owner;
|
1933
|
+
initBranch(renderer, branch);
|
1932
1934
|
} else {
|
1933
|
-
applyArgs(
|
1935
|
+
applyArgs(branch, MARK);
|
1934
1936
|
existing = true;
|
1935
1937
|
}
|
1936
|
-
applyArgs(
|
1938
|
+
applyArgs(branch, args);
|
1937
1939
|
});
|
1938
1940
|
if (!existing) {
|
1939
|
-
return
|
1941
|
+
return branch.___startNode === branch.___endNode ? branch.___startNode : branch.___startNode.parentNode;
|
1940
1942
|
}
|
1941
1943
|
}
|
1942
1944
|
};
|
package/dist/dom/compat.d.ts
CHANGED
@@ -8,8 +8,8 @@ export declare const compat: {
|
|
8
8
|
registerRenderer(fn: any): void;
|
9
9
|
isOp(value: any): boolean;
|
10
10
|
isRenderer(renderer: any): boolean;
|
11
|
-
getStartNode(
|
12
|
-
setScopeNodes(
|
11
|
+
getStartNode(branch: any): any;
|
12
|
+
setScopeNodes(branch: any, startNode: Node, endNode: Node): void;
|
13
13
|
runComponentEffects(this: any): void;
|
14
14
|
runComponentDestroy(this: any): void;
|
15
15
|
resolveRegistered(value: any, { runtimeId, componentIdPrefix, }: {
|
@@ -17,5 +17,5 @@ export declare const compat: {
|
|
17
17
|
componentIdPrefix: string;
|
18
18
|
}): any;
|
19
19
|
createRenderer(setup: Renderer["___setup"], clone: Renderer["___clone"], args: Renderer["___args"]): Renderer;
|
20
|
-
render(out: any, component: any, renderer: Renderer, args: any):
|
20
|
+
render(out: any, component: any, renderer: Renderer, args: any): ChildNode | ParentNode | null | undefined;
|
21
21
|
};
|
package/dist/dom/dom.d.ts
CHANGED
@@ -9,7 +9,7 @@ export declare function textContent(node: ParentNode, value: unknown): void;
|
|
9
9
|
export declare function attrs(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>): void;
|
10
10
|
export declare function partialAttrs(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, skip: Record<string, 1>): void;
|
11
11
|
export declare function attrsEvents(scope: Scope, nodeAccessor: Accessor): void;
|
12
|
-
export declare function html(scope: Scope, value: unknown,
|
12
|
+
export declare function html(scope: Scope, value: unknown, accessor: Accessor): void;
|
13
13
|
export declare function props(scope: Scope, nodeIndex: number, index: number): void;
|
14
14
|
export declare function normalizeAttrValue(value: unknown): string | undefined;
|
15
15
|
export declare function lifecycle(scope: Scope, index: string | number, thisObj: Record<string, unknown> & {
|
@@ -17,3 +17,4 @@ export declare function lifecycle(scope: Scope, index: string | number, thisObj:
|
|
17
17
|
onUpdate?: (this: unknown) => void;
|
18
18
|
onDestroy?: (this: unknown) => void;
|
19
19
|
}): void;
|
20
|
+
export declare function removeChildNodes(startNode: ChildNode, endNode: ChildNode): void;
|
package/dist/dom/reconcile.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
import type { BranchScope } from "../common/types";
|
2
|
-
export declare function reconcile(parent:
|
2
|
+
export declare function reconcile(parent: ParentNode, oldBranches: BranchScope[], newBranches: BranchScope[], afterReference: Node | null): void;
|