@marko/runtime-tags 6.0.111 → 6.0.112

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.
@@ -30,6 +30,7 @@ __export(html_exports, {
30
30
  _attr_input_checked: () => _attr_input_checked,
31
31
  _attr_input_checkedValue: () => _attr_input_checkedValue,
32
32
  _attr_input_value: () => _attr_input_value,
33
+ _attr_nonce: () => _attr_nonce,
33
34
  _attr_option_value: () => _attr_option_value,
34
35
  _attr_select_value: () => _attr_select_value,
35
36
  _attr_style: () => _attr_style,
@@ -2929,6 +2930,9 @@ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange) {
2929
2930
  }
2930
2931
  return _attr("open", open);
2931
2932
  }
2933
+ function _attr_nonce() {
2934
+ return getChunk().boundary.state.nonceAttr;
2935
+ }
2932
2936
  function _attr(name, value) {
2933
2937
  return isVoid(value) ? "" : nonVoidAttr(name, value);
2934
2938
  }
@@ -3620,6 +3624,7 @@ function NOOP3() {
3620
3624
  _attr_input_checked,
3621
3625
  _attr_input_checkedValue,
3622
3626
  _attr_input_value,
3627
+ _attr_nonce,
3623
3628
  _attr_option_value,
3624
3629
  _attr_select_value,
3625
3630
  _attr_style,
@@ -2837,6 +2837,9 @@ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange) {
2837
2837
  }
2838
2838
  return _attr("open", open);
2839
2839
  }
2840
+ function _attr_nonce() {
2841
+ return getChunk().boundary.state.nonceAttr;
2842
+ }
2840
2843
  function _attr(name, value) {
2841
2844
  return isVoid(value) ? "" : nonVoidAttr(name, value);
2842
2845
  }
