@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.cjs
CHANGED
|
@@ -1157,18 +1157,6 @@ var DOM_SPECIALS = {
|
|
|
1157
1157
|
function isSameVDomNode(a, b) {
|
|
1158
1158
|
return a.compareKey && b.compareKey === a.compareKey || !a.compareKey && !b.compareKey && a.tag === b.tag || a.tag === SPLITTER || b.tag === SPLITTER;
|
|
1159
1159
|
}
|
|
1160
|
-
function getKeyNodes(list, nodes, start, end, realEnd) {
|
|
1161
|
-
const keyedNodes = {};
|
|
1162
|
-
for (let i = end, re = realEnd; i >= start; i--, re--) {
|
|
1163
|
-
const oc = list[i];
|
|
1164
|
-
const cKey = oc.compareKey;
|
|
1165
|
-
if (cKey) {
|
|
1166
|
-
const bucket = keyedNodes[cKey] || (keyedNodes[cKey] = []);
|
|
1167
|
-
bucket.push(nodes[re]);
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
return keyedNodes;
|
|
1171
|
-
}
|
|
1172
1160
|
function vdomCreateNode(vnode, owner, ref) {
|
|
1173
1161
|
const tag = vnode.tag;
|
|
1174
1162
|
if (tag === V_TEXT_NODE) {
|
|
@@ -1257,9 +1245,10 @@ function vdomSetNode(realNode, oldParent, lastVDom, newVDom, ref, frame, keys, r
|
|
|
1257
1245
|
return;
|
|
1258
1246
|
}
|
|
1259
1247
|
if (lastTag === newTag) {
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1248
|
+
if (lastVDom.attrs === newVDom.attrs && lastVDom.html === newVDom.html) {
|
|
1249
|
+
if (newVDom.hasSpecials) {
|
|
1250
|
+
vdomSyncFormState(realNode, newVDom);
|
|
1251
|
+
}
|
|
1263
1252
|
return;
|
|
1264
1253
|
}
|
|
1265
1254
|
let attrChanged = 0;
|
|
@@ -1300,261 +1289,209 @@ function vdomSetNode(realNode, oldParent, lastVDom, newVDom, ref, frame, keys, r
|
|
|
1300
1289
|
oldParent.replaceChild(vdomCreateNode(newVDom, oldParent, ref), realNode);
|
|
1301
1290
|
}
|
|
1302
1291
|
}
|
|
1292
|
+
function computeLIS(sequence) {
|
|
1293
|
+
const len = sequence.length;
|
|
1294
|
+
if (len === 0) return [];
|
|
1295
|
+
const result = [];
|
|
1296
|
+
const tails = [];
|
|
1297
|
+
const predecessors = new Array(len);
|
|
1298
|
+
let lisLength = 0;
|
|
1299
|
+
for (let i = 0; i < len; i++) {
|
|
1300
|
+
const value = sequence[i];
|
|
1301
|
+
if (value < 0) continue;
|
|
1302
|
+
let lo = 0;
|
|
1303
|
+
let hi = lisLength;
|
|
1304
|
+
while (lo < hi) {
|
|
1305
|
+
const mid = lo + hi >>> 1;
|
|
1306
|
+
if (sequence[tails[mid]] < value) lo = mid + 1;
|
|
1307
|
+
else hi = mid;
|
|
1308
|
+
}
|
|
1309
|
+
tails[lo] = i;
|
|
1310
|
+
predecessors[i] = lo > 0 ? tails[lo - 1] : -1;
|
|
1311
|
+
if (lo === lisLength) lisLength++;
|
|
1312
|
+
}
|
|
1313
|
+
let cursor = tails[lisLength - 1];
|
|
1314
|
+
for (let i = lisLength - 1; i >= 0; i--) {
|
|
1315
|
+
result[i] = cursor;
|
|
1316
|
+
cursor = predecessors[cursor];
|
|
1317
|
+
}
|
|
1318
|
+
return result;
|
|
1319
|
+
}
|
|
1303
1320
|
function vdomSetChildNodes(realNode, lastVDom, newVDom, ref, frame, keys, view, ready) {
|
|
1304
1321
|
if (!lastVDom) {
|
|
1305
1322
|
ref.changed = 1;
|
|
1306
1323
|
realNode.innerHTML = newVDom.html;
|
|
1324
|
+
callFunction(ready, []);
|
|
1307
1325
|
return;
|
|
1308
1326
|
}
|
|
1309
1327
|
if (lastVDom.html === newVDom.html) {
|
|
1328
|
+
callFunction(ready, []);
|
|
1310
1329
|
return;
|
|
1311
1330
|
}
|
|
1312
1331
|
const oldChildren = lastVDom.children;
|
|
1313
1332
|
const newChildren = newVDom.children;
|
|
1314
1333
|
const oldLen = oldChildren?.length || 0;
|
|
1315
1334
|
const newLen = newChildren?.length || 0;
|
|
1316
|
-
if (oldLen === 0 && newLen === 0)
|
|
1335
|
+
if (oldLen === 0 && newLen === 0) {
|
|
1336
|
+
callFunction(ready, []);
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1317
1339
|
const nodes = realNode.childNodes;
|
|
1318
|
-
|
|
1319
|
-
let
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
let
|
|
1324
|
-
let
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
realEnd--;
|
|
1392
|
-
oldEndNode = oldChildren?.[--oldEnd];
|
|
1393
|
-
newEndNode = newChildren?.[--newEnd];
|
|
1394
|
-
} else if (isSameVDomNode(newEndNode, oldStartNode)) {
|
|
1395
|
-
if (newEndNode.tag === SPLITTER || oldStartNode.tag === SPLITTER) {
|
|
1396
|
-
ref.changed = 1;
|
|
1397
|
-
domUnmountFrames(frame, realNode);
|
|
1398
|
-
realNode.innerHTML = newEndNode.tag === SPLITTER ? newEndNode.html : "";
|
|
1399
|
-
if (newEndNode.tag !== SPLITTER) {
|
|
1400
|
-
realNode.appendChild(vdomCreateNode(newEndNode, realNode, ref));
|
|
1401
|
-
}
|
|
1402
|
-
} else {
|
|
1403
|
-
const oi = nodes[realStart];
|
|
1404
|
-
realNode.insertBefore(oi, nodes[realEnd + 1] || null);
|
|
1405
|
-
vdomSetNode(
|
|
1406
|
-
oi,
|
|
1407
|
-
realNode,
|
|
1408
|
-
oldStartNode,
|
|
1409
|
-
newEndNode,
|
|
1410
|
-
ref,
|
|
1411
|
-
frame,
|
|
1412
|
-
keys,
|
|
1413
|
-
view,
|
|
1414
|
-
ready
|
|
1415
|
-
);
|
|
1416
|
-
}
|
|
1417
|
-
reduceCached(keyedNodes, oldStartNode, nodes[realStart]);
|
|
1418
|
-
realStart++;
|
|
1419
|
-
oldStartNode = oldChildren?.[++oldStart];
|
|
1420
|
-
newEndNode = newChildren?.[--newEnd];
|
|
1421
|
-
} else if (isSameVDomNode(newStartNode, oldEndNode)) {
|
|
1422
|
-
if (newStartNode.tag === SPLITTER || oldEndNode.tag === SPLITTER) {
|
|
1423
|
-
ref.changed = 1;
|
|
1424
|
-
domUnmountFrames(frame, realNode);
|
|
1425
|
-
realNode.innerHTML = newStartNode.tag === SPLITTER ? newStartNode.html : "";
|
|
1426
|
-
if (newStartNode.tag !== SPLITTER) {
|
|
1427
|
-
realNode.appendChild(vdomCreateNode(newStartNode, realNode, ref));
|
|
1428
|
-
}
|
|
1429
|
-
} else {
|
|
1430
|
-
const oi = nodes[realEnd];
|
|
1431
|
-
realNode.insertBefore(oi, nodes[realStart]);
|
|
1432
|
-
vdomSetNode(
|
|
1433
|
-
oi,
|
|
1434
|
-
realNode,
|
|
1435
|
-
oldEndNode,
|
|
1436
|
-
newStartNode,
|
|
1437
|
-
ref,
|
|
1438
|
-
frame,
|
|
1439
|
-
keys,
|
|
1440
|
-
view,
|
|
1441
|
-
ready
|
|
1442
|
-
);
|
|
1443
|
-
}
|
|
1444
|
-
reduceCached(keyedNodes, oldEndNode, nodes[realEnd]);
|
|
1445
|
-
realEnd--;
|
|
1446
|
-
oldEndNode = oldChildren?.[--oldEnd];
|
|
1447
|
-
newStartNode = newChildren?.[++newStart];
|
|
1340
|
+
const oldDomNodes = new Array(oldLen);
|
|
1341
|
+
for (let i = 0; i < oldLen; i++) {
|
|
1342
|
+
oldDomNodes[i] = nodes[i];
|
|
1343
|
+
}
|
|
1344
|
+
const usedOldDomNodes = /* @__PURE__ */ new Set();
|
|
1345
|
+
let headIdx = 0;
|
|
1346
|
+
let tailIdx = oldLen - 1;
|
|
1347
|
+
let newHead = 0;
|
|
1348
|
+
let newTail = newLen - 1;
|
|
1349
|
+
while (headIdx <= tailIdx && newHead <= newTail) {
|
|
1350
|
+
const oc = oldChildren[headIdx];
|
|
1351
|
+
const nc = newChildren[newHead];
|
|
1352
|
+
if (!isSameVDomNode(nc, oc)) break;
|
|
1353
|
+
if (nc.tag === SPLITTER || oc.tag === SPLITTER) break;
|
|
1354
|
+
vdomSetNode(
|
|
1355
|
+
oldDomNodes[headIdx],
|
|
1356
|
+
realNode,
|
|
1357
|
+
oc,
|
|
1358
|
+
nc,
|
|
1359
|
+
ref,
|
|
1360
|
+
frame,
|
|
1361
|
+
keys,
|
|
1362
|
+
view,
|
|
1363
|
+
ready
|
|
1364
|
+
);
|
|
1365
|
+
usedOldDomNodes.add(oldDomNodes[headIdx]);
|
|
1366
|
+
headIdx++;
|
|
1367
|
+
newHead++;
|
|
1368
|
+
}
|
|
1369
|
+
while (headIdx <= tailIdx && newHead <= newTail) {
|
|
1370
|
+
const oc = oldChildren[tailIdx];
|
|
1371
|
+
const nc = newChildren[newTail];
|
|
1372
|
+
if (!isSameVDomNode(nc, oc)) break;
|
|
1373
|
+
if (nc.tag === SPLITTER || oc.tag === SPLITTER) break;
|
|
1374
|
+
vdomSetNode(
|
|
1375
|
+
oldDomNodes[tailIdx],
|
|
1376
|
+
realNode,
|
|
1377
|
+
oc,
|
|
1378
|
+
nc,
|
|
1379
|
+
ref,
|
|
1380
|
+
frame,
|
|
1381
|
+
keys,
|
|
1382
|
+
view,
|
|
1383
|
+
ready
|
|
1384
|
+
);
|
|
1385
|
+
usedOldDomNodes.add(oldDomNodes[tailIdx]);
|
|
1386
|
+
tailIdx--;
|
|
1387
|
+
newTail--;
|
|
1388
|
+
}
|
|
1389
|
+
if (headIdx > tailIdx && newHead > newTail) {
|
|
1390
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
const keyMap = {};
|
|
1394
|
+
for (let i = headIdx; i <= tailIdx; i++) {
|
|
1395
|
+
const c = oldChildren[i];
|
|
1396
|
+
if (c?.compareKey) {
|
|
1397
|
+
if (!keyMap[c.compareKey]) keyMap[c.compareKey] = [];
|
|
1398
|
+
keyMap[c.compareKey].push({ domNode: oldDomNodes[i], vdomNode: c });
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
const newRemaining = newTail - newHead + 1;
|
|
1402
|
+
const sequence = new Array(newRemaining);
|
|
1403
|
+
for (let i = 0; i < newRemaining; i++) {
|
|
1404
|
+
const nc = newChildren[newHead + i];
|
|
1405
|
+
const cKey = nc.compareKey;
|
|
1406
|
+
const entries = cKey ? keyMap[cKey] : void 0;
|
|
1407
|
+
if (entries && entries.length > 0) {
|
|
1408
|
+
const entry = entries.shift();
|
|
1409
|
+
if (entries.length === 0) delete keyMap[cKey];
|
|
1410
|
+
const oldIdx = oldChildren.indexOf(entry.vdomNode, headIdx);
|
|
1411
|
+
sequence[i] = oldIdx >= 0 ? oldIdx : -1;
|
|
1412
|
+
usedOldDomNodes.add(entry.domNode);
|
|
1448
1413
|
} else {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
);
|
|
1457
|
-
}
|
|
1458
|
-
const cKey = newStartNode.compareKey;
|
|
1459
|
-
let found;
|
|
1460
|
-
let compareKey;
|
|
1461
|
-
if (cKey && keyedNodes) {
|
|
1462
|
-
found = keyedNodes[cKey];
|
|
1463
|
-
compareKey = void 0;
|
|
1464
|
-
while (found && found.length > 0) {
|
|
1465
|
-
compareKey = found.pop();
|
|
1466
|
-
if (compareKey) break;
|
|
1467
|
-
}
|
|
1468
|
-
if (found && found.length === 0) delete keyedNodes[cKey];
|
|
1469
|
-
}
|
|
1470
|
-
if (compareKey) {
|
|
1471
|
-
if (compareKey !== nodes[realStart]) {
|
|
1472
|
-
for (let j = oldStart + 1; j <= oldEnd; j++) {
|
|
1473
|
-
const oc = oldChildren?.[j];
|
|
1474
|
-
if (oc && nodes[realStart + (j - oldStart)] === compareKey) {
|
|
1475
|
-
oldChildren[j] = void 0;
|
|
1476
|
-
break;
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
realNode.insertBefore(compareKey, nodes[realStart]);
|
|
1480
|
-
}
|
|
1481
|
-
vdomSetNode(
|
|
1482
|
-
compareKey,
|
|
1483
|
-
realNode,
|
|
1484
|
-
oldStartNode,
|
|
1485
|
-
newStartNode,
|
|
1486
|
-
ref,
|
|
1487
|
-
frame,
|
|
1488
|
-
keys,
|
|
1489
|
-
view,
|
|
1490
|
-
ready
|
|
1491
|
-
);
|
|
1492
|
-
} else if (oldStartNode.compareKey && lastVDom.reused?.[oldStartNode.compareKey] && newVDom.reused?.[oldStartNode.compareKey] || nodes[realStart]?.id && realNode.querySelectorAll?.(
|
|
1493
|
-
`#${nodes[realStart].id}`
|
|
1494
|
-
)?.length && !newStartNode.isLarkView) {
|
|
1414
|
+
sequence[i] = -1;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
if (newHead > newTail) {
|
|
1418
|
+
for (let i = 0; i < oldLen; i++) {
|
|
1419
|
+
const domNode = oldDomNodes[i];
|
|
1420
|
+
if (domNode && !usedOldDomNodes.has(domNode) && domNode.parentNode === realNode) {
|
|
1421
|
+
domUnmountFrames(frame, domNode);
|
|
1495
1422
|
ref.changed = 1;
|
|
1496
|
-
|
|
1497
|
-
realNode.insertBefore(newNode, nodes[realStart]);
|
|
1498
|
-
realStart--;
|
|
1499
|
-
realEnd++;
|
|
1500
|
-
} else {
|
|
1501
|
-
vdomSetNode(
|
|
1502
|
-
nodes[realStart],
|
|
1503
|
-
realNode,
|
|
1504
|
-
oldStartNode,
|
|
1505
|
-
newStartNode,
|
|
1506
|
-
ref,
|
|
1507
|
-
frame,
|
|
1508
|
-
keys,
|
|
1509
|
-
view,
|
|
1510
|
-
ready
|
|
1511
|
-
);
|
|
1423
|
+
realNode.removeChild(domNode);
|
|
1512
1424
|
}
|
|
1513
|
-
realStart++;
|
|
1514
|
-
oldStartNode = oldChildren?.[++oldStart];
|
|
1515
|
-
newStartNode = newChildren?.[++newStart];
|
|
1516
1425
|
}
|
|
1426
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
1427
|
+
return;
|
|
1517
1428
|
}
|
|
1518
|
-
if (
|
|
1519
|
-
const
|
|
1520
|
-
for (let i =
|
|
1429
|
+
if (headIdx > tailIdx) {
|
|
1430
|
+
const insertRef = tailIdx < oldLen ? oldDomNodes[tailIdx + 1] ?? null : null;
|
|
1431
|
+
for (let i = newHead; i <= newTail; i++) {
|
|
1432
|
+
ref.changed = 1;
|
|
1433
|
+
const newNode = vdomCreateNode(newChildren[i], realNode, ref);
|
|
1434
|
+
realNode.insertBefore(newNode, insertRef);
|
|
1435
|
+
}
|
|
1436
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
const lis = computeLIS(sequence);
|
|
1440
|
+
let lisCursor = lis.length - 1;
|
|
1441
|
+
let nextNode = tailIdx + 1 < oldLen ? oldDomNodes[tailIdx + 1] : null;
|
|
1442
|
+
for (let j = newRemaining - 1; j >= 0; j--) {
|
|
1443
|
+
const newIdx = newHead + j;
|
|
1444
|
+
const nc = newChildren[newIdx];
|
|
1445
|
+
if (lisCursor >= 0 && lis[lisCursor] === j) {
|
|
1446
|
+
const oldIdx = sequence[j];
|
|
1447
|
+
vdomSetNode(
|
|
1448
|
+
oldDomNodes[oldIdx],
|
|
1449
|
+
realNode,
|
|
1450
|
+
oldChildren[oldIdx],
|
|
1451
|
+
nc,
|
|
1452
|
+
ref,
|
|
1453
|
+
frame,
|
|
1454
|
+
keys,
|
|
1455
|
+
view,
|
|
1456
|
+
ready
|
|
1457
|
+
);
|
|
1458
|
+
nextNode = oldDomNodes[oldIdx];
|
|
1459
|
+
lisCursor--;
|
|
1460
|
+
} else if (sequence[j] >= 0) {
|
|
1461
|
+
const oldIdx = sequence[j];
|
|
1462
|
+
ref.changed = 1;
|
|
1463
|
+
realNode.insertBefore(oldDomNodes[oldIdx], nextNode);
|
|
1464
|
+
vdomSetNode(
|
|
1465
|
+
oldDomNodes[oldIdx],
|
|
1466
|
+
realNode,
|
|
1467
|
+
oldChildren[oldIdx],
|
|
1468
|
+
nc,
|
|
1469
|
+
ref,
|
|
1470
|
+
frame,
|
|
1471
|
+
keys,
|
|
1472
|
+
view,
|
|
1473
|
+
ready
|
|
1474
|
+
);
|
|
1475
|
+
nextNode = oldDomNodes[oldIdx];
|
|
1476
|
+
} else {
|
|
1521
1477
|
ref.changed = 1;
|
|
1522
|
-
const nc = newChildren[i];
|
|
1523
|
-
if (nc.tag === SPLITTER) {
|
|
1524
|
-
domUnmountFrames(frame, realNode);
|
|
1525
|
-
realNode.innerHTML = nc.html;
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
1478
|
const newNode = vdomCreateNode(nc, realNode, ref);
|
|
1529
|
-
realNode.insertBefore(newNode,
|
|
1479
|
+
realNode.insertBefore(newNode, nextNode);
|
|
1480
|
+
nextNode = newNode;
|
|
1530
1481
|
}
|
|
1531
1482
|
}
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
realNode.removeChild(node);
|
|
1539
|
-
}
|
|
1483
|
+
for (let i = 0; i < oldLen; i++) {
|
|
1484
|
+
const domNode = oldDomNodes[i];
|
|
1485
|
+
if (domNode && !usedOldDomNodes.has(domNode) && domNode.parentNode === realNode) {
|
|
1486
|
+
domUnmountFrames(frame, domNode);
|
|
1487
|
+
ref.changed = 1;
|
|
1488
|
+
realNode.removeChild(domNode);
|
|
1540
1489
|
}
|
|
1541
1490
|
}
|
|
1542
1491
|
if (ref.asyncCount === 0) {
|
|
1543
1492
|
callFunction(ready, []);
|
|
1544
1493
|
}
|
|
1545
1494
|
}
|
|
1546
|
-
function reduceCached(keyedNodes, node, compared) {
|
|
1547
|
-
if (!keyedNodes || !node.compareKey) return;
|
|
1548
|
-
const bucket = keyedNodes[node.compareKey];
|
|
1549
|
-
if (bucket) {
|
|
1550
|
-
for (let i = bucket.length; i--; ) {
|
|
1551
|
-
if (bucket[i] === compared) {
|
|
1552
|
-
bucket[i] = void 0;
|
|
1553
|
-
break;
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
1495
|
function createVDomRef(viewId) {
|
|
1559
1496
|
return {
|
|
1560
1497
|
viewId,
|
|
@@ -1697,9 +1634,6 @@ var Updater = class {
|
|
|
1697
1634
|
view,
|
|
1698
1635
|
ready
|
|
1699
1636
|
);
|
|
1700
|
-
if (ref.asyncCount === 0) {
|
|
1701
|
-
ready();
|
|
1702
|
-
}
|
|
1703
1637
|
} else {
|
|
1704
1638
|
const html = template(
|
|
1705
1639
|
this.data,
|
|
@@ -2196,6 +2130,60 @@ var Router = {
|
|
|
2196
2130
|
}
|
|
2197
2131
|
};
|
|
2198
2132
|
|
|
2133
|
+
// src/view-registry.ts
|
|
2134
|
+
var viewClassRegistry = {};
|
|
2135
|
+
function getViewClass(path) {
|
|
2136
|
+
return viewClassRegistry[path];
|
|
2137
|
+
}
|
|
2138
|
+
function registerViewClass(viewPath, ViewClass) {
|
|
2139
|
+
const parsed = parseUri(viewPath);
|
|
2140
|
+
const path = parsed.path;
|
|
2141
|
+
if (path) {
|
|
2142
|
+
viewClassRegistry[path] = ViewClass;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
function invalidateViewClass(viewPath) {
|
|
2146
|
+
const parsed = parseUri(viewPath);
|
|
2147
|
+
const path = parsed.path;
|
|
2148
|
+
if (path) {
|
|
2149
|
+
Reflect.deleteProperty(viewClassRegistry, path);
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
// src/hmr.ts
|
|
2154
|
+
function reloadViews(viewPath) {
|
|
2155
|
+
const allFrames = Frame.getAll();
|
|
2156
|
+
const toReload = [];
|
|
2157
|
+
for (const [, frame] of allFrames) {
|
|
2158
|
+
if (frame.viewPath) {
|
|
2159
|
+
const parsed = parseUri(frame.viewPath);
|
|
2160
|
+
if (parsed.path === viewPath) {
|
|
2161
|
+
toReload.push({ frame, fullPath: frame.viewPath });
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
for (const { frame, fullPath } of toReload) {
|
|
2166
|
+
frame.mountView(fullPath);
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
function acceptView(hot, viewPath) {
|
|
2170
|
+
hot.accept((newModule) => {
|
|
2171
|
+
const candidate = newModule?.default ?? newModule;
|
|
2172
|
+
if (typeof candidate === "function") {
|
|
2173
|
+
const NewViewClass = candidate;
|
|
2174
|
+
registerViewClass(viewPath, NewViewClass);
|
|
2175
|
+
reloadViews(viewPath);
|
|
2176
|
+
} else {
|
|
2177
|
+
hot.invalidate();
|
|
2178
|
+
}
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
function disposeView(hot, viewPath) {
|
|
2182
|
+
hot.dispose(() => {
|
|
2183
|
+
invalidateViewClass(viewPath);
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2199
2187
|
// src/view.ts
|
|
2200
2188
|
var VIEW_GLOBALS = {};
|
|
2201
2189
|
if (typeof window !== "undefined") {
|
|
@@ -2786,20 +2774,47 @@ var View = class _View {
|
|
|
2786
2774
|
_View.mergeMixins(mixins, this, existingCtors);
|
|
2787
2775
|
return this;
|
|
2788
2776
|
}
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
//
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2777
|
+
// ============================================================
|
|
2778
|
+
// HMR support (static accept / dispose)
|
|
2779
|
+
// ============================================================
|
|
2780
|
+
/**
|
|
2781
|
+
* Set up HMR accept handler for this view module.
|
|
2782
|
+
*
|
|
2783
|
+
* When the module is hot-replaced, the new View class is extracted from
|
|
2784
|
+
* the new module, registered in the view registry, and all currently
|
|
2785
|
+
* mounted frames using this viewPath are re-mounted.
|
|
2786
|
+
*
|
|
2787
|
+
* No-op when `hot` is undefined (production / non-HMR environment).
|
|
2788
|
+
*
|
|
2789
|
+
* ```ts
|
|
2790
|
+
* if (import.meta.hot) {
|
|
2791
|
+
* HomeView.accept(import.meta.hot, 'home');
|
|
2792
|
+
* }
|
|
2793
|
+
* ```
|
|
2794
|
+
*/
|
|
2795
|
+
static accept(hot, viewPath) {
|
|
2796
|
+
if (!hot) return;
|
|
2797
|
+
acceptView(hot, viewPath);
|
|
2801
2798
|
}
|
|
2802
|
-
|
|
2799
|
+
/**
|
|
2800
|
+
* Set up HMR dispose handler for this view module.
|
|
2801
|
+
*
|
|
2802
|
+
* When the module is about to be replaced, the old View class is removed
|
|
2803
|
+
* from the registry so subsequent lookups don't return the stale class.
|
|
2804
|
+
*
|
|
2805
|
+
* No-op when `hot` is undefined (production / non-HMR environment).
|
|
2806
|
+
*
|
|
2807
|
+
* ```ts
|
|
2808
|
+
* if (import.meta.hot) {
|
|
2809
|
+
* HomeView.dispose(import.meta.hot, 'home');
|
|
2810
|
+
* }
|
|
2811
|
+
* ```
|
|
2812
|
+
*/
|
|
2813
|
+
static dispose(hot, viewPath) {
|
|
2814
|
+
if (!hot) return;
|
|
2815
|
+
disposeView(hot, viewPath);
|
|
2816
|
+
}
|
|
2817
|
+
};
|
|
2803
2818
|
|
|
2804
2819
|
// src/frame.ts
|
|
2805
2820
|
var frameRegistry = /* @__PURE__ */ new Map();
|