marko 6.0.0-next.3.82 → 6.0.0-next.3.84

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.
@@ -1666,6 +1666,12 @@ var K_SCOPE_ID = Symbol("Scope ID");
1666
1666
  function getChunk() {
1667
1667
  return $chunk;
1668
1668
  }
1669
+ function getContext(key) {
1670
+ return $chunk.context?.[key];
1671
+ }
1672
+ function getState() {
1673
+ return $chunk.boundary.state;
1674
+ }
1669
1675
  function getScopeId(scope) {
1670
1676
  return scope[K_SCOPE_ID];
1671
1677
  }
@@ -2592,8 +2598,8 @@ function styleAttr(value) {
2592
2598
  return stringAttr("style", styleValue(value));
2593
2599
  }
2594
2600
  function optionValueAttr(value) {
2595
- const { [kSelectedValue]: selectedValue } = getChunk()?.context || {};
2596
- return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
2601
+ const selectedValue = getContext(kSelectedValue);
2602
+ return attr("value", value) + (!isVoid(value) && (Array.isArray(selectedValue) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
2597
2603
  }
2598
2604
  var kSelectedValue = Symbol("selectedValue");
2599
2605
  function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
@@ -2841,7 +2847,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2841
2847
  throw new Error(`Invalid renderer passed for dynamic tag: ${renderer}`);
2842
2848
  }
2843
2849
  }
2844
- const chunk = getChunk();
2850
+ const state = getState();
2845
2851
  const branchId = peekNextScopeId();
2846
2852
  let result;
2847
2853
  if (typeof renderer === "string") {
@@ -2883,8 +2889,8 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2883
2889
  throw new Error(`Body content is not supported for a "${renderer}" tag.`);
2884
2890
  }
