@phtngyn/cms 0.1.0-beta.5 → 0.2.0-beta.1

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 (93) hide show
  1. package/README.md +85 -5
  2. package/package.json +11 -1
  3. package/src/ApplicationTypes.d.ts +82 -0
  4. package/src/ApplicationTypes.js +1 -0
  5. package/src/{Configuration-CDMYfTre.js → Configuration-CjVUBBwa.js} +3 -3
  6. package/src/{Configuration-CDMYfTre.js.map → Configuration-CjVUBBwa.js.map} +1 -1
  7. package/src/Configuration.d.ts +9 -4
  8. package/src/Configuration.js.map +1 -1
  9. package/src/Content.d.ts +67 -0
  10. package/src/Content.js +291 -0
  11. package/src/Content.js.map +1 -0
  12. package/src/ContentTransfer-CRQet3QJ.d.ts +48 -0
  13. package/src/{ContentTransfer-C3Av9sWz.js → ContentTransfer-CTzGGKFV.js} +8 -4
  14. package/src/ContentTransfer-CTzGGKFV.js.map +1 -0
  15. package/src/{DocumentEngine-J7g-emdf.js → DocumentEngine-BbhfnTAc.js} +4 -4
  16. package/src/{DocumentEngine-J7g-emdf.js.map → DocumentEngine-BbhfnTAc.js.map} +1 -1
  17. package/src/DocumentModel.d.ts +8 -1
  18. package/src/DocumentModel.js +29 -2
  19. package/src/DocumentModel.js.map +1 -1
  20. package/src/{Forms-Dj6NuW66.js → Forms-02-p8qEw.js} +2 -2
  21. package/src/{Forms-Dj6NuW66.js.map → Forms-02-p8qEw.js.map} +1 -1
  22. package/src/{Forms-BsJMev5_.d.ts → Forms-BorTcIlp.d.ts} +2 -5
  23. package/src/Forms.d.ts +25 -14
  24. package/src/Forms.js.map +1 -1
  25. package/src/I18n-BXlVunfa.d.ts +27 -0
  26. package/src/I18n.d.ts +2 -20
  27. package/src/Module.js +14 -5
  28. package/src/Module.js.map +1 -1
  29. package/src/{S3MediaObjects-CpPSzJto.js → S3MediaObjects-DC0c8sYC.js} +54 -35
  30. package/src/{S3MediaObjects-CpPSzJto.js.map → S3MediaObjects-DC0c8sYC.js.map} +1 -1
  31. package/src/cli/content.js +63 -221
  32. package/src/cli/content.js.map +1 -1
  33. package/src/cli.js +93 -4
  34. package/src/cli.js.map +1 -1
  35. package/src/{connection-CBAy2qGy.js → connection-BPf4BQUZ.js} +2 -2
  36. package/src/{connection-CBAy2qGy.js.map → connection-BPf4BQUZ.js.map} +1 -1
  37. package/src/dev-lifecycle-vQLxwCFq.js +428 -0
  38. package/src/dev-lifecycle-vQLxwCFq.js.map +1 -0
  39. package/src/{installation-CNfIriVm.js → installation-DsGst1BH.js} +578 -457
  40. package/src/installation-DsGst1BH.js.map +1 -0
  41. package/src/internal/application-types.js +43 -0
  42. package/src/internal/application-types.js.map +1 -0
  43. package/src/internal/authoring-catalog.js +9 -4
  44. package/src/internal/authoring-catalog.js.map +1 -1
  45. package/src/internal/authoring-metadata.js +1 -1
  46. package/src/internal/configuration.js +10 -6
  47. package/src/internal/configuration.js.map +1 -1
  48. package/src/internal/dev-lifecycle.js +3 -0
  49. package/src/internal/document-model.js +2 -2
  50. package/src/internal/document-model.js.map +1 -1
  51. package/src/internal/i18n.js +21 -0
  52. package/src/internal/i18n.js.map +1 -1
  53. package/src/{location-BTqdfIzX.js → location-BgYhXEZp.js} +2 -2
  54. package/src/{location-BTqdfIzX.js.map → location-BgYhXEZp.js.map} +1 -1
  55. package/src/{models-Bah5B3bT.js → models-DgkGTFus.js} +6 -1
  56. package/src/models-DgkGTFus.js.map +1 -0
  57. package/src/{models-B4IoTmp7.js → models-k2nXyD6q.js} +2 -2
  58. package/src/{models-B4IoTmp7.js.map → models-k2nXyD6q.js.map} +1 -1
  59. package/src/runtime/delivery/context.js +1 -1
  60. package/src/runtime/delivery/plugin.js +27 -5
  61. package/src/runtime/delivery/plugin.js.map +1 -1
  62. package/src/runtime/delivery/preview.d.ts +1 -1
  63. package/src/runtime/delivery/types.d.ts +2 -85
  64. package/src/runtime/delivery/useCmsDocumentSeo.d.ts +8 -1
  65. package/src/runtime/delivery/useCmsDocumentSeo.js +19 -7
  66. package/src/runtime/delivery/useCmsDocumentSeo.js.map +1 -1
  67. package/src/runtime/delivery/useDocument.d.ts +2 -2
  68. package/src/runtime/delivery/useDocument.js.map +1 -1
  69. package/src/runtime/delivery/useDocumentQuery.d.ts +3 -3
  70. package/src/runtime/delivery/useDocumentQuery.js.map +1 -1
  71. package/src/runtime/forms/document.js +1 -1
  72. package/src/runtime/forms/useCmsForm.js +81 -41
  73. package/src/runtime/forms/useCmsForm.js.map +1 -1
  74. package/src/runtime/i18n/useCmsI18n.d.ts +9 -7
  75. package/src/runtime/i18n/useCmsI18n.js +5 -4
  76. package/src/runtime/i18n/useCmsI18n.js.map +1 -1
  77. package/src/runtime/installation.js +2 -2
  78. package/src/runtime/plugin.js +1 -1
  79. package/src/runtime/preview/connection.js +1 -1
  80. package/src/runtime/preview/controller.js +2 -2
  81. package/src/runtime/preview/plugin.client.js +3 -3
  82. package/src/runtime/preview/store.js +1 -1
  83. package/src/runtime/sitemap.js +1 -1
  84. package/src/scalars-CA6kyipS.d.ts +7 -0
  85. package/src/{store-b2CSXgMt.js → store-BYgSt7E3.js} +3 -3
  86. package/src/{store-b2CSXgMt.js.map → store-BYgSt7E3.js.map} +1 -1
  87. package/src/types-DutFRtaG.d.ts +90 -0
  88. package/studio/{CreateDocumentDialog-GGey1uBc.js → CreateDocumentDialog-BdiM77bb.js} +1 -1
  89. package/studio/{documentPlanning-DRErYmBU.js → documentPlanning-B7fyUj9r.js} +7072 -7065
  90. package/studio/host.js +2 -2
  91. package/src/ContentTransfer-C3Av9sWz.js.map +0 -1
  92. package/src/installation-CNfIriVm.js.map +0 -1
  93. package/src/models-Bah5B3bT.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Configuration-CDMYfTre.js","names":["isJsonObject","jsonObject","comarkToEditor","isJsonObject","isElementNode"],"sources":["../../../../document/src/internal/editor/attributes.ts","../../../../document/src/internal/editor/image.ts","../../../../document/src/internal/editor/marks.ts","../../../../document/src/internal/comark/to-editor.ts","../../../../document/src/internal/comark/source-mapping.ts","../../../../document/src/internal/comark/grammar.ts","../../../../document/src/internal/editor/errors.ts","../../../../document/src/AuthoringSchema.ts","../../../../protocol/src/Authoring.ts","../../../../protocol/src/Configuration.ts"],"sourcesContent":["import { Predicate, Schema } from 'effect'\n\nexport function compactJsonAttributes(\n attributes: Readonly<Record<string, Schema.Json | undefined>>,\n): Schema.JsonObject {\n return Object.fromEntries(\n Object.entries(attributes).filter((entry): entry is [string, Schema.Json] => entry[1] !== undefined),\n )\n}\n\nexport function nonEmptyStringAttribute(value: Schema.Json | undefined): string | undefined {\n return Predicate.isString(value) && value ? value : undefined\n}\n\nexport function finiteNumberAttribute(value: Schema.Json | undefined, fallback: number): number {\n const number = Predicate.isNumber(value) ? value : Number(value)\n\n return Number.isFinite(number) ? number : fallback\n}\n","import { Predicate, Schema } from 'effect'\nimport { compactJsonAttributes } from './attributes'\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\nconst EDITOR_IMAGE_LAYOUTS = ['natural', 'content', 'full'] as const\n\nexport type EditorImageLayout = (typeof EDITOR_IMAGE_LAYOUTS)[number]\n\nconst EditorImageLayout = Schema.Literals(EDITOR_IMAGE_LAYOUTS)\n\nconst isEditorImageLayout = Schema.is(EditorImageLayout)\n\nexport const EDITOR_IMAGE_LAYOUT_ATTRIBUTE = 'data-cms-layout'\n\nconst IMAGE_DECORATIVE_ATTRIBUTE = 'data-cms-decorative'\n\nconst IMAGE_SEMANTIC_ATTRIBUTES = new Set([\n 'alt',\n IMAGE_DECORATIVE_ATTRIBUTE,\n EDITOR_IMAGE_LAYOUT_ATTRIBUTE,\n 'src',\n 'title',\n])\n\nexport function decodeEditorImageAttributes(attributes: Schema.JsonObject): Schema.JsonObject {\n const cmsProps = Object.fromEntries(\n Object.entries(attributes).filter(([name]) => !IMAGE_SEMANTIC_ATTRIBUTES.has(name)),\n )\n\n return compactJsonAttributes({\n alt:\n attributes[IMAGE_DECORATIVE_ATTRIBUTE] !== undefined\n ? ''\n : Predicate.isString(attributes.alt)\n ? attributes.alt\n : null,\n cmsProps: Object.keys(cmsProps).length ? cmsProps : null,\n layout: normalizeEditorImageLayout(attributes[EDITOR_IMAGE_LAYOUT_ATTRIBUTE]),\n src: stringValue(attributes.src) || null,\n title: stringValue(attributes.title) || null,\n })\n}\n\nexport function encodeEditorImageAttributes(value: Schema.JsonObject | undefined): Schema.JsonObject {\n const attributes = jsonObject(value)\n const alt = attributes.alt\n const layout = normalizeEditorImageLayout(attributes.layout)\n\n return compactJsonAttributes(\n Object.assign({}, jsonObject(attributes.cmsProps), {\n alt: Predicate.isString(alt) ? alt : undefined,\n [IMAGE_DECORATIVE_ATTRIBUTE]: alt === '' ? 'true' : undefined,\n [EDITOR_IMAGE_LAYOUT_ATTRIBUTE]: layout === 'natural' ? undefined : layout,\n src: stringValue(attributes.src) || undefined,\n title: stringValue(attributes.title) || undefined,\n }),\n )\n}\n\nexport function normalizeEditorImageLayout(value: Schema.Json | undefined): EditorImageLayout {\n return isEditorImageLayout(value) ? value : 'natural'\n}\n\nfunction jsonObject(value: Schema.Json | undefined): Schema.JsonObject {\n return isJsonObject(value) ? value : {}\n}\n\nfunction stringValue(value: Schema.Json | undefined): string {\n return Predicate.isString(value) || Predicate.isNumber(value) ? String(value) : ''\n}\n","const EDITOR_MARKS = [\n ['bold', 'strong'],\n ['code', 'code'],\n ['italic', 'em'],\n ['link', 'a'],\n ['strike', 'del'],\n ['underline', 'u'],\n] as const\n\nexport const EDITOR_MARK_TYPES = EDITOR_MARKS.map(([type]) => type)\n\nconst editorToComark = new Map<string, string>(EDITOR_MARKS)\n\nconst comarkToEditor = new Map<string, string>(EDITOR_MARKS.map(([type, tag]) => [tag, type]))\n\nexport function comarkTagForEditorMark(type: string): string | undefined {\n return editorToComark.get(type)\n}\n\nexport function editorMarkForComarkTag(tag: string): string | undefined {\n return comarkToEditor.get(tag)\n}\n\nexport function isEditorMark(type: string): boolean {\n return editorToComark.has(type)\n}\n\nexport function isComarkMark(tag: string): boolean {\n return comarkToEditor.has(tag)\n}\n","import type { MarkdownNode } from '@internal/protocol/Documents'\nimport type { EditorNodeId } from '@internal/protocol/Documents'\nimport type { JSONContent } from '@tiptap/core'\nimport type { NodeRenderData } from 'comark'\nimport { Predicate, Schema } from 'effect'\nimport { projectCmsEditorComponentAttributes, resolveCmsComarkAttributes, withCmsComarkProps } from './bindings'\nimport { editorNodeId, createEditorNodeId } from '../editor/identity'\nimport { decodeEditorImageAttributes } from '../editor/image'\nimport { editorMetadata } from '../editor/metadata'\nimport { compactJsonAttributes, finiteNumberAttribute, nonEmptyStringAttribute } from '../editor/attributes'\nimport { editorMarkForComarkTag, isComarkMark } from '../editor/marks'\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\ntype ElementMarkdownNode = Extract<MarkdownNode, readonly [string, Schema.JsonObject, ...MarkdownNode[]]>\n\ninterface DecodeContext {\n readonly usedIds: Set<EditorNodeId>\n}\n\nconst OPAQUE_BLOCK_TAGS = new Set(['math', 'table', 'tbody', 'td', 'th', 'thead', 'tr'])\n\nexport function comarkToEditor(\n nodes: ReadonlyArray<MarkdownNode>,\n renderData: NodeRenderData = { data: {}, frontmatter: {}, meta: {}, props: {} },\n): JSONContent[] {\n return decodeBlocks(\n nodes,\n {\n usedIds: new Set(),\n },\n renderData,\n )\n}\n\nfunction decodeBlocks(\n nodes: ReadonlyArray<MarkdownNode>,\n context: DecodeContext,\n renderData: NodeRenderData,\n wrapInlineContent = false,\n): JSONContent[] {\n const content: JSONContent[] = []\n let inlineNodes: MarkdownNode[] = []\n\n const flushInlineNodes = () => {\n const inline = decodeInlines(inlineNodes, context, renderData)\n\n if (inline.length) {\n content.push({\n type: 'paragraph',\n attrs: wrapInlineContent ? { cmsSynthetic: true } : { cmsNodeId: claimIdentity(context) },\n content: inline,\n })\n }\n\n inlineNodes = []\n }\n\n for (const node of nodes) {\n if (Predicate.isString(node) || isInlineElement(node)) {\n inlineNodes.push(node)\n continue\n }\n\n flushInlineNodes()\n content.push(decodeBlock(node, context, renderData))\n }\n\n flushInlineNodes()\n\n return content\n}\n\nfunction decodeBlock(\n node: Exclude<MarkdownNode, string>,\n context: DecodeContext,\n renderData: NodeRenderData,\n): JSONContent {\n if (node[0] === null) {\n return opaqueBlock(node, 'Comment', claimIdentity(context, node[1]))\n }\n\n const [tag, rawAttributes, ...children] = node\n const attrs = cleanAttrs(rawAttributes)\n const childRenderData = withCmsComarkProps(renderData, resolveCmsComarkAttributes(rawAttributes, renderData))\n const metadata = editorMetadata(rawAttributes)\n const cmsNodeId = claimIdentity(context, rawAttributes)\n\n const commonAttrs = compactJsonAttributes({\n cmsNodeId,\n cmsProps: attrs,\n })\n\n if (/^h[1-6]$/u.test(tag)) {\n return {\n type: 'heading',\n attrs: mergeJsonAttributes(commonAttrs, { level: Number(tag.slice(1)) }),\n content: decodeInlines(children, context, childRenderData),\n }\n }\n\n switch (tag) {\n case 'p':\n return { type: 'paragraph', attrs: commonAttrs, content: decodeInlines(children, context, childRenderData) }\n case 'blockquote':\n return {\n type: 'blockquote',\n attrs: commonAttrs,\n content: decodeBlocks(children, context, childRenderData),\n }\n case 'ul':\n return {\n type: 'bulletList',\n attrs: commonAttrs,\n content: decodeListItems(children, context, childRenderData),\n }\n case 'ol':\n return {\n type: 'orderedList',\n attrs: mergeJsonAttributes(commonAttrs, { start: finiteNumberAttribute(attrs.start, 1) }),\n content: decodeListItems(children, context, childRenderData),\n }\n case 'li':\n return {\n type: 'listItem',\n attrs: commonAttrs,\n content: decodeBlocks(children, context, childRenderData),\n }\n case 'pre': {\n const code = children.find(isElementNode)\n\n const language =\n nonEmptyStringAttribute(attrs.language) ?? nonEmptyStringAttribute(code?.[1].class)?.replace(/^language-/u, '')\n\n return {\n type: 'codeBlock',\n attrs: mergeJsonAttributes(commonAttrs, { language }),\n content: textContent(code ? elementChildren(code) : children),\n }\n }\n\n case 'hr':\n return { type: 'horizontalRule', attrs: commonAttrs }\n default:\n if (OPAQUE_BLOCK_TAGS.has(tag)) return opaqueBlock(node, tag, cmsNodeId)\n const projection = projectCmsEditorComponentAttributes(rawAttributes, renderData)\n\n return {\n type: 'cmsBlock',\n attrs: compactJsonAttributes({\n bindings: projection.bindings,\n cmsNodeId,\n props: projection.props,\n tag,\n }),\n content: decodeComponentSlots(children, context, projection.renderData, metadata?.implicitSlotId),\n }\n }\n}\n\nfunction decodeComponentSlots(\n children: ReadonlyArray<MarkdownNode>,\n context: DecodeContext,\n renderData: NodeRenderData,\n implicitSlotId?: EditorNodeId,\n): JSONContent[] {\n const templates = children.filter(isSlotTemplate)\n const regular = children.filter((node) => !isSlotTemplate(node))\n const slots = templates.map((node) => decodeSlot(node, context, renderData))\n\n if (!regular.length) return slots\n\n const defaultContent = slotContent(decodeBlocks(regular, context, renderData, true))\n const explicitDefault = slots.find((slot) => slot.attrs?.name === 'default')\n\n if (explicitDefault) {\n explicitDefault.content = [...(explicitDefault.content ?? []), ...defaultContent]\n\n return slots\n }\n\n return [\n {\n type: 'cmsSlot',\n attrs: {\n cmsNodeId: claimIdentityValue(context, implicitSlotId),\n implicit: true,\n name: 'default',\n props: {},\n },\n content: defaultContent,\n },\n ...slots,\n ]\n}\n\nfunction decodeSlot(node: ElementMarkdownNode, context: DecodeContext, renderData: NodeRenderData): JSONContent {\n const attrs = cleanAttrs(node[1])\n const childRenderData = withCmsComarkProps(renderData, resolveCmsComarkAttributes(node[1], renderData))\n const name = slotName(attrs)\n const { name: _name, ...slotProps } = attrs\n\n return {\n type: 'cmsSlot',\n attrs: {\n cmsNodeId: claimIdentity(context, node[1]),\n implicit: false,\n name,\n props: slotProps,\n },\n content: slotContent(decodeBlocks(elementChildren(node), context, childRenderData, true)),\n }\n}\n\nfunction decodeListItems(\n nodes: ReadonlyArray<MarkdownNode>,\n context: DecodeContext,\n renderData: NodeRenderData,\n): JSONContent[] {\n return nodes.flatMap((node) =>\n isElementNode(node) && node[0] === 'li' ? [decodeBlock(node, context, renderData)] : [],\n )\n}\n\nfunction decodeInlines(\n nodes: ReadonlyArray<MarkdownNode>,\n context: DecodeContext,\n renderData: NodeRenderData,\n inheritedMarks: NonNullable<JSONContent['marks']> = [],\n): JSONContent[] {\n const result: JSONContent[] = []\n\n for (const node of nodes) {\n if (Predicate.isString(node)) {\n if (node) {\n result.push(withMarks({ type: 'text', text: node }, inheritedMarks))\n }\n\n continue\n }\n\n if (node[0] === null) {\n result.push(\n withMarks(\n {\n type: 'cmsInlineOpaque',\n attrs: { label: 'Comment', node: stripInternalMetadata(node) },\n },\n inheritedMarks,\n ),\n )\n continue\n }\n\n const markType = editorMarkForComarkTag(node[0])\n\n if (markType) {\n const attrs = cleanAttrs(node[1])\n const childRenderData = withCmsComarkProps(renderData, resolveCmsComarkAttributes(node[1], renderData))\n\n const markAttrs =\n markType === 'link'\n ? mergeJsonAttributes(attrs, { cmsProps: attrs })\n : Object.keys(attrs).length\n ? { cmsProps: attrs }\n : undefined\n\n const mark = markAttrs === undefined ? { type: markType } : { attrs: markAttrs, type: markType }\n result.push(...decodeInlines(elementChildren(node), context, childRenderData, [...inheritedMarks, mark]))\n continue\n }\n\n if (node[0] === 'br') {\n result.push(withMarks({ type: 'hardBreak' }, inheritedMarks))\n continue\n }\n\n if (node[0] === 'img') {\n result.push(\n withMarks(\n {\n type: 'image',\n attrs: mergeJsonAttributes(decodeEditorImageAttributes(cleanAttrs(node[1])), {\n cmsNodeId: claimIdentity(context, node[1]),\n }),\n },\n inheritedMarks,\n ),\n )\n continue\n }\n\n result.push(\n withMarks(\n {\n type: 'cmsInlineOpaque',\n attrs: {\n label: node[0],\n node: stripInternalMetadata(node),\n },\n },\n inheritedMarks,\n ),\n )\n }\n\n return result\n}\n\nfunction claimIdentity(context: DecodeContext, attributes?: Schema.JsonObject): EditorNodeId {\n return claimIdentityValue(context, attributes ? editorMetadata(attributes)?.nodeId : undefined)\n}\n\nfunction claimIdentityValue(context: DecodeContext, candidate?: Schema.Json): EditorNodeId {\n const existing = editorNodeId(candidate)\n\n if (existing !== undefined && !context.usedIds.has(existing)) {\n context.usedIds.add(existing)\n\n return existing\n }\n\n for (let attempt = 0; attempt < 100; attempt++) {\n const created = createEditorNodeId()\n\n if (!context.usedIds.has(created)) {\n context.usedIds.add(created)\n\n return created\n }\n }\n\n throw new Error('The editor identity factory did not produce a unique identity.')\n}\n\nfunction opaqueBlock(node: Exclude<MarkdownNode, string>, label: string, cmsNodeId: EditorNodeId): JSONContent {\n return {\n type: 'cmsOpaque',\n attrs: {\n cmsNodeId,\n label,\n node: stripInternalMetadata(node),\n },\n }\n}\n\nfunction stripInternalMetadata(node: Exclude<MarkdownNode, string>): Exclude<MarkdownNode, string> {\n if (node[0] === null) return [null, cleanAttrs(node[1]), node[2]]\n const [tag, attributes, ...children] = node\n const clean = cleanAttrs(attributes)\n\n return [tag, clean, ...children.map((child) => (Predicate.isString(child) ? child : stripInternalMetadata(child)))]\n}\n\nfunction slotContent(content: JSONContent[]): JSONContent[] {\n return content.length ? content : [{ type: 'paragraph', attrs: { cmsSynthetic: true } }]\n}\n\nfunction slotName(attrs: Schema.JsonObject): string {\n return nonEmptyStringAttribute(attrs.name) ?? 'default'\n}\n\nfunction cleanAttrs(attrs: Schema.JsonObject): Schema.JsonObject {\n const { $: _internal, 'data-cms-node': _marker, ...clean } = attrs\n\n return structuredClone(clean)\n}\n\nfunction textContent(nodes: ReadonlyArray<MarkdownNode>): JSONContent[] | undefined {\n const text = nodes\n .map((node) =>\n Predicate.isString(node)\n ? node\n : node[0] === null\n ? node[2]\n : (textContent(elementChildren(node))\n ?.map((child) => child.text ?? '')\n .join('') ?? ''),\n )\n .join('')\n\n return text ? [{ type: 'text', text }] : undefined\n}\n\nfunction isInlineElement(node: Exclude<MarkdownNode, string>): boolean {\n return (\n node[0] !== null &&\n (isComarkMark(node[0]) || node[0] === 'br' || node[0] === 'img' || jsonObject(node[1].$).block === 0)\n )\n}\n\nfunction isSlotTemplate(node: MarkdownNode): node is ElementMarkdownNode {\n return isElementNode(node) && node[0] === 'template'\n}\n\nfunction isElementNode(node: MarkdownNode | undefined): node is ElementMarkdownNode {\n return Array.isArray(node) && Predicate.isString(node[0])\n}\n\nfunction elementChildren(node: ElementMarkdownNode): MarkdownNode[] {\n const [, , ...children] = node\n\n return children\n}\n\nfunction jsonObject(value: Schema.Json | undefined): Schema.JsonObject {\n return isJsonObject(value) ? value : {}\n}\n\nfunction mergeJsonAttributes(\n attributes: Schema.JsonObject,\n additions: Readonly<Record<string, Schema.Json | undefined>>,\n): Schema.JsonObject {\n return compactJsonAttributes(Object.assign({}, attributes, additions))\n}\n\nfunction withMarks(content: JSONContent, marks: NonNullable<JSONContent['marks']>): JSONContent {\n return marks.length ? Object.assign({}, content, { marks }) : content\n}\n","import type { DocumentSourceMapping, DocumentSourcePoint, DocumentSourceRange } from '@internal/protocol/Documents'\nimport type { ComarkParsePostState, ComarkParsePreState, ComarkPlugin, ElementNode, Node } from 'comark'\nimport { Option, Predicate, Schema } from 'effect'\n\nexport const SOURCE_MAPPINGS_META_KEY = '__cmsSourceMappings'\n\ninterface SourceMapParseState {\n __cmsOriginalMarkdown?: string\n parsedLines?: number\n}\n\ninterface ComarkToken extends Schema.Schema.Type<typeof ComarkToken> {}\n\ninterface BlockDescriptor {\n readonly children: BlockDescriptor[]\n range: DocumentSourceRange\n readonly tag: string\n}\n\nconst BLOCK_TAGS = new Map([\n ['blockquote_open', 'blockquote'],\n ['bullet_list_open', 'ul'],\n ['list_item_open', 'li'],\n ['ordered_list_open', 'ol'],\n ['paragraph_open', 'p'],\n ['table_open', 'table'],\n ['tbody_open', 'tbody'],\n ['td_open', 'td'],\n ['th_open', 'th'],\n ['thead_open', 'thead'],\n ['tr_open', 'tr'],\n])\n\nconst ComarkToken = Schema.Struct({\n attrs: Schema.optionalKey(Schema.NullOr(Schema.Array(Schema.Tuple([Schema.String, Schema.String])))),\n hidden: Schema.optionalKey(Schema.Boolean),\n level: Schema.optionalKey(Schema.Finite),\n map: Schema.optionalKey(Schema.NullOr(Schema.Tuple([Schema.Finite, Schema.Finite]))),\n nesting: Schema.optionalKey(Schema.Finite),\n tag: Schema.optionalKey(Schema.String),\n type: Schema.optionalKey(Schema.String),\n})\n\nconst WRAPPER_TAGS = new Set(['blockquote', 'ol', 'pre', 'table', 'ul'])\n\nexport function sourceCapturePlugin(): ComarkPlugin {\n return {\n name: 'cms-source-capture',\n pre(state: ComarkParsePreState & SourceMapParseState) {\n state.__cmsOriginalMarkdown = state.markdown\n },\n }\n}\n\nexport function sourceMappingPlugin(): ComarkPlugin {\n return {\n name: 'cms-source-mapping',\n post(state: ComarkParsePostState & SourceMapParseState) {\n const source = state.__cmsOriginalMarkdown ?? state.markdown\n\n const descriptors = createBlockDescriptors(\n state.tokens.flatMap((token) => {\n const decoded = Schema.decodeUnknownOption(ComarkToken)(token)\n\n return Option.isSome(decoded) ? [decoded.value] : []\n }),\n source,\n state.markdown,\n state.parsedLines ?? 0,\n )\n\n const mappings: DocumentSourceMapping[] = []\n mapNodes(state.tree.nodes, descriptors, [], mappings)\n state.tree.meta[SOURCE_MAPPINGS_META_KEY] = mappings\n },\n }\n}\n\nfunction createBlockDescriptors(\n tokens: ReadonlyArray<ComarkToken>,\n source: string,\n parsedMarkdown: string,\n parsedLines: number,\n): BlockDescriptor[] {\n const roots: BlockDescriptor[] = []\n const stack: Array<{ descriptor: BlockDescriptor; level: number }> = []\n const sourceLineStarts = indexLineStarts(source)\n const parsedLineStarts = indexLineStarts(parsedMarkdown)\n const parsedOffset = source.lastIndexOf(parsedMarkdown)\n const slotMaps = createSlotTokenMaps(tokens, parsedMarkdown)\n\n for (let tokenIndex = 0; tokenIndex < tokens.length; tokenIndex++) {\n const token = tokens[tokenIndex]\n\n if (!token) continue\n const tag = blockTag(token)\n const tokenMap = token.map ?? slotMaps.get(tokenIndex)\n\n if (!tag || !tokenMap) continue\n\n const level = token.level ?? 0\n\n while (true) {\n const current = stack.at(-1)\n\n if (!current || current.level < level) break\n stack.pop()\n }\n\n const descriptor: BlockDescriptor = {\n children: [],\n range: rangeFromParsedLines(\n source,\n sourceLineStarts,\n parsedMarkdown,\n parsedLineStarts,\n parsedOffset,\n tokenMap[0],\n tokenMap[1] + (token.type === 'mdc_block_open' ? 1 : 0),\n parsedLines,\n ),\n tag,\n }\n\n const parent = stack.at(-1)?.descriptor\n\n ;(parent?.children ?? roots).push(descriptor)\n\n if (token.nesting === 1) stack.push({ descriptor, level })\n }\n\n return roots.map(collapseComarkWrapper).map(groupProjectedSlotContent)\n}\n\nfunction blockTag(token: ComarkToken): string | undefined {\n if (token.hidden || !token.type) return undefined\n\n if (token.type === 'heading_open') return token.tag\n\n if (token.type === 'mdc_block_open' || (token.type === 'mdc_block_shorthand' && token.nesting !== -1))\n return token.tag || 'component'\n\n if (token.type === 'mdc_block_slot' && token.nesting === 1) return 'template'\n\n if (['fence', 'fenced_code_block', 'code_block'].includes(token.type)) return 'pre'\n\n if (token.type === 'math_block') return 'math'\n\n if (token.type === 'html_block') return '*'\n\n if (token.type === 'hr') return 'hr'\n\n return BLOCK_TAGS.get(token.type)\n}\n\nfunction createSlotTokenMaps(\n tokens: ReadonlyArray<ComarkToken>,\n parsedMarkdown: string,\n): Map<number, [number, number]> {\n const maps = new Map<number, [number, number]>()\n const markers = slotMarkers(parsedMarkdown)\n const stack: Array<{ index: number; marker: number }> = []\n let nextMarker = 0\n\n for (let index = 0; index < tokens.length; index++) {\n const token = tokens[index]\n\n if (!token || token.type !== 'mdc_block_slot') continue\n\n if (token.nesting === 1) {\n const name = token.attrs?.[0]?.[0]?.replace(/^#/u, '')\n let markerIndex = nextMarker\n\n while (markerIndex < markers.length && markers[markerIndex]?.name !== name) markerIndex++\n const marker = markers[markerIndex]\n\n if (marker) {\n stack.push({ index, marker: marker.line })\n nextMarker = markerIndex + 1\n }\n\n continue\n }\n\n if (token.nesting !== -1) continue\n const open = stack.pop()\n\n if (!open) continue\n let endLine = open.marker + 1\n\n for (let childIndex = open.index + 1; childIndex < index; childIndex++) {\n const child = tokens[childIndex]\n const map = child?.map ?? maps.get(childIndex)\n\n if (child && map) {\n endLine = Math.max(endLine, map[1] + (child.type === 'mdc_block_open' ? 1 : 0))\n }\n }\n\n maps.set(open.index, [open.marker, endLine])\n }\n\n return maps\n}\n\nfunction slotMarkers(source: string): Array<{ line: number; name: string }> {\n return source.split(/\\r?\\n/u).flatMap((line, index) => {\n const name = line.match(/^\\s*#([^\\s{]+)/u)?.[1]\n\n return name ? [{ line: index, name }] : []\n })\n}\n\nfunction collapseComarkWrapper(descriptor: BlockDescriptor): BlockDescriptor {\n const children = descriptor.children.map(collapseComarkWrapper)\n\n if (WRAPPER_TAGS.has(descriptor.tag) && children.length === 1 && children[0]?.tag === descriptor.tag) {\n return { ...descriptor, children: children[0].children }\n }\n\n return { ...descriptor, children }\n}\n\n/** Comark projects siblings after a named slot into that active slot. */\nfunction groupProjectedSlotContent(descriptor: BlockDescriptor): BlockDescriptor {\n const grouped: BlockDescriptor[] = []\n let activeSlot: BlockDescriptor | undefined\n\n for (const rawChild of descriptor.children) {\n const child = groupProjectedSlotContent(rawChild)\n\n if (child.tag === 'template') {\n activeSlot = child\n grouped.push(child)\n continue\n }\n\n if (!activeSlot) {\n grouped.push(child)\n continue\n }\n\n activeSlot.children.push(child)\n\n if (child.range.end.offset > activeSlot.range.end.offset) {\n activeSlot.range = { start: activeSlot.range.start, end: child.range.end }\n }\n }\n\n return { ...descriptor, children: grouped }\n}\n\nfunction mapNodes(\n nodes: ReadonlyArray<Node>,\n descriptors: ReadonlyArray<BlockDescriptor>,\n parentPath: ReadonlyArray<number>,\n mappings: DocumentSourceMapping[],\n): void {\n let descriptorIndex = 0\n\n for (let nodeIndex = 0; nodeIndex < nodes.length; nodeIndex++) {\n const node = nodes[nodeIndex]\n\n if (!node || !isElementNode(node)) continue\n\n let matchIndex = descriptorIndex\n\n while (\n matchIndex < descriptors.length &&\n descriptors[matchIndex]?.tag !== '*' &&\n descriptors[matchIndex]?.tag !== node[0]\n ) {\n matchIndex++\n }\n\n const descriptor = descriptors[matchIndex]\n\n if (!descriptor) continue\n\n descriptorIndex = matchIndex + 1\n const nodePath = [...parentPath, nodeIndex]\n mappings.push({ nodePath, range: descriptor.range })\n const [, , ...children] = node\n mapNodes(children, descriptor.children, nodePath, mappings)\n }\n}\n\nfunction isElementNode(node: Node): node is ElementNode {\n return Array.isArray(node) && Predicate.isString(node[0])\n}\n\nfunction indexLineStarts(source: string): number[] {\n const starts = [0]\n\n for (let offset = 0; offset < source.length; offset++) {\n if (source.charCodeAt(offset) === 10) starts.push(offset + 1)\n }\n\n return starts\n}\n\nfunction rangeFromParsedLines(\n source: string,\n sourceLineStarts: ReadonlyArray<number>,\n parsedMarkdown: string,\n parsedLineStarts: ReadonlyArray<number>,\n parsedOffset: number,\n startLine: number,\n endLine: number,\n fallbackLineOffset: number,\n): DocumentSourceRange {\n const startOffset =\n parsedOffset >= 0\n ? parsedOffset + (parsedLineStarts[startLine] ?? parsedMarkdown.length)\n : (sourceLineStarts[startLine + fallbackLineOffset] ?? source.length)\n\n const endOffset =\n parsedOffset >= 0\n ? parsedOffset + (parsedLineStarts[endLine] ?? parsedMarkdown.length)\n : (sourceLineStarts[endLine + fallbackLineOffset] ?? source.length)\n\n return {\n start: pointAt(source, sourceLineStarts, startOffset),\n end: pointAt(source, sourceLineStarts, Math.max(startOffset, endOffset)),\n }\n}\n\nfunction pointAt(source: string, lineStarts: ReadonlyArray<number>, rawOffset: number): DocumentSourcePoint {\n const offset = Math.min(Math.max(rawOffset, 0), source.length)\n let low = 0\n let high = lineStarts.length - 1\n\n while (low < high) {\n const middle = Math.ceil((low + high) / 2)\n\n if ((lineStarts[middle] ?? source.length) <= offset) low = middle\n else high = middle - 1\n }\n\n return {\n offset,\n line: low + 1,\n column: offset - (lineStarts[low] ?? 0) + 1,\n }\n}\n","import type { ComarkParseFn } from 'comark'\nimport { createMarkdownParser } from 'comark/parse'\nimport alert from 'comark/plugins/alert'\nimport attributes from 'comark/plugins/attributes'\nimport components from 'comark/plugins/components'\nimport frontmatter from 'comark/plugins/frontmatter'\nimport headings from 'comark/plugins/headings'\nimport security from 'comark/plugins/security'\nimport taskList from 'comark/plugins/task-list'\nimport toc from 'comark/plugins/toc'\nimport { sourceCapturePlugin, sourceMappingPlugin } from './source-mapping'\n\n/**\n * Changes when parsing, normalization, or projection semantics change. Stored\n * with compiled documents so migrations can identify stale derived content.\n */\nexport const DOCUMENT_ENGINE_FINGERPRINT =\n 'comark@0.6.2/frontmatter+alert+task-list+components+attributes+security+headings+toc+source-mapping/v1'\n\nexport function createDocumentParser(): ComarkParseFn {\n return createMarkdownParser({\n autoClose: false,\n registerDefaultPlugins: false,\n plugins: [\n sourceCapturePlugin(),\n frontmatter(),\n alert(),\n taskList(),\n components(),\n attributes(),\n // Security mutates the tree before metadata and source paths are derived.\n security(),\n headings(),\n toc({ depth: 5, searchDepth: 6 }),\n sourceMappingPlugin(),\n ],\n })\n}\n","import { Schema } from 'effect'\n\nexport class EditorDocumentInvalid extends Schema.TaggedError<EditorDocumentInvalid>()('EditorDocument.Invalid', {\n message: Schema.NonEmptyString,\n cause: Schema.Defect(),\n}) {}\n\nexport class EditorRenderFailed extends Schema.TaggedError<EditorRenderFailed>()('EditorDocument.RenderFailed', {\n cause: Schema.Defect(),\n}) {}\n","import { formStructureIssues } from './Forms'\nimport type { BlockAuthoring, BlockProp, BlockSlot } from '@internal/protocol/Authoring'\nimport type { Editor, JSONContent } from '@tiptap/core'\nimport type { CollectionBody, ComponentDefinition } from '@internal/protocol/Configuration'\nimport { Extension } from '@tiptap/core'\nimport { Plugin } from '@tiptap/pm/state'\nimport { ySyncPluginKey } from '@tiptap/y-tiptap'\nimport { CmsMarkdownDocument } from '@internal/protocol/Documents'\nimport { Effect, Predicate, Schema } from 'effect'\nimport { comarkToEditor } from './internal/comark/to-editor'\nimport { createCmsComarkRenderData } from './internal/comark/document-adapter'\nimport { createDocumentParser } from './internal/comark/grammar'\nimport { EditorDocumentInvalid } from './internal/editor/errors'\nimport { createEditorNodeId } from './internal/editor/identity'\n\nexport const parseAuthoringContent = Effect.fn('AuthoringSchema.parseContent')(function* (markdown: string) {\n const body = yield* Effect.tryPromise({\n try: () => createDocumentParser()(markdown),\n catch: (cause) => new EditorDocumentInvalid({ cause, message: 'Invalid initial Markdown content.' }),\n })\n\n const decoded = yield* Schema.decodeUnknownEffect(CmsMarkdownDocument)(body)\n\n return decoded.nodes\n})\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\nexport function collectionComponents(\n components: ReadonlyArray<ComponentDefinition>,\n body: CollectionBody | undefined,\n): ReadonlyArray<ComponentDefinition> {\n if (!body) return components\n\n return components.filter(\n (component) =>\n body.blocks?.includes(component.name) ||\n (component.authoring.group !== undefined && body.groups?.includes(component.authoring.group)),\n )\n}\n\n/** Configuration errors belong to developers, before an installation adopts the catalog. */\nexport function validateCollectionBody(\n components: ReadonlyArray<ComponentDefinition>,\n body: CollectionBody | undefined,\n): ReadonlyArray<string> {\n return [\n ...components.flatMap((component) =>\n component.authoring.slots.flatMap((slot) => [\n ...(slot.blocks ?? [])\n .filter((name) => !components.some((candidate) => candidate.name === name))\n .map((name) => `Unknown block \"${name}\" in ${slot.label}.`),\n ...(slot.groups ?? [])\n .filter((group) => !components.some((candidate) => candidate.authoring.group === group))\n .map((group) => `Unknown block group \"${group}\" in ${slot.label}.`),\n ]),\n ),\n ...(body?.blocks ?? [])\n .filter((name) => !components.some((component) => component.name === name))\n .map((name) => `Unknown block \"${name}\".`),\n ...(body?.groups ?? [])\n .filter((group) => !components.some((component) => component.authoring.group === group))\n .map((group) => `Unknown block group \"${group}\".`),\n ]\n}\n\nfunction contentIssues(\n node: JSONContent,\n schemas: ReadonlyMap<string, AuthoringSchema>,\n allowed: ReadonlySet<string>,\n purpose: 'working' | 'publish',\n collectionAllowed: ReadonlySet<string> = allowed,\n): string[] {\n const issues: string[] = []\n\n if (node.type === 'cmsBlock') {\n const name = String(node.attrs?.tag).toLowerCase()\n const schema = schemas.get(name)\n\n if (!schema) issues.push('This block is unavailable. Ask your site developer to restore its definition.')\n else {\n if (!allowed.has(name)) issues.push(`${schema.definition.label} is not allowed in this content region.`)\n issues.push(...schema.validate(node, purpose))\n\n if (purpose === 'publish' && schema.definition.form)\n issues.push(...formStructureIssues(node.attrs?.props?.steps, schema.definition.form, name))\n }\n }\n\n if (node.type === 'cmsOpaque' || node.type === 'cmsInlineOpaque')\n issues.push('This content is unsupported. Ask your site developer to update it before publishing.')\n\n if (node.type === 'cmsBlock') {\n const schema = schemas.get(String(node.attrs?.tag).toLowerCase())\n\n for (const region of node.content ?? []) {\n const slot = schema?.definition.slots.find((candidate) => candidate.name === region.attrs?.name)\n\n const permitted =\n slot?.input === 'blocks'\n ? new Set(\n collectionComponents(\n [...schemas].map(([name, schema]) => ({ name, authoring: schema.definition })),\n slot.blocks === undefined && slot.groups === undefined ? undefined : slot,\n )\n .map((component) => component.name)\n .filter((name) => collectionAllowed.has(name)),\n )\n : collectionAllowed\n\n issues.push(...contentIssues(region, schemas, permitted, purpose, collectionAllowed))\n }\n\n return issues\n }\n\n return [\n ...issues,\n ...(node.content ?? []).flatMap((child) => contentIssues(child, schemas, allowed, purpose, collectionAllowed)),\n ]\n}\n\nexport function validateAuthoringDocument(\n body: CmsMarkdownDocument,\n components: ReadonlyMap<string, ComponentDefinition> | undefined,\n bodyPolicy?: CollectionBody,\n): ReadonlyArray<string> {\n return components ? createAuthoringDocumentValidator(components)(body, bodyPolicy) : []\n}\n\n/** Resolves a component catalog once so document compilation can reuse its authoring rules. */\nexport function createAuthoringDocumentValidator(components: ReadonlyMap<string, ComponentDefinition>) {\n const definitions = [...components.values()]\n\n const schemas = new Map(\n definitions.map((component) => [component.name, createAuthoringSchema(component.name, component.authoring)]),\n )\n\n return (body: CmsMarkdownDocument, bodyPolicy?: CollectionBody): ReadonlyArray<string> => {\n const allowed = new Set(collectionComponents(definitions, bodyPolicy).map((component) => component.name))\n\n return comarkToEditor(body.nodes, createCmsComarkRenderData(body)).flatMap((node) =>\n contentIssues(node, schemas, allowed, 'publish'),\n )\n }\n}\n\nexport interface AuthoringSchema {\n readonly definition: BlockAuthoring\n readonly createContent: () => JSONContent\n readonly createSlot: (name: string) => JSONContent\n readonly setProperty: (current: Schema.JsonObject, name: string, value: Schema.Json | undefined) => Schema.JsonObject\n readonly validate: (node: JSONContent, purpose: 'working' | 'publish') => ReadonlyArray<string>\n}\n\nexport function createAuthoringSchema(name: string, definition: BlockAuthoring): AuthoringSchema {\n const fields = new Map(definition.props.map((field) => [field.name, field]))\n const slots = new Map(definition.slots.map((slot) => [slot.name, slot]))\n\n if (fields.size !== definition.props.length || slots.size !== definition.slots.length) {\n throw new Error(`${definition.label}: authoring names must be unique.`)\n }\n\n const initialProps = {\n ...Object.fromEntries(\n definition.props.flatMap((field) => (field.defaultValue === undefined ? [] : [[field.name, field.defaultValue]])),\n ),\n ...definition.initialProps,\n }\n\n for (const field of definition.props) {\n if (field.defaultValue === undefined) continue\n const issue = propertyIssue(field, field.defaultValue, 'working')\n\n if (issue) throw new Error(`Invalid default for ${definition.label}: ${issue}`)\n }\n\n function createSlot(slotName: string): JSONContent {\n const slot = slots.get(slotName)\n\n if (!slot) throw new Error(`${definition.label}: unknown content region ${slotName}.`)\n const content = slot.initial ? comarkToEditor(slot.initial) : []\n\n return {\n type: 'cmsSlot',\n attrs: { cmsNodeId: createEditorNodeId(), name: slotName, implicit: slotName === 'default', props: {} },\n content: content.length ? content : [{ type: 'paragraph', attrs: { cmsNodeId: createEditorNodeId() } }],\n }\n }\n\n function createContent(): JSONContent {\n return {\n type: 'cmsBlock',\n attrs: { cmsNodeId: createEditorNodeId(), tag: name, props: structuredClone(initialProps) },\n content: definition.slots\n .filter((slot) => slot.required || slot.initial !== undefined)\n .map((slot) => createSlot(slot.name)),\n }\n }\n\n function validate(node: JSONContent, purpose: 'working' | 'publish'): ReadonlyArray<string> {\n const issues: string[] = []\n const attributes = node.attrs?.props\n const values = isJsonObject(attributes) ? attributes : {}\n\n for (const key of Object.keys(values))\n if (!fields.has(key)) issues.push(`${definition.label}: ${key} is not editable.`)\n\n for (const field of definition.props) {\n const value = values[field.name] ?? (values[field.name] === null ? null : field.defaultValue)\n const issue = propertyIssue(field, value, purpose)\n\n if (issue) issues.push(issue)\n }\n\n const used = new Set<string>()\n\n for (const region of node.content ?? []) {\n const key = String(region.attrs?.name ?? 'default')\n const slot = slots.get(key)\n\n if (!slot || region.type !== 'cmsSlot') {\n issues.push(`${definition.label}: unsupported content region ${key}.`)\n continue\n }\n\n if (used.has(key)) issues.push(`${slot.label} can only appear once.`)\n used.add(key)\n\n if (!validRegion(slot, region.content ?? []))\n issues.push(`${slot.label} contains unsupported formatting or blocks.`)\n }\n\n for (const slot of definition.slots)\n if (slot.required && !used.has(slot.name)) issues.push(`${slot.label} is required.`)\n\n return issues\n }\n\n const schema: AuthoringSchema = {\n definition,\n createContent,\n createSlot,\n validate,\n setProperty(current: Schema.JsonObject, key: string, value: Schema.Json | undefined) {\n const field = fields.get(key)\n\n if (!field) throw new Error(`${definition.label}: ${key} is not editable.`)\n const issue = propertyIssue(field, value, 'working')\n\n if (issue) throw new Error(issue)\n const next = Object.fromEntries(Object.entries(current))\n\n if (value === undefined) delete next[key]\n else next[key] = value\n\n return next\n },\n }\n\n const issues = validate(createContent(), 'publish')\n\n if (issues.length) throw new Error(`Invalid initial content for ${definition.label}: ${issues.join(' ')}`)\n\n return schema\n}\n\nexport function selectedAuthoringSlot(\n editor: Editor,\n components: ReadonlyArray<ComponentDefinition>,\n): BlockSlot | undefined {\n const position = editor.state.selection.$from\n\n for (let depth = position.depth; depth > 0; depth--) {\n const region = position.node(depth)\n\n if (region.type.name !== 'cmsSlot') continue\n const block = position.node(depth - 1)\n\n return components\n .find((component) => component.name === block.attrs.tag)\n ?.authoring.slots.find((slot) => slot.name === region.attrs.name)\n }\n\n return undefined\n}\n\n/** Applies authoring rules to local edits. Remote CRDT updates always converge; publication validates them. */\nexport function createAuthoringExtension(\n components: () => ReadonlyArray<ComponentDefinition>,\n body: () => CollectionBody | undefined = () => undefined,\n): Extension {\n let previousComponents: ReadonlyArray<ComponentDefinition> | undefined\n let schemas = new Map<string, ReturnType<typeof createAuthoringSchema>>()\n\n function refresh() {\n const current = components()\n\n if (current === previousComponents) return\n previousComponents = current\n schemas = new Map(\n current.map((component) => [component.name, createAuthoringSchema(component.name, component.authoring)]),\n )\n }\n\n function issues(content: JSONContent): string[] {\n const allowed = new Set(collectionComponents(components(), body()).map((component) => component.name))\n\n return contentIssues(content, schemas, allowed, 'working')\n }\n\n return Extension.create({\n name: 'cmsAuthoringPolicy',\n addProseMirrorPlugins() {\n return [\n new Plugin({\n filterTransaction(transaction, state) {\n if (!transaction.docChanged || transaction.getMeta(ySyncPluginKey)?.isChangeOrigin) return true\n refresh()\n const previous = issues(state.doc.toJSON())\n\n return issues(transaction.doc.toJSON()).every((issue) => {\n const index = previous.indexOf(issue)\n\n if (index < 0) return false\n previous.splice(index, 1)\n\n return true\n })\n },\n }),\n ]\n },\n })\n}\n\nfunction propertyIssue(\n field: BlockProp,\n value: Schema.Json | undefined,\n purpose: 'working' | 'publish',\n): string | undefined {\n if (value === undefined) return field.required && purpose === 'publish' ? `${field.label} is required.` : undefined\n\n if (value === null && field.nullable) return undefined\n\n let valid: boolean\n\n if (field.type === 'string') valid = Predicate.isString(value)\n else if (field.type === 'number') valid = Predicate.isNumber(value) && Number.isFinite(value)\n else if (field.type === 'boolean') valid = Predicate.isBoolean(value)\n else if (field.type === 'array') valid = Array.isArray(value)\n else valid = isJsonObject(value)\n\n if (!valid) return `${field.label} must be ${field.type}.`\n\n if (field.type === 'object' || field.type === 'array') {\n const entries = Array.isArray(value) ? value : [value]\n const ids = new Set<string>()\n\n for (const entry of entries) {\n if (!isJsonObject(entry)) return `${field.label} must contain objects.`\n\n if (field.type === 'array') {\n const id = entry.id\n\n if (!Predicate.isString(id) || !id || ids.has(id)) return `${field.label} items need unique identities.`\n ids.add(id)\n }\n\n for (const key of Object.keys(entry))\n if (!(field.type === 'array' && key === 'id') && !field.fields?.some((child) => child.name === key))\n return `${field.label} contains an unavailable field.`\n\n for (const child of field.fields ?? []) {\n const issue = propertyIssue(child, entry[child.name], purpose)\n\n if (issue) return `${field.label}: ${issue}`\n }\n }\n }\n\n if (purpose === 'publish' && field.required && value === '' && (field.input === 'image' || field.input === 'link'))\n return `${field.label} is required.`\n\n if (\n purpose === 'publish' &&\n Predicate.isString(value) &&\n value &&\n (field.input === 'image' || field.input === 'link') &&\n !validAuthoringUrl(value, field.input)\n )\n return `${field.label} needs a valid ${field.input === 'image' ? 'image URL' : 'link'}.`\n\n if (field.options.length && !field.options.some((option) => option.value === value))\n return `${field.label} must use one of its available choices.`\n\n return undefined\n}\n\nfunction validRegion(slot: BlockSlot, content: ReadonlyArray<JSONContent>): boolean {\n if (slot.input === 'blocks')\n return content.every((node) => node.type === 'cmsBlock' || (node.type === 'paragraph' && !node.content?.length))\n const types = new Set(['paragraph', 'text', 'hardBreak'])\n const marks = new Set<string>()\n\n if (slot.input === 'text' && content.length > 1) return false\n\n if (slot.input === 'rich-text')\n for (const feature of slot.features) {\n if (feature === 'bullet-list') {\n types.add('bulletList')\n types.add('listItem')\n } else marks.add(feature)\n }\n\n const valid = (node: JSONContent): boolean =>\n types.has(node.type ?? '') &&\n (node.marks ?? []).every((mark) => marks.has(mark.type)) &&\n (node.content ?? []).every(valid)\n\n return content.every(valid)\n}\n\n/** URL values remain ordinary Vue strings and use the document model's public paths. */\nexport function validAuthoringUrl(value: string, input: 'image' | 'link'): boolean {\n if (value.trim() !== value || value.includes('\\\\')) return false\n\n for (const character of value) if (character.charCodeAt(0) <= 32) return false\n\n if (value.startsWith('/') && !value.startsWith('//')) return true\n\n if (input === 'link' && value.startsWith('#')) return true\n\n try {\n const url = new URL(value)\n\n return ['https:', 'http:', ...(input === 'link' ? ['mailto:', 'tel:'] : [])].includes(url.protocol)\n } catch {\n return false\n }\n}\n\nexport function createAuthoringItem(fields: ReadonlyArray<BlockProp>, list = false): Schema.JsonObject {\n return {\n ...(list ? { id: createEditorNodeId() } : undefined),\n ...Object.fromEntries(\n fields.flatMap((field) =>\n field.required || field.defaultValue !== undefined\n ? [[field.name, field.defaultValue ?? defaultAuthoringValue(field)]]\n : [],\n ),\n ),\n }\n}\n\nfunction defaultAuthoringValue(field: BlockProp): Schema.Json {\n if (field.type === 'object') return createAuthoringItem(field.fields ?? [])\n\n if (field.type === 'array') return []\n\n if (field.type === 'number') return 0\n\n if (field.type === 'boolean') return false\n\n return field.options[0]?.value ?? ''\n}\n","import { Schema } from 'effect'\nimport { FormCapabilities } from './Forms'\nimport { MarkdownNode } from './internal/documents/models'\n\nexport interface BlockProp {\n readonly name: string\n readonly label: string\n readonly help?: string\n readonly type: 'string' | 'number' | 'boolean' | 'object' | 'array'\n readonly input: 'text' | 'textarea' | 'select' | 'number' | 'toggle' | 'image' | 'link' | 'object' | 'list'\n readonly required: boolean\n readonly nullable: boolean\n readonly defaultValue?: Schema.Json\n readonly options: ReadonlyArray<{ readonly value: string; readonly label: string }>\n readonly fields?: ReadonlyArray<BlockProp>\n}\n\nexport const BlockProp: Schema.Codec<BlockProp> = Schema.Struct({\n name: Schema.NonEmptyString,\n label: Schema.NonEmptyString,\n help: Schema.optionalKey(Schema.String),\n type: Schema.Literals(['string', 'number', 'boolean', 'object', 'array']),\n input: Schema.Literals(['text', 'textarea', 'select', 'number', 'toggle', 'image', 'link', 'object', 'list']),\n required: Schema.Boolean,\n nullable: Schema.Boolean,\n defaultValue: Schema.optionalKey(Schema.Json),\n fields: Schema.optionalKey(Schema.Array(Schema.suspend(() => BlockProp))),\n options: Schema.Array(Schema.Struct({ value: Schema.String, label: Schema.String })),\n})\n\nexport const BlockSlot = Schema.Struct({\n name: Schema.NonEmptyString,\n label: Schema.NonEmptyString,\n help: Schema.optionalKey(Schema.String),\n required: Schema.Boolean,\n input: Schema.Literals(['text', 'rich-text', 'blocks']),\n blocks: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n groups: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n features: Schema.Array(Schema.Literals(['bold', 'italic', 'link', 'bullet-list', 'code'])),\n initial: Schema.optionalKey(Schema.Array(MarkdownNode)),\n})\n\nexport interface BlockSlot extends Schema.Schema.Type<typeof BlockSlot> {}\n\nexport const BlockAuthoring = Schema.Struct({\n version: Schema.Literal(1),\n form: Schema.optionalKey(FormCapabilities),\n label: Schema.NonEmptyString,\n description: Schema.optionalKey(Schema.String),\n group: Schema.optionalKey(Schema.String),\n icon: Schema.optionalKey(Schema.String),\n props: Schema.Array(BlockProp),\n slots: Schema.Array(BlockSlot),\n initialProps: Schema.JsonObject,\n})\n\nexport interface BlockAuthoring extends Schema.Schema.Type<typeof BlockAuthoring> {}\n","import { Schema } from 'effect'\nimport { BlockAuthoring } from './Authoring'\nimport { AddressPattern, CollectionName, Locale, SourceDirectory } from './internal/configuration/scalars'\n\nexport { AddressPattern, CollectionName, Locale, SourceDirectory } from './internal/configuration/scalars'\n\nconst fieldPresentation = {\n path: Schema.NonEmptyString,\n label: Schema.NonEmptyString,\n description: Schema.optionalKey(Schema.String),\n defaultValue: Schema.optionalKey(Schema.Json),\n required: Schema.Boolean,\n}\n\nconst BooleanAuthoringField = Schema.Struct({\n type: Schema.tag('boolean'),\n ...fieldPresentation,\n input: Schema.Literal('toggle'),\n})\n\nconst DateAuthoringField = Schema.Struct({\n type: Schema.tag('date'),\n ...fieldPresentation,\n input: Schema.Literal('date'),\n})\n\nconst NumberAuthoringField = Schema.Struct({\n type: Schema.tag('number'),\n ...fieldPresentation,\n input: Schema.Literals(['number', 'select']),\n options: Schema.Array(Schema.Finite),\n})\n\nconst StringAuthoringField = Schema.Struct({\n type: Schema.tag('string'),\n ...fieldPresentation,\n input: Schema.Literals(['select', 'text', 'textarea']),\n options: Schema.Array(Schema.String),\n})\n\nconst StringArrayAuthoringField = Schema.Struct({\n type: Schema.tag('string[]'),\n ...fieldPresentation,\n input: Schema.Literal('multiselect'),\n options: Schema.Array(Schema.String),\n})\n\nexport const DocumentField = Schema.Union([\n BooleanAuthoringField,\n DateAuthoringField,\n NumberAuthoringField,\n StringArrayAuthoringField,\n StringAuthoringField,\n])\n\nexport type DocumentField = typeof DocumentField.Type\n\nexport const CollectionBody = Schema.Struct({\n blocks: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n groups: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n})\n\nexport interface CollectionBody extends Schema.Schema.Type<typeof CollectionBody> {}\n\nexport const CollectionDefinition = Schema.Struct({\n collection: CollectionName,\n body: Schema.optionalKey(CollectionBody),\n label: Schema.NonEmptyString,\n description: Schema.String,\n directory: SourceDirectory,\n addressPattern: AddressPattern,\n hierarchy: Schema.Boolean,\n canCreate: Schema.Boolean,\n authoringFields: Schema.Array(DocumentField),\n}).annotate({ identifier: 'CollectionDefinition' })\n\nexport interface CollectionDefinition extends Schema.Schema.Type<typeof CollectionDefinition> {}\n\nexport const LocaleConfiguration = Schema.Struct({\n locales: Schema.Array(Locale),\n defaultLocale: Locale,\n fallbackLocale: Schema.NullOr(Locale),\n prefixDefaultLocale: Schema.Boolean,\n}).annotate({ identifier: 'LocaleConfiguration' })\n\nexport interface LocaleConfiguration extends Schema.Schema.Type<typeof LocaleConfiguration> {}\n\nexport const DocumentConfiguration = Schema.Struct({\n types: Schema.Array(CollectionDefinition),\n locales: Schema.optionalKey(LocaleConfiguration),\n}).annotate({ identifier: 'DocumentConfiguration' })\n\nexport interface DocumentConfiguration extends Schema.Schema.Type<typeof DocumentConfiguration> {}\n\nexport const ComponentDefinition = Schema.Struct({\n authoring: BlockAuthoring,\n name: Schema.NonEmptyString,\n}).annotate({ identifier: 'ComponentDefinition' })\n\nexport interface ComponentDefinition extends Schema.Schema.Type<typeof ComponentDefinition> {}\n\nexport const AuthoringCatalog = Schema.Struct({\n revision: Schema.NonEmptyString,\n components: Schema.Array(ComponentDefinition),\n})\n\nexport interface AuthoringCatalog extends Schema.Schema.Type<typeof AuthoringCatalog> {}\n\nexport const MediaConfiguration = Schema.Struct({\n enabled: Schema.Boolean,\n maxUploadBytes: Schema.Int.check(Schema.isGreaterThan(0)),\n})\n\nexport interface MediaConfiguration extends Schema.Schema.Type<typeof MediaConfiguration> {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAEA,SAAgB,sBACd,YACmB;CACnB,OAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,QAAQ,UAA0C,MAAM,OAAO,MAAS,CACrG;AACF;AAEA,SAAgB,wBAAwB,OAAoD;CAC1F,OAAO,UAAU,SAAS,KAAK,KAAK,QAAQ,QAAQ;AACtD;AAEA,SAAgB,sBAAsB,OAAgC,UAA0B;CAC9F,MAAM,SAAS,UAAU,SAAS,KAAK,IAAI,QAAQ,OAAO,KAAK;CAE/D,OAAO,OAAO,SAAS,MAAM,IAAI,SAAS;AAC5C;;;;ACfA,MAAMA,iBAAe,OAAO,GAAG,OAAO,UAAU;AAMhD,MAAM,oBAAoB,OAAO,SAAS;CAJZ;CAAW;CAAW;AAIS,CAAC;AAE9D,MAAM,sBAAsB,OAAO,GAAG,iBAAiB;AAEvD,MAAa,gCAAgC;AAE7C,MAAM,6BAA6B;AAEnC,MAAM,4CAA4B,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,4BAA4B,YAAkD;CAC5F,MAAM,WAAW,OAAO,YACtB,OAAO,QAAQ,UAAU,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,0BAA0B,IAAI,IAAI,CAAC,CACpF;CAEA,OAAO,sBAAsB;EAC3B,KACE,WAAW,gCAAgC,SACvC,KACA,UAAU,SAAS,WAAW,GAAG,IAC/B,WAAW,MACX;EACR,UAAU,OAAO,KAAK,QAAQ,CAAC,CAAC,SAAS,WAAW;EACpD,QAAQ,2BAA2B,WAAW,8BAA8B;EAC5E,KAAK,YAAY,WAAW,GAAG,KAAK;EACpC,OAAO,YAAY,WAAW,KAAK,KAAK;CAC1C,CAAC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AAO,YAAY,OAAO,MAAM,OAAO,cAAc,CAAC;AAChE,CAAC;AAID,MAAa,uBAAuB,OAAO,OAAO;CAChD,YAAY;CACZ,MAAM,OAAO,YAAY,cAAc;CACvC,OAAO,OAAO;CACd,aAAa,OAAO;CACpB,WAAW;CACX,gBAAgB;CAChB,WAAW,OAAO;CAClB,WAAW,OAAO;CAClB,iBAAiB,OAAO,MAAM,aAAa;AAC7C,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,uBAAuB,CAAC;AAIlD,MAAa,sBAAsB,OAAO,OAAO;CAC/C,SAAS,OAAO,MAAM,MAAM;CAC5B,eAAe;CACf,gBAAgB,OAAO,OAAO,MAAM;CACpC,qBAAqB,OAAO;AAC9B,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,sBAAsB,CAAC;AAIjD,MAAa,wBAAwB,OAAO,OAAO;CACjD,OAAO,OAAO,MAAM,oBAAoB;CACxC,SAAS,OAAO,YAAY,mBAAmB;AACjD,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,wBAAwB,CAAC;AAInD,MAAa,sBAAsB,OAAO,OAAO;CAC/C,WAAW;CACX,MAAM,OAAO;AACf,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,sBAAsB,CAAC;AAIjD,MAAa,mBAAmB,OAAO,OAAO;CAC5C,UAAU,OAAO;CACjB,YAAY,OAAO,MAAM,mBAAmB;AAC9C,CAAC;AAID,MAAa,qBAAqB,OAAO,OAAO;CAC9C,SAAS,OAAO;CAChB,gBAAgB,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AAC1D,CAAC"}
1
+ {"version":3,"file":"Configuration-CjVUBBwa.js","names":["isJsonObject","jsonObject","comarkToEditor","isJsonObject","isElementNode"],"sources":["../../../../document/src/internal/editor/attributes.ts","../../../../document/src/internal/editor/image.ts","../../../../document/src/internal/editor/marks.ts","../../../../document/src/internal/comark/to-editor.ts","../../../../document/src/internal/comark/source-mapping.ts","../../../../document/src/internal/comark/grammar.ts","../../../../document/src/internal/editor/errors.ts","../../../../document/src/AuthoringSchema.ts","../../../../protocol/src/Authoring.ts","../../../../protocol/src/Configuration.ts"],"sourcesContent":["import { Predicate, Schema } from 'effect'\n\nexport function compactJsonAttributes(\n attributes: Readonly<Record<string, Schema.Json | undefined>>,\n): Schema.JsonObject {\n return Object.fromEntries(\n Object.entries(attributes).filter((entry): entry is [string, Schema.Json] => entry[1] !== undefined),\n )\n}\n\nexport function nonEmptyStringAttribute(value: Schema.Json | undefined): string | undefined {\n return Predicate.isString(value) && value ? value : undefined\n}\n\nexport function finiteNumberAttribute(value: Schema.Json | undefined, fallback: number): number {\n const number = Predicate.isNumber(value) ? value : Number(value)\n\n return Number.isFinite(number) ? number : fallback\n}\n","import { Predicate, Schema } from 'effect'\nimport { compactJsonAttributes } from './attributes'\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\nconst EDITOR_IMAGE_LAYOUTS = ['natural', 'content', 'full'] as const\n\nexport type EditorImageLayout = (typeof EDITOR_IMAGE_LAYOUTS)[number]\n\nconst EditorImageLayout = Schema.Literals(EDITOR_IMAGE_LAYOUTS)\n\nconst isEditorImageLayout = Schema.is(EditorImageLayout)\n\nexport const EDITOR_IMAGE_LAYOUT_ATTRIBUTE = 'data-cms-layout'\n\nconst IMAGE_DECORATIVE_ATTRIBUTE = 'data-cms-decorative'\n\nconst IMAGE_SEMANTIC_ATTRIBUTES = new Set([\n 'alt',\n IMAGE_DECORATIVE_ATTRIBUTE,\n EDITOR_IMAGE_LAYOUT_ATTRIBUTE,\n 'src',\n 'title',\n])\n\nexport function decodeEditorImageAttributes(attributes: Schema.JsonObject): Schema.JsonObject {\n const cmsProps = Object.fromEntries(\n Object.entries(attributes).filter(([name]) => !IMAGE_SEMANTIC_ATTRIBUTES.has(name)),\n )\n\n return compactJsonAttributes({\n alt:\n attributes[IMAGE_DECORATIVE_ATTRIBUTE] !== undefined\n ? ''\n : Predicate.isString(attributes.alt)\n ? attributes.alt\n : null,\n cmsProps: Object.keys(cmsProps).length ? cmsProps : null,\n layout: normalizeEditorImageLayout(attributes[EDITOR_IMAGE_LAYOUT_ATTRIBUTE]),\n src: stringValue(attributes.src) || null,\n title: stringValue(attributes.title) || null,\n })\n}\n\nexport function encodeEditorImageAttributes(value: Schema.JsonObject | undefined): Schema.JsonObject {\n const attributes = jsonObject(value)\n const alt = attributes.alt\n const layout = normalizeEditorImageLayout(attributes.layout)\n\n return compactJsonAttributes(\n Object.assign({}, jsonObject(attributes.cmsProps), {\n alt: Predicate.isString(alt) ? alt : undefined,\n [IMAGE_DECORATIVE_ATTRIBUTE]: alt === '' ? 'true' : undefined,\n [EDITOR_IMAGE_LAYOUT_ATTRIBUTE]: layout === 'natural' ? undefined : layout,\n src: stringValue(attributes.src) || undefined,\n title: stringValue(attributes.title) || undefined,\n }),\n )\n}\n\nexport function normalizeEditorImageLayout(value: Schema.Json | undefined): EditorImageLayout {\n return isEditorImageLayout(value) ? value : 'natural'\n}\n\nfunction jsonObject(value: Schema.Json | undefined): Schema.JsonObject {\n return isJsonObject(value) ? value : {}\n}\n\nfunction stringValue(value: Schema.Json | undefined): string {\n return Predicate.isString(value) || Predicate.isNumber(value) ? String(value) : ''\n}\n","const EDITOR_MARKS = [\n ['bold', 'strong'],\n ['code', 'code'],\n ['italic', 'em'],\n ['link', 'a'],\n ['strike', 'del'],\n ['underline', 'u'],\n] as const\n\nexport const EDITOR_MARK_TYPES = EDITOR_MARKS.map(([type]) => type)\n\nconst editorToComark = new Map<string, string>(EDITOR_MARKS)\n\nconst comarkToEditor = new Map<string, string>(EDITOR_MARKS.map(([type, tag]) => [tag, type]))\n\nexport function comarkTagForEditorMark(type: string): string | undefined {\n return editorToComark.get(type)\n}\n\nexport function editorMarkForComarkTag(tag: string): string | undefined {\n return comarkToEditor.get(tag)\n}\n\nexport function isEditorMark(type: string): boolean {\n return editorToComark.has(type)\n}\n\nexport function isComarkMark(tag: string): boolean {\n return comarkToEditor.has(tag)\n}\n","import type { MarkdownNode } from '@internal/protocol/Documents'\nimport type { EditorNodeId } from '@internal/protocol/Documents'\nimport type { JSONContent } from '@tiptap/core'\nimport type { NodeRenderData } from 'comark'\nimport { Predicate, Schema } from 'effect'\nimport { projectCmsEditorComponentAttributes, resolveCmsComarkAttributes, withCmsComarkProps } from './bindings'\nimport { editorNodeId, createEditorNodeId } from '../editor/identity'\nimport { decodeEditorImageAttributes } from '../editor/image'\nimport { editorMetadata } from '../editor/metadata'\nimport { compactJsonAttributes, finiteNumberAttribute, nonEmptyStringAttribute } from '../editor/attributes'\nimport { editorMarkForComarkTag, isComarkMark } from '../editor/marks'\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\ntype ElementMarkdownNode = Extract<MarkdownNode, readonly [string, Schema.JsonObject, ...MarkdownNode[]]>\n\ninterface DecodeContext {\n readonly usedIds: Set<EditorNodeId>\n}\n\nconst OPAQUE_BLOCK_TAGS = new Set(['math', 'table', 'tbody', 'td', 'th', 'thead', 'tr'])\n\nexport function comarkToEditor(\n nodes: ReadonlyArray<MarkdownNode>,\n renderData: NodeRenderData = { data: {}, frontmatter: {}, meta: {}, props: {} },\n): JSONContent[] {\n return decodeBlocks(\n nodes,\n {\n usedIds: new Set(),\n },\n renderData,\n )\n}\n\nfunction decodeBlocks(\n nodes: ReadonlyArray<MarkdownNode>,\n context: DecodeContext,\n renderData: NodeRenderData,\n wrapInlineContent = false,\n): JSONContent[] {\n const content: JSONContent[] = []\n let inlineNodes: MarkdownNode[] = []\n\n const flushInlineNodes = () => {\n const inline = decodeInlines(inlineNodes, context, renderData)\n\n if (inline.length) {\n content.push({\n type: 'paragraph',\n attrs: wrapInlineContent ? { cmsSynthetic: true } : { cmsNodeId: claimIdentity(context) },\n content: inline,\n })\n }\n\n inlineNodes = []\n }\n\n for (const node of nodes) {\n if (Predicate.isString(node) || isInlineElement(node)) {\n inlineNodes.push(node)\n continue\n }\n\n flushInlineNodes()\n content.push(decodeBlock(node, context, renderData))\n }\n\n flushInlineNodes()\n\n return content\n}\n\nfunction decodeBlock(\n node: Exclude<MarkdownNode, string>,\n context: DecodeContext,\n renderData: NodeRenderData,\n): JSONContent {\n if (node[0] === null) {\n return opaqueBlock(node, 'Comment', claimIdentity(context, node[1]))\n }\n\n const [tag, rawAttributes, ...children] = node\n const attrs = cleanAttrs(rawAttributes)\n const childRenderData = withCmsComarkProps(renderData, resolveCmsComarkAttributes(rawAttributes, renderData))\n const metadata = editorMetadata(rawAttributes)\n const cmsNodeId = claimIdentity(context, rawAttributes)\n\n const commonAttrs = compactJsonAttributes({\n cmsNodeId,\n cmsProps: attrs,\n })\n\n if (/^h[1-6]$/u.test(tag)) {\n return {\n type: 'heading',\n attrs: mergeJsonAttributes(commonAttrs, { level: Number(tag.slice(1)) }),\n content: decodeInlines(children, context, childRenderData),\n }\n }\n\n switch (tag) {\n case 'p':\n return { type: 'paragraph', attrs: commonAttrs, content: decodeInlines(children, context, childRenderData) }\n case 'blockquote':\n return {\n type: 'blockquote',\n attrs: commonAttrs,\n content: decodeBlocks(children, context, childRenderData),\n }\n case 'ul':\n return {\n type: 'bulletList',\n attrs: commonAttrs,\n content: decodeListItems(children, context, childRenderData),\n }\n case 'ol':\n return {\n type: 'orderedList',\n attrs: mergeJsonAttributes(commonAttrs, { start: finiteNumberAttribute(attrs.start, 1) }),\n content: decodeListItems(children, context, childRenderData),\n }\n case 'li':\n return {\n type: 'listItem',\n attrs: commonAttrs,\n content: decodeBlocks(children, context, childRenderData),\n }\n case 'pre': {\n const code = children.find(isElementNode)\n\n const language =\n nonEmptyStringAttribute(attrs.language) ?? nonEmptyStringAttribute(code?.[1].class)?.replace(/^language-/u, '')\n\n return {\n type: 'codeBlock',\n attrs: mergeJsonAttributes(commonAttrs, { language }),\n content: textContent(code ? elementChildren(code) : children),\n }\n }\n\n case 'hr':\n return { type: 'horizontalRule', attrs: commonAttrs }\n default:\n if (OPAQUE_BLOCK_TAGS.has(tag)) return opaqueBlock(node, tag, cmsNodeId)\n const projection = projectCmsEditorComponentAttributes(rawAttributes, renderData)\n\n return {\n type: 'cmsBlock',\n attrs: compactJsonAttributes({\n bindings: projection.bindings,\n cmsNodeId,\n props: projection.props,\n tag,\n }),\n content: decodeComponentSlots(children, context, projection.renderData, metadata?.implicitSlotId),\n }\n }\n}\n\nfunction decodeComponentSlots(\n children: ReadonlyArray<MarkdownNode>,\n context: DecodeContext,\n renderData: NodeRenderData,\n implicitSlotId?: EditorNodeId,\n): JSONContent[] {\n const templates = children.filter(isSlotTemplate)\n const regular = children.filter((node) => !isSlotTemplate(node))\n const slots = templates.map((node) => decodeSlot(node, context, renderData))\n\n if (!regular.length) return slots\n\n const defaultContent = slotContent(decodeBlocks(regular, context, renderData, true))\n const explicitDefault = slots.find((slot) => slot.attrs?.name === 'default')\n\n if (explicitDefault) {\n explicitDefault.content = [...(explicitDefault.content ?? []), ...defaultContent]\n\n return slots\n }\n\n return [\n {\n type: 'cmsSlot',\n attrs: {\n cmsNodeId: claimIdentityValue(context, implicitSlotId),\n implicit: true,\n name: 'default',\n props: {},\n },\n content: defaultContent,\n },\n ...slots,\n ]\n}\n\nfunction decodeSlot(node: ElementMarkdownNode, context: DecodeContext, renderData: NodeRenderData): JSONContent {\n const attrs = cleanAttrs(node[1])\n const childRenderData = withCmsComarkProps(renderData, resolveCmsComarkAttributes(node[1], renderData))\n const name = slotName(attrs)\n const { name: _name, ...slotProps } = attrs\n\n return {\n type: 'cmsSlot',\n attrs: {\n cmsNodeId: claimIdentity(context, node[1]),\n implicit: false,\n name,\n props: slotProps,\n },\n content: slotContent(decodeBlocks(elementChildren(node), context, childRenderData, true)),\n }\n}\n\nfunction decodeListItems(\n nodes: ReadonlyArray<MarkdownNode>,\n context: DecodeContext,\n renderData: NodeRenderData,\n): JSONContent[] {\n return nodes.flatMap((node) =>\n isElementNode(node) && node[0] === 'li' ? [decodeBlock(node, context, renderData)] : [],\n )\n}\n\nfunction decodeInlines(\n nodes: ReadonlyArray<MarkdownNode>,\n context: DecodeContext,\n renderData: NodeRenderData,\n inheritedMarks: NonNullable<JSONContent['marks']> = [],\n): JSONContent[] {\n const result: JSONContent[] = []\n\n for (const node of nodes) {\n if (Predicate.isString(node)) {\n if (node) {\n result.push(withMarks({ type: 'text', text: node }, inheritedMarks))\n }\n\n continue\n }\n\n if (node[0] === null) {\n result.push(\n withMarks(\n {\n type: 'cmsInlineOpaque',\n attrs: { label: 'Comment', node: stripInternalMetadata(node) },\n },\n inheritedMarks,\n ),\n )\n continue\n }\n\n const markType = editorMarkForComarkTag(node[0])\n\n if (markType) {\n const attrs = cleanAttrs(node[1])\n const childRenderData = withCmsComarkProps(renderData, resolveCmsComarkAttributes(node[1], renderData))\n\n const markAttrs =\n markType === 'link'\n ? mergeJsonAttributes(attrs, { cmsProps: attrs })\n : Object.keys(attrs).length\n ? { cmsProps: attrs }\n : undefined\n\n const mark = markAttrs === undefined ? { type: markType } : { attrs: markAttrs, type: markType }\n result.push(...decodeInlines(elementChildren(node), context, childRenderData, [...inheritedMarks, mark]))\n continue\n }\n\n if (node[0] === 'br') {\n result.push(withMarks({ type: 'hardBreak' }, inheritedMarks))\n continue\n }\n\n if (node[0] === 'img') {\n result.push(\n withMarks(\n {\n type: 'image',\n attrs: mergeJsonAttributes(decodeEditorImageAttributes(cleanAttrs(node[1])), {\n cmsNodeId: claimIdentity(context, node[1]),\n }),\n },\n inheritedMarks,\n ),\n )\n continue\n }\n\n result.push(\n withMarks(\n {\n type: 'cmsInlineOpaque',\n attrs: {\n label: node[0],\n node: stripInternalMetadata(node),\n },\n },\n inheritedMarks,\n ),\n )\n }\n\n return result\n}\n\nfunction claimIdentity(context: DecodeContext, attributes?: Schema.JsonObject): EditorNodeId {\n return claimIdentityValue(context, attributes ? editorMetadata(attributes)?.nodeId : undefined)\n}\n\nfunction claimIdentityValue(context: DecodeContext, candidate?: Schema.Json): EditorNodeId {\n const existing = editorNodeId(candidate)\n\n if (existing !== undefined && !context.usedIds.has(existing)) {\n context.usedIds.add(existing)\n\n return existing\n }\n\n for (let attempt = 0; attempt < 100; attempt++) {\n const created = createEditorNodeId()\n\n if (!context.usedIds.has(created)) {\n context.usedIds.add(created)\n\n return created\n }\n }\n\n throw new Error('The editor identity factory did not produce a unique identity.')\n}\n\nfunction opaqueBlock(node: Exclude<MarkdownNode, string>, label: string, cmsNodeId: EditorNodeId): JSONContent {\n return {\n type: 'cmsOpaque',\n attrs: {\n cmsNodeId,\n label,\n node: stripInternalMetadata(node),\n },\n }\n}\n\nfunction stripInternalMetadata(node: Exclude<MarkdownNode, string>): Exclude<MarkdownNode, string> {\n if (node[0] === null) return [null, cleanAttrs(node[1]), node[2]]\n const [tag, attributes, ...children] = node\n const clean = cleanAttrs(attributes)\n\n return [tag, clean, ...children.map((child) => (Predicate.isString(child) ? child : stripInternalMetadata(child)))]\n}\n\nfunction slotContent(content: JSONContent[]): JSONContent[] {\n return content.length ? content : [{ type: 'paragraph', attrs: { cmsSynthetic: true } }]\n}\n\nfunction slotName(attrs: Schema.JsonObject): string {\n return nonEmptyStringAttribute(attrs.name) ?? 'default'\n}\n\nfunction cleanAttrs(attrs: Schema.JsonObject): Schema.JsonObject {\n const { $: _internal, 'data-cms-node': _marker, ...clean } = attrs\n\n return structuredClone(clean)\n}\n\nfunction textContent(nodes: ReadonlyArray<MarkdownNode>): JSONContent[] | undefined {\n const text = nodes\n .map((node) =>\n Predicate.isString(node)\n ? node\n : node[0] === null\n ? node[2]\n : (textContent(elementChildren(node))\n ?.map((child) => child.text ?? '')\n .join('') ?? ''),\n )\n .join('')\n\n return text ? [{ type: 'text', text }] : undefined\n}\n\nfunction isInlineElement(node: Exclude<MarkdownNode, string>): boolean {\n return (\n node[0] !== null &&\n (isComarkMark(node[0]) || node[0] === 'br' || node[0] === 'img' || jsonObject(node[1].$).block === 0)\n )\n}\n\nfunction isSlotTemplate(node: MarkdownNode): node is ElementMarkdownNode {\n return isElementNode(node) && node[0] === 'template'\n}\n\nfunction isElementNode(node: MarkdownNode | undefined): node is ElementMarkdownNode {\n return Array.isArray(node) && Predicate.isString(node[0])\n}\n\nfunction elementChildren(node: ElementMarkdownNode): MarkdownNode[] {\n const [, , ...children] = node\n\n return children\n}\n\nfunction jsonObject(value: Schema.Json | undefined): Schema.JsonObject {\n return isJsonObject(value) ? value : {}\n}\n\nfunction mergeJsonAttributes(\n attributes: Schema.JsonObject,\n additions: Readonly<Record<string, Schema.Json | undefined>>,\n): Schema.JsonObject {\n return compactJsonAttributes(Object.assign({}, attributes, additions))\n}\n\nfunction withMarks(content: JSONContent, marks: NonNullable<JSONContent['marks']>): JSONContent {\n return marks.length ? Object.assign({}, content, { marks }) : content\n}\n","import type { DocumentSourceMapping, DocumentSourcePoint, DocumentSourceRange } from '@internal/protocol/Documents'\nimport type { ComarkParsePostState, ComarkParsePreState, ComarkPlugin, ElementNode, Node } from 'comark'\nimport { Option, Predicate, Schema } from 'effect'\n\nexport const SOURCE_MAPPINGS_META_KEY = '__cmsSourceMappings'\n\ninterface SourceMapParseState {\n __cmsOriginalMarkdown?: string\n parsedLines?: number\n}\n\ninterface ComarkToken extends Schema.Schema.Type<typeof ComarkToken> {}\n\ninterface BlockDescriptor {\n readonly children: BlockDescriptor[]\n range: DocumentSourceRange\n readonly tag: string\n}\n\nconst BLOCK_TAGS = new Map([\n ['blockquote_open', 'blockquote'],\n ['bullet_list_open', 'ul'],\n ['list_item_open', 'li'],\n ['ordered_list_open', 'ol'],\n ['paragraph_open', 'p'],\n ['table_open', 'table'],\n ['tbody_open', 'tbody'],\n ['td_open', 'td'],\n ['th_open', 'th'],\n ['thead_open', 'thead'],\n ['tr_open', 'tr'],\n])\n\nconst ComarkToken = Schema.Struct({\n attrs: Schema.optionalKey(Schema.NullOr(Schema.Array(Schema.Tuple([Schema.String, Schema.String])))),\n hidden: Schema.optionalKey(Schema.Boolean),\n level: Schema.optionalKey(Schema.Finite),\n map: Schema.optionalKey(Schema.NullOr(Schema.Tuple([Schema.Finite, Schema.Finite]))),\n nesting: Schema.optionalKey(Schema.Finite),\n tag: Schema.optionalKey(Schema.String),\n type: Schema.optionalKey(Schema.String),\n})\n\nconst WRAPPER_TAGS = new Set(['blockquote', 'ol', 'pre', 'table', 'ul'])\n\nexport function sourceCapturePlugin(): ComarkPlugin {\n return {\n name: 'cms-source-capture',\n pre(state: ComarkParsePreState & SourceMapParseState) {\n state.__cmsOriginalMarkdown = state.markdown\n },\n }\n}\n\nexport function sourceMappingPlugin(): ComarkPlugin {\n return {\n name: 'cms-source-mapping',\n post(state: ComarkParsePostState & SourceMapParseState) {\n const source = state.__cmsOriginalMarkdown ?? state.markdown\n\n const descriptors = createBlockDescriptors(\n state.tokens.flatMap((token) => {\n const decoded = Schema.decodeUnknownOption(ComarkToken)(token)\n\n return Option.isSome(decoded) ? [decoded.value] : []\n }),\n source,\n state.markdown,\n state.parsedLines ?? 0,\n )\n\n const mappings: DocumentSourceMapping[] = []\n mapNodes(state.tree.nodes, descriptors, [], mappings)\n state.tree.meta[SOURCE_MAPPINGS_META_KEY] = mappings\n },\n }\n}\n\nfunction createBlockDescriptors(\n tokens: ReadonlyArray<ComarkToken>,\n source: string,\n parsedMarkdown: string,\n parsedLines: number,\n): BlockDescriptor[] {\n const roots: BlockDescriptor[] = []\n const stack: Array<{ descriptor: BlockDescriptor; level: number }> = []\n const sourceLineStarts = indexLineStarts(source)\n const parsedLineStarts = indexLineStarts(parsedMarkdown)\n const parsedOffset = source.lastIndexOf(parsedMarkdown)\n const slotMaps = createSlotTokenMaps(tokens, parsedMarkdown)\n\n for (let tokenIndex = 0; tokenIndex < tokens.length; tokenIndex++) {\n const token = tokens[tokenIndex]\n\n if (!token) continue\n const tag = blockTag(token)\n const tokenMap = token.map ?? slotMaps.get(tokenIndex)\n\n if (!tag || !tokenMap) continue\n\n const level = token.level ?? 0\n\n while (true) {\n const current = stack.at(-1)\n\n if (!current || current.level < level) break\n stack.pop()\n }\n\n const descriptor: BlockDescriptor = {\n children: [],\n range: rangeFromParsedLines(\n source,\n sourceLineStarts,\n parsedMarkdown,\n parsedLineStarts,\n parsedOffset,\n tokenMap[0],\n tokenMap[1] + (token.type === 'mdc_block_open' ? 1 : 0),\n parsedLines,\n ),\n tag,\n }\n\n const parent = stack.at(-1)?.descriptor\n\n ;(parent?.children ?? roots).push(descriptor)\n\n if (token.nesting === 1) stack.push({ descriptor, level })\n }\n\n return roots.map(collapseComarkWrapper).map(groupProjectedSlotContent)\n}\n\nfunction blockTag(token: ComarkToken): string | undefined {\n if (token.hidden || !token.type) return undefined\n\n if (token.type === 'heading_open') return token.tag\n\n if (token.type === 'mdc_block_open' || (token.type === 'mdc_block_shorthand' && token.nesting !== -1))\n return token.tag || 'component'\n\n if (token.type === 'mdc_block_slot' && token.nesting === 1) return 'template'\n\n if (['fence', 'fenced_code_block', 'code_block'].includes(token.type)) return 'pre'\n\n if (token.type === 'math_block') return 'math'\n\n if (token.type === 'html_block') return '*'\n\n if (token.type === 'hr') return 'hr'\n\n return BLOCK_TAGS.get(token.type)\n}\n\nfunction createSlotTokenMaps(\n tokens: ReadonlyArray<ComarkToken>,\n parsedMarkdown: string,\n): Map<number, [number, number]> {\n const maps = new Map<number, [number, number]>()\n const markers = slotMarkers(parsedMarkdown)\n const stack: Array<{ index: number; marker: number }> = []\n let nextMarker = 0\n\n for (let index = 0; index < tokens.length; index++) {\n const token = tokens[index]\n\n if (!token || token.type !== 'mdc_block_slot') continue\n\n if (token.nesting === 1) {\n const name = token.attrs?.[0]?.[0]?.replace(/^#/u, '')\n let markerIndex = nextMarker\n\n while (markerIndex < markers.length && markers[markerIndex]?.name !== name) markerIndex++\n const marker = markers[markerIndex]\n\n if (marker) {\n stack.push({ index, marker: marker.line })\n nextMarker = markerIndex + 1\n }\n\n continue\n }\n\n if (token.nesting !== -1) continue\n const open = stack.pop()\n\n if (!open) continue\n let endLine = open.marker + 1\n\n for (let childIndex = open.index + 1; childIndex < index; childIndex++) {\n const child = tokens[childIndex]\n const map = child?.map ?? maps.get(childIndex)\n\n if (child && map) {\n endLine = Math.max(endLine, map[1] + (child.type === 'mdc_block_open' ? 1 : 0))\n }\n }\n\n maps.set(open.index, [open.marker, endLine])\n }\n\n return maps\n}\n\nfunction slotMarkers(source: string): Array<{ line: number; name: string }> {\n return source.split(/\\r?\\n/u).flatMap((line, index) => {\n const name = line.match(/^\\s*#([^\\s{]+)/u)?.[1]\n\n return name ? [{ line: index, name }] : []\n })\n}\n\nfunction collapseComarkWrapper(descriptor: BlockDescriptor): BlockDescriptor {\n const children = descriptor.children.map(collapseComarkWrapper)\n\n if (WRAPPER_TAGS.has(descriptor.tag) && children.length === 1 && children[0]?.tag === descriptor.tag) {\n return { ...descriptor, children: children[0].children }\n }\n\n return { ...descriptor, children }\n}\n\n/** Comark projects siblings after a named slot into that active slot. */\nfunction groupProjectedSlotContent(descriptor: BlockDescriptor): BlockDescriptor {\n const grouped: BlockDescriptor[] = []\n let activeSlot: BlockDescriptor | undefined\n\n for (const rawChild of descriptor.children) {\n const child = groupProjectedSlotContent(rawChild)\n\n if (child.tag === 'template') {\n activeSlot = child\n grouped.push(child)\n continue\n }\n\n if (!activeSlot) {\n grouped.push(child)\n continue\n }\n\n activeSlot.children.push(child)\n\n if (child.range.end.offset > activeSlot.range.end.offset) {\n activeSlot.range = { start: activeSlot.range.start, end: child.range.end }\n }\n }\n\n return { ...descriptor, children: grouped }\n}\n\nfunction mapNodes(\n nodes: ReadonlyArray<Node>,\n descriptors: ReadonlyArray<BlockDescriptor>,\n parentPath: ReadonlyArray<number>,\n mappings: DocumentSourceMapping[],\n): void {\n let descriptorIndex = 0\n\n for (let nodeIndex = 0; nodeIndex < nodes.length; nodeIndex++) {\n const node = nodes[nodeIndex]\n\n if (!node || !isElementNode(node)) continue\n\n let matchIndex = descriptorIndex\n\n while (\n matchIndex < descriptors.length &&\n descriptors[matchIndex]?.tag !== '*' &&\n descriptors[matchIndex]?.tag !== node[0]\n ) {\n matchIndex++\n }\n\n const descriptor = descriptors[matchIndex]\n\n if (!descriptor) continue\n\n descriptorIndex = matchIndex + 1\n const nodePath = [...parentPath, nodeIndex]\n mappings.push({ nodePath, range: descriptor.range })\n const [, , ...children] = node\n mapNodes(children, descriptor.children, nodePath, mappings)\n }\n}\n\nfunction isElementNode(node: Node): node is ElementNode {\n return Array.isArray(node) && Predicate.isString(node[0])\n}\n\nfunction indexLineStarts(source: string): number[] {\n const starts = [0]\n\n for (let offset = 0; offset < source.length; offset++) {\n if (source.charCodeAt(offset) === 10) starts.push(offset + 1)\n }\n\n return starts\n}\n\nfunction rangeFromParsedLines(\n source: string,\n sourceLineStarts: ReadonlyArray<number>,\n parsedMarkdown: string,\n parsedLineStarts: ReadonlyArray<number>,\n parsedOffset: number,\n startLine: number,\n endLine: number,\n fallbackLineOffset: number,\n): DocumentSourceRange {\n const startOffset =\n parsedOffset >= 0\n ? parsedOffset + (parsedLineStarts[startLine] ?? parsedMarkdown.length)\n : (sourceLineStarts[startLine + fallbackLineOffset] ?? source.length)\n\n const endOffset =\n parsedOffset >= 0\n ? parsedOffset + (parsedLineStarts[endLine] ?? parsedMarkdown.length)\n : (sourceLineStarts[endLine + fallbackLineOffset] ?? source.length)\n\n return {\n start: pointAt(source, sourceLineStarts, startOffset),\n end: pointAt(source, sourceLineStarts, Math.max(startOffset, endOffset)),\n }\n}\n\nfunction pointAt(source: string, lineStarts: ReadonlyArray<number>, rawOffset: number): DocumentSourcePoint {\n const offset = Math.min(Math.max(rawOffset, 0), source.length)\n let low = 0\n let high = lineStarts.length - 1\n\n while (low < high) {\n const middle = Math.ceil((low + high) / 2)\n\n if ((lineStarts[middle] ?? source.length) <= offset) low = middle\n else high = middle - 1\n }\n\n return {\n offset,\n line: low + 1,\n column: offset - (lineStarts[low] ?? 0) + 1,\n }\n}\n","import type { ComarkParseFn } from 'comark'\nimport { createMarkdownParser } from 'comark/parse'\nimport alert from 'comark/plugins/alert'\nimport attributes from 'comark/plugins/attributes'\nimport components from 'comark/plugins/components'\nimport frontmatter from 'comark/plugins/frontmatter'\nimport headings from 'comark/plugins/headings'\nimport security from 'comark/plugins/security'\nimport taskList from 'comark/plugins/task-list'\nimport toc from 'comark/plugins/toc'\nimport { sourceCapturePlugin, sourceMappingPlugin } from './source-mapping'\n\n/**\n * Changes when parsing, normalization, or projection semantics change. Stored\n * with compiled documents so migrations can identify stale derived content.\n */\nexport const DOCUMENT_ENGINE_FINGERPRINT =\n 'comark@0.6.2/frontmatter+alert+task-list+components+attributes+security+headings+toc+source-mapping/v1'\n\nexport function createDocumentParser(): ComarkParseFn {\n return createMarkdownParser({\n autoClose: false,\n registerDefaultPlugins: false,\n plugins: [\n sourceCapturePlugin(),\n frontmatter(),\n alert(),\n taskList(),\n components(),\n attributes(),\n // Security mutates the tree before metadata and source paths are derived.\n security(),\n headings(),\n toc({ depth: 5, searchDepth: 6 }),\n sourceMappingPlugin(),\n ],\n })\n}\n","import { Schema } from 'effect'\n\nexport class EditorDocumentInvalid extends Schema.TaggedError<EditorDocumentInvalid>()('EditorDocument.Invalid', {\n message: Schema.NonEmptyString,\n cause: Schema.Defect(),\n}) {}\n\nexport class EditorRenderFailed extends Schema.TaggedError<EditorRenderFailed>()('EditorDocument.RenderFailed', {\n cause: Schema.Defect(),\n}) {}\n","import { formStructureIssues } from './Forms'\nimport type { BlockAuthoring, BlockProp, BlockSlot } from '@internal/protocol/Authoring'\nimport type { Editor, JSONContent } from '@tiptap/core'\nimport type { CollectionBody, ComponentDefinition } from '@internal/protocol/Configuration'\nimport { Extension } from '@tiptap/core'\nimport { Plugin } from '@tiptap/pm/state'\nimport { ySyncPluginKey } from '@tiptap/y-tiptap'\nimport { CmsMarkdownDocument } from '@internal/protocol/Documents'\nimport { Effect, Predicate, Schema } from 'effect'\nimport { comarkToEditor } from './internal/comark/to-editor'\nimport { createCmsComarkRenderData } from './internal/comark/document-adapter'\nimport { createDocumentParser } from './internal/comark/grammar'\nimport { EditorDocumentInvalid } from './internal/editor/errors'\nimport { createEditorNodeId } from './internal/editor/identity'\n\nexport const parseAuthoringContent = Effect.fn('AuthoringSchema.parseContent')(function* (markdown: string) {\n const body = yield* Effect.tryPromise({\n try: () => createDocumentParser()(markdown),\n catch: (cause) => new EditorDocumentInvalid({ cause, message: 'Invalid initial Markdown content.' }),\n })\n\n const decoded = yield* Schema.decodeUnknownEffect(CmsMarkdownDocument)(body)\n\n return decoded.nodes\n})\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\nexport function collectionComponents(\n components: ReadonlyArray<ComponentDefinition>,\n body: CollectionBody | undefined,\n): ReadonlyArray<ComponentDefinition> {\n if (!body) return components\n\n return components.filter(\n (component) =>\n body.blocks?.includes(component.name) ||\n (component.authoring.group !== undefined && body.groups?.includes(component.authoring.group)),\n )\n}\n\n/** Configuration errors belong to developers, before an installation adopts the catalog. */\nexport function validateCollectionBody(\n components: ReadonlyArray<ComponentDefinition>,\n body: CollectionBody | undefined,\n): ReadonlyArray<string> {\n return [\n ...components.flatMap((component) =>\n component.authoring.slots.flatMap((slot) => [\n ...(slot.blocks ?? [])\n .filter((name) => !components.some((candidate) => candidate.name === name))\n .map((name) => `Unknown block \"${name}\" in ${slot.label}.`),\n ...(slot.groups ?? [])\n .filter((group) => !components.some((candidate) => candidate.authoring.group === group))\n .map((group) => `Unknown block group \"${group}\" in ${slot.label}.`),\n ]),\n ),\n ...(body?.blocks ?? [])\n .filter((name) => !components.some((component) => component.name === name))\n .map((name) => `Unknown block \"${name}\".`),\n ...(body?.groups ?? [])\n .filter((group) => !components.some((component) => component.authoring.group === group))\n .map((group) => `Unknown block group \"${group}\".`),\n ]\n}\n\nfunction contentIssues(\n node: JSONContent,\n schemas: ReadonlyMap<string, AuthoringSchema>,\n allowed: ReadonlySet<string>,\n purpose: 'working' | 'publish',\n collectionAllowed: ReadonlySet<string> = allowed,\n): string[] {\n const issues: string[] = []\n\n if (node.type === 'cmsBlock') {\n const name = String(node.attrs?.tag).toLowerCase()\n const schema = schemas.get(name)\n\n if (!schema) issues.push('This block is unavailable. Ask your site developer to restore its definition.')\n else {\n if (!allowed.has(name)) issues.push(`${schema.definition.label} is not allowed in this content region.`)\n issues.push(...schema.validate(node, purpose))\n\n if (purpose === 'publish' && schema.definition.form)\n issues.push(...formStructureIssues(node.attrs?.props?.steps, schema.definition.form, name))\n }\n }\n\n if (node.type === 'cmsOpaque' || node.type === 'cmsInlineOpaque')\n issues.push('This content is unsupported. Ask your site developer to update it before publishing.')\n\n if (node.type === 'cmsBlock') {\n const schema = schemas.get(String(node.attrs?.tag).toLowerCase())\n\n for (const region of node.content ?? []) {\n const slot = schema?.definition.slots.find((candidate) => candidate.name === region.attrs?.name)\n\n const permitted =\n slot?.input === 'blocks'\n ? new Set(\n collectionComponents(\n [...schemas].map(([name, schema]) => ({ name, authoring: schema.definition })),\n slot.blocks === undefined && slot.groups === undefined ? undefined : slot,\n )\n .map((component) => component.name)\n .filter((name) => collectionAllowed.has(name)),\n )\n : collectionAllowed\n\n issues.push(...contentIssues(region, schemas, permitted, purpose, collectionAllowed))\n }\n\n return issues\n }\n\n return [\n ...issues,\n ...(node.content ?? []).flatMap((child) => contentIssues(child, schemas, allowed, purpose, collectionAllowed)),\n ]\n}\n\nexport function validateAuthoringDocument(\n body: CmsMarkdownDocument,\n components: ReadonlyMap<string, ComponentDefinition> | undefined,\n bodyPolicy?: CollectionBody,\n): ReadonlyArray<string> {\n return components ? createAuthoringDocumentValidator(components)(body, bodyPolicy) : []\n}\n\n/** Resolves a component catalog once so document compilation can reuse its authoring rules. */\nexport function createAuthoringDocumentValidator(components: ReadonlyMap<string, ComponentDefinition>) {\n const definitions = [...components.values()]\n\n const schemas = new Map(\n definitions.map((component) => [component.name, createAuthoringSchema(component.name, component.authoring)]),\n )\n\n return (body: CmsMarkdownDocument, bodyPolicy?: CollectionBody): ReadonlyArray<string> => {\n const allowed = new Set(collectionComponents(definitions, bodyPolicy).map((component) => component.name))\n\n return comarkToEditor(body.nodes, createCmsComarkRenderData(body)).flatMap((node) =>\n contentIssues(node, schemas, allowed, 'publish'),\n )\n }\n}\n\nexport interface AuthoringSchema {\n readonly definition: BlockAuthoring\n readonly createContent: () => JSONContent\n readonly createSlot: (name: string) => JSONContent\n readonly setProperty: (current: Schema.JsonObject, name: string, value: Schema.Json | undefined) => Schema.JsonObject\n readonly validate: (node: JSONContent, purpose: 'working' | 'publish') => ReadonlyArray<string>\n}\n\nexport function createAuthoringSchema(name: string, definition: BlockAuthoring): AuthoringSchema {\n const fields = new Map(definition.props.map((field) => [field.name, field]))\n const slots = new Map(definition.slots.map((slot) => [slot.name, slot]))\n\n if (fields.size !== definition.props.length || slots.size !== definition.slots.length) {\n throw new Error(`${definition.label}: authoring names must be unique.`)\n }\n\n const initialProps = {\n ...Object.fromEntries(\n definition.props.flatMap((field) => (field.defaultValue === undefined ? [] : [[field.name, field.defaultValue]])),\n ),\n ...definition.initialProps,\n }\n\n for (const field of definition.props) {\n if (field.defaultValue === undefined) continue\n const issue = propertyIssue(field, field.defaultValue, 'working')\n\n if (issue) throw new Error(`Invalid default for ${definition.label}: ${issue}`)\n }\n\n function createSlot(slotName: string): JSONContent {\n const slot = slots.get(slotName)\n\n if (!slot) throw new Error(`${definition.label}: unknown content region ${slotName}.`)\n const content = slot.initial ? comarkToEditor(slot.initial) : []\n\n return {\n type: 'cmsSlot',\n attrs: { cmsNodeId: createEditorNodeId(), name: slotName, implicit: slotName === 'default', props: {} },\n content: content.length ? content : [{ type: 'paragraph', attrs: { cmsNodeId: createEditorNodeId() } }],\n }\n }\n\n function createContent(): JSONContent {\n return {\n type: 'cmsBlock',\n attrs: { cmsNodeId: createEditorNodeId(), tag: name, props: structuredClone(initialProps) },\n content: definition.slots\n .filter((slot) => slot.required || slot.initial !== undefined)\n .map((slot) => createSlot(slot.name)),\n }\n }\n\n function validate(node: JSONContent, purpose: 'working' | 'publish'): ReadonlyArray<string> {\n const issues: string[] = []\n const attributes = node.attrs?.props\n const values = isJsonObject(attributes) ? attributes : {}\n\n for (const key of Object.keys(values))\n if (!fields.has(key)) issues.push(`${definition.label}: ${key} is not editable.`)\n\n for (const field of definition.props) {\n const value = values[field.name] ?? (values[field.name] === null ? null : field.defaultValue)\n const issue = propertyIssue(field, value, purpose)\n\n if (issue) issues.push(issue)\n }\n\n const used = new Set<string>()\n\n for (const region of node.content ?? []) {\n const key = String(region.attrs?.name ?? 'default')\n const slot = slots.get(key)\n\n if (!slot || region.type !== 'cmsSlot') {\n issues.push(`${definition.label}: unsupported content region ${key}.`)\n continue\n }\n\n if (used.has(key)) issues.push(`${slot.label} can only appear once.`)\n used.add(key)\n\n if (!validRegion(slot, region.content ?? []))\n issues.push(`${slot.label} contains unsupported formatting or blocks.`)\n }\n\n for (const slot of definition.slots)\n if (slot.required && !used.has(slot.name)) issues.push(`${slot.label} is required.`)\n\n return issues\n }\n\n const schema: AuthoringSchema = {\n definition,\n createContent,\n createSlot,\n validate,\n setProperty(current: Schema.JsonObject, key: string, value: Schema.Json | undefined) {\n const field = fields.get(key)\n\n if (!field) throw new Error(`${definition.label}: ${key} is not editable.`)\n const issue = propertyIssue(field, value, 'working')\n\n if (issue) throw new Error(issue)\n const next = Object.fromEntries(Object.entries(current))\n\n if (value === undefined) delete next[key]\n else next[key] = value\n\n return next\n },\n }\n\n const issues = validate(createContent(), 'publish')\n\n if (issues.length) throw new Error(`Invalid initial content for ${definition.label}: ${issues.join(' ')}`)\n\n return schema\n}\n\nexport function selectedAuthoringSlot(\n editor: Editor,\n components: ReadonlyArray<ComponentDefinition>,\n): BlockSlot | undefined {\n const position = editor.state.selection.$from\n\n for (let depth = position.depth; depth > 0; depth--) {\n const region = position.node(depth)\n\n if (region.type.name !== 'cmsSlot') continue\n const block = position.node(depth - 1)\n\n return components\n .find((component) => component.name === block.attrs.tag)\n ?.authoring.slots.find((slot) => slot.name === region.attrs.name)\n }\n\n return undefined\n}\n\n/** Applies authoring rules to local edits. Remote CRDT updates always converge; publication validates them. */\nexport function createAuthoringExtension(\n components: () => ReadonlyArray<ComponentDefinition>,\n body: () => CollectionBody | undefined = () => undefined,\n): Extension {\n let previousComponents: ReadonlyArray<ComponentDefinition> | undefined\n let schemas = new Map<string, ReturnType<typeof createAuthoringSchema>>()\n\n function refresh() {\n const current = components()\n\n if (current === previousComponents) return\n previousComponents = current\n schemas = new Map(\n current.map((component) => [component.name, createAuthoringSchema(component.name, component.authoring)]),\n )\n }\n\n function issues(content: JSONContent): string[] {\n const allowed = new Set(collectionComponents(components(), body()).map((component) => component.name))\n\n return contentIssues(content, schemas, allowed, 'working')\n }\n\n return Extension.create({\n name: 'cmsAuthoringPolicy',\n addProseMirrorPlugins() {\n return [\n new Plugin({\n filterTransaction(transaction, state) {\n if (!transaction.docChanged || transaction.getMeta(ySyncPluginKey)?.isChangeOrigin) return true\n refresh()\n const previous = issues(state.doc.toJSON())\n\n return issues(transaction.doc.toJSON()).every((issue) => {\n const index = previous.indexOf(issue)\n\n if (index < 0) return false\n previous.splice(index, 1)\n\n return true\n })\n },\n }),\n ]\n },\n })\n}\n\nfunction propertyIssue(\n field: BlockProp,\n value: Schema.Json | undefined,\n purpose: 'working' | 'publish',\n): string | undefined {\n if (value === undefined) return field.required && purpose === 'publish' ? `${field.label} is required.` : undefined\n\n if (value === null && field.nullable) return undefined\n\n let valid: boolean\n\n if (field.type === 'string') valid = Predicate.isString(value)\n else if (field.type === 'number') valid = Predicate.isNumber(value) && Number.isFinite(value)\n else if (field.type === 'boolean') valid = Predicate.isBoolean(value)\n else if (field.type === 'array') valid = Array.isArray(value)\n else valid = isJsonObject(value)\n\n if (!valid) return `${field.label} must be ${field.type}.`\n\n if (field.type === 'object' || field.type === 'array') {\n const entries = Array.isArray(value) ? value : [value]\n const ids = new Set<string>()\n\n for (const entry of entries) {\n if (!isJsonObject(entry)) return `${field.label} must contain objects.`\n\n if (field.type === 'array') {\n const id = entry.id\n\n if (!Predicate.isString(id) || !id || ids.has(id)) return `${field.label} items need unique identities.`\n ids.add(id)\n }\n\n for (const key of Object.keys(entry))\n if (!(field.type === 'array' && key === 'id') && !field.fields?.some((child) => child.name === key))\n return `${field.label} contains an unavailable field.`\n\n for (const child of field.fields ?? []) {\n const issue = propertyIssue(child, entry[child.name], purpose)\n\n if (issue) return `${field.label}: ${issue}`\n }\n }\n }\n\n if (purpose === 'publish' && field.required && value === '' && (field.input === 'image' || field.input === 'link'))\n return `${field.label} is required.`\n\n if (\n purpose === 'publish' &&\n Predicate.isString(value) &&\n value &&\n (field.input === 'image' || field.input === 'link') &&\n !validAuthoringUrl(value, field.input)\n )\n return `${field.label} needs a valid ${field.input === 'image' ? 'image URL' : 'link'}.`\n\n if (field.options.length && !field.options.some((option) => option.value === value))\n return `${field.label} must use one of its available choices.`\n\n return undefined\n}\n\nfunction validRegion(slot: BlockSlot, content: ReadonlyArray<JSONContent>): boolean {\n if (slot.input === 'blocks')\n return content.every((node) => node.type === 'cmsBlock' || (node.type === 'paragraph' && !node.content?.length))\n const types = new Set(['paragraph', 'text', 'hardBreak'])\n const marks = new Set<string>()\n\n if (slot.input === 'text' && content.length > 1) return false\n\n if (slot.input === 'rich-text')\n for (const feature of slot.features) {\n if (feature === 'bullet-list') {\n types.add('bulletList')\n types.add('listItem')\n } else marks.add(feature)\n }\n\n const valid = (node: JSONContent): boolean =>\n types.has(node.type ?? '') &&\n (node.marks ?? []).every((mark) => marks.has(mark.type)) &&\n (node.content ?? []).every(valid)\n\n return content.every(valid)\n}\n\n/** URL values remain ordinary Vue strings and use the document model's public paths. */\nexport function validAuthoringUrl(value: string, input: 'image' | 'link'): boolean {\n if (value.trim() !== value || value.includes('\\\\')) return false\n\n for (const character of value) if (character.charCodeAt(0) <= 32) return false\n\n if (value.startsWith('/') && !value.startsWith('//')) return true\n\n if (input === 'link' && value.startsWith('#')) return true\n\n try {\n const url = new URL(value)\n\n return ['https:', 'http:', ...(input === 'link' ? ['mailto:', 'tel:'] : [])].includes(url.protocol)\n } catch {\n return false\n }\n}\n\nexport function createAuthoringItem(fields: ReadonlyArray<BlockProp>, list = false): Schema.JsonObject {\n return {\n ...(list ? { id: createEditorNodeId() } : undefined),\n ...Object.fromEntries(\n fields.flatMap((field) =>\n field.required || field.defaultValue !== undefined\n ? [[field.name, field.defaultValue ?? defaultAuthoringValue(field)]]\n : [],\n ),\n ),\n }\n}\n\nfunction defaultAuthoringValue(field: BlockProp): Schema.Json {\n if (field.type === 'object') return createAuthoringItem(field.fields ?? [])\n\n if (field.type === 'array') return []\n\n if (field.type === 'number') return 0\n\n if (field.type === 'boolean') return false\n\n return field.options[0]?.value ?? ''\n}\n","import { Schema } from 'effect'\nimport { FormCapabilities } from './Forms'\nimport { MarkdownNode } from './internal/documents/models'\n\nexport interface BlockProp {\n readonly name: string\n readonly label: string\n readonly help?: string\n readonly type: 'string' | 'number' | 'boolean' | 'object' | 'array'\n readonly input: 'text' | 'textarea' | 'select' | 'number' | 'toggle' | 'image' | 'link' | 'object' | 'list'\n readonly required: boolean\n readonly nullable: boolean\n readonly defaultValue?: Schema.Json\n readonly options: ReadonlyArray<{ readonly value: string; readonly label: string }>\n readonly fields?: ReadonlyArray<BlockProp>\n}\n\nexport const BlockProp: Schema.Codec<BlockProp> = Schema.Struct({\n name: Schema.NonEmptyString,\n label: Schema.NonEmptyString,\n help: Schema.optionalKey(Schema.String),\n type: Schema.Literals(['string', 'number', 'boolean', 'object', 'array']),\n input: Schema.Literals(['text', 'textarea', 'select', 'number', 'toggle', 'image', 'link', 'object', 'list']),\n required: Schema.Boolean,\n nullable: Schema.Boolean,\n defaultValue: Schema.optionalKey(Schema.Json),\n fields: Schema.optionalKey(Schema.Array(Schema.suspend(() => BlockProp))),\n options: Schema.Array(Schema.Struct({ value: Schema.String, label: Schema.String })),\n})\n\nexport const BlockSlot = Schema.Struct({\n name: Schema.NonEmptyString,\n label: Schema.NonEmptyString,\n help: Schema.optionalKey(Schema.String),\n required: Schema.Boolean,\n input: Schema.Literals(['text', 'rich-text', 'blocks']),\n blocks: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n groups: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n features: Schema.Array(Schema.Literals(['bold', 'italic', 'link', 'bullet-list', 'code'])),\n initial: Schema.optionalKey(Schema.Array(MarkdownNode)),\n})\n\nexport interface BlockSlot extends Schema.Schema.Type<typeof BlockSlot> {}\n\nexport const BlockAuthoring = Schema.Struct({\n version: Schema.Literal(1),\n form: Schema.optionalKey(FormCapabilities),\n label: Schema.NonEmptyString,\n description: Schema.optionalKey(Schema.String),\n group: Schema.optionalKey(Schema.String),\n icon: Schema.optionalKey(Schema.String),\n props: Schema.Array(BlockProp),\n slots: Schema.Array(BlockSlot),\n initialProps: Schema.JsonObject,\n})\n\nexport interface BlockAuthoring extends Schema.Schema.Type<typeof BlockAuthoring> {}\n","import { Schema } from 'effect'\nimport { BlockAuthoring } from './Authoring'\nimport { AddressPattern, CollectionName, Locale, SourceDirectory } from './internal/configuration/scalars'\n\nexport { AddressPattern, CollectionName, Locale, SourceDirectory } from './internal/configuration/scalars'\n\nconst fieldPresentation = {\n path: Schema.NonEmptyString,\n label: Schema.NonEmptyString,\n description: Schema.optionalKey(Schema.String),\n defaultValue: Schema.optionalKey(Schema.Json),\n required: Schema.Boolean,\n}\n\nconst BooleanAuthoringField = Schema.Struct({\n type: Schema.tag('boolean'),\n ...fieldPresentation,\n input: Schema.Literal('toggle'),\n})\n\nconst DateAuthoringField = Schema.Struct({\n type: Schema.tag('date'),\n ...fieldPresentation,\n input: Schema.Literal('date'),\n})\n\nconst NumberAuthoringField = Schema.Struct({\n type: Schema.tag('number'),\n ...fieldPresentation,\n input: Schema.Literals(['number', 'select']),\n options: Schema.Array(Schema.Finite),\n})\n\nconst StringAuthoringField = Schema.Struct({\n type: Schema.tag('string'),\n ...fieldPresentation,\n input: Schema.Literals(['select', 'text', 'textarea']),\n options: Schema.Array(Schema.String),\n})\n\nconst StringArrayAuthoringField = Schema.Struct({\n type: Schema.tag('string[]'),\n ...fieldPresentation,\n input: Schema.Literal('multiselect'),\n options: Schema.Array(Schema.String),\n})\n\nexport const DocumentField = Schema.Union([\n BooleanAuthoringField,\n DateAuthoringField,\n NumberAuthoringField,\n StringArrayAuthoringField,\n StringAuthoringField,\n])\n\nexport type DocumentField = typeof DocumentField.Type\n\nexport const CollectionBody = Schema.Struct({\n blocks: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n groups: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n})\n\nexport interface CollectionBody extends Schema.Schema.Type<typeof CollectionBody> {}\n\nexport const CollectionDefinition = Schema.Struct({\n collection: CollectionName,\n body: Schema.optionalKey(CollectionBody),\n label: Schema.NonEmptyString,\n description: Schema.String,\n directory: SourceDirectory,\n addressPattern: AddressPattern,\n hierarchy: Schema.Boolean,\n canCreate: Schema.Boolean,\n authoringFields: Schema.Array(DocumentField),\n}).annotate({ identifier: 'CollectionDefinition' })\n\nexport interface CollectionDefinition extends Schema.Schema.Type<typeof CollectionDefinition> {}\n\nexport const LocaleConfiguration = Schema.Struct({\n locales: Schema.Array(Locale),\n defaultLocale: Locale,\n fallbackLocale: Schema.NullOr(Locale),\n prefixDefaultLocale: Schema.Boolean,\n}).annotate({ identifier: 'LocaleConfiguration' })\n\nexport interface LocaleConfiguration extends Schema.Schema.Type<typeof LocaleConfiguration> {}\n\nexport const DocumentConfiguration = Schema.Struct({\n types: Schema.Array(CollectionDefinition),\n locales: Schema.optionalKey(LocaleConfiguration),\n}).annotate({ identifier: 'DocumentConfiguration' })\n\nexport interface DocumentConfiguration extends Schema.Schema.Type<typeof DocumentConfiguration> {}\n\nexport const ComponentDefinition = Schema.Struct({\n authoring: BlockAuthoring,\n name: Schema.NonEmptyString,\n}).annotate({ identifier: 'ComponentDefinition' })\n\nexport interface ComponentDefinition extends Schema.Schema.Type<typeof ComponentDefinition> {}\n\nexport const AuthoringCatalog = Schema.Struct({\n revision: Schema.NonEmptyString,\n components: Schema.Array(ComponentDefinition),\n})\n\nexport interface AuthoringCatalog extends Schema.Schema.Type<typeof AuthoringCatalog> {}\n\nexport const MediaConfiguration = Schema.Struct({\n enabled: Schema.Boolean,\n maxUploadBytes: Schema.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uB,OAAO,OAAO;CAChD,YAAY;CACZ,MAAM,OAAO,YAAY,cAAc;CACvC,OAAO,OAAO;CACd,aAAa,OAAO;CACpB,WAAW;CACX,gBAAgB;CAChB,WAAW,OAAO;CAClB,WAAW,OAAO;CAClB,iBAAiB,OAAO,MAAM,aAAa;AAC7C,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,uBAAuB,CAAC;AAIlD,MAAa,sBAAsB,OAAO,OAAO;CAC/C,SAAS,OAAO,MAAM,MAAM;CAC5B,eAAe;CACf,gBAAgB,OAAO,OAAO,MAAM;CACpC,qBAAqB,OAAO;AAC9B,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,sBAAsB,CAAC;AAIjD,MAAa,wBAAwB,OAAO,OAAO;CACjD,OAAO,OAAO,MAAM,oBAAoB;CACxC,SAAS,OAAO,YAAY,mBAAmB;AACjD,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,wBAAwB,CAAC;AAInD,MAAa,sBAAsB,OAAO,OAAO;CAC/C,WAAW;CACX,MAAM,OAAO;AACf,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,sBAAsB,CAAC;AAIjD,MAAa,mBAAmB,OAAO,OAAO;CAC5C,UAAU,OAAO;CACjB,YAAY,OAAO,MAAM,mBAAmB;AAC9C,CAAC;AAID,MAAa,qBAAqB,OAAO,OAAO;CAC9C,SAAS,OAAO;CAChB,gBAAgB,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AAC1D,CAAC"}
@@ -1,7 +1,8 @@
1
- import { CmsI18nOptions } from "./I18n.js";
2
- import { n as FormDefinition, s as FormValues, t as FormCapabilities } from "./Forms-BsJMev5_.js";
3
- import { CmsDocumentModelOptions } from "./DocumentModel.js";
1
+ import { n as FormDefinition, s as FormValues, t as FormCapabilities } from "./Forms-BorTcIlp.js";
2
+ import { t as CmsI18nOptions } from "./I18n-BXlVunfa.js";
4
3
  import { r as SeoConfiguration } from "./Seo-402YumpT.js";
4
+ import "./ContentTransfer-CRQet3QJ.js";
5
+ import { CmsDocumentModelOptions } from "./DocumentModel.js";
5
6
  import { Cause, Context, Crypto, DateTime, Effect, Layer, Option, Result, Schema, Scope, Stream } from "effect";
6
7
  import { Extension, Node } from "@tiptap/core";
7
8
  import "comark";
@@ -33,6 +34,7 @@ export interface CmsMediaStorageOptions {
33
34
  readonly endpoint?: string;
34
35
  readonly forcePathStyle?: boolean;
35
36
  readonly provisionBucket?: boolean;
37
+ readonly prefix: string;
36
38
  readonly region: string;
37
39
  }
38
40
  export interface CmsMediaOptions {
@@ -47,7 +49,10 @@ export interface CmsConfiguration {
47
49
  }>>;
48
50
  readonly baseUrl: string;
49
51
  readonly cleanup?: false | CmsCleanupOptions;
50
- readonly databaseUrl: string;
52
+ readonly database: {
53
+ readonly schema: string;
54
+ readonly url: string;
55
+ };
51
56
  readonly documents: CmsDocumentModelOptions;
52
57
  readonly i18n?: CmsI18nOptions;
53
58
  readonly initializationToken: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Configuration.js","names":[],"sources":["../../../src/Configuration.ts"],"sourcesContent":["import type { CmsI18nOptions } from './I18n'\nimport type { FormCapabilities } from '@internal/protocol/Forms'\nimport type { FormSubmissionHandler } from '@internal/server/Forms'\nimport type { CmsDocumentModelOptions } from './DocumentModel'\nimport type { SeoConfiguration as SeoConfigurationSchema } from '@internal/protocol/Seo'\nimport type { Schema } from 'effect'\n\nexport type CmsSeoOptions = Schema.Codec.Encoded<typeof SeoConfigurationSchema>\n\nexport interface CmsCleanupOptions {\n readonly initialDelayMillis?: number\n readonly intervalMillis?: number\n}\n\nexport interface CmsMediaStorageCredentials {\n readonly accessKeyId: string\n readonly secretAccessKey: string\n readonly sessionToken?: string\n}\n\nexport interface CmsMediaStorageOptions {\n readonly bucket: string\n readonly credentials?: CmsMediaStorageCredentials\n readonly endpoint?: string\n readonly forcePathStyle?: boolean\n readonly provisionBucket?: boolean\n readonly region: string\n}\n\nexport interface CmsMediaOptions {\n readonly maxUploadBytes?: number\n readonly publicBaseUrl: string\n readonly storage: CmsMediaStorageOptions\n}\n\nexport interface CmsConfiguration {\n readonly forms?: Readonly<\n Record<string, { readonly definition: FormCapabilities; readonly onSubmit: FormSubmissionHandler }>\n >\n readonly baseUrl: string\n readonly cleanup?: false | CmsCleanupOptions\n readonly databaseUrl: string\n readonly documents: CmsDocumentModelOptions\n readonly i18n?: CmsI18nOptions\n readonly initializationToken: string\n readonly media?: false | CmsMediaOptions\n readonly seo?: CmsSeoOptions\n readonly secret: string\n}\n\nexport function defineCmsConfig<const Configuration extends CmsConfiguration>(\n configuration: Configuration,\n): Configuration {\n return configuration\n}\n"],"mappings":";AAkDA,SAAgB,gBACd,eACe;CACf,OAAO;AACT"}
1
+ {"version":3,"file":"Configuration.js","names":[],"sources":["../../../src/Configuration.ts"],"sourcesContent":["import type { CmsI18nOptions } from './I18n'\nimport type { FormCapabilities } from '@internal/protocol/Forms'\nimport type { FormSubmissionHandler } from '@internal/server/Forms'\nimport type { CmsDocumentModelOptions } from './DocumentModel'\nimport type { SeoConfiguration as SeoConfigurationSchema } from '@internal/protocol/Seo'\nimport type { Schema } from 'effect'\n\nexport type CmsSeoOptions = Schema.Codec.Encoded<typeof SeoConfigurationSchema>\n\nexport interface CmsCleanupOptions {\n readonly initialDelayMillis?: number\n readonly intervalMillis?: number\n}\n\nexport interface CmsMediaStorageCredentials {\n readonly accessKeyId: string\n readonly secretAccessKey: string\n readonly sessionToken?: string\n}\n\nexport interface CmsMediaStorageOptions {\n readonly bucket: string\n readonly credentials?: CmsMediaStorageCredentials\n readonly endpoint?: string\n readonly forcePathStyle?: boolean\n readonly provisionBucket?: boolean\n readonly prefix: string\n readonly region: string\n}\n\nexport interface CmsMediaOptions {\n readonly maxUploadBytes?: number\n readonly publicBaseUrl: string\n readonly storage: CmsMediaStorageOptions\n}\n\nexport interface CmsConfiguration {\n readonly forms?: Readonly<\n Record<string, { readonly definition: FormCapabilities; readonly onSubmit: FormSubmissionHandler }>\n >\n readonly baseUrl: string\n readonly cleanup?: false | CmsCleanupOptions\n readonly database: {\n readonly schema: string\n readonly url: string\n }\n readonly documents: CmsDocumentModelOptions\n readonly i18n?: CmsI18nOptions\n readonly initializationToken: string\n readonly media?: false | CmsMediaOptions\n readonly seo?: CmsSeoOptions\n readonly secret: string\n}\n\nexport function defineCmsConfig<const Configuration extends CmsConfiguration>(\n configuration: Configuration,\n): Configuration {\n return configuration\n}\n"],"mappings":";AAsDA,SAAgB,gBACd,eACe;CACf,OAAO;AACT"}
@@ -0,0 +1,67 @@
1
+ import { a as DocumentIssue, i as ContentSource, n as ContentPlanEntry, r as ContentSnapshotSource, t as ContentApplyResult } from "./ContentTransfer-CRQet3QJ.js";
2
+ //#region src/Content.d.ts
3
+ export type CmsContentErrorCode = 'authentication-required' | 'content-conflict' | 'filesystem-error' | 'generation-changed' | 'invalid-document' | 'document-not-found' | 'invalid-response' | 'network-error';
4
+ export declare class CmsContentError extends Error {
5
+ readonly code: CmsContentErrorCode;
6
+ readonly conflicts?: ReadonlyArray<CmsContentPlanEntry>;
7
+ readonly issues?: ReadonlyArray<DocumentIssue>;
8
+ constructor(code: CmsContentErrorCode, message: string, options?: {
9
+ readonly cause?: unknown;
10
+ readonly conflicts?: ReadonlyArray<CmsContentPlanEntry>;
11
+ readonly issues?: ReadonlyArray<DocumentIssue>;
12
+ });
13
+ }
14
+ export interface CmsContentCredentials {
15
+ readonly email: string;
16
+ readonly password: string;
17
+ }
18
+ export interface CmsContentClientOptions {
19
+ readonly baseUrl: string;
20
+ readonly credentials: CmsContentCredentials;
21
+ readonly fetch?: typeof globalThis.fetch;
22
+ }
23
+ export interface CmsContentSourceSet {
24
+ readonly sources: ReadonlyArray<ContentSource>;
25
+ }
26
+ export interface CmsContentDocument extends ContentSnapshotSource {}
27
+ export interface CmsContentPlanEntry extends ContentPlanEntry {}
28
+ export interface CmsContentPlan {
29
+ readonly generation: string;
30
+ readonly creates: ReadonlyArray<CmsContentPlanEntry>;
31
+ readonly updates: ReadonlyArray<CmsContentPlanEntry>;
32
+ readonly publications: ReadonlyArray<CmsContentPlanEntry>;
33
+ readonly conflicts: ReadonlyArray<CmsContentPlanEntry>;
34
+ readonly unchanged: ReadonlyArray<CmsContentPlanEntry>;
35
+ readonly issues: ReadonlyArray<DocumentIssue>;
36
+ readonly targetOnly: ReadonlyArray<ContentSource>;
37
+ readonly valid: boolean;
38
+ }
39
+ export interface CmsContentImportOptions {
40
+ readonly overwrite?: boolean;
41
+ readonly publish?: boolean;
42
+ }
43
+ export interface CmsContentDiff {
44
+ readonly changes: ReadonlyArray<{
45
+ readonly sourcePath: string;
46
+ readonly local?: ContentSource;
47
+ readonly target?: ContentSource;
48
+ readonly markdownChanged: boolean;
49
+ readonly publicationChanged: boolean;
50
+ }>;
51
+ readonly targetOnly: ReadonlyArray<ContentSource>;
52
+ }
53
+ export interface CmsContentClient {
54
+ readonly plan: (source: CmsContentSourceSet, options?: CmsContentImportOptions) => Promise<CmsContentPlan>;
55
+ readonly apply: (plan: CmsContentPlan) => Promise<ContentApplyResult>;
56
+ readonly diff: (source: CmsContentSourceSet) => Promise<CmsContentDiff>;
57
+ readonly export: (options: {
58
+ readonly directory: string;
59
+ }) => Promise<CmsContentSourceSet>;
60
+ readonly readDocument: (documentId: string) => Promise<CmsContentDocument>;
61
+ }
62
+ export declare function createCmsContentClient(options: CmsContentClientOptions): CmsContentClient;
63
+ export declare function readCmsContentDirectory(directory: string): Promise<CmsContentSourceSet>;
64
+ export declare function diffCmsContentSources(local: ReadonlyArray<ContentSource>, target: ReadonlyArray<ContentSource>): CmsContentDiff;
65
+ //#endregion
66
+ export type { ContentApplyResult, ContentSource };
67
+ //# sourceMappingURL=Content.d.ts.map