@marko/runtime-tags 0.3.49 → 0.3.51

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.
@@ -5,7 +5,6 @@ export interface BranchScope extends Scope {
5
5
  ___startNode: ChildNode;
6
6
  ___endNode: ChildNode;
7
7
  ___parentBranch: BranchScope | undefined;
8
- ___branchDepth: number;
9
8
  ___destroyed: 1 | undefined;
10
9
  ___abortScopes: Set<Scope> | undefined;
11
10
  ___branchScopes: Set<BranchScope> | undefined;
package/dist/debug/dom.js CHANGED
@@ -1333,11 +1333,6 @@ function longestIncreasingSubsequence(a) {
1333
1333
 
1334
1334
  // src/dom/walker.ts
1335
1335
  var walker = /* @__PURE__ */ document.createTreeWalker(document);
1336
- function trimWalkString(walkString) {
1337
- let end = walkString.length;
1338
- while (walkString.charCodeAt(--end) > 49 /* DynamicTagWithVar */) ;
1339
- return walkString.slice(0, end + 1);
1340
- }
1341
1336
  function walk(startNode, walkCodes, branch) {
1342
1337
  walker.currentNode = startNode;
1343
1338
  walkInternal(0, walkCodes, branch);
@@ -1411,63 +1406,44 @@ function getDebugKey(index, node) {
1411
1406
  }
1412
1407
 
1413
1408
  // src/dom/renderer.ts
1414
- function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
1415
- const branch = createBranch(
1416
- $global,
1417
- tagNameOrRenderer,
1418
- parentScope,
1419
- parentNode
1420
- );
1421
- if (typeof tagNameOrRenderer === "string") {
1422
- branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
1423
- tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
1424
- tagNameOrRenderer
1425
- );
1426
- }
1427
- return branch;
1428
- }
1429
1409
  function createBranch($global, renderer, parentScope, parentNode) {
1430
1410
  const branch = createScope($global);
1431
1411
  const parentBranch = parentScope?.___closestBranch;
1432
1412
  branch._ = renderer.___owner || parentScope;
1433
1413
  branch.___closestBranch = branch;
1434
1414
  if (parentBranch) {
1435
- branch.___branchDepth = parentBranch.___branchDepth + 1;
1436
1415
  branch.___parentBranch = parentBranch;
1437
1416
  (parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
1438
- } else {
1439
- branch.___branchDepth = 1;
1440
1417
  }
1441
1418
  if (true) {
1442
1419
  branch.___renderer = renderer;
1443
1420
  }
1444
- renderer.___init?.(
1421
+ renderer.___clone?.(
1445
1422
  branch,
1446
1423
  parentNode.namespaceURI
1447
1424
  );
1448
1425
  return branch;
1449
1426
  }
1450
- function createContent(id, template, rawWalks, setup, getArgs, dynamicScopesAccessor) {
1427
+ function createContent(id, template, walks, setup, getArgs, dynamicScopesAccessor) {
1428
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
1451
1429
  let args;
1452
- const walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : "";
1453
- const init2 = template ? (branch, ns) => {
1430
+ const clone = template ? (branch, ns) => {
1454
1431
  ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
1455
1432
  template,
1456
1433
  ns
1457
1434
  ))(branch, walks);
1458
- setup && queueRender(branch, setup, -1);
1459
1435
  } : (branch) => {
1460
1436
  walk(
1461
1437
  branch.___startNode = branch.___endNode = new Text(),
1462
1438
  walks,
1463
1439
  branch
1464
1440
  );
1465
- setup && queueRender(branch, setup, -1);
1466
1441
  };
1467
1442
  return (owner) => {
1468
1443
  return {
1469
1444
  ___id: id,
1470
- ___init: init2,
1445
+ ___clone: clone,
1446
+ ___setup: setup,
1471
1447
  ___owner: owner,
1472
1448
  ___accessor: dynamicScopesAccessor,
1473
1449
  get ___args() {
@@ -1741,7 +1717,7 @@ function conditional(nodeAccessor, ...branches) {
1741
1717
  scope,
1742
1718
  nodeAccessor,
1743
1719
  branches[scope[branchAccessor] = newBranch],
1744
- createBranch
1720
+ createAndSetupBranch
1745
1721
  );
1746
1722
  }
1747
1723
  };
@@ -1771,7 +1747,7 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
1771
1747
  scope[childScopeAccessor],
1772
1748
  true ? `#${normalizedRenderer}/0` : 0,
1773
1749
  content,
1774
- createBranch
1750
+ createAndSetupBranch
1775
1751
  );
1776
1752
  if (content.___accessor) {
1777
1753
  subscribeToScopeSet(
@@ -1884,7 +1860,7 @@ function loop(nodeAccessor, renderer, forEach) {
1884
1860
  const newMap = scope[nodeAccessor + "(" /* LoopScopeMap */] = /* @__PURE__ */ new Map();
1885
1861
  const newArray = scope[nodeAccessor + "!" /* LoopScopeArray */] = [];
1886
1862
  forEach(value2, (key, args) => {
1887
- const branch = oldMap?.get(key) || createBranch(scope.$global, renderer, scope, parentNode);
1863
+ const branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
1888
1864
  params?.(branch, args);
1889
1865
  newMap.set(key, branch);
1890
1866
  newArray.push(branch);
@@ -1904,6 +1880,28 @@ function loop(nodeAccessor, renderer, forEach) {
1904
1880
  reconcile(parentNode, oldArray, newArray, afterReference);
1905
1881
  };
1906
1882
  }
1883
+ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
1884
+ const branch = createBranch($global, renderer, parentScope, parentNode);
1885
+ renderer.___setup && queueRender(branch, renderer.___setup, -1);
1886
+ return branch;
1887
+ }
1888
+ function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
1889
+ const branch = createBranch(
1890
+ $global,
1891
+ tagNameOrRenderer,
1892
+ parentScope,
1893
+ parentNode
1894
+ );
1895
+ if (typeof tagNameOrRenderer === "string") {
1896
+ branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
1897
+ tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
1898
+ tagNameOrRenderer
1899
+ );
1900
+ } else if (tagNameOrRenderer.___setup) {
1901
+ queueRender(branch, tagNameOrRenderer.___setup, -1);
1902
+ }
1903
+ return branch;
1904
+ }
1907
1905
  function bySecondArg(_item, index) {
1908
1906
  return index;
1909
1907
  }
@@ -1926,7 +1924,7 @@ var compat = {
1926
1924
  register(RENDERER_REGISTER_ID, fn);
1927
1925
  },
1928
1926
  isRenderer(renderer) {
1929
- return renderer.___init;
1927
+ return renderer.___clone;
1930
1928
  },
1931
1929
  getStartNode(branch) {
1932
1930
  return branch.___startNode;
@@ -1957,7 +1955,7 @@ var compat = {
1957
1955
  },
1958
1956
  createRenderer(args, clone) {
1959
1957
  const renderer = createRenderer(0, 0, 0, () => args);
1960
- renderer.___init = (branch) => {
1958
+ renderer.___clone = (branch) => {
1961
1959
  const cloned = clone();
1962
1960
  branch.___startNode = cloned.startNode;
1963
1961
  branch.___endNode = cloned.endNode;
@@ -1990,6 +1988,7 @@ var compat = {
1990
1988
  renderer.___owner,
1991
1989
  document.body
1992
1990
  );
1991
+ renderer.___setup && renderer.___setup(branch);
1993
1992
  } else {
1994
1993
  existing = true;
1995
1994
  }
@@ -2002,11 +2001,11 @@ var compat = {
2002
2001
  };
2003
2002
 
2004
2003
  // src/dom/template.ts
2005
- var createTemplate = (id, template, rawWalks, setup, inputSignal) => {
2004
+ var createTemplate = (id, template, walks, setup, inputSignal) => {
2006
2005
  const renderer = createContent(
2007
2006
  id,
2008
2007
  template,
2009
- rawWalks,
2008
+ walks,
2010
2009
  setup,
2011
2010
  inputSignal && (() => inputSignal)
2012
2011
  )();
@@ -2062,7 +2061,8 @@ function mount(input = {}, reference, position) {
2062
2061
  void 0,
2063
2062
  parentNode
2064
2063
  );
2065
- args?.(branch, input);
2064
+ this.___setup && this.___setup(branch);
2065
+ args && args(branch, input);
2066
2066
  });
2067
2067
  insertChildNodes(
2068
2068
  parentNode,
@@ -1248,11 +1248,6 @@ function longestIncreasingSubsequence(a) {
1248
1248
 
1249
1249
  // src/dom/walker.ts
1250
1250
  var walker = /* @__PURE__ */ document.createTreeWalker(document);
1251
- function trimWalkString(walkString) {
1252
- let end = walkString.length;
1253
- while (walkString.charCodeAt(--end) > 49 /* DynamicTagWithVar */) ;
1254
- return walkString.slice(0, end + 1);
1255
- }
1256
1251
  function walk(startNode, walkCodes, branch) {
1257
1252
  walker.currentNode = startNode;
1258
1253
  walkInternal(0, walkCodes, branch);
@@ -1326,63 +1321,44 @@ function getDebugKey(index, node) {
1326
1321
  }
1327
1322
 
1328
1323
  // src/dom/renderer.ts
1329
- function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
1330
- const branch = createBranch(
1331
- $global,
1332
- tagNameOrRenderer,
1333
- parentScope,
1334
- parentNode
1335
- );
1336
- if (typeof tagNameOrRenderer === "string") {
1337
- branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
1338
- tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
1339
- tagNameOrRenderer
1340
- );
1341
- }
1342
- return branch;
1343
- }
1344
1324
  function createBranch($global, renderer, parentScope, parentNode) {
1345
1325
  const branch = createScope($global);
1346
1326
  const parentBranch = parentScope?.___closestBranch;
1347
1327
  branch._ = renderer.___owner || parentScope;
1348
1328
  branch.___closestBranch = branch;
1349
1329
  if (parentBranch) {
1350
- branch.___branchDepth = parentBranch.___branchDepth + 1;
1351
1330
  branch.___parentBranch = parentBranch;
1352
1331
  (parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
1353
- } else {
1354
- branch.___branchDepth = 1;
1355
1332
  }
1356
1333
  if (true) {
1357
1334
  branch.___renderer = renderer;
1358
1335
  }
1359
- renderer.___init?.(
1336
+ renderer.___clone?.(
1360
1337
  branch,
1361
1338
  parentNode.namespaceURI
1362
1339
  );
1363
1340
  return branch;
1364
1341
  }
1365
- function createContent(id, template, rawWalks, setup, getArgs, dynamicScopesAccessor) {
1342
+ function createContent(id, template, walks, setup, getArgs, dynamicScopesAccessor) {
1343
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
1366
1344
  let args;
1367
- const walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : "";
1368
- const init2 = template ? (branch, ns) => {
1345
+ const clone = template ? (branch, ns) => {
1369
1346
  ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
1370
1347
  template,
1371
1348
  ns
1372
1349
  ))(branch, walks);
1373
- setup && queueRender(branch, setup, -1);
1374
1350
  } : (branch) => {
1375
1351
  walk(
1376
1352
  branch.___startNode = branch.___endNode = new Text(),
1377
1353
  walks,
1378
1354
  branch
1379
1355
  );
1380
- setup && queueRender(branch, setup, -1);
1381
1356
  };
1382
1357
  return (owner) => {
1383
1358
  return {
1384
1359
  ___id: id,
1385
- ___init: init2,
1360
+ ___clone: clone,
1361
+ ___setup: setup,
1386
1362
  ___owner: owner,
1387
1363
  ___accessor: dynamicScopesAccessor,
1388
1364
  get ___args() {
@@ -1656,7 +1632,7 @@ function conditional(nodeAccessor, ...branches) {
1656
1632
  scope,
1657
1633
  nodeAccessor,
1658
1634
  branches[scope[branchAccessor] = newBranch],
1659
- createBranch
1635
+ createAndSetupBranch
1660
1636
  );
1661
1637
  }
1662
1638
  };
@@ -1686,7 +1662,7 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
1686
1662
  scope[childScopeAccessor],
1687
1663
  true ? `#${normalizedRenderer}/0` : 0,
1688
1664
  content,
1689
- createBranch
1665
+ createAndSetupBranch
1690
1666
  );
1691
1667
  if (content.___accessor) {
1692
1668
  subscribeToScopeSet(
@@ -1799,7 +1775,7 @@ function loop(nodeAccessor, renderer, forEach) {
1799
1775
  const newMap = scope[nodeAccessor + "(" /* LoopScopeMap */] = /* @__PURE__ */ new Map();
1800
1776
  const newArray = scope[nodeAccessor + "!" /* LoopScopeArray */] = [];
1801
1777
  forEach(value2, (key, args) => {
1802
- const branch = oldMap?.get(key) || createBranch(scope.$global, renderer, scope, parentNode);
1778
+ const branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
1803
1779
  params?.(branch, args);
1804
1780
  newMap.set(key, branch);
1805
1781
  newArray.push(branch);
@@ -1819,6 +1795,28 @@ function loop(nodeAccessor, renderer, forEach) {
1819
1795
  reconcile(parentNode, oldArray, newArray, afterReference);
1820
1796
  };
1821
1797
  }
1798
+ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
1799
+ const branch = createBranch($global, renderer, parentScope, parentNode);
1800
+ renderer.___setup && queueRender(branch, renderer.___setup, -1);
1801
+ return branch;
1802
+ }
1803
+ function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
1804
+ const branch = createBranch(
1805
+ $global,
1806
+ tagNameOrRenderer,
1807
+ parentScope,
1808
+ parentNode
1809
+ );
1810
+ if (typeof tagNameOrRenderer === "string") {
1811
+ branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
1812
+ tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
1813
+ tagNameOrRenderer
1814
+ );
1815
+ } else if (tagNameOrRenderer.___setup) {
1816
+ queueRender(branch, tagNameOrRenderer.___setup, -1);
1817
+ }
1818
+ return branch;
1819
+ }
1822
1820
  function bySecondArg(_item, index) {
1823
1821
  return index;
1824
1822
  }
@@ -1841,7 +1839,7 @@ var compat = {
1841
1839
  register(RENDERER_REGISTER_ID, fn);
1842
1840
  },
1843
1841
  isRenderer(renderer) {
1844
- return renderer.___init;
1842
+ return renderer.___clone;
1845
1843
  },
1846
1844
  getStartNode(branch) {
1847
1845
  return branch.___startNode;
@@ -1872,7 +1870,7 @@ var compat = {
1872
1870
  },
1873
1871
  createRenderer(args, clone) {
1874
1872
  const renderer = createRenderer(0, 0, 0, () => args);
1875
- renderer.___init = (branch) => {
1873
+ renderer.___clone = (branch) => {
1876
1874
  const cloned = clone();
1877
1875
  branch.___startNode = cloned.startNode;
1878
1876
  branch.___endNode = cloned.endNode;
@@ -1905,6 +1903,7 @@ var compat = {
1905
1903
  renderer.___owner,
1906
1904
  document.body
1907
1905
  );
1906
+ renderer.___setup && renderer.___setup(branch);
1908
1907
  } else {
1909
1908
  existing = true;
1910
1909
  }
@@ -1917,11 +1916,11 @@ var compat = {
1917
1916
  };
1918
1917
 
1919
1918
  // src/dom/template.ts
1920
- var createTemplate = (id, template, rawWalks, setup, inputSignal) => {
1919
+ var createTemplate = (id, template, walks, setup, inputSignal) => {
1921
1920
  const renderer = createContent(
1922
1921
  id,
1923
1922
  template,
1924
- rawWalks,
1923
+ walks,
1925
1924
  setup,
1926
1925
  inputSignal && (() => inputSignal)
1927
1926
  )();
@@ -1977,7 +1976,8 @@ function mount(input = {}, reference, position) {
1977
1976
  void 0,
1978
1977
  parentNode
1979
1978
  );
1980
- args?.(branch, input);
1979
+ this.___setup && this.___setup(branch);
1980
+ args && args(branch, input);
1981
1981
  });
1982
1982
  insertChildNodes(
1983
1983
  parentNode,
@@ -2,15 +2,15 @@ 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
- ___init: (branch: BranchScope, ns: string) => void;
5
+ ___setup: undefined | 0 | ((branch: BranchScope) => void);
6
+ ___clone: (branch: BranchScope, ns: string) => void;
6
7
  ___args: Signal<unknown> | undefined;
7
8
  ___owner: Scope | undefined;
8
9
  ___accessor: Accessor | undefined;
9
10
  };
10
11
  type SetupFn = (scope: Scope) => void;
11
- export declare function createBranchWithTagNameOrRenderer($global: Scope["$global"], tagNameOrRenderer: Renderer | string, parentScope: Scope, parentNode: ParentNode): BranchScope;
12
12
  export declare function createBranch($global: Scope["$global"], renderer: Renderer | string, parentScope: Scope | undefined, parentNode: ParentNode): BranchScope;
13
- export declare function createContent(id: string, template?: string | 0, rawWalks?: string | 0, setup?: SetupFn | 0, getArgs?: (() => Signal<unknown>) | 0, dynamicScopesAccessor?: Accessor): (owner?: Scope) => Renderer;
14
- export declare function registerContent(id: string, template?: string | 0, walks?: string | 0, setup?: SetupFn | 0, getArgs?: (() => Signal<unknown>) | 0, dynamicScopesAccessor?: Accessor): (owner?: Scope) => Renderer;
15
- export declare function createRenderer(template?: string | 0, walks?: string | 0, setup?: SetupFn | 0, getArgs?: (() => Signal<unknown>) | 0): Renderer;
13
+ export declare function createContent(id: string, template: string | 0, walks?: string | 0, setup?: SetupFn | 0, getArgs?: (() => Signal<unknown>) | 0, dynamicScopesAccessor?: Accessor): (owner?: Scope) => Renderer;
14
+ export declare function registerContent(id: string, template: string | 0, walks?: string | 0, setup?: SetupFn | 0, getArgs?: (() => Signal<unknown>) | 0, dynamicScopesAccessor?: Accessor): (owner?: Scope) => Renderer;
15
+ export declare function createRenderer(template: string | 0, walks?: string | 0, setup?: SetupFn | 0, getArgs?: (() => Signal<unknown>) | 0): Renderer;
16
16
  export {};
@@ -1,3 +1,3 @@
1
1
  import type { Scope, Template } from "../common/types";
2
2
  import type { Signal } from "./signals";
3
- export declare const createTemplate: (id: string, template?: string | 0, rawWalks?: string | 0, setup?: ((scope: Scope) => void) | 0, inputSignal?: Signal<unknown>) => Template;
3
+ export declare const createTemplate: (id: string, template: string | 0, walks?: string | 0, setup?: ((scope: Scope) => void) | 0, inputSignal?: Signal<unknown>) => Template;
@@ -1,4 +1,3 @@
1
1
  import { type BranchScope } from "../common/types";
2
2
  export declare const walker: TreeWalker;
3
- export declare function trimWalkString(walkString: string): string;
4
3
  export declare function walk(startNode: Node, walkCodes: string, branch: BranchScope): void;