@alloy-js/markdown 0.25.0 → 0.27.0-dev.4

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +45 -0
  3. package/dist/dev/src/components/Code.js +20 -5
  4. package/dist/dev/src/components/Code.js.map +1 -1
  5. package/dist/dev/src/components/Heading.js +66 -2
  6. package/dist/dev/src/components/Heading.js.map +1 -1
  7. package/dist/dev/src/components/Link.js +33 -1
  8. package/dist/dev/src/components/Link.js.map +1 -1
  9. package/dist/dev/src/components/SourceFile.js +27 -6
  10. package/dist/dev/src/components/SourceFile.js.map +1 -1
  11. package/dist/dev/src/components/index.js +2 -0
  12. package/dist/dev/src/components/index.js.map +1 -1
  13. package/dist/dev/src/components/inline-code.js +28 -0
  14. package/dist/dev/src/components/inline-code.js.map +1 -0
  15. package/dist/dev/src/components/table.js +98 -0
  16. package/dist/dev/src/components/table.js.map +1 -0
  17. package/dist/dev/src/context/source-file.js +50 -0
  18. package/dist/dev/src/context/source-file.js.map +1 -0
  19. package/dist/dev/src/context/table.js +8 -0
  20. package/dist/dev/src/context/table.js.map +1 -0
  21. package/dist/dev/src/symbols/heading-symbol.js +22 -0
  22. package/dist/dev/src/symbols/heading-symbol.js.map +1 -0
  23. package/dist/dev/test/Code.test.js +150 -6
  24. package/dist/dev/test/Code.test.js.map +1 -1
  25. package/dist/dev/test/heading.test.js +774 -0
  26. package/dist/dev/test/heading.test.js.map +1 -0
  27. package/dist/dev/test/inline-code.test.js +236 -0
  28. package/dist/dev/test/inline-code.test.js.map +1 -0
  29. package/dist/dev/test/table.test.js +499 -0
  30. package/dist/dev/test/table.test.js.map +1 -0
  31. package/dist/dev/test/vitest.d.js.map +1 -1
  32. package/dist/src/components/Code.d.ts +10 -3
  33. package/dist/src/components/Code.d.ts.map +1 -1
  34. package/dist/src/components/Code.js +19 -4
  35. package/dist/src/components/Code.js.map +1 -1
  36. package/dist/src/components/Heading.d.ts +10 -2
  37. package/dist/src/components/Heading.d.ts.map +1 -1
  38. package/dist/src/components/Heading.js +54 -2
  39. package/dist/src/components/Heading.js.map +1 -1
  40. package/dist/src/components/Link.d.ts +9 -1
  41. package/dist/src/components/Link.d.ts.map +1 -1
  42. package/dist/src/components/Link.js +33 -1
  43. package/dist/src/components/Link.js.map +1 -1
  44. package/dist/src/components/SourceFile.d.ts.map +1 -1
  45. package/dist/src/components/SourceFile.js +17 -4
  46. package/dist/src/components/SourceFile.js.map +1 -1
  47. package/dist/src/components/index.d.ts +2 -0
  48. package/dist/src/components/index.d.ts.map +1 -1
  49. package/dist/src/components/index.js +2 -0
  50. package/dist/src/components/index.js.map +1 -1
  51. package/dist/src/components/inline-code.d.ts +16 -0
  52. package/dist/src/components/inline-code.d.ts.map +1 -0
  53. package/dist/src/components/inline-code.js +28 -0
  54. package/dist/src/components/inline-code.js.map +1 -0
  55. package/dist/src/components/table.d.ts +37 -0
  56. package/dist/src/components/table.d.ts.map +1 -0
  57. package/dist/src/components/table.js +74 -0
  58. package/dist/src/components/table.js.map +1 -0
  59. package/dist/src/context/source-file.d.ts +19 -0
  60. package/dist/src/context/source-file.d.ts.map +1 -0
  61. package/dist/src/context/source-file.js +50 -0
  62. package/dist/src/context/source-file.js.map +1 -0
  63. package/dist/src/context/table.d.ts +4 -0
  64. package/dist/src/context/table.d.ts.map +1 -0
  65. package/dist/src/context/table.js +8 -0
  66. package/dist/src/context/table.js.map +1 -0
  67. package/dist/src/symbols/heading-symbol.d.ts +14 -0
  68. package/dist/src/symbols/heading-symbol.d.ts.map +1 -0
  69. package/dist/src/symbols/heading-symbol.js +22 -0
  70. package/dist/src/symbols/heading-symbol.js.map +1 -0
  71. package/dist/test/Code.test.js +107 -3
  72. package/dist/test/Code.test.js.map +1 -1
  73. package/dist/test/heading.test.d.ts +2 -0
  74. package/dist/test/heading.test.d.ts.map +1 -0
  75. package/dist/test/heading.test.js +494 -0
  76. package/dist/test/heading.test.js.map +1 -0
  77. package/dist/test/inline-code.test.d.ts +2 -0
  78. package/dist/test/inline-code.test.d.ts.map +1 -0
  79. package/dist/test/inline-code.test.js +148 -0
  80. package/dist/test/inline-code.test.js.map +1 -0
  81. package/dist/test/table.test.d.ts +2 -0
  82. package/dist/test/table.test.d.ts.map +1 -0
  83. package/dist/test/table.test.js +303 -0
  84. package/dist/test/table.test.js.map +1 -0
  85. package/dist/test/vitest.d.js.map +1 -1
  86. package/dist/tsconfig.tsbuildinfo +1 -1
  87. package/docs/index.md +92 -0
  88. package/docs/tables.md +81 -0
  89. package/package.json +11 -6
  90. package/src/components/Code.tsx +35 -8
  91. package/src/components/Heading.tsx +103 -4
  92. package/src/components/Link.tsx +61 -2
  93. package/src/components/SourceFile.tsx +19 -2
  94. package/src/components/index.ts +2 -0
  95. package/src/components/inline-code.tsx +51 -0
  96. package/src/components/table.tsx +113 -0
  97. package/src/context/source-file.ts +79 -0
  98. package/src/context/table.ts +8 -0
  99. package/src/symbols/heading-symbol.ts +38 -0
  100. package/temp/api.json +552 -9
  101. package/test/Code.test.tsx +102 -2
  102. package/test/heading.test.tsx +464 -0
  103. package/test/inline-code.test.tsx +166 -0
  104. package/test/table.test.tsx +282 -0
  105. package/test/vitest.d.ts +4 -1
