marko 6.0.39 → 6.0.41

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.
@@ -71,8 +71,11 @@ __export(html_exports, {
71
71
  toString: () => toString,
72
72
  tryContent: () => tryContent,
73
73
  write: () => write,
74
+ writeAttrsAndContent: () => writeAttrsAndContent,
75
+ writeContent: () => writeContent,
74
76
  writeEffect: () => writeEffect,
75
77
  writeExistingScope: () => writeExistingScope,
78
+ writePartialAttrsAndContent: () => writePartialAttrsAndContent,
76
79
  writeScope: () => writeScope,
77
80
  writeSubscribe: () => writeSubscribe,
78
81
  writeTrailers: () => writeTrailers
@@ -1698,6 +1701,44 @@ function writeEffect(scopeId, registryId) {
1698
1701
  $chunk.boundary.state.needsMainRuntime = true;
1699
1702
  $chunk.writeEffect(scopeId, registryId);
1700
1703
  }
1704
+ function writeContent(nodeAccessor, scopeId, content, serializeReason) {
1705
+ const shouldResume = serializeReason !== 0;
1706
+ const render2 = normalizeServerRender(content);
1707
+ const branchId = peekNextScopeId();
1708
+ if (render2) {
1709
+ if (shouldResume) {
1710
+ withBranchId(branchId, render2);
1711
+ } else {
1712
+ render2();
1713
+ }
1714
+ }
1715
+ const rendered = peekNextScopeId() !== branchId;
1716
+ if (rendered) {
1717
+ if (shouldResume) {
1718
+ writeScope(scopeId, {
1719
+ ["ConditionalScope:" /* ConditionalScope */ + nodeAccessor]: writeScope(
1720
+ branchId,
1721
+ {}
1722
+ ),
1723
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor]: render2?.___id
1724
+ });
1725
+ }
1726
+ } else {
1727
+ nextScopeId();
1728
+ }
1729
+ }
1730
+ function normalizeServerRender(value) {
1731
+ const renderer = normalizeDynamicRenderer(value);
1732
+ if (renderer) {
1733
+ if (typeof renderer === "function") {
1734
+ return renderer;
1735
+ } else if (true) {
1736
+ throw new Error(
1737
+ `Invalid \`content\` attribute. Received ${typeof value}`
1738
+ );
1739
+ }
1740
+ }
1741
+ }
1701
1742
  var kPendingContexts = Symbol("Pending Contexts");
1702
1743
  function withContext(key, value, cb) {
1703
1744
  const ctx = $chunk.context ||= { [kPendingContexts]: 0 };
@@ -2757,6 +2798,10 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
2757
2798
  }
2758
2799
  return result;
2759
2800
  }
2801
+ function writeAttrsAndContent(data, nodeAccessor, scopeId, tagName, serializeReason) {
2802
+ write(`${attrs(data, nodeAccessor, scopeId, tagName)}>`);
2803
+ writeContent(nodeAccessor, scopeId, data?.content, serializeReason);
2804
+ }
2760
2805
  function partialAttrs(data, skip, nodeAccessor, scopeId, tagName) {
2761
2806
  const partial = {};
2762
2807
  for (const key in data) {
@@ -2764,6 +2809,10 @@ function partialAttrs(data, skip, nodeAccessor, scopeId, tagName) {
2764
2809
  }
2765
2810
  return attrs(partial, nodeAccessor, scopeId, tagName);
2766
2811
  }
2812
+ function writePartialAttrsAndContent(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
2813
+ write(`${partialAttrs(data, skip, nodeAccessor, scopeId, tagName)}>`);
2814
+ writeContent(nodeAccessor, scopeId, data?.content, serializeReason);
2815
+ }
2767
2816
  function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
2768
2817
  writeScope(scopeId, {
2769
2818
  ["ControlledType:" /* ControlledType */ + nodeAccessor]: type,
@@ -3067,6 +3116,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
3067
3116
  let result;
3068
3117
  if (typeof renderer === "string") {
3069
3118
  const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
3119
+ const renderContent = content || normalizeDynamicRenderer(input.content);
3070
3120
  nextScopeId();
3071
3121
  write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
3072
3122
  if (!voidElementsReg.test(renderer)) {
@@ -3085,17 +3135,22 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
3085
3135
  input.valueChange
3086
3136
  )
3087
3137
  );
3088
- } else if (content) {
3138
+ } else if (renderContent) {
3139
+ if (typeof renderContent !== "function") {
3140
+ throw new Error(
3141
+ `Body content is not supported for the \`<${renderer}>\` tag.`
3142
+ );
3143
+ }
3089
3144
  if (renderer === "select" && ("value" in input || "valueChange" in input)) {
3090
3145
  controllable_select_value(
3091
3146
  scopeId,
3092
3147
  accessor,
3093
3148
  input.value,
3094
3149
  input.valueChange,
3095
- content
3150
+ renderContent
3096
3151
  );
3097
3152
  } else {
3098
- content();
3153
+ renderContent();
3099
3154
  }
3100
3155
  }
3101
3156
  };
@@ -3106,7 +3161,9 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
3106
3161
  }
