payload-markdown 1.8.1 → 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 (94) hide show
  1. package/dist/core/plugins/remarkCompileLayouts.js.map +1 -1
  2. package/dist/core/plugins/remarkDirectiveLines.d.ts +7 -5
  3. package/dist/core/plugins/remarkDirectiveLines.js +29 -18
  4. package/dist/core/plugins/remarkDirectiveLines.js.map +1 -1
  5. package/dist/core/plugins/remarkLayoutDirectives.js +1 -1
  6. package/dist/core/plugins/remarkLayoutDirectives.js.map +1 -1
  7. package/dist/core/plugins/remarkValidateDirectiveThemes.js +7 -14
  8. package/dist/core/plugins/remarkValidateDirectiveThemes.js.map +1 -1
  9. package/dist/core/renderMarkdown.js +2 -231
  10. package/dist/core/renderMarkdown.js.map +1 -1
  11. package/dist/core/sanitizeSchema.d.ts +11 -0
  12. package/dist/core/sanitizeSchema.js +176 -0
  13. package/dist/core/sanitizeSchema.js.map +1 -0
  14. package/dist/directives/definitions/badge.d.ts +5 -2
  15. package/dist/directives/definitions/badge.js +138 -10
  16. package/dist/directives/definitions/badge.js.map +1 -1
  17. package/dist/directives/definitions/badges.d.ts +1 -2
  18. package/dist/directives/definitions/badges.js +12 -3
  19. package/dist/directives/definitions/badges.js.map +1 -1
  20. package/dist/directives/definitions/button.d.ts +6 -2
  21. package/dist/directives/definitions/button.js +202 -12
  22. package/dist/directives/definitions/button.js.map +1 -1
  23. package/dist/directives/definitions/buttons.d.ts +1 -2
  24. package/dist/directives/definitions/buttons.js +12 -3
  25. package/dist/directives/definitions/buttons.js.map +1 -1
  26. package/dist/directives/definitions/callout.d.ts +1 -2
  27. package/dist/directives/definitions/callout.js +37 -3
  28. package/dist/directives/definitions/callout.js.map +1 -1
  29. package/dist/directives/definitions/card.d.ts +6 -2
  30. package/dist/directives/definitions/card.js +51 -3
  31. package/dist/directives/definitions/card.js.map +1 -1
  32. package/dist/directives/definitions/cards.d.ts +1 -2
  33. package/dist/directives/definitions/cards.js +40 -4
  34. package/dist/directives/definitions/cards.js.map +1 -1
  35. package/dist/directives/definitions/cell.d.ts +2 -2
  36. package/dist/directives/definitions/cell.js +9 -3
  37. package/dist/directives/definitions/cell.js.map +1 -1
  38. package/dist/directives/definitions/columns.d.ts +3 -4
  39. package/dist/directives/definitions/columns.js +17 -3
  40. package/dist/directives/definitions/columns.js.map +1 -1
  41. package/dist/directives/definitions/details.d.ts +1 -2
  42. package/dist/directives/definitions/details.js +24 -3
  43. package/dist/directives/definitions/details.js.map +1 -1
  44. package/dist/directives/definitions/section.d.ts +1 -2
  45. package/dist/directives/definitions/section.js +22 -3
  46. package/dist/directives/definitions/section.js.map +1 -1
  47. package/dist/directives/definitions/steps.d.ts +1 -2
  48. package/dist/directives/definitions/steps.js +22 -3
  49. package/dist/directives/definitions/steps.js.map +1 -1
  50. package/dist/directives/definitions/tab.d.ts +8 -2
  51. package/dist/directives/definitions/tab.js +45 -3
  52. package/dist/directives/definitions/tab.js.map +1 -1
  53. package/dist/directives/definitions/tabs.d.ts +1 -1
  54. package/dist/directives/definitions/tabs.js +40 -3
  55. package/dist/directives/definitions/tabs.js.map +1 -1
  56. package/dist/directives/definitions/toc.d.ts +1 -2
  57. package/dist/directives/definitions/toc.js +32 -4
  58. package/dist/directives/definitions/toc.js.map +1 -1
  59. package/dist/directives/diagnostics.d.ts +2 -15
  60. package/dist/directives/diagnostics.js +27 -157
  61. package/dist/directives/diagnostics.js.map +1 -1
  62. package/dist/directives/lint.d.ts +11 -0
  63. package/dist/directives/lint.js +33 -0
  64. package/dist/directives/lint.js.map +1 -0
  65. package/dist/directives/registry.d.ts +23 -5
  66. package/dist/directives/registry.js +52 -40
  67. package/dist/directives/registry.js.map +1 -1
  68. package/dist/directives/spec.js +25 -51
  69. package/dist/directives/spec.js.map +1 -1
  70. package/dist/directives/themeDiagnostics.d.ts +8 -0
  71. package/dist/directives/themeDiagnostics.js +21 -0
  72. package/dist/directives/themeDiagnostics.js.map +1 -0
  73. package/dist/directives/types.d.ts +157 -14
  74. package/dist/directives/types.js +6 -1
  75. package/dist/directives/types.js.map +1 -1
  76. package/dist/editor/directives/completions.js +11 -4
  77. package/dist/editor/directives/completions.js.map +1 -1
  78. package/dist/editor/themes/payload.js +2 -1
  79. package/dist/editor/themes/payload.js.map +1 -1
  80. package/dist/version.d.ts +1 -1
  81. package/dist/version.js +1 -1
  82. package/dist/version.js.map +1 -1
  83. package/package.json +1 -1
  84. package/skills/payload-markdown/claude/skill.json +1 -1
  85. package/skills/payload-markdown/codex/skill.json +1 -1
  86. package/dist/core/plugins/directiveBadge.d.ts +0 -6
  87. package/dist/core/plugins/directiveBadge.js +0 -94
  88. package/dist/core/plugins/directiveBadge.js.map +0 -1
  89. package/dist/core/plugins/directiveButton.d.ts +0 -6
  90. package/dist/core/plugins/directiveButton.js +0 -132
  91. package/dist/core/plugins/directiveButton.js.map +0 -1
  92. package/dist/directives/buttonSyntax.d.ts +0 -7
  93. package/dist/directives/buttonSyntax.js +0 -6
  94. package/dist/directives/buttonSyntax.js.map +0 -1