@@ -3527,6 +3530,7 @@ export {
3527
3530
  _attr_input_checked,
3528
3531
  _attr_input_checkedValue,
3529
3532
  _attr_input_value,
3533
+ _attr_nonce,
3530
3534
  _attr_option_value,
3531
3535
  _attr_select_value,
3532
3536
  _attr_style,
@@ -8,6 +8,7 @@ export declare function _attr_input_value(scopeId: number, nodeAccessor: Accesso
8
8
  export declare function _attr_input_checked(scopeId: number, nodeAccessor: Accessor, checked: unknown, checkedChange: unknown): string;
9
9
  export declare function _attr_input_checkedValue(scopeId: number, nodeAccessor: Accessor, checkedValue: unknown, checkedValueChange: unknown, value: unknown): string;
10
10
  export declare function _attr_details_or_dialog_open(scopeId: number, nodeAccessor: Accessor, open: unknown, openChange: unknown): string;
11
+ export declare function _attr_nonce(): string;
11
12
  export declare function _attr(name: string, value: unknown): string;
12
13
  export declare function _attrs(data: Record<string, unknown>, nodeAccessor: Accessor, scopeId: number, tagName: string): string;
13
14
  export declare function _attrs_content(data: Record<string, unknown>, nodeAccessor: Accessor, scopeId: number, tagName: string, serializeReason?: 1 | 0): void;
package/dist/html.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { attrTag, attrTags } from "./common/attr-tag";
2
2
  export { _assert_hoist, _el_read_error, _hoist_read_error, } from "./common/errors";
3
- export { _attr, _attr_class, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_option_value, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, } from "./html/attrs";
3
+ export { _attr, _attr_class, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_option_value, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, } from "./html/attrs";
4
4
  export { compat } from "./html/compat";
5
5
  export { _escape, _escape_script, _escape_style, _escape_textarea_value, _unescaped, } from "./html/content";
6
6
  export { _content, _content_resume, _dynamic_tag } from "./html/dynamic-tag";
package/dist/html.js CHANGED
@@ -27,6 +27,7 @@ __export(html_exports, {
27
27
  _attr_input_checked: () => _attr_input_checked,
28
28
  _attr_input_checkedValue: () => _attr_input_checkedValue,
29
29
  _attr_input_value: () => _attr_input_value,
30
+ _attr_nonce: () => _attr_nonce,
30
31
  _attr_option_value: () => _attr_option_value,
31
32
  _attr_select_value: () => _attr_select_value,
32
33
  _attr_style: () => _attr_style,
@@ -1820,6 +1821,9 @@ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange) {
1820
1821
  openChange
1821
1822
  ), _attr("open", open);
1822
1823
  }
1824
+ function _attr_nonce() {
1825
+ return getChunk().boundary.state.nonceAttr;
1826
+ }
1823
1827
  function _attr(name, value) {
1824
1828
  return isVoid(value) ? "" : nonVoidAttr(name, value);
1825
1829
  }
@@ -2301,6 +2305,7 @@ function NOOP3() {
2301
2305
  _attr_input_checked,
2302
2306
  _attr_input_checkedValue,
2303
2307
  _attr_input_value,
2308
+ _attr_nonce,
2304
2309
  _attr_option_value,
2305
2310
  _attr_select_value,
2306
2311
  _attr_style,
package/dist/html.mjs CHANGED
@@ -1731,6 +1731,9 @@ function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange) {
1731
1731
  openChange
1732
1732
  ), _attr("open", open);
1733
1733
  }
1734
+ function _attr_nonce() {
1735
+ return getChunk().boundary.state.nonceAttr;
1736
+ }
1734
1737
  function _attr(name, value) {
1735
1738
  return isVoid(value) ? "" : nonVoidAttr(name, value);
1736
1739
  }
@@ -2211,6 +2214,7 @@ export {
2211
2214
  _attr_input_checked,
2212
2215
  _attr_input_checkedValue,
2213
2216
  _attr_input_value,
2217
+ _attr_nonce,
2214
2218
  _attr_option_value,
2215
2219
  _attr_select_value,
2216
2220
  _attr_style,
@@ -9832,8 +9832,11 @@ var html_script_default = {
9832
9832
  visit(tag, 32 /* Get */);
9833
9833
  }
9834
9834
  write`<script`;
9835
- const usedAttrs = getUsedAttrs2(tag.node);
9836
- const { staticAttrs, skipExpression, spreadExpression } = usedAttrs;
9835
+ const usedAttrs = getUsedAttrs2(tag.node, isHTML);
9836
+ const { hasNonce, staticAttrs, skipExpression, spreadExpression } = usedAttrs;
9837
+ if (isHTML && !hasNonce && !spreadExpression) {
9838
+ write`${callRuntime("_attr_nonce")}`;
9839
+ }
9837
9840
  for (const attr of staticAttrs) {
9838
9841
  const { name: name2, value } = attr;
9839
9842
  const { confident, computed } = value.extra || {};
@@ -10022,7 +10025,7 @@ var html_script_default = {
10022
10025
  }
10023
10026
  ]
10024
10027
  };
10025
- function getUsedAttrs2(tag) {
10028
+ function getUsedAttrs2(tag, injectNonce) {
10026
10029
  const seen = {};
10027
10030
  const { attributes } = tag;
10028
10031
  const maybeStaticAttrs = /* @__PURE__ */ new Set();
@@ -10030,6 +10033,7 @@ function getUsedAttrs2(tag) {
10030
10033
  let skipExpression;
10031
10034
  let spreadProps;
10032
10035
  let skipProps;
10036
+ let hasNonce = false;
10033
10037
  for (let i = attributes.length; i--; ) {
10034
10038
  const attr = attributes[i];
10035
10039
  const { value } = attr;
@@ -10040,6 +10044,9 @@ function getUsedAttrs2(tag) {
10040
10044
  spreadProps.push(import_compiler44.types.spreadElement(value));
10041
10045
  } else if (!seen[attr.name]) {
10042
10046
  seen[attr.name] = attr;
10047
+ if (attr.name === "nonce") {
10048
+ hasNonce = true;
10049
+ }
10043
10050
  if (spreadProps) {
10044
10051
  spreadProps.push(toObjectProperty(attr.name, attr.value));
10045
10052
  } else {
@@ -10056,9 +10063,18 @@ function getUsedAttrs2(tag) {
10056
10063
  if (skipProps) {
10057
10064
  skipExpression = import_compiler44.types.objectExpression(skipProps);
10058
10065
  }
10066
+ if (injectNonce && !hasNonce) {
10067
+ spreadProps.unshift(
10068
+ import_compiler44.types.objectProperty(
10069
+ import_compiler44.types.identifier("nonce"),
10070
+ import_compiler44.types.memberExpression(callRuntime("$global"), import_compiler44.types.identifier("cspNonce"))
10071
+ )
10072
+ );
10073
+ }
10059
10074
  spreadExpression = propsToExpression(spreadProps);
10060
10075
  }
10061
10076
  return {
10077
+ hasNonce,
10062
10078
  staticAttrs,
10063
10079
  spreadExpression,
10064
10080
  skipExpression
@@ -10173,8 +10189,11 @@ var html_style_default = {
10173
10189
  visit(tag, 32 /* Get */);
10174
10190
  }
10175
10191
  write`<style`;
10176
- const usedAttrs = getUsedAttrs3(tag.node);
10177
- const { staticAttrs, skipExpression, spreadExpression } = usedAttrs;
10192
+ const usedAttrs = getUsedAttrs3(tag.node, isHTML);
10193
+ const { hasNonce, staticAttrs, skipExpression, spreadExpression } = usedAttrs;
10194
+ if (isHTML && !hasNonce && !spreadExpression) {
10195
+ write`${callRuntime("_attr_nonce")}`;
10196
+ }
10178
10197
  for (const attr of staticAttrs) {
10179
10198
  const { name: name2, value } = attr;
10180
10199
  const { confident, computed } = value.extra || {};
@@ -10358,7 +10377,7 @@ var html_style_default = {
10358
10377
  }
10359
10378
  ]
10360
10379
  };
10361
- function getUsedAttrs3(tag) {
10380
+ function getUsedAttrs3(tag, injectNonce) {
10362
10381
  const seen = {};
10363
10382
  const { attributes } = tag;
10364
10383
  const maybeStaticAttrs = /* @__PURE__ */ new Set();
@@ -10366,6 +10385,7 @@ function getUsedAttrs3(tag) {
10366
10385
  let skipExpression;
10367
10386
  let spreadProps;
10368
10387
  let skipProps;
10388
+ let hasNonce = false;
10369
10389
  for (let i = attributes.length; i--; ) {
10370
10390
  const attr = attributes[i];
10371
10391
  const { value } = attr;
@@ -10376,6 +10396,9 @@ function getUsedAttrs3(tag) {
10376
10396
  spreadProps.push(import_compiler45.types.spreadElement(value));
10377
10397
  } else if (!seen[attr.name]) {
10378
10398
  seen[attr.name] = attr;
10399
+ if (attr.name === "nonce") {
10400
+ hasNonce = true;
10401
+ }
10379
10402
  if (spreadProps) {
10380
10403
  spreadProps.push(toObjectProperty(attr.name, attr.value));
10381
10404
  } else {
@@ -10392,9 +10415,18 @@ function getUsedAttrs3(tag) {
10392
10415
  if (skipProps) {
10393
10416
  skipExpression = import_compiler45.types.objectExpression(skipProps);
10394
10417
  }
10418
+ if (injectNonce && !hasNonce) {
10419
+ spreadProps.unshift(
10420
+ import_compiler45.types.objectProperty(
10421
+ import_compiler45.types.identifier("nonce"),
10422
+ import_compiler45.types.memberExpression(callRuntime("$global"), import_compiler45.types.identifier("cspNonce"))
10423
+ )
10424
+ );
10425
+ }
10395
10426
  spreadExpression = propsToExpression(spreadProps);
10396
10427
  }
10397
10428
  return {
10429
+ hasNonce,
10398
10430
  staticAttrs,
10399
10431
  spreadExpression,
10400
10432
  skipExpression
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/runtime-tags",
3
- "version": "6.0.111",
3
+ "version": "6.0.112",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",