3107
3162
  write(`</${renderer}>`);
3108
3163
  } else if (content) {
3109
- throw new Error(`Body content is not supported for a "${renderer}" tag.`);
3164
+ throw new Error(
3165
+ `Body content is not supported for the \`<${renderer}>\` tag.`
3166
+ );
3110
3167
  }
3111
3168
  if (shouldResume) {
3112
3169
  write(
@@ -3323,8 +3380,11 @@ var compat = {
3323
3380
  toString,
3324
3381
  tryContent,
3325
3382
  write,
3383
+ writeAttrsAndContent,
3384
+ writeContent,
3326
3385
  writeEffect,
3327
3386
  writeExistingScope,
3387
+ writePartialAttrsAndContent,
3328
3388
  writeScope,
3329
3389
  writeSubscribe,
3330
3390
  writeTrailers
@@ -1617,6 +1617,44 @@ function writeEffect(scopeId, registryId) {
1617
1617
  $chunk.boundary.state.needsMainRuntime = true;
1618
1618
  $chunk.writeEffect(scopeId, registryId);
1619
1619
  }
1620
+ function writeContent(nodeAccessor, scopeId, content, serializeReason) {
1621
+ const shouldResume = serializeReason !== 0;
1622
+ const render2 = normalizeServerRender(content);
1623
+ const branchId = peekNextScopeId();
1624
+ if (render2) {
1625
+ if (shouldResume) {
1626
+ withBranchId(branchId, render2);
1627
+ } else {
1628
+ render2();
1629
+ }
1630
+ }
1631
+ const rendered = peekNextScopeId() !== branchId;
1632
+ if (rendered) {
1633
+ if (shouldResume) {
1634
+ writeScope(scopeId, {
1635
+ ["ConditionalScope:" /* ConditionalScope */ + nodeAccessor]: writeScope(
1636
+ branchId,
1637
+ {}
1638
+ ),
1639
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor]: render2?.___id
1640
+ });
1641
+ }
1642
+ } else {
1643
+ nextScopeId();
1644
+ }
1645
+ }
1646
+ function normalizeServerRender(value) {
1647
+ const renderer = normalizeDynamicRenderer(value);
1648
+ if (renderer) {
1649
+ if (typeof renderer === "function") {
1650
+ return renderer;
1651
+ } else if (true) {
1652
+ throw new Error(
1653
+ `Invalid \`content\` attribute. Received ${typeof value}`
1654
+ );
1655
+ }
1656
+ }
1657
+ }
1620
1658
  var kPendingContexts = Symbol("Pending Contexts");
1621
1659
  function withContext(key, value, cb) {
1622
1660
  const ctx = $chunk.context ||= { [kPendingContexts]: 0 };
@@ -2676,6 +2714,10 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
2676
2714
  }
2677
2715
  return result;
2678
2716
  }
2717
+ function writeAttrsAndContent(data, nodeAccessor, scopeId, tagName, serializeReason) {
2718
+ write(`${attrs(data, nodeAccessor, scopeId, tagName)}>`);
2719
+ writeContent(nodeAccessor, scopeId, data?.content, serializeReason);
2720
+ }
2679
2721
  function partialAttrs(data, skip, nodeAccessor, scopeId, tagName) {
2680
2722
  const partial = {};
2681
2723
  for (const key in data) {
@@ -2683,6 +2725,10 @@ function partialAttrs(data, skip, nodeAccessor, scopeId, tagName) {
2683
2725
  }
2684
2726
  return attrs(partial, nodeAccessor, scopeId, tagName);
2685
2727
  }
2728
+ function writePartialAttrsAndContent(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
2729
+ write(`${partialAttrs(data, skip, nodeAccessor, scopeId, tagName)}>`);
2730
+ writeContent(nodeAccessor, scopeId, data?.content, serializeReason);
2731
+ }
2686
2732
  function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
2687
2733
  writeScope(scopeId, {
2688
2734
  ["ControlledType:" /* ControlledType */ + nodeAccessor]: type,
@@ -2986,6 +3032,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
2986
3032
  let result;
2987
3033
  if (typeof renderer === "string") {
2988
3034
  const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
3035
+ const renderContent = content || normalizeDynamicRenderer(input.content);
2989
3036
  nextScopeId();
2990
3037
  write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
2991
3038
  if (!voidElementsReg.test(renderer)) {
@@ -3004,17 +3051,22 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
3004
3051
  input.valueChange
3005
3052
  )
3006
3053
  );
3007
- } else if (content) {
3054
+ } else if (renderContent) {
3055
+ if (typeof renderContent !== "function") {
3056
+ throw new Error(
3057
+ `Body content is not supported for the \`<${renderer}>\` tag.`
3058
+ );
3059
+ }
3008
3060
  if (renderer === "select" && ("value" in input || "valueChange" in input)) {
3009
3061
  controllable_select_value(
3010
3062
  scopeId,
3011
3063
  accessor,
3012
3064
  input.value,
3013
3065
  input.valueChange,
3014
- content
3066
+ renderContent
3015
3067
  );
3016
3068
  } else {
3017
- content();
3069
+ renderContent();
3018
3070
  }
3019
3071
  }
3020
3072
  };
@@ -3025,7 +3077,9 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
3025
3077
  }
3026
3078
  write(`</${renderer}>`);
3027
3079
  } else if (content) {
3028
- throw new Error(`Body content is not supported for a "${renderer}" tag.`);
3080
+ throw new Error(
3081
+ `Body content is not supported for the \`<${renderer}>\` tag.`
3082
+ );
3029
3083
  }
