@marko/runtime-tags 0.2.3 → 0.2.5

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/debug/dom.js CHANGED
@@ -83,6 +83,7 @@ __export(dom_exports, {
83
83
  styleAttr: () => styleAttr,
84
84
  tagVarSignal: () => tagVarSignal,
85
85
  tagVarSignalChange: () => tagVarSignalChange,
86
+ textContent: () => textContent,
86
87
  value: () => value
87
88
  });
88
89
  module.exports = __toCommonJS(dom_exports);
@@ -373,6 +374,7 @@ var Render = class {
373
374
  delete this.___renders[this.___renderId];
374
375
  } else {
375
376
  registeredValues[resumes[i++]](
377
+ scopeLookup[resumeData],
376
378
  scopeLookup[resumeData]
377
379
  );
378
380
  }
@@ -695,7 +697,7 @@ function runEffects(effects = pendingEffects) {
695
697
  for (let i = 0; i < effects.length; i += 2 /* Total */) {
696
698
  const scope = effects[i];
697
699
  const fn = effects[i + 1];
698
- fn(scope);
700
+ fn(scope, scope);
699
701
  }
700
702
  }
701
703
  function runSignals(signals) {
@@ -1298,7 +1300,11 @@ function parseHTML(html2) {
1298
1300
  }
1299
1301
  function parseHTMLOrSingleNode(html2) {
1300
1302
  const content = parseHTML(html2);
1301
- return content.firstChild === content.lastChild ? content.firstChild || fallback : content;
1303
+ if (!content.firstChild) return fallback;
1304
+ return content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
1305
+ // a single replaced node, in which case the walker can't replace
1306
+ // the node itself.
1307
+ content.firstChild.nodeType !== 8 ? content.firstChild : content;
1302
1308
  }
1303
1309
 
1304
1310
  // src/dom/dom.ts
@@ -1326,6 +1332,12 @@ function data(node, value2) {
1326
1332
  node.data = normalizedValue;
1327
1333
  }
1328
1334
  }