@@ -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"}
@@ -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;IACAK;IACAK;IACAH;IACAL;IACAD;IACAQ;IACAD;CACD;AAED,MAAMI,eAAe,IAAIC,IAAyB;IAChD;QAAC;QAAO;YAAEC,MAAM;YAAiBC,QAAQ;QAAQ;KAAE;IACnD;QAAC;QAAU;YAAED,MAAM;YAAiBC,QAAQ;QAAe;KAAE;IAC7D;QAAC;QAAa;YAAED,MAAM;YAAiBC,QAAQ;QAAY;KAAE;IAC7D;QAAC;QAAiB;YAAED,MAAM;YAAiBC,QAAQ;QAAe;KAAE;CACrE;AAED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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,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ACrC,OAAOI,0BAA0BJ,MAAM5B,KAAK;AAC9C;AAEA,OAAO,MAAMkD,0BAA0B;IACrCC,KAAK9D;IAEL,6DAA6D,GAC7DM,cAAc;WAAIA;KAAa,CAACH,GAAG,CAAC,CAAC,CAAC2B,QAAQnB,MAAM,GAAM,CAAA;YAAEH,QAAQG,MAAMH,MAAM;YAAEsB;QAAO,CAAA;IAEzFjB,KAAKD;IAEL,gFAAgF,GAChFmD,eAAc1D,IAAY;QACxB,OAAOO,uBAAuBP,OAAOa,WAAW8C,cAAc,CAAC,GAAG,EAAE3D,MAAM;IAC5E;IAEA4D,iBAAiBtC;IAEjBD;IAEAF;IAEA0C,YAAW7D,IAAwB;QACjC,OAAOA,SAAS8D,aAAa7C,mBAAmB8C,QAAQ,CAAC/D;IAC3D;IAEAgE,qBAAoBhE,IAAY;QAC9B,OAAOc,mBAAmBiD,QAAQ,CAAC/D;IACrC;IAEAS;IAEAK;IAEAyC;IAEAjB;IAEAf;AACF,EAAC"}
@@ -1,40 +1,22 @@
1
- import { CALLOUT_VARIANTS } from './definitions/callout.js';
2
1
  import { slugTabValue } from './definitions/tab.js';
3
2
  import { slugifyHeading } from './headingAnchors.js';
4
- import { DIRECTIVE_LABEL_ATTRIBUTES, layoutDirectiveRegistry } from './registry.js';
3
+ import { layoutDirectiveRegistry } from './registry.js';
5
4
  import { SHIELDS_BADGE_ORIGIN, SHIELDS_BADGE_QUERY_ATTRIBUTES, SHIELDS_BADGE_REQUIRED_ATTRIBUTES, SHIELDS_BADGE_TARGETS } from './shields.js';
6
5
  import { DEFAULT_DIRECTIVE_THEMES, getDirectiveFallbackThemeName } from './themes.js';
7
6
  /**
8
7
  * Version of the spec's JSON shape. Bump it on incompatible shape changes;
9
8
  * adding directives, attributes or values does not change it.
10
9
  */ export const DIRECTIVE_SPEC_VERSION = 1;
11
- const URL_ATTRIBUTES = new Set([
12
- 'href',
13
- 'src'
14
- ]);
15
- const BOOLEAN_ATTRIBUTES = new Set([
16
- 'disabled',
17
- 'open'
18
- ]);
19
- const NUMBER_ATTRIBUTES = {
20
- cacheSeconds: {
21
- min: 0
22
- },
23
- depth: {
24
- max: 6,
25
- min: 1
26
- }
27
- };
28
- /** Enumerations the definitions validate in code rather than through `attributeValues`. */ const EXTRA_ENUMS = {
29
- callout: {
30
- variant: CALLOUT_VARIANTS
31
- }
32
- };
33
10
  function isBooleanValues(values) {
34
11
  return Boolean(values && values.length === 2 && values.includes('true') && values.includes('false'));
35
12
  }
