@phtngyn/cms 0.1.0-beta.0 → 0.1.0-beta.2
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.
- package/README.md +260 -6
- package/package.json +31 -16
- package/src/Authoring.d.ts +13 -1
- package/src/Configuration-Br7tE9Qt.d.ts +68 -0
- package/src/{AuthoringSchema-BQ5kbhVB.js → Configuration-CA_jvQKG.js} +599 -492
- package/src/Configuration-CA_jvQKG.js.map +1 -0
- package/src/Configuration.d.ts +2 -44
- package/src/Configuration.js +0 -1
- package/src/Configuration.js.map +1 -1
- package/src/{DocumentEngine-Da0kWotL.js → DocumentEngine-CgiBQU4g.js} +110 -84
- package/src/DocumentEngine-CgiBQU4g.js.map +1 -0
- package/src/DocumentModel-BB9igGC7.d.ts +34 -0
- package/src/DocumentModel.d.ts +2 -30
- package/src/DocumentModel.js +13 -3
- package/src/DocumentModel.js.map +1 -1
- package/src/Forms-BsJMev5_.d.ts +74 -0
- package/src/Forms-CfcI3tPU.js +79 -0
- package/src/Forms-CfcI3tPU.js.map +1 -0
- package/src/Forms-DxbkU3_5.js +367 -0
- package/src/Forms-DxbkU3_5.js.map +1 -0
- package/src/Forms.d.ts +35 -0
- package/src/Forms.js +13 -0
- package/src/Forms.js.map +1 -0
- package/src/HttpPaths-c9nLZ9H2.js +21 -0
- package/src/HttpPaths-c9nLZ9H2.js.map +1 -0
- package/src/I18n-DZK4CkJF.d.ts +21 -0
- package/src/I18n.d.ts +2 -0
- package/src/I18n.js +1 -0
- package/src/Module.js +78 -81
- package/src/Module.js.map +1 -1
- package/src/S3MediaObjects-JKMAWyVB.js +2664 -0
- package/src/S3MediaObjects-JKMAWyVB.js.map +1 -0
- package/src/Seed.d.ts +6 -0
- package/src/Seed.js +34 -0
- package/src/Seed.js.map +1 -0
- package/src/Seo-402YumpT.d.ts +198 -0
- package/src/{connection-ZGtL54qY.js → connection-B-iz0Y9Y.js} +5 -7
- package/src/connection-B-iz0Y9Y.js.map +1 -0
- package/src/{installation-BNKaVjni.js → installation-DgF2M1gL.js} +1162 -2147
- package/src/installation-DgF2M1gL.js.map +1 -0
- package/src/internal/authoring-catalog.js +153 -0
- package/src/internal/authoring-catalog.js.map +1 -0
- package/src/internal/authoring-compiler.js +2 -2
- package/src/internal/authoring-compiler.js.map +1 -1
- package/src/internal/authoring-metadata.js +68 -49
- package/src/internal/authoring-metadata.js.map +1 -1
- package/src/internal/cms-config.js +0 -1
- package/src/internal/cms-config.js.map +1 -1
- package/src/internal/configuration.js +25 -13
- package/src/internal/configuration.js.map +1 -1
- package/src/internal/document-model.js +66 -20
- package/src/internal/document-model.js.map +1 -1
- package/src/internal/form-capabilities.js +12 -0
- package/src/internal/form-capabilities.js.map +1 -0
- package/src/internal/i18n.js +47 -0
- package/src/internal/i18n.js.map +1 -0
- package/src/internal/studio-app.js +66 -0
- package/src/internal/studio-app.js.map +1 -0
- package/src/location-CFKTeK1K.js +35 -0
- package/src/location-CFKTeK1K.js.map +1 -0
- package/src/{metadata-Czvi3E4K.js → metadata-BEZPWh-3.js} +3 -72
- package/src/metadata-BEZPWh-3.js.map +1 -0
- package/src/{models-DS5ClMsH.js → models-BWm1pTAf.js} +9 -31
- package/src/models-BWm1pTAf.js.map +1 -0
- package/src/models-DwYioyNV.js +726 -0
- package/src/models-DwYioyNV.js.map +1 -0
- package/src/runtime/blocks.js +30 -0
- package/src/runtime/blocks.js.map +1 -0
- package/src/runtime/collaboration.js +9 -4
- package/src/runtime/collaboration.js.map +1 -1
- package/src/runtime/delivery/DocumentRenderer.js +10 -4
- package/src/runtime/delivery/DocumentRenderer.js.map +1 -1
- package/src/runtime/delivery/blocks.js +8 -0
- package/src/runtime/delivery/blocks.js.map +1 -0
- package/src/runtime/delivery/context.js +12 -0
- package/src/runtime/delivery/context.js.map +1 -0
- package/src/runtime/delivery/document-page.js +14 -12
- package/src/runtime/delivery/document-page.js.map +1 -1
- package/src/runtime/delivery/document.js +21 -3
- package/src/runtime/delivery/document.js.map +1 -1
- package/src/runtime/delivery/error.js +11 -0
- package/src/runtime/delivery/error.js.map +1 -0
- package/src/runtime/delivery/plugin.js +41 -0
- package/src/runtime/delivery/plugin.js.map +1 -0
- package/src/runtime/delivery/types.d.ts +5 -0
- package/src/runtime/delivery/useCmsDocumentSeo.d.ts +56 -0
- package/src/runtime/delivery/useCmsDocumentSeo.js +99 -0
- package/src/runtime/delivery/useCmsDocumentSeo.js.map +1 -0
- package/src/runtime/delivery/useDocument.js +5 -2
- package/src/runtime/delivery/useDocument.js.map +1 -1
- package/src/runtime/delivery/useDocumentQuery.js +5 -2
- package/src/runtime/delivery/useDocumentQuery.js.map +1 -1
- package/src/runtime/forms/document.js +38 -0
- package/src/runtime/forms/document.js.map +1 -0
- package/src/runtime/forms/useCmsForm.js +149 -0
- package/src/runtime/forms/useCmsForm.js.map +1 -0
- package/src/runtime/i18n/translator.js +22 -0
- package/src/runtime/i18n/translator.js.map +1 -0
- package/src/runtime/i18n/useCmsI18n.d.ts +9 -0
- package/src/runtime/i18n/useCmsI18n.js +29 -0
- package/src/runtime/i18n/useCmsI18n.js.map +1 -0
- package/src/runtime/installation.js +1 -1
- package/src/runtime/plugin.js +3 -3
- package/src/runtime/plugin.js.map +1 -1
- package/src/runtime/preview/comark-document.js +0 -1
- package/src/runtime/preview/comark-document.js.map +1 -1
- package/src/runtime/preview/connection.js +1 -1
- package/src/runtime/preview/controller.js +37 -11
- package/src/runtime/preview/controller.js.map +1 -1
- package/src/runtime/preview/overlay.js +65 -0
- package/src/runtime/preview/overlay.js.map +1 -0
- package/src/runtime/preview/plugin.client.js +59 -61
- package/src/runtime/preview/plugin.client.js.map +1 -1
- package/src/runtime/preview/preview.css +72 -4
- package/src/runtime/preview/protocol.js.map +1 -1
- package/src/runtime/preview/store.js +1 -1
- package/src/runtime/preview/targets.js +0 -1
- package/src/runtime/preview/targets.js.map +1 -1
- package/src/runtime/sitemap-entries.js +17 -0
- package/src/runtime/sitemap-entries.js.map +1 -0
- package/src/runtime/sitemap.js +24 -0
- package/src/runtime/sitemap.js.map +1 -0
- package/src/runtime/studio-app.js +5 -1
- package/src/runtime/studio-app.js.map +1 -1
- package/src/runtime/studio-entry.js +36 -0
- package/src/runtime/studio-entry.js.map +1 -0
- package/src/runtime/studio-navigation.js +11 -0
- package/src/runtime/studio-navigation.js.map +1 -0
- package/src/scalars-B2lgGUnj.js +26 -0
- package/src/scalars-B2lgGUnj.js.map +1 -0
- package/src/{store-Nl4uxEXx.js → store-DjJs3I7k.js} +12 -7
- package/src/store-DjJs3I7k.js.map +1 -0
- package/studio/CreateDocumentDialog-CTeIFlPb.js +256 -0
- package/studio/collaboration-DcK2F6v9.js +4566 -0
- package/studio/documentPlanning-Bfv-d7OU.js +29820 -0
- package/studio/dom-to-image-more.min-D6jGGdrW.js +877 -0
- package/studio/editor-Bzlh3zXt.js +30827 -0
- package/studio/host.css +3 -0
- package/studio/host.js +46614 -0
- package/studio/rolldown-runtime-B0aSnxlc.js +20 -0
- package/dist/studio/assets/ActivityEntryRow-D--fRvWI.js +0 -1
- package/dist/studio/assets/ActivityView-D-XBBUHb.js +0 -1
- package/dist/studio/assets/CreateDocumentDialog-CH8UH1QM.js +0 -1
- package/dist/studio/assets/DocumentsView-CxRpmAxt.js +0 -34
- package/dist/studio/assets/DropdownMenu-BSb1l7fr.js +0 -1
- package/dist/studio/assets/Input-DVao38h7.js +0 -3
- package/dist/studio/assets/MediaView-BHrPIjxB.js +0 -1
- package/dist/studio/assets/Modal-VNrXGa5C.js +0 -1
- package/dist/studio/assets/OverviewView-DfP6-mLZ.js +0 -1
- package/dist/studio/assets/Select-BJZIs9sY.js +0 -1
- package/dist/studio/assets/SettingsView-CerHe-ua.js +0 -1
- package/dist/studio/assets/Skeleton-CWJNi3nS.js +0 -1
- package/dist/studio/assets/StudioPageHeader-DP9HDAF2.js +0 -1
- package/dist/studio/assets/UsersView-cP3REkH2.js +0 -1
- package/dist/studio/assets/collaboration-BLnCzfvV.js +0 -4
- package/dist/studio/assets/context-dY4fNbn3.js +0 -1
- package/dist/studio/assets/editor-CE07wW83.js +0 -137
- package/dist/studio/assets/gateway-BAyQgCse.js +0 -10
- package/dist/studio/assets/index-CjoaPLhZ.js +0 -28
- package/dist/studio/assets/index-s2rPqCmP.css +0 -2
- package/dist/studio/assets/render-BkxbK2St.js +0 -83
- package/dist/studio/assets/rolldown-runtime-DK3Fl9T5.js +0 -1
- package/dist/studio/assets/useMediaLibrary-D7qR7aBf.js +0 -1
- package/dist/studio/index.html +0 -76
- package/src/AuthoringSchema-BQ5kbhVB.js.map +0 -1
- package/src/Configuration-BGYFD2N1.js +0 -150
- package/src/Configuration-BGYFD2N1.js.map +0 -1
- package/src/DocumentEngine-Da0kWotL.js.map +0 -1
- package/src/HttpPaths-86qLGB90.js +0 -15
- package/src/HttpPaths-86qLGB90.js.map +0 -1
- package/src/StudioHttp-BTLLooh0.js +0 -916
- package/src/StudioHttp-BTLLooh0.js.map +0 -1
- package/src/connection-ZGtL54qY.js.map +0 -1
- package/src/installation-BNKaVjni.js.map +0 -1
- package/src/internal/component-metadata.js +0 -37
- package/src/internal/component-metadata.js.map +0 -1
- package/src/metadata-Czvi3E4K.js.map +0 -1
- package/src/models-Citx8jBi.js +0 -306
- package/src/models-Citx8jBi.js.map +0 -1
- package/src/models-DS5ClMsH.js.map +0 -1
- package/src/store-Nl4uxEXx.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Configuration-CA_jvQKG.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":";;;;;;;;;;;;;;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X,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"}
|
package/src/Configuration.d.ts
CHANGED
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface CmsInitialDocument {
|
|
4
|
-
readonly markdown: string;
|
|
5
|
-
readonly published: boolean;
|
|
6
|
-
readonly sourcePath: string;
|
|
7
|
-
}
|
|
8
|
-
export type CmsInitialDocumentProvider = () => PromiseLike<ReadonlyArray<CmsInitialDocument>> | ReadonlyArray<CmsInitialDocument>;
|
|
9
|
-
export interface CmsCleanupOptions {
|
|
10
|
-
readonly initialDelayMillis?: number;
|
|
11
|
-
readonly intervalMillis?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface CmsMediaStorageCredentials {
|
|
14
|
-
readonly accessKeyId: string;
|
|
15
|
-
readonly secretAccessKey: string;
|
|
16
|
-
readonly sessionToken?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface CmsMediaStorageOptions {
|
|
19
|
-
readonly bucket: string;
|
|
20
|
-
readonly credentials?: CmsMediaStorageCredentials;
|
|
21
|
-
readonly endpoint?: string;
|
|
22
|
-
readonly forcePathStyle?: boolean;
|
|
23
|
-
readonly provisionBucket?: boolean;
|
|
24
|
-
readonly region: string;
|
|
25
|
-
}
|
|
26
|
-
export interface CmsMediaOptions {
|
|
27
|
-
readonly maxUploadBytes?: number;
|
|
28
|
-
readonly publicBaseUrl: string;
|
|
29
|
-
readonly storage: CmsMediaStorageOptions;
|
|
30
|
-
}
|
|
31
|
-
export interface CmsConfiguration {
|
|
32
|
-
readonly baseUrl: string;
|
|
33
|
-
readonly cleanup?: false | CmsCleanupOptions;
|
|
34
|
-
readonly databaseUrl: string;
|
|
35
|
-
readonly documents: CmsDocumentModelOptions;
|
|
36
|
-
readonly initialSources?: CmsInitialDocumentProvider;
|
|
37
|
-
readonly initializationToken: string;
|
|
38
|
-
readonly media?: false | CmsMediaOptions;
|
|
39
|
-
readonly secret: string;
|
|
40
|
-
}
|
|
41
|
-
/** Preserves full inference while checking the authored CMS configuration. */
|
|
42
|
-
export declare function defineCmsConfig<const Configuration extends CmsConfiguration>(configuration: Configuration): Configuration;
|
|
43
|
-
//#endregion
|
|
44
|
-
//# sourceMappingURL=Configuration.d.ts.map
|
|
1
|
+
import { a as CmsMediaOptions, c as CmsSeoOptions, i as CmsInitialDocumentProvider, l as defineCmsConfig, n as CmsConfiguration, o as CmsMediaStorageCredentials, r as CmsInitialDocument, s as CmsMediaStorageOptions, t as CmsCleanupOptions } from "./Configuration-Br7tE9Qt.js";
|
|
2
|
+
export { CmsCleanupOptions, CmsConfiguration, CmsInitialDocument, CmsInitialDocumentProvider, CmsMediaOptions, CmsMediaStorageCredentials, CmsMediaStorageOptions, CmsSeoOptions, defineCmsConfig };
|
package/src/Configuration.js
CHANGED
package/src/Configuration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.js","names":[],"sources":["../../../src/Configuration.ts"],"sourcesContent":["import type { CmsDocumentModelOptions } from './DocumentModel'\n\nexport interface CmsInitialDocument {\n readonly markdown: string\n readonly published: boolean\n readonly sourcePath: string\n}\n\nexport type CmsInitialDocumentProvider = () =>\n | PromiseLike<ReadonlyArray<CmsInitialDocument>>\n | ReadonlyArray<CmsInitialDocument>\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 baseUrl: string\n readonly cleanup?: false | CmsCleanupOptions\n readonly databaseUrl: string\n readonly documents: CmsDocumentModelOptions\n readonly initialSources?: CmsInitialDocumentProvider\n readonly initializationToken: string\n readonly media?: false | CmsMediaOptions\n readonly secret: string\n}\n\
|
|
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 CmsInitialDocument {\n readonly markdown: string\n readonly published: boolean\n readonly sourcePath: string\n}\n\nexport type CmsInitialDocumentProvider = () =>\n | PromiseLike<ReadonlyArray<CmsInitialDocument>>\n | ReadonlyArray<CmsInitialDocument>\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 initialSources?: CmsInitialDocumentProvider\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":";AA6DA,SAAgB,gBACd,eACe;CACf,OAAO;AACT"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createCmsComarkRenderData,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { d as SourcePath, o as PublicPath } from "./scalars-B2lgGUnj.js";
|
|
2
|
+
import { c as resolveCmsComarkAttributes, d as createCmsComarkRenderData, l as withCmsComarkProps, o as normalizeCmsComponentBindings, u as cmsComarkTextContent } from "./Forms-DxbkU3_5.js";
|
|
3
|
+
import { F as DocumentSeo, d as DocumentIssue, n as CmsMarkdownDocument, r as CompiledDocument, t as CmsDocumentAnalysis, v as DocumentSourceMapping, x as DocumentValidationResult } from "./models-DwYioyNV.js";
|
|
4
|
+
import { f as DOCUMENT_ENGINE_FINGERPRINT, l as validateCollectionBody, m as SOURCE_MAPPINGS_META_KEY, o as createAuthoringDocumentValidator, p as createDocumentParser } from "./Configuration-CA_jvQKG.js";
|
|
5
|
+
import { DateTime, Effect, Option, Predicate, Result, Schema } from "effect";
|
|
5
6
|
|
|
6
|
-
//#region ../
|
|
7
|
+
//#region ../document/src/internal/document-address.ts
|
|
7
8
|
const addressTokenPattern = /:([a-z][\w.]*)(\*)?/giu;
|
|
8
9
|
function parseDocumentAddress(pattern) {
|
|
9
10
|
const tokens = [...pattern.matchAll(addressTokenPattern)].map((match) => ({
|
|
@@ -220,7 +221,7 @@ const validateFrontmatter = Effect.fn("DocumentEngine.validateFrontmatter")(func
|
|
|
220
221
|
};
|
|
221
222
|
}
|
|
222
223
|
const parsed = Schema.decodeUnknownOption(Schema.JsonObject)(result.value);
|
|
223
|
-
if (parsed
|
|
224
|
+
if (Option.isNone(parsed)) {
|
|
224
225
|
issues.push(issue("schema.constraint", "The collection schema output must be a JSON-compatible object.", type, sourcePath, "frontmatter"));
|
|
225
226
|
return {
|
|
226
227
|
data: projection.value,
|
|
@@ -280,8 +281,10 @@ const compileCompiledDocument = Effect.fn("DocumentEngine.compileDocument")(func
|
|
|
280
281
|
const parsedBody = yield* parseBody(parseMarkdown, source);
|
|
281
282
|
const mappings = yield* sourceMappings(parsedBody, source);
|
|
282
283
|
const body = normalizeCmsComponentBindings(withoutSourceMappings(parsedBody), configuration.components);
|
|
284
|
+
const { collectionFrontmatter, rawSeo } = splitFrontmatter(body.frontmatter);
|
|
285
|
+
const seoProjection = projectSeo(rawSeo, source.sourcePath);
|
|
283
286
|
const relativeKey = yield* fromAddressResult(documentKeyFromSourcePath(location.relativeSourcePath), source.sourcePath);
|
|
284
|
-
const validation = yield* validateFrontmatter(
|
|
287
|
+
const validation = yield* validateFrontmatter(collectionFrontmatter, location.type.schema, location.type.definition, source.sourcePath).pipe(Effect.mapError((cause) => new DocumentCompilationFailed({ issues: [{
|
|
285
288
|
code: "schema.constraint",
|
|
286
289
|
collection: location.type.definition.collection,
|
|
287
290
|
message: cause.message,
|
|
@@ -294,8 +297,9 @@ const compileCompiledDocument = Effect.fn("DocumentEngine.compileDocument")(func
|
|
|
294
297
|
const title = stringValue(validation.data.title) ?? stringValue(body.meta.title) ?? titleFromSource(location.relativeSourcePath);
|
|
295
298
|
const description = stringValue(validation.data.description) ?? stringValue(body.meta.description);
|
|
296
299
|
const issues = Result.isSuccess(address) ? validation.issues : [...validation.issues, addressIssue(address.failure, source.sourcePath)];
|
|
300
|
+
const canonicalFrontmatter = rawSeo === void 0 ? validation.data : Object.assign({ _seo: rawSeo }, validation.data);
|
|
297
301
|
const canonicalBody = CmsMarkdownDocument.make({
|
|
298
|
-
frontmatter:
|
|
302
|
+
frontmatter: canonicalFrontmatter,
|
|
299
303
|
meta: body.meta,
|
|
300
304
|
nodes: body.nodes
|
|
301
305
|
});
|
|
@@ -311,21 +315,48 @@ const compileCompiledDocument = Effect.fn("DocumentEngine.compileDocument")(func
|
|
|
311
315
|
draft: source.draft,
|
|
312
316
|
title,
|
|
313
317
|
data: validation.data,
|
|
314
|
-
issues: [
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
issues: [
|
|
319
|
+
...issues,
|
|
320
|
+
...seoProjection.issues,
|
|
321
|
+
...(configuration.validateAuthoringDocument?.(canonicalBody, location.type.definition.body) ?? []).map((message) => ({
|
|
322
|
+
code: "reference.component",
|
|
323
|
+
message,
|
|
324
|
+
severity: "error",
|
|
325
|
+
sourcePath: source.sourcePath
|
|
326
|
+
}))
|
|
327
|
+
],
|
|
320
328
|
analysis,
|
|
321
329
|
body: canonicalBody,
|
|
322
330
|
engineFingerprint: DOCUMENT_ENGINE_FINGERPRINT,
|
|
323
331
|
source: {
|
|
324
332
|
path: source.sourcePath,
|
|
325
|
-
mappings
|
|
333
|
+
mappings,
|
|
334
|
+
...source.publishedAt === void 0 ? void 0 : { publishedAt: source.publishedAt }
|
|
326
335
|
}
|
|
327
|
-
}, location.locale === void 0 ? void 0 : { locale: location.locale }, description === void 0 ? void 0 : { description }));
|
|
336
|
+
}, location.locale === void 0 ? void 0 : { locale: location.locale }, description === void 0 ? void 0 : { description }, seoProjection.seo === void 0 ? void 0 : { seo: seoProjection.seo }));
|
|
328
337
|
});
|
|
338
|
+
function splitFrontmatter(frontmatter) {
|
|
339
|
+
const { _seo: rawSeo, ...collectionFrontmatter } = frontmatter;
|
|
340
|
+
return {
|
|
341
|
+
collectionFrontmatter,
|
|
342
|
+
rawSeo
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function projectSeo(rawSeo, sourcePath) {
|
|
346
|
+
if (rawSeo === void 0) return { issues: [] };
|
|
347
|
+
const decoded = Schema.decodeUnknownResult(DocumentSeo)(rawSeo, { onExcessProperty: "error" });
|
|
348
|
+
if (Result.isSuccess(decoded)) return {
|
|
349
|
+
issues: [],
|
|
350
|
+
seo: decoded.success
|
|
351
|
+
};
|
|
352
|
+
return { issues: [{
|
|
353
|
+
code: "seo.invalid",
|
|
354
|
+
field: "_seo",
|
|
355
|
+
message: `Document SEO is invalid: ${String(decoded.failure)}`,
|
|
356
|
+
severity: "error",
|
|
357
|
+
sourcePath
|
|
358
|
+
}] };
|
|
359
|
+
}
|
|
329
360
|
function provisionalKey(documentId) {
|
|
330
361
|
return PublicPath.make(`/_cms-invalid/${documentId}`);
|
|
331
362
|
}
|
|
@@ -523,32 +554,6 @@ function collisionIssue(message, document, key) {
|
|
|
523
554
|
return key === void 0 ? issue : Object.assign(issue, { key });
|
|
524
555
|
}
|
|
525
556
|
|
|
526
|
-
//#endregion
|
|
527
|
-
//#region ../document/src/internal/document-engine/component-validation.ts
|
|
528
|
-
function componentValidationMessages(definition, attributes, children) {
|
|
529
|
-
if (definition.authoring) return [];
|
|
530
|
-
const messages = [];
|
|
531
|
-
const props = new Map(definition.props.map((prop) => [prop.name, prop]));
|
|
532
|
-
for (const prop of definition.props) if (prop.required && attributes.get(prop.name) === void 0) messages.push(`Document component "${definition.name}" requires prop "${prop.name}".`);
|
|
533
|
-
for (const [name, value] of attributes) {
|
|
534
|
-
if (name === "$" || name === "class" || name === "id" || name === "style") continue;
|
|
535
|
-
const prop = props.get(name);
|
|
536
|
-
if (!prop) messages.push(`Document component "${definition.name}" does not define prop "${name}".`);
|
|
537
|
-
else if (!matchesCmsComponentPropType(value, prop.type)) messages.push(`Document component "${definition.name}" prop "${name}" must be ${article(prop.type)} ${prop.type}.`);
|
|
538
|
-
}
|
|
539
|
-
const slots = new Set(definition.slots.map((slot) => slot.name));
|
|
540
|
-
const explicitSlots = children.flatMap((node) => {
|
|
541
|
-
if (Predicate.isString(node) || node[0] !== "template") return [];
|
|
542
|
-
return [Predicate.isString(node[1].name) ? node[1].name : "default"];
|
|
543
|
-
});
|
|
544
|
-
if (children.some((node) => Predicate.isString(node) ? Boolean(node.trim()) : node[0] !== "template") && !slots.has("default")) explicitSlots.push("default");
|
|
545
|
-
for (const name of new Set(explicitSlots)) if (!slots.has(name)) messages.push(`Document component "${definition.name}" does not define slot "${name}".`);
|
|
546
|
-
return messages;
|
|
547
|
-
}
|
|
548
|
-
function article(type) {
|
|
549
|
-
return type === "array" || type === "object" ? "an" : "a";
|
|
550
|
-
}
|
|
551
|
-
|
|
552
557
|
//#endregion
|
|
553
558
|
//#region ../document/src/internal/document-engine/reference-target.ts
|
|
554
559
|
function referenceTarget(tag, attributes, documentPath, mediaBaseUrl) {
|
|
@@ -628,36 +633,38 @@ function createDocumentReferenceIndex(documents, configuration, findByPath) {
|
|
|
628
633
|
const all = [];
|
|
629
634
|
const byTarget = /* @__PURE__ */ new Map();
|
|
630
635
|
const issues = /* @__PURE__ */ new Map();
|
|
631
|
-
for (const document of documents)
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
636
|
+
for (const document of documents) {
|
|
637
|
+
const indexTarget = (target, nodePath) => {
|
|
638
|
+
if (!target) return;
|
|
639
|
+
const reference = freezeReference({
|
|
640
|
+
nodePath,
|
|
641
|
+
source: {
|
|
642
|
+
documentId: document.id,
|
|
643
|
+
path: document.path,
|
|
644
|
+
sourcePath: document.source.path
|
|
645
|
+
},
|
|
646
|
+
target
|
|
647
|
+
});
|
|
648
|
+
all.push(reference);
|
|
649
|
+
const key = targetKey(target);
|
|
650
|
+
const matching = byTarget.get(key) ?? [];
|
|
651
|
+
matching.push(reference);
|
|
652
|
+
byTarget.set(key, matching);
|
|
653
|
+
if (target.kind === "document" && Option.isNone(findByPath(target.path))) addIssue(issues, document.source.path, {
|
|
654
|
+
code: "reference.document",
|
|
655
|
+
key: target.path,
|
|
656
|
+
message: `Document link "${target.path}" does not resolve.`,
|
|
657
|
+
severity: "error",
|
|
639
658
|
sourcePath: document.source.path
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
byTarget.set(key, matching);
|
|
648
|
-
if (target.kind === "document" && Option.isNone(findByPath(target.path))) addIssue(issues, document.source.path, {
|
|
649
|
-
code: "reference.document",
|
|
650
|
-
key: target.path,
|
|
651
|
-
message: `Document link "${target.path}" does not resolve.`,
|
|
652
|
-
severity: "error",
|
|
653
|
-
sourcePath: document.source.path
|
|
659
|
+
});
|
|
660
|
+
};
|
|
661
|
+
const seoImageTarget = document.seo?.socialImage ? referenceTarget("img", /* @__PURE__ */ new Map([["src", document.seo.socialImage.url]]), document.path, configuration.mediaBaseUrl) : void 0;
|
|
662
|
+
indexTarget(seoImageTarget?.kind === "media" ? Object.assign({}, seoImageTarget, { mediaId: document.seo?.socialImage?.mediaId }) : seoImageTarget, []);
|
|
663
|
+
visit(document.body.nodes, createCmsComarkRenderData(document.body), (tag, attributes, children, nodePath) => {
|
|
664
|
+
const targets = [referenceTarget(tag, attributes, document.path, configuration.mediaBaseUrl), ...propertyTargets(configuration.components?.get(tag.toLowerCase())?.authoring.props ?? [], Object.fromEntries([...attributes].flatMap(([key, value]) => value === void 0 ? [] : [[key, value]])), document.path, configuration.mediaBaseUrl)];
|
|
665
|
+
for (const target of targets) indexTarget(target, nodePath);
|
|
654
666
|
});
|
|
655
|
-
|
|
656
|
-
const definition = configuration.components.get(target.name);
|
|
657
|
-
if (!definition) addIssue(issues, document.source.path, componentIssue(document.source.path, `Document component "${tag}" is not registered.`));
|
|
658
|
-
else for (const message of componentValidationMessages(definition, attributes, children)) addIssue(issues, document.source.path, componentIssue(document.source.path, message));
|
|
659
|
-
}
|
|
660
|
-
});
|
|
667
|
+
}
|
|
661
668
|
const frozenAll = Object.freeze(all);
|
|
662
669
|
const frozenByTarget = new Map([...byTarget].map(([key, references]) => [key, Object.freeze(references)]));
|
|
663
670
|
return {
|
|
@@ -685,19 +692,22 @@ function freezeReference(reference) {
|
|
|
685
692
|
target: Object.freeze({ ...reference.target })
|
|
686
693
|
});
|
|
687
694
|
}
|
|
688
|
-
function componentIssue(sourcePath, message) {
|
|
689
|
-
return {
|
|
690
|
-
code: "reference.component",
|
|
691
|
-
message,
|
|
692
|
-
severity: "error",
|
|
693
|
-
sourcePath
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
695
|
function addIssue(issues, sourcePath, issue) {
|
|
697
696
|
const sourceIssues = issues.get(sourcePath) ?? [];
|
|
698
697
|
sourceIssues.push(issue);
|
|
699
698
|
issues.set(sourcePath, sourceIssues);
|
|
700
699
|
}
|
|
700
|
+
function propertyTargets(fields, values, path, mediaBaseUrl) {
|
|
701
|
+
return fields.flatMap((field) => {
|
|
702
|
+
const value = values[field.name] === void 0 ? field.defaultValue : values[field.name];
|
|
703
|
+
if (field.input === "link" || field.input === "image") {
|
|
704
|
+
const target = referenceTarget(field.input === "link" ? "a" : "img", /* @__PURE__ */ new Map([[field.input === "link" ? "href" : "src", value]]), path, mediaBaseUrl);
|
|
705
|
+
return target ? [target] : [];
|
|
706
|
+
}
|
|
707
|
+
if (field.fields) return (Array.isArray(value) ? value : [value]).flatMap((entry) => Schema.is(Schema.JsonObject)(entry) ? propertyTargets(field.fields ?? [], entry, path, mediaBaseUrl) : []);
|
|
708
|
+
return [];
|
|
709
|
+
});
|
|
710
|
+
}
|
|
701
711
|
|
|
702
712
|
//#endregion
|
|
703
713
|
//#region ../document/src/internal/document-engine/catalog.ts
|
|
@@ -750,10 +760,16 @@ function resolveDocumentEngineConfiguration(documents, options) {
|
|
|
750
760
|
if (locales.fallbackLocale && !locales.locales.includes(locales.fallbackLocale)) return invalid(`Fallback locale "${locales.fallbackLocale}" is not configured.`, "locales.fallbackLocale");
|
|
751
761
|
}
|
|
752
762
|
let components;
|
|
763
|
+
let validateAuthoringDocument;
|
|
753
764
|
if (options.components !== void 0) {
|
|
754
765
|
const result = resolveComponents(options.components);
|
|
755
766
|
if (Result.isFailure(result)) return Result.fail(result.failure);
|
|
756
|
-
components = result.success;
|
|
767
|
+
components = result.success.components;
|
|
768
|
+
validateAuthoringDocument = result.success.validateAuthoringDocument;
|
|
769
|
+
for (const definition of documents.types) {
|
|
770
|
+
const issues = validateCollectionBody(options.components, definition.body);
|
|
771
|
+
if (issues.length) return invalid(`${definition.label}: ${issues.join(" ")}`, "body");
|
|
772
|
+
}
|
|
757
773
|
}
|
|
758
774
|
const mediaBaseUrl = options.mediaBaseUrl?.replace(/\/+$/u, "");
|
|
759
775
|
resolved.sort((left, right) => directoryDepth(right.definition.directory) - directoryDepth(left.definition.directory));
|
|
@@ -762,6 +778,7 @@ function resolveDocumentEngineConfiguration(documents, options) {
|
|
|
762
778
|
types: resolved
|
|
763
779
|
};
|
|
764
780
|
if (components !== void 0) configuration.components = components;
|
|
781
|
+
if (validateAuthoringDocument !== void 0) configuration.validateAuthoringDocument = validateAuthoringDocument;
|
|
765
782
|
if (mediaBaseUrl !== void 0) configuration.mediaBaseUrl = mediaBaseUrl;
|
|
766
783
|
return Result.succeed(configuration);
|
|
767
784
|
}
|
|
@@ -772,7 +789,14 @@ function resolveComponents(definitions) {
|
|
|
772
789
|
if (components.has(name)) return invalid(`Document component "${component.name}" is defined more than once.`, "components");
|
|
773
790
|
components.set(name, component);
|
|
774
791
|
}
|
|
775
|
-
|
|
792
|
+
try {
|
|
793
|
+
return Result.succeed({
|
|
794
|
+
components,
|
|
795
|
+
validateAuthoringDocument: createAuthoringDocumentValidator(components)
|
|
796
|
+
});
|
|
797
|
+
} catch (cause) {
|
|
798
|
+
return invalid(cause instanceof Error ? cause.message : "The component authoring catalog is invalid.", "components");
|
|
799
|
+
}
|
|
776
800
|
}
|
|
777
801
|
function directoryDepth(directory) {
|
|
778
802
|
return directory === "." ? 0 : directory.split("/").length;
|
|
@@ -787,7 +811,6 @@ function invalid(message, field) {
|
|
|
787
811
|
//#endregion
|
|
788
812
|
//#region ../document/src/DocumentEngine.ts
|
|
789
813
|
const isDocumentParseFailed = Schema.is(DocumentParseFailed);
|
|
790
|
-
/** Resolves installation configuration once and rejects an unusable engine before any Source is compiled. */
|
|
791
814
|
const createDocumentEngine = Effect.fn("DocumentEngine.make")(function* (documents, options) {
|
|
792
815
|
const configuration = yield* Effect.fromResult(resolveDocumentEngineConfiguration(documents, options));
|
|
793
816
|
const parseMarkdown = createDocumentParser();
|
|
@@ -840,12 +863,15 @@ const createDocumentEngine = Effect.fn("DocumentEngine.make")(function* (documen
|
|
|
840
863
|
};
|
|
841
864
|
});
|
|
842
865
|
function sameCompilationSource(left, right) {
|
|
843
|
-
return left.documentId === right.documentId && left.draft === right.draft && left.markdown === right.markdown && left.sourcePath === right.sourcePath;
|
|
866
|
+
return left.documentId === right.documentId && left.draft === right.draft && left.markdown === right.markdown && left.sourcePath === right.sourcePath && samePublishedAt(left.publishedAt, right.publishedAt);
|
|
867
|
+
}
|
|
868
|
+
function samePublishedAt(left, right) {
|
|
869
|
+
return left === void 0 || right === void 0 ? left === right : DateTime.Equivalence(left, right);
|
|
844
870
|
}
|
|
845
871
|
function errorMessage(cause) {
|
|
846
872
|
return cause instanceof Error && cause.message ? cause.message : "Markdown could not be parsed.";
|
|
847
873
|
}
|
|
848
874
|
|
|
849
875
|
//#endregion
|
|
850
|
-
export {
|
|
851
|
-
//# sourceMappingURL=DocumentEngine-
|
|
876
|
+
export { normalizeDocumentRelativePath as a, resolveDocumentAddress as c, localizeDocumentPath as i, referenceTarget as n, normalizePublicPath as o, DocumentCompilationFailed as r, parseDocumentAddress as s, createDocumentEngine as t };
|
|
877
|
+
//# sourceMappingURL=DocumentEngine-CgiBQU4g.js.map
|