marko 6.0.15 → 6.0.17
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/debug/dom.js +194 -189
- package/dist/debug/dom.mjs +194 -189
- package/dist/dom/renderer.d.ts +9 -11
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +140 -138
- package/dist/dom.mjs +140 -138
- package/dist/translator/index.js +150 -75
- package/dist/translator/util/references.d.ts +3 -2
- package/dist/translator/util/sections.d.ts +1 -0
- package/dist/translator/util/signals.d.ts +2 -1
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
@@ -63,6 +63,7 @@ __export(dom_exports, {
|
|
63
63
|
init: () => init,
|
64
64
|
intersection: () => intersection,
|
65
65
|
lifecycle: () => lifecycle,
|
66
|
+
localClosures: () => localClosures,
|
66
67
|
loopClosure: () => loopClosure,
|
67
68
|
loopIn: () => loopIn,
|
68
69
|
loopOf: () => loopOf,
|
@@ -1222,183 +1223,6 @@ function longestIncreasingSubsequence(a) {
|
|
1222
1223
|
return result;
|
1223
1224
|
}
|
1224
1225
|
|
1225
|
-
// src/dom/walker.ts
|
1226
|
-
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
1227
|
-
function walk(startNode, walkCodes, branch) {
|
1228
|
-
walker.currentNode = startNode;
|
1229
|
-
walkInternal(0, walkCodes, branch);
|
1230
|
-
}
|
1231
|
-
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
1232
|
-
let value2;
|
1233
|
-
let storedMultiplier = 0;
|
1234
|
-
let currentMultiplier = 0;
|
1235
|
-
let currentScopeIndex = 0;
|
1236
|
-
for (; currentWalkIndex < walkCodes.length; ) {
|
1237
|
-
value2 = walkCodes.charCodeAt(currentWalkIndex++);
|
1238
|
-
currentMultiplier = storedMultiplier;
|
1239
|
-
storedMultiplier = 0;
|
1240
|
-
if (value2 === 32 /* Get */) {
|
1241
|
-
const node = walker.currentNode;
|
1242
|
-
scope[true ? getDebugKey(currentScopeIndex, walker.currentNode) : currentScopeIndex] = node;
|
1243
|
-
scope["Getter:" /* Getter */ + (true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++)] = () => node;
|
1244
|
-
} else if (value2 === 37 /* Replace */ || value2 === 49 /* DynamicTagWithVar */) {
|
1245
|
-
walker.currentNode.replaceWith(
|
1246
|
-
walker.currentNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = new Text()
|
1247
|
-
);
|
1248
|
-
if (value2 === 49 /* DynamicTagWithVar */) {
|
1249
|
-
scope[true ? getDebugKey(currentScopeIndex++, "#scopeOffset") : currentScopeIndex++] = skipScope(scope);
|
1250
|
-
}
|
1251
|
-
} else if (value2 === 38 /* EndChild */) {
|
1252
|
-
return currentWalkIndex;
|
1253
|
-
} else if (value2 === 47 /* BeginChild */ || value2 === 48 /* BeginChildWithVar */) {
|
1254
|
-
currentWalkIndex = walkInternal(
|
1255
|
-
currentWalkIndex,
|
1256
|
-
walkCodes,
|
1257
|
-
scope[true ? getDebugKey(currentScopeIndex++, "#childScope") : currentScopeIndex++] = createScope(scope.$global, scope.___closestBranch)
|
1258
|
-
);
|
1259
|
-
if (value2 === 48 /* BeginChildWithVar */) {
|
1260
|
-
scope[true ? getDebugKey(currentScopeIndex++, "#scopeOffset") : currentScopeIndex++] = skipScope(scope);
|
1261
|
-
}
|
1262
|
-
} else if (value2 < 91 /* NextEnd */ + 1) {
|
1263
|
-
value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */;
|
1264
|
-
while (value2--) {
|
1265
|
-
walker.nextNode();
|
1266
|
-
}
|
1267
|
-
} else if (value2 < 106 /* OverEnd */ + 1) {
|
1268
|
-
value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */;
|
1269
|
-
while (value2--) {
|
1270
|
-
walker.nextSibling();
|
1271
|
-
}
|
1272
|
-
} else if (value2 < 116 /* OutEnd */ + 1) {
|
1273
|
-
value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */;
|
1274
|
-
while (value2--) {
|
1275
|
-
walker.parentNode();
|
1276
|
-
}
|
1277
|
-
walker.nextSibling();
|
1278
|
-
} else {
|
1279
|
-
if (value2 < 117 /* Multiplier */ || value2 > 126 /* MultiplierEnd */) {
|
1280
|
-
throw new Error(`Unknown walk code: ${value2}`);
|
1281
|
-
}
|
1282
|
-
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
|
1283
|
-
}
|
1284
|
-
}
|
1285
|
-
}
|
1286
|
-
function getDebugKey(index, node) {
|
1287
|
-
if (typeof node === "string") {
|
1288
|
-
return `${node}/${index}`;
|
1289
|
-
} else if (node.nodeType === 3 /* Text */) {
|
1290
|
-
return `#text/${index}`;
|
1291
|
-
} else if (node.nodeType === 8 /* Comment */) {
|
1292
|
-
return `#comment/${index}`;
|
1293
|
-
} else if (node.nodeType === 1 /* Element */) {
|
1294
|
-
return `#${node.tagName.toLowerCase()}/${index}`;
|
1295
|
-
}
|
1296
|
-
return index;
|
1297
|
-
}
|
1298
|
-
|
1299
|
-
// src/dom/renderer.ts
|
1300
|
-
function createBranch($global, renderer, parentScope, parentNode) {
|
1301
|
-
const branch = createScope($global);
|
1302
|
-
const parentBranch = parentScope?.___closestBranch;
|
1303
|
-
branch["_" /* Owner */] = renderer.___owner || parentScope;
|
1304
|
-
branch.___closestBranch = branch;
|
1305
|
-
if (parentBranch) {
|
1306
|
-
branch.___parentBranch = parentBranch;
|
1307
|
-
(parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
|
1308
|
-
}
|
1309
|
-
if (true) {
|
1310
|
-
branch.___renderer = renderer;
|
1311
|
-
}
|
1312
|
-
renderer.___clone?.(
|
1313
|
-
branch,
|
1314
|
-
parentNode.namespaceURI
|
1315
|
-
);
|
1316
|
-
return branch;
|
1317
|
-
}
|
1318
|
-
function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
1319
|
-
return setupBranch(
|
1320
|
-
renderer,
|
1321
|
-
createBranch($global, renderer, parentScope, parentNode)
|
1322
|
-
);
|
1323
|
-
}
|
1324
|
-
function setupBranch(renderer, branch) {
|
1325
|
-
if (renderer.___setup || renderer.___closures) {
|
1326
|
-
queueRender(
|
1327
|
-
branch,
|
1328
|
-
(branch2) => {
|
1329
|
-
renderer.___setup?.(branch2);
|
1330
|
-
renderer.___closures?.(branch2);
|
1331
|
-
},
|
1332
|
-
-1
|
1333
|
-
);
|
1334
|
-
}
|
1335
|
-
return branch;
|
1336
|
-
}
|
1337
|
-
function createContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
1338
|
-
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
1339
|
-
setup ||= void 0;
|
1340
|
-
params ||= void 0;
|
1341
|
-
closures = closures ? closures._ || closures : void 0;
|
1342
|
-
const clone = template ? (branch, ns) => {
|
1343
|
-
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
|
1344
|
-
template,
|
1345
|
-
ns
|
1346
|
-
))(branch, walks);
|
1347
|
-
} : (branch) => {
|
1348
|
-
walk(
|
1349
|
-
branch.___startNode = branch.___endNode = new Text(),
|
1350
|
-
walks,
|
1351
|
-
branch
|
1352
|
-
);
|
1353
|
-
};
|
1354
|
-
return (owner) => {
|
1355
|
-
return {
|
1356
|
-
___id: id,
|
1357
|
-
___clone: clone,
|
1358
|
-
___owner: owner,
|
1359
|
-
___setup: setup,
|
1360
|
-
___params: params,
|
1361
|
-
___closures: closures,
|
1362
|
-
___accessor: dynamicScopesAccessor
|
1363
|
-
};
|
1364
|
-
};
|
1365
|
-
}
|
1366
|
-
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
1367
|
-
return register(
|
1368
|
-
id,
|
1369
|
-
createContent(
|
1370
|
-
id,
|
1371
|
-
template,
|
1372
|
-
walks,
|
1373
|
-
setup,
|
1374
|
-
params,
|
1375
|
-
closures,
|
1376
|
-
dynamicScopesAccessor
|
1377
|
-
)
|
1378
|
-
);
|
1379
|
-
}
|
1380
|
-
function createRenderer(template, walks, setup, params, closures) {
|
1381
|
-
return createContent("", template, walks, setup, params, closures)();
|
1382
|
-
}
|
1383
|
-
var cloneCache = {};
|
1384
|
-
function createCloneableHTML(html2, ns) {
|
1385
|
-
const { firstChild, lastChild } = parseHTML(html2, ns);
|
1386
|
-
const parent = document.createElementNS(ns, "t");
|
1387
|
-
insertChildNodes(parent, null, firstChild, lastChild);
|
1388
|
-
return firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
|
1389
|
-
walk(
|
1390
|
-
branch.___startNode = branch.___endNode = firstChild.cloneNode(true),
|
1391
|
-
walks,
|
1392
|
-
branch
|
1393
|
-
);
|
1394
|
-
} : (branch, walks) => {
|
1395
|
-
const clone = parent.cloneNode(true);
|
1396
|
-
walk(clone.firstChild, walks, branch);
|
1397
|
-
branch.___startNode = clone.firstChild;
|
1398
|
-
branch.___endNode = clone.lastChild;
|
1399
|
-
};
|
1400
|
-
}
|
1401
|
-
|
1402
1226
|
// src/dom/schedule.ts
|
1403
1227
|
var runTask;
|
1404
1228
|
var isScheduled;
|
@@ -1634,6 +1458,178 @@ function hoist(...path) {
|
|
1634
1458
|
};
|
1635
1459
|
}
|
1636
1460
|
|
1461
|
+
// src/dom/walker.ts
|
1462
|
+
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
1463
|
+
function walk(startNode, walkCodes, branch) {
|
1464
|
+
walker.currentNode = startNode;
|
1465
|
+
walkInternal(0, walkCodes, branch);
|
1466
|
+
}
|
1467
|
+
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
1468
|
+
let value2;
|
1469
|
+
let storedMultiplier = 0;
|
1470
|
+
let currentMultiplier = 0;
|
1471
|
+
let currentScopeIndex = 0;
|
1472
|
+
for (; currentWalkIndex < walkCodes.length; ) {
|
1473
|
+
value2 = walkCodes.charCodeAt(currentWalkIndex++);
|
1474
|
+
currentMultiplier = storedMultiplier;
|
1475
|
+
storedMultiplier = 0;
|
1476
|
+
if (value2 === 32 /* Get */) {
|
1477
|
+
const node = walker.currentNode;
|
1478
|
+
scope[true ? getDebugKey(currentScopeIndex, walker.currentNode) : currentScopeIndex] = node;
|
1479
|
+
scope["Getter:" /* Getter */ + (true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++)] = () => node;
|
1480
|
+
} else if (value2 === 37 /* Replace */ || value2 === 49 /* DynamicTagWithVar */) {
|
1481
|
+
walker.currentNode.replaceWith(
|
1482
|
+
walker.currentNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = new Text()
|
1483
|
+
);
|
1484
|
+
if (value2 === 49 /* DynamicTagWithVar */) {
|
1485
|
+
scope[true ? getDebugKey(currentScopeIndex++, "#scopeOffset") : currentScopeIndex++] = skipScope(scope);
|
1486
|
+
}
|
1487
|
+
} else if (value2 === 38 /* EndChild */) {
|
1488
|
+
return currentWalkIndex;
|
1489
|
+
} else if (value2 === 47 /* BeginChild */ || value2 === 48 /* BeginChildWithVar */) {
|
1490
|
+
currentWalkIndex = walkInternal(
|
1491
|
+
currentWalkIndex,
|
1492
|
+
walkCodes,
|
1493
|
+
scope[true ? getDebugKey(currentScopeIndex++, "#childScope") : currentScopeIndex++] = createScope(scope.$global, scope.___closestBranch)
|
1494
|
+
);
|
1495
|
+
if (value2 === 48 /* BeginChildWithVar */) {
|
1496
|
+
scope[true ? getDebugKey(currentScopeIndex++, "#scopeOffset") : currentScopeIndex++] = skipScope(scope);
|
1497
|
+
}
|
1498
|
+
} else if (value2 < 91 /* NextEnd */ + 1) {
|
1499
|
+
value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */;
|
1500
|
+
while (value2--) {
|
1501
|
+
walker.nextNode();
|
1502
|
+
}
|
1503
|
+
} else if (value2 < 106 /* OverEnd */ + 1) {
|
1504
|
+
value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */;
|
1505
|
+
while (value2--) {
|
1506
|
+
walker.nextSibling();
|
1507
|
+
}
|
1508
|
+
} else if (value2 < 116 /* OutEnd */ + 1) {
|
1509
|
+
value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */;
|
1510
|
+
while (value2--) {
|
1511
|
+
walker.parentNode();
|
1512
|
+
}
|
1513
|
+
walker.nextSibling();
|
1514
|
+
} else {
|
1515
|
+
if (value2 < 117 /* Multiplier */ || value2 > 126 /* MultiplierEnd */) {
|
1516
|
+
throw new Error(`Unknown walk code: ${value2}`);
|
1517
|
+
}
|
1518
|
+
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
|
1519
|
+
}
|
1520
|
+
}
|
1521
|
+
}
|
1522
|
+
function getDebugKey(index, node) {
|
1523
|
+
if (typeof node === "string") {
|
1524
|
+
return `${node}/${index}`;
|
1525
|
+
} else if (node.nodeType === 3 /* Text */) {
|
1526
|
+
return `#text/${index}`;
|
1527
|
+
} else if (node.nodeType === 8 /* Comment */) {
|
1528
|
+
return `#comment/${index}`;
|
1529
|
+
} else if (node.nodeType === 1 /* Element */) {
|
1530
|
+
return `#${node.tagName.toLowerCase()}/${index}`;
|
1531
|
+
}
|
1532
|
+
return index;
|
1533
|
+
}
|
1534
|
+
|
1535
|
+
// src/dom/renderer.ts
|
1536
|
+
function createBranch($global, renderer, parentScope, parentNode) {
|
1537
|
+
const branch = createScope($global);
|
1538
|
+
const parentBranch = parentScope?.___closestBranch;
|
1539
|
+
branch["_" /* Owner */] = renderer.___owner || parentScope;
|
1540
|
+
branch.___closestBranch = branch;
|
1541
|
+
if (parentBranch) {
|
1542
|
+
branch.___parentBranch = parentBranch;
|
1543
|
+
(parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
|
1544
|
+
}
|
1545
|
+
if (true) {
|
1546
|
+
branch.___renderer = renderer;
|
1547
|
+
}
|
1548
|
+
renderer.___clone?.(
|
1549
|
+
branch,
|
1550
|
+
parentNode.namespaceURI
|
1551
|
+
);
|
1552
|
+
return branch;
|
1553
|
+
}
|
1554
|
+
function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
1555
|
+
return setupBranch(
|
1556
|
+
renderer,
|
1557
|
+
createBranch($global, renderer, parentScope, parentNode)
|
1558
|
+
);
|
1559
|
+
}
|
1560
|
+
function setupBranch(renderer, branch) {
|
1561
|
+
if (renderer.___setup) {
|
1562
|
+
queueRender(branch, renderer.___setup, -1);
|
1563
|
+
}
|
1564
|
+
return branch;
|
1565
|
+
}
|
1566
|
+
function createContent(id, template, walks, setup, params, dynamicScopesAccessor) {
|
1567
|
+
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
1568
|
+
setup = setup ? setup._ || setup : void 0;
|
1569
|
+
params ||= void 0;
|
1570
|
+
const clone = template ? (branch, ns) => {
|
1571
|
+
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
|
1572
|
+
template,
|
1573
|
+
ns
|
1574
|
+
))(branch, walks);
|
1575
|
+
} : (branch) => {
|
1576
|
+
walk(
|
1577
|
+
branch.___startNode = branch.___endNode = new Text(),
|
1578
|
+
walks,
|
1579
|
+
branch
|
1580
|
+
);
|
1581
|
+
};
|
1582
|
+
return (owner) => {
|
1583
|
+
return {
|
1584
|
+
___id: id,
|
1585
|
+
___clone: clone,
|
1586
|
+
___owner: owner,
|
1587
|
+
___setup: setup,
|
1588
|
+
___params: params,
|
1589
|
+
___accessor: dynamicScopesAccessor
|
1590
|
+
};
|
1591
|
+
};
|
1592
|
+
}
|
1593
|
+
function registerContent(id, template, walks, setup, params, dynamicScopesAccessor) {
|
1594
|
+
return register(
|
1595
|
+
id,
|
1596
|
+
createContent(id, template, walks, setup, params, dynamicScopesAccessor)
|
1597
|
+
);
|
1598
|
+
}
|
1599
|
+
function localClosures(renderer, closureFns) {
|
1600
|
+
const closureSignals = {};
|
1601
|
+
for (const key in closureFns) {
|
1602
|
+
closureSignals[key] = value(key, closureFns[key]);
|
1603
|
+
}
|
1604
|
+
return (owner, closureValues) => {
|
1605
|
+
const instance = renderer(owner);
|
1606
|
+
instance.___localClosures = closureSignals;
|
1607
|
+
instance.___localClosureValues = closureValues;
|
1608
|
+
return instance;
|
1609
|
+
};
|
1610
|
+
}
|
1611
|
+
function createRenderer(template, walks, setup, params) {
|
1612
|
+
return createContent("", template, walks, setup, params)();
|
1613
|
+
}
|
1614
|
+
var cloneCache = {};
|
1615
|
+
function createCloneableHTML(html2, ns) {
|
1616
|
+
const { firstChild, lastChild } = parseHTML(html2, ns);
|
1617
|
+
const parent = document.createElementNS(ns, "t");
|
1618
|
+
insertChildNodes(parent, null, firstChild, lastChild);
|
1619
|
+
return firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
|
1620
|
+
walk(
|
1621
|
+
branch.___startNode = branch.___endNode = firstChild.cloneNode(true),
|
1622
|
+
walks,
|
1623
|
+
branch
|
1624
|
+
);
|
1625
|
+
} : (branch, walks) => {
|
1626
|
+
const clone = parent.cloneNode(true);
|
1627
|
+
walk(clone.firstChild, walks, branch);
|
1628
|
+
branch.___startNode = clone.firstChild;
|
1629
|
+
branch.___endNode = clone.lastChild;
|
1630
|
+
};
|
1631
|
+
}
|
1632
|
+
|
1637
1633
|
// src/dom/control-flow.ts
|
1638
1634
|
function awaitTag(nodeAccessor, renderer) {
|
1639
1635
|
const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
|
@@ -1845,26 +1841,35 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
1845
1841
|
}
|
1846
1842
|
}
|
1847
1843
|
if (normalizedRenderer) {
|
1844
|
+
const childScope = scope[childScopeAccessor];
|
1848
1845
|
const args = getInput?.();
|
1849
1846
|
if (typeof normalizedRenderer === "string") {
|
1850
1847
|
attrs(
|
1851
|
-
|
1848
|
+
childScope,
|
1852
1849
|
true ? `#${normalizedRenderer}/0` : 0,
|
1853
1850
|
(inputIsArgs ? args[0] : args) || {}
|
1854
1851
|
);
|
1855
|
-
} else
|
1856
|
-
|
1857
|
-
normalizedRenderer.
|
1858
|
-
|
1859
|
-
normalizedRenderer.
|
1860
|
-
);
|
1861
|
-
} else {
|
1862
|
-
const inputWithContent = getContent ? { ...args, content: getContent(scope) } : args || {};
|
1863
|
-
normalizedRenderer.___params(
|
1864
|
-
scope[childScopeAccessor],
|
1865
|
-
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
1852
|
+
} else {
|
1853
|
+
for (const accessor in normalizedRenderer.___localClosures) {
|
1854
|
+
normalizedRenderer.___localClosures[accessor](
|
1855
|
+
childScope,
|
1856
|
+
normalizedRenderer.___localClosureValues[accessor]
|
1866
1857
|
);
|
1867
1858
|
}
|
1859
|
+
if (normalizedRenderer.___params) {
|
1860
|
+
if (inputIsArgs) {
|
1861
|
+
normalizedRenderer.___params(
|
1862
|
+
childScope,
|
1863
|
+
normalizedRenderer._ ? args[0] : args
|
1864
|
+
);
|
1865
|
+
} else {
|
1866
|
+
const inputWithContent = getContent ? { ...args, content: getContent(scope) } : args || {};
|
1867
|
+
normalizedRenderer.___params(
|
1868
|
+
childScope,
|
1869
|
+
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
1870
|
+
);
|
1871
|
+
}
|
1872
|
+
}
|
1868
1873
|
}
|
1869
1874
|
}
|
1870
1875
|
};
|