2885
2891
  if (resume) {
2886
- chunk.writeHTML(
2887
- chunk.boundary.state.mark(
2892
+ write(
2893
+ state.mark(
2888
2894
  "|" /* BranchSingleNode */,
2889
2895
  scopeId + " " + accessor + " " + branchId
2890
2896
  )
@@ -2892,9 +2898,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2892
2898
  }
2893
2899
  } else {
2894
2900
  if (resume) {
2895
- chunk.writeHTML(
2896
- chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2897
- );
2901
+ write(state.mark("[" /* BranchStart */, branchId + ""));
2898
2902
  }
2899
2903
  result = withBranchId(branchId, () => {
2900
2904
  if (renderer) {
@@ -2906,12 +2910,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2906
2910
  }
2907
2911
  });
2908
2912
  if (resume) {
2909
- chunk.writeHTML(
2910
- chunk.boundary.state.mark(
2911
- "]" /* BranchEnd */,
2912
- scopeId + " " + accessor
2913
- )
2914
- );
2913
+ write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
2915
2914
  }
2916
2915
  }
2917
2916
  const rendered = peekNextScopeId() !== branchId;
@@ -1584,6 +1584,12 @@ var K_SCOPE_ID = Symbol("Scope ID");
1584
1584
  function getChunk() {
1585
1585
  return $chunk;
1586
1586
  }
1587
+ function getContext(key) {
1588
+ return $chunk.context?.[key];
1589
+ }
1590
+ function getState() {
1591
+ return $chunk.boundary.state;
1592
+ }
1587
1593
  function getScopeId(scope) {
1588
1594
  return scope[K_SCOPE_ID];
1589
1595
  }
@@ -2510,8 +2516,8 @@ function styleAttr(value) {
2510
2516
  return stringAttr("style", styleValue(value));
2511
2517
  }
2512
2518
  function optionValueAttr(value) {
2513
- const { [kSelectedValue]: selectedValue } = getChunk()?.context || {};
2514
- return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
2519
+ const selectedValue = getContext(kSelectedValue);
2520
+ return attr("value", value) + (!isVoid(value) && (Array.isArray(selectedValue) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
2515
2521
  }
2516
2522
  var kSelectedValue = Symbol("selectedValue");
2517
2523
  function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
@@ -2759,7 +2765,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2759
2765
  throw new Error(`Invalid renderer passed for dynamic tag: ${renderer}`);
2760
2766
  }
2761
2767
  }
2762
- const chunk = getChunk();
2768
+ const state = getState();
2763
2769
  const branchId = peekNextScopeId();
2764
2770
  let result;
2765
2771
  if (typeof renderer === "string") {
@@ -2801,8 +2807,8 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2801
2807
  throw new Error(`Body content is not supported for a "${renderer}" tag.`);
2802
2808
  }
2803
2809
  if (resume) {
2804
- chunk.writeHTML(
2805
- chunk.boundary.state.mark(
2810
+ write(
2811
+ state.mark(
2806
2812
  "|" /* BranchSingleNode */,
2807
2813
  scopeId + " " + accessor + " " + branchId
2808
2814
  )
@@ -2810,9 +2816,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2810
2816
  }
2811
2817
  } else {
2812
2818
  if (resume) {
2813
- chunk.writeHTML(
2814
- chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2815
- );
2819
+ write(state.mark("[" /* BranchStart */, branchId + ""));
2816
2820
  }
2817
2821
  result = withBranchId(branchId, () => {
2818
2822
  if (renderer) {
@@ -2824,12 +2828,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2824
2828
  }
2825
2829
  });
2826
2830
  if (resume) {
2827
- chunk.writeHTML(
2828
- chunk.boundary.state.mark(
2829
- "]" /* BranchEnd */,
2830
- scopeId + " " + accessor
2831
- )
2832
- );
2831
+ write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
2833
2832
  }
2834
2833
  }
2835
2834
  const rendered = peekNextScopeId() !== branchId;
@@ -11,6 +11,8 @@ declare enum Mark {
11
11
  ReorderMarker = "#"
12
12
  }
13
13
  export declare function getChunk(): Chunk | undefined;
14
+ export declare function getContext(key: keyof NonNullable<Chunk["context"]>): unknown;
15
+ export declare function getState(): State;
14
16
  export declare function getScopeId(scope: unknown): number | undefined;
15
17
  export declare function write(html: string): void;
16
18
  export declare function writeScript(script: string): void;
package/dist/html.js CHANGED
@@ -1083,6 +1083,12 @@ var $chunk, NOOP = () => {
1083
1083
  function getChunk() {
1084
1084
  return $chunk;
1085
1085
  }
1086
+ function getContext(key) {
1087
+ return $chunk.context?.[key];
1088
+ }
1089
+ function getState() {
1090
+ return $chunk.boundary.state;
1091
+ }
1086
1092
  function getScopeId(scope) {
1087
1093
  return scope[K_SCOPE_ID];
1088
1094
  }
@@ -1659,8 +1665,8 @@ function styleAttr(value) {
1659
1665
  return stringAttr("style", styleValue(value));
1660
1666
  }
1661
1667
  function optionValueAttr(value) {
1662
- let { [kSelectedValue]: selectedValue } = getChunk()?.context || {};
1663
- return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
1668
+ let selectedValue = getContext(kSelectedValue);
1669
+ return attr("value", value) + (!isVoid(value) && (Array.isArray(selectedValue) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
1664
1670
  }
1665
1671
  var kSelectedValue = Symbol("selectedValue");
1666
1672
  function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
@@ -1851,7 +1857,7 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
1851
1857
 
1852
1858
  // src/html/dynamic-tag.ts
1853
1859
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
1854
- let renderer = normalizeDynamicRenderer(tag), chunk = getChunk(), branchId = peekNextScopeId(), result;
1860
+ let renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
1855
1861
  if (typeof renderer == "string") {
1856
1862
  let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
1857
1863
  nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), voidElementsReg.test(renderer) || (withBranchId(branchId, () => {
@@ -1869,28 +1875,21 @@ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|p
1869
1875
  input.valueChange,
1870
1876
  content
1871
1877
  ) : content());
1872
- }), write(`</${renderer}>`)), resume && chunk.writeHTML(
1873
- chunk.boundary.state.mark(
1878
+ }), write(`</${renderer}>`)), resume && write(
1879
+ state.mark(
1874
1880
  "|" /* BranchSingleNode */,
1875
1881
  scopeId + " " + accessor + " " + branchId
1876
1882
  )
1877
1883
  );
1878
1884
  } else
1879
- resume && chunk.writeHTML(
1880
- chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1881
- ), result = withBranchId(branchId, () => {
1885
+ resume && write(state.mark("[" /* BranchStart */, branchId + "")), result = withBranchId(branchId, () => {
1882
1886
  if (renderer)
1883
1887
  return inputIsArgs ? renderer(...inputOrArgs) : renderer(
1884
1888
  content ? { ...inputOrArgs, content } : inputOrArgs
1885
1889
  );
1886
1890
  if (content)
1887
1891
  return content();
1888
- }), resume && chunk.writeHTML(
1889
- chunk.boundary.state.mark(
1890
- "]" /* BranchEnd */,
1891
- scopeId + " " + accessor
1892
- )
1893
- );
1892
+ }), resume && write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
1894
1893
  return peekNextScopeId() !== branchId ? resume && writeScope(scopeId, {
1895
1894
  ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
1896
1895
  ["c" /* ConditionalRenderer */ + accessor]: renderer?.h || renderer
package/dist/html.mjs CHANGED
@@ -1004,6 +1004,12 @@ var $chunk, NOOP = () => {
1004
1004
  function getChunk() {
1005
1005
  return $chunk;
1006
1006
  }
1007
+ function getContext(key) {
1008
+ return $chunk.context?.[key];
1009
+ }
1010
+ function getState() {
1011
+ return $chunk.boundary.state;
1012
+ }
1007
1013
  function getScopeId(scope) {
1008
1014
  return scope[K_SCOPE_ID];
1009
1015
  }
@@ -1580,8 +1586,8 @@ function styleAttr(value) {
1580
1586
  return stringAttr("style", styleValue(value));
1581
1587
  }
1582
1588
  function optionValueAttr(value) {
1583
- let { [kSelectedValue]: selectedValue } = getChunk()?.context || {};
1584
- return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
1589
+ let selectedValue = getContext(kSelectedValue);
1590
+ return attr("value", value) + (!isVoid(value) && (Array.isArray(selectedValue) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
1585
1591
  }
1586
1592
  var kSelectedValue = Symbol("selectedValue");
1587
1593
  function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
@@ -1772,7 +1778,7 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
1772
1778
 
1773
1779
  // src/html/dynamic-tag.ts
1774
1780
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
1775
- let renderer = normalizeDynamicRenderer(tag), chunk = getChunk(), branchId = peekNextScopeId(), result;
1781
+ let renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
1776
1782
  if (typeof renderer == "string") {
1777
1783
  let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
1778
1784
  nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), voidElementsReg.test(renderer) || (withBranchId(branchId, () => {
@@ -1790,28 +1796,21 @@ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|p
1790
1796
  input.valueChange,
1791
1797
  content
1792
1798
  ) : content());
1793
- }), write(`</${renderer}>`)), resume && chunk.writeHTML(
1794
- chunk.boundary.state.mark(
1799
+ }), write(`</${renderer}>`)), resume && write(
1800
+ state.mark(
1795
1801
  "|" /* BranchSingleNode */,
1796
1802
  scopeId + " " + accessor + " " + branchId
1797
1803
  )
1798
1804
  );
1799
1805
  } else
1800
- resume && chunk.writeHTML(
1801
- chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1802
- ), result = withBranchId(branchId, () => {
1806
+ resume && write(state.mark("[" /* BranchStart */, branchId + "")), result = withBranchId(branchId, () => {
1803
1807
  if (renderer)
1804
1808
  return inputIsArgs ? renderer(...inputOrArgs) : renderer(
1805
1809
  content ? { ...inputOrArgs, content } : inputOrArgs
1806
1810
  );
1807
1811
  if (content)
1808
1812
  return content();
1809
- }), resume && chunk.writeHTML(
1810
- chunk.boundary.state.mark(
1811
- "]" /* BranchEnd */,
1812
- scopeId + " " + accessor
1813
- )
1814
- );
1813
+ }), resume && write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
1815
1814
  return peekNextScopeId() !== branchId ? resume && writeScope(scopeId, {
1816
1815
  ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
1817
1816
  ["c" /* ConditionalRenderer */ + accessor]: renderer?.h || renderer
@@ -1,10 +1,10 @@
1
1
  import { type Tag } from "@marko/compiler/babel-utils";
2
2
  import { type Binding } from "../util/references";
3
- export declare const kCommentTagBinding: unique symbol;
3
+ declare const kNodeBinding: unique symbol;
4
4
  declare const kGetterId: unique symbol;
5
5
  declare module "@marko/compiler/dist/types" {
6
6
  interface NodeExtra {
7
- [kCommentTagBinding]?: Binding;
7
+ [kNodeBinding]?: Binding;
8
8
  [kGetterId]?: string;
9
9
  }
10
10
  }
@@ -1,7 +1,10 @@
1
1
  import { type Tag } from "@marko/compiler/babel-utils";
2
+ import { type Binding } from "../util/references";
3
+ declare const kNodeBinding: unique symbol;
2
4
  declare const kGetterId: unique symbol;
3
5
  declare module "@marko/compiler/dist/types" {
4
6
  interface NodeExtra {
7
+ [kNodeBinding]?: Binding;
5
8
  [kGetterId]?: string;
6
9
  }
7
10
  }
@@ -1,7 +1,10 @@
1
1
  import { type Tag } from "@marko/compiler/babel-utils";
2
+ import { type Binding } from "../util/references";
3
+ declare const kNodeBinding: unique symbol;
2
4
  declare const kGetterId: unique symbol;
3
5
  declare module "@marko/compiler/dist/types" {
4
6
  interface NodeExtra {
7
+ [kNodeBinding]?: Binding;
5
8
  [kGetterId]?: string;
6
9
  }
7
10
  }