@elastic/isomer-sdk 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.txt +0 -286
- package/README.md +13 -2
- package/THIRD_PARTY_LICENSES.md +1 -885
- package/dist/author/authored_fields.d.ts +93 -18
- package/dist/author/authored_fields.d.ts.map +1 -1
- package/dist/author/authored_fields.js +63 -43
- package/dist/author/authored_fields.js.map +1 -1
- package/dist/author/authoring_input.d.ts +7 -0
- package/dist/author/authoring_input.d.ts.map +1 -0
- package/dist/author/authoring_input.js +66 -0
- package/dist/author/authoring_input.js.map +1 -0
- package/dist/author/authoring_model.d.ts +33 -0
- package/dist/author/authoring_model.d.ts.map +1 -0
- package/dist/author/authoring_model.js +142 -0
- package/dist/author/authoring_model.js.map +1 -0
- package/dist/author/declarations.d.ts +13 -0
- package/dist/author/declarations.d.ts.map +1 -0
- package/dist/author/declarations.js +288 -0
- package/dist/author/declarations.js.map +1 -0
- package/dist/author/index.d.ts +4 -1
- package/dist/author/index.d.ts.map +1 -1
- package/dist/author/index.js +4 -1
- package/dist/author/index.js.map +1 -1
- package/dist/author/jsx_shim.d.ts +50 -30
- package/dist/author/jsx_shim.d.ts.map +1 -1
- package/dist/author/jsx_shim.js +146 -138
- package/dist/author/jsx_shim.js.map +1 -1
- package/dist/author/print_jsx.d.ts +19 -0
- package/dist/author/print_jsx.d.ts.map +1 -0
- package/dist/author/print_jsx.js +372 -0
- package/dist/author/print_jsx.js.map +1 -0
- package/dist/author/prompt.d.ts +2 -2
- package/dist/author/prompt.d.ts.map +1 -1
- package/dist/author/prompt.js +7 -2
- package/dist/author/prompt.js.map +1 -1
- package/dist/author/schema_to_typescript.d.ts +37 -0
- package/dist/author/schema_to_typescript.d.ts.map +1 -0
- package/dist/author/schema_to_typescript.js +289 -0
- package/dist/author/schema_to_typescript.js.map +1 -0
- package/dist/cjs/author/authored_fields.js +68 -47
- package/dist/cjs/author/authored_fields.js.map +1 -1
- package/dist/cjs/author/authoring_input.js +70 -0
- package/dist/cjs/author/authoring_input.js.map +1 -0
- package/dist/cjs/author/authoring_model.js +149 -0
- package/dist/cjs/author/authoring_model.js.map +1 -0
- package/dist/cjs/author/declarations.js +292 -0
- package/dist/cjs/author/declarations.js.map +1 -0
- package/dist/cjs/author/index.js +10 -1
- package/dist/cjs/author/index.js.map +1 -1
- package/dist/cjs/author/jsx_shim.js +148 -140
- package/dist/cjs/author/jsx_shim.js.map +1 -1
- package/dist/cjs/author/print_jsx.js +378 -0
- package/dist/cjs/author/print_jsx.js.map +1 -0
- package/dist/cjs/author/prompt.js +7 -2
- package/dist/cjs/author/prompt.js.map +1 -1
- package/dist/cjs/author/schema_to_typescript.js +298 -0
- package/dist/cjs/author/schema_to_typescript.js.map +1 -0
- package/dist/cjs/composition/body_node_base.js +11 -4
- package/dist/cjs/composition/body_node_base.js.map +1 -1
- package/dist/cjs/composition/error.js +2 -0
- package/dist/cjs/composition/error.js.map +1 -1
- package/dist/cjs/composition/index.js +2 -1
- package/dist/cjs/composition/index.js.map +1 -1
- package/dist/cjs/composition/structured_value.js.map +1 -1
- package/dist/cjs/define/frame.js +2 -3
- package/dist/cjs/define/frame.js.map +1 -1
- package/dist/cjs/define/index.js +7 -1
- package/dist/cjs/define/index.js.map +1 -1
- package/dist/cjs/define/primitive_example.js +26 -0
- package/dist/cjs/define/primitive_example.js.map +1 -0
- package/dist/cjs/define/primitive_icon.js +17 -0
- package/dist/cjs/define/primitive_icon.js.map +1 -0
- package/dist/cjs/define/primitive_module.js +24 -7
- package/dist/cjs/define/primitive_module.js.map +1 -1
- package/dist/cjs/define/slack_assets.js.map +1 -1
- package/dist/cjs/entries/index.js +8 -2
- package/dist/cjs/entries/index.js.map +1 -1
- package/dist/cjs/entries/markdown.js +2 -1
- package/dist/cjs/entries/markdown.js.map +1 -1
- package/dist/cjs/entries/slack.js +1 -2
- package/dist/cjs/entries/slack.js.map +1 -1
- package/dist/cjs/pack/capabilities.js +17 -11
- package/dist/cjs/pack/capabilities.js.map +1 -1
- package/dist/cjs/pack/compose.js +4 -1
- package/dist/cjs/pack/compose.js.map +1 -1
- package/dist/cjs/pack/index.js +2 -1
- package/dist/cjs/pack/index.js.map +1 -1
- package/dist/cjs/pack/primitive_pack.js +27 -5
- package/dist/cjs/pack/primitive_pack.js.map +1 -1
- package/dist/cjs/render/anchors.js +1 -1
- package/dist/cjs/render/anchors.js.map +1 -1
- package/dist/cjs/render/format_number.js +2 -1
- package/dist/cjs/render/format_number.js.map +1 -1
- package/dist/cjs/render/html/envelope.js +12 -6
- package/dist/cjs/render/html/envelope.js.map +1 -1
- package/dist/cjs/render/layout_check.js.map +1 -1
- package/dist/cjs/render/markdown/builder.js +18 -8
- package/dist/cjs/render/markdown/builder.js.map +1 -1
- package/dist/cjs/render/markdown/format.js +70 -30
- package/dist/cjs/render/markdown/format.js.map +1 -1
- package/dist/cjs/render/markdown/host_tags.js +67 -0
- package/dist/cjs/render/markdown/host_tags.js.map +1 -0
- package/dist/cjs/render/markdown/index.js +3 -1
- package/dist/cjs/render/markdown/index.js.map +1 -1
- package/dist/cjs/render/markdown/split.js +325 -0
- package/dist/cjs/render/markdown/split.js.map +1 -0
- package/dist/cjs/render/primitive_dispatch.js +11 -25
- package/dist/cjs/render/primitive_dispatch.js.map +1 -1
- package/dist/cjs/render/react/content.js +3 -1
- package/dist/cjs/render/react/content.js.map +1 -1
- package/dist/cjs/render/slack/format.js +1 -601
- package/dist/cjs/render/slack/format.js.map +1 -1
- package/dist/cjs/render/slack/index.js +1 -2
- package/dist/cjs/render/slack/index.js.map +1 -1
- package/dist/cjs/render/slack/markdown_content.js +172 -115
- package/dist/cjs/render/slack/markdown_content.js.map +1 -1
- package/dist/cjs/testing/conformance.js +40 -24
- package/dist/cjs/testing/conformance.js.map +1 -1
- package/dist/cjs/testing/icon.js +248 -0
- package/dist/cjs/testing/icon.js.map +1 -0
- package/dist/cjs/testing/index.js +3 -1
- package/dist/cjs/testing/index.js.map +1 -1
- package/dist/cjs/testing/registration.js +5 -3
- package/dist/cjs/testing/registration.js.map +1 -1
- package/dist/cjs/validate/authoring_schema.js +17 -1
- package/dist/cjs/validate/authoring_schema.js.map +1 -1
- package/dist/cjs/validate/index.js +2 -1
- package/dist/cjs/validate/index.js.map +1 -1
- package/dist/cjs/validate/json_schema.js +10 -3
- package/dist/cjs/validate/json_schema.js.map +1 -1
- package/dist/cjs/validate/url.js +2 -1
- package/dist/cjs/validate/url.js.map +1 -1
- package/dist/cjs/validate/validation.js +2 -45
- package/dist/cjs/validate/validation.js.map +1 -1
- package/dist/composition/body_node_base.d.ts +7 -6
- package/dist/composition/body_node_base.d.ts.map +1 -1
- package/dist/composition/body_node_base.js +10 -3
- package/dist/composition/body_node_base.js.map +1 -1
- package/dist/composition/error.d.ts +2 -0
- package/dist/composition/error.d.ts.map +1 -1
- package/dist/composition/error.js +2 -0
- package/dist/composition/error.js.map +1 -1
- package/dist/composition/index.d.ts +1 -1
- package/dist/composition/index.d.ts.map +1 -1
- package/dist/composition/index.js +1 -1
- package/dist/composition/index.js.map +1 -1
- package/dist/composition/structured_value.d.ts +3 -3
- package/dist/composition/structured_value.d.ts.map +1 -1
- package/dist/composition/structured_value.js.map +1 -1
- package/dist/define/frame.d.ts +9 -20
- package/dist/define/frame.d.ts.map +1 -1
- package/dist/define/frame.js +2 -3
- package/dist/define/frame.js.map +1 -1
- package/dist/define/index.d.ts +3 -1
- package/dist/define/index.d.ts.map +1 -1
- package/dist/define/index.js +3 -1
- package/dist/define/index.js.map +1 -1
- package/dist/define/primitive_example.d.ts +30 -0
- package/dist/define/primitive_example.d.ts.map +1 -0
- package/dist/define/primitive_example.js +21 -0
- package/dist/define/primitive_example.js.map +1 -0
- package/dist/define/primitive_icon.d.ts +11 -0
- package/dist/define/primitive_icon.d.ts.map +1 -0
- package/dist/define/primitive_icon.js +14 -0
- package/dist/define/primitive_icon.js.map +1 -0
- package/dist/define/primitive_module.d.ts +45 -24
- package/dist/define/primitive_module.d.ts.map +1 -1
- package/dist/define/primitive_module.js +24 -7
- package/dist/define/primitive_module.js.map +1 -1
- package/dist/define/slack_assets.d.ts +1 -1
- package/dist/define/slack_assets.d.ts.map +1 -1
- package/dist/define/slack_assets.js.map +1 -1
- package/dist/entries/index.d.ts +3 -3
- package/dist/entries/index.d.ts.map +1 -1
- package/dist/entries/index.js +3 -3
- package/dist/entries/index.js.map +1 -1
- package/dist/entries/markdown.d.ts +1 -1
- package/dist/entries/markdown.d.ts.map +1 -1
- package/dist/entries/markdown.js +1 -1
- package/dist/entries/markdown.js.map +1 -1
- package/dist/entries/slack.d.ts +1 -1
- package/dist/entries/slack.d.ts.map +1 -1
- package/dist/entries/slack.js +1 -1
- package/dist/entries/slack.js.map +1 -1
- package/dist/pack/capabilities.d.ts +24 -10
- package/dist/pack/capabilities.d.ts.map +1 -1
- package/dist/pack/capabilities.js +17 -11
- package/dist/pack/capabilities.js.map +1 -1
- package/dist/pack/compose.d.ts +4 -1
- package/dist/pack/compose.d.ts.map +1 -1
- package/dist/pack/compose.js +4 -1
- package/dist/pack/compose.js.map +1 -1
- package/dist/pack/index.d.ts +2 -2
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +2 -2
- package/dist/pack/index.js.map +1 -1
- package/dist/pack/primitive_pack.d.ts +14 -3
- package/dist/pack/primitive_pack.d.ts.map +1 -1
- package/dist/pack/primitive_pack.js +25 -4
- package/dist/pack/primitive_pack.js.map +1 -1
- package/dist/render/anchors.d.ts +2 -2
- package/dist/render/anchors.d.ts.map +1 -1
- package/dist/render/anchors.js +1 -1
- package/dist/render/anchors.js.map +1 -1
- package/dist/render/format_number.d.ts.map +1 -1
- package/dist/render/format_number.js +2 -1
- package/dist/render/format_number.js.map +1 -1
- package/dist/render/html/envelope.d.ts +3 -3
- package/dist/render/html/envelope.js +12 -6
- package/dist/render/html/envelope.js.map +1 -1
- package/dist/render/layout_check.d.ts +1 -1
- package/dist/render/layout_check.d.ts.map +1 -1
- package/dist/render/layout_check.js.map +1 -1
- package/dist/render/markdown/builder.d.ts +5 -4
- package/dist/render/markdown/builder.d.ts.map +1 -1
- package/dist/render/markdown/builder.js +16 -7
- package/dist/render/markdown/builder.js.map +1 -1
- package/dist/render/markdown/format.d.ts +9 -0
- package/dist/render/markdown/format.d.ts.map +1 -1
- package/dist/render/markdown/format.js +67 -31
- package/dist/render/markdown/format.js.map +1 -1
- package/dist/render/markdown/host_tags.d.ts +14 -0
- package/dist/render/markdown/host_tags.d.ts.map +1 -0
- package/dist/render/markdown/host_tags.js +63 -0
- package/dist/render/markdown/host_tags.js.map +1 -0
- package/dist/render/markdown/index.d.ts +1 -0
- package/dist/render/markdown/index.d.ts.map +1 -1
- package/dist/render/markdown/index.js +1 -0
- package/dist/render/markdown/index.js.map +1 -1
- package/dist/render/markdown/split.d.ts +32 -0
- package/dist/render/markdown/split.d.ts.map +1 -0
- package/dist/render/markdown/split.js +321 -0
- package/dist/render/markdown/split.js.map +1 -0
- package/dist/render/primitive_dispatch.d.ts +6 -6
- package/dist/render/primitive_dispatch.d.ts.map +1 -1
- package/dist/render/primitive_dispatch.js +12 -26
- package/dist/render/primitive_dispatch.js.map +1 -1
- package/dist/render/react/content.d.ts +1 -1
- package/dist/render/react/content.d.ts.map +1 -1
- package/dist/render/react/content.js +3 -1
- package/dist/render/react/content.js.map +1 -1
- package/dist/render/slack/format.d.ts +0 -25
- package/dist/render/slack/format.d.ts.map +1 -1
- package/dist/render/slack/format.js +1 -599
- package/dist/render/slack/format.js.map +1 -1
- package/dist/render/slack/index.d.ts +1 -1
- package/dist/render/slack/index.d.ts.map +1 -1
- package/dist/render/slack/index.js +1 -1
- package/dist/render/slack/index.js.map +1 -1
- package/dist/render/slack/markdown_content.d.ts +10 -4
- package/dist/render/slack/markdown_content.d.ts.map +1 -1
- package/dist/render/slack/markdown_content.js +169 -113
- package/dist/render/slack/markdown_content.js.map +1 -1
- package/dist/testing/conformance.d.ts +19 -14
- package/dist/testing/conformance.d.ts.map +1 -1
- package/dist/testing/conformance.js +40 -24
- package/dist/testing/conformance.js.map +1 -1
- package/dist/testing/icon.d.ts +11 -0
- package/dist/testing/icon.d.ts.map +1 -0
- package/dist/testing/icon.js +244 -0
- package/dist/testing/icon.js.map +1 -0
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/registration.d.ts +1 -1
- package/dist/testing/registration.d.ts.map +1 -1
- package/dist/testing/registration.js +6 -4
- package/dist/testing/registration.js.map +1 -1
- package/dist/validate/authoring_schema.d.ts +6 -0
- package/dist/validate/authoring_schema.d.ts.map +1 -1
- package/dist/validate/authoring_schema.js +15 -0
- package/dist/validate/authoring_schema.js.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +1 -1
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/json_schema.d.ts.map +1 -1
- package/dist/validate/json_schema.js +10 -3
- package/dist/validate/json_schema.js.map +1 -1
- package/dist/validate/url.d.ts.map +1 -1
- package/dist/validate/url.js +2 -1
- package/dist/validate/url.js.map +1 -1
- package/dist/validate/validation.d.ts +1 -11
- package/dist/validate/validation.d.ts.map +1 -1
- package/dist/validate/validation.js +3 -46
- package/dist/validate/validation.js.map +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown_content.js","sourceRoot":"","sources":["../../../../src/render/slack/markdown_content.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAiBH,iDAI6B;AAE7B,qCASkB;AAClB,qCAA0E;AAE1E,MAAM,SAAS,GAAG,CAAC,IAAW,EAAU,EAAE;IACxC,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;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,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC;IACR,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AA1CW,QAAA,4BAA4B,gCA0CvC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n// Builder content to Block Kit, read from the tree rather than re-parsed from\n// Markdown. Rich text carries formatting as style flags beside literal text,\n// so nothing is escaped and nesting survives exactly.\n\nimport type {\n Blockquote,\n List,\n ListItem,\n Nodes,\n PhrasingContent,\n RootContent,\n Table,\n} from 'mdast';\n\nimport type { MarkdownContent } from '../../define/markdown_content';\nimport {\n markdownBlocks,\n serializeMarkdown,\n VERBATIM_TYPE,\n} from '../markdown/builder';\n\nimport {\n SLACK_LIMITS,\n type SlackBlock,\n type SlackRichTextBlockElement,\n type SlackRichTextInline,\n type SlackRichTextSection,\n type SlackRichTextStyle,\n type SlackTableBlock,\n type SlackTableCell,\n} from './blocks';\nimport { clampSlackText, gfmToSlackBlocks, slackLinkUrl } from './format';\n\nconst plainText = (node: Nodes): string => {\n if ('value' in node) {\n return node.value;\n }\n if (node.type === 'image') {\n return node.alt ?? '';\n }\n return 'children' in node ? node.children.map(plainText).join('') : '';\n};\n\nconst styled = (style: SlackRichTextStyle): SlackRichTextStyle | undefined =>\n Object.keys(style).length === 0 ? undefined : style;\n\nconst textElement = (\n text: string,\n style: SlackRichTextStyle\n): SlackRichTextInline[] => {\n const withStyle = styled(style);\n return text === ''\n ? []\n : [{ type: 'text', text, ...(withStyle ? { style: withStyle } : {}) }];\n};\n\n// One link element per styled run of the label, so its formatting survives;\n// an empty label is a bare link. A URL Slack cannot link leaves the label.\nconst linkRuns = (\n href: string,\n runs: SlackRichTextInline[],\n style: SlackRichTextStyle\n): SlackRichTextInline[] => {\n const url = slackLinkUrl(href);\n if (url === null) {\n return runs;\n }\n if (runs.length === 0) {\n const withStyle = styled(style);\n return [{ type: 'link', url, ...(withStyle ? { style: withStyle } : {}) }];\n }\n return runs.map((run) =>\n run.type === 'text' ? { ...run, type: 'link', url } : run\n );\n};\n\nconst inline = (\n nodes: readonly PhrasingContent[],\n style: SlackRichTextStyle = {}\n): SlackRichTextInline[] =>\n nodes.flatMap((node): SlackRichTextInline[] => {\n switch (node.type) {\n case 'strong':\n return inline(node.children, { ...style, bold: true });\n case 'emphasis':\n return inline(node.children, { ...style, italic: true });\n case 'delete':\n return inline(node.children, { ...style, strike: true });\n case 'inlineCode':\n return textElement(node.value, { ...style, code: true });\n case 'link':\n return linkRuns(node.url, inline(node.children, style), style);\n // Slack draws no inline image, so it links to the source.\n case 'image':\n return linkRuns(node.url, textElement(node.alt ?? '', style), style);\n case 'break':\n return textElement('\\n', style);\n default:\n return textElement(plainText(node), style);\n }\n });\n\nconst inlineText = (element: SlackRichTextInline): string =>\n element.type === 'link' ? (element.text ?? element.url) : element.text;\n\n// The envelope leaves rich text alone, so a section keeps to the budget the\n// string path gives a section's text.\nconst clampInline = (\n elements: readonly SlackRichTextInline[],\n budget: number = SLACK_LIMITS.sectionTextChars\n): SlackRichTextInline[] => {\n const kept: SlackRichTextInline[] = [];\n let spent = 0;\n for (const element of elements) {\n const length = inlineText(element).length;\n const rest = budget - spent;\n if (length <= rest) {\n kept.push(element);\n spent += length;\n continue;\n }\n const text = rest > 0 ? clampSlackText(inlineText(element), rest) : '';\n if (text !== '') {\n kept.push({ ...element, text });\n }\n break;\n }\n return kept;\n};\n\nconst section = (elements: SlackRichTextInline[]): SlackRichTextSection[] => {\n const clamped = clampInline(elements);\n return clamped.length === 0\n ? []\n : [{ type: 'rich_text_section', elements: clamped }];\n};\n\nconst childInline = (\n child: ListItem['children'][number]\n): SlackRichTextInline[] =>\n 'children' in child\n ? inline(\n child.children as PhrasingContent[],\n child.type === 'heading' ? { bold: true } : {}\n )\n : textElement(\n plainText(child),\n child.type === 'code' ? { code: true } : {}\n );\n\n// An item's children are read in order. Its paragraphs share one bullet; a\n// nested list follows at the next indent; what the item holds after a nested\n// list follows unbulleted, since a Slack list item cannot resume; and the\n// outer list resumes at its next number.\n// A quote holds its blocks at one level.\nconst unquoted = (node: RootContent): RootContent[] =>\n node.type === 'blockquote' ? node.children.flatMap(unquoted) : [node];\n\nconst listElements = (\n list: List,\n indent: number\n): SlackRichTextBlockElement[] => {\n const style = list.ordered ? 'ordered' : 'bullet';\n const out: SlackRichTextBlockElement[] = [];\n let current: SlackRichTextSection[] = [];\n let number = list.start ?? 1;\n let offset = number - 1;\n const flush = (): void => {\n if (current.length > 0) {\n out.push({\n type: 'rich_text_list',\n style,\n ...(indent > 0 ? { indent } : {}),\n // A list starting at 0 would need a negative offset, which Slack\n // may reject along with the whole message; it starts at 1 instead.\n ...(list.ordered && offset > 0 ? { offset } : {}),\n elements: current,\n });\n }\n current = [];\n offset = number - 1;\n };\n for (const item of list.children) {\n let runs: SlackRichTextInline[] = [];\n let numbered = false;\n const emit = (): void => {\n const sections = section(runs);\n runs = [];\n if (sections.length === 0) {\n return;\n }\n if (numbered) {\n flush();\n out.push(...sections);\n } else {\n current.push(...sections);\n number += 1;\n numbered = true;\n }\n };\n for (const child of item.children.flatMap(\n unquoted\n ) as ListItem['children']) {\n if (child.type === 'list') {\n emit();\n flush();\n out.push(\n ...listElements(\n child,\n Math.min(indent + 1, SLACK_LIMITS.richTextListMaxIndent)\n )\n );\n } else {\n runs.push(\n ...(runs.length > 0 ? textElement('\\n', {}) : []),\n ...childInline(child)\n );\n }\n }\n emit();\n }\n flush();\n return out;\n};\n\nconst richTextElements = (node: RootContent): SlackRichTextBlockElement[] => {\n switch (node.type) {\n case 'paragraph':\n return section(inline(node.children));\n case 'heading':\n return section(inline(node.children, { bold: true }));\n case 'list':\n return listElements(node, 0);\n case 'code':\n return node.value === ''\n ? []\n : [\n {\n type: 'rich_text_preformatted',\n elements: textElement(\n clampSlackText(node.value, SLACK_LIMITS.sectionTextChars),\n {}\n ),\n },\n ];\n default:\n return [];\n }\n};\n\nconst tableCell = (cell: PhrasingContent[]): SlackTableCell => {\n const elements = inline(cell);\n const plain = elements.every(\n (element) => element.type === 'text' && element.style === undefined\n );\n return plain\n ? { type: 'raw_text', text: cell.map(plainText).join('') }\n : {\n type: 'rich_text',\n elements: section(elements),\n };\n};\n\n// Slack rejects a row with no cells, so such rows are dropped, and a table\n// whose header has none prints nothing.\nconst tableBlock = (table: Table): SlackTableBlock[] => {\n const rows = table.children\n .slice(0, SLACK_LIMITS.tableRows)\n .map((row) =>\n row.children\n .slice(0, SLACK_LIMITS.tableColumns)\n .map((cell) => tableCell(cell.children))\n );\n const [header] = rows;\n if (header === undefined || header.length === 0) {\n return [];\n }\n return [\n {\n type: 'table',\n rows: rows.filter((cells) => cells.length > 0),\n column_settings: header.map((_cell, index) => ({\n align: table.align?.[index] ?? 'left',\n is_wrapped: true,\n })),\n },\n ];\n};\n\nconst containsVerbatim = (node: Nodes): boolean =>\n (node.type as string) === VERBATIM_TYPE ||\n ('children' in node && node.children.some(containsVerbatim));\n\nconst LIST_ITEM_CONTENT: ReadonlySet<string> = new Set([\n 'paragraph',\n 'heading',\n 'code',\n 'list',\n]);\n\n// A rich-text list item holds lines of text, so a list holding any other\n// block, such as a table, goes through the string translator whole.\nconst fitsRichTextList = (list: List): boolean =>\n list.children.every((item) =>\n item.children\n .flatMap(unquoted)\n .every(\n (child) =>\n LIST_ITEM_CONTENT.has(child.type) &&\n (child.type !== 'list' || fitsRichTextList(child))\n )\n );\n\n// The string translator reads a line at a time, so a hard break reaches it as\n// a line ending and a quote as its blocks.\nconst forStringPath = (node: Nodes): Nodes[] => {\n if (node.type === 'break') {\n return [{ type: 'text', value: '\\n' }];\n }\n if (node.type === 'blockquote') {\n return node.children.flatMap(forStringPath);\n }\n return 'children' in node\n ? [{ ...node, children: node.children.flatMap(forStringPath) } as Nodes]\n : [node];\n};\n\nconst viaStringPath = (node: RootContent): SlackBlock[] =>\n gfmToSlackBlocks(\n serializeMarkdown(forStringPath(node) as unknown as MarkdownContent)\n );\n\ntype Piece = SlackRichTextBlockElement | SlackBlock;\n\nconst isElement = (piece: Piece): piece is SlackRichTextBlockElement =>\n piece.type.startsWith('rich_text_');\n\nconst borderedElement = (\n element: SlackRichTextBlockElement\n): SlackRichTextBlockElement => {\n switch (element.type) {\n case 'rich_text_list':\n case 'rich_text_preformatted':\n return { ...element, border: 1 };\n case 'rich_text_section':\n return { type: 'rich_text_quote', elements: element.elements };\n default:\n return element;\n }\n};\n\n// What a quote holds besides text keeps a quote's border; a table has none.\nconst bordered = (piece: Piece): Piece => {\n if (isElement(piece)) {\n return borderedElement(piece);\n }\n switch (piece.type) {\n case 'rich_text':\n return { ...piece, elements: piece.elements.map(borderedElement) };\n case 'section':\n return piece.text?.type === 'mrkdwn'\n ? {\n ...piece,\n text: {\n ...piece.text,\n text: piece.text.text.replace(/^(?=.*\\S)/gm, '> '),\n },\n }\n : piece;\n default:\n return piece;\n }\n};\n\nconst blockPieces = (node: RootContent): Piece[] => {\n if (node.type === 'blockquote') {\n return quotePieces(node);\n }\n if (\n containsVerbatim(node) ||\n (node.type === 'list' && !fitsRichTextList(node))\n ) {\n return viaStringPath(node);\n }\n if (node.type === 'table') {\n return tableBlock(node);\n }\n const translated = richTextElements(node);\n return translated.length === 0 &&\n !['paragraph', 'heading', 'code'].includes(node.type)\n ? viaStringPath(node)\n : translated;\n};\n\n// A quote is one level, nested quotes spread into it: its text as\n// `rich_text_quote`, and any other block it holds with a border.\nconst quotePieces = (quote: Blockquote): Piece[] => {\n const out: Piece[] = [];\n let runs: SlackRichTextInline[] = [];\n const flush = (): void => {\n const elements = clampInline(runs);\n runs = [];\n if (elements.length > 0) {\n out.push({ type: 'rich_text_quote', elements });\n }\n };\n for (const child of quote.children.flatMap(unquoted)) {\n if (child.type === 'paragraph' || child.type === 'heading') {\n const line = childInline(child);\n runs.push(\n ...(runs.length > 0 && line.length > 0 ? textElement('\\n', {}) : []),\n ...line\n );\n } else {\n flush();\n out.push(...blockPieces(child).map(bordered));\n }\n }\n flush();\n return out;\n};\n\n/**\n * Builder content as Block Kit: paragraphs, headings, lists, quotes, and code\n * as `rich_text`, tables as `table` blocks. A quote is one level, and inside a\n * list item its blocks are the item's. A run of rich-text blocks shares one\n * `rich_text` block. Markdown printed as written, any block holding it, and a\n * list holding a table go through {@link gfmToSlackBlocks}.\n */\nexport const markdownContentToSlackBlocks = (\n content: MarkdownContent\n): SlackBlock[] => {\n const blocks: SlackBlock[] = [];\n let elements: SlackRichTextBlockElement[] = [];\n const flush = (): void => {\n if (elements.length > 0) {\n // A section followed by another ends in a line break, so paragraphs\n // never run together.\n blocks.push({\n type: 'rich_text',\n elements: elements.map((element, index) =>\n element.type === 'rich_text_section' &&\n elements[index + 1]?.type === 'rich_text_section'\n ? {\n ...element,\n elements: [\n ...clampInline(\n element.elements,\n SLACK_LIMITS.sectionTextChars - 1\n ),\n { type: 'text', text: '\\n' },\n ],\n }\n : element\n ),\n });\n }\n elements = [];\n };\n for (const node of markdownBlocks(content) as RootContent[]) {\n for (const piece of blockPieces(node)) {\n if (isElement(piece)) {\n elements.push(piece);\n } else {\n flush();\n blocks.push(piece);\n }\n }\n }\n flush();\n return blocks;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"markdown_content.js","sourceRoot":"","sources":["../../../../src/render/slack/markdown_content.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAoBH,iDAAoE;AACpE,+CAAoD;AAEpD,qCASkB;AAClB,qCAAwD;AAExD,MAAM,aAAa,GAAG,CAAC,EACrB,UAAU,EACV,KAAK,GAC4C,EAAU,EAAE,CAC7D,KAAK,KAAK,IAAI,UAAU,GAAG,CAAC;AAE9B,MAAM,SAAS,GAAG,CAAC,IAAW,EAAU,EAAE;IACxC,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IACD,IAAI,IAAI,CAAC,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AC,CAAC;AADnB,QAAA,gBAAgB,oBACG","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n// Markdown to Block Kit, read from the tree rather than re-parsed line by\n// line. Rich text carries formatting as style flags beside literal text, so\n// nothing is escaped and nesting survives exactly.\n\nimport type {\n Blockquote,\n Definition,\n FootnoteDefinition,\n List,\n ListItem,\n Nodes,\n Paragraph,\n PhrasingContent,\n RootContent,\n Table,\n} from 'mdast';\n\nimport type { MarkdownContent } from '../../define/markdown_content';\nimport { markdownBlocks, VERBATIM_TYPE } from '../markdown/builder';\nimport { parseGfmBlocks } from '../markdown/format';\n\nimport {\n SLACK_LIMITS,\n type SlackBlock,\n type SlackRichTextBlockElement,\n type SlackRichTextInline,\n type SlackRichTextSection,\n type SlackRichTextStyle,\n type SlackTableBlock,\n type SlackTableCell,\n} from './blocks';\nimport { clampSlackText, slackLinkUrl } from './format';\n\nconst footnoteLabel = ({\n identifier,\n label,\n}: Pick<FootnoteDefinition, 'identifier' | 'label'>): string =>\n `[^${label ?? identifier}]`;\n\nconst plainText = (node: Nodes): string => {\n if ('value' in node) {\n return node.value;\n }\n if (node.type === 'image') {\n return node.alt ?? '';\n }\n if (node.type === 'footnoteReference') {\n return footnoteLabel(node);\n }\n return 'children' in node ? node.children.map(plainText).join('') : '';\n};\n\nconst styled = (style: SlackRichTextStyle): SlackRichTextStyle | undefined =>\n Object.keys(style).length === 0 ? undefined : style;\n\nconst textElement = (\n text: string,\n style: SlackRichTextStyle\n): SlackRichTextInline[] => {\n const withStyle = styled(style);\n return text === ''\n ? []\n : [{ type: 'text', text, ...(withStyle ? { style: withStyle } : {}) }];\n};\n\n// One link element per styled run of the label, so its formatting survives;\n// an empty label is a bare link. A URL Slack cannot link leaves the label.\nconst linkRuns = (\n href: string,\n runs: SlackRichTextInline[],\n style: SlackRichTextStyle\n): SlackRichTextInline[] => {\n const url = slackLinkUrl(href);\n if (url === null) {\n return runs;\n }\n if (runs.length === 0) {\n const withStyle = styled(style);\n return [{ type: 'link', url, ...(withStyle ? { style: withStyle } : {}) }];\n }\n return runs.map((run) =>\n run.type === 'text' ? { ...run, type: 'link', url } : run\n );\n};\n\nconst inline = (\n nodes: readonly PhrasingContent[],\n style: SlackRichTextStyle = {}\n): SlackRichTextInline[] =>\n nodes.flatMap((node): SlackRichTextInline[] => {\n switch (node.type) {\n case 'strong':\n return inline(node.children, { ...style, bold: true });\n case 'emphasis':\n return inline(node.children, { ...style, italic: true });\n case 'delete':\n return inline(node.children, { ...style, strike: true });\n case 'inlineCode':\n return textElement(node.value, { ...style, code: true });\n case 'link':\n return linkRuns(node.url, inline(node.children, style), style);\n // Slack draws no inline image, so it links to the source.\n case 'image':\n return linkRuns(node.url, textElement(node.alt ?? '', style), style);\n case 'break':\n return textElement('\\n', style);\n default:\n return textElement(plainText(node), style);\n }\n });\n\nconst inlineText = (element: SlackRichTextInline): string =>\n element.type === 'link' ? (element.text ?? element.url) : element.text;\n\n// The envelope leaves rich text alone, so a section keeps to the budget of a\n// `section` block's text.\nconst clampInline = (\n elements: readonly SlackRichTextInline[],\n budget: number = SLACK_LIMITS.sectionTextChars\n): SlackRichTextInline[] => {\n const kept: SlackRichTextInline[] = [];\n let spent = 0;\n for (const element of elements) {\n const length = inlineText(element).length;\n const rest = budget - spent;\n if (length <= rest) {\n kept.push(element);\n spent += length;\n continue;\n }\n const text = rest > 0 ? clampSlackText(inlineText(element), rest) : '';\n if (text !== '') {\n kept.push({ ...element, text });\n }\n break;\n }\n return kept;\n};\n\nconst section = (elements: SlackRichTextInline[]): SlackRichTextSection[] => {\n const clamped = clampInline(elements);\n return clamped.length === 0\n ? []\n : [{ type: 'rich_text_section', elements: clamped }];\n};\n\ntype Piece = SlackRichTextBlockElement | SlackBlock;\n\nconst isElement = (piece: Piece): piece is SlackRichTextBlockElement =>\n piece.type.startsWith('rich_text_');\n\n// Blocks a rich-text list item holds as lines of its text.\nconst ITEM_LINES: ReadonlySet<string> = new Set([\n 'paragraph',\n 'heading',\n 'code',\n 'html',\n]);\n\nconst childInline = (\n child: ListItem['children'][number]\n): SlackRichTextInline[] =>\n 'children' in child\n ? inline(\n child.children as PhrasingContent[],\n child.type === 'heading' ? { bold: true } : {}\n )\n : textElement(\n plainText(child),\n child.type === 'code' ? { code: true } : {}\n );\n\n// A quote holds its blocks at one level.\nconst unquoted = (node: RootContent): RootContent[] =>\n node.type === 'blockquote' ? node.children.flatMap(unquoted) : [node];\n\n// An item's children are read in order. Its lines of text share one bullet; a\n// nested list follows at the next indent; any other block, such as a table,\n// follows on its own; what the item holds after either follows unbulleted,\n// since a Slack list item cannot resume; and the list resumes at its next\n// number. An empty item keeps its number, so the list resumes past it. A task\n// item's first line leads with its box.\nconst listPieces = (list: List, indent: number): Piece[] => {\n const style = list.ordered ? 'ordered' : 'bullet';\n const out: Piece[] = [];\n let current: SlackRichTextSection[] = [];\n let number = list.start ?? 1;\n let offset = number - 1;\n const flush = (): void => {\n if (current.length > 0) {\n out.push({\n type: 'rich_text_list',\n style,\n ...(indent > 0 ? { indent } : {}),\n // A list starting at 0 would need a negative offset, which Slack\n // may reject along with the whole message; it starts at 1 instead.\n ...(list.ordered && offset > 0 ? { offset } : {}),\n elements: current,\n });\n }\n current = [];\n offset = number - 1;\n };\n for (const item of list.children) {\n let runs: SlackRichTextInline[] = [];\n let numbered = false;\n let box =\n typeof item.checked === 'boolean'\n ? textElement(item.checked ? '☑ ' : '☐ ', {})\n : [];\n const emit = (): void => {\n const sections = section(runs);\n runs = [];\n if (sections.length === 0) {\n return;\n }\n if (numbered) {\n flush();\n out.push(...sections);\n } else {\n current.push(...sections);\n number += 1;\n numbered = true;\n }\n };\n for (const child of item.children.flatMap(\n unquoted\n ) as ListItem['children']) {\n if (ITEM_LINES.has(child.type)) {\n runs.push(\n ...(runs.length > 0 ? textElement('\\n', {}) : box),\n ...childInline(child)\n );\n box = [];\n continue;\n }\n const pieces =\n child.type === 'list'\n ? listPieces(\n child,\n Math.min(indent + 1, SLACK_LIMITS.richTextListMaxIndent)\n )\n : blockPieces(child);\n if (pieces.length > 0) {\n emit();\n flush();\n out.push(...pieces);\n }\n }\n emit();\n if (item.children.length === 0) {\n flush();\n number += 1;\n offset = number - 1;\n }\n }\n flush();\n return out;\n};\n\nconst tableCell = (cell: PhrasingContent[]): SlackTableCell => {\n const elements = inline(cell);\n const plain = elements.every(\n (element) => element.type === 'text' && element.style === undefined\n );\n return plain\n ? { type: 'raw_text', text: cell.map(plainText).join('') }\n : {\n type: 'rich_text',\n elements: section(elements),\n };\n};\n\n// Slack rejects a row with no cells, so such rows are dropped, and a table\n// whose header has none prints nothing.\nconst tableBlock = (table: Table): SlackTableBlock[] => {\n const rows = table.children\n .slice(0, SLACK_LIMITS.tableRows)\n .map((row) =>\n row.children\n .slice(0, SLACK_LIMITS.tableColumns)\n .map((cell) => tableCell(cell.children))\n );\n const [header] = rows;\n if (header === undefined || header.length === 0) {\n return [];\n }\n return [\n {\n type: 'table',\n rows: rows.filter((cells) => cells.length > 0),\n column_settings: header.map((_cell, index) => ({\n align: table.align?.[index] ?? 'left',\n is_wrapped: true,\n })),\n },\n ];\n};\n\n// A footnote's label leads its first paragraph.\nconst footnotePieces = ({\n children,\n ...footnote\n}: FootnoteDefinition): Piece[] => {\n const [first, ...rest] = children;\n const label: PhrasingContent = {\n type: 'text',\n value: `${footnoteLabel(footnote)}: `,\n };\n const lead: Paragraph = {\n type: 'paragraph',\n children: [label, ...(first?.type === 'paragraph' ? first.children : [])],\n };\n return [lead, ...(first?.type === 'paragraph' ? rest : children)].flatMap(\n blockPieces\n );\n};\n\nconst borderedElement = (\n element: SlackRichTextBlockElement\n): SlackRichTextBlockElement => {\n switch (element.type) {\n case 'rich_text_list':\n case 'rich_text_preformatted':\n return { ...element, border: 1 };\n case 'rich_text_section':\n return { type: 'rich_text_quote', elements: element.elements };\n default:\n return element;\n }\n};\n\n// What a quote holds besides text keeps a quote's border; a table or divider\n// has none.\nconst bordered = (piece: Piece): Piece =>\n isElement(piece) ? borderedElement(piece) : piece;\n\n// A quote is one level, nested quotes spread into it: its text as\n// `rich_text_quote`, and any other block it holds with a border.\nconst quotePieces = (quote: Blockquote): Piece[] => {\n const out: Piece[] = [];\n let runs: SlackRichTextInline[] = [];\n const flush = (): void => {\n const elements = clampInline(runs);\n runs = [];\n if (elements.length > 0) {\n out.push({ type: 'rich_text_quote', elements });\n }\n };\n for (const child of quote.children.flatMap(unquoted)) {\n if (child.type === 'paragraph' || child.type === 'heading') {\n const line = childInline(child);\n runs.push(\n ...(runs.length > 0 && line.length > 0 ? textElement('\\n', {}) : []),\n ...line\n );\n } else {\n const pieces = blockPieces(child);\n if (pieces.length > 0) {\n flush();\n out.push(...pieces.map(bordered));\n }\n }\n }\n flush();\n return out;\n};\n\nconst blockPieces = (node: RootContent): Piece[] => {\n switch (node.type) {\n case 'paragraph':\n case 'html':\n return section(childInline(node));\n case 'heading':\n return section(inline(node.children, { bold: true }));\n case 'code':\n return node.value === ''\n ? []\n : [\n {\n type: 'rich_text_preformatted',\n elements: textElement(\n clampSlackText(node.value, SLACK_LIMITS.sectionTextChars),\n {}\n ),\n },\n ];\n case 'list':\n return listPieces(node, 0);\n case 'blockquote':\n return quotePieces(node);\n case 'table':\n return tableBlock(node);\n case 'thematicBreak':\n return [{ type: 'divider' }];\n case 'footnoteDefinition':\n return footnotePieces(node);\n default:\n return [];\n }\n};\n\n// Each reference resolved to its document's first definition.\nconst withReferences = (blocks: readonly RootContent[]): RootContent[] => {\n const definitions = new Map<string, Definition>();\n const collect = (node: Nodes): void => {\n if (node.type === 'definition' && !definitions.has(node.identifier)) {\n definitions.set(node.identifier, node);\n }\n if ('children' in node) {\n node.children.forEach(collect);\n }\n };\n blocks.forEach(collect);\n if (definitions.size === 0) {\n return [...blocks];\n }\n const resolve = (node: Nodes): Nodes => {\n switch (node.type) {\n case 'linkReference':\n return {\n type: 'link',\n url: definitions.get(node.identifier)?.url ?? '',\n children: node.children.map(resolve) as PhrasingContent[],\n };\n case 'imageReference':\n return {\n type: 'image',\n url: definitions.get(node.identifier)?.url ?? '',\n alt: node.alt ?? null,\n };\n default:\n return 'children' in node\n ? ({ ...node, children: node.children.map(resolve) } as Nodes)\n : node;\n }\n };\n return blocks.map(resolve) as RootContent[];\n};\n\nconst lines = (text: string): string => text.replace(/\\r\\n?/g, '\\n');\n\nconst literalParagraphs = (text: string): RootContent[] =>\n lines(text)\n .split(/\\n[ \\t]*\\n/)\n .filter((paragraph) => paragraph.trim() !== '')\n .map((paragraph) => ({\n type: 'paragraph',\n children: [{ type: 'text', value: paragraph.trim() }],\n }));\n\n// Source past the parse budget prints as its literal paragraphs.\nconst gfmBlocks = (gfm: string): RootContent[] => {\n const parsed = parseGfmBlocks(lines(gfm)) as RootContent[] | null;\n return parsed === null ? literalParagraphs(gfm) : withReferences(parsed);\n};\n\n// Markdown printed as written is read as the GFM it holds; authored source\n// that sanitizing left inert is never parsed.\nconst expanded = (node: Nodes): Nodes[] => {\n if ((node.type as string) === VERBATIM_TYPE) {\n const { value, source } = node as unknown as {\n value: string;\n source?: string;\n };\n return source === undefined ? gfmBlocks(value) : literalParagraphs(source);\n }\n return 'children' in node\n ? [{ ...node, children: node.children.flatMap(expanded) } as Nodes]\n : [node];\n};\n\nconst toSlackBlocks = (nodes: readonly RootContent[]): SlackBlock[] => {\n const blocks: SlackBlock[] = [];\n let elements: SlackRichTextBlockElement[] = [];\n const flush = (): void => {\n if (elements.length > 0) {\n // A section followed by another ends in a line break, so paragraphs\n // never run together.\n blocks.push({\n type: 'rich_text',\n elements: elements.map((element, index) =>\n element.type === 'rich_text_section' &&\n elements[index + 1]?.type === 'rich_text_section'\n ? {\n ...element,\n elements: [\n ...clampInline(\n element.elements,\n SLACK_LIMITS.sectionTextChars - 1\n ),\n { type: 'text', text: '\\n' },\n ],\n }\n : element\n ),\n });\n }\n elements = [];\n };\n for (const node of nodes) {\n for (const piece of blockPieces(node)) {\n if (isElement(piece)) {\n elements.push(piece);\n } else {\n flush();\n blocks.push(piece);\n }\n }\n }\n flush();\n return blocks;\n};\n\n/**\n * Builder content as Block Kit: paragraphs, headings, lists, quotes, and code\n * as `rich_text`, tables as `table` blocks, and thematic breaks as `divider`\n * blocks. A quote is one level, and inside a list item its blocks are the\n * item's. A run of rich-text blocks shares one `rich_text` block. Source from\n * `md.authored` is parsed as GFM and translated the same way.\n */\nexport const markdownContentToSlackBlocks = (\n content: MarkdownContent\n): SlackBlock[] =>\n toSlackBlocks(\n (markdownBlocks(content) as RootContent[]).flatMap(\n expanded\n ) as RootContent[]\n );\n\n/**\n * GFM as Block Kit, parsed as CommonMark with GFM and translated as\n * {@link markdownContentToSlackBlocks} translates builder content. Source past\n * the parse budget that `md.authored` applies prints as literal paragraphs.\n */\nexport const gfmToSlackBlocks = (gfm: string): SlackBlock[] =>\n toSlackBlocks(gfmBlocks(gfm));\n"]}
|
|
@@ -17,6 +17,7 @@ exports.primitiveConformanceCases = exports.runPrimitiveInventoryConformance = e
|
|
|
17
17
|
// package's dependency set. Each pack drives the array with `it.each`, so a
|
|
18
18
|
// second vocabulary costs one package and one test file.
|
|
19
19
|
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
20
|
+
const primitive_example_1 = require("../define/primitive_example");
|
|
20
21
|
const anchors_1 = require("../render/anchors");
|
|
21
22
|
const input_budget_1 = require("../validate/input_budget");
|
|
22
23
|
/**
|
|
@@ -24,12 +25,13 @@ const input_budget_1 = require("../validate/input_budget");
|
|
|
24
25
|
* hands a container must render text/markdown containing this string, or the
|
|
25
26
|
* cross-pack nesting case cannot tell a dropped child from an empty one.
|
|
26
27
|
*/
|
|
27
|
-
exports.CONFORMANCE_FOREIGN_MARKER = '
|
|
28
|
+
exports.CONFORMANCE_FOREIGN_MARKER = 'isomerConformanceForeign';
|
|
28
29
|
/** Every definition's examples, flattened to one row each. */
|
|
29
|
-
const examplesFromDefinitions = (definitions) => definitions.flatMap((definition) => definition.
|
|
30
|
+
const examplesFromDefinitions = (definitions) => definitions.flatMap((definition) => (0, primitive_example_1.primitiveExamples)(definition).map(({ name, node }, exampleIndex) => ({
|
|
30
31
|
definition,
|
|
31
32
|
type: definition.type,
|
|
32
33
|
exampleIndex,
|
|
34
|
+
...(name === undefined ? {} : { exampleName: name }),
|
|
33
35
|
node,
|
|
34
36
|
})));
|
|
35
37
|
exports.examplesFromDefinitions = examplesFromDefinitions;
|
|
@@ -41,8 +43,9 @@ const primitiveConformanceRows = (definitions) => (0, exports.examplesFromDefini
|
|
|
41
43
|
exports.primitiveConformanceRows = primitiveConformanceRows;
|
|
42
44
|
/**
|
|
43
45
|
* Asserts the inventory itself holds up: the pack has examples, every
|
|
44
|
-
* definition contributes one,
|
|
45
|
-
*
|
|
46
|
+
* definition contributes one, `catalog.name` and example names are non-empty,
|
|
47
|
+
* example names are unique within their definition, each example's `type` matches its definition, and
|
|
48
|
+
* `catalog.example` is within the input budget and parses or matches a
|
|
46
49
|
* published example.
|
|
47
50
|
*/
|
|
48
51
|
const runPrimitiveInventoryConformance = (definitions) => {
|
|
@@ -50,12 +53,23 @@ const runPrimitiveInventoryConformance = (definitions) => {
|
|
|
50
53
|
strict_1.default.ok(examples.length > 0, 'expected at least one primitive example');
|
|
51
54
|
for (const definition of definitions) {
|
|
52
55
|
strict_1.default.ok(definition.examples.length > 0, `${definition.type} primitive must expose at least one example`);
|
|
56
|
+
const { name: catalogName } = definition.catalog;
|
|
57
|
+
strict_1.default.ok(catalogName === undefined || catalogName.trim().length > 0, `${definition.type} catalog.name must be non-empty when present`);
|
|
58
|
+
const names = new Set();
|
|
59
|
+
for (const { name } of (0, primitive_example_1.primitiveExamples)(definition)) {
|
|
60
|
+
if (name === undefined) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
strict_1.default.ok(name.trim().length > 0, `${definition.type} example names must be non-empty`);
|
|
64
|
+
strict_1.default.ok(!names.has(name), `${definition.type} has two examples named ${JSON.stringify(name)}`);
|
|
65
|
+
names.add(name);
|
|
66
|
+
}
|
|
53
67
|
const checked = (0, input_budget_1.checkInputBudget)(definition.catalog.example);
|
|
54
68
|
if (!checked.valid) {
|
|
55
69
|
strict_1.default.fail(`${definition.type} catalog.example must be within the input budget: ${checked.error.message}`);
|
|
56
70
|
}
|
|
57
71
|
const catalogExample = checked.value;
|
|
58
|
-
const matchesPublished = definition.
|
|
72
|
+
const matchesPublished = (0, primitive_example_1.exampleNodes)(definition).some((node) => {
|
|
59
73
|
const published = (0, input_budget_1.checkInputBudget)(node);
|
|
60
74
|
return (published.valid &&
|
|
61
75
|
JSON.stringify(published.value) === JSON.stringify(catalogExample));
|
|
@@ -71,7 +85,8 @@ const runPrimitiveInventoryConformance = (definitions) => {
|
|
|
71
85
|
}
|
|
72
86
|
};
|
|
73
87
|
exports.runPrimitiveInventoryConformance = runPrimitiveInventoryConformance;
|
|
74
|
-
const previewHint = (type, exampleIndex) => `Failing example: \`${type}\` definition, examples[${exampleIndex}]
|
|
88
|
+
const previewHint = ({ type, exampleIndex, exampleName, }) => `Failing example: \`${type}\` definition, examples[${exampleIndex}]` +
|
|
89
|
+
`${exampleName === undefined ? '' : ` (${JSON.stringify(exampleName)})`}.`;
|
|
75
90
|
const renderedClassNames = (html) => {
|
|
76
91
|
const classNames = new Set();
|
|
77
92
|
for (const match of html.matchAll(/\bclass="([^"]+)"/g)) {
|
|
@@ -100,8 +115,9 @@ const cssHasClassSelector = (css, className) => new RegExp(`\\.${cssEscapeClass(
|
|
|
100
115
|
exports.primitiveConformanceCases = [
|
|
101
116
|
{
|
|
102
117
|
name: 'validates as a primitive node and inside a composition',
|
|
103
|
-
run: (
|
|
104
|
-
const
|
|
118
|
+
run: (example, harness) => {
|
|
119
|
+
const { node } = example;
|
|
120
|
+
const hint = previewHint(example);
|
|
105
121
|
const primitiveErrors = [...harness.validateNode(node)];
|
|
106
122
|
strict_1.default.deepEqual(primitiveErrors, [], hint);
|
|
107
123
|
const result = harness.validateComposition(harness.wrapComposition(node));
|
|
@@ -162,22 +178,22 @@ exports.primitiveConformanceCases = [
|
|
|
162
178
|
},
|
|
163
179
|
},
|
|
164
180
|
{
|
|
165
|
-
name: 'renders through
|
|
181
|
+
name: 'renders through snapshot primitive dispatch without throwing',
|
|
166
182
|
run: ({ type, exampleIndex, node }, harness) => {
|
|
167
|
-
if (!harness.
|
|
183
|
+
if (!harness.renderSnapshot) {
|
|
168
184
|
return;
|
|
169
185
|
}
|
|
170
|
-
strict_1.default.doesNotThrow(() => harness.
|
|
186
|
+
strict_1.default.doesNotThrow(() => harness.renderSnapshot?.(node, `conformance-${type}-${exampleIndex}`));
|
|
171
187
|
},
|
|
172
188
|
},
|
|
173
189
|
{
|
|
174
|
-
name: 'reports a positive finite
|
|
190
|
+
name: 'reports a positive finite snapshot height estimate',
|
|
175
191
|
run: ({ node }, harness) => {
|
|
176
192
|
if (harness.sizesFromNodeHeights === false ||
|
|
177
|
-
!harness.
|
|
193
|
+
!harness.estimateSnapshotHeight) {
|
|
178
194
|
return;
|
|
179
195
|
}
|
|
180
|
-
const height = harness.
|
|
196
|
+
const height = harness.estimateSnapshotHeight(node);
|
|
181
197
|
strict_1.default.equal(Number.isFinite(height), true);
|
|
182
198
|
strict_1.default.ok(height > 0);
|
|
183
199
|
},
|
|
@@ -207,17 +223,17 @@ exports.primitiveConformanceCases = [
|
|
|
207
223
|
},
|
|
208
224
|
{
|
|
209
225
|
name: 'renders a node anchor on every node when asked',
|
|
210
|
-
run: (
|
|
226
|
+
run: (example, harness) => {
|
|
211
227
|
if (!harness.renderHTML || !harness.anchorWalk) {
|
|
212
228
|
return;
|
|
213
229
|
}
|
|
214
|
-
const composition = harness.wrapComposition(node);
|
|
230
|
+
const composition = harness.wrapComposition(example.node);
|
|
215
231
|
const { body } = harness.renderHTML(composition, { anchors: true });
|
|
216
232
|
const expected = (0, anchors_1.anchoredNodes)(composition.body, harness.anchorWalk).flatMap((anchored) => {
|
|
217
233
|
const anchoredType = (0, anchors_1.nodeType)(anchored);
|
|
218
234
|
return anchoredType === undefined ? [] : [(0, anchors_1.anchorValue)(anchoredType)];
|
|
219
235
|
});
|
|
220
|
-
strict_1.default.deepEqual(renderedAnchors(body), expected, `Expected one anchor per node, in walker order. ${previewHint(
|
|
236
|
+
strict_1.default.deepEqual(renderedAnchors(body), expected, `Expected one anchor per node, in walker order. ${previewHint(example)}`);
|
|
221
237
|
},
|
|
222
238
|
},
|
|
223
239
|
{
|
|
@@ -234,10 +250,11 @@ exports.primitiveConformanceCases = [
|
|
|
234
250
|
},
|
|
235
251
|
{
|
|
236
252
|
name: 'reaches every rendered readable class in compact CSS collection',
|
|
237
|
-
run: (
|
|
253
|
+
run: (example, harness) => {
|
|
238
254
|
if (!harness.renderHTML) {
|
|
239
255
|
return;
|
|
240
256
|
}
|
|
257
|
+
const { type, exampleIndex, node } = example;
|
|
241
258
|
const result = harness.renderHTML(harness.wrapComposition(node), {
|
|
242
259
|
css: 'separate',
|
|
243
260
|
names: 'readable',
|
|
@@ -245,7 +262,7 @@ exports.primitiveConformanceCases = [
|
|
|
245
262
|
const missing = renderedClassNames(result.body).filter((className) => !cssHasClassSelector(result.css, className));
|
|
246
263
|
const hint = `Missing CSS for ${type} example #${exampleIndex}: ` +
|
|
247
264
|
`${missing.join(', ') || '(none)'}. ` +
|
|
248
|
-
previewHint(
|
|
265
|
+
previewHint(example);
|
|
249
266
|
strict_1.default.deepEqual(missing, [], hint);
|
|
250
267
|
},
|
|
251
268
|
},
|
|
@@ -280,15 +297,14 @@ exports.primitiveConformanceCases = [
|
|
|
280
297
|
},
|
|
281
298
|
},
|
|
282
299
|
{
|
|
283
|
-
name: 'renders
|
|
300
|
+
name: 'renders a snapshot wrapped in a minimal composition',
|
|
284
301
|
run: async ({ node }, harness) => {
|
|
285
|
-
if (!harness.
|
|
302
|
+
if (!harness.renderSnapshotComposition) {
|
|
286
303
|
return;
|
|
287
304
|
}
|
|
288
|
-
const result = await harness.
|
|
305
|
+
const result = await harness.renderSnapshotComposition(harness.wrapComposition(node));
|
|
289
306
|
strict_1.default.deepEqual(result.validationErrors, []);
|
|
290
|
-
strict_1.default.ok(result.
|
|
291
|
-
strict_1.default.ok(result.svg.includes('</svg>'));
|
|
307
|
+
strict_1.default.ok(result.html.trim().length > 0);
|
|
292
308
|
strict_1.default.ok(result.measurement.total > 0);
|
|
293
309
|
},
|
|
294
310
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conformance.js","sourceRoot":"","sources":["../../../src/testing/conformance.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,6EAA6E;AAC7E,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,4EAA4E;AAC5E,yDAAyD;AAEzD,gEAAwC;AASxC,+CAK2B;AAG3B,2DAA4D;AAG5D;;;;GAIG;AACU,QAAA,0BAA0B,GAAG,gCAAgC,CAAC;AA8H3E,8DAA8D;AACvD,MAAM,uBAAuB,GAAG,CACrC,WAA8C,EACN,EAAE,CAC1C,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CACjC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;IAC/C,UAAU;IACV,IAAI,EAAE,UAAU,CAAC,IAAI;IACrB,YAAY;IACZ,IAAI;CACL,CAAC,CAAC,CACJ,CAAC;AAVS,QAAA,uBAAuB,2BAUhC;AAEJ,mEAAmE;AAC5D,MAAM,wBAAwB,GAAG,CACtC,WAA8C,EACuB,EAAE,CACvE,IAAA,+BAAuB,EAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CACvD,iCAAyB,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAClD,GAAG,OAAO;IACV,GAAG,eAAe;CACnB,CAAC,CAAC,CACJ,CAAC;AARS,QAAA,wBAAwB,4BAQjC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C;QAC9C,CAAC;KACF;IACD;QACE,IAAI,EAAE,4DAA4D;QAClE,GAAG,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE;YAC/B,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC;gBAClC,OAAO;YACT,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,oBAAoB,CAC/C,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAC9B,CAAC;YACF,gBAAM,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;YAC9C,gBAAM,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YACvC,gBAAM,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;YACzC,gBAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;KACF;CACF,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n// The behaviour every primitive definition owes its callers, expressed once.\n//\n// Framework-agnostic on purpose: only `node:assert/strict` and Node builtins,\n// so this ships on a public entry without dragging vitest into a vocabulary\n// package's dependency set. Each pack drives the array with `it.each`, so a\n// second vocabulary costs one package and one test file.\n\nimport assert from 'node:assert/strict';\n\nimport type { ChildNodeWalker } from '../composition/body_node_base';\nimport type { Composition } from '../composition/composition';\nimport type { ValidationError } from '../composition/validation_error';\nimport type {\n AnyPrimitiveDefinition,\n PrimitiveNode,\n} from '../define/primitive_module';\nimport {\n anchoredNodes,\n anchorValue,\n NODE_ANCHOR_ATTRIBUTE,\n nodeType,\n} from '../render/anchors';\nimport type { HTMLRenderResult } from '../render/html/envelope';\nimport type { SlackBlock } from '../render/slack/blocks';\nimport { checkInputBudget } from '../validate/input_budget';\nimport type { ValidationResult } from '../validate/validation';\n\n/**\n * The foreign node {@link PrimitiveConformanceHarness.nestForeignChild}\n * hands a container must render text/markdown containing this string, or the\n * cross-pack nesting case cannot tell a dropped child from an empty one.\n */\nexport const CONFORMANCE_FOREIGN_MARKER = '__isomer_conformance_foreign__';\n\n/** One example node, paired with the definition that published it. */\nexport interface PrimitiveConformanceExample {\n readonly definition: AnyPrimitiveDefinition;\n /** Always `definition.type`, lifted onto the row so `it.each` titles can read it. */\n readonly type: string;\n /** Index into {@link AnyPrimitiveDefinition.examples}, and half of the preview hint a failure prints. */\n readonly exampleIndex: number;\n readonly node: PrimitiveNode;\n}\n\n/** The subset of a host's HTML render options the cases exercise. */\nexport interface PrimitiveConformanceHtmlOptions {\n /** `'separate'` must move the stylesheet out of the markup and into `css`; the CSS cases assert against that field. */\n readonly css?: 'inline' | 'separate';\n /** `'readable'` must emit human-legible class names, which the CSS coverage case matches back against the emitted selectors. */\n readonly names?: string;\n /** Must render node anchors, as the `anchors` HTML render option does. */\n readonly anchors?: boolean;\n}\n\n/** The subset of a host's SVG render result the cases assert on. */\nexport interface PrimitiveConformanceSvgResult {\n /** Must be empty for every published example. */\n readonly validationErrors: readonly ValidationError[];\n readonly svg: string;\n /** `total` is the rendered byte size, and must be positive. */\n readonly measurement: { readonly total: number };\n}\n\n/** The subset of a host's Slack render result the cases assert on. */\nexport interface PrimitiveConformanceSlackResult {\n readonly blocks: readonly SlackBlock[];\n /** Notification fallback text. Must be non-empty. */\n readonly text: string;\n}\n\n/**\n * Pack-owned render and validation bindings. The cases cannot import a\n * vocabulary package, so the pack closes over its dispatcher, frame, and\n * theme when it builds this object.\n *\n * Unsuffixed members take a single node; the `Composition`-suffixed ones take\n * a whole {@link Composition}. Optional members gate the cases that need\n * them, so a pack supplies only what its surfaces can answer.\n */\nexport interface PrimitiveConformanceHarness {\n /**\n * The smallest composition that carries one node. Its `title` must be\n * `'Conformance fixture'`, which the envelope cases look for as\n * `CONFORMANCE FIXTURE` in text and `# Conformance fixture` in markdown.\n */\n wrapComposition(node: PrimitiveNode): Composition;\n /** Validation errors for the node on its own. Must be empty for every published example. */\n validateNode(node: PrimitiveNode): readonly ValidationError[];\n /** Whole-composition validation. Must be `valid` with no `errors` for a wrapped example. */\n validateComposition(composition: Composition): ValidationResult;\n /** Must return something other than `undefined`; the case does not mount the element. */\n renderReact(node: PrimitiveNode): unknown;\n /** Drives the pack's style collection for one node. Must not throw. */\n collectStyles(node: PrimitiveNode): void;\n /** Must return a string with non-whitespace content. */\n renderText(node: PrimitiveNode): string;\n /** Must return a string with non-whitespace content. */\n renderMarkdown(node: PrimitiveNode): string;\n /** Must return at least one block, each an object with a string `type`. */\n renderSlack(node: PrimitiveNode): readonly SlackBlock[];\n /** `key` is unique per example and only has to survive into the React tree. Must not throw. Omit for a pack with no `svg` path. */\n renderSvg?(node: PrimitiveNode, key: string): unknown;\n /** Must be finite and greater than zero, so a frame can lay the node out unrendered. Omit for a pack with no `svg` path. */\n estimateSvgHeight?(node: PrimitiveNode): number;\n /**\n * Set `false` for packs whose frame is fixed-size (`sizesFromNodeHeights: false`).\n * Skips the positive-finite height assertion, which no fixed-frame pack can satisfy.\n */\n sizesFromNodeHeights?: boolean;\n /**\n * For a container example, returns `container` with one of its children\n * replaced by a node from a pack the harness composed in only for this\n * check — never one `container`'s own pack registers. That node's `text`\n * and `markdown` renderers must emit {@link CONFORMANCE_FOREIGN_MARKER}.\n * Omit to skip the cross-pack nesting case.\n */\n nestForeignChild?(container: PrimitiveNode): PrimitiveNode;\n /**\n * Must honor {@link PrimitiveConformanceHtmlOptions}. Cases assert the\n * markup wraps the body in a `<section>`, that `measurement.js` is zero, and\n * that `validationErrors` is empty. Omit to skip the HTML cases.\n */\n renderHTML?(\n composition: Composition,\n options?: PrimitiveConformanceHtmlOptions\n ): HTMLRenderResult;\n /**\n * The child walker over every definition the harness renders with. Set it\n * once every `react` renderer spreads `nodeAnchor` on its root; the anchor\n * case then asserts each node renders one.\n */\n anchorWalk?: ChildNodeWalker;\n /** Must throw when `css` references a `var(--name)` it never declares. Omit to skip the CSS variable case. */\n assertVarRefsHaveDeclarations?(css: string): void;\n /** Whole-composition text render, title envelope included. */\n renderTextComposition(composition: Composition): string;\n /** Whole-composition markdown render, title heading included. */\n renderMarkdownComposition(composition: Composition): string;\n /** Must lead with a `plain_text` header block carrying the composition title. */\n renderSlackComposition(\n composition: Composition\n ): PrimitiveConformanceSlackResult;\n /** Must resolve to complete `<svg>`/`</svg>` markup with no validation errors. Omit for a pack with no frame. */\n renderSVGComposition?(\n composition: Composition\n ): Promise<PrimitiveConformanceSvgResult>;\n}\n\n/** One assertion, run once per example. */\nexport interface PrimitiveConformanceCase {\n readonly name: string;\n /** Signals failure by throwing. May be async, so a pack must await it. */\n readonly run: (\n example: PrimitiveConformanceExample,\n harness: PrimitiveConformanceHarness\n ) => void | Promise<void>;\n}\n\n/** Every definition's examples, flattened to one row each. */\nexport const examplesFromDefinitions = (\n definitions: readonly AnyPrimitiveDefinition[]\n): readonly PrimitiveConformanceExample[] =>\n definitions.flatMap((definition) =>\n definition.examples.map((node, exampleIndex) => ({\n definition,\n type: definition.type,\n exampleIndex,\n node,\n }))\n );\n\n/** Every example crossed with every case, shaped for `it.each`. */\nexport const primitiveConformanceRows = (\n definitions: readonly AnyPrimitiveDefinition[]\n): readonly (PrimitiveConformanceExample & PrimitiveConformanceCase)[] =>\n examplesFromDefinitions(definitions).flatMap((example) =>\n primitiveConformanceCases.map((conformanceCase) => ({\n ...example,\n ...conformanceCase,\n }))\n );\n\n/**\n * Asserts the inventory itself holds up: the pack has examples, every\n * definition contributes one, each example's `type` matches its definition,\n * and `catalog.example` is within the input budget and parses or matches a\n * published example.\n */\nexport const runPrimitiveInventoryConformance = (\n definitions: readonly AnyPrimitiveDefinition[]\n): void => {\n const examples = examplesFromDefinitions(definitions);\n assert.ok(examples.length > 0, 'expected at least one primitive example');\n for (const definition of definitions) {\n assert.ok(\n definition.examples.length > 0,\n `${definition.type} primitive must expose at least one example`\n );\n const checked = checkInputBudget(definition.catalog.example);\n if (!checked.valid) {\n assert.fail(\n `${definition.type} catalog.example must be within the input budget: ${checked.error.message}`\n );\n }\n const catalogExample = checked.value;\n const matchesPublished = definition.examples.some((node) => {\n const published = checkInputBudget(node);\n return (\n published.valid &&\n JSON.stringify(published.value) === JSON.stringify(catalogExample)\n );\n });\n if (matchesPublished) {\n continue;\n }\n const parsed = definition.schema.safeParse(catalogExample);\n assert.ok(\n parsed.success,\n `${definition.type} catalog.example must parse against its schema or match a published example`\n );\n }\n for (const { type, node } of examples) {\n assert.equal(node.type, type);\n }\n};\n\nconst previewHint = (type: string, exampleIndex: number): string =>\n `Failing example: \\`${type}\\` definition, examples[${exampleIndex}].`;\n\nconst renderedClassNames = (html: string): string[] => {\n const classNames = new Set<string>();\n for (const match of html.matchAll(/\\bclass=\"([^\"]+)\"/g)) {\n match[1]!\n .split(/\\s+/)\n .filter(Boolean)\n .forEach((className) => classNames.add(className));\n }\n return [...classNames].sort();\n};\n\n/** The node anchor values in serialized `html`, in document order. */\nconst renderedAnchors = (html: string): string[] => {\n const attribute = new RegExp(`\\\\s${NODE_ANCHOR_ATTRIBUTE}=\"([^\"]*)\"`);\n // Only opening tags: the serializer escapes `<`, `>`, and `\"` in text and attribute values.\n return [...html.matchAll(/<[a-zA-Z][^>]*>/g)].flatMap(([tag]) => {\n const [, value] = attribute.exec(tag) ?? [];\n return value === undefined ? [] : [value];\n });\n};\n\nconst cssEscapeClass = (className: string): string =>\n className.replace(/([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^`{|}~])/g, '\\\\$1');\n\nconst cssHasClassSelector = (css: string, className: string): boolean =>\n new RegExp(`\\\\.${cssEscapeClass(className)}(?![\\\\w-])`).test(css);\n\n/**\n * Every assertion a primitive owes its callers, for a pack to drive with\n * `it.each`.\n */\nexport const primitiveConformanceCases: readonly PrimitiveConformanceCase[] = [\n {\n name: 'validates as a primitive node and inside a composition',\n run: ({ type, exampleIndex, node }, harness) => {\n const hint = previewHint(type, exampleIndex);\n const primitiveErrors = [...harness.validateNode(node)];\n assert.deepEqual(primitiveErrors, [], hint);\n const result = harness.validateComposition(harness.wrapComposition(node));\n assert.equal(result.valid, true, hint);\n assert.deepEqual(result.errors, [], hint);\n },\n },\n {\n name: 'renders through React without throwing',\n run: ({ node }, harness) => {\n const rendered = harness.renderReact(node);\n assert.notEqual(rendered, undefined);\n },\n },\n {\n name: 'collects styles without throwing',\n run: ({ node }, harness) => {\n assert.doesNotThrow(() => harness.collectStyles(node));\n },\n },\n {\n name: 'a container recurses through scope for a node from another pack',\n run: ({ definition, node }, harness) => {\n if (!definition.children || !harness.nestForeignChild) {\n return;\n }\n const nested = harness.nestForeignChild(node);\n assert.notEqual(harness.renderReact(nested), undefined);\n assert.ok(\n harness.renderText(nested).includes(CONFORMANCE_FOREIGN_MARKER)\n );\n assert.ok(\n harness.renderMarkdown(nested).includes(CONFORMANCE_FOREIGN_MARKER)\n );\n },\n },\n {\n name: 'renders through plain text with non-empty output',\n run: ({ node }, harness) => {\n const text = harness.renderText(node);\n assert.equal(typeof text, 'string');\n assert.ok(text.trim().length > 0);\n },\n },\n {\n name: 'renders through markdown with non-empty output',\n run: ({ node }, harness) => {\n const markdown = harness.renderMarkdown(node);\n assert.equal(typeof markdown, 'string');\n assert.ok(markdown.trim().length > 0);\n },\n },\n {\n name: 'renders through Slack dispatch returning at least one block',\n run: ({ node }, harness) => {\n const blocks = harness.renderSlack(node);\n assert.ok(blocks.length > 0);\n for (const block of blocks) {\n assert.equal(typeof block, 'object');\n assert.equal(typeof block.type, 'string');\n }\n },\n },\n {\n name: 'renders through SVG primitive dispatch without throwing',\n run: ({ type, exampleIndex, node }, harness) => {\n if (!harness.renderSvg) {\n return;\n }\n assert.doesNotThrow(() =>\n harness.renderSvg?.(node, `conformance-${type}-${exampleIndex}`)\n );\n },\n },\n {\n name: 'reports a positive finite SVG height estimate',\n run: ({ node }, harness) => {\n if (\n harness.sizesFromNodeHeights === false ||\n !harness.estimateSvgHeight\n ) {\n return;\n }\n const height = harness.estimateSvgHeight(node);\n assert.equal(Number.isFinite(height), true);\n assert.ok(height > 0);\n },\n },\n {\n name: 'renders through renderHTML wrapped in a minimal composition',\n run: ({ node }, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const result = harness.renderHTML(harness.wrapComposition(node));\n assert.deepEqual(result.validationErrors, []);\n assert.ok(result.html.includes('<section'));\n assert.equal(result.measurement.js, 0);\n assert.ok(result.measurement.total > 0);\n },\n },\n {\n name: 'renders no node anchors unless asked',\n run: ({ node }, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const { body } = harness.renderHTML(harness.wrapComposition(node));\n assert.deepEqual(renderedAnchors(body), []);\n },\n },\n {\n name: 'renders a node anchor on every node when asked',\n run: ({ type, exampleIndex, node }, harness) => {\n if (!harness.renderHTML || !harness.anchorWalk) {\n return;\n }\n const composition = harness.wrapComposition(node);\n const { body } = harness.renderHTML(composition, { anchors: true });\n const expected = anchoredNodes(\n composition.body,\n harness.anchorWalk\n ).flatMap((anchored) => {\n const anchoredType = nodeType(anchored);\n return anchoredType === undefined ? [] : [anchorValue(anchoredType)];\n });\n assert.deepEqual(\n renderedAnchors(body),\n expected,\n `Expected one anchor per node, in walker order. ${previewHint(type, exampleIndex)}`\n );\n },\n },\n {\n name: 'emits CSS where every var(...) reference has a matching declaration',\n run: ({ node }, harness) => {\n if (!harness.renderHTML || !harness.assertVarRefsHaveDeclarations) {\n return;\n }\n const result = harness.renderHTML(harness.wrapComposition(node), {\n css: 'separate',\n });\n harness.assertVarRefsHaveDeclarations(result.css);\n },\n },\n {\n name: 'reaches every rendered readable class in compact CSS collection',\n run: ({ type, exampleIndex, node }, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const result = harness.renderHTML(harness.wrapComposition(node), {\n css: 'separate',\n names: 'readable',\n });\n const missing = renderedClassNames(result.body).filter(\n (className) => !cssHasClassSelector(result.css, className)\n );\n const hint =\n `Missing CSS for ${type} example #${exampleIndex}: ` +\n `${missing.join(', ') || '(none)'}. ` +\n previewHint(type, exampleIndex);\n assert.deepEqual(missing, [], hint);\n },\n },\n {\n name: 'renders through renderText wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const text = harness.renderTextComposition(harness.wrapComposition(node));\n assert.ok(text.length > 0);\n assert.ok(text.includes('CONFORMANCE FIXTURE'));\n },\n },\n {\n name: 'renders through renderMarkdown wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const markdown = harness.renderMarkdownComposition(\n harness.wrapComposition(node)\n );\n assert.ok(markdown.length > 0);\n assert.ok(markdown.includes('# Conformance fixture'));\n },\n },\n {\n name: 'renders through renderSlack wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const result = harness.renderSlackComposition(\n harness.wrapComposition(node)\n );\n assert.ok(result.blocks.length > 0);\n assert.ok(result.text.length > 0);\n const first = result.blocks[0];\n assert.ok(first);\n if (first.type !== 'header') {\n assert.fail(`expected a header block, got ${first.type}`);\n }\n assert.equal(first.text.type, 'plain_text');\n },\n },\n {\n name: 'renders through renderSVG wrapped in a minimal composition',\n run: async ({ node }, harness) => {\n if (!harness.renderSVGComposition) {\n return;\n }\n const result = await harness.renderSVGComposition(\n harness.wrapComposition(node)\n );\n assert.deepEqual(result.validationErrors, []);\n assert.ok(result.svg.includes('<svg'));\n assert.ok(result.svg.includes('</svg>'));\n assert.ok(result.measurement.total > 0);\n },\n },\n];\n"]}
|
|
1
|
+
{"version":3,"file":"conformance.js","sourceRoot":"","sources":["../../../src/testing/conformance.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,6EAA6E;AAC7E,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,4EAA4E;AAC5E,yDAAyD;AAEzD,gEAAwC;AAKxC,mEAA8E;AAK9E,+CAK2B;AAG3B,2DAA4D;AAG5D;;;;GAIG;A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I,CAAC,CAC9B,CAAC;YACF,gBAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACpC,gBAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAClC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC/B,gBAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;YACjB,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC5B,gBAAM,CAAC,IAAI,CAAC,gCAAgC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YAC5D,CAAC;YACD,gBAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC9C,CAAC;KACF;IACD;QACE,IAAI,EAAE,qDAAqD;QAC3D,GAAG,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE;YAC/B,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC;gBACvC,OAAO;YACT,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,yBAAyB,CACpD,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAC9B,CAAC;YACF,gBAAM,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;YAC9C,gBAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACzC,gBAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;KACF;CACF,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n// The behaviour every primitive definition owes its callers, expressed once.\n//\n// Framework-agnostic on purpose: only `node:assert/strict` and Node builtins,\n// so this ships on a public entry without dragging vitest into a vocabulary\n// package's dependency set. Each pack drives the array with `it.each`, so a\n// second vocabulary costs one package and one test file.\n\nimport assert from 'node:assert/strict';\n\nimport type { ChildNodeWalker } from '../composition/body_node_base';\nimport type { Composition } from '../composition/composition';\nimport type { ValidationError } from '../composition/validation_error';\nimport { exampleNodes, primitiveExamples } from '../define/primitive_example';\nimport type {\n AnyPrimitiveDefinition,\n PrimitiveNode,\n} from '../define/primitive_module';\nimport {\n anchoredNodes,\n anchorValue,\n NODE_ANCHOR_ATTRIBUTE,\n nodeType,\n} from '../render/anchors';\nimport type { HTMLRenderResult } from '../render/html/envelope';\nimport type { SlackBlock } from '../render/slack/blocks';\nimport { checkInputBudget } from '../validate/input_budget';\nimport type { ValidationResult } from '../validate/validation';\n\n/**\n * The foreign node {@link PrimitiveConformanceHarness.nestForeignChild}\n * hands a container must render text/markdown containing this string, or the\n * cross-pack nesting case cannot tell a dropped child from an empty one.\n */\nexport const CONFORMANCE_FOREIGN_MARKER = 'isomerConformanceForeign';\n\n/** One example node, paired with the definition that published it. */\nexport interface PrimitiveConformanceExample {\n readonly definition: AnyPrimitiveDefinition;\n /** Always `definition.type`, lifted onto the row so `it.each` titles can read it. */\n readonly type: string;\n /** Index into {@link AnyPrimitiveDefinition.examples}, and half of the preview hint a failure prints. */\n readonly exampleIndex: number;\n /** The example's `name`, absent for a bare node. */\n readonly exampleName?: string;\n readonly node: PrimitiveNode;\n}\n\n/** The subset of a host's HTML render options the cases exercise. */\nexport interface PrimitiveConformanceHtmlOptions {\n /** `'separate'` must move the stylesheet out of the markup and into `css`; the CSS cases assert against that field. */\n readonly css?: 'inline' | 'separate';\n /** `'readable'` must emit human-legible class names, which the CSS coverage case matches back against the emitted selectors. */\n readonly names?: string;\n /** Must render node anchors, as the `anchors` HTML render option does. */\n readonly anchors?: boolean;\n}\n\n/** The subset of a host's `snapshot` render result the cases assert on. */\nexport interface PrimitiveConformanceSnapshotResult {\n /** Must be empty for every published example. */\n readonly validationErrors: readonly ValidationError[];\n /** The frame's markup, stylesheet included or not. */\n readonly html: string;\n /** `total` is the rendered byte size, and must be positive. */\n readonly measurement: { readonly total: number };\n}\n\n/** The subset of a host's Slack render result the cases assert on. */\nexport interface PrimitiveConformanceSlackResult {\n readonly blocks: readonly SlackBlock[];\n /** Notification fallback text. Must be non-empty. */\n readonly text: string;\n}\n\n/**\n * Pack-owned render and validation bindings. The cases cannot import a\n * vocabulary package, so the pack closes over its dispatcher, frame, and\n * theme when it builds this object.\n *\n * Unsuffixed members take a single node; the `Composition`-suffixed ones take\n * a whole {@link Composition}. Optional members gate the cases that need\n * them, so a pack supplies only what its surfaces can answer.\n */\nexport interface PrimitiveConformanceHarness {\n /**\n * The smallest composition that carries one node. Its `title` must be\n * `'Conformance fixture'`, which the envelope cases look for as\n * `CONFORMANCE FIXTURE` in text and `# Conformance fixture` in markdown.\n */\n wrapComposition(node: PrimitiveNode): Composition;\n /** Validation errors for the node on its own. Must be empty for every published example. */\n validateNode(node: PrimitiveNode): readonly ValidationError[];\n /** Whole-composition validation. Must be `valid` with no `errors` for a wrapped example. */\n validateComposition(composition: Composition): ValidationResult;\n /** Must return something other than `undefined`; the case does not mount the element. */\n renderReact(node: PrimitiveNode): unknown;\n /** Drives the pack's style collection for one node. Must not throw. */\n collectStyles(node: PrimitiveNode): void;\n /** Must return a string with non-whitespace content. */\n renderText(node: PrimitiveNode): string;\n /** Must return a string with non-whitespace content. */\n renderMarkdown(node: PrimitiveNode): string;\n /** Must return at least one block, each an object with a string `type`. */\n renderSlack(node: PrimitiveNode): readonly SlackBlock[];\n /** `key` is unique per example and only has to survive into the React tree. Must not throw. Omit for a pack with no `snapshot` path. */\n renderSnapshot?(node: PrimitiveNode, key: string): unknown;\n /** Must be finite and greater than zero, so a frame can lay the node out unrendered. Omit for a pack with no `snapshot` path. */\n estimateSnapshotHeight?(node: PrimitiveNode): number;\n /**\n * Set `false` for a pack whose frame is a fixed size, so its primitives are\n * not required to report a positive `metrics.snapshotHeight`. Skips the\n * positive-finite height assertion.\n */\n sizesFromNodeHeights?: boolean;\n /**\n * For a container example, returns `container` with one of its children\n * replaced by a node from a pack the harness composed in only for this\n * check — never one `container`'s own pack registers. That node's `text`\n * and `markdown` renderers must emit {@link CONFORMANCE_FOREIGN_MARKER}.\n * Omit to skip the cross-pack nesting case.\n */\n nestForeignChild?(container: PrimitiveNode): PrimitiveNode;\n /**\n * Must honor {@link PrimitiveConformanceHtmlOptions}. Cases assert the\n * markup wraps the body in a `<section>`, that `measurement.js` is zero, and\n * that `validationErrors` is empty. Omit to skip the HTML cases.\n */\n renderHTML?(\n composition: Composition,\n options?: PrimitiveConformanceHtmlOptions\n ): HTMLRenderResult;\n /**\n * The child walker over every definition the harness renders with. Set it\n * once every `react` renderer spreads `nodeAnchor` on its root; the anchor\n * case then asserts each node renders one.\n */\n anchorWalk?: ChildNodeWalker;\n /** Must throw when `css` references a `var(--name)` it never declares. Omit to skip the CSS variable case. */\n assertVarRefsHaveDeclarations?(css: string): void;\n /** Whole-composition text render, title envelope included. */\n renderTextComposition(composition: Composition): string;\n /** Whole-composition markdown render, title heading included. */\n renderMarkdownComposition(composition: Composition): string;\n /** Must lead with a `plain_text` header block carrying the composition title. */\n renderSlackComposition(\n composition: Composition\n ): PrimitiveConformanceSlackResult;\n /** Must resolve to non-empty markup with no validation errors. Omit for a pack with no frame. */\n renderSnapshotComposition?(\n composition: Composition\n ): Promise<PrimitiveConformanceSnapshotResult>;\n}\n\n/** One assertion, run once per example. */\nexport interface PrimitiveConformanceCase {\n readonly name: string;\n /** Signals failure by throwing. May be async, so a pack must await it. */\n readonly run: (\n example: PrimitiveConformanceExample,\n harness: PrimitiveConformanceHarness\n ) => void | Promise<void>;\n}\n\n/** Every definition's examples, flattened to one row each. */\nexport const examplesFromDefinitions = (\n definitions: readonly AnyPrimitiveDefinition[]\n): readonly PrimitiveConformanceExample[] =>\n definitions.flatMap((definition) =>\n primitiveExamples(definition).map(({ name, node }, exampleIndex) => ({\n definition,\n type: definition.type,\n exampleIndex,\n ...(name === undefined ? {} : { exampleName: name }),\n node,\n }))\n );\n\n/** Every example crossed with every case, shaped for `it.each`. */\nexport const primitiveConformanceRows = (\n definitions: readonly AnyPrimitiveDefinition[]\n): readonly (PrimitiveConformanceExample & PrimitiveConformanceCase)[] =>\n examplesFromDefinitions(definitions).flatMap((example) =>\n primitiveConformanceCases.map((conformanceCase) => ({\n ...example,\n ...conformanceCase,\n }))\n );\n\n/**\n * Asserts the inventory itself holds up: the pack has examples, every\n * definition contributes one, `catalog.name` and example names are non-empty,\n * example names are unique within their definition, each example's `type` matches its definition, and\n * `catalog.example` is within the input budget and parses or matches a\n * published example.\n */\nexport const runPrimitiveInventoryConformance = (\n definitions: readonly AnyPrimitiveDefinition[]\n): void => {\n const examples = examplesFromDefinitions(definitions);\n assert.ok(examples.length > 0, 'expected at least one primitive example');\n for (const definition of definitions) {\n assert.ok(\n definition.examples.length > 0,\n `${definition.type} primitive must expose at least one example`\n );\n const { name: catalogName } = definition.catalog;\n assert.ok(\n catalogName === undefined || catalogName.trim().length > 0,\n `${definition.type} catalog.name must be non-empty when present`\n );\n const names = new Set<string>();\n for (const { name } of primitiveExamples(definition)) {\n if (name === undefined) {\n continue;\n }\n assert.ok(\n name.trim().length > 0,\n `${definition.type} example names must be non-empty`\n );\n assert.ok(\n !names.has(name),\n `${definition.type} has two examples named ${JSON.stringify(name)}`\n );\n names.add(name);\n }\n const checked = checkInputBudget(definition.catalog.example);\n if (!checked.valid) {\n assert.fail(\n `${definition.type} catalog.example must be within the input budget: ${checked.error.message}`\n );\n }\n const catalogExample = checked.value;\n const matchesPublished = exampleNodes(definition).some((node) => {\n const published = checkInputBudget(node);\n return (\n published.valid &&\n JSON.stringify(published.value) === JSON.stringify(catalogExample)\n );\n });\n if (matchesPublished) {\n continue;\n }\n const parsed = definition.schema.safeParse(catalogExample);\n assert.ok(\n parsed.success,\n `${definition.type} catalog.example must parse against its schema or match a published example`\n );\n }\n for (const { type, node } of examples) {\n assert.equal(node.type, type);\n }\n};\n\nconst previewHint = ({\n type,\n exampleIndex,\n exampleName,\n}: PrimitiveConformanceExample): string =>\n `Failing example: \\`${type}\\` definition, examples[${exampleIndex}]` +\n `${exampleName === undefined ? '' : ` (${JSON.stringify(exampleName)})`}.`;\n\nconst renderedClassNames = (html: string): string[] => {\n const classNames = new Set<string>();\n for (const match of html.matchAll(/\\bclass=\"([^\"]+)\"/g)) {\n match[1]!\n .split(/\\s+/)\n .filter(Boolean)\n .forEach((className) => classNames.add(className));\n }\n return [...classNames].sort();\n};\n\n/** The node anchor values in serialized `html`, in document order. */\nconst renderedAnchors = (html: string): string[] => {\n const attribute = new RegExp(`\\\\s${NODE_ANCHOR_ATTRIBUTE}=\"([^\"]*)\"`);\n // Only opening tags: the serializer escapes `<`, `>`, and `\"` in text and attribute values.\n return [...html.matchAll(/<[a-zA-Z][^>]*>/g)].flatMap(([tag]) => {\n const [, value] = attribute.exec(tag) ?? [];\n return value === undefined ? [] : [value];\n });\n};\n\nconst cssEscapeClass = (className: string): string =>\n className.replace(/([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^`{|}~])/g, '\\\\$1');\n\nconst cssHasClassSelector = (css: string, className: string): boolean =>\n new RegExp(`\\\\.${cssEscapeClass(className)}(?![\\\\w-])`).test(css);\n\n/**\n * Every assertion a primitive owes its callers, for a pack to drive with\n * `it.each`.\n */\nexport const primitiveConformanceCases: readonly PrimitiveConformanceCase[] = [\n {\n name: 'validates as a primitive node and inside a composition',\n run: (example, harness) => {\n const { node } = example;\n const hint = previewHint(example);\n const primitiveErrors = [...harness.validateNode(node)];\n assert.deepEqual(primitiveErrors, [], hint);\n const result = harness.validateComposition(harness.wrapComposition(node));\n assert.equal(result.valid, true, hint);\n assert.deepEqual(result.errors, [], hint);\n },\n },\n {\n name: 'renders through React without throwing',\n run: ({ node }, harness) => {\n const rendered = harness.renderReact(node);\n assert.notEqual(rendered, undefined);\n },\n },\n {\n name: 'collects styles without throwing',\n run: ({ node }, harness) => {\n assert.doesNotThrow(() => harness.collectStyles(node));\n },\n },\n {\n name: 'a container recurses through scope for a node from another pack',\n run: ({ definition, node }, harness) => {\n if (!definition.children || !harness.nestForeignChild) {\n return;\n }\n const nested = harness.nestForeignChild(node);\n assert.notEqual(harness.renderReact(nested), undefined);\n assert.ok(\n harness.renderText(nested).includes(CONFORMANCE_FOREIGN_MARKER)\n );\n assert.ok(\n harness.renderMarkdown(nested).includes(CONFORMANCE_FOREIGN_MARKER)\n );\n },\n },\n {\n name: 'renders through plain text with non-empty output',\n run: ({ node }, harness) => {\n const text = harness.renderText(node);\n assert.equal(typeof text, 'string');\n assert.ok(text.trim().length > 0);\n },\n },\n {\n name: 'renders through markdown with non-empty output',\n run: ({ node }, harness) => {\n const markdown = harness.renderMarkdown(node);\n assert.equal(typeof markdown, 'string');\n assert.ok(markdown.trim().length > 0);\n },\n },\n {\n name: 'renders through Slack dispatch returning at least one block',\n run: ({ node }, harness) => {\n const blocks = harness.renderSlack(node);\n assert.ok(blocks.length > 0);\n for (const block of blocks) {\n assert.equal(typeof block, 'object');\n assert.equal(typeof block.type, 'string');\n }\n },\n },\n {\n name: 'renders through snapshot primitive dispatch without throwing',\n run: ({ type, exampleIndex, node }, harness) => {\n if (!harness.renderSnapshot) {\n return;\n }\n assert.doesNotThrow(() =>\n harness.renderSnapshot?.(node, `conformance-${type}-${exampleIndex}`)\n );\n },\n },\n {\n name: 'reports a positive finite snapshot height estimate',\n run: ({ node }, harness) => {\n if (\n harness.sizesFromNodeHeights === false ||\n !harness.estimateSnapshotHeight\n ) {\n return;\n }\n const height = harness.estimateSnapshotHeight(node);\n assert.equal(Number.isFinite(height), true);\n assert.ok(height > 0);\n },\n },\n {\n name: 'renders through renderHTML wrapped in a minimal composition',\n run: ({ node }, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const result = harness.renderHTML(harness.wrapComposition(node));\n assert.deepEqual(result.validationErrors, []);\n assert.ok(result.html.includes('<section'));\n assert.equal(result.measurement.js, 0);\n assert.ok(result.measurement.total > 0);\n },\n },\n {\n name: 'renders no node anchors unless asked',\n run: ({ node }, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const { body } = harness.renderHTML(harness.wrapComposition(node));\n assert.deepEqual(renderedAnchors(body), []);\n },\n },\n {\n name: 'renders a node anchor on every node when asked',\n run: (example, harness) => {\n if (!harness.renderHTML || !harness.anchorWalk) {\n return;\n }\n const composition = harness.wrapComposition(example.node);\n const { body } = harness.renderHTML(composition, { anchors: true });\n const expected = anchoredNodes(\n composition.body,\n harness.anchorWalk\n ).flatMap((anchored) => {\n const anchoredType = nodeType(anchored);\n return anchoredType === undefined ? [] : [anchorValue(anchoredType)];\n });\n assert.deepEqual(\n renderedAnchors(body),\n expected,\n `Expected one anchor per node, in walker order. ${previewHint(example)}`\n );\n },\n },\n {\n name: 'emits CSS where every var(...) reference has a matching declaration',\n run: ({ node }, harness) => {\n if (!harness.renderHTML || !harness.assertVarRefsHaveDeclarations) {\n return;\n }\n const result = harness.renderHTML(harness.wrapComposition(node), {\n css: 'separate',\n });\n harness.assertVarRefsHaveDeclarations(result.css);\n },\n },\n {\n name: 'reaches every rendered readable class in compact CSS collection',\n run: (example, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const { type, exampleIndex, node } = example;\n const result = harness.renderHTML(harness.wrapComposition(node), {\n css: 'separate',\n names: 'readable',\n });\n const missing = renderedClassNames(result.body).filter(\n (className) => !cssHasClassSelector(result.css, className)\n );\n const hint =\n `Missing CSS for ${type} example #${exampleIndex}: ` +\n `${missing.join(', ') || '(none)'}. ` +\n previewHint(example);\n assert.deepEqual(missing, [], hint);\n },\n },\n {\n name: 'renders through renderText wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const text = harness.renderTextComposition(harness.wrapComposition(node));\n assert.ok(text.length > 0);\n assert.ok(text.includes('CONFORMANCE FIXTURE'));\n },\n },\n {\n name: 'renders through renderMarkdown wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const markdown = harness.renderMarkdownComposition(\n harness.wrapComposition(node)\n );\n assert.ok(markdown.length > 0);\n assert.ok(markdown.includes('# Conformance fixture'));\n },\n },\n {\n name: 'renders through renderSlack wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const result = harness.renderSlackComposition(\n harness.wrapComposition(node)\n );\n assert.ok(result.blocks.length > 0);\n assert.ok(result.text.length > 0);\n const first = result.blocks[0];\n assert.ok(first);\n if (first.type !== 'header') {\n assert.fail(`expected a header block, got ${first.type}`);\n }\n assert.equal(first.text.type, 'plain_text');\n },\n },\n {\n name: 'renders a snapshot wrapped in a minimal composition',\n run: async ({ node }, harness) => {\n if (!harness.renderSnapshotComposition) {\n return;\n }\n const result = await harness.renderSnapshotComposition(\n harness.wrapComposition(node)\n );\n assert.deepEqual(result.validationErrors, []);\n assert.ok(result.html.trim().length > 0);\n assert.ok(result.measurement.total > 0);\n },\n },\n];\n"]}
|