@@ -1,7 +1,59 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
1
+ import { memo as _$memo, createIntrinsic as _$createIntrinsic, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { BasicScope, childrenArray, code, createSymbol, Declaration, memo, onCleanup, shallowRef, SourceFileContext, useContext, useScope } from "@alloy-js/core";
2
3
  import { useSectionContext } from "../context/section.js";
4
+ import { MarkdownFileContext } from "../context/source-file.js";
5
+ import { HeadingSymbol } from "../symbols/heading-symbol.js";
3
6
  export function Heading(props) {
4
7
  const level = props.level !== undefined ? props.level : useSectionContext().level;
5
- return [_$memo(() => "#".repeat(level)), " ", _$memo(() => props.children)];
8
+ const children = memo(() => childrenArray(() => props.children));
9
+ const file = useContext(MarkdownFileContext);
10
+ const sourceFile = useContext(SourceFileContext);
11
+ const scope = useScope();
12
+ if (!file || !sourceFile || !(scope instanceof BasicScope)) {
13
+ if (props.refkey === undefined && props.id === undefined) {
14
+ return [_$memo(() => "#".repeat(level)), " ", children];
15
+ }
16
+ throw new Error("Heading must be rendered inside a Markdown SourceFile.");
17
+ }
18
+ const text = memo(() => headingText(children()));
19
+ const symbol = props.refkey === undefined ? undefined : createSymbol(HeadingSymbol, props.id ?? "", scope.symbols, {
20
+ refkeys: props.refkey,
21
+ ignoreNameConflict: true,
22
+ path: sourceFile.path,
23
+ text
24
+ });
25
+ const entry = {
26
+ text,
27
+ get id() {
28
+ const id = props.id;
29
+ if (id !== undefined && (id.length === 0 || /[\s"'<>&]/u.test(id))) {
30
+ throw new Error(`Invalid Markdown heading ID: ${JSON.stringify(id)}.`);
31
+ }
32
+ return id;
33
+ },
34
+ symbol,
35
+ anchor: shallowRef()
36
+ };
37
+ file.headings.add(entry);
38
+ onCleanup(() => {
39
+ file.headings.delete(entry);
40
+ symbol?.delete();
41
+ });
42
+ const heading = [() => entry.anchor.value !== undefined && [_$memo(() => code`<a id="${entry.anchor.value}"></a>`), _$createIntrinsic("hbr", {}), _$createIntrinsic("hbr", {})], _$memo(() => "#".repeat(level)), " ", children];
43
+ return symbol ? _$createComponent(Declaration, {
44
+ symbol: symbol,
45
+ children: heading
46
+ }) : heading;
47
+ }
48
+ function headingText(children) {
49
+ let text = "";
50
+ for (const child of children) {
51
+ if (typeof child === "string" || typeof child === "number") {
52
+ text += child;
53
+ } else if (child !== null && child !== undefined && typeof child !== "boolean") {
54
+ return undefined;
55
+ }
56
+ }
57
+ return text.trim();
6
58
  }
7
59
  //# sourceMappingURL=Heading.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../../src/components/Heading.tsx"],"sourcesContent":["import type { Refkey } from \"@alloy-js/core\";\nimport type { Children } from \"@alloy-js/core/jsx-runtime\";\n\nimport { useSectionContext } from \"../context/section.js\";\n\nexport interface HeadingProps {\n level?: number;\n children: Children;\n refkey?: Refkey;\n}\n\nexport function Heading(props: HeadingProps) {\n const level =\n props.level !== undefined ? props.level : useSectionContext().level;\n return (\n <>\n {\"#\".repeat(level)} {props.children}\n </>\n );\n}\n"],"mappings":";AAGA,SAAS,iBAAiB,QAAQ,uBAAuB;AAQzD,OAAO,SAAS,OAAO,CAAC,KAAmB,EAAE;EAC3C,MAAM,KAAK,GACT,KAAK,CAAC,KAAK,KAAK,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,iBAAiB,CAAC,CAAC,CAAC,KAAK;EACrE,qBAEK,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAG,KAAK,CAAC,QAAQ;AAGzC","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["../../../src/components/Heading.tsx"],"sourcesContent":["import {\n BasicScope,\n childrenArray,\n code,\n createSymbol,\n Declaration,\n memo,\n onCleanup,\n shallowRef,\n SourceFileContext,\n useContext,\n useScope,\n type Children,\n type Refkey,\n} from \"@alloy-js/core\";\n\nimport { useSectionContext } from \"../context/section.js\";\nimport {\n MarkdownFileContext,\n type HeadingEntry,\n} from \"../context/source-file.js\";\nimport { HeadingSymbol } from \"../symbols/heading-symbol.js\";\n\nexport interface HeadingProps {\n /** Heading depth. Defaults to the current section depth. */\n level?: number;\n /**\n * Heading content. Automatic IDs and default link text are derived from\n * string children; headings with JSX children need an explicit `id` to be\n * referenced.\n */\n children: Children;\n /** Key used to link to this heading. */\n refkey?: Refkey;\n /** Stable anchor ID independent of the display text. Must be unique in the file. */\n id?: string;\n}\n\nexport function Heading(props: HeadingProps) {\n const level =\n props.level !== undefined ? props.level : useSectionContext().level;\n const children = memo(() => childrenArray(() => props.children));\n const file = useContext(MarkdownFileContext);\n const sourceFile = useContext(SourceFileContext);\n const scope = useScope();\n if (!file || !sourceFile || !(scope instanceof BasicScope)) {\n if (props.refkey === undefined && props.id === undefined) {\n return (\n <>\n {\"#\".repeat(level)} {children}\n </>\n );\n }\n throw new Error(\"Heading must be rendered inside a Markdown SourceFile.\");\n }\n\n const text = memo(() => headingText(children()));\n const symbol =\n props.refkey === undefined\n ? undefined\n : createSymbol(HeadingSymbol, props.id ?? \"\", scope.symbols, {\n refkeys: props.refkey,\n ignoreNameConflict: true,\n path: sourceFile.path,\n text,\n });\n const entry: HeadingEntry = {\n text,\n get id() {\n const id = props.id;\n if (id !== undefined && (id.length === 0 || /[\\s\"'<>&]/u.test(id))) {\n throw new Error(`Invalid Markdown heading ID: ${JSON.stringify(id)}.`);\n }\n return id;\n },\n symbol,\n anchor: shallowRef<string>(),\n };\n file.headings.add(entry);\n onCleanup(() => {\n file.headings.delete(entry);\n symbol?.delete();\n });\n const heading = (\n <>\n {() =>\n entry.anchor.value !== undefined && (\n <>\n {code`<a id=\"${entry.anchor.value}\"></a>`}\n <hbr />\n <hbr />\n </>\n )\n }\n {\"#\".repeat(level)} {children}\n </>\n );\n return symbol ? (\n <Declaration symbol={symbol}>{heading}</Declaration>\n ) : (\n heading\n );\n}\n\nfunction headingText(children: Children[]): string | undefined {\n let text = \"\";\n for (const child of children) {\n if (typeof child === \"string\" || typeof child === \"number\") {\n text += child;\n } else if (\n child !== null &&\n child !== undefined &&\n typeof child !== \"boolean\"\n ) {\n return undefined;\n }\n }\n return text.trim();\n}\n"],"mappings":";AAAA,SACE,UAAU,EACV,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,QAAQ,QAGH,gBAAgB;AAEvB,SAAS,iBAAiB,QAAQ,uBAAuB;AACzD,SACE,mBAAmB,QAEd,2BAA2B;AAClC,SAAS,aAAa,QAAQ,8BAA8B;AAiB5D,OAAO,SAAS,OAAO,CAAC,KAAmB,EAAE;EAC3C,MAAM,KAAK,GACT,KAAK,CAAC,KAAK,KAAK,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,iBAAiB,CAAC,CAAC,CAAC,KAAK;EACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,aAAa,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;EAChE,MAAM,IAAI,GAAG,UAAU,CAAC,mBAAmB,CAAC;EAC5C,MAAM,UAAU,GAAG,UAAU,CAAC,iBAAiB,CAAC;EAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC;EACxB,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,IAAI,EAAE,KAAK,YAAY,UAAU,CAAC,EAAE;IAC1D,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,EAAE,KAAK,SAAS,EAAE;MACxD,qBAEK,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAG,QAAQ;IAGnC;IACA,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC;EAC3E;EAEA,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;EAChD,MAAM,MAAM,GACV,KAAK,CAAC,MAAM,KAAK,SAAS,GACtB,SAAS,GACT,YAAY,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE;IACzD,OAAO,EAAE,KAAK,CAAC,MAAM;IACrB,kBAAkB,EAAE,IAAI;IACxB,IAAI,EAAE,UAAU,CAAC,IAAI;IACrB;EACF,CAAC,CAAC;EACR,MAAM,KAAmB,GAAG;IAC1B,IAAI;IACJ,IAAI,EAAE,GAAG;MACP,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE;MACnB,IAAI,EAAE,KAAK,SAAS,KAAK,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE;QAClE,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC;MACxE;MACA,OAAO,EAAE;IACX,CAAC;IACD,MAAM;IACN,MAAM,EAAE,UAAU,CAAS;EAC7B,CAAC;EACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC;EACxB,SAAS,CAAC,MAAM;IACd,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,CAAC;EAClB,CAAC,CAAC;EACF,MAAM,OAAO,IAER,MACC,KAAK,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,kBAE3B,IAAI,UAAU,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ,8DAI5C,eAEF,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAG,QAAQ,CAEhC;EACD,OAAO,MAAM,qBACV,WAAW;IAAC,MAAM,EAAE,MAAM;IAAA,UAAG;EAAO,KAErC,OACD;AACH;AAEA,SAAS,WAAW,CAAC,QAAoB,EAAsB;EAC7D,IAAI,IAAI,GAAG,EAAE;EACb,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;MAC1D,IAAI,IAAI,KAAK;IACf,CAAC,MAAM,IACL,KAAK,KAAK,IAAI,IACd,KAAK,KAAK,SAAS,IACnB,OAAO,KAAK,KAAK,SAAS,EAC1B;MACA,OAAO,SAAS;IAClB;EACF;EACA,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;AACpB","ignoreList":[]}
@@ -1,9 +1,17 @@
1
- import type { Refkey } from "@alloy-js/core";
1
+ import { type Refkey } from "@alloy-js/core";
2
2
  export interface LinkPropsWithRefkey {
3
+ /** Key of the target heading, which may be declared later or in another file. */
3
4
  refkey: Refkey;
5
+ /**
6
+ * Override the link text. Defaults to the target heading's text, which
7
+ * requires the heading to have string children.
8
+ */
9
+ title?: string;
4
10
  }
5
11
  export interface LinkPropsWithHref {
12
+ /** Link destination. */
6
13
  href: string;
14
+ /** Link text. */
7
15
  title: string;
8
16
  }
9
17
  export type LinkProps = LinkPropsWithRefkey | LinkPropsWithHref;
@@ -1 +1 @@
1
- {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../src/components/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,SAAS,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAEhE,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,qCAUpC"}
1
+ {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../src/components/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,MAAM,EACZ,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,mBAAmB;IAClC,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,SAAS,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAEhE,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,qCAiCpC"}
@@ -1,8 +1,40 @@
1
1
  import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { resolve, SourceFileContext, unresolvedRefkey, useContext } from "@alloy-js/core";
3
+ import { dirname, relative } from "pathe";
4
+ import { useTableContext } from "../context/table.js";
5
+ import { HeadingSymbol } from "../symbols/heading-symbol.js";
2
6
  export function Link(props) {
3
7
  if ("refkey" in props) {
4
- return "refkey";
8
+ const sourceFile = useContext(SourceFileContext);
9
+ if (!sourceFile) {
10
+ throw new Error("Link references must be rendered inside a SourceFile.");
11
+ }
12
+ const table = useTableContext();
13
+ return () => {
14
+ const target = resolve(props.refkey);
15
+ if (!target.value) {
16
+ return unresolvedRefkey(props.refkey);
17
+ }
18
+ const symbol = target.value.symbol;
19
+ if (!(symbol instanceof HeadingSymbol)) {
20
+ throw new Error("Markdown Link refkey must reference a Heading.");
21
+ }
22
+ const path = sourceFile.path === symbol.path ? "" : relative(dirname(sourceFile.path), symbol.path).split("/").map(encodeUrlPart).join("/");
23
+ const href = `${path}#${encodeUrlPart(symbol.name)}`;
24
+ return `[${props.title ?? defaultTitle(symbol, table)}](${href})`;
25
+ };
5
26
  }
6
27
  return ["[", _$memo(() => props.title), "](", _$memo(() => props.href), ")"];
7
28
  }
29
+ function defaultTitle(symbol, table) {
30
+ const text = symbol.text();
31
+ if (text === undefined) {
32
+ throw new Error(`Link to Markdown heading ${JSON.stringify(symbol.name)} requires a title because the heading has non-string children.`);
33
+ }
34
+ const title = text.replace(/[\\`*_[\]<>&~]/g, "\\$&");
35
+ return table ? title.replace(/\|/g, "\\|") : title;
36
+ }
37
+ function encodeUrlPart(value) {
38
+ return encodeURIComponent(value).replace(/[!'()*]/g, character => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
39
+ }
8
40
  //# sourceMappingURL=Link.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../../src/components/Link.tsx"],"sourcesContent":["import type { Refkey } from \"@alloy-js/core\";\n\nexport interface LinkPropsWithRefkey {\n refkey: Refkey;\n}\n\nexport interface LinkPropsWithHref {\n href: string;\n title: string;\n}\n\nexport type LinkProps = LinkPropsWithRefkey | LinkPropsWithHref;\n\nexport function Link(props: LinkProps) {\n if (\"refkey\" in props) {\n return \"refkey\";\n }\n\n return (\n <>\n [{props.title}]({props.href})\n </>\n );\n}\n"],"mappings":";AAaA,OAAO,SAAS,IAAI,CAAC,KAAgB,EAAE;EACrC,IAAI,QAAQ,IAAI,KAAK,EAAE;IACrB,OAAO,QAAQ;EACjB;EAEA,0BAEM,KAAK,CAAC,KAAK,sBAAI,KAAK,CAAC,IAAI;AAGjC","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["../../../src/components/Link.tsx"],"sourcesContent":["import {\n resolve,\n SourceFileContext,\n unresolvedRefkey,\n useContext,\n type Refkey,\n} from \"@alloy-js/core\";\nimport { dirname, relative } from \"pathe\";\n\nimport { useTableContext } from \"../context/table.js\";\nimport { HeadingSymbol } from \"../symbols/heading-symbol.js\";\n\nexport interface LinkPropsWithRefkey {\n /** Key of the target heading, which may be declared later or in another file. */\n refkey: Refkey;\n /**\n * Override the link text. Defaults to the target heading's text, which\n * requires the heading to have string children.\n */\n title?: string;\n}\n\nexport interface LinkPropsWithHref {\n /** Link destination. */\n href: string;\n /** Link text. */\n title: string;\n}\n\nexport type LinkProps = LinkPropsWithRefkey | LinkPropsWithHref;\n\nexport function Link(props: LinkProps) {\n if (\"refkey\" in props) {\n const sourceFile = useContext(SourceFileContext);\n if (!sourceFile) {\n throw new Error(\"Link references must be rendered inside a SourceFile.\");\n }\n const table = useTableContext();\n return () => {\n const target = resolve(props.refkey);\n if (!target.value) {\n return unresolvedRefkey(props.refkey);\n }\n const symbol = target.value.symbol;\n if (!(symbol instanceof HeadingSymbol)) {\n throw new Error(\"Markdown Link refkey must reference a Heading.\");\n }\n const path =\n sourceFile.path === symbol.path\n ? \"\"\n : relative(dirname(sourceFile.path), symbol.path)\n .split(\"/\")\n .map(encodeUrlPart)\n .join(\"/\");\n const href = `${path}#${encodeUrlPart(symbol.name)}`;\n return `[${props.title ?? defaultTitle(symbol, table)}](${href})`;\n };\n }\n\n return (\n <>\n [{props.title}]({props.href})\n </>\n );\n}\n\nfunction defaultTitle(symbol: HeadingSymbol, table: boolean): string {\n const text = symbol.text();\n if (text === undefined) {\n throw new Error(\n `Link to Markdown heading ${JSON.stringify(symbol.name)} requires a title because the heading has non-string children.`,\n );\n }\n const title = text.replace(/[\\\\`*_[\\]<>&~]/g, \"\\\\$&\");\n return table ? title.replace(/\\|/g, \"\\\\|\") : title;\n}\n\nfunction encodeUrlPart(value: string): string {\n return encodeURIComponent(value).replace(\n /[!'()*]/g,\n (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`,\n );\n}\n"],"mappings":";AAAA,SACE,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,QAEL,gBAAgB;AACvB,SAAS,OAAO,EAAE,QAAQ,QAAQ,OAAO;AAEzC,SAAS,eAAe,QAAQ,qBAAqB;AACrD,SAAS,aAAa,QAAQ,8BAA8B;AAqB5D,OAAO,SAAS,IAAI,CAAC,KAAgB,EAAE;EACrC,IAAI,QAAQ,IAAI,KAAK,EAAE;IACrB,MAAM,UAAU,GAAG,UAAU,CAAC,iBAAiB,CAAC;IAChD,IAAI,CAAC,UAAU,EAAE;MACf,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC;IAC1E;IACA,MAAM,KAAK,GAAG,eAAe,CAAC,CAAC;IAC/B,OAAO,MAAM;MACX,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;MACpC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QACjB,OAAO,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC;MACvC;MACA,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM;MAClC,IAAI,EAAE,MAAM,YAAY,aAAa,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC;MACnE;MACA,MAAM,IAAI,GACR,UAAU,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,GAC3B,EAAE,GACF,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAC5C,KAAK,CAAC,GAAG,CAAC,CACV,GAAG,CAAC,aAAa,CAAC,CAClB,IAAI,CAAC,GAAG,CAAC;MAClB,MAAM,IAAI,GAAG,GAAG,IAAI,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;MACpD,OAAO,IAAI,KAAK,CAAC,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI,GAAG;IACnE,CAAC;EACH;EAEA,0BAEM,KAAK,CAAC,KAAK,sBAAI,KAAK,CAAC,IAAI;AAGjC;AAEA,SAAS,YAAY,CAAC,MAAqB,EAAE,KAAc,EAAU;EACnE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;EAC1B,IAAI,IAAI,KAAK,SAAS,EAAE;IACtB,MAAM,IAAI,KAAK,CACb,4BAA4B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,gEACzD,CAAC;EACH;EACA,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC;EACrD,OAAO,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,KAAK;AACpD;AAEA,SAAS,aAAa,CAAC,KAAa,EAAU;EAC5C,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,OAAO,CACtC,UAAU,EACT,SAAS,IAAK,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,EACvE,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK/C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;CACpB;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAMhD"}
1
+ {"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAgB/C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;CACpB;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAYhD"}
@@ -1,7 +1,10 @@
1
1
  import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { SourceFile as CoreSourceFile, List } from "@alloy-js/core";
2
+ import { BasicScope, SourceFile as CoreSourceFile, createScope, List, Scope, useScope } from "@alloy-js/core";
3
+ import { createMarkdownFileContext, MarkdownFileContext } from "../context/source-file.js";
3
4
  import { Link } from "./Link.js";
4
5
  export function SourceFile(props) {
6
+ const scope = createScope(BasicScope, props.path, useScope());
7
+ const file = createMarkdownFileContext();
5
8
  return _$createComponent(CoreSourceFile, {
6
9
  get path() {
7
10
  return props.path;
@@ -9,10 +12,20 @@ export function SourceFile(props) {
9
12
  filetype: "md",
10
13
  reference: Link,
11
14
  get children() {
12
- return _$createComponent(List, {
13
- doubleHardline: true,
15
+ return _$createComponent(Scope, {
16
+ value: scope,
14
17
  get children() {
15
- return props.children;
18
+ return _$createComponent(MarkdownFileContext.Provider, {
19
+ value: file,
20
+ get children() {
21
+ return _$createComponent(List, {
22
+ doubleHardline: true,
23
+ get children() {
24
+ return props.children;
25
+ }
26
+ });
27
+ }
28
+ });
16
29
  }
17
30
  });
18
31
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../../src/components/SourceFile.tsx"],"sourcesContent":["import type { Children } from \"@alloy-js/core\";\nimport { SourceFile as CoreSourceFile, List } from \"@alloy-js/core\";\n\nimport { Link } from \"./Link.jsx\";\n\nexport interface SourceFileProps {\n path: string;\n children: Children;\n}\nexport function SourceFile(props: SourceFileProps) {\n return (\n <CoreSourceFile path={props.path} filetype=\"md\" reference={Link}>\n <List doubleHardline>{props.children}</List>\n </CoreSourceFile>\n );\n}\n"],"mappings":";AACA,SAAS,UAAU,IAAI,cAAc,EAAE,IAAI,QAAQ,gBAAgB;AAEnE,SAAS,IAAI;AAMb,OAAO,SAAS,UAAU,CAAC,KAAsB,EAAE;EACjD,yBACG,cAAc;IAAA,IAAC,IAAI;MAAA,OAAE,KAAK,CAAC,IAAI;IAAA;IAAE,QAAQ;IAAM,SAAS,EAAE,IAAI;IAAA;MAAA,yBAC5D,IAAI;QAAC,cAAc;QAAA;UAAA,OAAE,KAAK,CAAC,QAAQ;QAAA;MAAA;IAAA;EAAA;AAG1C","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["../../../src/components/SourceFile.tsx"],"sourcesContent":["import type { Children } from \"@alloy-js/core\";\nimport {\n BasicScope,\n SourceFile as CoreSourceFile,\n createScope,\n List,\n Scope,\n useScope,\n} from \"@alloy-js/core\";\n\nimport {\n createMarkdownFileContext,\n MarkdownFileContext,\n} from \"../context/source-file.js\";\nimport { Link } from \"./Link.jsx\";\n\nexport interface SourceFileProps {\n path: string;\n children: Children;\n}\nexport function SourceFile(props: SourceFileProps) {\n const scope = createScope(BasicScope, props.path, useScope());\n const file = createMarkdownFileContext();\n return (\n <CoreSourceFile path={props.path} filetype=\"md\" reference={Link}>\n <Scope value={scope}>\n <MarkdownFileContext.Provider value={file}>\n <List doubleHardline>{props.children}</List>\n </MarkdownFileContext.Provider>\n </Scope>\n </CoreSourceFile>\n );\n}\n"],"mappings":";AACA,SACE,UAAU,EACV,UAAU,IAAI,cAAc,EAC5B,WAAW,EACX,IAAI,EACJ,KAAK,EACL,QAAQ,QACH,gBAAgB;AAEvB,SACE,yBAAyB,EACzB,mBAAmB,QACd,2BAA2B;AAClC,SAAS,IAAI;AAMb,OAAO,SAAS,UAAU,CAAC,KAAsB,EAAE;EACjD,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;EAC7D,MAAM,IAAI,GAAG,yBAAyB,CAAC,CAAC;EACxC,yBACG,cAAc;IAAA,IAAC,IAAI;MAAA,OAAE,KAAK,CAAC,IAAI;IAAA;IAAE,QAAQ;IAAM,SAAS,EAAE,IAAI;IAAA;MAAA,yBAC5D,KAAK;QAAC,KAAK,EAAE,KAAK;QAAA;UAAA,yBAChB,mBAAmB,CAAC,QAAQ;YAAC,KAAK,EAAE,IAAI;YAAA;cAAA,yBACtC,IAAI;gBAAC,cAAc;gBAAA;kBAAA,OAAE,KAAK,CAAC,QAAQ;gBAAA;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA;AAK9C","ignoreList":[]}
@@ -1,8 +1,10 @@
1
1
  export * from "./Code.jsx";
2
2
  export * from "./Frontmatter.jsx";
3
3
  export * from "./Heading.jsx";
4
+ export * from "./inline-code.jsx";
4
5
  export * from "./Link.jsx";
5
6
  export * from "./List.jsx";
6
7
  export * from "./Section.jsx";
7
8
  export * from "./SourceFile.jsx";
9
+ export * from "./table.jsx";
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
@@ -1,8 +1,10 @@
1
1
  export * from "./Code.js";
2
2
  export * from "./Frontmatter.js";
3
3
  export * from "./Heading.js";
4
+ export * from "./inline-code.js";
4
5
  export * from "./Link.js";
5
6
  export * from "./List.js";
6
7
  export * from "./Section.js";
7
8
  export * from "./SourceFile.js";
9
+ export * from "./table.js";
8
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from \"./Code.jsx\";\nexport * from \"./Frontmatter.jsx\";\nexport * from \"./Heading.jsx\";\nexport * from \"./Link.jsx\";\nexport * from \"./List.jsx\";\nexport * from \"./Section.jsx\";\nexport * from \"./SourceFile.jsx\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from \"./Code.jsx\";\nexport * from \"./Frontmatter.jsx\";\nexport * from \"./Heading.jsx\";\nexport * from \"./inline-code.jsx\";\nexport * from \"./Link.jsx\";\nexport * from \"./List.jsx\";\nexport * from \"./Section.jsx\";\nexport * from \"./SourceFile.jsx\";\nexport * from \"./table.jsx\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ import type { Children } from "@alloy-js/core";
2
+ export interface InlineCodeProps {
3
+ /**
4
+ * Direct strings are escaped automatically. JSX and other non-string
5
+ * children are wrapped in single backticks unchanged; callers own escaping.
6
+ */
7
+ children?: Children;
8
+ }
9
+ /**
10
+ * Render a Markdown code span. Direct strings use adaptive delimiters and
11
+ * padding, with each CRLF, CR, or LF replaced by one space.
12
+ * Empty strings and omitted content use inline HTML.
13
+ * Direct string pipes are escaped inside table cells and left literal elsewhere.
14
+ */
15
+ export declare function InlineCode(props: InlineCodeProps): () => Children;
16
+ //# sourceMappingURL=inline-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-code.d.ts","sourceRoot":"","sources":["../../../src/components/inline-code.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,kBAchD"}
@@ -0,0 +1,28 @@
1
+ import { useTableContext } from "../context/table.js";
2
+ /**
3
+ * Render a Markdown code span. Direct strings use adaptive delimiters and
4
+ * padding, with each CRLF, CR, or LF replaced by one space.
5
+ * Empty strings and omitted content use inline HTML.
6
+ * Direct string pipes are escaped inside table cells and left literal elsewhere.
7
+ */
8
+ export function InlineCode(props) {
9
+ const inTable = useTableContext();
10
+ return () => {
11
+ const content = props.children ?? "";
12
+ return typeof content === "string" ? inlineCode(inTable ? content.replace(/\|/g, "\\|") : content) : ["`", content, "`"];
13
+ };
14
+ }
15
+ function inlineCode(content) {
16
+ const text = content.replace(/\r\n|\r|\n/g, " ");
17
+ // CommonMark has no empty code-span syntax.
18
+ if (text.length === 0) return "<code></code>";
19
+ let delimiterLength = 1;
20
+ for (const match of text.matchAll(/`+/g)) {
21
+ delimiterLength = Math.max(delimiterLength, match[0].length + 1);
22
+ }
23
+ const delimiter = "`".repeat(delimiterLength);
24
+ const needsPadding = text.startsWith("`") || text.endsWith("`") || text.startsWith(" ") && text.endsWith(" ") && /[^ ]/.test(text);
25
+ const padding = needsPadding ? " " : "";
26
+ return delimiter + padding + text + padding + delimiter;
27
+ }
28
+ //# sourceMappingURL=inline-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../src/components/inline-code.tsx"],"sourcesContent":["import type { Children } from \"@alloy-js/core\";\n\nimport { useTableContext } from \"../context/table.js\";\n\nexport interface InlineCodeProps {\n /**\n * Direct strings are escaped automatically. JSX and other non-string\n * children are wrapped in single backticks unchanged; callers own escaping.\n */\n children?: Children;\n}\n\n/**\n * Render a Markdown code span. Direct strings use adaptive delimiters and\n * padding, with each CRLF, CR, or LF replaced by one space.\n * Empty strings and omitted content use inline HTML.\n * Direct string pipes are escaped inside table cells and left literal elsewhere.\n */\nexport function InlineCode(props: InlineCodeProps) {\n const inTable = useTableContext();\n return () => {\n const content = props.children ?? \"\";\n return typeof content === \"string\" ? (\n inlineCode(inTable ? content.replace(/\\|/g, \"\\\\|\") : content)\n ) : (\n <>\n {\"`\"}\n {content}\n {\"`\"}\n </>\n );\n };\n}\n\nfunction inlineCode(content: string): string {\n const text = content.replace(/\\r\\n|\\r|\\n/g, \" \");\n // CommonMark has no empty code-span syntax.\n if (text.length === 0) return \"<code></code>\";\n\n let delimiterLength = 1;\n for (const match of text.matchAll(/`+/g)) {\n delimiterLength = Math.max(delimiterLength, match[0].length + 1);\n }\n const delimiter = \"`\".repeat(delimiterLength);\n const needsPadding =\n text.startsWith(\"`\") ||\n text.endsWith(\"`\") ||\n (text.startsWith(\" \") && text.endsWith(\" \") && /[^ ]/.test(text));\n const padding = needsPadding ? \" \" : \"\";\n return delimiter + padding + text + padding + delimiter;\n}\n"],"mappings":"AAEA,SAAS,eAAe,QAAQ,qBAAqB;AAUrD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,UAAU,CAAC,KAAsB,EAAE;EACjD,MAAM,OAAO,GAAG,eAAe,CAAC,CAAC;EACjC,OAAO,MAAM;IACX,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE;IACpC,OAAO,OAAO,OAAO,KAAK,QAAQ,GAChC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,IAG1D,GAAG,EACH,OAAO,EACP,GAAG,CAEP;EACH,CAAC;AACH;AAEA,SAAS,UAAU,CAAC,OAAe,EAAU;EAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;EAChD;EACA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,OAAO,eAAe;EAE7C,IAAI,eAAe,GAAG,CAAC;EACvB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;IACxC,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;EAClE;EACA,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC;EAC7C,MAAM,YAAY,GAChB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IACpB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IACjB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAE;EACnE,MAAM,OAAO,GAAG,YAAY,GAAG,GAAG,GAAG,EAAE;EACvC,OAAO,SAAS,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS;AACzD","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ import { type Children } from "@alloy-js/core";
2
+ export interface TableColumn {
3
+ /** Column heading. Direct strings are escaped; JSX is passed through. */
4
+ header: Children;
5
+ /** Alignment of the column's contents. */
6
+ align?: "left" | "center" | "right";
7
+ }
8
+ export interface TableProps {
9
+ /** Columns in output order. At least one column is required. */
10
+ columns: readonly TableColumn[];
11
+ /** TableRow components, with one TableCell per column. */
12
+ children?: Children;
13
+ }
14
+ /**
15
+ * Render a GFM table with a header and optional body rows.
16
+ *
17
+ * Direct string cells are escaped, with newlines converted to inline HTML
18
+ * breaks. JSX output is not inspected; callers own its escaping and layout.
19
+ */
20
+ export declare function Table(props: TableProps): () => Children;
21
+ export interface TableRowProps {
22
+ /** TableCell components. Use an empty joiner when composing cells with For. */
23
+ children?: Children;
24
+ }
25
+ /** Render a single row. Provide one TableCell per column. */
26
+ export declare function TableRow(props: TableRowProps): Children;
27
+ export interface TableCellProps {
28
+ /** Direct strings are escaped as literal text. JSX is passed through. */
29
+ children?: Children;
30
+ }
31
+ /**
32
+ * Escape direct string children without inspecting rendered JSX output.
33
+ * Context-aware Markdown components can escape their own pipes. Other JSX
34
+ * remains uninspected; callers own its escaping and physical line breaks.
35
+ */
36
+ export declare function TableCell(props: TableCellProps): Children;
37
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/components/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,MAAM,EAAE,QAAQ,CAAC;IACjB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,UAAU;IACzB,gEAAgE;IAChE,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,kBA6BtC;AAED,MAAM,WAAW,aAAa;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,6DAA6D;AAC7D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,YAE5C;AAED,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,YAW9C"}
@@ -0,0 +1,74 @@
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { childrenArray, code, For, List, memo } from "@alloy-js/core";
3
+ import { TableContext } from "../context/table.js";
4
+ /**
5
+ * Render a GFM table with a header and optional body rows.
6
+ *
7
+ * Direct string cells are escaped, with newlines converted to inline HTML
8
+ * breaks. JSX output is not inspected; callers own its escaping and layout.
9
+ */
10
+ export function Table(props) {
11
+ const rows = memo(() => childrenArray(() => props.children));
12
+ return () => {
13
+ if (props.columns.length === 0) {
14
+ throw new Error("Table requires at least one column.");
15
+ }
16
+ const delimiters = props.columns.map(column => column.align === "center" ? ":---:" : column.align === "right" ? "---:" : column.align === "left" ? ":---" : "---");
17
+ return _$createComponent(List, {
18
+ get children() {
19
+ return [_$createComponent(TableRow, {
20
+ get children() {
21
+ return _$createComponent(For, {
22
+ get each() {
23
+ return props.columns;
24
+ },
25
+ joiner: "",
26
+ children: column => _$createComponent(TableCell, {
27
+ get children() {
28
+ return column.header;
29
+ }
30
+ })
31
+ });
32
+ }
33
+ }), _$memo(() => code`| ${delimiters.join(" | ")} |`), _$createComponent(List, {
34
+ children: rows
35
+ })];
36
+ }
37
+ });
38
+ };
39
+ }
40
+ /** Render a single row. Provide one TableCell per column. */
41
+ export function TableRow(props) {
42
+ return code`|${props.children}`;
43
+ }
44
+ /**
45
+ * Escape direct string children without inspecting rendered JSX output.
46
+ * Context-aware Markdown components can escape their own pipes. Other JSX
47
+ * remains uninspected; callers own its escaping and physical line breaks.
48
+ */
49
+ export function TableCell(props) {
50
+ const content = memo(() => childrenArray(() => props.children).map(child => typeof child === "string" ? escapeTableText(child) : child));
51
+ return _$createComponent(TableContext.Provider, {
52
+ value: true,
53
+ children: code` ${content} |`
54
+ });
55
+ }
56
+ function escapeTableText(text) {
57
+ return text.replace(/[&<>\\`*_[\]~|]|\r\n?|\n/g, character => {
58
+ switch (character) {
59
+ case "&":
60
+ return "&amp;";
61
+ case "<":
62
+ return "&lt;";
63
+ case ">":
64
+ return "&gt;";
65
+ case "\r":
66
+ case "\n":
67
+ case "\r\n":
68
+ return "<br>";
69
+ default:
70
+ return `\\${character}`;
71
+ }
72
+ });
73
+ }
74
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../src/components/table.tsx"],"sourcesContent":["import {\n childrenArray,\n code,\n For,\n List,\n memo,\n type Children,\n} from \"@alloy-js/core\";\n\nimport { TableContext } from \"../context/table.js\";\n\nexport interface TableColumn {\n /** Column heading. Direct strings are escaped; JSX is passed through. */\n header: Children;\n /** Alignment of the column's contents. */\n align?: \"left\" | \"center\" | \"right\";\n}\n\nexport interface TableProps {\n /** Columns in output order. At least one column is required. */\n columns: readonly TableColumn[];\n /** TableRow components, with one TableCell per column. */\n children?: Children;\n}\n\n/**\n * Render a GFM table with a header and optional body rows.\n *\n * Direct string cells are escaped, with newlines converted to inline HTML\n * breaks. JSX output is not inspected; callers own its escaping and layout.\n */\nexport function Table(props: TableProps) {\n const rows = memo(() => childrenArray(() => props.children));\n return () => {\n if (props.columns.length === 0) {\n throw new Error(\"Table requires at least one column.\");\n }\n\n const delimiters = props.columns.map((column) =>\n column.align === \"center\"\n ? \":---:\"\n : column.align === \"right\"\n ? \"---:\"\n : column.align === \"left\"\n ? \":---\"\n : \"---\",\n );\n\n return (\n <List>\n <TableRow>\n <For each={props.columns} joiner=\"\">\n {(column) => <TableCell>{column.header}</TableCell>}\n </For>\n </TableRow>\n {code`| ${delimiters.join(\" | \")} |`}\n <List>{rows}</List>\n </List>\n );\n };\n}\n\nexport interface TableRowProps {\n /** TableCell components. Use an empty joiner when composing cells with For. */\n children?: Children;\n}\n\n/** Render a single row. Provide one TableCell per column. */\nexport function TableRow(props: TableRowProps) {\n return code`|${props.children}`;\n}\n\nexport interface TableCellProps {\n /** Direct strings are escaped as literal text. JSX is passed through. */\n children?: Children;\n}\n\n/**\n * Escape direct string children without inspecting rendered JSX output.\n * Context-aware Markdown components can escape their own pipes. Other JSX\n * remains uninspected; callers own its escaping and physical line breaks.\n */\nexport function TableCell(props: TableCellProps) {\n const content = memo(() =>\n childrenArray(() => props.children).map((child) =>\n typeof child === \"string\" ? escapeTableText(child) : child,\n ),\n );\n return (\n <TableContext.Provider value={true}>\n {code` ${content} |`}\n </TableContext.Provider>\n );\n}\n\nfunction escapeTableText(text: string): string {\n return text.replace(/[&<>\\\\`*_[\\]~|]|\\r\\n?|\\n/g, (character) => {\n switch (character) {\n case \"&\":\n return \"&amp;\";\n case \"<\":\n return \"&lt;\";\n case \">\":\n return \"&gt;\";\n case \"\\r\":\n case \"\\n\":\n case \"\\r\\n\":\n return \"<br>\";\n default:\n return `\\\\${character}`;\n }\n });\n}\n"],"mappings":";AAAA,SACE,aAAa,EACb,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,IAAI,QAEC,gBAAgB;AAEvB,SAAS,YAAY,QAAQ,qBAAqB;AAgBlD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,KAAK,CAAC,KAAiB,EAAE;EACvC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,aAAa,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;EAC5D,OAAO,MAAM;IACX,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;MAC9B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC;IACxD;IAEA,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAE,MAAM,IAC1C,MAAM,CAAC,KAAK,KAAK,QAAQ,GACrB,OAAO,GACP,MAAM,CAAC,KAAK,KAAK,OAAO,GACtB,MAAM,GACN,MAAM,CAAC,KAAK,KAAK,MAAM,GACrB,MAAM,GACN,KACV,CAAC;IAED,yBACG,IAAI;MAAA;QAAA,0BACF,QAAQ;UAAA;YAAA,yBACN,GAAG;cAAA,IAAC,IAAI;gBAAA,OAAE,KAAK,CAAC,OAAO;cAAA;cAAE,MAAM;cAAA,UAC5B,MAAM,sBAAM,SAAS;gBAAA;kBAAA,OAAE,MAAM,CAAC,MAAM;gBAAA;cAAA;YAAa;UAAA;QAAA,iBAGtD,IAAI,KAAK,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,qBACnC,IAAI;UAAA,UAAE;QAAI;MAAA;IAAA;EAGjB,CAAC;AACH;AAOA;AACA,OAAO,SAAS,QAAQ,CAAC,KAAoB,EAAE;EAC7C,OAAO,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE;AACjC;AAOA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,SAAS,CAAC,KAAqB,EAAE;EAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,MACnB,aAAa,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAE,KAAK,IAC5C,OAAO,KAAK,KAAK,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,KACvD,CACF,CAAC;EACD,yBACG,YAAY,CAAC,QAAQ;IAAC,KAAK,EAAE,IAAI;IAAA,UAC/B,IAAI,IAAI,OAAO;EAAI;AAG1B;AAEA,SAAS,eAAe,CAAC,IAAY,EAAU;EAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,2BAA2B,EAAG,SAAS,IAAK;IAC9D,QAAQ,SAAS;MACf,KAAK,GAAG;QACN,OAAO,OAAO;MAChB,KAAK,GAAG;QACN,OAAO,MAAM;MACf,KAAK,GAAG;QACN,OAAO,MAAM;MACf,KAAK,IAAI;MACT,KAAK,IAAI;MACT,KAAK,MAAM;QACT,OAAO,MAAM;MACf;QACE,OAAO,KAAK,SAAS,EAAE;IAC3B;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ import { type Ref } from "@alloy-js/core";
2
+ import type { HeadingSymbol } from "../symbols/heading-symbol.js";
3
+ export interface HeadingEntry {
4
+ /** Trimmed heading text, or `undefined` when the heading has JSX children. */
5
+ text: () => string | undefined;
6
+ /** Explicit anchor ID. */
7
+ id?: string;
8
+ /** Link target, present when the heading has a refkey. */
9
+ symbol?: HeadingSymbol;
10
+ /** HTML anchor emitted before the heading, if any. */
11
+ anchor: Ref<string | undefined>;
12
+ }
13
+ export interface MarkdownFileContext {
14
+ /** Headings in the file, in mount order. */
15
+ headings: Set<HeadingEntry>;
16
+ }
17
+ export declare const MarkdownFileContext: import("@alloy-js/core").ComponentContext<MarkdownFileContext>;
18
+ export declare function createMarkdownFileContext(): MarkdownFileContext;
19
+ //# sourceMappingURL=source-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-file.d.ts","sourceRoot":"","sources":["../../../src/context/source-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,GAAG,EACT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,IAAI,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAC/B,0BAA0B;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,0DAA0D;IAC1D,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,sDAAsD;IACtD,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC,4CAA4C;IAC5C,QAAQ,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;CAC7B;AAED,eAAO,MAAM,mBAAmB,gEAAuC,CAAC;AAExE,wBAAgB,yBAAyB,IAAI,mBAAmB,CAI/D"}
@@ -0,0 +1,50 @@
1
+ import { createContext, effect, shallowReactive } from "@alloy-js/core";
2
+ import GithubSlugger from "github-slugger";
3
+ export const MarkdownFileContext = createContext();
4
+ export function createMarkdownFileContext() {
5
+ const headings = shallowReactive(new Set());
6
+ effect(() => allocateHeadingIds([...headings]));
7
+ return {
8
+ headings
9
+ };
10
+ }
11
+ function allocateHeadingIds(headings) {
12
+ // Renderers generate an ID for every heading, including those with an explicit ID.
13
+ const slugger = new GithubSlugger();
14
+ let opaque = false;
15
+ const automatic = headings.map(heading => {
16
+ const text = heading.text();
17
+ if (opaque && heading.symbol && heading.id === undefined) {
18
+ throw new Error("A Heading with a refkey requires an explicit id after a heading with non-string children.");
19
+ }
20
+ if (text === undefined) opaque = true;
21
+ return text === undefined ? undefined : slugger.slug(text);
22
+ });
23
+ const ids = new Set(automatic.filter(id => id !== undefined));
24
+ const explicit = new Set();
25
+ headings.forEach((heading, i) => {
26
+ const id = heading.id;
27
+ if (id === undefined) return;
28
+ if (explicit.has(id) || ids.has(id) && automatic[i] !== id) {
29
+ throw new Error(`Duplicate Markdown heading ID: ${JSON.stringify(id)}.`);
30
+ }
31
+ explicit.add(id);
32
+ });
33
+ for (const id of explicit) ids.add(id);
34
+ headings.forEach((heading, i) => {
35
+ let anchor = heading.id;
36
+ if (anchor === undefined && automatic[i] === "" && heading.symbol) {
37
+ anchor = "section";
38
+ for (let n = 1; ids.has(anchor); n++) anchor = `section-${n}`;
39
+ ids.add(anchor);
40
+ }
41
+ heading.anchor.value = anchor;
42
+ if (!heading.symbol) return;
43
+ const name = anchor ?? automatic[i];
44
+ if (name === undefined) {
45
+ throw new Error("A Heading with a refkey and non-string children requires an explicit id.");
46
+ }
47
+ heading.symbol.name = name;
48
+ });
49
+ }
50
+ //# sourceMappingURL=source-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../src/context/source-file.ts"],"sourcesContent":["import {\n createContext,\n effect,\n shallowReactive,\n type Ref,\n} from \"@alloy-js/core\";\nimport GithubSlugger from \"github-slugger\";\n\nimport type { HeadingSymbol } from \"../symbols/heading-symbol.js\";\n\nexport interface HeadingEntry {\n /** Trimmed heading text, or `undefined` when the heading has JSX children. */\n text: () => string | undefined;\n /** Explicit anchor ID. */\n id?: string;\n /** Link target, present when the heading has a refkey. */\n symbol?: HeadingSymbol;\n /** HTML anchor emitted before the heading, if any. */\n anchor: Ref<string | undefined>;\n}\n\nexport interface MarkdownFileContext {\n /** Headings in the file, in mount order. */\n headings: Set<HeadingEntry>;\n}\n\nexport const MarkdownFileContext = createContext<MarkdownFileContext>();\n\nexport function createMarkdownFileContext(): MarkdownFileContext {\n const headings = shallowReactive(new Set<HeadingEntry>());\n effect(() => allocateHeadingIds([...headings]));\n return { headings };\n}\n\nfunction allocateHeadingIds(headings: HeadingEntry[]) {\n // Renderers generate an ID for every heading, including those with an explicit ID.\n const slugger = new GithubSlugger();\n let opaque = false;\n const automatic = headings.map((heading) => {\n const text = heading.text();\n if (opaque && heading.symbol && heading.id === undefined) {\n throw new Error(\n \"A Heading with a refkey requires an explicit id after a heading with non-string children.\",\n );\n }\n if (text === undefined) opaque = true;\n return text === undefined ? undefined : slugger.slug(text);\n });\n const ids = new Set(automatic.filter((id) => id !== undefined));\n\n const explicit = new Set<string>();\n headings.forEach((heading, i) => {\n const id = heading.id;\n if (id === undefined) return;\n if (explicit.has(id) || (ids.has(id) && automatic[i] !== id)) {\n throw new Error(`Duplicate Markdown heading ID: ${JSON.stringify(id)}.`);\n }\n explicit.add(id);\n });\n for (const id of explicit) ids.add(id);\n\n headings.forEach((heading, i) => {\n let anchor = heading.id;\n if (anchor === undefined && automatic[i] === \"\" && heading.symbol) {\n anchor = \"section\";\n for (let n = 1; ids.has(anchor); n++) anchor = `section-${n}`;\n ids.add(anchor);\n }\n heading.anchor.value = anchor;\n if (!heading.symbol) return;\n const name = anchor ?? automatic[i];\n if (name === undefined) {\n throw new Error(\n \"A Heading with a refkey and non-string children requires an explicit id.\",\n );\n }\n heading.symbol.name = name;\n });\n}\n"],"mappings":"AAAA,SACE,aAAa,EACb,MAAM,EACN,eAAe,QAEV,gBAAgB;AACvB,OAAO,aAAa,MAAM,gBAAgB;AAoB1C,OAAO,MAAM,mBAAmB,GAAG,aAAa,CAAsB,CAAC;AAEvE,OAAO,SAAS,yBAAyB,GAAwB;EAC/D,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,GAAG,CAAe,CAAC,CAAC;EACzD,MAAM,CAAC,MAAM,kBAAkB,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;EAC/C,OAAO;IAAE;EAAS,CAAC;AACrB;AAEA,SAAS,kBAAkB,CAAC,QAAwB,EAAE;EACpD;EACA,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,CAAC;EACnC,IAAI,MAAM,GAAG,KAAK;EAClB,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAE,OAAO,IAAK;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,MAAM,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,EAAE,KAAK,SAAS,EAAE;MACxD,MAAM,IAAI,KAAK,CACb,2FACF,CAAC;IACH;IACA,IAAI,IAAI,KAAK,SAAS,EAAE,MAAM,GAAG,IAAI;IACrC,OAAO,IAAI,KAAK,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;EAC5D,CAAC,CAAC;EACF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,CAAE,EAAE,IAAK,EAAE,KAAK,SAAS,CAAC,CAAC;EAE/D,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAS,CAAC;EAClC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK;IAC/B,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE;IACrB,IAAI,EAAE,KAAK,SAAS,EAAE;IACtB,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAK,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,EAAG,EAAE;MAC5D,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC;IAC1E;IACA,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;EAClB,CAAC,CAAC;EACF,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;EAEtC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK;IAC/B,IAAI,MAAM,GAAG,OAAO,CAAC,EAAE;IACvB,IAAI,MAAM,KAAK,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE;MACjE,MAAM,GAAG,SAAS;MAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,CAAC,EAAE;MAC7D,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC;IACjB;IACA,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM;IAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;IACrB,MAAM,IAAI,GAAG,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC;IACnC,IAAI,IAAI,KAAK,SAAS,EAAE;MACtB,MAAM,IAAI,KAAK,CACb,0EACF,CAAC;IACH;IACA,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI;EAC5B,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ /** Whether inline Markdown is being rendered inside a table cell. */
2
+ export declare const TableContext: import("@alloy-js/core").ComponentContext<boolean>;
3
+ export declare function useTableContext(): boolean;
4
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/context/table.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,eAAO,MAAM,YAAY,oDAAgC,CAAC;AAE1D,wBAAgB,eAAe,IAAI,OAAO,CAEzC"}
@@ -0,0 +1,8 @@
1
+ import { createContext, useContext } from "@alloy-js/core";
2
+
3
+ /** Whether inline Markdown is being rendered inside a table cell. */
4
+ export const TableContext = createContext(false);
5
+ export function useTableContext() {
6
+ return useContext(TableContext) === true;
7
+ }
8
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../src/context/table.ts"],"sourcesContent":["import { createContext, useContext } from \"@alloy-js/core\";\n\n/** Whether inline Markdown is being rendered inside a table cell. */\nexport const TableContext = createContext<boolean>(false);\n\nexport function useTableContext(): boolean {\n return useContext(TableContext) === true;\n}\n"],"mappings":"AAAA,SAAS,aAAa,EAAE,UAAU,QAAQ,gBAAgB;;AAE1D;AACA,OAAO,MAAM,YAAY,GAAG,aAAa,CAAU,KAAK,CAAC;AAEzD,OAAO,SAAS,eAAe,GAAY;EACzC,OAAO,UAAU,CAAC,YAAY,CAAC,KAAK,IAAI;AAC1C","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import { OutputSymbol, type OutputSpace, type OutputSymbolOptions } from "@alloy-js/core";
2
+ export interface HeadingSymbolOptions extends OutputSymbolOptions {
3
+ path: string;
4
+ text: () => string | undefined;
5
+ }
6
+ export declare class HeadingSymbol extends OutputSymbol {
7
+ /** Path of the file declaring the heading. */
8
+ readonly path: string;
9
+ /** Trimmed heading text, or `undefined` when the heading has JSX children. */
10
+ readonly text: () => string | undefined;
11
+ constructor(name: string, spaces: OutputSpace | OutputSpace[] | undefined, options: HeadingSymbolOptions);
12
+ copy(): HeadingSymbol;
13
+ }
14
+ //# sourceMappingURL=heading-symbol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/heading-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACzB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,qBAAa,aAAc,SAAQ,YAAY;IAC7C,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAExC,YACE,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAAG,WAAW,EAAE,GAAG,SAAS,EAC/C,OAAO,EAAE,oBAAoB,EAK9B;IAED,IAAI,kBAQH;CACF"}
@@ -0,0 +1,22 @@
1
+ import { createSymbol, OutputSymbol } from "@alloy-js/core";
2
+ export class HeadingSymbol extends OutputSymbol {
3
+ /** Path of the file declaring the heading. */
4
+ path;
5
+ /** Trimmed heading text, or `undefined` when the heading has JSX children. */
6
+ text;
7
+ constructor(name, spaces, options) {
8
+ super(name, spaces, options);
9
+ this.path = options.path;
10
+ this.text = options.text;
11
+ }
12
+ copy() {
13
+ const copy = createSymbol(HeadingSymbol, this.name, undefined, {
14
+ ...this.getCopyOptions(),
15
+ path: this.path,
16
+ text: this.text
17
+ });
18
+ this.initializeCopy(copy);
19
+ return copy;
20
+ }
21
+ }
22
+ //# sourceMappingURL=heading-symbol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../src/symbols/heading-symbol.ts"],"sourcesContent":["import {\n createSymbol,\n OutputSymbol,\n type OutputSpace,\n type OutputSymbolOptions,\n} from \"@alloy-js/core\";\n\nexport interface HeadingSymbolOptions extends OutputSymbolOptions {\n path: string;\n text: () => string | undefined;\n}\n\nexport class HeadingSymbol extends OutputSymbol {\n /** Path of the file declaring the heading. */\n readonly path: string;\n /** Trimmed heading text, or `undefined` when the heading has JSX children. */\n readonly text: () => string | undefined;\n\n constructor(\n name: string,\n spaces: OutputSpace | OutputSpace[] | undefined,\n options: HeadingSymbolOptions,\n ) {\n super(name, spaces, options);\n this.path = options.path;\n this.text = options.text;\n }\n\n copy() {\n const copy = createSymbol(HeadingSymbol, this.name, undefined, {\n ...this.getCopyOptions(),\n path: this.path,\n text: this.text,\n });\n this.initializeCopy(copy);\n return copy;\n }\n}\n"],"mappings":"AAAA,SACE,YAAY,EACZ,YAAY,QAGP,gBAAgB;AAOvB,OAAO,MAAM,aAAa,SAAS,YAAY,CAAC;EAC9C;EACS,IAAI;EACb;EACS,IAAI;EAEb,WAAW,CACT,IAAY,EACZ,MAA+C,EAC/C,OAA6B,EAC7B;IACA,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;IAC5B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI;IACxB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI;EAC1B;EAEA,IAAI,GAAG;IACL,MAAM,IAAI,GAAG,YAAY,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE;MAC7D,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;MACxB,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,IAAI,EAAE,IAAI,CAAC;IACb,CAAC,CAAC;IACF,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;IACzB,OAAO,IAAI;EACb;AACF","ignoreList":[]}