36
- function describeAttribute(definition, name) {
37
- const values = definition.attributeValues?.[name] ?? EXTRA_ENUMS[definition.name]?.[name];
13
+ /**
14
+ * An attribute's spec entry, from the definition alone: `themeAttributes`
15
+ * (theme names), `attributeTypes` (declared types), `attributeValues` (enums,
16
+ * or booleans when the values are exactly true/false), else a string.
17
+ */ function describeAttribute(definition, name) {
18
+ const declared = definition.attributeTypes?.[name];
19
+ const values = definition.attributeValues?.[name] ?? (declared?.type === 'enum' ? declared.values : undefined);
38
20
  const themeGroup = definition.themeAttributes?.[name];
39
21
  const defaultValue = definition.defaultAttributes?.[name];
40
22
  const base = {
@@ -48,11 +30,11 @@ function describeAttribute(definition, name) {
48
30
  type: 'string',
49
31
  themeGroup
50
32
  };
51
- if (URL_ATTRIBUTES.has(name)) return {
33
+ if (declared?.type === 'url') return {
52
34
  ...base,
53
35
  type: 'url'
54
36
  };
55
- if (BOOLEAN_ATTRIBUTES.has(name) || isBooleanValues(values)) return {
37
+ if (declared?.type === 'boolean' || isBooleanValues(values)) return {
56
38
  ...base,
57
39
  type: 'boolean',
58
40
  values: [
@@ -60,9 +42,14 @@ function describeAttribute(definition, name) {
60
42
  'false'
61
43
  ]
62
44
  };
63
- if (NUMBER_ATTRIBUTES[name]) return {
45
+ if (declared?.type === 'number') return {
64
46
  ...base,
65
- ...NUMBER_ATTRIBUTES[name],
47
+ ...declared.max !== undefined ? {
48
+ max: declared.max
49
+ } : {},
50
+ ...declared.min !== undefined ? {
51
+ min: declared.min
52
+ } : {},
66
53
  type: 'number'
67
54
  };
68
55
  if (values) return {
@@ -72,12 +59,12 @@ function describeAttribute(definition, name) {
72
59
  ...values
73
60
  ]
74
61
  };
75
- if (name === 'icon') return {
62
+ if (declared?.type === 'icon') return {
76
63
  ...base,
77
64
  type: 'string',
78
65
  format: 'icon'
79
66
  };
80
- if (name === 'palette' || name === 'iconPalette') return {
67
+ if (declared?.type === 'palette') return {
81
68
  ...base,
82
69
  type: 'string',
83
70
  format: 'palette'
@@ -87,24 +74,9 @@ function describeAttribute(definition, name) {
87
74
  type: 'string'
88
75
  };
89
76
  }
90
- function getCloseMarkers(definition) {
91
- if (!definition.openMarker) return [];
92
- if (layoutDirectiveRegistry.isGridName(definition.name)) return [
93
- ':::',
94
- ':::endcol'
95
- ];
96
- if (definition.name === 'section') return [
97
- ':::',
98
- ':::end',
99
- ':::endsection'
100
- ];
101
- return [
102
- ':::'
103
- ];
104
- }
105
77
  function describeDirective(definition) {
106
- const container = Boolean(definition.openMarker);
107
- const labelAttribute = DIRECTIVE_LABEL_ATTRIBUTES.get(definition.name);
78
+ const container = Boolean(definition.container);
79
+ const labelAttribute = definition.container?.labelAttribute;
108
80
  return {
109
81
  name: definition.name,
110
82
  attributes: [
@@ -113,7 +85,9 @@ function describeDirective(definition) {
113
85
  ...container ? {
114
86
  closeLabel: layoutDirectiveRegistry.getCloseLabel(definition.name)
115
87
  } : {},
116
- closeMarkers: getCloseMarkers(definition),
88
+ closeMarkers: [
89
+ ...layoutDirectiveRegistry.getCloseMarkers(definition)
90
+ ],
117
91
  ...definition.description ? {
118
92
  description: definition.description
119
93
  } : {},
@@ -121,7 +95,7 @@ function describeDirective(definition) {
121
95
  ...labelAttribute ? {
122
96
  labelAttribute
123
97
  } : {},
124
- open: definition.openMarker ?? `::${definition.name}`,
98
+ open: layoutDirectiveRegistry.getOpenMarker(definition),
125
99
  supportsAttributes: Boolean(definition.supportsAttributes)
126
100
  };
127
101
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/directives/spec.ts"],"sourcesContent":["import type { DirectiveThemeGroupName } from './themes.js'\nimport type { LayoutDirectiveDefinition } from './types.js'\n\nimport { CALLOUT_VARIANTS } from './definitions/callout.js'\nimport { slugTabValue } from './definitions/tab.js'\nimport { slugifyHeading } from './headingAnchors.js'\nimport { DIRECTIVE_LABEL_ATTRIBUTES, layoutDirectiveRegistry } from './registry.js'\nimport {\n SHIELDS_BADGE_ORIGIN,\n SHIELDS_BADGE_QUERY_ATTRIBUTES,\n SHIELDS_BADGE_REQUIRED_ATTRIBUTES,\n SHIELDS_BADGE_TARGETS,\n} from './shields.js'\nimport { DEFAULT_DIRECTIVE_THEMES, getDirectiveFallbackThemeName } from './themes.js'\n\n/**\n * Version of the spec's JSON shape. Bump it on incompatible shape changes;\n * adding directives, attributes or values does not change it.\n */\nexport const DIRECTIVE_SPEC_VERSION = 1\n\nexport type DirectiveAttributeType = 'boolean' | 'enum' | 'number' | 'string' | 'url'\n\nexport type DirectiveSpecAttribute = {\n default?: string\n /**\n * Value format hint for `string` attributes. `icon`: one `@pack/name` icon\n * ref, or a comma-separated list where each entry may add `palette=<name>`.\n * `palette`: a palette name (built-in, configured, or managed in the admin).\n */\n format?: 'icon' | 'palette'\n max?: number\n min?: number\n name: string\n /** Theme group whose names are valid (built-in themes plus configured ones). */\n themeGroup?: DirectiveThemeGroupName\n type: DirectiveAttributeType\n /** Allowed values of `enum` attributes; the literals of `boolean` attributes. */\n values?: string[]\n}\n\nexport type DirectiveSpecDirective = {\n attributes: DirectiveSpecAttribute[]\n /** Close-label text the editor shows after a generic `:::` closer. */\n closeLabel?: string\n /** Markers that close this directive; empty for leaf directives. */\n closeMarkers: string[]\n description?: string\n kind: 'container' | 'leaf'\n /** Attribute that `[label]` stands for, if any. */\n labelAttribute?: string\n name: string\n /** Opening marker: `:::name` (container) or `::name` (leaf). */\n open: string\n supportsAttributes: boolean\n}\n\nexport type DirectiveSpec = {\n badges: {\n intervals: string[]\n origin: string\n queryAttributes: string[]\n requiredAttributes: Record<string, string[]>\n styles: string[]\n targets: Record<string, string[]>\n types: string[]\n }\n closeMarkers: Array<{ closes: 'grid' | 'innermost' | 'section'; marker: string }>\n constraints: string[]\n directives: DirectiveSpecDirective[]\n headings: { examples: Array<[string, string]>; slug: string[] }\n package: string\n specVersion: number\n tabs: { examples: Array<{ index: number; raw: string; value: string }>; value: string[] }\n themes: Record<string, { builtIn: string[]; fallback: string }>\n}\n\nconst URL_ATTRIBUTES = new Set(['href', 'src'])\nconst BOOLEAN_ATTRIBUTES = new Set(['disabled', 'open'])\nconst NUMBER_ATTRIBUTES: Record<string, { max?: number; min?: number }> = {\n cacheSeconds: { min: 0 },\n depth: { max: 6, min: 1 },\n}\n/** Enumerations the definitions validate in code rather than through `attributeValues`. */\nconst EXTRA_ENUMS: Record<string, Record<string, readonly string[]>> = {\n callout: { variant: CALLOUT_VARIANTS },\n}\n\nfunction isBooleanValues(values: readonly string[] | undefined): boolean {\n return Boolean(values && values.length === 2 && values.includes('true') && values.includes('false'))\n}\n\nfunction describeAttribute(\n definition: LayoutDirectiveDefinition,\n name: string,\n): DirectiveSpecAttribute {\n const values = definition.attributeValues?.[name] ?? EXTRA_ENUMS[definition.name]?.[name]\n const themeGroup = definition.themeAttributes?.[name]\n const defaultValue = definition.defaultAttributes?.[name]\n const base = {\n name,\n ...(defaultValue !== undefined ? { default: defaultValue } : {}),\n }\n\n if (themeGroup) return { ...base, type: 'string', themeGroup }\n if (URL_ATTRIBUTES.has(name)) return { ...base, type: 'url' }\n if (BOOLEAN_ATTRIBUTES.has(name) || isBooleanValues(values))\n return { ...base, type: 'boolean', values: ['true', 'false'] }\n if (NUMBER_ATTRIBUTES[name]) return { ...base, ...NUMBER_ATTRIBUTES[name], type: 'number' }\n if (values) return { ...base, type: 'enum', values: [...values] }\n if (name === 'icon') return { ...base, type: 'string', format: 'icon' }\n if (name === 'palette' || name === 'iconPalette') return { ...base, type: 'string', format: 'palette' }\n\n return { ...base, type: 'string' }\n}\n\nfunction getCloseMarkers(definition: LayoutDirectiveDefinition): string[] {\n if (!definition.openMarker) return []\n if (layoutDirectiveRegistry.isGridName(definition.name)) return [':::', ':::endcol']\n if (definition.name === 'section') return [':::', ':::end', ':::endsection']\n\n return [':::']\n}\n\nfunction describeDirective(definition: LayoutDirectiveDefinition): DirectiveSpecDirective {\n const container = Boolean(definition.openMarker)\n const labelAttribute = DIRECTIVE_LABEL_ATTRIBUTES.get(definition.name)\n\n return {\n name: definition.name,\n attributes: [...(definition.allowedAttributes ?? [])]\n .sort()\n .map((name) => describeAttribute(definition, name)),\n ...(container ? { closeLabel: layoutDirectiveRegistry.getCloseLabel(definition.name) } : {}),\n closeMarkers: getCloseMarkers(definition),\n ...(definition.description ? { description: definition.description } : {}),\n kind: container ? 'container' : 'leaf',\n ...(labelAttribute ? { labelAttribute } : {}),\n open: definition.openMarker ?? `::${definition.name}`,\n supportsAttributes: Boolean(definition.supportsAttributes),\n }\n}\n\nconst CLOSES = {\n close: 'innermost',\n closeGrid: 'grid',\n closeSection: 'section',\n} as const\n\nconst CONSTRAINTS = [\n 'Directive markers are recognised only at the start of a line of a top-level paragraph. Markers inside lists, blockquotes, tables or footnotes render as text and are reported.',\n 'The marker must start the source line as plain text: inline code, emphasis, links, a backslash escape (\\\\:::) or a character reference never open a directive.',\n 'Container syntax is :::name[label]{attributes}; leaf syntax is ::name[label]{attributes} on its own line.',\n 'Attributes are written inside {…} as key=\"value\", key=value, bare boolean keys, #id or .class; the block may span lines until the closing }.',\n 'Unbraced key=value attributes after the marker are accepted for compatibility; any other text after a container marker is reported and the line renders as text.',\n 'Quoted attribute values are literal except for CommonMark backslash escapes and character references, which are decoded.',\n 'A generic ::: closes the innermost open container; :::endcol closes the nearest grid (2col, 3col); :::end and :::endsection close the nearest section.',\n 'Opening a grid inside a section closes a grid that is already open in that section.',\n 'Inside a grid, a heading shallower than the heading before the grid closes the grid; headings one level deeper than that start a new cell.',\n 'Containers still open at the end of the document are closed automatically and reported.',\n 'Unknown attributes, unknown theme names and invalid enum values are reported; the renderer falls back to defaults.',\n 'Directive href attributes accept relative URLs and http, https, irc, ircs, mailto and xmpp URLs; other links are removed and reported.',\n]\n\nconst TAB_EXAMPLES: Array<[string, number]> = [\n ['Install', 0],\n ['npmInstall', 1],\n ['Hello, World!', 2],\n ['日本', 3],\n]\n\nconst HEADING_EXAMPLES = ['Getting Started', \"What's New?\", '日本語', 'API v2.0']\n\n/**\n * The directive language as data: names, kinds, markers, attributes and\n * their types, theme groups, badge resolver tables, tab-value and heading\n * slug semantics, and parser constraints. Generated from the registry; the\n * build writes it to `dist/directive-spec.json` and the skill reference\n * copies are checked against it.\n */\nexport function getDirectiveSpec(): DirectiveSpec {\n const badge = layoutDirectiveRegistry.get('badge')\n const themes = Object.fromEntries(\n (Object.keys(DEFAULT_DIRECTIVE_THEMES) as DirectiveThemeGroupName[]).sort().map((group) => [\n group,\n {\n builtIn: DEFAULT_DIRECTIVE_THEMES[group].map((theme) => theme.name),\n fallback: getDirectiveFallbackThemeName(group),\n },\n ]),\n )\n\n return {\n badges: {\n intervals: [...(badge?.attributeValues?.interval ?? [])],\n origin: SHIELDS_BADGE_ORIGIN,\n queryAttributes: [...SHIELDS_BADGE_QUERY_ATTRIBUTES],\n requiredAttributes: Object.fromEntries(\n Object.entries(SHIELDS_BADGE_REQUIRED_ATTRIBUTES).map(([type, names]) => [type, [...names]]),\n ),\n styles: [...(badge?.attributeValues?.style ?? [])],\n targets: Object.fromEntries(\n Object.entries(SHIELDS_BADGE_TARGETS).map(([type, targets]) => [type, [...targets]]),\n ),\n types: [...(badge?.attributeValues?.type ?? [])],\n },\n closeMarkers: layoutDirectiveRegistry.closeMarkers.map(({ action, marker }) => ({\n closes: CLOSES[action as keyof typeof CLOSES],\n marker,\n })),\n constraints: CONSTRAINTS,\n directives: layoutDirectiveRegistry.all.map((definition) => describeDirective(definition)),\n headings: {\n slug: [\n 'Lowercase; remove quotes; replace every run of characters other than a-z and 0-9 with \"-\"; trim \"-\"; an empty result becomes \"section\".',\n 'Repeated slugs get -1, -2, … suffixes, skipping ids already emitted in the document.',\n 'Only top-level headings and headings directly inside container directives get ids.',\n ],\n examples: HEADING_EXAMPLES.map((text) => [text, slugifyHeading(text)]),\n },\n package: '@valkyrianlabs/payload-markdown',\n specVersion: DIRECTIVE_SPEC_VERSION,\n tabs: {\n examples: TAB_EXAMPLES.map(([raw, index]) => ({ index, raw, value: slugTabValue(raw, index) })),\n value: [\n 'A tab value comes from the value attribute, else the [label], else the label attribute, else tab-N (N is the 1-based tab position).',\n 'It is slugged: split camelCase with \"-\", lowercase, replace runs of characters other than a-z and 0-9 with \"-\", trim \"-\". An empty slug becomes tab-N.',\n 'Repeated values in one tabs block get -1, -2, … suffixes.',\n 'tabs default=\"…\" matches a tab value (after slugging) first, then a raw value or label; otherwise the first enabled tab is active.',\n ],\n },\n themes,\n }\n}\n"],"names":["CALLOUT_VARIANTS","slugTabValue","slugifyHeading","DIRECTIVE_LABEL_ATTRIBUTES","layoutDirectiveRegistry","SHIELDS_BADGE_ORIGIN","SHIELDS_BADGE_QUERY_ATTRIBUTES","SHIELDS_BADGE_REQUIRED_ATTRIBUTES","SHIELDS_BADGE_TARGETS","DEFAULT_DIRECTIVE_THEMES","getDirectiveFallbackThemeName","DIRECTIVE_SPEC_VERSION","URL_ATTRIBUTES","Set","BOOLEAN_ATTRIBUTES","NUMBER_ATTRIBUTES","cacheSeconds","min","depth","max","EXTRA_ENUMS","callout","variant","isBooleanValues","values","Boolean","length","includes","describeAttribute","definition","name","attributeValues","themeGroup","themeAttributes","defaultValue","defaultAttributes","base","undefined","default","type","has","format","getCloseMarkers","openMarker","isGridName","describeDirective","container","labelAttribute","get","attributes","allowedAttributes","sort","map","closeLabel","getCloseLabel","closeMarkers","description","kind","open","supportsAttributes","CLOSES","close","closeGrid","closeSection","CONSTRAINTS","TAB_EXAMPLES","HEADING_EXAMPLES","getDirectiveSpec","badge","themes","Object","fromEntries","keys","group","builtIn","theme","fallback","badges","intervals","interval","origin","queryAttributes","requiredAttributes","entries","names","styles","style","targets","types","action","marker","closes","constraints","directives","all","headings","slug","examples","text","package","specVersion","tabs","raw","index","value"],"mappings":"AAGA,SAASA,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,YAAY,QAAQ,uBAAsB;AACnD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,0BAA0B,EAAEC,uBAAuB,QAAQ,gBAAe;AACnF,SACEC,oBAAoB,EACpBC,8BAA8B,EAC9BC,iCAAiC,EACjCC,qBAAqB,QAChB,eAAc;AACrB,SAASC,wBAAwB,EAAEC,6BAA6B,QAAQ,cAAa;AAErF;;;CAGC,GACD,OAAO,MAAMC,yBAAyB,EAAC;AA0DvC,MAAMC,iBAAiB,IAAIC,IAAI;IAAC;IAAQ;CAAM;AAC9C,MAAMC,qBAAqB,IAAID,IAAI;IAAC;IAAY;CAAO;AACvD,MAAME,oBAAoE;IACxEC,cAAc;QAAEC,KAAK;IAAE;IACvBC,OAAO;QAAEC,KAAK;QAAGF,KAAK;IAAE;AAC1B;AACA,yFAAyF,GACzF,MAAMG,cAAiE;IACrEC,SAAS;QAAEC,SAAStB;IAAiB;AACvC;AAEA,SAASuB,gBAAgBC,MAAqC;IAC5D,OAAOC,QAAQD,UAAUA,OAAOE,MAAM,KAAK,KAAKF,OAAOG,QAAQ,CAAC,WAAWH,OAAOG,QAAQ,CAAC;AAC7F;AAEA,SAASC,kBACPC,UAAqC,EACrCC,IAAY;IAEZ,MAAMN,SAASK,WAAWE,eAAe,EAAE,CAACD,KAAK,IAAIV,WAAW,CAACS,WAAWC,IAAI,CAAC,EAAE,CAACA,KAAK;IACzF,MAAME,aAAaH,WAAWI,eAAe,EAAE,CAACH,KAAK;IACrD,MAAMI,eAAeL,WAAWM,iBAAiB,EAAE,CAACL,KAAK;IACzD,MAAMM,OAAO;QACXN;QACA,GAAII,iBAAiBG,YAAY;YAAEC,SAASJ;QAAa,IAAI,CAAC,CAAC;IACjE;IAEA,IAAIF,YAA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;YACR4E,iBAAiB;mBAAI3E;aAA+B;YACpD4E,oBAAoBZ,OAAOC,WAAW,CACpCD,OAAOa,OAAO,CAAC5E,mCAAmC6C,GAAG,CAAC,CAAC,CAACb,MAAM6C,MAAM,GAAK;oBAAC7C;oBAAM;2BAAI6C;qBAAM;iBAAC;YAE7FC,QAAQ;mBAAKjB,OAAOrC,iBAAiBuD,SAAS,EAAE;aAAE;YAClDC,SAASjB,OAAOC,WAAW,CACzBD,OAAOa,OAAO,CAAC3E,uBAAuB4C,GAAG,CAAC,CAAC,CAACb,MAAMgD,QAAQ,GAAK;oBAAChD;oBAAM;2BAAIgD;qBAAQ;iBAAC;YAErFC,OAAO;mBAAKpB,OAAOrC,iBAAiBQ,QAAQ,EAAE;aAAE;QAClD;QACAgB,cAAcnD,wBAAwBmD,YAAY,CAACH,GAAG,CAAC,CAAC,EAAEqC,MAAM,EAAEC,MAAM,EAAE,GAAM,CAAA;gBAC9EC,QAAQ/B,MAAM,CAAC6B,OAA8B;gBAC7CC;YACF,CAAA;QACAE,aAAa5B;QACb6B,YAAYzF,wBAAwB0F,GAAG,CAAC1C,GAAG,CAAC,CAACvB,aAAegB,kBAAkBhB;QAC9EkE,UAAU;YACRC,MAAM;gBACJ;gBACA;gBACA;aACD;YACDC,UAAU/B,iBAAiBd,GAAG,CAAC,CAAC8C,OAAS;oBAACA;oBAAMhG,eAAegG;iBAAM;QACvE;QACAC,SAAS;QACTC,aAAazF;QACb0F,MAAM;YACJJ,UAAUhC,aAAab,GAAG,CAAC,CAAC,CAACkD,KAAKC,MAAM,GAAM,CAAA;oBAAEA;oBAAOD;oBAAKE,OAAOvG,aAAaqG,KAAKC;gBAAO,CAAA;YAC5FC,OAAO;gBACL;gBACA;gBACA;gBACA;aACD;QACH;QACAnC;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/directives/spec.ts"],"sourcesContent":["import type { DirectiveThemeGroupName } from './themes.js'\nimport type { LayoutDirectiveDefinition } from './types.js'\n\nimport { slugTabValue } from './definitions/tab.js'\nimport { slugifyHeading } from './headingAnchors.js'\nimport { layoutDirectiveRegistry } from './registry.js'\nimport {\n SHIELDS_BADGE_ORIGIN,\n SHIELDS_BADGE_QUERY_ATTRIBUTES,\n SHIELDS_BADGE_REQUIRED_ATTRIBUTES,\n SHIELDS_BADGE_TARGETS,\n} from './shields.js'\nimport { DEFAULT_DIRECTIVE_THEMES, getDirectiveFallbackThemeName } from './themes.js'\n\n/**\n * Version of the spec's JSON shape. Bump it on incompatible shape changes;\n * adding directives, attributes or values does not change it.\n */\nexport const DIRECTIVE_SPEC_VERSION = 1\n\nexport type DirectiveAttributeType = 'boolean' | 'enum' | 'number' | 'string' | 'url'\n\nexport type DirectiveSpecAttribute = {\n default?: string\n /**\n * Value format hint for `string` attributes. `icon`: one `@pack/name` icon\n * ref, or a comma-separated list where each entry may add `palette=<name>`.\n * `palette`: a palette name (built-in, configured, or managed in the admin).\n */\n format?: 'icon' | 'palette'\n max?: number\n min?: number\n name: string\n /** Theme group whose names are valid (built-in themes plus configured ones). */\n themeGroup?: DirectiveThemeGroupName\n type: DirectiveAttributeType\n /** Allowed values of `enum` attributes; the literals of `boolean` attributes. */\n values?: string[]\n}\n\nexport type DirectiveSpecDirective = {\n attributes: DirectiveSpecAttribute[]\n /** Close-label text the editor shows after a generic `:::` closer. */\n closeLabel?: string\n /** Markers that close this directive; empty for leaf directives. */\n closeMarkers: string[]\n description?: string\n kind: 'container' | 'leaf'\n /** Attribute that `[label]` stands for, if any. */\n labelAttribute?: string\n name: string\n /** Opening marker: `:::name` (container) or `::name` (leaf). */\n open: string\n supportsAttributes: boolean\n}\n\nexport type DirectiveSpec = {\n badges: {\n intervals: string[]\n origin: string\n queryAttributes: string[]\n requiredAttributes: Record<string, string[]>\n styles: string[]\n targets: Record<string, string[]>\n types: string[]\n }\n closeMarkers: Array<{ closes: 'grid' | 'innermost' | 'section'; marker: string }>\n constraints: string[]\n directives: DirectiveSpecDirective[]\n headings: { examples: Array<[string, string]>; slug: string[] }\n package: string\n specVersion: number\n tabs: { examples: Array<{ index: number; raw: string; value: string }>; value: string[] }\n themes: Record<string, { builtIn: string[]; fallback: string }>\n}\n\nfunction isBooleanValues(values: readonly string[] | undefined): boolean {\n return Boolean(values && values.length === 2 && values.includes('true') && values.includes('false'))\n}\n\n/**\n * An attribute's spec entry, from the definition alone: `themeAttributes`\n * (theme names), `attributeTypes` (declared types), `attributeValues` (enums,\n * or booleans when the values are exactly true/false), else a string.\n */\nfunction describeAttribute(\n definition: LayoutDirectiveDefinition,\n name: string,\n): DirectiveSpecAttribute {\n const declared = definition.attributeTypes?.[name]\n const values =\n definition.attributeValues?.[name] ?? (declared?.type === 'enum' ? declared.values : undefined)\n const themeGroup = definition.themeAttributes?.[name]\n const defaultValue = definition.defaultAttributes?.[name]\n const base = {\n name,\n ...(defaultValue !== undefined ? { default: defaultValue } : {}),\n }\n\n if (themeGroup) return { ...base, type: 'string', themeGroup }\n if (declared?.type === 'url') return { ...base, type: 'url' }\n if (declared?.type === 'boolean' || isBooleanValues(values))\n return { ...base, type: 'boolean', values: ['true', 'false'] }\n if (declared?.type === 'number')\n return {\n ...base,\n ...(declared.max !== undefined ? { max: declared.max } : {}),\n ...(declared.min !== undefined ? { min: declared.min } : {}),\n type: 'number',\n }\n if (values) return { ...base, type: 'enum', values: [...values] }\n if (declared?.type === 'icon') return { ...base, type: 'string', format: 'icon' }\n if (declared?.type === 'palette') return { ...base, type: 'string', format: 'palette' }\n\n return { ...base, type: 'string' }\n}\n\nfunction describeDirective(definition: LayoutDirectiveDefinition): DirectiveSpecDirective {\n const container = Boolean(definition.container)\n const labelAttribute = definition.container?.labelAttribute\n\n return {\n name: definition.name,\n attributes: [...(definition.allowedAttributes ?? [])]\n .sort()\n .map((name) => describeAttribute(definition, name)),\n ...(container ? { closeLabel: layoutDirectiveRegistry.getCloseLabel(definition.name) } : {}),\n closeMarkers: [...layoutDirectiveRegistry.getCloseMarkers(definition)],\n ...(definition.description ? { description: definition.description } : {}),\n kind: container ? 'container' : 'leaf',\n ...(labelAttribute ? { labelAttribute } : {}),\n open: layoutDirectiveRegistry.getOpenMarker(definition),\n supportsAttributes: Boolean(definition.supportsAttributes),\n }\n}\n\nconst CLOSES = {\n close: 'innermost',\n closeGrid: 'grid',\n closeSection: 'section',\n} as const\n\nconst CONSTRAINTS = [\n 'Directive markers are recognised only at the start of a line of a top-level paragraph. Markers inside lists, blockquotes, tables or footnotes render as text and are reported.',\n 'The marker must start the source line as plain text: inline code, emphasis, links, a backslash escape (\\\\:::) or a character reference never open a directive.',\n 'Container syntax is :::name[label]{attributes}; leaf syntax is ::name[label]{attributes} on its own line.',\n 'Attributes are written inside {…} as key=\"value\", key=value, bare boolean keys, #id or .class; the block may span lines until the closing }.',\n 'Unbraced key=value attributes after the marker are accepted for compatibility; any other text after a container marker is reported and the line renders as text.',\n 'Quoted attribute values are literal except for CommonMark backslash escapes and character references, which are decoded.',\n 'A generic ::: closes the innermost open container; :::endcol closes the nearest grid (2col, 3col); :::end and :::endsection close the nearest section.',\n 'Opening a grid inside a section closes a grid that is already open in that section.',\n 'Inside a grid, a heading shallower than the heading before the grid closes the grid; headings one level deeper than that start a new cell.',\n 'Containers still open at the end of the document are closed automatically and reported.',\n 'Unknown attributes, unknown theme names and invalid enum values are reported; the renderer falls back to defaults.',\n 'Directive href attributes accept relative URLs and http, https, irc, ircs, mailto and xmpp URLs; other links are removed and reported.',\n]\n\nconst TAB_EXAMPLES: Array<[string, number]> = [\n ['Install', 0],\n ['npmInstall', 1],\n ['Hello, World!', 2],\n ['日本', 3],\n]\n\nconst HEADING_EXAMPLES = ['Getting Started', \"What's New?\", '日本語', 'API v2.0']\n\n/**\n * The directive language as data: names, kinds, markers, attributes and\n * their types, theme groups, badge resolver tables, tab-value and heading\n * slug semantics, and parser constraints. Generated from the registry; the\n * build writes it to `dist/directive-spec.json` and the skill reference\n * copies are checked against it.\n */\nexport function getDirectiveSpec(): DirectiveSpec {\n const badge = layoutDirectiveRegistry.get('badge')\n const themes = Object.fromEntries(\n (Object.keys(DEFAULT_DIRECTIVE_THEMES) as DirectiveThemeGroupName[]).sort().map((group) => [\n group,\n {\n builtIn: DEFAULT_DIRECTIVE_THEMES[group].map((theme) => theme.name),\n fallback: getDirectiveFallbackThemeName(group),\n },\n ]),\n )\n\n return {\n badges: {\n intervals: [...(badge?.attributeValues?.interval ?? [])],\n origin: SHIELDS_BADGE_ORIGIN,\n queryAttributes: [...SHIELDS_BADGE_QUERY_ATTRIBUTES],\n requiredAttributes: Object.fromEntries(\n Object.entries(SHIELDS_BADGE_REQUIRED_ATTRIBUTES).map(([type, names]) => [type, [...names]]),\n ),\n styles: [...(badge?.attributeValues?.style ?? [])],\n targets: Object.fromEntries(\n Object.entries(SHIELDS_BADGE_TARGETS).map(([type, targets]) => [type, [...targets]]),\n ),\n types: [...(badge?.attributeValues?.type ?? [])],\n },\n closeMarkers: layoutDirectiveRegistry.closeMarkers.map(({ action, marker }) => ({\n closes: CLOSES[action as keyof typeof CLOSES],\n marker,\n })),\n constraints: CONSTRAINTS,\n directives: layoutDirectiveRegistry.all.map((definition) => describeDirective(definition)),\n headings: {\n slug: [\n 'Lowercase; remove quotes; replace every run of characters other than a-z and 0-9 with \"-\"; trim \"-\"; an empty result becomes \"section\".',\n 'Repeated slugs get -1, -2, … suffixes, skipping ids already emitted in the document.',\n 'Only top-level headings and headings directly inside container directives get ids.',\n ],\n examples: HEADING_EXAMPLES.map((text) => [text, slugifyHeading(text)]),\n },\n package: '@valkyrianlabs/payload-markdown',\n specVersion: DIRECTIVE_SPEC_VERSION,\n tabs: {\n examples: TAB_EXAMPLES.map(([raw, index]) => ({ index, raw, value: slugTabValue(raw, index) })),\n value: [\n 'A tab value comes from the value attribute, else the [label], else the label attribute, else tab-N (N is the 1-based tab position).',\n 'It is slugged: split camelCase with \"-\", lowercase, replace runs of characters other than a-z and 0-9 with \"-\", trim \"-\". An empty slug becomes tab-N.',\n 'Repeated values in one tabs block get -1, -2, … suffixes.',\n 'tabs default=\"…\" matches a tab value (after slugging) first, then a raw value or label; otherwise the first enabled tab is active.',\n ],\n },\n themes,\n }\n}\n"],"names":["slugTabValue","slugifyHeading","layoutDirectiveRegistry","SHIELDS_BADGE_ORIGIN","SHIELDS_BADGE_QUERY_ATTRIBUTES","SHIELDS_BADGE_REQUIRED_ATTRIBUTES","SHIELDS_BADGE_TARGETS","DEFAULT_DIRECTIVE_THEMES","getDirectiveFallbackThemeName","DIRECTIVE_SPEC_VERSION","isBooleanValues","values","Boolean","length","includes","describeAttribute","definition","name","declared","attributeTypes","attributeValues","type","undefined","themeGroup","themeAttributes","defaultValue","defaultAttributes","base","default","max","min","format","describeDirective","container","labelAttribute","attributes","allowedAttributes","sort","map","closeLabel","getCloseLabel","closeMarkers","getCloseMarkers","description","kind","open","getOpenMarker","supportsAttributes","CLOSES","close","closeGrid","closeSection","CONSTRAINTS","TAB_EXAMPLES","HEADING_EXAMPLES","getDirectiveSpec","badge","get","themes","Object","fromEntries","keys","group","builtIn","theme","fallback","badges","intervals","interval","origin","queryAttributes","requiredAttributes","entries","names","styles","style","targets","types","action","marker","closes","constraints","directives","all","headings","slug","examples","text","package","specVersion","tabs","raw","index","value"],"mappings":"AAGA,SAASA,YAAY,QAAQ,uBAAsB;AACnD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,uBAAuB,QAAQ,gBAAe;AACvD,SACEC,oBAAoB,EACpBC,8BAA8B,EAC9BC,iCAAiC,EACjCC,qBAAqB,QAChB,eAAc;AACrB,SAASC,wBAAwB,EAAEC,6BAA6B,QAAQ,cAAa;AAErF;;;CAGC,GACD,OAAO,MAAMC,yBAAyB,EAAC;AA0DvC,SAASC,gBAAgBC,MAAqC;IAC5D,OAAOC,QAAQD,UAAUA,OAAOE,MAAM,KAAK,KAAKF,OAAOG,QAAQ,CAAC,WAAWH,OAAOG,QAAQ,CAAC;AAC7F;AAEA;;;;CAIC,GACD,SAASC,kBACPC,UAAqC,EACrCC,IAAY;IAEZ,MA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7F,aAAa2F,KAAKC;gBAAO,CAAA;YAC5FC,OAAO;gBACL;gBACA;gBACA;gBACA;aACD;QACH;QACAnC;IACF;AACF"}
@@ -0,0 +1,8 @@
1
+ import type { MarkdownDirectiveThemes } from '../types/core.js';
2
+ import type { LayoutDirectiveDefinition } from './types.js';
3
+ /**
4
+ * "Unknown theme" diagnostics for a directive's theme attributes. Shared by
5
+ * the renderer (remarkValidateDirectiveThemes) and the editor linter, so both
6
+ * report the same messages.
7
+ */
8
+ export declare function getUnknownThemeDiagnostics(definition: LayoutDirectiveDefinition, attributes: null | Record<string, unknown> | undefined, themes: MarkdownDirectiveThemes | undefined): string[];
@@ -0,0 +1,21 @@
1
+ import { getDirectiveFallbackThemeName, hasDirectiveTheme } from './themes.js';
2
+ /**
3
+ * "Unknown theme" diagnostics for a directive's theme attributes. Shared by
4
+ * the renderer (remarkValidateDirectiveThemes) and the editor linter, so both
5
+ * report the same messages.
6
+ */ export function getUnknownThemeDiagnostics(definition, attributes, themes) {
7
+ if (!definition.themeAttributes) return [];
8
+ const diagnostics = [];
9
+ for (const [attribute, groupName] of Object.entries(definition.themeAttributes)){
10
+ if (!groupName) continue;
11
+ const value = attributes?.[attribute];
12
+ if (typeof value !== 'string' || !value.trim()) continue;
13
+ if (hasDirectiveTheme(groupName, value, themes)) continue;
14
+ const label = attribute === 'theme' ? 'theme' : attribute;
15
+ const hint = definition.unknownThemeHint?.(attribute, value);
16
+ diagnostics.push(`Unknown ${label} "${value}" on "${definition.name}". Falling back to "${getDirectiveFallbackThemeName(groupName, themes)}".${hint ? ` ${hint}` : ''}`);
17
+ }
18
+ return diagnostics;
19
+ }
20
+
21
+ //# sourceMappingURL=themeDiagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/directives/themeDiagnostics.ts"],"sourcesContent":["import type { MarkdownDirectiveThemes } from '../types/core.js'\nimport type { LayoutDirectiveDefinition } from './types.js'\n\nimport { getDirectiveFallbackThemeName, hasDirectiveTheme } from './themes.js'\n\n/**\n * \"Unknown theme\" diagnostics for a directive's theme attributes. Shared by\n * the renderer (remarkValidateDirectiveThemes) and the editor linter, so both\n * report the same messages.\n */\nexport function getUnknownThemeDiagnostics(\n definition: LayoutDirectiveDefinition,\n attributes: null | Record<string, unknown> | undefined,\n themes: MarkdownDirectiveThemes | undefined,\n): string[] {\n if (!definition.themeAttributes) return []\n\n const diagnostics: string[] = []\n\n for (const [attribute, groupName] of Object.entries(definition.themeAttributes)) {\n if (!groupName) continue\n\n const value = attributes?.[attribute]\n if (typeof value !== 'string' || !value.trim()) continue\n if (hasDirectiveTheme(groupName, value, themes)) continue\n\n const label = attribute === 'theme' ? 'theme' : attribute\n const hint = definition.unknownThemeHint?.(attribute, value)\n\n diagnostics.push(\n `Unknown ${label} \"${value}\" on \"${definition.name}\". Falling back to \"${getDirectiveFallbackThemeName(groupName, themes)}\".${hint ? ` ${hint}` : ''}`,\n )\n }\n\n return diagnostics\n}\n"],"names":["getDirectiveFallbackThemeName","hasDirectiveTheme","getUnknownThemeDiagnostics","definition","attributes","themes","themeAttributes","diagnostics","attribute","groupName","Object","entries","value","trim","label","hint","unknownThemeHint","push","name"],"mappings":"AAGA,SAASA,6BAA6B,EAAEC,iBAAiB,QAAQ,cAAa;AAE9E;;;;CAIC,GACD,OAAO,SAASC,2BACdC,UAAqC,EACrCC,UAAsD,EACtDC,MAA2C;IAE3C,IAAI,CAACF,WAAWG,eAAe,EAAE,OAAO,EAAE;IAE1C,MAAMC,cAAwB,EAAE;IAEhC,KAAK,MAAM,CAACC,WAAWC,UAAU,IAAIC,OAAOC,OAAO,CAACR,WAAWG,eAAe,EAAG;QAC/E,IAAI,CAACG,WAAW;QAEhB,MAAMG,QAAQR,YAAY,CAACI,UAAU;QACrC,IAAI,OAAOI,UAAU,YAAY,CAACA,MAAMC,IAAI,IAAI;QAChD,IAAIZ,kBAAkBQ,WAAWG,OAAOP,SAAS;QAEjD,MAAMS,QAAQN,cAAc,UAAU,UAAUA;QAChD,MAAMO,OAAOZ,WAAWa,gBAAgB,GAAGR,WAAWI;QAEtDL,YAAYU,IAAI,CACd,CAAC,QAAQ,EAAEH,MAAM,EAAE,EAAEF,MAAM,MAAM,EAAET,WAAWe,IAAI,CAAC,oBAAoB,EAAElB,8BAA8BS,WAAWJ,QAAQ,EAAE,EAAEU,OAAO,CAAC,CAAC,EAAEA,MAAM,GAAG,IAAI;IAE1J;IAEA,OAAOR;AACT"}