3030
3084
  if (shouldResume) {
3031
3085
  write(
@@ -3241,8 +3295,11 @@ export {
3241
3295
  toString,
3242
3296
  tryContent,
3243
3297
  write,
3298
+ writeAttrsAndContent,
3299
+ writeContent,
3244
3300
  writeEffect,
3245
3301
  writeExistingScope,
3302
+ writePartialAttrsAndContent,
3246
3303
  writeScope,
3247
3304
  writeSubscribe,
3248
3305
  writeTrailers
package/dist/dom/dom.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type Accessor, type Scope } from "../common/types";
2
+ import { type Renderer } from "./renderer";
2
3
  export declare function attr(element: Element, name: string, value: unknown): void;
3
4
  export declare function setAttribute(element: Element, name: string, value: string | undefined): void;
4
5
  export declare function classAttr(element: Element, value: unknown): void;
@@ -10,9 +11,13 @@ export declare function styleItem(element: HTMLElement, name: string, value: unk
10
11
  export declare function data(node: Text | Comment, value: unknown): void;
11
12
  export declare function textContent(node: ParentNode, value: unknown): void;
12
13
  export declare function attrs(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>): void;
14
+ export declare function attrsAndContent(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>): void;
13
15
  export declare function partialAttrs(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, skip: Record<string, 1>): void;
16
+ export declare function partialAttrsAndContent(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, skip: Record<string, 1>): void;
17
+ export declare function insertContent(scope: Scope, nodeAccessor: Accessor, value: unknown): void;
14
18
  export declare function attrsEvents(scope: Scope, nodeAccessor: Accessor): void;
15
19
  export declare function html(scope: Scope, value: unknown, accessor: Accessor): void;
20
+ export declare function normalizeClientRender(value: any): Renderer | undefined;
16
21
  export declare function props(scope: Scope, nodeIndex: number, index: number): void;
17
22
  export declare function normalizeAttrValue(value: unknown): string | undefined;
18
23
  export declare function lifecycle(scope: Scope, index: string | number, thisObj: Record<string, unknown> & {
package/dist/dom.d.ts CHANGED
@@ -4,7 +4,7 @@ export { getAbortSignal, resetAbortSignal } from "./dom/abort-signal";
4
4
  export { compat } from "./dom/compat";
5
5
  export { awaitTag, conditional, createTry, dynamicTag, loopIn, loopOf, loopTo, } from "./dom/control-flow";
6
6
  export { controllable_detailsOrDialog_open, controllable_detailsOrDialog_open_effect, controllable_input_checked, controllable_input_checked_effect, controllable_input_checkedValue, controllable_input_checkedValue_effect, controllable_input_value, controllable_input_value_effect, controllable_select_value, controllable_select_value_effect, controllable_textarea_value, controllable_textarea_value_effect, } from "./dom/controllable";
7
- export { attr, attrs, attrsEvents, classAttr, classItem, classItems, data, html, lifecycle, partialAttrs, props, styleAttr, styleItem, styleItems, textContent, } from "./dom/dom";
7
+ export { attr, attrs, attrsAndContent, attrsEvents, classAttr, classItem, classItems, data, html, insertContent, lifecycle, partialAttrs, partialAttrsAndContent, props, styleAttr, styleItem, styleItems, textContent, } from "./dom/dom";
8
8
  export { on } from "./dom/event";
9
9
  export { enableCatch, run } from "./dom/queue";
10
10
  export { createContent, createRenderer, localClosures, registerContent, } from "./dom/renderer";