1335
+ function textContent(node, value2) {
1336
+ const normalizedValue = normalizeString(value2);
1337
+ if (node.textContent !== normalizedValue) {
1338
+ node.textContent = normalizedValue;
1339
+ }
1340
+ }
1329
1341
  function attrs(scope, nodeAccessor, nextAttrs) {
1330
1342
  const el = scope[nodeAccessor];
1331
1343
  for (const { name } of el.attributes) {
@@ -284,6 +284,7 @@ var Render = class {
284
284
  delete this.___renders[this.___renderId];
285
285
  } else {
286
286
  registeredValues[resumes[i++]](
287
+ scopeLookup[resumeData],
287
288
  scopeLookup[resumeData]
288
289
  );
289
290
  }
@@ -606,7 +607,7 @@ function runEffects(effects = pendingEffects) {
606
607
  for (let i = 0; i < effects.length; i += 2 /* Total */) {
607
608
  const scope = effects[i];
608
609
  const fn = effects[i + 1];
609
- fn(scope);
610
+ fn(scope, scope);
610
611
  }
611
612
  }
612
613
  function runSignals(signals) {
@@ -1209,7 +1210,11 @@ function parseHTML(html2) {
1209
1210
  }
1210
1211
  function parseHTMLOrSingleNode(html2) {
1211
1212
  const content = parseHTML(html2);
1212
- return content.firstChild === content.lastChild ? content.firstChild || fallback : content;
1213
+ if (!content.firstChild) return fallback;
1214
+ return content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
1215
+ // a single replaced node, in which case the walker can't replace
1216
+ // the node itself.
1217
+ content.firstChild.nodeType !== 8 ? content.firstChild : content;
1213
1218
  }
1214
1219
 
1215
1220
  // src/dom/dom.ts
@@ -1237,6 +1242,12 @@ function data(node, value2) {
1237
1242
  node.data = normalizedValue;
1238
1243
  }
1239
1244
  }
1245
+ function textContent(node, value2) {
1246
+ const normalizedValue = normalizeString(value2);
1247
+ if (node.textContent !== normalizedValue) {
1248
+ node.textContent = normalizedValue;
1249
+ }
1250
+ }
1240
1251
  function attrs(scope, nodeAccessor, nextAttrs) {
1241
1252
  const el = scope[nodeAccessor];
1242
1253
  for (const { name } of el.attributes) {
@@ -2073,5 +2084,6 @@ export {
2073
2084
  styleAttr,
2074
2085
  tagVarSignal,
2075
2086
  tagVarSignalChange,
2087
+ textContent,
2076
2088
  value
2077
2089
  };
@@ -1649,6 +1649,9 @@ var State2 = class {
1649
1649
  constructor($global2) {
1650
1650
  this.$global = $global2;
1651
1651
  this.$global = $global2;
1652
+ if ($global2.cspNonce) {
1653
+ this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + "");
1654
+ }
1652
1655
  }
1653
1656
  tagIndex = 0;
1654
1657
  scopeIndex = 0;
@@ -1659,6 +1662,7 @@ var State2 = class {
1659
1662
  hasReorderRuntime = false;
1660
1663
  hasWrittenResume = false;
1661
1664
  trailerHTML = "";
1665
+ nonceAttr = "";
1662
1666
  serializer = new Serializer();
1663
1667
  writeReorders = null;
1664
1668
  scopes = /* @__PURE__ */ new Map();
@@ -1832,8 +1836,7 @@ function prepareChunk(chunk) {
1832
1836
  const head = chunk.consume();
1833
1837
  const { boundary, effects } = head;
1834
1838
  const { state } = boundary;
1835
- const { $global: $global2, runtimePrefix, serializer } = state;
1836
- const nonceAttr = $global2.cspNonce ? " nonce=" + escapeAttrValue($global2.cspNonce + "") : "";
1839
+ const { $global: $global2, runtimePrefix, serializer, nonceAttr } = state;
1837
1840
  let { html, scripts } = head;
1838
1841
  let hasWalk = false;
1839
1842
  head.effects = "";
@@ -1944,7 +1947,7 @@ function flushChunk(head, last) {
1944
1947
  let result = html;
1945
1948
  head.html = head.scripts = "";
1946
1949
  if (scripts) {
1947
- result += ($global2.cspNonce ? "<script nonce=" + escapeAttrValue($global2.cspNonce + "") + ">" : "<script>") + scripts + "</script>";
1950
+ result += "<script" + state.nonceAttr + ">" + scripts + "</script>";
1948
1951
  }
1949
1952
  if (__flush__) {
1950
1953
  $global2.__flush__ = void 0;
@@ -1573,6 +1573,9 @@ var State2 = class {
1573
1573
  constructor($global2) {
1574
1574
  this.$global = $global2;
1575
1575
  this.$global = $global2;
1576
+ if ($global2.cspNonce) {
1577
+ this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + "");
1578
+ }
1576
1579
  }
1577
1580
  tagIndex = 0;
1578
1581
  scopeIndex = 0;
@@ -1583,6 +1586,7 @@ var State2 = class {
1583
1586
  hasReorderRuntime = false;
1584
1587
  hasWrittenResume = false;
1585
1588
  trailerHTML = "";
1589
+ nonceAttr = "";
1586
1590
  serializer = new Serializer();
1587
1591
  writeReorders = null;
1588
1592
  scopes = /* @__PURE__ */ new Map();
@@ -1756,8 +1760,7 @@ function prepareChunk(chunk) {
1756
1760
  const head = chunk.consume();
1757
1761
  const { boundary, effects } = head;
1758
1762
  const { state } = boundary;
1759
- const { $global: $global2, runtimePrefix, serializer } = state;
1760
- const nonceAttr = $global2.cspNonce ? " nonce=" + escapeAttrValue($global2.cspNonce + "") : "";
1763
+ const { $global: $global2, runtimePrefix, serializer, nonceAttr } = state;
1761
1764
  let { html, scripts } = head;
1762
1765
  let hasWalk = false;
1763
1766
  head.effects = "";
@@ -1868,7 +1871,7 @@ function flushChunk(head, last) {
1868
1871
  let result = html;
1869
1872
  head.html = head.scripts = "";
1870
1873
  if (scripts) {
1871
- result += ($global2.cspNonce ? "<script nonce=" + escapeAttrValue($global2.cspNonce + "") + ">" : "<script>") + scripts + "</script>";
1874
+ result += "<script" + state.nonceAttr + ">" + scripts + "</script>";
1872
1875
  }
1873
1876
  if (__flush__) {
1874
1877
  $global2.__flush__ = void 0;
package/dist/dom/dom.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare function setAttribute(element: Element, name: string, value: stri
5
5
  export declare function classAttr(element: Element, value: unknown): void;
6
6
  export declare function styleAttr(element: Element, value: unknown): void;
7
7
  export declare function data(node: Text | Comment, value: unknown): void;
8
+ export declare function textContent(node: ParentNode, value: unknown): void;
8
9
  export declare function attrs(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>): void;
9
10
  export declare function partialAttrs(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, skip: Record<string, 1>): void;
10
11
  export declare function attrsEvents(scope: Scope, nodeAccessor: Accessor): void;
@@ -1,5 +1,5 @@
1
1
  export declare function parseHTML(html: string): DocumentFragment;
2
- export declare function parseHTMLOrSingleNode(html: string): Node & {
2
+ export declare function parseHTMLOrSingleNode(html: string): Text | (Node & {
3
3
  firstChild?: ChildNode;
4
4
  lastChild?: ChildNode;
5
- };
5
+ });
@@ -1,2 +1,3 @@
1
1
  import type { Scope, Template } from "../common/types";
2
+ import { createRenderer } from "./renderer";
2
3
  export declare const createTemplate: (templateId: string, template: string, walks?: string | undefined, setup?: ((scope: Scope) => void) | undefined, getClosureSignals?: (() => import("./signals").IntersectionSignal[]) | undefined, getArgs?: (() => import("./signals").ValueSignal) | undefined) => Template;
package/dist/dom.d.ts CHANGED
@@ -5,7 +5,7 @@ export { getAbortSignal, resetAbortSignal } from "./dom/abort-signal";
5
5
  export { compat } from "./dom/compat";
6
6
  export { conditional, conditionalOnlyChild, inConditionalScope, inLoopScope, loopIn, loopOf, loopTo, } from "./dom/control-flow";
7
7
  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";
8
- export { attr, attrs, attrsEvents, classAttr, data, html, lifecycle, partialAttrs, props, styleAttr, } from "./dom/dom";
8
+ export { attr, attrs, attrsEvents, classAttr, data, html, lifecycle, partialAttrs, props, styleAttr, textContent, } from "./dom/dom";
9
9
  export { on } from "./dom/event";
10
10
  export { run } from "./dom/queue";
11
11
  export { createRenderer, createRendererWithOwner, dynamicTagAttrs, } from "./dom/renderer";
package/dist/dom.js CHANGED
@@ -80,6 +80,7 @@ __export(dom_exports, {
80
80
  styleAttr: () => styleAttr,
81
81
  tagVarSignal: () => tagVarSignal,
82
82
  tagVarSignalChange: () => tagVarSignalChange,
83
+ textContent: () => textContent,
83
84
  value: () => value
84
85
  });
85
86
  module.exports = __toCommonJS(dom_exports);
@@ -254,6 +255,7 @@ var registeredValues = {}, Render = class {
254
255
  cleanupOwnerId && (scope.d = scopes[cleanupOwnerId], onDestroy(scope));
255
256
  }
256
257
  } else i === len || typeof resumes[i] != "string" ? delete this.z[this.o] : registeredValues[resumes[i++]](
258
+ scopeLookup[resumeData],
257
259
  scopeLookup[resumeData]
258
260
  );
259
261
  }
@@ -444,7 +446,7 @@ function prepareEffects(fn) {
444
446
  function runEffects(effects = pendingEffects) {
445
447
  for (let i = 0; i < effects.length; i += 2 /* Total */) {
446
448
  let scope = effects[i], fn = effects[i + 1];
447
- fn(scope);
449
+ fn(scope, scope);
448
450
  }
449
451
  }
450
452
  function runSignals(signals) {
@@ -814,7 +816,10 @@ function parseHTML(html2) {
814
816
  }
815
817
  function parseHTMLOrSingleNode(html2) {
816
818
  let content = parseHTML(html2);
817
- return content.firstChild === content.lastChild ? content.firstChild || fallback : content;
819
+ return content.firstChild ? content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
820
+ // a single replaced node, in which case the walker can't replace
821
+ // the node itself.
822
+ content.firstChild.nodeType !== 8 ? content.firstChild : content : fallback;
818
823
  }
819
824
 
820
825
  // src/dom/dom.ts
@@ -834,6 +839,10 @@ function data(node, value2) {
834
839
  let normalizedValue = normalizeString(value2);
835
840
  node.data !== normalizedValue && (node.data = normalizedValue);
836
841
  }
842
+ function textContent(node, value2) {
843
+ let normalizedValue = normalizeString(value2);
844
+ node.textContent !== normalizedValue && (node.textContent = normalizedValue);
845
+ }
837
846
  function attrs(scope, nodeAccessor, nextAttrs) {
838
847
  let el = scope[nodeAccessor];
839
848
  for (let { name } of el.attributes)
package/dist/dom.mjs CHANGED
@@ -168,6 +168,7 @@ var registeredValues = {}, Render = class {
168
168
  cleanupOwnerId && (scope.d = scopes[cleanupOwnerId], onDestroy(scope));
169
169
  }
170
170
  } else i === len || typeof resumes[i] != "string" ? delete this.z[this.o] : registeredValues[resumes[i++]](
171
+ scopeLookup[resumeData],
171
172
  scopeLookup[resumeData]
172
173
  );
173
174
  }
@@ -358,7 +359,7 @@ function prepareEffects(fn) {
358
359
  function runEffects(effects = pendingEffects) {
359
360
  for (let i = 0; i < effects.length; i += 2 /* Total */) {
360
361
  let scope = effects[i], fn = effects[i + 1];
361
- fn(scope);
362
+ fn(scope, scope);
362
363
  }
363
364
  }
364
365
  function runSignals(signals) {
@@ -728,7 +729,10 @@ function parseHTML(html2) {
728
729
  }
729
730
  function parseHTMLOrSingleNode(html2) {
730
731
  let content = parseHTML(html2);
731
- return content.firstChild === content.lastChild ? content.firstChild || fallback : content;
732
+ return content.firstChild ? content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
733
+ // a single replaced node, in which case the walker can't replace
734
+ // the node itself.
735
+ content.firstChild.nodeType !== 8 ? content.firstChild : content : fallback;
732
736
  }
733
737
 
734
738
  // src/dom/dom.ts
@@ -748,6 +752,10 @@ function data(node, value2) {
748
752
  let normalizedValue = normalizeString(value2);
749
753
  node.data !== normalizedValue && (node.data = normalizedValue);
750
754
  }
755
+ function textContent(node, value2) {
756
+ let normalizedValue = normalizeString(value2);
757
+ node.textContent !== normalizedValue && (node.textContent = normalizedValue);
758
+ }
751
759
  function attrs(scope, nodeAccessor, nextAttrs) {
752
760
  let el = scope[nodeAccessor];
753
761
  for (let { name } of el.attributes)
@@ -1337,5 +1345,6 @@ export {
1337
1345
  styleAttr,
1338
1346
  tagVarSignal,
1339
1347
  tagVarSignalChange,
1348
+ textContent,
1340
1349
  value
1341
1350
  };
@@ -57,6 +57,7 @@ export declare class State {
57
57
  hasReorderRuntime: boolean;
58
58
  hasWrittenResume: boolean;
59
59
  trailerHTML: string;
60
+ nonceAttr: string;
60
61
  serializer: Serializer;
61
62
  writeReorders: Chunk[] | null;
62
63
  scopes: Map<number, PartialScope>;
package/dist/html.js CHANGED
@@ -1095,7 +1095,7 @@ function tryCatch(renderBody, renderCatch) {
1095
1095
  var State2 = class {
1096
1096
  constructor($global2) {
1097
1097
  this.$global = $global2;
1098
- this.$global = $global2;
1098
+ this.$global = $global2, $global2.cspNonce && (this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + ""));
1099
1099
  }
1100
1100
  tagIndex = 0;
1101
1101
  scopeIndex = 0;
@@ -1106,6 +1106,7 @@ var State2 = class {
1106
1106
  hasReorderRuntime = !1;
1107
1107
  hasWrittenResume = !1;
1108
1108
  trailerHTML = "";
1109
+ nonceAttr = "";
1109
1110
  serializer = new Serializer();
1110
1111
  writeReorders = null;
1111
1112
  scopes = /* @__PURE__ */ new Map();
@@ -1220,7 +1221,7 @@ var State2 = class {
1220
1221
  }
1221
1222
  };
1222
1223
  function prepareChunk(chunk) {
1223
- let head = chunk.consume(), { boundary, effects } = head, { state } = boundary, { $global: $global2, runtimePrefix, serializer } = state, nonceAttr = $global2.cspNonce ? " nonce=" + escapeAttrValue($global2.cspNonce + "") : "", { html, scripts } = head, hasWalk = !1;
1224
+ let head = chunk.consume(), { boundary, effects } = head, { state } = boundary, { $global: $global2, runtimePrefix, serializer, nonceAttr } = state, { html, scripts } = head, hasWalk = !1;
1224
1225
  head.effects = "", state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
1225
1226
  scripts,
1226
1227
  WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
@@ -1261,7 +1262,7 @@ function prepareChunk(chunk) {
1261
1262
  }
1262
1263
  function flushChunk(head, last) {
1263
1264
  let { boundary } = head, { state } = boundary, { html, scripts } = head, { $global: $global2 } = state, { __flush__ } = $global2, result = html;
1264
- return head.html = head.scripts = "", scripts && (result += ($global2.cspNonce ? "<script nonce=" + escapeAttrValue($global2.cspNonce + "") + ">" : "<script>") + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, result = __flush__($global2, result)), last && state.trailerHTML && (result += state.trailerHTML), result;
1265
+ return head.html = head.scripts = "", scripts && (result += "<script" + state.nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, result = __flush__($global2, result)), last && state.trailerHTML && (result += state.trailerHTML), result;
1265
1266
  }
1266
1267
  function writeTrailers(html) {
1267
1268
  $chunk.boundary.state.trailerHTML += html;
package/dist/html.mjs CHANGED
@@ -1022,7 +1022,7 @@ function tryCatch(renderBody, renderCatch) {
1022
1022
  var State2 = class {
1023
1023
  constructor($global2) {
1024
1024
  this.$global = $global2;
1025
- this.$global = $global2;
1025
+ this.$global = $global2, $global2.cspNonce && (this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + ""));
1026
1026
  }
1027
1027
  tagIndex = 0;
1028
1028
  scopeIndex = 0;
@@ -1033,6 +1033,7 @@ var State2 = class {
1033
1033
  hasReorderRuntime = !1;
1034
1034
  hasWrittenResume = !1;
1035
1035
  trailerHTML = "";
1036
+ nonceAttr = "";
1036
1037
  serializer = new Serializer();
1037
1038
  writeReorders = null;
1038
1039
  scopes = /* @__PURE__ */ new Map();
@@ -1147,7 +1148,7 @@ var State2 = class {
1147
1148
  }
1148
1149
  };
1149
1150
  function prepareChunk(chunk) {
1150
- let head = chunk.consume(), { boundary, effects } = head, { state } = boundary, { $global: $global2, runtimePrefix, serializer } = state, nonceAttr = $global2.cspNonce ? " nonce=" + escapeAttrValue($global2.cspNonce + "") : "", { html, scripts } = head, hasWalk = !1;
1151
+ let head = chunk.consume(), { boundary, effects } = head, { state } = boundary, { $global: $global2, runtimePrefix, serializer, nonceAttr } = state, { html, scripts } = head, hasWalk = !1;
1151
1152
  head.effects = "", state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
1152
1153
  scripts,
1153
1154
  WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
@@ -1188,7 +1189,7 @@ function prepareChunk(chunk) {
1188
1189
  }
1189
1190
  function flushChunk(head, last) {
1190
1191
  let { boundary } = head, { state } = boundary, { html, scripts } = head, { $global: $global2 } = state, { __flush__ } = $global2, result = html;
1191
- return head.html = head.scripts = "", scripts && (result += ($global2.cspNonce ? "<script nonce=" + escapeAttrValue($global2.cspNonce + "") + ">" : "<script>") + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, result = __flush__($global2, result)), last && state.trailerHTML && (result += state.trailerHTML), result;
1192
+ return head.html = head.scripts = "", scripts && (result += "<script" + state.nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, result = __flush__($global2, result)), last && state.trailerHTML && (result += state.trailerHTML), result;
1192
1193
  }
1193
1194
  function writeTrailers(html) {
1194
1195
  $chunk.boundary.state.trailerHTML += html;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/runtime-tags",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",