payload-markdown 1.8.0 → 1.9.0

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 (196) hide show
  1. package/README.md +16 -0
  2. package/dist/agent/access.d.ts +1 -1
  3. package/dist/agent/access.js.map +1 -1
  4. package/dist/agent/guide.d.ts +3 -0
  5. package/dist/agent/guide.js +28 -2
  6. package/dist/agent/guide.js.map +1 -1
  7. package/dist/agent/palettes.d.ts +55 -0
  8. package/dist/agent/palettes.js +194 -0
  9. package/dist/agent/palettes.js.map +1 -0
  10. package/dist/agent/skill.d.ts +2 -2
  11. package/dist/agent/skill.js +2 -2
  12. package/dist/agent/skill.js.map +1 -1
  13. package/dist/agent/validate.d.ts +1 -1
  14. package/dist/agent/validate.js +3 -0
  15. package/dist/agent/validate.js.map +1 -1
  16. package/dist/appearance/PaletteRowLabel.client.d.ts +2 -0
  17. package/dist/appearance/PaletteRowLabel.client.js +70 -0
  18. package/dist/appearance/PaletteRowLabel.client.js.map +1 -0
  19. package/dist/appearance/config.d.ts +8 -0
  20. package/dist/appearance/config.js +172 -0
  21. package/dist/appearance/config.js.map +1 -0
  22. package/dist/appearance/options.d.ts +11 -0
  23. package/dist/appearance/options.js +15 -0
  24. package/dist/appearance/options.js.map +1 -0
  25. package/dist/appearance/runtime.d.ts +25 -0
  26. package/dist/appearance/runtime.js +126 -0
  27. package/dist/appearance/runtime.js.map +1 -0
  28. package/dist/components/MarkdownRenderer/Component.js +4 -0
  29. package/dist/components/MarkdownRenderer/Component.js.map +1 -1
  30. package/dist/core/plugins/rehypeResolveIcons.js +10 -1
  31. package/dist/core/plugins/rehypeResolveIcons.js.map +1 -1
  32. package/dist/core/plugins/remarkCompileLayouts.js.map +1 -1
  33. package/dist/core/plugins/remarkDirectiveLines.d.ts +7 -5
  34. package/dist/core/plugins/remarkDirectiveLines.js +29 -18
  35. package/dist/core/plugins/remarkDirectiveLines.js.map +1 -1
  36. package/dist/core/plugins/remarkLayoutDirectives.js +1 -1
  37. package/dist/core/plugins/remarkLayoutDirectives.js.map +1 -1
  38. package/dist/core/plugins/remarkValidateDirectiveThemes.js +7 -14
  39. package/dist/core/plugins/remarkValidateDirectiveThemes.js.map +1 -1
  40. package/dist/core/plugins/remarkValidatePalettes.d.ts +9 -0
  41. package/dist/core/plugins/remarkValidatePalettes.js +51 -0
  42. package/dist/core/plugins/remarkValidatePalettes.js.map +1 -0
  43. package/dist/core/renderMarkdown.js +4 -221
  44. package/dist/core/renderMarkdown.js.map +1 -1
  45. package/dist/core/sanitizeSchema.d.ts +11 -0
  46. package/dist/core/sanitizeSchema.js +176 -0
  47. package/dist/core/sanitizeSchema.js.map +1 -0
  48. package/dist/directive-spec.json +60 -0
  49. package/dist/directives/definitions/badge.d.ts +5 -2
  50. package/dist/directives/definitions/badge.js +138 -10
  51. package/dist/directives/definitions/badge.js.map +1 -1
  52. package/dist/directives/definitions/badges.d.ts +1 -2
  53. package/dist/directives/definitions/badges.js +12 -3
  54. package/dist/directives/definitions/badges.js.map +1 -1
  55. package/dist/directives/definitions/button.d.ts +7 -3
  56. package/dist/directives/definitions/button.js +211 -14
  57. package/dist/directives/definitions/button.js.map +1 -1
  58. package/dist/directives/definitions/buttons.d.ts +1 -2
  59. package/dist/directives/definitions/buttons.js +12 -3
  60. package/dist/directives/definitions/buttons.js.map +1 -1
  61. package/dist/directives/definitions/callout.d.ts +1 -2
  62. package/dist/directives/definitions/callout.js +46 -5
  63. package/dist/directives/definitions/callout.js.map +1 -1
  64. package/dist/directives/definitions/card.d.ts +6 -4
  65. package/dist/directives/definitions/card.js +64 -11
  66. package/dist/directives/definitions/card.js.map +1 -1
  67. package/dist/directives/definitions/cards.d.ts +1 -2
  68. package/dist/directives/definitions/cards.js +49 -4
  69. package/dist/directives/definitions/cards.js.map +1 -1
  70. package/dist/directives/definitions/cell.d.ts +2 -2
  71. package/dist/directives/definitions/cell.js +9 -3
  72. package/dist/directives/definitions/cell.js.map +1 -1
  73. package/dist/directives/definitions/columns.d.ts +3 -4
  74. package/dist/directives/definitions/columns.js +17 -3
  75. package/dist/directives/definitions/columns.js.map +1 -1
  76. package/dist/directives/definitions/details.d.ts +1 -2
  77. package/dist/directives/definitions/details.js +28 -3
  78. package/dist/directives/definitions/details.js.map +1 -1
  79. package/dist/directives/definitions/section.d.ts +1 -2
  80. package/dist/directives/definitions/section.js +26 -3
  81. package/dist/directives/definitions/section.js.map +1 -1
  82. package/dist/directives/definitions/steps.d.ts +1 -2
  83. package/dist/directives/definitions/steps.js +26 -3
  84. package/dist/directives/definitions/steps.js.map +1 -1
  85. package/dist/directives/definitions/tab.d.ts +8 -2
  86. package/dist/directives/definitions/tab.js +45 -3
  87. package/dist/directives/definitions/tab.js.map +1 -1
  88. package/dist/directives/definitions/tabs.d.ts +1 -1
  89. package/dist/directives/definitions/tabs.js +44 -3
  90. package/dist/directives/definitions/tabs.js.map +1 -1
  91. package/dist/directives/definitions/toc.d.ts +1 -2
  92. package/dist/directives/definitions/toc.js +33 -5
  93. package/dist/directives/definitions/toc.js.map +1 -1
  94. package/dist/directives/diagnostics.d.ts +2 -10
  95. package/dist/directives/diagnostics.js +27 -141
  96. package/dist/directives/diagnostics.js.map +1 -1
  97. package/dist/directives/iconPlaceholder.d.ts +9 -3
  98. package/dist/directives/iconPlaceholder.js +8 -1
  99. package/dist/directives/iconPlaceholder.js.map +1 -1
  100. package/dist/directives/lint.d.ts +11 -0
  101. package/dist/directives/lint.js +33 -0
  102. package/dist/directives/lint.js.map +1 -0
  103. package/dist/directives/palette.d.ts +23 -0
  104. package/dist/directives/palette.js +40 -0
  105. package/dist/directives/palette.js.map +1 -0
  106. package/dist/directives/registry.d.ts +23 -5
  107. package/dist/directives/registry.js +52 -40
  108. package/dist/directives/registry.js.map +1 -1
  109. package/dist/directives/spec.d.ts +6 -2
  110. package/dist/directives/spec.js +29 -50
  111. package/dist/directives/spec.js.map +1 -1
  112. package/dist/directives/themeDiagnostics.d.ts +8 -0
  113. package/dist/directives/themeDiagnostics.js +21 -0
  114. package/dist/directives/themeDiagnostics.js.map +1 -0
  115. package/dist/directives/types.d.ts +157 -14
  116. package/dist/directives/types.js +6 -1
  117. package/dist/directives/types.js.map +1 -1
  118. package/dist/editor/directiveConfig.d.ts +15 -1
  119. package/dist/editor/directiveConfig.js +21 -1
  120. package/dist/editor/directiveConfig.js.map +1 -1
  121. package/dist/editor/directives/completions.d.ts +4 -2
  122. package/dist/editor/directives/completions.js +33 -7
  123. package/dist/editor/directives/completions.js.map +1 -1
  124. package/dist/editor/directives/diagnostics.d.ts +2 -2
  125. package/dist/editor/directives/diagnostics.js +10 -3
  126. package/dist/editor/directives/diagnostics.js.map +1 -1
  127. package/dist/editor/themes/payload.js +2 -1
  128. package/dist/editor/themes/payload.js.map +1 -1
  129. package/dist/exports/client.d.ts +4 -1
  130. package/dist/exports/client.js +5 -2
  131. package/dist/exports/client.js.map +1 -1
  132. package/dist/field/MarkdownField/Component.js +54 -3
  133. package/dist/field/MarkdownField/Component.js.map +1 -1
  134. package/dist/icons/entries.d.ts +22 -0
  135. package/dist/icons/entries.js +50 -0
  136. package/dist/icons/entries.js.map +1 -0
  137. package/dist/icons/resolve.d.ts +2 -1
  138. package/dist/icons/resolve.js +2 -2
  139. package/dist/icons/resolve.js.map +1 -1
  140. package/dist/icons/sanitizeSvg.d.ts +12 -2
  141. package/dist/icons/sanitizeSvg.js +104 -3
  142. package/dist/icons/sanitizeSvg.js.map +1 -1
  143. package/dist/index.d.ts +11 -4
  144. package/dist/index.js +34 -3
  145. package/dist/index.js.map +1 -1
  146. package/dist/mcp/index.d.ts +2 -2
  147. package/dist/mcp/index.js +65 -4
  148. package/dist/mcp/index.js.map +1 -1
  149. package/dist/palettes/colors.d.ts +21 -0
  150. package/dist/palettes/colors.js +43 -0
  151. package/dist/palettes/colors.js.map +1 -0
  152. package/dist/palettes/contrast.d.ts +7 -0
  153. package/dist/palettes/contrast.js +63 -0
  154. package/dist/palettes/contrast.js.map +1 -0
  155. package/dist/palettes/defaults.d.ts +8 -0
  156. package/dist/palettes/defaults.js +275 -0
  157. package/dist/palettes/defaults.js.map +1 -0
  158. package/dist/palettes/diagnostics.d.ts +10 -0
  159. package/dist/palettes/diagnostics.js +38 -0
  160. package/dist/palettes/diagnostics.js.map +1 -0
  161. package/dist/palettes/index.d.ts +61 -0
  162. package/dist/palettes/index.js +246 -0
  163. package/dist/palettes/index.js.map +1 -0
  164. package/dist/render/renderMarkdown.d.ts +3 -1
  165. package/dist/render/renderMarkdown.js +9 -1
  166. package/dist/render/renderMarkdown.js.map +1 -1
  167. package/dist/runtime/index.d.ts +12 -1
  168. package/dist/runtime/index.js +21 -2
  169. package/dist/runtime/index.js.map +1 -1
  170. package/dist/types/core.d.ts +43 -0
  171. package/dist/types/core.js.map +1 -1
  172. package/dist/types.d.ts +46 -2
  173. package/dist/types.js.map +1 -1
  174. package/dist/version.d.ts +1 -1
  175. package/dist/version.js +1 -1
  176. package/dist/version.js.map +1 -1
  177. package/package.json +1 -1
  178. package/skills/payload-markdown/claude/SKILL.md +1 -0
  179. package/skills/payload-markdown/claude/reference/directive-spec.json +60 -0
  180. package/skills/payload-markdown/claude/reference/mcp-content-workflow.md +7 -0
  181. package/skills/payload-markdown/claude/reference/payload-markdown-directives.md +22 -2
  182. package/skills/payload-markdown/claude/skill.json +2 -2
  183. package/skills/payload-markdown/codex/SKILL.md +1 -0
  184. package/skills/payload-markdown/codex/reference/directive-spec.json +60 -0
  185. package/skills/payload-markdown/codex/reference/mcp-content-workflow.md +7 -0
  186. package/skills/payload-markdown/codex/reference/payload-markdown-directives.md +22 -2
  187. package/skills/payload-markdown/codex/skill.json +2 -2
  188. package/dist/core/plugins/directiveBadge.d.ts +0 -6
  189. package/dist/core/plugins/directiveBadge.js +0 -94
  190. package/dist/core/plugins/directiveBadge.js.map +0 -1
  191. package/dist/core/plugins/directiveButton.d.ts +0 -6
  192. package/dist/core/plugins/directiveButton.js +0 -115
  193. package/dist/core/plugins/directiveButton.js.map +0 -1
  194. package/dist/directives/buttonSyntax.d.ts +0 -7
  195. package/dist/directives/buttonSyntax.js +0 -6
  196. package/dist/directives/buttonSyntax.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/directives/diagnostics.ts"],"sourcesContent":["import type { Root } from 'mdast'\n\nimport type { MarkdownDirectiveThemes } from '../types/core.js'\nimport type { TabsDefaultCandidate } from './definitions/tab.js'\nimport type { ScannedDirectiveLine, SourceIndex } from './lineScanner.js'\n\nimport { normalizePayloadMarkdownIconRef } from '../icons/refs.js'\nimport { parseButtonDirectiveLine } from './buttonSyntax.js'\nimport { getTabRawValue, resolveTabsDefault, slugTabValue } from './definitions/tab.js'\nimport { getLeafDirectiveName, getLeafDirectiveProblem, parseLeafDirectiveLine } from './leafSyntax.js'\nimport {\n createSourceIndex,\n findNestedDirectiveMarkers,\n getNestedDirectiveMarkerDiagnostic,\n scanDirectiveLineAt,\n splitParagraphIntoLines,\n} from './lineScanner.js'\nimport { layoutDirectiveRegistry } from './registry.js'\nimport { resolveShieldsBadge } from './shields.js'\nimport { parseDirectiveSourceTree } from './sourceTree.js'\nimport { getDirectiveFallbackThemeName, hasDirectiveTheme } from './themes.js'\nimport { isSafeHref } from './urls.js'\n\nexport type DirectiveDiagnostic = {\n from: number\n line: number\n message: string\n severity: 'warning'\n to: number\n}\n\ntype OpenFrame = {\n cardsHasHref?: boolean\n cardsLinkScope?: string\n defaultValue?: string\n from: number\n hasContent?: boolean\n line: number\n name: string\n parentHeadingDepth?: number\n tabCandidates?: TabsDefaultCandidate[]\n tabCount?: number\n tabValues?: Map<string, number>\n}\n\ntype LintState = {\n currentHeadingDepth?: number\n options: LintMarkdownDirectivesOptions\n stack: OpenFrame[]\n}\n\nexport type LintMarkdownDirectivesOptions = {\n /**\n * Configured icon pack aliases. When provided, icon refs to other packs are\n * reported exactly like the renderer does (\"Unknown icon pack\").\n */\n iconPacks?: readonly string[]\n /** Configured directive themes (names are what matters). */\n themes?: MarkdownDirectiveThemes\n}\n\nfunction getIconPackDiagnostics(icon: unknown, options: LintMarkdownDirectivesOptions): string[] {\n if (typeof icon !== 'string' || !options.iconPacks) return []\n\n const normalized = normalizePayloadMarkdownIconRef(icon)\n if (!normalized.icon || options.iconPacks.includes(normalized.icon.packAlias)) return []\n\n return [`Unknown icon pack \"${normalized.icon.packAlias}\".`]\n}\n\nfunction findNearestFrameIndex(stack: OpenFrame[], predicate: (frame: OpenFrame) => boolean) {\n for (let index = stack.length - 1; index >= 0; --index) {\n const frame = stack[index]\n if (predicate(frame)) return index\n }\n\n return -1\n}\n\nfunction getTabValue(\n attributes: Record<string, boolean | string> | undefined,\n index: number,\n label?: string,\n): string {\n return slugTabValue(getTabRawValue(attributes, label) ?? `tab-${index + 1}`, index)\n}\n\nconst TOC_CONTENT_DIAGNOSTIC =\n 'Directive \"toc\" contains authored content; it is rendered after the generated table of contents. Close \":::toc\" with \":::\" on the next line.'\n\nfunction finalizeFrame(frame: OpenFrame): string[] {\n if (frame.name === 'toc') return frame.hasContent ? [TOC_CONTENT_DIAGNOSTIC] : []\n\n return finalizeTabsFrame(frame)\n}\n\nfunction finalizeTabsFrame(frame: OpenFrame): string[] {\n if (frame.name !== 'tabs') return []\n\n const diagnostics: string[] = []\n const tabValues = frame.tabValues ?? new Map<string, number>()\n\n if (!frame.tabCount) diagnostics.push('Directive \"tabs\" has no child \"tab\" directives.')\n\n for (const [value, count] of tabValues)\n if (count > 1) diagnostics.push(`Duplicate tab value \"${value}\" in \"tabs\".`)\n\n if (frame.defaultValue && !resolveTabsDefault(frame.defaultValue, frame.tabCandidates ?? []))\n diagnostics.push(`Invalid tabs default \"${frame.defaultValue}\". Falling back to the first tab.`)\n\n return diagnostics\n}\n\nfunction findNearestTabsFrame(stack: OpenFrame[]): OpenFrame | undefined {\n for (let index = stack.length - 1; index >= 0; --index) {\n const frame = stack[index]\n if (frame.name === 'tabs') return frame\n }\n\n return undefined\n}\n\nfunction findNearestCardsFrame(stack: OpenFrame[]): OpenFrame | undefined {\n for (let index = stack.length - 1; index >= 0; --index) {\n const frame = stack[index]\n if (frame.name === 'cards') return frame\n }\n\n return undefined\n}\n\nfunction hasAttribute(\n attributes: Record<string, boolean | string> | undefined,\n name: string,\n): boolean {\n return Object.prototype.hasOwnProperty.call(attributes ?? {}, name)\n}\n\nfunction popFrames(stack: OpenFrame[], index: number): string[] {\n return stack.splice(index).flatMap((frame) => finalizeFrame(frame))\n}\n\nfunction markTopFrameContent(state: LintState) {\n const top = state.stack[state.stack.length - 1]\n if (top) top.hasContent = true\n}\n\n/** Mirrors remarkCompileLayouts: a heading shallower than a grid's parent heading closes the grid. */\nfunction applyHeading(state: LintState, depth: number): string[] {\n markTopFrameContent(state)\n\n const top = state.stack[state.stack.length - 1]\n const diagnostics =\n top &&\n layoutDirectiveRegistry.isGridName(top.name) &&\n typeof top.parentHeadingDepth === 'number' &&\n depth < top.parentHeadingDepth\n ? popFrames(state.stack, state.stack.length - 1)\n : []\n\n state.currentHeadingDepth = depth\n\n return diagnostics\n}\n\nfunction updateOpenStack(\n state: LintState,\n text: string,\n line: number,\n from: number,\n): string[] {\n const { stack } = state\n const token = layoutDirectiveRegistry.parseMarkdownLineDetailed(text).token\n const diagnostics: string[] = []\n\n if (!token) return diagnostics\n\n if (token.action === 'open') {\n markTopFrameContent(state)\n\n if (token.name === 'card') {\n const cardsFrame = findNearestCardsFrame(stack)\n const cardsSectionLink =\n cardsFrame?.cardsHasHref &&\n (cardsFrame.cardsLinkScope === undefined || cardsFrame.cardsLinkScope === 'section')\n\n if (\n cardsSectionLink &&\n (hasAttribute(token.attributes, 'href') ||\n hasAttribute(token.attributes, 'linkScope') ||\n hasAttribute(token.attributes, 'newTab'))\n )\n diagnostics.push(\n 'Directive \"cards\" with linkScope=\"section\" ignores child \"card\" link overrides.',\n )\n }\n\n if (token.name === 'tab') {\n const tabsFrame = findNearestTabsFrame(stack)\n\n if (!tabsFrame) diagnostics.push('Directive \"tab\" is usually intended inside \"tabs\".')\n else {\n const nextIndex = tabsFrame.tabCount ?? 0\n const value = getTabValue(token.attributes, nextIndex, token.label)\n\n tabsFrame.tabCandidates ??= []\n tabsFrame.tabCandidates.push({\n label: getTabRawValue({ label: token.attributes?.label ?? '' }, token.label) ?? `Tab ${nextIndex + 1}`,\n raw: getTabRawValue(token.attributes),\n value,\n })\n tabsFrame.tabCount = nextIndex + 1\n tabsFrame.tabValues ??= new Map<string, number>()\n tabsFrame.tabValues.set(value, (tabsFrame.tabValues.get(value) ?? 0) + 1)\n }\n }\n\n const isGrid = layoutDirectiveRegistry.isGridName(token.name)\n\n if (isGrid) {\n // remarkCompileLayouts closes an open grid inside the nearest section.\n const gridIndex = findNearestFrameIndex(stack, (frame) =>\n layoutDirectiveRegistry.isGridName(frame.name),\n )\n const sectionIndex = findNearestFrameIndex(stack, (frame) => frame.name === 'section')\n\n if (gridIndex >= 0 && sectionIndex >= 0 && gridIndex > sectionIndex)\n diagnostics.push(...popFrames(stack, gridIndex))\n }\n\n stack.push({\n name: token.name,\n from,\n line,\n ...(isGrid ? { parentHeadingDepth: state.currentHeadingDepth ?? 1 } : {}),\n ...(token.name === 'cards'\n ? {\n cardsHasHref:\n typeof token.attributes?.href === 'string' && isSafeHref(token.attributes.href.trim()),\n cardsLinkScope:\n typeof token.attributes?.linkScope === 'string'\n ? token.attributes.linkScope\n : undefined,\n }\n : {}),\n ...(token.name === 'tabs'\n ? {\n defaultValue:\n typeof token.attributes?.default === 'string'\n ? token.attributes.default\n : undefined,\n tabCount: 0,\n tabValues: new Map<string, number>(),\n }\n : {}),\n })\n return diagnostics\n }\n\n if (token.action === 'close') {\n if (stack.length === 0) return ['Encountered ::: with no open layout block.']\n\n return popFrames(stack, stack.length - 1)\n }\n\n if (token.action === 'closeGrid') {\n const index = findNearestFrameIndex(stack, (frame) =>\n layoutDirectiveRegistry.isGridName(frame.name),\n )\n\n if (index < 0) return ['Encountered :::endcol with no open grid.']\n\n return popFrames(stack, index)\n }\n\n const index = findNearestFrameIndex(stack, (frame) => frame.name === 'section')\n if (index < 0) return ['Encountered :::end or :::endsection with no open section.']\n\n return popFrames(stack, index)\n}\n\nfunction getThemeDiagnostics(text: string, options: LintMarkdownDirectivesOptions): string[] {\n const token = layoutDirectiveRegistry.parseMarkdownLineDetailed(text).token\n if (!token || token.action !== 'open') return []\n\n const definition = layoutDirectiveRegistry.get(token.name)\n const diagnostics: string[] = [...getIconPackDiagnostics(token.attributes?.icon, options)]\n\n if (!definition?.themeAttributes) return diagnostics\n\n for (const [attribute, groupName] of Object.entries(definition.themeAttributes)) {\n if (!groupName) continue\n\n const value = token.attributes?.[attribute]\n if (typeof value !== 'string' || !value.trim()) continue\n if (hasDirectiveTheme(groupName, value, options.themes)) continue\n\n const label = attribute === 'theme' ? 'theme' : attribute\n diagnostics.push(\n `Unknown ${label} \"${value}\" on \"${token.name}\". Falling back to \"${getDirectiveFallbackThemeName(groupName, options.themes)}\".`,\n )\n }\n\n return diagnostics\n}\n\nfunction getButtonDiagnostics(text: string, options: LintMarkdownDirectivesOptions): string[] {\n const parsed = parseButtonDirectiveLine(text)\n if (!parsed) return []\n\n const definition = layoutDirectiveRegistry.get('button')\n const diagnostics = [\n ...parsed.warnings,\n ...(definition?.validateAttributes?.({ name: 'button', attributes: parsed.attributes }) ?? []),\n ]\n const icon = parsed.attributes.icon\n\n if (typeof icon === 'string') {\n const normalized = normalizePayloadMarkdownIconRef(icon)\n if (normalized.warning) diagnostics.push(normalized.warning)\n }\n\n if (!parsed.label.trim() && typeof parsed.attributes.ariaLabel !== 'string')\n diagnostics.push('Icon-only button requires an ariaLabel attribute.')\n\n return [...diagnostics, ...getIconPackDiagnostics(icon, options)]\n}\n\nfunction getBadgeDiagnostics(text: string): string[] {\n const parsed = parseLeafDirectiveLine(text, 'badge')\n if (!parsed) return []\n\n const definition = layoutDirectiveRegistry.get('badge')\n const resolved = resolveShieldsBadge(parsed.attributes)\n\n return [\n ...parsed.warnings,\n ...(definition?.validateAttributes?.({ name: 'badge', attributes: parsed.attributes }) ?? []),\n ...resolved.warnings,\n ]\n}\n\ntype DiagnosticSink = (message: string, from: number, to: number, line: number) => void\n\nfunction lintContainerLine(state: LintState, scanned: ScannedDirectiveLine, push: DiagnosticSink) {\n const report = (message: string) => push(message, scanned.from, scanned.to, scanned.startLine)\n const result = layoutDirectiveRegistry.parseMarkdownLineDetailed(scanned.text)\n\n for (const message of result.diagnostics) report(message)\n for (const message of getThemeDiagnostics(scanned.text, state.options)) report(message)\n for (const message of updateOpenStack(state, scanned.text, scanned.startLine, scanned.from))\n report(message)\n\n // Tokens that do not open/close anything render as prose inside the frame.\n if (!result.token) markTopFrameContent(state)\n}\n\nfunction lintLeafLine(state: LintState, scanned: ScannedDirectiveLine, push: DiagnosticSink) {\n const report = (message: string) => push(message, scanned.from, scanned.to, scanned.startLine)\n const leafName = getLeafDirectiveName(scanned.text)\n\n markTopFrameContent(state)\n\n if (!leafName) return\n\n if (!layoutDirectiveRegistry.isLeafDirectiveName(leafName)) {\n report(`Unknown directive \"${leafName}\".`)\n return\n }\n\n const problem = getLeafDirectiveProblem(scanned.text, leafName)\n\n if (problem) {\n report(problem)\n return\n }\n\n const messages =\n leafName === 'button'\n ? getButtonDiagnostics(scanned.text, state.options)\n : getBadgeDiagnostics(scanned.text)\n\n for (const message of messages) report(message)\n}\n\nfunction lintParagraph(\n state: LintState,\n paragraph: Root['children'][number],\n index: SourceIndex,\n push: DiagnosticSink,\n) {\n if (paragraph.type !== 'paragraph') return\n\n const lines = splitParagraphIntoLines(paragraph)\n\n for (let lineIndex = 0; lineIndex < lines.length; ++lineIndex) {\n const scanned = scanDirectiveLineAt(lines, lineIndex, index)\n\n if (!scanned) {\n markTopFrameContent(state)\n continue\n }\n\n if (scanned.kind === 'container') lintContainerLine(state, scanned, push)\n else lintLeafLine(state, scanned, push)\n\n lineIndex = scanned.phrasingEnd\n }\n}\n\n/**\n * Editor-side directive diagnostics. The document is parsed with the same\n * remark/GFM front end and the same directive line scanner as the renderer,\n * so code blocks, lists, blockquotes and prose are classified identically.\n * Every renderer warning about directive syntax has an editor counterpart;\n * the renderer's \"Auto-closing unclosed layout block: X\" is reported here as\n * \"Unclosed directive \"X\".\" at the opening marker.\n */\nexport function lintMarkdownDirectives(\n markdown: string,\n options: LintMarkdownDirectivesOptions = {},\n): DirectiveDiagnostic[] {\n const diagnostics: DirectiveDiagnostic[] = []\n const state: LintState = { options, stack: [] }\n const index = createSourceIndex(markdown)\n const tree = parseDirectiveSourceTree(markdown)\n\n const push: DiagnosticSink = (message, from, to, line) =>\n diagnostics.push({ from, line, message, severity: 'warning', to })\n\n const nested = findNestedDirectiveMarkers(tree, index)\n let nestedIndex = 0\n\n const flushNestedBefore = (line: number) => {\n while (nestedIndex < nested.length && nested[nestedIndex].line < line) {\n const marker = nested[nestedIndex++]\n push(getNestedDirectiveMarkerDiagnostic(marker), marker.from, marker.to, marker.line)\n }\n }\n\n for (const node of tree.children) {\n flushNestedBefore(\n ('position' in node ? node.position?.start.line : undefined) ?? Number.POSITIVE_INFINITY,\n )\n\n if (node.type === 'paragraph') {\n lintParagraph(state, node, index, push)\n continue\n }\n\n if (node.type === 'heading') {\n const line = node.position?.start.line ?? 1\n const from = index.lineStarts[line] ?? 0\n\n for (const message of applyHeading(state, node.depth)) push(message, from, from, line)\n continue\n }\n\n markTopFrameContent(state)\n }\n\n flushNestedBefore(Number.POSITIVE_INFINITY)\n\n for (const frame of state.stack) {\n for (const message of finalizeFrame(frame))\n push(message, frame.from, frame.from + frame.name.length + 3, frame.line)\n\n push(`Unclosed directive \"${frame.name}\".`, frame.from, frame.from + frame.name.length + 3, frame.line)\n }\n\n return diagnostics\n}\n"],"names":["normalizePayloadMarkdownIconRef","parseButtonDirectiveLine","getTabRawValue","resolveTabsDefault","slugTabValue","getLeafDirectiveName","getLeafDirectiveProblem","parseLeafDirectiveLine","createSourceIndex","findNestedDirectiveMarkers","getNestedDirectiveMarkerDiagnostic","scanDirectiveLineAt","splitParagraphIntoLines","layoutDirectiveRegistry","resolveShieldsBadge","parseDirectiveSourceTree","getDirectiveFallbackThemeName","hasDirectiveTheme","isSafeHref","getIconPackDiagnostics","icon","options","iconPacks","normalized","includes","packAlias","findNearestFrameIndex","stack","predicate","index","length","frame","getTabValue","attributes","label","TOC_CONTENT_DIAGNOSTIC","finalizeFrame","name","hasContent","finalizeTabsFrame","diagnostics","tabValues","Map","tabCount","push","value","count","defaultValue","tabCandidates","findNearestTabsFrame","undefined","findNearestCardsFrame","hasAttribute","Object","prototype","hasOwnProperty","call","popFrames","splice","flatMap","markTopFrameContent","state","top","applyHeading","depth","isGridName","parentHeadingDepth","currentHeadingDepth","updateOpenStack","text","line","from","token","parseMarkdownLineDetailed","action","cardsFrame","cardsSectionLink","cardsHasHref","cardsLinkScope","tabsFrame","nextIndex","raw","set","get","isGrid","gridIndex","sectionIndex","href","trim","linkScope","default","getThemeDiagnostics","definition","themeAttributes","attribute","groupName","entries","themes","getButtonDiagnostics","parsed","warnings","validateAttributes","warning","ariaLabel","getBadgeDiagnostics","resolved","lintContainerLine","scanned","report","message","to","startLine","result","lintLeafLine","leafName","isLeafDirectiveName","problem","messages","lintParagraph","paragraph","type","lines","lineIndex","kind","phrasingEnd","lintMarkdownDirectives","markdown","tree","severity","nested","nestedIndex","flushNestedBefore","marker","node","children","position","start","Number","POSITIVE_INFINITY","lineStarts"],"mappings":"AAMA,SAASA,+BAA+B,QAAQ,mBAAkB;AAClE,SAASC,wBAAwB,QAAQ,oBAAmB;AAC5D,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,YAAY,QAAQ,uBAAsB;AACvF,SAASC,oBAAoB,EAAEC,uBAAuB,EAAEC,sBAAsB,QAAQ,kBAAiB;AACvG,SACEC,iBAAiB,EACjBC,0BAA0B,EAC1BC,kCAAkC,EAClCC,mBAAmB,EACnBC,uBAAuB,QAClB,mBAAkB;AACzB,SAASC,uBAAuB,QAAQ,gBAAe;AACvD,SAASC,mBAAmB,QAAQ,eAAc;AAClD,SAASC,wBAAwB,QAA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,SAASH,MAAM,CAACC,cAAc;YACpCtF,KAAKlC,mCAAmC0H,SAASA,OAAO7D,IAAI,EAAE6D,OAAOtB,EAAE,EAAEsB,OAAO9D,IAAI;QACtF;IACF;IAEA,KAAK,MAAM+D,QAAQN,KAAKO,QAAQ,CAAE;QAChCH,kBACE,AAAC,CAAA,cAAcE,OAAOA,KAAKE,QAAQ,EAAEC,MAAMlE,OAAOpB,SAAQ,KAAMuF,OAAOC,iBAAiB;QAG1F,IAAIL,KAAKb,IAAI,KAAK,aAAa;YAC7BF,cAAczD,OAAOwE,MAAMxG,OAAOe;YAClC;QACF;QAEA,IAAIyF,KAAKb,IAAI,KAAK,WAAW;YAC3B,MAAMlD,OAAO+D,KAAKE,QAAQ,EAAEC,MAAMlE,QAAQ;YAC1C,MAAMC,OAAO1C,MAAM8G,UAAU,CAACrE,KAAK,IAAI;YAEvC,KAAK,MAAMuC,WAAW9C,aAAaF,OAAOwE,KAAKrE,KAAK,EAAGpB,KAAKiE,SAAStC,MAAMA,MAAMD;YACjF;QACF;QAEAV,oBAAoBC;IACtB;IAEAsE,kBAAkBM,OAAOC,iBAAiB;IAE1C,KAAK,MAAM3G,SAAS8B,MAAMlC,KAAK,CAAE;QAC/B,KAAK,MAAMkF,WAAWzE,cAAcL,OAClCa,KAAKiE,SAAS9E,MAAMwC,IAAI,EAAExC,MAAMwC,IAAI,GAAGxC,MAAMM,IAAI,CAACP,MAAM,GAAG,GAAGC,MAAMuC,IAAI;QAE1E1B,KAAK,CAAC,oBAAoB,EAAEb,MAAMM,IAAI,CAAC,EAAE,CAAC,EAAEN,MAAMwC,IAAI,EAAExC,MAAMwC,IAAI,GAAGxC,MAAMM,IAAI,CAACP,MAAM,GAAG,GAAGC,MAAMuC,IAAI;IACxG;IAEA,OAAO9B;AACT"}
1
+ {"version":3,"sources":["../../src/directives/diagnostics.ts"],"sourcesContent":["import type { Root } from 'mdast'\n\nimport type { ScannedDirectiveLine, SourceIndex } from './lineScanner.js'\nimport type { DirectiveLintFrame, LintMarkdownDirectivesOptions } from './types.js'\n\nimport { getLeafDirectiveName, getLeafDirectiveProblem } from './leafSyntax.js'\nimport {\n createSourceIndex,\n findNestedDirectiveMarkers,\n getNestedDirectiveMarkerDiagnostic,\n scanDirectiveLineAt,\n splitParagraphIntoLines,\n} from './lineScanner.js'\nimport { getIconLintDiagnostics, getPaletteLintDiagnostics } from './lint.js'\nimport { layoutDirectiveRegistry } from './registry.js'\nimport { parseDirectiveSourceTree } from './sourceTree.js'\nimport { getUnknownThemeDiagnostics } from './themeDiagnostics.js'\n\nexport type { LintMarkdownDirectivesOptions } from './types.js'\n\nexport type DirectiveDiagnostic = {\n from: number\n line: number\n message: string\n severity: 'warning'\n to: number\n}\n\ntype LintState = {\n currentHeadingDepth?: number\n options: LintMarkdownDirectivesOptions\n stack: DirectiveLintFrame[]\n}\n\nfunction findNearestFrameIndex(stack: DirectiveLintFrame[], predicate: (frame: DirectiveLintFrame) => boolean) {\n for (let index = stack.length - 1; index >= 0; --index) {\n const frame = stack[index]\n if (predicate(frame)) return index\n }\n\n return -1\n}\n\n/** A directive's own checks when its frame closes (definition `lint.close`). */\nfunction finalizeFrame(frame: DirectiveLintFrame): string[] {\n return layoutDirectiveRegistry.get(frame.name)?.lint?.close?.(frame) ?? []\n}\n\nfunction popFrames(stack: DirectiveLintFrame[], index: number): string[] {\n return stack.splice(index).flatMap((frame) => finalizeFrame(frame))\n}\n\nfunction markTopFrameContent(state: LintState) {\n const top = state.stack[state.stack.length - 1]\n if (top) top.hasContent = true\n}\n\n/** Mirrors remarkCompileLayouts: a heading shallower than a grid's parent heading closes the grid. */\nfunction applyHeading(state: LintState, depth: number): string[] {\n markTopFrameContent(state)\n\n const top = state.stack[state.stack.length - 1]\n const diagnostics =\n top &&\n layoutDirectiveRegistry.isGridName(top.name) &&\n typeof top.parentHeadingDepth === 'number' &&\n depth < top.parentHeadingDepth\n ? popFrames(state.stack, state.stack.length - 1)\n : []\n\n state.currentHeadingDepth = depth\n\n return diagnostics\n}\n\nfunction updateOpenStack(\n state: LintState,\n text: string,\n line: number,\n from: number,\n): string[] {\n const { stack } = state\n const token = layoutDirectiveRegistry.parseMarkdownLineDetailed(text).token\n const diagnostics: string[] = []\n\n if (!token) return diagnostics\n\n if (token.action === 'open') {\n markTopFrameContent(state)\n\n const isGrid = layoutDirectiveRegistry.isGridName(token.name)\n const frame: DirectiveLintFrame = {\n name: token.name,\n from,\n line,\n ...(isGrid ? { parentHeadingDepth: state.currentHeadingDepth ?? 1 } : {}),\n }\n\n // The directive's own nesting checks see the stack before it opens.\n diagnostics.push(\n ...(layoutDirectiveRegistry.get(token.name)?.lint?.open?.({\n attributes: token.attributes ?? {},\n frame,\n label: token.label,\n stack,\n }) ?? []),\n )\n\n if (isGrid) {\n // remarkCompileLayouts closes an open grid inside the nearest section.\n const gridIndex = findNearestFrameIndex(stack, (open) =>\n layoutDirectiveRegistry.isGridName(open.name),\n )\n const sectionIndex = findNearestFrameIndex(stack, (open) => open.name === 'section')\n\n if (gridIndex >= 0 && sectionIndex >= 0 && gridIndex > sectionIndex)\n diagnostics.push(...popFrames(stack, gridIndex))\n }\n\n stack.push(frame)\n return diagnostics\n }\n\n if (token.action === 'close') {\n if (stack.length === 0) return ['Encountered ::: with no open layout block.']\n\n return popFrames(stack, stack.length - 1)\n }\n\n if (token.action === 'closeGrid') {\n const index = findNearestFrameIndex(stack, (frame) =>\n layoutDirectiveRegistry.isGridName(frame.name),\n )\n\n if (index < 0) return ['Encountered :::endcol with no open grid.']\n\n return popFrames(stack, index)\n }\n\n const index = findNearestFrameIndex(stack, (frame) => frame.name === 'section')\n if (index < 0) return ['Encountered :::end or :::endsection with no open section.']\n\n return popFrames(stack, index)\n}\n\nfunction getThemeDiagnostics(text: string, options: LintMarkdownDirectivesOptions): string[] {\n const token = layoutDirectiveRegistry.parseMarkdownLineDetailed(text).token\n if (!token || token.action !== 'open') return []\n\n const definition = layoutDirectiveRegistry.get(token.name)\n\n return [\n ...getIconLintDiagnostics(token.name, token.attributes?.icon, options),\n ...getPaletteLintDiagnostics(token.name, definition?.allowedAttributes, token.attributes, options),\n ...(definition ? getUnknownThemeDiagnostics(definition, token.attributes, options.themes) : []),\n ]\n}\n\ntype DiagnosticSink = (message: string, from: number, to: number, line: number) => void\n\nfunction lintContainerLine(state: LintState, scanned: ScannedDirectiveLine, push: DiagnosticSink) {\n const report = (message: string) => push(message, scanned.from, scanned.to, scanned.startLine)\n const result = layoutDirectiveRegistry.parseMarkdownLineDetailed(scanned.text)\n\n for (const message of result.diagnostics) report(message)\n for (const message of getThemeDiagnostics(scanned.text, state.options)) report(message)\n for (const message of updateOpenStack(state, scanned.text, scanned.startLine, scanned.from))\n report(message)\n\n // Tokens that do not open/close anything render as prose inside the frame.\n if (!result.token) markTopFrameContent(state)\n}\n\nfunction lintLeafLine(state: LintState, scanned: ScannedDirectiveLine, push: DiagnosticSink) {\n const report = (message: string) => push(message, scanned.from, scanned.to, scanned.startLine)\n const leafName = getLeafDirectiveName(scanned.text)\n\n markTopFrameContent(state)\n\n if (!leafName) return\n\n const leaf = layoutDirectiveRegistry.get(leafName)?.leaf\n\n if (!leaf) {\n report(`Unknown directive \"${leafName}\".`)\n return\n }\n\n const problem = getLeafDirectiveProblem(scanned.text, leafName)\n\n if (problem) {\n report(problem)\n return\n }\n\n for (const message of leaf.lint(scanned.text, state.options)) report(message)\n}\n\nfunction lintParagraph(\n state: LintState,\n paragraph: Root['children'][number],\n index: SourceIndex,\n push: DiagnosticSink,\n) {\n if (paragraph.type !== 'paragraph') return\n\n const lines = splitParagraphIntoLines(paragraph)\n\n for (let lineIndex = 0; lineIndex < lines.length; ++lineIndex) {\n const scanned = scanDirectiveLineAt(lines, lineIndex, index)\n\n if (!scanned) {\n markTopFrameContent(state)\n continue\n }\n\n if (scanned.kind === 'container') lintContainerLine(state, scanned, push)\n else lintLeafLine(state, scanned, push)\n\n lineIndex = scanned.phrasingEnd\n }\n}\n\n/**\n * Editor-side directive diagnostics. The document is parsed with the same\n * remark/GFM front end and the same directive line scanner as the renderer,\n * so code blocks, lists, blockquotes and prose are classified identically.\n * Every renderer warning about directive syntax has an editor counterpart;\n * the renderer's \"Auto-closing unclosed layout block: X\" is reported here as\n * \"Unclosed directive \"X\".\" at the opening marker.\n */\nexport function lintMarkdownDirectives(\n markdown: string,\n options: LintMarkdownDirectivesOptions = {},\n): DirectiveDiagnostic[] {\n const diagnostics: DirectiveDiagnostic[] = []\n const state: LintState = { options, stack: [] }\n const index = createSourceIndex(markdown)\n const tree = parseDirectiveSourceTree(markdown)\n\n const push: DiagnosticSink = (message, from, to, line) =>\n diagnostics.push({ from, line, message, severity: 'warning', to })\n\n const nested = findNestedDirectiveMarkers(tree, index)\n let nestedIndex = 0\n\n const flushNestedBefore = (line: number) => {\n while (nestedIndex < nested.length && nested[nestedIndex].line < line) {\n const marker = nested[nestedIndex++]\n push(getNestedDirectiveMarkerDiagnostic(marker), marker.from, marker.to, marker.line)\n }\n }\n\n for (const node of tree.children) {\n flushNestedBefore(\n ('position' in node ? node.position?.start.line : undefined) ?? Number.POSITIVE_INFINITY,\n )\n\n if (node.type === 'paragraph') {\n lintParagraph(state, node, index, push)\n continue\n }\n\n if (node.type === 'heading') {\n const line = node.position?.start.line ?? 1\n const from = index.lineStarts[line] ?? 0\n\n for (const message of applyHeading(state, node.depth)) push(message, from, from, line)\n continue\n }\n\n markTopFrameContent(state)\n }\n\n flushNestedBefore(Number.POSITIVE_INFINITY)\n\n for (const frame of state.stack) {\n for (const message of finalizeFrame(frame))\n push(message, frame.from, frame.from + frame.name.length + 3, frame.line)\n\n push(`Unclosed directive \"${frame.name}\".`, frame.from, frame.from + frame.name.length + 3, frame.line)\n }\n\n return diagnostics\n}\n"],"names":["getLeafDirectiveName","getLeafDirectiveProblem","createSourceIndex","findNestedDirectiveMarkers","getNestedDirectiveMarkerDiagnostic","scanDirectiveLineAt","splitParagraphIntoLines","getIconLintDiagnostics","getPaletteLintDiagnostics","layoutDirectiveRegistry","parseDirectiveSourceTree","getUnknownThemeDiagnostics","findNearestFrameIndex","stack","predicate","index","length","frame","finalizeFrame","get","name","lint","close","popFrames","splice","flatMap","markTopFrameContent","state","top","hasContent","applyHeading","depth","diagnostics","isGridName","parentHeadingDepth","currentHeadingDepth","updateOpenStack","text","line","from","token","parseMarkdownLineDetailed","action","isGrid","push","open","attributes","label","gridIndex","sectionIndex","getThemeDiagnostics","options","definition","icon","allowedAttributes","themes","lintContainerLine","scanned","report","message","to","startLine","result","lintLeafLine","leafName","leaf","problem","lintParagraph","paragraph","type","lines","lineIndex","kind","phrasingEnd","lintMarkdownDirectives","markdown","tree","severity","nested","nestedIndex","flushNestedBefore","marker","node","children","position","start","undefined","Number","POSITIVE_INFINITY","lineStarts"],"mappings":"AAKA,SAASA,oBAAoB,EAAEC,uBAAuB,QAAQ,kBAAiB;AAC/E,SACEC,iBAAiB,EACjBC,0BAA0B,EAC1BC,kCAAkC,EAClCC,mBAAmB,EACnBC,uBAAuB,QAClB,mBAAkB;AACzB,SAASC,sBAAsB,EAAEC,yBAAyB,QAAQ,YAAW;AAC7E,SAASC,uBAAuB,QAAQ,gBAAe;AACvD,SAASC,wBAAwB,QAAQ,kBAAiB;AAC1D,SAASC,0BAA0B,QAAQ,wBAAuB;AAkBlE,SAASC,sBAAsBC,KAA2B,EAAEC,SAAiD;IAC3G,IAAK,IAAIC,QAAQF,MAAMG,MAAM,GAAG,GAAGD,SAAS,GAAG,EAAEA,MAAO;QACtD,MAAME,QAAQJ,KAAK,CAACE,MAAM;QAC1B,IAAID,UAAUG,QAAQ,OAAOF;IAC/B;IAEA,OAAO,CAAC;AACV;AAEA,8EAA8E,GAC9E,SAASG,cAAcD,KAAyB;IAC9C,OAAOR,wBAAwBU,GAAG,CAACF,MAAMG,IAAI,GAAGC,MAAMC,QAAQL,UAAU,EAAE;AAC5E;AAEA,SAASM,UAAUV,KAA2B,EAAEE,KAAa;IAC3D,OAAOF,MAAMW,MAAM,CAACT,OAAOU,OAAO,CAAC,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qB,OAAO3C,IAAI;QACtF;IACF;IAEA,KAAK,MAAM4C,QAAQN,KAAKO,QAAQ,CAAE;QAChCH,kBACE,AAAC,CAAA,cAAcE,OAAOA,KAAKE,QAAQ,EAAEC,MAAM/C,OAAOgD,SAAQ,KAAMC,OAAOC,iBAAiB;QAG1F,IAAIN,KAAKb,IAAI,KAAK,aAAa;YAC7BF,cAAcxC,OAAOuD,MAAMnE,OAAO6B;YAClC;QACF;QAEA,IAAIsC,KAAKb,IAAI,KAAK,WAAW;YAC3B,MAAM/B,OAAO4C,KAAKE,QAAQ,EAAEC,MAAM/C,QAAQ;YAC1C,MAAMC,OAAOxB,MAAM0E,UAAU,CAACnD,KAAK,IAAI;YAEvC,KAAK,MAAMqB,WAAW7B,aAAaH,OAAOuD,KAAKnD,KAAK,EAAGa,KAAKe,SAASpB,MAAMA,MAAMD;YACjF;QACF;QAEAZ,oBAAoBC;IACtB;IAEAqD,kBAAkBO,OAAOC,iBAAiB;IAE1C,KAAK,MAAMvE,SAASU,MAAMd,KAAK,CAAE;QAC/B,KAAK,MAAM8C,WAAWzC,cAAcD,OAClC2B,KAAKe,SAAS1C,MAAMsB,IAAI,EAAEtB,MAAMsB,IAAI,GAAGtB,MAAMG,IAAI,CAACJ,MAAM,GAAG,GAAGC,MAAMqB,IAAI;QAE1EM,KAAK,CAAC,oBAAoB,EAAE3B,MAAMG,IAAI,CAAC,EAAE,CAAC,EAAEH,MAAMsB,IAAI,EAAEtB,MAAMsB,IAAI,GAAGtB,MAAMG,IAAI,CAACJ,MAAM,GAAG,GAAGC,MAAMqB,IAAI;IACxG;IAEA,OAAON;AACT"}
@@ -1,12 +1,18 @@
1
- export declare function makeDirectiveIconPlaceholder(icon: string, className: string[]): {
1
+ /**
2
+ * A placeholder that rehypeResolveIcons replaces with the sanitized SVG.
3
+ * `palette` (optional) paints that icon; without it the icon renders exactly
4
+ * as before palettes existed.
5
+ */
6
+ export declare function makeDirectiveIconPlaceholder(icon: string, className: string[], palette?: string): {
2
7
  type: "element";
3
8
  children: never[];
4
9
  properties: {
10
+ dataPmdIconRef: string;
11
+ focusable: string;
12
+ dataPmdIconPalette?: string | undefined;
5
13
  ariaHidden: string;
6
14
  className: string[];
7
15
  dataPmdIcon: string;
8
- dataPmdIconRef: string;
9
- focusable: string;
10
16
  };
11
17
  tagName: string;
12
18
  };
@@ -1,5 +1,9 @@
1
1
  import { normalizePayloadMarkdownIconRef } from '../icons/refs.js';
2
- export function makeDirectiveIconPlaceholder(icon, className) {
2
+ /**
3
+ * A placeholder that rehypeResolveIcons replaces with the sanitized SVG.
4
+ * `palette` (optional) paints that icon; without it the icon renders exactly
5
+ * as before palettes existed.
6
+ */ export function makeDirectiveIconPlaceholder(icon, className, palette) {
3
7
  const normalized = normalizePayloadMarkdownIconRef(icon);
4
8
  const iconKey = normalized.icon?.key ?? icon;
5
9
  return {
@@ -9,6 +13,9 @@ export function makeDirectiveIconPlaceholder(icon, className) {
9
13
  ariaHidden: 'true',
10
14
  className,
11
15
  dataPmdIcon: iconKey,
16
+ ...palette ? {
17
+ dataPmdIconPalette: palette
18
+ } : {},
12
19
  dataPmdIconRef: icon,
13
20
  focusable: 'false'
14
21
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/directives/iconPlaceholder.ts"],"sourcesContent":["import { normalizePayloadMarkdownIconRef } from '../icons/refs.js'\n\nexport function makeDirectiveIconPlaceholder(icon: string, className: string[]) {\n const normalized = normalizePayloadMarkdownIconRef(icon)\n const iconKey = normalized.icon?.key ?? icon\n\n return {\n type: 'element' as const,\n children: [],\n properties: {\n ariaHidden: 'true',\n className,\n dataPmdIcon: iconKey,\n dataPmdIconRef: icon,\n focusable: 'false',\n },\n tagName: 'span',\n }\n}\n"],"names":["normalizePayloadMarkdownIconRef","makeDirectiveIconPlaceholder","icon","className","normalized","iconKey","key","type","children","properties","ariaHidden","dataPmdIcon","dataPmdIconRef","focusable","tagName"],"mappings":"AAAA,SAASA,+BAA+B,QAAQ,mBAAkB;AAElE,OAAO,SAASC,6BAA6BC,IAAY,EAAEC,SAAmB;IAC5E,MAAMC,aAAaJ,gCAAgCE;IACnD,MAAMG,UAAUD,WAAWF,IAAI,EAAEI,OAAOJ;IAExC,OAAO;QACLK,MAAM;QACNC,UAAU,EAAE;QACZC,YAAY;YACVC,YAAY;YACZP;YACAQ,aAAaN;YACbO,gBAAgBV;YAChBW,WAAW;QACb;QACAC,SAAS;IACX;AACF"}
1
+ {"version":3,"sources":["../../src/directives/iconPlaceholder.ts"],"sourcesContent":["import { normalizePayloadMarkdownIconRef } from '../icons/refs.js'\n\n/**\n * A placeholder that rehypeResolveIcons replaces with the sanitized SVG.\n * `palette` (optional) paints that icon; without it the icon renders exactly\n * as before palettes existed.\n */\nexport function makeDirectiveIconPlaceholder(icon: string, className: string[], palette?: string) {\n const normalized = normalizePayloadMarkdownIconRef(icon)\n const iconKey = normalized.icon?.key ?? icon\n\n return {\n type: 'element' as const,\n children: [],\n properties: {\n ariaHidden: 'true',\n className,\n dataPmdIcon: iconKey,\n ...(palette ? { dataPmdIconPalette: palette } : {}),\n dataPmdIconRef: icon,\n focusable: 'false',\n },\n tagName: 'span',\n }\n}\n"],"names":["normalizePayloadMarkdownIconRef","makeDirectiveIconPlaceholder","icon","className","palette","normalized","iconKey","key","type","children","properties","ariaHidden","dataPmdIcon","dataPmdIconPalette","dataPmdIconRef","focusable","tagName"],"mappings":"AAAA,SAASA,+BAA+B,QAAQ,mBAAkB;AAElE;;;;CAIC,GACD,OAAO,SAASC,6BAA6BC,IAAY,EAAEC,SAAmB,EAAEC,OAAgB;IAC9F,MAAMC,aAAaL,gCAAgCE;IACnD,MAAMI,UAAUD,WAAWH,IAAI,EAAEK,OAAOL;IAExC,OAAO;QACLM,MAAM;QACNC,UAAU,EAAE;QACZC,YAAY;YACVC,YAAY;YACZR;YACAS,aAAaN;YACb,GAAIF,UAAU;gBAAES,oBAAoBT;YAAQ,IAAI,CAAC,CAAC;YAClDU,gBAAgBZ;YAChBa,WAAW;QACb;QACAC,SAAS;IACX;AACF"}
@@ -0,0 +1,11 @@
1
+ import type { DirectiveLintFrame, LintMarkdownDirectivesOptions } from './types.js';
2
+ /**
3
+ * Helpers shared by the editor linter (diagnostics.ts) and the lint hooks of
4
+ * directive definitions. Nothing here imports the registry.
5
+ */
6
+ /** Nearest open frame named `name`, innermost first. */
7
+ export declare function findNearestLintFrame(stack: readonly DirectiveLintFrame[], name: string): DirectiveLintFrame | undefined;
8
+ /** Icon-entry option problems, extra icons, then unknown icon packs (one per entry). */
9
+ export declare function getIconLintDiagnostics(directive: string, icon: unknown, options: LintMarkdownDirectivesOptions): string[];
10
+ /** Unknown `palette` / `iconPalette` / icon-entry palettes, when the known palettes are given. */
11
+ export declare function getPaletteLintDiagnostics(directive: string, allowedAttributes: readonly string[] | undefined, attributes: Record<string, unknown> | undefined, options: LintMarkdownDirectivesOptions): string[];
@@ -0,0 +1,33 @@
1
+ import { getExtraIconWarnings, parseIconEntries } from '../icons/entries.js';
2
+ import { normalizePayloadMarkdownIconRef } from '../icons/refs.js';
3
+ import { collectPaletteNames, formatUnknownPaletteMessage } from '../palettes/diagnostics.js';
4
+ /**
5
+ * Helpers shared by the editor linter (diagnostics.ts) and the lint hooks of
6
+ * directive definitions. Nothing here imports the registry.
7
+ */ /** Nearest open frame named `name`, innermost first. */ export function findNearestLintFrame(stack, name) {
8
+ for(let index = stack.length - 1; index >= 0; --index){
9
+ const frame = stack[index];
10
+ if (frame.name === name) return frame;
11
+ }
12
+ return undefined;
13
+ }
14
+ /** Icon-entry option problems, extra icons, then unknown icon packs (one per entry). */ export function getIconLintDiagnostics(directive, icon, options) {
15
+ if (typeof icon !== 'string') return [];
16
+ const { entries, warnings } = parseIconEntries(icon);
17
+ const diagnostics = [
18
+ ...warnings,
19
+ ...getExtraIconWarnings(directive, entries)
20
+ ];
21
+ if (options.iconPacks) for (const entry of entries){
22
+ const normalized = normalizePayloadMarkdownIconRef(entry.ref);
23
+ if (normalized.icon && !options.iconPacks.includes(normalized.icon.packAlias)) diagnostics.push(`Unknown icon pack "${normalized.icon.packAlias}".`);
24
+ }
25
+ return diagnostics;
26
+ }
27
+ /** Unknown `palette` / `iconPalette` / icon-entry palettes, when the known palettes are given. */ export function getPaletteLintDiagnostics(directive, allowedAttributes, attributes, options) {
28
+ const known = options.palettes;
29
+ if (!known) return [];
30
+ return collectPaletteNames(allowedAttributes ?? [], attributes).filter((name)=>!known.includes(name)).map((name)=>formatUnknownPaletteMessage(name, directive, known));
31
+ }
32
+
33
+ //# sourceMappingURL=lint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/directives/lint.ts"],"sourcesContent":["import type { DirectiveLintFrame, LintMarkdownDirectivesOptions } from './types.js'\n\nimport { getExtraIconWarnings, parseIconEntries } from '../icons/entries.js'\nimport { normalizePayloadMarkdownIconRef } from '../icons/refs.js'\nimport { collectPaletteNames, formatUnknownPaletteMessage } from '../palettes/diagnostics.js'\n\n/**\n * Helpers shared by the editor linter (diagnostics.ts) and the lint hooks of\n * directive definitions. Nothing here imports the registry.\n */\n\n/** Nearest open frame named `name`, innermost first. */\nexport function findNearestLintFrame(\n stack: readonly DirectiveLintFrame[],\n name: string,\n): DirectiveLintFrame | undefined {\n for (let index = stack.length - 1; index >= 0; --index) {\n const frame = stack[index]\n if (frame.name === name) return frame\n }\n\n return undefined\n}\n\n/** Icon-entry option problems, extra icons, then unknown icon packs (one per entry). */\nexport function getIconLintDiagnostics(\n directive: string,\n icon: unknown,\n options: LintMarkdownDirectivesOptions,\n): string[] {\n if (typeof icon !== 'string') return []\n\n const { entries, warnings } = parseIconEntries(icon)\n const diagnostics = [...warnings, ...getExtraIconWarnings(directive, entries)]\n\n if (options.iconPacks)\n for (const entry of entries) {\n const normalized = normalizePayloadMarkdownIconRef(entry.ref)\n if (normalized.icon && !options.iconPacks.includes(normalized.icon.packAlias))\n diagnostics.push(`Unknown icon pack \"${normalized.icon.packAlias}\".`)\n }\n\n return diagnostics\n}\n\n/** Unknown `palette` / `iconPalette` / icon-entry palettes, when the known palettes are given. */\nexport function getPaletteLintDiagnostics(\n directive: string,\n allowedAttributes: readonly string[] | undefined,\n attributes: Record<string, unknown> | undefined,\n options: LintMarkdownDirectivesOptions,\n): string[] {\n const known = options.palettes\n if (!known) return []\n\n return collectPaletteNames(allowedAttributes ?? [], attributes)\n .filter((name) => !known.includes(name))\n .map((name) => formatUnknownPaletteMessage(name, directive, known))\n}\n"],"names":["getExtraIconWarnings","parseIconEntries","normalizePayloadMarkdownIconRef","collectPaletteNames","formatUnknownPaletteMessage","findNearestLintFrame","stack","name","index","length","frame","undefined","getIconLintDiagnostics","directive","icon","options","entries","warnings","diagnostics","iconPacks","entry","normalized","ref","includes","packAlias","push","getPaletteLintDiagnostics","allowedAttributes","attributes","known","palettes","filter","map"],"mappings":"AAEA,SAASA,oBAAoB,EAAEC,gBAAgB,QAAQ,sBAAqB;AAC5E,SAASC,+BAA+B,QAAQ,mBAAkB;AAClE,SAASC,mBAAmB,EAAEC,2BAA2B,QAAQ,6BAA4B;AAE7F;;;CAGC,GAED,sDAAsD,GACtD,OAAO,SAASC,qBACdC,KAAoC,EACpCC,IAAY;IAEZ,IAAK,IAAIC,QAAQF,MAAMG,MAAM,GAAG,GAAGD,SAAS,GAAG,EAAEA,MAAO;QACtD,MAAME,QAAQJ,KAAK,CAACE,MAAM;QAC1B,IAAIE,MAAMH,IAAI,KAAKA,MAAM,OAAOG;IAClC;IAEA,OAAOC;AACT;AAEA,sFAAsF,GACtF,OAAO,SAASC,uBACdC,SAAiB,EACjBC,IAAa,EACbC,OAAsC;IAEtC,IAAI,OAAOD,SAAS,UAAU,OAAO,EAAE;IAEvC,MAAM,EAAEE,OAAO,EAAEC,QAAQ,EAAE,GAAGhB,iBAAiBa;IAC/C,MAAMI,cAAc;WAAID;WAAajB,qBAAqBa,WAAWG;KAAS;IAE9E,IAAID,QAAQI,SAAS,EACnB,KAAK,MAAMC,SAASJ,QAAS;QAC3B,MAAMK,aAAanB,gCAAgCkB,MAAME,GAAG;QAC5D,IAAID,WAAWP,IAAI,IAAI,CAACC,QAAQI,SAAS,CAACI,QAAQ,CAACF,WAAWP,IAAI,CAACU,SAAS,GAC1EN,YAAYO,IAAI,CAAC,CAAC,mBAAmB,EAAEJ,WAAWP,IAAI,CAACU,SAAS,CAAC,EAAE,CAAC;IACxE;IAEF,OAAON;AACT;AAEA,gGAAgG,GAChG,OAAO,SAASQ,0BACdb,SAAiB,EACjBc,iBAAgD,EAChDC,UAA+C,EAC/Cb,OAAsC;IAEtC,MAAMc,QAAQd,QAAQe,QAAQ;IAC9B,IAAI,CAACD,OAAO,OAAO,EAAE;IAErB,OAAO1B,oBAAoBwB,qBAAqB,EAAE,EAAEC,YACjDG,MAAM,CAAC,CAACxB,OAAS,CAACsB,MAAMN,QAAQ,CAAChB,OACjCyB,GAAG,CAAC,CAACzB,OAASH,4BAA4BG,MAAMM,WAAWgB;AAChE"}
@@ -0,0 +1,23 @@
1
+ import type { Element } from 'hast';
2
+ import type { ContainerDirective } from 'mdast-util-directive';
3
+ import type { IconEntry } from '../icons/entries.js';
4
+ import type { MarkdownRenderConfig } from '../types/core.js';
5
+ /** Attributes every palette-aware directive accepts. */
6
+ export declare const PALETTE_ATTRIBUTES: readonly ["iconPalette", "palette"];
7
+ /** Render properties carrying `palette` / `iconPalette` from mdast to hast. */
8
+ export declare function getPaletteRenderProperties(node: ContainerDirective): {
9
+ dataIconPalette: string | undefined;
10
+ dataPalette: string | undefined;
11
+ };
12
+ /**
13
+ * The palette an icon of this directive is painted with: its own entry, then
14
+ * the directive's `iconPalette`, then the directive's `palette`.
15
+ */
16
+ export declare function resolveIconPaletteName(node: Element, entry?: IconEntry): string | undefined;
17
+ /**
18
+ * Scopes the directive's palette to it: the palette colours become the public
19
+ * `--pmd-*` tokens (or button tokens) on the directive element, which the
20
+ * default themes read first. Unknown palettes were reported during validation
21
+ * and leave the directive unchanged.
22
+ */
23
+ export declare function applyDirectivePalette(node: Element, config: MarkdownRenderConfig, kind?: 'button' | 'surface'): void;
@@ -0,0 +1,40 @@
1
+ import { buttonPaletteStyle, directivePaletteStyle, getPaletteRegistry } from '../palettes/index.js';
2
+ /** Attributes every palette-aware directive accepts. */ export const PALETTE_ATTRIBUTES = [
3
+ 'iconPalette',
4
+ 'palette'
5
+ ];
6
+ function getAttribute(node, name) {
7
+ const value = node.attributes?.[name];
8
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
9
+ }
10
+ /** Render properties carrying `palette` / `iconPalette` from mdast to hast. */ export function getPaletteRenderProperties(node) {
11
+ return {
12
+ dataIconPalette: getAttribute(node, 'iconPalette'),
13
+ dataPalette: getAttribute(node, 'palette')
14
+ };
15
+ }
16
+ function readProperty(node, name) {
17
+ const value = node.properties[name];
18
+ return typeof value === 'string' && value ? value : undefined;
19
+ }
20
+ /**
21
+ * The palette an icon of this directive is painted with: its own entry, then
22
+ * the directive's `iconPalette`, then the directive's `palette`.
23
+ */ export function resolveIconPaletteName(node, entry) {
24
+ return entry?.palette ?? readProperty(node, 'dataIconPalette') ?? readProperty(node, 'dataPalette');
25
+ }
26
+ /**
27
+ * Scopes the directive's palette to it: the palette colours become the public
28
+ * `--pmd-*` tokens (or button tokens) on the directive element, which the
29
+ * default themes read first. Unknown palettes were reported during validation
30
+ * and leave the directive unchanged.
31
+ */ export function applyDirectivePalette(node, config, kind = 'surface') {
32
+ const name = readProperty(node, 'dataPalette');
33
+ if (!name) return;
34
+ const palette = getPaletteRegistry(config.palettes).get(name);
35
+ if (!palette) return;
36
+ const style = kind === 'button' ? buttonPaletteStyle(palette) : directivePaletteStyle(palette);
37
+ if (style) node.properties.style = style;
38
+ }
39
+
40
+ //# sourceMappingURL=palette.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/directives/palette.ts"],"sourcesContent":["import type { Element } from 'hast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { IconEntry } from '../icons/entries.js'\nimport type { MarkdownRenderConfig } from '../types/core.js'\n\nimport { buttonPaletteStyle, directivePaletteStyle, getPaletteRegistry } from '../palettes/index.js'\n\n/** Attributes every palette-aware directive accepts. */\nexport const PALETTE_ATTRIBUTES = ['iconPalette', 'palette'] as const\n\nfunction getAttribute(node: ContainerDirective, name: string): string | undefined {\n const value = node.attributes?.[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\n/** Render properties carrying `palette` / `iconPalette` from mdast to hast. */\nexport function getPaletteRenderProperties(node: ContainerDirective) {\n return {\n dataIconPalette: getAttribute(node, 'iconPalette'),\n dataPalette: getAttribute(node, 'palette'),\n }\n}\n\nfunction readProperty(node: Element, name: 'dataIconPalette' | 'dataPalette'): string | undefined {\n const value = node.properties[name]\n\n return typeof value === 'string' && value ? value : undefined\n}\n\n/**\n * The palette an icon of this directive is painted with: its own entry, then\n * the directive's `iconPalette`, then the directive's `palette`.\n */\nexport function resolveIconPaletteName(node: Element, entry?: IconEntry): string | undefined {\n return entry?.palette ?? readProperty(node, 'dataIconPalette') ?? readProperty(node, 'dataPalette')\n}\n\n/**\n * Scopes the directive's palette to it: the palette colours become the public\n * `--pmd-*` tokens (or button tokens) on the directive element, which the\n * default themes read first. Unknown palettes were reported during validation\n * and leave the directive unchanged.\n */\nexport function applyDirectivePalette(\n node: Element,\n config: MarkdownRenderConfig,\n kind: 'button' | 'surface' = 'surface',\n): void {\n const name = readProperty(node, 'dataPalette')\n if (!name) return\n\n const palette = getPaletteRegistry(config.palettes).get(name)\n if (!palette) return\n\n const style = kind === 'button' ? buttonPaletteStyle(palette) : directivePaletteStyle(palette)\n if (style) node.properties.style = style\n}\n"],"names":["buttonPaletteStyle","directivePaletteStyle","getPaletteRegistry","PALETTE_ATTRIBUTES","getAttribute","node","name","value","attributes","trim","undefined","getPaletteRenderProperties","dataIconPalette","dataPalette","readProperty","properties","resolveIconPaletteName","entry","palette","applyDirectivePalette","config","kind","palettes","get","style"],"mappings":"AAMA,SAASA,kBAAkB,EAAEC,qBAAqB,EAAEC,kBAAkB,QAAQ,uBAAsB;AAEpG,sDAAsD,GACtD,OAAO,MAAMC,qBAAqB;IAAC;IAAe;CAAU,CAAS;AAErE,SAASC,aAAaC,IAAwB,EAAEC,IAAY;IAC1D,MAAMC,QAAQF,KAAKG,UAAU,EAAE,CAACF,KAAK;IAErC,OAAO,OAAOC,UAAU,YAAYA,MAAME,IAAI,KAAKF,MAAME,IAAI,KAAKC;AACpE;AAEA,6EAA6E,GAC7E,OAAO,SAASC,2BAA2BN,IAAwB;IACjE,OAAO;QACLO,iBAAiBR,aAAaC,MAAM;QACpCQ,aAAaT,aAAaC,MAAM;IAClC;AACF;AAEA,SAASS,aAAaT,IAAa,EAAEC,IAAuC;IAC1E,MAAMC,QAAQF,KAAKU,UAAU,CAACT,KAAK;IAEnC,OAAO,OAAOC,UAAU,YAAYA,QAAQA,QAAQG;AACtD;AAEA;;;CAGC,GACD,OAAO,SAASM,uBAAuBX,IAAa,EAAEY,KAAiB;IACrE,OAAOA,OAAOC,WAAWJ,aAAaT,MAAM,sBAAsBS,aAAaT,MAAM;AACvF;AAEA;;;;;CAKC,GACD,OAAO,SAASc,sBACdd,IAAa,EACbe,MAA4B,EAC5BC,OAA6B,SAAS;IAEtC,MAAMf,OAAOQ,aAAaT,MAAM;IAChC,IAAI,CAACC,MAAM;IAEX,MAAMY,UAAUhB,mBAAmBkB,OAAOE,QAAQ,EAAEC,GAAG,CAACjB;IACxD,IAAI,CAACY,SAAS;IAEd,MAAMM,QAAQH,SAAS,WAAWrB,mBAAmBkB,WAAWjB,sBAAsBiB;IACtF,IAAIM,OAAOnB,KAAKU,UAAU,CAACS,KAAK,GAAGA;AACrC"}
@@ -1,4 +1,11 @@
1
- import type { GridDirectiveName, LayoutDirectiveDefinition, LayoutName, LayoutToken, MarkdownDirectiveName } from './types.js';
1
+ import type { DirectiveCloseMarker, GridDirectiveName, LayoutDirectiveDefinition, LayoutName, LayoutToken, MarkdownDirectiveName } from './types.js';
2
+ /**
3
+ * Every directive, in registry order (the order of the spec, the editor
4
+ * completions and the leaf diagnostics). A directive is one definition file
5
+ * under definitions/ plus an entry here; names, kinds, the sanitize
6
+ * allowlist, the spec and the leaf pipeline are derived from the definitions.
7
+ */
8
+ export declare const directiveDefinitions: readonly [LayoutDirectiveDefinition<"section", "section">, LayoutDirectiveDefinition<"2col", "grid">, LayoutDirectiveDefinition<"3col", "grid">, LayoutDirectiveDefinition<"cell", "cell">, LayoutDirectiveDefinition<"button", "button">, LayoutDirectiveDefinition<"buttons", "buttons">, LayoutDirectiveDefinition<"badge", "badge">, LayoutDirectiveDefinition<"badges", "badges">, LayoutDirectiveDefinition<"callout", "callout">, LayoutDirectiveDefinition<"details", "details">, LayoutDirectiveDefinition<"toc", "toc">, LayoutDirectiveDefinition<"steps", "steps">, LayoutDirectiveDefinition<"cards", "cards">, LayoutDirectiveDefinition<"card", "card">, LayoutDirectiveDefinition<"tabs", "tabs">, LayoutDirectiveDefinition<"tab", "tab">];
2
9
  type ParseMarkdownLineResult = {
3
10
  diagnostics: string[];
4
11
  token: LayoutToken | null;
@@ -6,21 +13,31 @@ type ParseMarkdownLineResult = {
6
13
  declare function getDirectiveDefinition(name: string): LayoutDirectiveDefinition | undefined;
7
14
  declare function isSupportedDirectiveName(name: string): name is MarkdownDirectiveName;
8
15
  declare function getPublicDefinitions(): LayoutDirectiveDefinition[];
9
- /** Attribute a container directive's `[label]` stands for. */
10
- export declare const DIRECTIVE_LABEL_ATTRIBUTES: ReadonlyMap<string, string>;
16
+ /** Opening marker of a definition's primary form: `:::name` (container) or `::name` (leaf). */
17
+ declare function getOpenMarker(definition: LayoutDirectiveDefinition): string;
18
+ /** Markers that close a container directive; empty for leaf-only directives. */
19
+ declare function getDefinitionCloseMarkers(definition: LayoutDirectiveDefinition): readonly DirectiveCloseMarker[];
20
+ /**
21
+ * Whether the directive's element carries the `data-vl-layout` marker that
22
+ * runs its `applyHast` after sanitizing: every container, and leaves that
23
+ * ask for it (`leaf.marker`).
24
+ */
25
+ declare function receivesLayoutMarker(definition: LayoutDirectiveDefinition, form: 'container' | 'leaf'): boolean;
11
26
  export declare function getUnexpectedTextDiagnostic(marker: string, text: string): string;
12
27
  declare function parseMarkdownLineDetailed(text: string): ParseMarkdownLineResult;
13
28
  declare function parseMarkdownLine(text: string): LayoutToken | null;
14
29
  export declare const layoutDirectiveRegistry: {
15
- all: readonly [LayoutDirectiveDefinition, ...LayoutDirectiveDefinition[], LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition, LayoutDirectiveDefinition];
30
+ all: readonly [LayoutDirectiveDefinition<"section", "section">, LayoutDirectiveDefinition<"2col", "grid">, LayoutDirectiveDefinition<"3col", "grid">, LayoutDirectiveDefinition<"cell", "cell">, LayoutDirectiveDefinition<"button", "button">, LayoutDirectiveDefinition<"buttons", "buttons">, LayoutDirectiveDefinition<"badge", "badge">, LayoutDirectiveDefinition<"badges", "badges">, LayoutDirectiveDefinition<"callout", "callout">, LayoutDirectiveDefinition<"details", "details">, LayoutDirectiveDefinition<"toc", "toc">, LayoutDirectiveDefinition<"steps", "steps">, LayoutDirectiveDefinition<"cards", "cards">, LayoutDirectiveDefinition<"card", "card">, LayoutDirectiveDefinition<"tabs", "tabs">, LayoutDirectiveDefinition<"tab", "tab">];
16
31
  /** Close markers and the layout token action each produces. */
17
32
  closeMarkers: {
18
33
  action: "close" | "open" | "closeGrid" | "closeSection";
19
- marker: string;
34
+ marker: DirectiveCloseMarker;
20
35
  }[];
21
36
  get: typeof getDirectiveDefinition;
22
37
  /** Editor close-label text for a container directive (`endcard`, `endcol`, …). */
23
38
  getCloseLabel(name: string): string;
39
+ getCloseMarkers: typeof getDefinitionCloseMarkers;
40
+ getOpenMarker: typeof getOpenMarker;
24
41
  getPublicDefinitions: typeof getPublicDefinitions;
25
42
  isGridName(name: string | undefined): name is GridDirectiveName;
26
43
  isLeafDirectiveName(name: string): boolean;
@@ -28,5 +45,6 @@ export declare const layoutDirectiveRegistry: {
28
45
  leafDirectiveNames: readonly string[];
29
46
  parseMarkdownLine: typeof parseMarkdownLine;
30
47
  parseMarkdownLineDetailed: typeof parseMarkdownLineDetailed;
48
+ receivesLayoutMarker: typeof receivesLayoutMarker;
31
49
  };
32
50
  export type { GridDirectiveName, LayoutName, LayoutToken, MarkdownDirectiveName };
@@ -16,7 +16,12 @@ import { stepsDirective } from './definitions/steps.js';
16
16
  import { tabDirective } from './definitions/tab.js';
17
17
  import { tabsDirective } from './definitions/tabs.js';
18
18
  import { tocDirective } from './definitions/toc.js';
19
- const directiveDefinitions = [
19
+ /**
20
+ * Every directive, in registry order (the order of the spec, the editor
21
+ * completions and the leaf diagnostics). A directive is one definition file
22
+ * under definitions/ plus an entry here; names, kinds, the sanitize
23
+ * allowlist, the spec and the leaf pipeline are derived from the definitions.
24
+ */ export const directiveDefinitions = [
20
25
  sectionDirective,
21
26
  ...columnDirectives,
22
27
  cellDirective,
@@ -33,7 +38,14 @@ const directiveDefinitions = [
33
38
  tabsDirective,
34
39
  tabDirective
35
40
  ];
36
- const closeMarkers = new Map([
41
+ const definitionsByName = new Map(directiveDefinitions.map((definition)=>[
42
+ definition.name,
43
+ definition
44
+ ]));
45
+ /**
46
+ * Close markers and the layout action each produces (the directive grammar;
47
+ * a container lists the ones that close it in `container.closeMarkers`).
48
+ */ const closeMarkers = new Map([
37
49
  [
38
50
  ':::',
39
51
  {
@@ -63,48 +75,44 @@ const closeMarkers = new Map([
63
75
  }
64
76
  ]
65
77
  ]);
78
+ const DEFAULT_CLOSE_MARKERS = [
79
+ ':::'
80
+ ];
66
81
  function cloneToken(token) {
67
82
  return {
68
83
  ...token
69
84
  };
70
85
  }
71
- function isLayoutName(name) {
72
- return Boolean(directiveDefinitions.find((definition)=>definition.name === name)?.openMarker);
73
- }
74
86
  function getDirectiveDefinition(name) {
75
- return directiveDefinitions.find((definition)=>definition.name === name);
87
+ return definitionsByName.get(name);
76
88
  }
77
- /** Leaf directives (`::name[label]{…}`): definitions without a `:::` open marker. */ const leafDirectiveNames = directiveDefinitions.filter((definition)=>!('openMarker' in definition) || !definition.openMarker).map((definition)=>definition.name);
78
89
  function isSupportedDirectiveName(name) {
79
- return directiveDefinitions.some((definition)=>definition.name === name);
90
+ return definitionsByName.has(name);
91
+ }
92
+ /** Directives with a container form (`:::name…`). */ function isContainerName(name) {
93
+ return Boolean(getDirectiveDefinition(name)?.container);
80
94
  }
95
+ /** Leaf directives (`::name[label]{…}`): definitions with a leaf form. */ const leafDirectiveNames = directiveDefinitions.filter((definition)=>'leaf' in definition && definition.leaf).map((definition)=>definition.name);
96
+ const gridDirectiveNames = directiveDefinitions.filter((definition)=>definition.kind === 'grid').map((definition)=>definition.name);
81
97
  function getPublicDefinitions() {
82
98
  return directiveDefinitions.filter((definition)=>definition.public);
83
99
  }
84
- /** Attribute a container directive's `[label]` stands for. */ export const DIRECTIVE_LABEL_ATTRIBUTES = new Map([
85
- [
86
- 'callout',
87
- 'title'
88
- ],
89
- [
90
- 'card',
91
- 'title'
92
- ],
93
- [
94
- 'details',
95
- 'title'
96
- ],
97
- [
98
- 'tab',
99
- 'label'
100
- ],
101
- [
102
- 'toc',
103
- 'title'
104
- ]
105
- ]);
106
- function getLabelConflictDiagnostics(name, label, attributes) {
107
- const labelAttribute = DIRECTIVE_LABEL_ATTRIBUTES.get(name);
100
+ /** Opening marker of a definition's primary form: `:::name` (container) or `::name` (leaf). */ function getOpenMarker(definition) {
101
+ return definition.container ? `:::${definition.name}` : `::${definition.name}`;
102
+ }
103
+ /** Markers that close a container directive; empty for leaf-only directives. */ function getDefinitionCloseMarkers(definition) {
104
+ if (!definition.container) return [];
105
+ return definition.container.closeMarkers ?? DEFAULT_CLOSE_MARKERS;
106
+ }
107
+ /**
108
+ * Whether the directive's element carries the `data-vl-layout` marker that
109
+ * runs its `applyHast` after sanitizing: every container, and leaves that
110
+ * ask for it (`leaf.marker`).
111
+ */ function receivesLayoutMarker(definition, form) {
112
+ return form === 'container' ? Boolean(definition.container) : Boolean(definition.leaf?.marker);
113
+ }
114
+ function getLabelConflictDiagnostics(definition, label, attributes) {
115
+ const labelAttribute = definition.container?.labelAttribute;
108
116
  if (!labelAttribute) return [];
109
117
  const normalizedLabel = label?.trim();
110
118
  const attributeTitle = attributes[labelAttribute];
@@ -144,12 +152,12 @@ function parseMarkdownLineDetailed(text) {
144
152
  ],
145
153
  token: null
146
154
  };
147
- if (!isLayoutName(parsed.name)) return {
155
+ if (!isContainerName(parsed.name)) return {
148
156
  diagnostics: [],
149
157
  token: null
150
158
  };
151
159
  const definition = getDirectiveDefinition(parsed.name);
152
- if (!definition?.openMarker) return {
160
+ if (!definition?.container) return {
153
161
  diagnostics: [],
154
162
  token: null
155
163
  };
@@ -159,8 +167,9 @@ function parseMarkdownLineDetailed(text) {
159
167
  ],
160
168
  token: null
161
169
  };
162
- const exactMatch = definition.openMarker === trimmed;
163
- const attributedMatch = definition.supportsAttributes && (trimmed.startsWith(`${definition.openMarker} `) || trimmed.startsWith(`${definition.openMarker}[`) || trimmed.startsWith(`${definition.openMarker}{`));
170
+ const openMarker = getOpenMarker(definition);
171
+ const exactMatch = openMarker === trimmed;
172
+ const attributedMatch = definition.supportsAttributes && (trimmed.startsWith(`${openMarker} `) || trimmed.startsWith(`${openMarker}[`) || trimmed.startsWith(`${openMarker}{`));
164
173
  if (!exactMatch && !attributedMatch) return {
165
174
  diagnostics: [],
166
175
  token: null
@@ -168,7 +177,7 @@ function parseMarkdownLineDetailed(text) {
168
177
  const diagnostics = [
169
178
  ...parsed.warnings,
170
179
  ...getUnknownAttributeWarnings(parsed.name, definition.allowedAttributes, parsed.attributes),
171
- ...getLabelConflictDiagnostics(parsed.name, parsed.label, parsed.attributes),
180
+ ...getLabelConflictDiagnostics(definition, parsed.label, parsed.attributes),
172
181
  ...typeof parsed.attributes.icon === 'string' ? [
173
182
  normalizePayloadMarkdownIconRef(parsed.attributes.icon).warning
174
183
  ].filter((warning)=>Boolean(warning)) : [],
@@ -202,11 +211,13 @@ export const layoutDirectiveRegistry = {
202
211
  })),
203
212
  get: getDirectiveDefinition,
204
213
  /** Editor close-label text for a container directive (`endcard`, `endcol`, …). */ getCloseLabel (name) {
205
- return name === '2col' || name === '3col' ? 'endcol' : `end${name}`;
214
+ return getDirectiveDefinition(name)?.container?.closeLabel ?? `end${name}`;
206
215
  },
216
+ getCloseMarkers: getDefinitionCloseMarkers,
217
+ getOpenMarker,
207
218
  getPublicDefinitions,
208
219
  isGridName (name) {
209
- return name === '2col' || name === '3col';
220
+ return name !== undefined && gridDirectiveNames.includes(name);
210
221
  },
211
222
  isLeafDirectiveName (name) {
212
223
  return leafDirectiveNames.includes(name);
@@ -214,7 +225,8 @@ export const layoutDirectiveRegistry = {
214
225
  isSupportedDirectiveName,
215
226
  leafDirectiveNames,
216
227
  parseMarkdownLine,
217
- parseMarkdownLineDetailed
228
+ parseMarkdownLineDetailed,
229
+ receivesLayoutMarker
218
230
  };
219
231
 
220
232
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/directives/registry.ts"],"sourcesContent":["import type {\n GridDirectiveName,\n LayoutDirectiveDefinition,\n LayoutName,\n LayoutToken,\n MarkdownDirectiveName,\n} from './types.js'\n\nimport { normalizePayloadMarkdownIconRef } from '../icons/refs.js'\nimport { getUnknownAttributeWarnings } from './attributeDiagnostics.js'\nimport { parseDirectiveLine } from './attributes.js'\nimport { badgeDirective } from './definitions/badge.js'\nimport { badgesDirective } from './definitions/badges.js'\nimport { buttonDirective } from './definitions/button.js'\nimport { buttonsDirective } from './definitions/buttons.js'\nimport { calloutDirective } from './definitions/callout.js'\nimport { cardDirective } from './definitions/card.js'\nimport { cardsDirective } from './definitions/cards.js'\nimport { cellDirective } from './definitions/cell.js'\nimport { columnDirectives } from './definitions/columns.js'\nimport { detailsDirective } from './definitions/details.js'\nimport { sectionDirective } from './definitions/section.js'\nimport { stepsDirective } from './definitions/steps.js'\nimport { tabDirective } from './definitions/tab.js'\nimport { tabsDirective } from './definitions/tabs.js'\nimport { tocDirective } from './definitions/toc.js'\n\nconst directiveDefinitions = [\n sectionDirective,\n ...columnDirectives,\n cellDirective,\n buttonDirective,\n buttonsDirective,\n badgeDirective,\n badgesDirective,\n calloutDirective,\n detailsDirective,\n tocDirective,\n stepsDirective,\n cardsDirective,\n cardDirective,\n tabsDirective,\n tabDirective,\n] as const satisfies readonly LayoutDirectiveDefinition[]\n\nconst closeMarkers = new Map<string, LayoutToken>([\n [':::', { type: 'vlLayoutToken', action: 'close' }],\n [':::end', { type: 'vlLayoutToken', action: 'closeSection' }],\n [':::endcol', { type: 'vlLayoutToken', action: 'closeGrid' }],\n [':::endsection', { type: 'vlLayoutToken', action: 'closeSection' }],\n])\n\nfunction cloneToken(token: LayoutToken): LayoutToken {\n return { ...token }\n}\n\ntype ParseMarkdownLineResult = {\n diagnostics: string[]\n token: LayoutToken | null\n}\n\nfunction isLayoutName(name: MarkdownDirectiveName): name is LayoutName {\n return Boolean(directiveDefinitions.find((definition) => definition.name === name)?.openMarker)\n}\n\nfunction getDirectiveDefinition(name: string): LayoutDirectiveDefinition | undefined {\n return directiveDefinitions.find((definition) => definition.name === name)\n}\n\n/** Leaf directives (`::name[label]{…}`): definitions without a `:::` open marker. */\nconst leafDirectiveNames: readonly string[] = directiveDefinitions\n .filter((definition) => !('openMarker' in definition) || !definition.openMarker)\n .map((definition) => definition.name)\n\nfunction isSupportedDirectiveName(name: string): name is MarkdownDirectiveName {\n return directiveDefinitions.some((definition) => definition.name === name)\n}\n\nfunction getPublicDefinitions(): LayoutDirectiveDefinition[] {\n return directiveDefinitions.filter((definition) => definition.public)\n}\n\n/** Attribute a container directive's `[label]` stands for. */\nexport const DIRECTIVE_LABEL_ATTRIBUTES: ReadonlyMap<string, string> = new Map<string, string>([\n ['callout', 'title'],\n ['card', 'title'],\n ['details', 'title'],\n ['tab', 'label'],\n ['toc', 'title'],\n])\n\nfunction getLabelConflictDiagnostics(\n name: string,\n label: string | undefined,\n attributes: Record<string, boolean | string>,\n): string[] {\n const labelAttribute = DIRECTIVE_LABEL_ATTRIBUTES.get(name)\n if (!labelAttribute) return []\n\n const normalizedLabel = label?.trim()\n const attributeTitle = attributes[labelAttribute]\n if (!normalizedLabel || typeof attributeTitle !== 'string' || !attributeTitle.trim()) return []\n if (normalizedLabel === attributeTitle.trim()) return []\n\n return [\n `Directive has both [Label] and ${labelAttribute}. [Label] is preferred; remove one to avoid ambiguity.`,\n ]\n}\n\nexport function getUnexpectedTextDiagnostic(marker: string, text: string): string {\n const preview = text.length > 40 ? `${text.slice(0, 40)}…` : text\n\n return `Unexpected text \"${preview}\" after \"${marker}\". Directive attributes must be wrapped in {…}; the line is rendered as text.`\n}\n\nfunction parseMarkdownLineDetailed(text: string): ParseMarkdownLineResult {\n const trimmed = text.trim()\n const closeToken = closeMarkers.get(trimmed)\n\n if (closeToken)\n return {\n diagnostics: [],\n token: cloneToken(closeToken),\n }\n\n const parsed = parseDirectiveLine(trimmed)\n if (!parsed)\n return {\n diagnostics: trimmed.startsWith(':::')\n ? ['Malformed directive marker.']\n : [],\n token: null,\n }\n\n if (!isSupportedDirectiveName(parsed.name))\n return {\n diagnostics: [`Unknown directive \"${parsed.name}\".`],\n token: null,\n }\n\n if (parsed.unexpectedText)\n return {\n diagnostics: [getUnexpectedTextDiagnostic(`:::${parsed.name}`, parsed.unexpectedText)],\n token: null,\n }\n\n if (!isLayoutName(parsed.name))\n return {\n diagnostics: [],\n token: null,\n }\n\n const definition = getDirectiveDefinition(parsed.name)\n if (!definition?.openMarker)\n return {\n diagnostics: [],\n token: null,\n }\n\n if (!definition.supportsAttributes && parsed.rawAttributes)\n return {\n diagnostics: [`Directive \"${parsed.name}\" does not support attributes.`],\n token: null,\n }\n\n const exactMatch = definition.openMarker === trimmed\n const attributedMatch =\n definition.supportsAttributes &&\n (trimmed.startsWith(`${definition.openMarker} `) ||\n trimmed.startsWith(`${definition.openMarker}[`) ||\n trimmed.startsWith(`${definition.openMarker}{`))\n\n if (!exactMatch && !attributedMatch)\n return {\n diagnostics: [],\n token: null,\n }\n\n const diagnostics = [\n ...parsed.warnings,\n ...getUnknownAttributeWarnings(parsed.name, definition.allowedAttributes, parsed.attributes),\n ...getLabelConflictDiagnostics(parsed.name, parsed.label, parsed.attributes),\n ...(typeof parsed.attributes.icon === 'string'\n ? [normalizePayloadMarkdownIconRef(parsed.attributes.icon).warning].filter(\n (warning): warning is string => Boolean(warning),\n )\n : []),\n ...(definition.validateAttributes?.({\n name: parsed.name,\n attributes: parsed.attributes,\n }) ?? []),\n ]\n\n const token: LayoutToken = {\n name: parsed.name,\n type: 'vlLayoutToken',\n action: 'open',\n attributes: parsed.attributes,\n label: parsed.label,\n }\n\n return {\n diagnostics,\n token,\n }\n}\n\nfunction parseMarkdownLine(text: string): LayoutToken | null {\n return parseMarkdownLineDetailed(text).token\n}\n\nexport const layoutDirectiveRegistry = {\n all: directiveDefinitions,\n\n /** Close markers and the layout token action each produces. */\n closeMarkers: [...closeMarkers].map(([marker, token]) => ({ action: token.action, marker })),\n\n get: getDirectiveDefinition,\n\n /** Editor close-label text for a container directive (`endcard`, `endcol`, …). */\n getCloseLabel(name: string): string {\n return name === '2col' || name === '3col' ? 'endcol' : `end${name}`\n },\n\n getPublicDefinitions,\n\n isGridName(name: string | undefined): name is GridDirectiveName {\n return name === '2col' || name === '3col'\n },\n\n isLeafDirectiveName(name: string): boolean {\n return leafDirectiveNames.includes(name)\n },\n\n isSupportedDirectiveName,\n\n leafDirectiveNames,\n\n parseMarkdownLine,\n\n parseMarkdownLineDetailed,\n}\n\nexport type { GridDirectiveName, LayoutName, LayoutToken, MarkdownDirectiveName }\n"],"names":["normalizePayloadMarkdownIconRef","getUnknownAttributeWarnings","parseDirectiveLine","badgeDirective","badgesDirective","buttonDirective","buttonsDirective","calloutDirective","cardDirective","cardsDirective","cellDirective","columnDirectives","detailsDirective","sectionDirective","stepsDirective","tabDirective","tabsDirective","tocDirective","directiveDefinitions","closeMarkers","Map","type","action","cloneToken","token","isLayoutName","name","Boolean","find","definition","openMarker","getDirectiveDefinition","leafDirectiveNames","filter","map","isSupportedDirectiveName","some","getPublicDefinitions","public","DIRECTIVE_LABEL_ATTRIBUTES","getLabelConflictDiagnostics","label","attributes","labelAttribute","get","normalizedLabel","trim","attributeTitle","getUnexpectedTextDiagnostic","marker","text","preview","length","slice","parseMarkdownLineDetailed","trimmed","closeToken","diagnostics","parsed","startsWith","unexpectedText","supportsAttributes","rawAttributes","exactMatch","attributedMatch","warnings","allowedAttributes","icon","warning","validateAttributes","parseMarkdownLine","layoutDirectiveRegistry","all","getCloseLabel","isGridName","isLeafDirectiveName","includes"],"mappings":"AAQA,SAASA,+BAA+B,QAAQ,mBAAkB;AAClE,SAASC,2BAA2B,QAAQ,4BAA2B;AACvE,SAASC,kBAAkB,QAAQ,kBAAiB;AACpD,SAASC,cAAc,QAAQ,yBAAwB;AACvD,SAASC,eAAe,QAAQ,0BAAyB;AACzD,SAASC,eAAe,QAAQ,0BAAyB;AACzD,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,aAAa,QAAQ,wBAAuB;AACrD,SAASC,cAAc,QAAQ,yBAAwB;AACvD,SAASC,aAAa,QAAQ,wBAAuB;AACrD,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,cAAc,QAAQ,yBAAwB;AACvD,SAASC,YAAY,QAAQ,uBAAsB;AACnD,SAASC,aAAa,QAAQ,wBAAuB;AACrD,SAASC,YAAY,QAAQ,uBAAsB;AAEnD,MAAMC,uBAAuB;IAC3BL;OACGF;IACHD;IACAL;IACAC;IACAH;IACAC;IACAG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ACT;IAED,MAAMlB,QAAqB;QACzBE,MAAMgC,OAAOhC,IAAI;QACjBL,MAAM;QACNC,QAAQ;QACRoB,YAAYgB,OAAOhB,UAAU;QAC7BD,OAAOiB,OAAOjB,KAAK;IACrB;IAEA,OAAO;QACLgB;QACAjC;IACF;AACF;AAEA,SAAS8C,kBAAkBpB,IAAY;IACrC,OAAOI,0BAA0BJ,MAAM1B,KAAK;AAC9C;AAEA,OAAO,MAAM+C,0BAA0B;IACrCC,KAAKtD;IAEL,6DAA6D,GAC7DC,cAAc;WAAIA;KAAa,CAACe,GAAG,CAAC,CAAC,CAACe,QAAQzB,MAAM,GAAM,CAAA;YAAEF,QAAQE,MAAMF,MAAM;YAAE2B;QAAO,CAAA;IAEzFL,KAAKb;IAEL,gFAAgF,GAChF0C,eAAc/C,IAAY;QACxB,OAAOA,SAAS,UAAUA,SAAS,SAAS,WAAW,CAAC,GAAG,EAAEA,MAAM;IACrE;IAEAW;IAEAqC,YAAWhD,IAAwB;QACjC,OAAOA,SAAS,UAAUA,SAAS;IACrC;IAEAiD,qBAAoBjD,IAAY;QAC9B,OAAOM,mBAAmB4C,QAAQ,CAAClD;IACrC;IAEAS;IAEAH;IAEAsC;IAEAhB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/directives/registry.ts"],"sourcesContent":["import type {\n DirectiveCloseMarker,\n GridDirectiveName,\n LayoutDirectiveDefinition,\n LayoutName,\n LayoutToken,\n MarkdownDirectiveName,\n} from './types.js'\n\nimport { normalizePayloadMarkdownIconRef } from '../icons/refs.js'\nimport { getUnknownAttributeWarnings } from './attributeDiagnostics.js'\nimport { parseDirectiveLine } from './attributes.js'\nimport { badgeDirective } from './definitions/badge.js'\nimport { badgesDirective } from './definitions/badges.js'\nimport { buttonDirective } from './definitions/button.js'\nimport { buttonsDirective } from './definitions/buttons.js'\nimport { calloutDirective } from './definitions/callout.js'\nimport { cardDirective } from './definitions/card.js'\nimport { cardsDirective } from './definitions/cards.js'\nimport { cellDirective } from './definitions/cell.js'\nimport { columnDirectives } from './definitions/columns.js'\nimport { detailsDirective } from './definitions/details.js'\nimport { sectionDirective } from './definitions/section.js'\nimport { stepsDirective } from './definitions/steps.js'\nimport { tabDirective } from './definitions/tab.js'\nimport { tabsDirective } from './definitions/tabs.js'\nimport { tocDirective } from './definitions/toc.js'\n\n/**\n * Every directive, in registry order (the order of the spec, the editor\n * completions and the leaf diagnostics). A directive is one definition file\n * under definitions/ plus an entry here; names, kinds, the sanitize\n * allowlist, the spec and the leaf pipeline are derived from the definitions.\n */\nexport const directiveDefinitions = [\n sectionDirective,\n ...columnDirectives,\n cellDirective,\n buttonDirective,\n buttonsDirective,\n badgeDirective,\n badgesDirective,\n calloutDirective,\n detailsDirective,\n tocDirective,\n stepsDirective,\n cardsDirective,\n cardDirective,\n tabsDirective,\n tabDirective,\n] as const satisfies readonly LayoutDirectiveDefinition[]\n\nconst definitionsByName = new Map<string, LayoutDirectiveDefinition>(\n directiveDefinitions.map((definition) => [definition.name, definition]),\n)\n\n/**\n * Close markers and the layout action each produces (the directive grammar;\n * a container lists the ones that close it in `container.closeMarkers`).\n */\nconst closeMarkers = new Map<DirectiveCloseMarker, LayoutToken>([\n [':::', { type: 'vlLayoutToken', action: 'close' }],\n [':::end', { type: 'vlLayoutToken', action: 'closeSection' }],\n [':::endcol', { type: 'vlLayoutToken', action: 'closeGrid' }],\n [':::endsection', { type: 'vlLayoutToken', action: 'closeSection' }],\n])\n\nconst DEFAULT_CLOSE_MARKERS: readonly DirectiveCloseMarker[] = [':::']\n\nfunction cloneToken(token: LayoutToken): LayoutToken {\n return { ...token }\n}\n\ntype ParseMarkdownLineResult = {\n diagnostics: string[]\n token: LayoutToken | null\n}\n\nfunction getDirectiveDefinition(name: string): LayoutDirectiveDefinition | undefined {\n return definitionsByName.get(name)\n}\n\nfunction isSupportedDirectiveName(name: string): name is MarkdownDirectiveName {\n return definitionsByName.has(name)\n}\n\n/** Directives with a container form (`:::name…`). */\nfunction isContainerName(name: MarkdownDirectiveName): name is LayoutName {\n return Boolean(getDirectiveDefinition(name)?.container)\n}\n\n/** Leaf directives (`::name[label]{…}`): definitions with a leaf form. */\nconst leafDirectiveNames: readonly string[] = directiveDefinitions\n .filter((definition) => 'leaf' in definition && definition.leaf)\n .map((definition) => definition.name)\n\nconst gridDirectiveNames: readonly string[] = directiveDefinitions\n .filter((definition) => definition.kind === 'grid')\n .map((definition) => definition.name)\n\nfunction getPublicDefinitions(): LayoutDirectiveDefinition[] {\n return directiveDefinitions.filter((definition) => definition.public)\n}\n\n/** Opening marker of a definition's primary form: `:::name` (container) or `::name` (leaf). */\nfunction getOpenMarker(definition: LayoutDirectiveDefinition): string {\n return definition.container ? `:::${definition.name}` : `::${definition.name}`\n}\n\n/** Markers that close a container directive; empty for leaf-only directives. */\nfunction getDefinitionCloseMarkers(definition: LayoutDirectiveDefinition): readonly DirectiveCloseMarker[] {\n if (!definition.container) return []\n\n return definition.container.closeMarkers ?? DEFAULT_CLOSE_MARKERS\n}\n\n/**\n * Whether the directive's element carries the `data-vl-layout` marker that\n * runs its `applyHast` after sanitizing: every container, and leaves that\n * ask for it (`leaf.marker`).\n */\nfunction receivesLayoutMarker(definition: LayoutDirectiveDefinition, form: 'container' | 'leaf'): boolean {\n return form === 'container' ? Boolean(definition.container) : Boolean(definition.leaf?.marker)\n}\n\nfunction getLabelConflictDiagnostics(\n definition: LayoutDirectiveDefinition,\n label: string | undefined,\n attributes: Record<string, boolean | string>,\n): string[] {\n const labelAttribute = definition.container?.labelAttribute\n if (!labelAttribute) return []\n\n const normalizedLabel = label?.trim()\n const attributeTitle = attributes[labelAttribute]\n if (!normalizedLabel || typeof attributeTitle !== 'string' || !attributeTitle.trim()) return []\n if (normalizedLabel === attributeTitle.trim()) return []\n\n return [\n `Directive has both [Label] and ${labelAttribute}. [Label] is preferred; remove one to avoid ambiguity.`,\n ]\n}\n\nexport function getUnexpectedTextDiagnostic(marker: string, text: string): string {\n const preview = text.length > 40 ? `${text.slice(0, 40)}…` : text\n\n return `Unexpected text \"${preview}\" after \"${marker}\". Directive attributes must be wrapped in {…}; the line is rendered as text.`\n}\n\nfunction parseMarkdownLineDetailed(text: string): ParseMarkdownLineResult {\n const trimmed = text.trim()\n const closeToken = closeMarkers.get(trimmed as DirectiveCloseMarker)\n\n if (closeToken)\n return {\n diagnostics: [],\n token: cloneToken(closeToken),\n }\n\n const parsed = parseDirectiveLine(trimmed)\n if (!parsed)\n return {\n diagnostics: trimmed.startsWith(':::')\n ? ['Malformed directive marker.']\n : [],\n token: null,\n }\n\n if (!isSupportedDirectiveName(parsed.name))\n return {\n diagnostics: [`Unknown directive \"${parsed.name}\".`],\n token: null,\n }\n\n if (parsed.unexpectedText)\n return {\n diagnostics: [getUnexpectedTextDiagnostic(`:::${parsed.name}`, parsed.unexpectedText)],\n token: null,\n }\n\n if (!isContainerName(parsed.name))\n return {\n diagnostics: [],\n token: null,\n }\n\n const definition = getDirectiveDefinition(parsed.name)\n if (!definition?.container)\n return {\n diagnostics: [],\n token: null,\n }\n\n if (!definition.supportsAttributes && parsed.rawAttributes)\n return {\n diagnostics: [`Directive \"${parsed.name}\" does not support attributes.`],\n token: null,\n }\n\n const openMarker = getOpenMarker(definition)\n const exactMatch = openMarker === trimmed\n const attributedMatch =\n definition.supportsAttributes &&\n (trimmed.startsWith(`${openMarker} `) ||\n trimmed.startsWith(`${openMarker}[`) ||\n trimmed.startsWith(`${openMarker}{`))\n\n if (!exactMatch && !attributedMatch)\n return {\n diagnostics: [],\n token: null,\n }\n\n const diagnostics = [\n ...parsed.warnings,\n ...getUnknownAttributeWarnings(parsed.name, definition.allowedAttributes, parsed.attributes),\n ...getLabelConflictDiagnostics(definition, parsed.label, parsed.attributes),\n ...(typeof parsed.attributes.icon === 'string'\n ? [normalizePayloadMarkdownIconRef(parsed.attributes.icon).warning].filter(\n (warning): warning is string => Boolean(warning),\n )\n : []),\n ...(definition.validateAttributes?.({\n name: parsed.name,\n attributes: parsed.attributes,\n }) ?? []),\n ]\n\n const token: LayoutToken = {\n name: parsed.name,\n type: 'vlLayoutToken',\n action: 'open',\n attributes: parsed.attributes,\n label: parsed.label,\n }\n\n return {\n diagnostics,\n token,\n }\n}\n\nfunction parseMarkdownLine(text: string): LayoutToken | null {\n return parseMarkdownLineDetailed(text).token\n}\n\nexport const layoutDirectiveRegistry = {\n all: directiveDefinitions,\n\n /** Close markers and the layout token action each produces. */\n closeMarkers: [...closeMarkers].map(([marker, token]) => ({ action: token.action, marker })),\n\n get: getDirectiveDefinition,\n\n /** Editor close-label text for a container directive (`endcard`, `endcol`, …). */\n getCloseLabel(name: string): string {\n return getDirectiveDefinition(name)?.container?.closeLabel ?? `end${name}`\n },\n\n getCloseMarkers: getDefinitionCloseMarkers,\n\n getOpenMarker,\n\n getPublicDefinitions,\n\n isGridName(name: string | undefined): name is GridDirectiveName {\n return name !== undefined && gridDirectiveNames.includes(name)\n },\n\n isLeafDirectiveName(name: string): boolean {\n return leafDirectiveNames.includes(name)\n },\n\n isSupportedDirectiveName,\n\n leafDirectiveNames,\n\n parseMarkdownLine,\n\n parseMarkdownLineDetailed,\n\n receivesLayoutMarker,\n}\n\nexport type { GridDirectiveName, LayoutName, LayoutToken, MarkdownDirectiveName }\n"],"names":["normalizePayloadMarkdownIconRef","getUnknownAttributeWarnings","parseDirectiveLine","badgeDirective","badgesDirective","buttonDirective","buttonsDirective","calloutDirective","cardDirective","cardsDirective","cellDirective","columnDirectives","detailsDirective","sectionDirective","stepsDirective","tabDirective","tabsDirective","tocDirective","directiveDefinitions","definitionsByName","Map","map","definition","name","closeMarkers","type","action","DEFAULT_CLOSE_MARKERS","cloneToken","token","getDirectiveDefinition","get","isSupportedDirectiveName","has","isContainerName","Boolean","container","leafDirectiveNames","filter","leaf","gridDirectiveNames","kind","getPublicDefinitions","public","getOpenMarker","getDefinitionCloseMarkers","receivesLayoutMarker","form","marker","getLabelConflictDiagnostics","label","attributes","labelAttribute","normalizedLabel","trim","attributeTitle","getUnexpectedTextDiagnostic","text","preview","length","slice","parseMarkdownLineDetailed","trimmed","closeToken","diagnostics","parsed","startsWith","unexpectedText","supportsAttributes","rawAttributes","openMarker","exactMatch","attributedMatch","warnings","allowedAttributes","icon","warning","validateAttributes","parseMarkdownLine","layoutDirectiveRegistry","all","getCloseLabel","closeLabel","getCloseMarkers","isGridName","undefined","includes","isLeafDirectiveName"],"mappings":"AASA,SAASA,+BAA+B,QAAQ,mBAAkB;AAClE,SAASC,2BAA2B,QAAQ,4BAA2B;AACvE,SAASC,kBAAkB,QAAQ,kBAAiB;AACpD,SAASC,cAAc,QAAQ,yBAAwB;AACvD,SAASC,eAAe,QAAQ,0BAAyB;AACzD,SAASC,eAAe,QAAQ,0BAAyB;AACzD,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,aAAa,QAAQ,wBAAuB;AACrD,SAASC,cAAc,QAAQ,yBAAwB;AACvD,SAASC,aAAa,QAAQ,wBAAuB;AACrD,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,cAAc,QAAQ,yBAAwB;AACvD,SAASC,YAAY,QAAQ,uBAAsB;AACnD,SAASC,aAAa,QAAQ,wBAAuB;AACrD,SAASC,YAAY,QAAQ,uBAAsB;AAEnD;;;;;CAKC,GACD,OAAO,MAAMC,uBAAuB;IAClCL;OACGF;IACHD;IACAL;IACAC;IACAH;IACAC;IACAG;IACAK;IACAK;IACAH;IACAL;IACAD;IACAQ;IACAD;CACD,CAAwD;AAEzD,MAAMI,oBAAoB,IAAIC,IAC5BF,qBAAqBG,GAAG,CAAC,CAACC,aAAe;QAACA,WAAWC,IAAI;QAAED;KAAW;AAGxE;;;CAGC,GACD,MAAME,eAAe,IAAIJ,IAAuC;IAC9D;QAAC;QAAO;YAAEK,MAAM;YAAiBC,QAAQ;QAAQ;KAAE;IACnD;QAA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