@lark.js/mvc 0.0.11 → 0.0.12
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/devtool.cjs +272 -257
- package/dist/devtool.js +273 -258
- package/dist/index.cjs +278 -269
- package/dist/index.d.cts +61 -2
- package/dist/index.d.ts +61 -2
- package/dist/index.js +277 -269
- package/dist/rspack.cjs +8 -4
- package/dist/rspack.js +8 -4
- package/dist/runtime.js +1 -1
- package/dist/vite.cjs +51 -5
- package/dist/vite.d.cts +7 -1
- package/dist/vite.d.ts +7 -1
- package/dist/vite.js +53 -4
- package/dist/webpack.cjs +8 -4
- package/dist/webpack.js +8 -4
- package/package.json +1 -1
- package/src/client.d.ts +8 -0
- /package/dist/{chunk-RIV4NK3K.js → chunk-66OZBBSP.js} +0 -0
package/dist/devtool.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
nextCounter,
|
|
22
22
|
refFn,
|
|
23
23
|
strSafe
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-66OZBBSP.js";
|
|
25
25
|
|
|
26
26
|
// src/utils.ts
|
|
27
27
|
var CALL_BREAK_TIME = 9;
|
|
@@ -1070,18 +1070,6 @@ var DOM_SPECIALS = {
|
|
|
1070
1070
|
function isSameVDomNode(a, b) {
|
|
1071
1071
|
return a.compareKey && b.compareKey === a.compareKey || !a.compareKey && !b.compareKey && a.tag === b.tag || a.tag === SPLITTER || b.tag === SPLITTER;
|
|
1072
1072
|
}
|
|
1073
|
-
function getKeyNodes(list, nodes, start, end, realEnd) {
|
|
1074
|
-
const keyedNodes = {};
|
|
1075
|
-
for (let i = end, re = realEnd; i >= start; i--, re--) {
|
|
1076
|
-
const oc = list[i];
|
|
1077
|
-
const cKey = oc.compareKey;
|
|
1078
|
-
if (cKey) {
|
|
1079
|
-
const bucket = keyedNodes[cKey] || (keyedNodes[cKey] = []);
|
|
1080
|
-
bucket.push(nodes[re]);
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
return keyedNodes;
|
|
1084
|
-
}
|
|
1085
1073
|
function vdomCreateNode(vnode, owner, ref) {
|
|
1086
1074
|
const tag = vnode.tag;
|
|
1087
1075
|
if (tag === V_TEXT_NODE) {
|
|
@@ -1170,9 +1158,10 @@ function vdomSetNode(realNode, oldParent, lastVDom, newVDom, ref, frame, keys, r
|
|
|
1170
1158
|
return;
|
|
1171
1159
|
}
|
|
1172
1160
|
if (lastTag === newTag) {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1161
|
+
if (lastVDom.attrs === newVDom.attrs && lastVDom.html === newVDom.html) {
|
|
1162
|
+
if (newVDom.hasSpecials) {
|
|
1163
|
+
vdomSyncFormState(realNode, newVDom);
|
|
1164
|
+
}
|
|
1176
1165
|
return;
|
|
1177
1166
|
}
|
|
1178
1167
|
let attrChanged = 0;
|
|
@@ -1213,261 +1202,209 @@ function vdomSetNode(realNode, oldParent, lastVDom, newVDom, ref, frame, keys, r
|
|
|
1213
1202
|
oldParent.replaceChild(vdomCreateNode(newVDom, oldParent, ref), realNode);
|
|
1214
1203
|
}
|
|
1215
1204
|
}
|
|
1205
|
+
function computeLIS(sequence) {
|
|
1206
|
+
const len = sequence.length;
|
|
1207
|
+
if (len === 0) return [];
|
|
1208
|
+
const result = [];
|
|
1209
|
+
const tails = [];
|
|
1210
|
+
const predecessors = new Array(len);
|
|
1211
|
+
let lisLength = 0;
|
|
1212
|
+
for (let i = 0; i < len; i++) {
|
|
1213
|
+
const value = sequence[i];
|
|
1214
|
+
if (value < 0) continue;
|
|
1215
|
+
let lo = 0;
|
|
1216
|
+
let hi = lisLength;
|
|
1217
|
+
while (lo < hi) {
|
|
1218
|
+
const mid = lo + hi >>> 1;
|
|
1219
|
+
if (sequence[tails[mid]] < value) lo = mid + 1;
|
|
1220
|
+
else hi = mid;
|
|
1221
|
+
}
|
|
1222
|
+
tails[lo] = i;
|
|
1223
|
+
predecessors[i] = lo > 0 ? tails[lo - 1] : -1;
|
|
1224
|
+
if (lo === lisLength) lisLength++;
|
|
1225
|
+
}
|
|
1226
|
+
let cursor = tails[lisLength - 1];
|
|
1227
|
+
for (let i = lisLength - 1; i >= 0; i--) {
|
|
1228
|
+
result[i] = cursor;
|
|
1229
|
+
cursor = predecessors[cursor];
|
|
1230
|
+
}
|
|
1231
|
+
return result;
|
|
1232
|
+
}
|
|
1216
1233
|
function vdomSetChildNodes(realNode, lastVDom, newVDom, ref, frame, keys, view, ready) {
|
|
1217
1234
|
if (!lastVDom) {
|
|
1218
1235
|
ref.changed = 1;
|
|
1219
1236
|
realNode.innerHTML = newVDom.html;
|
|
1237
|
+
callFunction(ready, []);
|
|
1220
1238
|
return;
|
|
1221
1239
|
}
|
|
1222
1240
|
if (lastVDom.html === newVDom.html) {
|
|
1241
|
+
callFunction(ready, []);
|
|
1223
1242
|
return;
|
|
1224
1243
|
}
|
|
1225
1244
|
const oldChildren = lastVDom.children;
|
|
1226
1245
|
const newChildren = newVDom.children;
|
|
1227
1246
|
const oldLen = oldChildren?.length || 0;
|
|
1228
1247
|
const newLen = newChildren?.length || 0;
|
|
1229
|
-
if (oldLen === 0 && newLen === 0)
|
|
1248
|
+
if (oldLen === 0 && newLen === 0) {
|
|
1249
|
+
callFunction(ready, []);
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1230
1252
|
const nodes = realNode.childNodes;
|
|
1231
|
-
|
|
1232
|
-
let
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
let
|
|
1237
|
-
let
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
realEnd--;
|
|
1305
|
-
oldEndNode = oldChildren?.[--oldEnd];
|
|
1306
|
-
newEndNode = newChildren?.[--newEnd];
|
|
1307
|
-
} else if (isSameVDomNode(newEndNode, oldStartNode)) {
|
|
1308
|
-
if (newEndNode.tag === SPLITTER || oldStartNode.tag === SPLITTER) {
|
|
1309
|
-
ref.changed = 1;
|
|
1310
|
-
domUnmountFrames(frame, realNode);
|
|
1311
|
-
realNode.innerHTML = newEndNode.tag === SPLITTER ? newEndNode.html : "";
|
|
1312
|
-
if (newEndNode.tag !== SPLITTER) {
|
|
1313
|
-
realNode.appendChild(vdomCreateNode(newEndNode, realNode, ref));
|
|
1314
|
-
}
|
|
1315
|
-
} else {
|
|
1316
|
-
const oi = nodes[realStart];
|
|
1317
|
-
realNode.insertBefore(oi, nodes[realEnd + 1] || null);
|
|
1318
|
-
vdomSetNode(
|
|
1319
|
-
oi,
|
|
1320
|
-
realNode,
|
|
1321
|
-
oldStartNode,
|
|
1322
|
-
newEndNode,
|
|
1323
|
-
ref,
|
|
1324
|
-
frame,
|
|
1325
|
-
keys,
|
|
1326
|
-
view,
|
|
1327
|
-
ready
|
|
1328
|
-
);
|
|
1329
|
-
}
|
|
1330
|
-
reduceCached(keyedNodes, oldStartNode, nodes[realStart]);
|
|
1331
|
-
realStart++;
|
|
1332
|
-
oldStartNode = oldChildren?.[++oldStart];
|
|
1333
|
-
newEndNode = newChildren?.[--newEnd];
|
|
1334
|
-
} else if (isSameVDomNode(newStartNode, oldEndNode)) {
|
|
1335
|
-
if (newStartNode.tag === SPLITTER || oldEndNode.tag === SPLITTER) {
|
|
1336
|
-
ref.changed = 1;
|
|
1337
|
-
domUnmountFrames(frame, realNode);
|
|
1338
|
-
realNode.innerHTML = newStartNode.tag === SPLITTER ? newStartNode.html : "";
|
|
1339
|
-
if (newStartNode.tag !== SPLITTER) {
|
|
1340
|
-
realNode.appendChild(vdomCreateNode(newStartNode, realNode, ref));
|
|
1341
|
-
}
|
|
1342
|
-
} else {
|
|
1343
|
-
const oi = nodes[realEnd];
|
|
1344
|
-
realNode.insertBefore(oi, nodes[realStart]);
|
|
1345
|
-
vdomSetNode(
|
|
1346
|
-
oi,
|
|
1347
|
-
realNode,
|
|
1348
|
-
oldEndNode,
|
|
1349
|
-
newStartNode,
|
|
1350
|
-
ref,
|
|
1351
|
-
frame,
|
|
1352
|
-
keys,
|
|
1353
|
-
view,
|
|
1354
|
-
ready
|
|
1355
|
-
);
|
|
1356
|
-
}
|
|
1357
|
-
reduceCached(keyedNodes, oldEndNode, nodes[realEnd]);
|
|
1358
|
-
realEnd--;
|
|
1359
|
-
oldEndNode = oldChildren?.[--oldEnd];
|
|
1360
|
-
newStartNode = newChildren?.[++newStart];
|
|
1253
|
+
const oldDomNodes = new Array(oldLen);
|
|
1254
|
+
for (let i = 0; i < oldLen; i++) {
|
|
1255
|
+
oldDomNodes[i] = nodes[i];
|
|
1256
|
+
}
|
|
1257
|
+
const usedOldDomNodes = /* @__PURE__ */ new Set();
|
|
1258
|
+
let headIdx = 0;
|
|
1259
|
+
let tailIdx = oldLen - 1;
|
|
1260
|
+
let newHead = 0;
|
|
1261
|
+
let newTail = newLen - 1;
|
|
1262
|
+
while (headIdx <= tailIdx && newHead <= newTail) {
|
|
1263
|
+
const oc = oldChildren[headIdx];
|
|
1264
|
+
const nc = newChildren[newHead];
|
|
1265
|
+
if (!isSameVDomNode(nc, oc)) break;
|
|
1266
|
+
if (nc.tag === SPLITTER || oc.tag === SPLITTER) break;
|
|
1267
|
+
vdomSetNode(
|
|
1268
|
+
oldDomNodes[headIdx],
|
|
1269
|
+
realNode,
|
|
1270
|
+
oc,
|
|
1271
|
+
nc,
|
|
1272
|
+
ref,
|
|
1273
|
+
frame,
|
|
1274
|
+
keys,
|
|
1275
|
+
view,
|
|
1276
|
+
ready
|
|
1277
|
+
);
|
|
1278
|
+
usedOldDomNodes.add(oldDomNodes[headIdx]);
|
|
1279
|
+
headIdx++;
|
|
1280
|
+
newHead++;
|
|
1281
|
+
}
|
|
1282
|
+
while (headIdx <= tailIdx && newHead <= newTail) {
|
|
1283
|
+
const oc = oldChildren[tailIdx];
|
|
1284
|
+
const nc = newChildren[newTail];
|
|
1285
|
+
if (!isSameVDomNode(nc, oc)) break;
|
|
1286
|
+
if (nc.tag === SPLITTER || oc.tag === SPLITTER) break;
|
|
1287
|
+
vdomSetNode(
|
|
1288
|
+
oldDomNodes[tailIdx],
|
|
1289
|
+
realNode,
|
|
1290
|
+
oc,
|
|
1291
|
+
nc,
|
|
1292
|
+
ref,
|
|
1293
|
+
frame,
|
|
1294
|
+
keys,
|
|
1295
|
+
view,
|
|
1296
|
+
ready
|
|
1297
|
+
);
|
|
1298
|
+
usedOldDomNodes.add(oldDomNodes[tailIdx]);
|
|
1299
|
+
tailIdx--;
|
|
1300
|
+
newTail--;
|
|
1301
|
+
}
|
|
1302
|
+
if (headIdx > tailIdx && newHead > newTail) {
|
|
1303
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
const keyMap = {};
|
|
1307
|
+
for (let i = headIdx; i <= tailIdx; i++) {
|
|
1308
|
+
const c = oldChildren[i];
|
|
1309
|
+
if (c?.compareKey) {
|
|
1310
|
+
if (!keyMap[c.compareKey]) keyMap[c.compareKey] = [];
|
|
1311
|
+
keyMap[c.compareKey].push({ domNode: oldDomNodes[i], vdomNode: c });
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
const newRemaining = newTail - newHead + 1;
|
|
1315
|
+
const sequence = new Array(newRemaining);
|
|
1316
|
+
for (let i = 0; i < newRemaining; i++) {
|
|
1317
|
+
const nc = newChildren[newHead + i];
|
|
1318
|
+
const cKey = nc.compareKey;
|
|
1319
|
+
const entries = cKey ? keyMap[cKey] : void 0;
|
|
1320
|
+
if (entries && entries.length > 0) {
|
|
1321
|
+
const entry = entries.shift();
|
|
1322
|
+
if (entries.length === 0) delete keyMap[cKey];
|
|
1323
|
+
const oldIdx = oldChildren.indexOf(entry.vdomNode, headIdx);
|
|
1324
|
+
sequence[i] = oldIdx >= 0 ? oldIdx : -1;
|
|
1325
|
+
usedOldDomNodes.add(entry.domNode);
|
|
1361
1326
|
} else {
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
);
|
|
1370
|
-
}
|
|
1371
|
-
const cKey = newStartNode.compareKey;
|
|
1372
|
-
let found;
|
|
1373
|
-
let compareKey;
|
|
1374
|
-
if (cKey && keyedNodes) {
|
|
1375
|
-
found = keyedNodes[cKey];
|
|
1376
|
-
compareKey = void 0;
|
|
1377
|
-
while (found && found.length > 0) {
|
|
1378
|
-
compareKey = found.pop();
|
|
1379
|
-
if (compareKey) break;
|
|
1380
|
-
}
|
|
1381
|
-
if (found && found.length === 0) delete keyedNodes[cKey];
|
|
1382
|
-
}
|
|
1383
|
-
if (compareKey) {
|
|
1384
|
-
if (compareKey !== nodes[realStart]) {
|
|
1385
|
-
for (let j = oldStart + 1; j <= oldEnd; j++) {
|
|
1386
|
-
const oc = oldChildren?.[j];
|
|
1387
|
-
if (oc && nodes[realStart + (j - oldStart)] === compareKey) {
|
|
1388
|
-
oldChildren[j] = void 0;
|
|
1389
|
-
break;
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
realNode.insertBefore(compareKey, nodes[realStart]);
|
|
1393
|
-
}
|
|
1394
|
-
vdomSetNode(
|
|
1395
|
-
compareKey,
|
|
1396
|
-
realNode,
|
|
1397
|
-
oldStartNode,
|
|
1398
|
-
newStartNode,
|
|
1399
|
-
ref,
|
|
1400
|
-
frame,
|
|
1401
|
-
keys,
|
|
1402
|
-
view,
|
|
1403
|
-
ready
|
|
1404
|
-
);
|
|
1405
|
-
} else if (oldStartNode.compareKey && lastVDom.reused?.[oldStartNode.compareKey] && newVDom.reused?.[oldStartNode.compareKey] || nodes[realStart]?.id && realNode.querySelectorAll?.(
|
|
1406
|
-
`#${nodes[realStart].id}`
|
|
1407
|
-
)?.length && !newStartNode.isLarkView) {
|
|
1327
|
+
sequence[i] = -1;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
if (newHead > newTail) {
|
|
1331
|
+
for (let i = 0; i < oldLen; i++) {
|
|
1332
|
+
const domNode = oldDomNodes[i];
|
|
1333
|
+
if (domNode && !usedOldDomNodes.has(domNode) && domNode.parentNode === realNode) {
|
|
1334
|
+
domUnmountFrames(frame, domNode);
|
|
1408
1335
|
ref.changed = 1;
|
|
1409
|
-
|
|
1410
|
-
realNode.insertBefore(newNode, nodes[realStart]);
|
|
1411
|
-
realStart--;
|
|
1412
|
-
realEnd++;
|
|
1413
|
-
} else {
|
|
1414
|
-
vdomSetNode(
|
|
1415
|
-
nodes[realStart],
|
|
1416
|
-
realNode,
|
|
1417
|
-
oldStartNode,
|
|
1418
|
-
newStartNode,
|
|
1419
|
-
ref,
|
|
1420
|
-
frame,
|
|
1421
|
-
keys,
|
|
1422
|
-
view,
|
|
1423
|
-
ready
|
|
1424
|
-
);
|
|
1336
|
+
realNode.removeChild(domNode);
|
|
1425
1337
|
}
|
|
1426
|
-
realStart++;
|
|
1427
|
-
oldStartNode = oldChildren?.[++oldStart];
|
|
1428
|
-
newStartNode = newChildren?.[++newStart];
|
|
1429
1338
|
}
|
|
1339
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
1340
|
+
return;
|
|
1430
1341
|
}
|
|
1431
|
-
if (
|
|
1432
|
-
const
|
|
1433
|
-
for (let i =
|
|
1342
|
+
if (headIdx > tailIdx) {
|
|
1343
|
+
const insertRef = tailIdx < oldLen ? oldDomNodes[tailIdx + 1] ?? null : null;
|
|
1344
|
+
for (let i = newHead; i <= newTail; i++) {
|
|
1345
|
+
ref.changed = 1;
|
|
1346
|
+
const newNode = vdomCreateNode(newChildren[i], realNode, ref);
|
|
1347
|
+
realNode.insertBefore(newNode, insertRef);
|
|
1348
|
+
}
|
|
1349
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
const lis = computeLIS(sequence);
|
|
1353
|
+
let lisCursor = lis.length - 1;
|
|
1354
|
+
let nextNode = tailIdx + 1 < oldLen ? oldDomNodes[tailIdx + 1] : null;
|
|
1355
|
+
for (let j = newRemaining - 1; j >= 0; j--) {
|
|
1356
|
+
const newIdx = newHead + j;
|
|
1357
|
+
const nc = newChildren[newIdx];
|
|
1358
|
+
if (lisCursor >= 0 && lis[lisCursor] === j) {
|
|
1359
|
+
const oldIdx = sequence[j];
|
|
1360
|
+
vdomSetNode(
|
|
1361
|
+
oldDomNodes[oldIdx],
|
|
1362
|
+
realNode,
|
|
1363
|
+
oldChildren[oldIdx],
|
|
1364
|
+
nc,
|
|
1365
|
+
ref,
|
|
1366
|
+
frame,
|
|
1367
|
+
keys,
|
|
1368
|
+
view,
|
|
1369
|
+
ready
|
|
1370
|
+
);
|
|
1371
|
+
nextNode = oldDomNodes[oldIdx];
|
|
1372
|
+
lisCursor--;
|
|
1373
|
+
} else if (sequence[j] >= 0) {
|
|
1374
|
+
const oldIdx = sequence[j];
|
|
1375
|
+
ref.changed = 1;
|
|
1376
|
+
realNode.insertBefore(oldDomNodes[oldIdx], nextNode);
|
|
1377
|
+
vdomSetNode(
|
|
1378
|
+
oldDomNodes[oldIdx],
|
|
1379
|
+
realNode,
|
|
1380
|
+
oldChildren[oldIdx],
|
|
1381
|
+
nc,
|
|
1382
|
+
ref,
|
|
1383
|
+
frame,
|
|
1384
|
+
keys,
|
|
1385
|
+
view,
|
|
1386
|
+
ready
|
|
1387
|
+
);
|
|
1388
|
+
nextNode = oldDomNodes[oldIdx];
|
|
1389
|
+
} else {
|
|
1434
1390
|
ref.changed = 1;
|
|
1435
|
-
const nc = newChildren[i];
|
|
1436
|
-
if (nc.tag === SPLITTER) {
|
|
1437
|
-
domUnmountFrames(frame, realNode);
|
|
1438
|
-
realNode.innerHTML = nc.html;
|
|
1439
|
-
return;
|
|
1440
|
-
}
|
|
1441
1391
|
const newNode = vdomCreateNode(nc, realNode, ref);
|
|
1442
|
-
realNode.insertBefore(newNode,
|
|
1392
|
+
realNode.insertBefore(newNode, nextNode);
|
|
1393
|
+
nextNode = newNode;
|
|
1443
1394
|
}
|
|
1444
1395
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
realNode.removeChild(node);
|
|
1452
|
-
}
|
|
1396
|
+
for (let i = 0; i < oldLen; i++) {
|
|
1397
|
+
const domNode = oldDomNodes[i];
|
|
1398
|
+
if (domNode && !usedOldDomNodes.has(domNode) && domNode.parentNode === realNode) {
|
|
1399
|
+
domUnmountFrames(frame, domNode);
|
|
1400
|
+
ref.changed = 1;
|
|
1401
|
+
realNode.removeChild(domNode);
|
|
1453
1402
|
}
|
|
1454
1403
|
}
|
|
1455
1404
|
if (ref.asyncCount === 0) {
|
|
1456
1405
|
callFunction(ready, []);
|
|
1457
1406
|
}
|
|
1458
1407
|
}
|
|
1459
|
-
function reduceCached(keyedNodes, node, compared) {
|
|
1460
|
-
if (!keyedNodes || !node.compareKey) return;
|
|
1461
|
-
const bucket = keyedNodes[node.compareKey];
|
|
1462
|
-
if (bucket) {
|
|
1463
|
-
for (let i = bucket.length; i--; ) {
|
|
1464
|
-
if (bucket[i] === compared) {
|
|
1465
|
-
bucket[i] = void 0;
|
|
1466
|
-
break;
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
1408
|
function createVDomRef(viewId) {
|
|
1472
1409
|
return {
|
|
1473
1410
|
viewId,
|
|
@@ -1610,9 +1547,6 @@ var Updater = class {
|
|
|
1610
1547
|
view,
|
|
1611
1548
|
ready
|
|
1612
1549
|
);
|
|
1613
|
-
if (ref.asyncCount === 0) {
|
|
1614
|
-
ready();
|
|
1615
|
-
}
|
|
1616
1550
|
} else {
|
|
1617
1551
|
const html = template(
|
|
1618
1552
|
this.data,
|
|
@@ -2109,6 +2043,60 @@ var Router = {
|
|
|
2109
2043
|
}
|
|
2110
2044
|
};
|
|
2111
2045
|
|
|
2046
|
+
// src/view-registry.ts
|
|
2047
|
+
var viewClassRegistry = {};
|
|
2048
|
+
function getViewClass(path) {
|
|
2049
|
+
return viewClassRegistry[path];
|
|
2050
|
+
}
|
|
2051
|
+
function registerViewClass(viewPath, ViewClass) {
|
|
2052
|
+
const parsed = parseUri(viewPath);
|
|
2053
|
+
const path = parsed.path;
|
|
2054
|
+
if (path) {
|
|
2055
|
+
viewClassRegistry[path] = ViewClass;
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
function invalidateViewClass(viewPath) {
|
|
2059
|
+
const parsed = parseUri(viewPath);
|
|
2060
|
+
const path = parsed.path;
|
|
2061
|
+
if (path) {
|
|
2062
|
+
Reflect.deleteProperty(viewClassRegistry, path);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
// src/hmr.ts
|
|
2067
|
+
function reloadViews(viewPath) {
|
|
2068
|
+
const allFrames = Frame.getAll();
|
|
2069
|
+
const toReload = [];
|
|
2070
|
+
for (const [, frame] of allFrames) {
|
|
2071
|
+
if (frame.viewPath) {
|
|
2072
|
+
const parsed = parseUri(frame.viewPath);
|
|
2073
|
+
if (parsed.path === viewPath) {
|
|
2074
|
+
toReload.push({ frame, fullPath: frame.viewPath });
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
for (const { frame, fullPath } of toReload) {
|
|
2079
|
+
frame.mountView(fullPath);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
function acceptView(hot, viewPath) {
|
|
2083
|
+
hot.accept((newModule) => {
|
|
2084
|
+
const candidate = newModule?.default ?? newModule;
|
|
2085
|
+
if (typeof candidate === "function") {
|
|
2086
|
+
const NewViewClass = candidate;
|
|
2087
|
+
registerViewClass(viewPath, NewViewClass);
|
|
2088
|
+
reloadViews(viewPath);
|
|
2089
|
+
} else {
|
|
2090
|
+
hot.invalidate();
|
|
2091
|
+
}
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
function disposeView(hot, viewPath) {
|
|
2095
|
+
hot.dispose(() => {
|
|
2096
|
+
invalidateViewClass(viewPath);
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2112
2100
|
// src/view.ts
|
|
2113
2101
|
var VIEW_GLOBALS = {};
|
|
2114
2102
|
if (typeof window !== "undefined") {
|
|
@@ -2699,20 +2687,47 @@ var View = class _View {
|
|
|
2699
2687
|
_View.mergeMixins(mixins, this, existingCtors);
|
|
2700
2688
|
return this;
|
|
2701
2689
|
}
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
//
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2690
|
+
// ============================================================
|
|
2691
|
+
// HMR support (static accept / dispose)
|
|
2692
|
+
// ============================================================
|
|
2693
|
+
/**
|
|
2694
|
+
* Set up HMR accept handler for this view module.
|
|
2695
|
+
*
|
|
2696
|
+
* When the module is hot-replaced, the new View class is extracted from
|
|
2697
|
+
* the new module, registered in the view registry, and all currently
|
|
2698
|
+
* mounted frames using this viewPath are re-mounted.
|
|
2699
|
+
*
|
|
2700
|
+
* No-op when `hot` is undefined (production / non-HMR environment).
|
|
2701
|
+
*
|
|
2702
|
+
* ```ts
|
|
2703
|
+
* if (import.meta.hot) {
|
|
2704
|
+
* HomeView.accept(import.meta.hot, 'home');
|
|
2705
|
+
* }
|
|
2706
|
+
* ```
|
|
2707
|
+
*/
|
|
2708
|
+
static accept(hot, viewPath) {
|
|
2709
|
+
if (!hot) return;
|
|
2710
|
+
acceptView(hot, viewPath);
|
|
2714
2711
|
}
|
|
2715
|
-
|
|
2712
|
+
/**
|
|
2713
|
+
* Set up HMR dispose handler for this view module.
|
|
2714
|
+
*
|
|
2715
|
+
* When the module is about to be replaced, the old View class is removed
|
|
2716
|
+
* from the registry so subsequent lookups don't return the stale class.
|
|
2717
|
+
*
|
|
2718
|
+
* No-op when `hot` is undefined (production / non-HMR environment).
|
|
2719
|
+
*
|
|
2720
|
+
* ```ts
|
|
2721
|
+
* if (import.meta.hot) {
|
|
2722
|
+
* HomeView.dispose(import.meta.hot, 'home');
|
|
2723
|
+
* }
|
|
2724
|
+
* ```
|
|
2725
|
+
*/
|
|
2726
|
+
static dispose(hot, viewPath) {
|
|
2727
|
+
if (!hot) return;
|
|
2728
|
+
disposeView(hot, viewPath);
|
|
2729
|
+
}
|
|
2730
|
+
};
|
|
2716
2731
|
|
|
2717
2732
|
// src/frame.ts
|
|
2718
2733
|
var frameRegistry = /* @__PURE__ */ new Map();
|