@orkestrel/template 0.0.18 → 0.0.20

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.
@@ -1620,7 +1620,7 @@ export declare function compileTemplateUnary(tokens: readonly TemplateToken[], i
1620
1620
  export declare function renderTemplateValue(value: TemplateRuntimeValue): string;
1621
1621
 
1622
1622
  /**
1623
- * Resolves a Private Use Area sentinel prefix guaranteed absent from `combined`.
1623
+ * Resolves a Private Use Area sentinel prefix absent from `combined`.
1624
1624
  *
1625
1625
  * @param combined - Concatenated template text and fill values in one markdown run
1626
1626
  * @returns The collision-free sentinel prefix
@@ -1686,7 +1686,7 @@ export declare function compileTemplateUnary(tokens: readonly TemplateToken[], i
1686
1686
  * ```ts
1687
1687
  * import { restoreMarkdownBlock } from '@orkestrel/template'
1688
1688
  *
1689
- * restoreMarkdownBlock({ element: 'thematicBreak' }, /\uE000\uE001(\d+)\uE003/gu, []) // { element: 'thematicBreak' }
1689
+ * restoreMarkdownBlock({ element: 'rule' }, /\uE000\uE001(\d+)\uE003/gu, []) // { element: 'rule' }
1690
1690
  * ```
1691
1691
  */
1692
1692
  export declare function restoreMarkdownBlock(node: BlockNode, pattern: RegExp, fills: readonly string[], depth?: number): BlockNode;
@@ -1620,7 +1620,7 @@ export declare function compileTemplateUnary(tokens: readonly TemplateToken[], i
1620
1620
  export declare function renderTemplateValue(value: TemplateRuntimeValue): string;
1621
1621
 
1622
1622
  /**
1623
- * Resolves a Private Use Area sentinel prefix guaranteed absent from `combined`.
1623
+ * Resolves a Private Use Area sentinel prefix absent from `combined`.
1624
1624
  *
1625
1625
  * @param combined - Concatenated template text and fill values in one markdown run
1626
1626
  * @returns The collision-free sentinel prefix
@@ -1686,7 +1686,7 @@ export declare function compileTemplateUnary(tokens: readonly TemplateToken[], i
1686
1686
  * ```ts
1687
1687
  * import { restoreMarkdownBlock } from '@orkestrel/template'
1688
1688
  *
1689
- * restoreMarkdownBlock({ element: 'thematicBreak' }, /\uE000\uE001(\d+)\uE003/gu, []) // { element: 'thematicBreak' }
1689
+ * restoreMarkdownBlock({ element: 'rule' }, /\uE000\uE001(\d+)\uE003/gu, []) // { element: 'rule' }
1690
1690
  * ```
1691
1691
  */
1692
1692
  export declare function restoreMarkdownBlock(node: BlockNode, pattern: RegExp, fills: readonly string[], depth?: number): BlockNode;
@@ -1317,8 +1317,8 @@ function renderTemplateType(value) {
1317
1317
  */
1318
1318
  function renderTemplateNumber(value) {
1319
1319
  if (Number.isNaN(value)) return "nan";
1320
- if (value === Infinity) return "inf";
1321
- if (value === -Infinity) return "-inf";
1320
+ if (value === 1e400) return "inf";
1321
+ if (value === -1e400) return "-inf";
1322
1322
  if (Number.isInteger(value)) return Object.is(value, -0) ? "0" : String(value);
1323
1323
  const [digits = "", power = "0"] = value.toExponential().split("e");
1324
1324
  const exponent = Number(power);
@@ -2797,9 +2797,9 @@ function sanitizeTemplateMarkdownInlines(nodes, options, depth = 0) {
2797
2797
  const schemes = options?.schemes ?? SAFE_URL_SCHEMES;
2798
2798
  const sanitized = [];
2799
2799
  for (const child of nodes) {
2800
- if (child.element === "codeSpan") {
2800
+ if (child.element === "code") {
2801
2801
  sanitized.push({
2802
- element: "codeSpan",
2802
+ element: "code",
2803
2803
  value: normalizeTemplateMarkdownText(child.value)
2804
2804
  });
2805
2805
  continue;
@@ -2887,15 +2887,15 @@ function sanitizeTemplateMarkdown(node, options, depth = 0) {
2887
2887
  switch (node.element) {
2888
2888
  case "text":
2889
2889
  case "break":
2890
- case "thematicBreak": return node;
2891
- case "codeSpan": return {
2892
- element: "codeSpan",
2890
+ case "rule": return node;
2891
+ case "code": return {
2892
+ element: "code",
2893
2893
  value: normalizeTemplateMarkdownText(node.value)
2894
2894
  };
2895
- case "codeBlock": {
2895
+ case "fence": {
2896
2896
  const lang = node.lang !== void 0 ? sanitizeTemplateMarkdownLanguage(node.lang) : void 0;
2897
2897
  return {
2898
- element: "codeBlock",
2898
+ element: "fence",
2899
2899
  ...lang !== void 0 ? { lang } : {},
2900
2900
  code: node.code
2901
2901
  };
@@ -2944,13 +2944,13 @@ function sanitizeTemplateMarkdown(node, options, depth = 0) {
2944
2944
  element: "blockquote",
2945
2945
  children: sanitizeTemplateMarkdownBlocks(node.children, options, depth + 1)
2946
2946
  };
2947
- case "listItem": return {
2948
- element: "listItem",
2947
+ case "entry": return {
2948
+ element: "entry",
2949
2949
  children: sanitizeTemplateMarkdownBlocks(node.children, options, depth + 1)
2950
2950
  };
2951
2951
  case "list": {
2952
2952
  const items = node.items.map((item) => ({
2953
- element: "listItem",
2953
+ element: "entry",
2954
2954
  children: sanitizeTemplateMarkdownBlocks(item.children, options, depth + 1)
2955
2955
  }));
2956
2956
  return {
@@ -2973,7 +2973,7 @@ function sanitizeTemplateMarkdown(node, options, depth = 0) {
2973
2973
  }
2974
2974
  }
2975
2975
  /**
2976
- * Resolves a Private Use Area sentinel prefix guaranteed absent from `combined`.
2976
+ * Resolves a Private Use Area sentinel prefix absent from `combined`.
2977
2977
  *
2978
2978
  * @param combined - Concatenated template text and fill values in one markdown run
2979
2979
  * @returns The collision-free sentinel prefix
@@ -3040,8 +3040,8 @@ function restoreMarkdownInlines(nodes, pattern, fills, depth = 0) {
3040
3040
  element: "text",
3041
3041
  value: restoreMarkdownText(node.value, pattern, inlineFills)
3042
3042
  };
3043
- case "codeSpan": return {
3044
- element: "codeSpan",
3043
+ case "code": return {
3044
+ element: "code",
3045
3045
  value: normalizeTemplateMarkdownText(restoreMarkdownText(node.value, pattern, inlineFills))
3046
3046
  };
3047
3047
  case "break": return node;
@@ -3078,13 +3078,13 @@ function restoreMarkdownInlines(nodes, pattern, fills, depth = 0) {
3078
3078
  * ```ts
3079
3079
  * import { restoreMarkdownBlock } from '@orkestrel/template'
3080
3080
  *
3081
- * restoreMarkdownBlock({ element: 'thematicBreak' }, /\uE000\uE001(\d+)\uE003/gu, []) // { element: 'thematicBreak' }
3081
+ * restoreMarkdownBlock({ element: 'rule' }, /\uE000\uE001(\d+)\uE003/gu, []) // { element: 'rule' }
3082
3082
  * ```
3083
3083
  */
3084
3084
  function restoreMarkdownBlock(node, pattern, fills, depth = 0) {
3085
3085
  if (depth >= MAX_DEPTH) return node;
3086
3086
  switch (node.element) {
3087
- case "thematicBreak": return node;
3087
+ case "rule": return node;
3088
3088
  case "heading": return {
3089
3089
  element: "heading",
3090
3090
  level: node.level,
@@ -3094,10 +3094,10 @@ function restoreMarkdownBlock(node, pattern, fills, depth = 0) {
3094
3094
  element: "paragraph",
3095
3095
  children: restoreMarkdownInlines(node.children, pattern, fills, depth + 1)
3096
3096
  };
3097
- case "codeBlock": {
3097
+ case "fence": {
3098
3098
  const lang = node.lang !== void 0 ? sanitizeTemplateMarkdownLanguage(restoreMarkdownText(node.lang, pattern, fills)) : void 0;
3099
3099
  return {
3100
- element: "codeBlock",
3100
+ element: "fence",
3101
3101
  ...lang !== void 0 ? { lang } : {},
3102
3102
  code: restoreMarkdownText(node.code, pattern, fills)
3103
3103
  };
@@ -3111,7 +3111,7 @@ function restoreMarkdownBlock(node, pattern, fills, depth = 0) {
3111
3111
  ordered: node.ordered,
3112
3112
  start: node.start,
3113
3113
  items: node.items.map((item) => ({
3114
- element: "listItem",
3114
+ element: "entry",
3115
3115
  children: item.children.map((child) => restoreMarkdownBlock(child, pattern, fills, depth + 1))
3116
3116
  }))
3117
3117
  };
@@ -4444,7 +4444,7 @@ function templateToMarkdown(source, values, options) {
4444
4444
  }
4445
4445
  const sanitized = sanitizeTemplateMarkdown(part, options?.sanitize);
4446
4446
  if (sanitized === void 0) continue;
4447
- if (sanitized.element === "document" || sanitized.element === "listItem") for (const block of sanitized.children) blocks.push(block);
4447
+ if (sanitized.element === "document" || sanitized.element === "entry") for (const block of sanitized.children) blocks.push(block);
4448
4448
  else if (isBlockNode(sanitized)) blocks.push(sanitized);
4449
4449
  else if (isInlineNode(sanitized)) blocks.push({
4450
4450
  element: "paragraph",