marko 6.0.0-next.3.50 → 6.0.0-next.3.52
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 +6 -7
- package/dist/debug/dom.js +103 -69
- package/dist/debug/dom.mjs +103 -69
- package/dist/dom/compat.d.ts +1 -1
- package/dist/dom/renderer.d.ts +9 -6
- package/dist/dom/signals.d.ts +5 -9
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +103 -76
- package/dist/dom.mjs +103 -76
- package/dist/translator/index.js +194 -142
- package/dist/translator/util/references.d.ts +3 -2
- package/dist/translator/util/sections.d.ts +6 -1
- package/dist/translator/util/signals.d.ts +2 -3
- package/package.json +1 -1
package/dist/debug/dom.mjs
CHANGED
@@ -1321,21 +1321,6 @@ function getDebugKey(index, node) {
|
|
1321
1321
|
}
|
1322
1322
|
|
1323
1323
|
// src/dom/renderer.ts
|
1324
|
-
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
1325
|
-
const branch = createBranch(
|
1326
|
-
$global,
|
1327
|
-
tagNameOrRenderer,
|
1328
|
-
parentScope,
|
1329
|
-
parentNode
|
1330
|
-
);
|
1331
|
-
if (typeof tagNameOrRenderer === "string") {
|
1332
|
-
branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
|
1333
|
-
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
1334
|
-
tagNameOrRenderer
|
1335
|
-
);
|
1336
|
-
}
|
1337
|
-
return branch;
|
1338
|
-
}
|
1339
1324
|
function createBranch($global, renderer, parentScope, parentNode) {
|
1340
1325
|
const branch = createScope($global);
|
1341
1326
|
const parentBranch = parentScope?.___closestBranch;
|
@@ -1348,49 +1333,76 @@ function createBranch($global, renderer, parentScope, parentNode) {
|
|
1348
1333
|
if (true) {
|
1349
1334
|
branch.___renderer = renderer;
|
1350
1335
|
}
|
1351
|
-
renderer.
|
1336
|
+
renderer.___clone?.(
|
1352
1337
|
branch,
|
1353
1338
|
parentNode.namespaceURI
|
1354
1339
|
);
|
1355
1340
|
return branch;
|
1356
1341
|
}
|
1357
|
-
function
|
1342
|
+
function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
1343
|
+
return setupBranch(
|
1344
|
+
renderer,
|
1345
|
+
createBranch($global, renderer, parentScope, parentNode)
|
1346
|
+
);
|
1347
|
+
}
|
1348
|
+
function setupBranch(renderer, branch) {
|
1349
|
+
if (renderer.___setup || renderer.___closures) {
|
1350
|
+
queueRender(
|
1351
|
+
branch,
|
1352
|
+
(branch2) => {
|
1353
|
+
renderer.___setup?.(branch2);
|
1354
|
+
renderer.___closures?.(branch2);
|
1355
|
+
},
|
1356
|
+
-1
|
1357
|
+
);
|
1358
|
+
}
|
1359
|
+
return branch;
|
1360
|
+
}
|
1361
|
+
function createContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
1358
1362
|
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
1359
|
-
|
1360
|
-
|
1363
|
+
setup ||= void 0;
|
1364
|
+
params ||= void 0;
|
1365
|
+
closures ||= void 0;
|
1366
|
+
const clone = template ? (branch, ns) => {
|
1361
1367
|
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
|
1362
1368
|
template,
|
1363
1369
|
ns
|
1364
1370
|
))(branch, walks);
|
1365
|
-
setup && queueRender(branch, setup, -1);
|
1366
1371
|
} : (branch) => {
|
1367
1372
|
walk(
|
1368
1373
|
branch.___startNode = branch.___endNode = new Text(),
|
1369
1374
|
walks,
|
1370
1375
|
branch
|
1371
1376
|
);
|
1372
|
-
setup && queueRender(branch, setup, -1);
|
1373
1377
|
};
|
1374
1378
|
return (owner) => {
|
1375
1379
|
return {
|
1376
1380
|
___id: id,
|
1377
|
-
|
1381
|
+
___clone: clone,
|
1378
1382
|
___owner: owner,
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
+
___setup: setup,
|
1384
|
+
___params: params,
|
1385
|
+
___closures: closures,
|
1386
|
+
___accessor: dynamicScopesAccessor
|
1383
1387
|
};
|
1384
1388
|
};
|
1385
1389
|
}
|
1386
|
-
function registerContent(id, template, walks, setup,
|
1390
|
+
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
1387
1391
|
return register(
|
1388
1392
|
id,
|
1389
|
-
createContent(
|
1393
|
+
createContent(
|
1394
|
+
id,
|
1395
|
+
template,
|
1396
|
+
walks,
|
1397
|
+
setup,
|
1398
|
+
params,
|
1399
|
+
closures,
|
1400
|
+
dynamicScopesAccessor
|
1401
|
+
)
|
1390
1402
|
);
|
1391
1403
|
}
|
1392
|
-
function createRenderer(template, walks, setup,
|
1393
|
-
return createContent("", template, walks, setup,
|
1404
|
+
function createRenderer(template, walks, setup, params, closures) {
|
1405
|
+
return createContent("", template, walks, setup, params, closures)();
|
1394
1406
|
}
|
1395
1407
|
var cloneCache = {};
|
1396
1408
|
function createCloneableHTML(html2, ns) {
|
@@ -1501,7 +1513,6 @@ function value(valueAccessor, fn = () => {
|
|
1501
1513
|
}
|
1502
1514
|
};
|
1503
1515
|
}
|
1504
|
-
var accessorId = 0;
|
1505
1516
|
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "___id") {
|
1506
1517
|
return (scope) => {
|
1507
1518
|
if (scope.___pending) {
|
@@ -1564,34 +1575,39 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
1564
1575
|
);
|
1565
1576
|
}
|
1566
1577
|
}
|
1567
|
-
function dynamicClosure(
|
1568
|
-
const
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1578
|
+
function dynamicClosure(...closureSignals) {
|
1579
|
+
const [{ ___scopeInstancesAccessor, ___signalIndexAccessor }] = closureSignals;
|
1580
|
+
for (let i = closureSignals.length; i--; ) {
|
1581
|
+
closureSignals[i].___index = i;
|
1582
|
+
}
|
1583
|
+
return (scope) => {
|
1584
|
+
if (scope[___scopeInstancesAccessor]) {
|
1585
|
+
for (const childScope of scope[___scopeInstancesAccessor]) {
|
1586
|
+
if (!childScope.___pending) {
|
1587
|
+
queueRender(
|
1588
|
+
childScope,
|
1589
|
+
closureSignals[childScope[___signalIndexAccessor]],
|
1590
|
+
-1
|
1591
|
+
);
|
1576
1592
|
}
|
1577
1593
|
}
|
1578
1594
|
}
|
1579
1595
|
};
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
ownerSignal._ = (scope) => {
|
1596
|
+
}
|
1597
|
+
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
1598
|
+
const childSignal = closure(valueAccessor, fn, getOwnerScope);
|
1599
|
+
const closureSignal = (scope) => {
|
1600
|
+
scope[closureSignal.___signalIndexAccessor] = closureSignal.___index;
|
1586
1601
|
childSignal(scope);
|
1587
|
-
|
1602
|
+
subscribeToScopeSet(
|
1603
|
+
getOwnerScope ? getOwnerScope(scope) : scope._,
|
1604
|
+
closureSignal.___scopeInstancesAccessor,
|
1605
|
+
scope
|
1606
|
+
);
|
1588
1607
|
};
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
const signal = dynamicClosure(valueAccessor, fn, getOwnerScope);
|
1593
|
-
register(registryId, signal.___subscribe);
|
1594
|
-
return signal;
|
1608
|
+
closureSignal.___scopeInstancesAccessor = valueAccessor + "!" /* ClosureScopes */;
|
1609
|
+
closureSignal.___signalIndexAccessor = valueAccessor + "(" /* ClosureSignalIndex */;
|
1610
|
+
return closureSignal;
|
1595
1611
|
}
|
1596
1612
|
function closure(valueAccessor, fn, getOwnerScope) {
|
1597
1613
|
return (scope) => {
|
@@ -1648,7 +1664,7 @@ function conditional(nodeAccessor, ...branches) {
|
|
1648
1664
|
scope,
|
1649
1665
|
nodeAccessor,
|
1650
1666
|
branches[scope[branchAccessor] = newBranch],
|
1651
|
-
|
1667
|
+
createAndSetupBranch
|
1652
1668
|
);
|
1653
1669
|
}
|
1654
1670
|
};
|
@@ -1678,7 +1694,7 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
1678
1694
|
scope[childScopeAccessor],
|
1679
1695
|
true ? `#${normalizedRenderer}/0` : 0,
|
1680
1696
|
content,
|
1681
|
-
|
1697
|
+
createAndSetupBranch
|
1682
1698
|
);
|
1683
1699
|
if (content.___accessor) {
|
1684
1700
|
subscribeToScopeSet(
|
@@ -1704,9 +1720,9 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
1704
1720
|
true ? `#${normalizedRenderer}/0` : 0,
|
1705
1721
|
(inputIsArgs ? args[0] : args) || {}
|
1706
1722
|
);
|
1707
|
-
} else if (normalizedRenderer.
|
1723
|
+
} else if (normalizedRenderer.___params) {
|
1708
1724
|
if (inputIsArgs) {
|
1709
|
-
normalizedRenderer.
|
1725
|
+
normalizedRenderer.___params(
|
1710
1726
|
scope[childScopeAccessor],
|
1711
1727
|
normalizedRenderer._ ? args[0] : args
|
1712
1728
|
);
|
@@ -1715,7 +1731,7 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
1715
1731
|
...args,
|
1716
1732
|
content: getContent(scope)
|
1717
1733
|
} : args || {};
|
1718
|
-
normalizedRenderer.
|
1734
|
+
normalizedRenderer.___params(
|
1719
1735
|
scope[childScopeAccessor],
|
1720
1736
|
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
1721
1737
|
);
|
@@ -1780,7 +1796,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1780
1796
|
);
|
1781
1797
|
}
|
1782
1798
|
function loop(nodeAccessor, renderer, forEach) {
|
1783
|
-
const params = renderer.
|
1799
|
+
const params = renderer.___params;
|
1784
1800
|
return (scope, value2) => {
|
1785
1801
|
const referenceNode = scope[nodeAccessor];
|
1786
1802
|
const oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */];
|
@@ -1791,7 +1807,7 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1791
1807
|
const newMap = scope[nodeAccessor + "(" /* LoopScopeMap */] = /* @__PURE__ */ new Map();
|
1792
1808
|
const newArray = scope[nodeAccessor + "!" /* LoopScopeArray */] = [];
|
1793
1809
|
forEach(value2, (key, args) => {
|
1794
|
-
const branch = oldMap?.get(key) ||
|
1810
|
+
const branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
|
1795
1811
|
params?.(branch, args);
|
1796
1812
|
newMap.set(key, branch);
|
1797
1813
|
newArray.push(branch);
|
@@ -1811,6 +1827,23 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1811
1827
|
reconcile(parentNode, oldArray, newArray, afterReference);
|
1812
1828
|
};
|
1813
1829
|
}
|
1830
|
+
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
1831
|
+
const branch = createBranch(
|
1832
|
+
$global,
|
1833
|
+
tagNameOrRenderer,
|
1834
|
+
parentScope,
|
1835
|
+
parentNode
|
1836
|
+
);
|
1837
|
+
if (typeof tagNameOrRenderer === "string") {
|
1838
|
+
branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
|
1839
|
+
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
1840
|
+
tagNameOrRenderer
|
1841
|
+
);
|
1842
|
+
} else {
|
1843
|
+
setupBranch(tagNameOrRenderer, branch);
|
1844
|
+
}
|
1845
|
+
return branch;
|
1846
|
+
}
|
1814
1847
|
function bySecondArg(_item, index) {
|
1815
1848
|
return index;
|
1816
1849
|
}
|
@@ -1833,7 +1866,7 @@ var compat = {
|
|
1833
1866
|
register(RENDERER_REGISTER_ID, fn);
|
1834
1867
|
},
|
1835
1868
|
isRenderer(renderer) {
|
1836
|
-
return renderer.
|
1869
|
+
return renderer.___clone;
|
1837
1870
|
},
|
1838
1871
|
getStartNode(branch) {
|
1839
1872
|
return branch.___startNode;
|
@@ -1862,9 +1895,9 @@ var compat = {
|
|
1862
1895
|
}
|
1863
1896
|
return value2;
|
1864
1897
|
},
|
1865
|
-
createRenderer(
|
1866
|
-
const renderer = createRenderer(0, 0, 0,
|
1867
|
-
renderer.
|
1898
|
+
createRenderer(params, clone) {
|
1899
|
+
const renderer = createRenderer(0, 0, 0, params);
|
1900
|
+
renderer.___clone = (branch) => {
|
1868
1901
|
const cloned = clone();
|
1869
1902
|
branch.___startNode = cloned.startNode;
|
1870
1903
|
branch.___endNode = cloned.endNode;
|
@@ -1891,7 +1924,7 @@ var compat = {
|
|
1891
1924
|
component.effects = prepareEffects(() => {
|
1892
1925
|
if (!branch) {
|
1893
1926
|
out.global.___nextScopeId ||= 0;
|
1894
|
-
branch = component.scope =
|
1927
|
+
branch = component.scope = createAndSetupBranch(
|
1895
1928
|
out.global,
|
1896
1929
|
renderer,
|
1897
1930
|
renderer.___owner,
|
@@ -1900,7 +1933,7 @@ var compat = {
|
|
1900
1933
|
} else {
|
1901
1934
|
existing = true;
|
1902
1935
|
}
|
1903
|
-
renderer.
|
1936
|
+
renderer.___params?.(branch, renderer._ ? args[0] : args);
|
1904
1937
|
});
|
1905
1938
|
if (!existing) {
|
1906
1939
|
return toInsertNode(branch.___startNode, branch.___endNode);
|
@@ -1915,7 +1948,7 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
|
|
1915
1948
|
template,
|
1916
1949
|
walks,
|
1917
1950
|
setup,
|
1918
|
-
inputSignal
|
1951
|
+
inputSignal
|
1919
1952
|
)();
|
1920
1953
|
renderer.mount = mount;
|
1921
1954
|
renderer._ = renderer;
|
@@ -1961,7 +1994,7 @@ function mount(input = {}, reference, position) {
|
|
1961
1994
|
nextSibling = reference.nextSibling;
|
1962
1995
|
break;
|
1963
1996
|
}
|
1964
|
-
const args = this.
|
1997
|
+
const args = this.___params;
|
1965
1998
|
const effects = prepareEffects(() => {
|
1966
1999
|
branch = createBranch(
|
1967
2000
|
$global,
|
@@ -1969,6 +2002,7 @@ function mount(input = {}, reference, position) {
|
|
1969
2002
|
void 0,
|
1970
2003
|
parentNode
|
1971
2004
|
);
|
2005
|
+
this.___setup?.(branch);
|
1972
2006
|
args?.(branch, input);
|
1973
2007
|
});
|
1974
2008
|
insertChildNodes(
|
@@ -2020,6 +2054,7 @@ export {
|
|
2020
2054
|
createTemplate,
|
2021
2055
|
data,
|
2022
2056
|
dynamicClosure,
|
2057
|
+
dynamicClosureRead,
|
2023
2058
|
dynamicTag,
|
2024
2059
|
effect,
|
2025
2060
|
forIn,
|
@@ -2043,7 +2078,6 @@ export {
|
|
2043
2078
|
register,
|
2044
2079
|
registerBoundSignal,
|
2045
2080
|
registerContent,
|
2046
|
-
registerDynamicClosure,
|
2047
2081
|
resetAbortSignal,
|
2048
2082
|
run,
|
2049
2083
|
setTagVar,
|
package/dist/dom/compat.d.ts
CHANGED
@@ -15,7 +15,7 @@ export declare const compat: {
|
|
15
15
|
runtimeId: string;
|
16
16
|
componentIdPrefix: string;
|
17
17
|
}): any;
|
18
|
-
createRenderer(
|
18
|
+
createRenderer(params: NonNullable<Renderer["___params"]>, clone: () => {
|
19
19
|
startNode: ChildNode;
|
20
20
|
endNode: ChildNode;
|
21
21
|
}): Renderer;
|
package/dist/dom/renderer.d.ts
CHANGED
@@ -2,15 +2,18 @@ import { type Accessor, type BranchScope, type Scope } from "../common/types";
|
|
2
2
|
import type { Signal } from "./signals";
|
3
3
|
export type Renderer = {
|
4
4
|
___id: string;
|
5
|
-
|
6
|
-
|
5
|
+
___setup: undefined | ((branch: BranchScope) => void);
|
6
|
+
___clone: (branch: BranchScope, ns: string) => void;
|
7
|
+
___params: Signal<unknown> | undefined;
|
8
|
+
___closures: SetupFn | undefined;
|
7
9
|
___owner: Scope | undefined;
|
8
10
|
___accessor: Accessor | undefined;
|
9
11
|
};
|
10
12
|
type SetupFn = (scope: Scope) => void;
|
11
|
-
export declare function createBranchWithTagNameOrRenderer($global: Scope["$global"], tagNameOrRenderer: Renderer | string, parentScope: Scope, parentNode: ParentNode): BranchScope;
|
12
13
|
export declare function createBranch($global: Scope["$global"], renderer: Renderer | string, parentScope: Scope | undefined, parentNode: ParentNode): BranchScope;
|
13
|
-
export declare function
|
14
|
-
export declare function
|
15
|
-
export declare function
|
14
|
+
export declare function createAndSetupBranch($global: Scope["$global"], renderer: Renderer, parentScope: Scope | undefined, parentNode: ParentNode): BranchScope;
|
15
|
+
export declare function setupBranch(renderer: Renderer, branch: BranchScope): BranchScope;
|
16
|
+
export declare function createContent(id: string, template: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown> | 0, closures?: Signal<unknown> | 0, dynamicScopesAccessor?: Accessor): (owner?: Scope) => Renderer;
|
17
|
+
export declare function registerContent(id: string, template: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown> | 0, closures?: Signal<unknown> | 0, dynamicScopesAccessor?: Accessor): (owner?: Scope) => Renderer;
|
18
|
+
export declare function createRenderer(template: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown> | 0, closures?: Signal<unknown> | 0): Renderer;
|
16
19
|
export {};
|
package/dist/dom/signals.d.ts
CHANGED
@@ -9,15 +9,11 @@ export declare function intersection(id: number, fn: SignalFn<never>, defaultPen
|
|
9
9
|
export declare function loopClosure<T>(valueAccessor: Accessor, ownerLoopNodeAccessor: Accessor, fn: SignalFn<T>): SignalFn<T>;
|
10
10
|
export declare function conditionalClosure<T>(valueAccessor: Accessor, ownerConditionalNodeAccessor: Accessor, branch: number, fn: SignalFn<T>): SignalFn<T>;
|
11
11
|
export declare function subscribeToScopeSet(ownerScope: Scope, accessor: Accessor, scope: Scope): void;
|
12
|
-
export declare function dynamicClosure
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
export declare function registerDynamicClosure<T>(registryId: string, valueAccessor: Accessor, fn: Signal<T>, getOwnerScope?: (scope: Scope) => Scope): {
|
18
|
-
(ownerScope: Scope): void;
|
19
|
-
___subscribe(scope: Scope): void;
|
20
|
-
_(scope: Scope): void;
|
12
|
+
export declare function dynamicClosure(...closureSignals: ReturnType<typeof dynamicClosureRead>[]): (scope: Scope) => void;
|
13
|
+
export declare function dynamicClosureRead<T>(valueAccessor: Accessor, fn: Signal<T>, getOwnerScope?: (scope: Scope) => Scope): ((scope: Scope) => void) & {
|
14
|
+
___scopeInstancesAccessor: string;
|
15
|
+
___signalIndexAccessor: string;
|
16
|
+
___index: number;
|
21
17
|
};
|
22
18
|
export declare function setTagVar(scope: Scope, childAccessor: Accessor, tagVarSignal: Signal<unknown>): void;
|
23
19
|
export declare const tagVarSignal: (scope: Scope, value: unknown) => any;
|
package/dist/dom.d.ts
CHANGED
@@ -9,5 +9,5 @@ export { on } from "./dom/event";
|
|
9
9
|
export { run } from "./dom/queue";
|
10
10
|
export { createContent, createRenderer, registerContent } from "./dom/renderer";
|
11
11
|
export { init, nodeRef, register, registerBoundSignal } from "./dom/resume";
|
12
|
-
export { conditionalClosure, dynamicClosure, effect, hoist, intersection, loopClosure, nextTagId,
|
12
|
+
export { conditionalClosure, dynamicClosure, dynamicClosureRead, effect, hoist, intersection, loopClosure, nextTagId, setTagVar, setTagVarChange, state, tagVarSignal, tagVarSignalChange, value, } from "./dom/signals";
|
13
13
|
export { createTemplate } from "./dom/template";
|