@elastic/isomer-sdk 0.2.0 → 0.4.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/THIRD_PARTY_LICENSES.md +1 -885
- package/dist/author/authored_fields.d.ts +37 -12
- package/dist/author/authored_fields.d.ts.map +1 -1
- package/dist/author/authored_fields.js +45 -69
- package/dist/author/authored_fields.js.map +1 -1
- package/dist/author/authoring_input.d.ts.map +1 -1
- package/dist/author/authoring_input.js +12 -6
- package/dist/author/authoring_input.js.map +1 -1
- package/dist/author/authoring_model.d.ts +8 -2
- package/dist/author/authoring_model.d.ts.map +1 -1
- package/dist/author/authoring_model.js +67 -23
- package/dist/author/authoring_model.js.map +1 -1
- package/dist/author/declarations.d.ts.map +1 -1
- package/dist/author/declarations.js +45 -34
- package/dist/author/declarations.js.map +1 -1
- package/dist/author/index.d.ts +2 -1
- package/dist/author/index.d.ts.map +1 -1
- package/dist/author/index.js +2 -1
- package/dist/author/index.js.map +1 -1
- package/dist/author/jsx_shim.d.ts +49 -30
- package/dist/author/jsx_shim.d.ts.map +1 -1
- package/dist/author/jsx_shim.js +131 -40
- 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.map +1 -1
- package/dist/author/schema_to_typescript.js +6 -3
- package/dist/author/schema_to_typescript.js.map +1 -1
- package/dist/cjs/author/authored_fields.js +47 -70
- package/dist/cjs/author/authored_fields.js.map +1 -1
- package/dist/cjs/author/authoring_input.js +12 -6
- package/dist/cjs/author/authoring_input.js.map +1 -1
- package/dist/cjs/author/authoring_model.js +69 -24
- package/dist/cjs/author/authoring_model.js.map +1 -1
- package/dist/cjs/author/declarations.js +44 -33
- package/dist/cjs/author/declarations.js.map +1 -1
- package/dist/cjs/author/index.js +5 -1
- package/dist/cjs/author/index.js.map +1 -1
- package/dist/cjs/author/jsx_shim.js +130 -39
- 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 +6 -3
- package/dist/cjs/author/schema_to_typescript.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/structured_value.js.map +1 -1
- package/dist/cjs/define/index.js.map +1 -1
- package/dist/cjs/define/primitive_module.js +10 -4
- package/dist/cjs/define/primitive_module.js.map +1 -1
- package/dist/cjs/define/slack_blocks.js.map +1 -1
- package/dist/cjs/entries/index.js +5 -2
- package/dist/cjs/entries/index.js.map +1 -1
- package/dist/cjs/entries/markdown.js +3 -1
- package/dist/cjs/entries/markdown.js.map +1 -1
- package/dist/cjs/entries/react.js +2 -1
- package/dist/cjs/entries/react.js.map +1 -1
- package/dist/cjs/entries/slack.js +5 -1
- package/dist/cjs/entries/slack.js.map +1 -1
- package/dist/cjs/pack/enhancements.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 +14 -4
- package/dist/cjs/pack/primitive_pack.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/markdown/blocks.js +82 -0
- package/dist/cjs/render/markdown/blocks.js.map +1 -0
- package/dist/cjs/render/markdown/builder.js +6 -2
- package/dist/cjs/render/markdown/builder.js.map +1 -1
- package/dist/cjs/render/markdown/format.js +46 -24
- 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 +5 -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 +36 -6
- 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/react/index.js +3 -1
- package/dist/cjs/render/react/index.js.map +1 -1
- package/dist/cjs/render/react/markdown_content.js +143 -0
- package/dist/cjs/render/react/markdown_content.js.map +1 -0
- package/dist/cjs/render/slack/blocks.js +7 -0
- package/dist/cjs/render/slack/blocks.js.map +1 -1
- package/dist/cjs/render/slack/container.js +62 -0
- package/dist/cjs/render/slack/container.js.map +1 -0
- package/dist/cjs/render/slack/envelope.js +70 -14
- package/dist/cjs/render/slack/envelope.js.map +1 -1
- package/dist/cjs/render/slack/format.js +56 -6
- package/dist/cjs/render/slack/format.js.map +1 -1
- package/dist/cjs/render/slack/index.js +7 -1
- package/dist/cjs/render/slack/index.js.map +1 -1
- package/dist/cjs/render/slack/markdown_content.js +36 -77
- package/dist/cjs/render/slack/markdown_content.js.map +1 -1
- package/dist/cjs/render/slack/unmodeled.js +38 -0
- package/dist/cjs/render/slack/unmodeled.js.map +1 -0
- package/dist/cjs/testing/conformance.js +15 -1
- package/dist/cjs/testing/conformance.js.map +1 -1
- package/dist/cjs/testing/index.js +2 -1
- package/dist/cjs/testing/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/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/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/index.d.ts +1 -1
- package/dist/define/index.d.ts.map +1 -1
- package/dist/define/index.js.map +1 -1
- package/dist/define/primitive_module.d.ts +14 -5
- package/dist/define/primitive_module.d.ts.map +1 -1
- package/dist/define/primitive_module.js +10 -4
- package/dist/define/primitive_module.js.map +1 -1
- package/dist/define/slack_blocks.d.ts +31 -1
- package/dist/define/slack_blocks.d.ts.map +1 -1
- package/dist/define/slack_blocks.js.map +1 -1
- package/dist/entries/index.d.ts +2 -2
- package/dist/entries/index.d.ts.map +1 -1
- package/dist/entries/index.js +2 -2
- 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/react.d.ts +1 -1
- package/dist/entries/react.d.ts.map +1 -1
- package/dist/entries/react.js +1 -1
- package/dist/entries/react.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/enhancements.d.ts +4 -0
- package/dist/pack/enhancements.d.ts.map +1 -1
- package/dist/pack/enhancements.js.map +1 -1
- package/dist/pack/index.d.ts +1 -1
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +1 -1
- package/dist/pack/index.js.map +1 -1
- package/dist/pack/primitive_pack.d.ts +3 -1
- package/dist/pack/primitive_pack.d.ts.map +1 -1
- package/dist/pack/primitive_pack.js +13 -3
- package/dist/pack/primitive_pack.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.js +12 -6
- package/dist/render/html/envelope.js.map +1 -1
- package/dist/render/markdown/blocks.d.ts +6 -0
- package/dist/render/markdown/blocks.d.ts.map +1 -0
- package/dist/render/markdown/blocks.js +77 -0
- package/dist/render/markdown/blocks.js.map +1 -0
- package/dist/render/markdown/builder.d.ts +3 -0
- package/dist/render/markdown/builder.d.ts.map +1 -1
- package/dist/render/markdown/builder.js +3 -1
- package/dist/render/markdown/builder.js.map +1 -1
- package/dist/render/markdown/format.d.ts +2 -0
- package/dist/render/markdown/format.d.ts.map +1 -1
- package/dist/render/markdown/format.js +42 -22
- 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 +2 -0
- package/dist/render/markdown/index.d.ts.map +1 -1
- package/dist/render/markdown/index.js +2 -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 +4 -2
- package/dist/render/primitive_dispatch.d.ts.map +1 -1
- package/dist/render/primitive_dispatch.js +36 -6
- 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/react/index.d.ts +1 -0
- package/dist/render/react/index.d.ts.map +1 -1
- package/dist/render/react/index.js +1 -0
- package/dist/render/react/index.js.map +1 -1
- package/dist/render/react/markdown_content.d.ts +9 -0
- package/dist/render/react/markdown_content.d.ts.map +1 -0
- package/dist/render/react/markdown_content.js +139 -0
- package/dist/render/react/markdown_content.js.map +1 -0
- package/dist/render/slack/blocks.d.ts +8 -1
- package/dist/render/slack/blocks.d.ts.map +1 -1
- package/dist/render/slack/blocks.js +7 -0
- package/dist/render/slack/blocks.js.map +1 -1
- package/dist/render/slack/container.d.ts +25 -0
- package/dist/render/slack/container.d.ts.map +1 -0
- package/dist/render/slack/container.js +55 -0
- package/dist/render/slack/container.js.map +1 -0
- package/dist/render/slack/envelope.d.ts +6 -4
- package/dist/render/slack/envelope.d.ts.map +1 -1
- package/dist/render/slack/envelope.js +71 -15
- package/dist/render/slack/envelope.js.map +1 -1
- package/dist/render/slack/format.d.ts +15 -3
- package/dist/render/slack/format.d.ts.map +1 -1
- package/dist/render/slack/format.js +54 -5
- package/dist/render/slack/format.js.map +1 -1
- package/dist/render/slack/index.d.ts +4 -2
- package/dist/render/slack/index.d.ts.map +1 -1
- package/dist/render/slack/index.js +2 -0
- package/dist/render/slack/index.js.map +1 -1
- package/dist/render/slack/markdown_content.d.ts +3 -2
- package/dist/render/slack/markdown_content.d.ts.map +1 -1
- package/dist/render/slack/markdown_content.js +27 -68
- package/dist/render/slack/markdown_content.js.map +1 -1
- package/dist/render/slack/unmodeled.d.ts +16 -0
- package/dist/render/slack/unmodeled.d.ts.map +1 -0
- package/dist/render/slack/unmodeled.js +32 -0
- package/dist/render/slack/unmodeled.js.map +1 -0
- package/dist/testing/conformance.d.ts +3 -1
- package/dist/testing/conformance.d.ts.map +1 -1
- package/dist/testing/conformance.js +14 -0
- package/dist/testing/conformance.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/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/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js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AC,CAAC,CAAC;IAC/C,IAAI,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC;QAC3E,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7C,IAAI,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC;QACrE,GAAG,GAAG,IAAI,CAAC;IACb,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC;AAC7C,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,GAAW,EAAU,EAAE;IAClE,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAChC,OAAO,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAC/D,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACxD,cAAc,CACZ,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EACjC,YAAY,CAAC,eAAe,CAC7B,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// Slack mrkdwn helpers.\n//\n// Slack uses a flavour of Markdown called \"mrkdwn\" that differs from CommonMark\n// in subtle ways: links are `<url|label>`, code uses single backticks (or\n// fenced ```` ``` ```` blocks), and `&`, `<`, `>` must be HTML-escaped inside\n// any text element. These helpers centralize the escaping so primitive\n// renderers cannot accidentally emit a literal `<https://...>` that Slack\n// would parse as auto-link with no label.\n//\n// See https://api.slack.com/reference/surfaces/formatting\n\nimport { sanitizeNavigationHref } from '../../validate/url';\n\nimport { SLACK_LIMITS } from './blocks';\n\nconst MRKDWN_ESCAPES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n};\n\n/**\n * Escapes the three characters Slack treats as HTML in `mrkdwn` text.\n *\n * The formatting markers (`*`, `_`, `~`, `` ` ``) are left intact so callers\n * can compose markdown with them. Wrap text in {@link code} when literal\n * asterisks are needed.\n */\nexport const escapeMrkdwn = (value: string): string =>\n value.replace(/[&<>]/g, (match) => MRKDWN_ESCAPES[match] ?? match);\n\n/** `text` escaped and wrapped in mrkdwn bold markers. */\nexport const bold = (text: string): string => `*${escapeMrkdwn(text)}*`;\n/** `text` escaped and wrapped in mrkdwn italic markers. */\nexport const italic = (text: string): string => `_${escapeMrkdwn(text)}_`;\n/** `text` escaped and wrapped in mrkdwn strikethrough markers. */\nexport const strike = (text: string): string => `~${escapeMrkdwn(text)}~`;\n\n/**\n * Inline code span. Contents are not mrkdwn-escaped, since `<` and friends are\n * literal inside a code span; only embedded backticks are demoted, to a\n * modifier letter that cannot close the span.\n */\nexport const code = (text: string): string =>\n `\\`${text.replace(/`/g, '\\u02CB')}\\``;\n\n/**\n * Fenced code block. Slack honours the triple-backtick fence but not a language\n * hint. Embedded triple-backticks are demoted with a zero-width joiner so they\n * cannot terminate the block early.\n */\nexport const codeBlock = (text: string): string =>\n `\\`\\`\\`\\n${text.replace(/```/g, '``\\u200d`')}\\n\\`\\`\\``;\n\nconst URL_PARTS_RE = /^([a-z][a-z0-9+.-]*:(?:\\/\\/[^/?#]*)?)(.*)$/is;\n// Letter, digit, and hyphen labels, with an optional DNS root dot.\nconst DNS_NAME_RE =\n /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*\\.?$/i;\nconst IPV6_HOST_RE = /^\\[[0-9a-f:.]+\\]$/i;\n\nconst MALFORMED_ESCAPE_RE = /%(?![0-9a-f]{2})/i;\n\n// `url` parsed, when its escapes are well formed and `URL` prints it as\n// written up to the case of its scheme and authority and a `/` for an empty\n// path.\nconst parsedAsWritten = (url: string): URL | null => {\n if (MALFORMED_ESCAPE_RE.test(url)) {\n return null;\n }\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n const [, prefix, rest] = URL_PARTS_RE.exec(url) ?? [];\n const [, printedPrefix, printedRest] = URL_PARTS_RE.exec(parsed.href) ?? [];\n return prefix !== undefined &&\n prefix.toLowerCase() === printedPrefix?.toLowerCase() &&\n (printedRest === rest || printedRest === `/${rest}`)\n ? parsed\n : null;\n};\n\n/**\n * Whether `url` is an `http:` or `https:` URL with a DNS or IPv6 host that\n * `URL` prints as written, so nothing it repairs or encodes, such as a\n * backslash, whitespace, or non-ASCII, passes.\n */\nexport const isAbsoluteHttpUrl = (url: string): boolean => {\n const parsed = parsedAsWritten(url);\n return (\n (parsed?.protocol === 'http:' || parsed?.protocol === 'https:') &&\n (DNS_NAME_RE.test(parsed.hostname) || IPV6_HOST_RE.test(parsed.hostname))\n );\n};\n\n// RFC 5322 dot-atom text, less `/`, `?`, `#`, and `%`.\nconst LOCAL_PART_RE =\n /^[a-z0-9!$&'*+=^_`{|}~-]+(?:\\.[a-z0-9!$&'*+=^_`{|}~-]+)*$/i;\n\nconst isMailbox = (recipient: string): boolean => {\n const at = recipient.lastIndexOf('@');\n return (\n at > 0 &&\n LOCAL_PART_RE.test(recipient.slice(0, at)) &&\n DNS_NAME_RE.test(recipient.slice(at + 1))\n );\n};\n\nconst decoded = (value: string): string | null => {\n try {\n return decodeURIComponent(value);\n } catch {\n return null;\n }\n};\n\n// Every comma-separated recipient before the query or fragment is a mailbox.\nconst isMailtoUrl = (url: string): boolean => {\n const [, recipients] = /^mailto:([^?#]*)/i.exec(url) ?? [];\n return (\n recipients !== undefined &&\n parsedAsWritten(url) !== null &&\n recipients\n .split(',')\n .every((recipient) => isMailbox(decoded(recipient) ?? ''))\n );\n};\n\n/**\n * `href` when {@link sanitizeNavigationHref} passes it and it is an `http:` or\n * `https:` URL with a host, or a `mailto:` of well-formed mailboxes; `null`\n * otherwise. Slack has no page to resolve a relative URL against.\n */\nexport const slackLinkUrl = (href: string): string | null => {\n const url = sanitizeNavigationHref(href);\n if (url === null) {\n return null;\n }\n return isAbsoluteHttpUrl(url) || isMailtoUrl(url) ? url : null;\n};\n\n/**\n * Slack mrkdwn link, `<url|label>`, or a bare `<url>` when `label` is omitted.\n *\n * URL and label are both escaped so `&` and `>` cannot break Slack's link\n * parser, and a `|` in the URL is percent-encoded so it cannot end the URL\n * early. A URL {@link slackLinkUrl} rejects degrades to plain escaped text\n * with no link.\n */\nexport const link = (url: string, label?: string): string => {\n const sanitized = slackLinkUrl(url);\n if (!sanitized) {\n return escapeMrkdwn(label ?? url);\n }\n const safeUrl = escapeMrkdwn(sanitized).replaceAll('|', '%7C');\n if (!label) {\n return `<${safeUrl}>`;\n }\n return `<${safeUrl}|${escapeMrkdwn(label)}>`;\n};\n\n/**\n * Truncates `value` to `max` UTF-16 code units at a grapheme boundary,\n * appending an ellipsis when it had to cut. Pass a `SLACK_LIMITS` constant as\n * the budget.\n */\nexport const clampSlackText = (value: string, max: number): string => {\n if (value.length <= max) {\n return value;\n }\n const budget = max <= 1 ? max : max - 1;\n let end = 0;\n for (const { index, segment } of new Intl.Segmenter(undefined, {\n granularity: 'grapheme',\n }).segment(value)) {\n if (index + segment.length > budget) {\n break;\n }\n end = index + segment.length;\n }\n const head = value.slice(0, end);\n return max <= 1 ? head : `${head.trimEnd()}…`;\n};\n\n// A `<…>` link or mention and an entity, each matched where it starts.\nconst LINK_TOKEN_RE = /<[^<>\\n]*>/y;\nconst ENTITY_TOKEN_RE = /&(?:amp|lt|gt);/y;\n\n// The end of the token `re` matches at `index`, or `undefined`.\nconst tokenEnd = (\n value: string,\n re: RegExp,\n index: number\n): number | undefined => {\n re.lastIndex = index;\n return re.test(value) ? re.lastIndex : undefined;\n};\n\n/**\n * {@link clampSlackText} for `mrkdwn`: never cuts inside a `<…>` link or\n * mention or an entity. Formatting marks are left as they fall; Slack prints an\n * unclosed one as written.\n */\nexport const clampMrkdwn = (value: string, max: number): string => {\n const clamped = clampSlackText(value, max);\n if (clamped === value || max <= 1) {\n return clamped;\n }\n // Entity first: a link holds no `<` of its own, so stepping back to its\n // start cannot land inside an entity, while the reverse could.\n let cut = clamped.length - 1;\n const entity = value.lastIndexOf('&', cut - 1);\n if (entity !== -1 && (tokenEnd(value, ENTITY_TOKEN_RE, entity) ?? 0) > cut) {\n cut = entity;\n }\n const link = value.lastIndexOf('<', cut - 1);\n if (link !== -1 && (tokenEnd(value, LINK_TOKEN_RE, link) ?? 0) > cut) {\n cut = link;\n }\n return `${value.slice(0, cut).trimEnd()}…`;\n};\n\n/**\n * `value` cut to `max` UTF-16 code units, never through a surrogate pair. For\n * opaque values a host reads back, which an ellipsis would change.\n */\nexport const cutSlackValue = (value: string, max: number): string => {\n const cut = value.slice(0, max);\n return /[\\ud800-\\udbff]$/.test(cut) ? cut.slice(0, -1) : cut;\n};\n\n/**\n * Collapses whitespace and clamps to `SLACK_LIMITS.headerTextChars`. Header\n * text is `plain_text`, so no markdown survives — do not pre-format it.\n */\nexport const formatHeaderText = (value: string): string =>\n clampSlackText(\n value.replace(/\\s+/g, ' ').trim(),\n SLACK_LIMITS.headerTextChars\n );\n"]}
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/render/slack/format.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAwB;AAC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AC,CAAC;IAChC,OAAO,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAC/D,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE,CACxD,cAAc,CACZ,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EACjC,YAAY,CAAC,eAAe,CAC7B,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// Slack mrkdwn helpers.\n//\n// Slack uses a flavour of Markdown called \"mrkdwn\" that differs from CommonMark\n// in subtle ways: links are `<url|label>`, code uses single backticks (or\n// fenced ```` ``` ```` blocks), and `&`, `<`, `>` must be HTML-escaped inside\n// any text element. These helpers centralize the escaping so primitive\n// renderers cannot accidentally emit a literal `<https://...>` that Slack\n// would parse as auto-link with no label.\n//\n// See https://api.slack.com/reference/surfaces/formatting\n\nimport { IsomerError } from '../../composition/error';\nimport { sanitizeNavigationHref } from '../../validate/url';\n\nimport { SLACK_LIMITS } from './blocks';\n\nconst MRKDWN_ESCAPES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n};\n\n/**\n * Escapes the three characters Slack treats as HTML in `mrkdwn` text.\n *\n * The formatting markers (`*`, `_`, `~`, `` ` ``) are left intact so callers\n * can compose markdown with them. Wrap text in {@link code} when literal\n * asterisks are needed.\n */\nexport const escapeMrkdwn = (value: string): string =>\n value.replace(/[&<>]/g, (match) => MRKDWN_ESCAPES[match] ?? match);\n\n/** `text` escaped and wrapped in mrkdwn bold markers. */\nexport const bold = (text: string): string => `*${escapeMrkdwn(text)}*`;\n/** `text` escaped and wrapped in mrkdwn italic markers. */\nexport const italic = (text: string): string => `_${escapeMrkdwn(text)}_`;\n/** `text` escaped and wrapped in mrkdwn strikethrough markers. */\nexport const strike = (text: string): string => `~${escapeMrkdwn(text)}~`;\n\n/**\n * Inline code span. Contents are not mrkdwn-escaped, since `<` and friends are\n * literal inside a code span; only embedded backticks are demoted, to a\n * modifier letter that cannot close the span.\n */\nexport const code = (text: string): string =>\n `\\`${text.replace(/`/g, '\\u02CB')}\\``;\n\n/**\n * Fenced code block. Slack honours the triple-backtick fence but not a language\n * hint. Embedded triple-backticks are demoted with a zero-width joiner so they\n * cannot terminate the block early.\n */\nexport const codeBlock = (text: string): string =>\n `\\`\\`\\`\\n${text.replace(/```/g, '``\\u200d`')}\\n\\`\\`\\``;\n\nconst URL_PARTS_RE = /^([a-z][a-z0-9+.-]*:(?:\\/\\/[^/?#]*)?)(.*)$/is;\n// Letter, digit, and hyphen labels, with an optional DNS root dot.\nconst DNS_NAME_RE =\n /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*\\.?$/i;\nconst IPV6_HOST_RE = /^\\[[0-9a-f:.]+\\]$/i;\n\nconst MALFORMED_ESCAPE_RE = /%(?![0-9a-f]{2})/i;\n\n// `url` parsed, when its escapes are well formed and `URL` prints it as\n// written up to the case of its scheme and authority and a `/` for an empty\n// path.\nconst parsedAsWritten = (url: string): URL | null => {\n if (MALFORMED_ESCAPE_RE.test(url)) {\n return null;\n }\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n const [, prefix, rest] = URL_PARTS_RE.exec(url) ?? [];\n const [, printedPrefix, printedRest] = URL_PARTS_RE.exec(parsed.href) ?? [];\n return prefix !== undefined &&\n prefix.toLowerCase() === printedPrefix?.toLowerCase() &&\n (printedRest === rest || printedRest === `/${rest}`)\n ? parsed\n : null;\n};\n\n/**\n * Whether `url` is an `http:` or `https:` URL with a DNS or IPv6 host that\n * `URL` prints as written, so nothing it repairs or encodes, such as a\n * backslash, whitespace, or non-ASCII, passes.\n */\nexport const isAbsoluteHttpUrl = (url: string): boolean => {\n const parsed = parsedAsWritten(url);\n return (\n (parsed?.protocol === 'http:' || parsed?.protocol === 'https:') &&\n (DNS_NAME_RE.test(parsed.hostname) || IPV6_HOST_RE.test(parsed.hostname))\n );\n};\n\n// RFC 5322 dot-atom text, less `/`, `?`, `#`, and `%`.\nconst LOCAL_PART_RE =\n /^[a-z0-9!$&'*+=^_`{|}~-]+(?:\\.[a-z0-9!$&'*+=^_`{|}~-]+)*$/i;\n\nconst isMailbox = (recipient: string): boolean => {\n const at = recipient.lastIndexOf('@');\n return (\n at > 0 &&\n LOCAL_PART_RE.test(recipient.slice(0, at)) &&\n DNS_NAME_RE.test(recipient.slice(at + 1))\n );\n};\n\nconst decoded = (value: string): string | null => {\n try {\n return decodeURIComponent(value);\n } catch {\n return null;\n }\n};\n\n// Every comma-separated recipient before the query or fragment is a mailbox.\nconst isMailtoUrl = (url: string): boolean => {\n const [, recipients] = /^mailto:([^?#]*)/i.exec(url) ?? [];\n return (\n recipients !== undefined &&\n parsedAsWritten(url) !== null &&\n recipients\n .split(',')\n .every((recipient) => isMailbox(decoded(recipient) ?? ''))\n );\n};\n\n/** Where Slack output's relative links resolve. */\nexport interface SlackLinkOptions {\n /** Absolute `http(s)` URL a relative link resolves against; without it, a relative link prints its label. */\n baseUrl?: string;\n}\n\n// Parsed rather than checked as written: a base is only resolved against, so\n// a default port or an uppercase host is fine.\nconst isSlackBaseUrl = (baseUrl: string): boolean => {\n let parsed: URL;\n try {\n parsed = new URL(baseUrl);\n } catch {\n return false;\n }\n return (\n (parsed.protocol === 'http:' || parsed.protocol === 'https:') &&\n parsed.username === '' &&\n parsed.password === '' &&\n (DNS_NAME_RE.test(parsed.hostname) || IPV6_HOST_RE.test(parsed.hostname))\n );\n};\n\n/**\n * Throws `INVALID_BASE_URL` unless `baseUrl` is absent or an `http:` or\n * `https:` URL with a DNS or IPv6 host and no credentials.\n */\nexport const assertSlackBaseUrl = (baseUrl: string | undefined): void => {\n if (baseUrl !== undefined && !isSlackBaseUrl(baseUrl)) {\n throw new IsomerError(\n 'INVALID_BASE_URL',\n `Slack baseUrl must be an absolute http or https URL without credentials, got \"${baseUrl}\"`\n );\n }\n};\n\nconst HAS_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;\n\n// A relative path resolved onto the base's origin, or `null` when it would\n// leave that origin. A fragment, `BLOCKED_HREF` included, names a place in a\n// document Slack does not show, so it never resolves.\nconst resolvedOnBase = (url: string, baseUrl: string): string | null => {\n if (url.startsWith('#') || HAS_SCHEME_RE.test(url)) {\n return null;\n }\n let resolved: URL;\n try {\n resolved = new URL(url, baseUrl);\n } catch {\n return null;\n }\n return resolved.origin === new URL(baseUrl).origin ? resolved.href : null;\n};\n\n/**\n * `href` when {@link sanitizeNavigationHref} passes it and it is an `http:` or\n * `https:` URL with a host, or a `mailto:` of well-formed mailboxes; `null`\n * otherwise. Slack has no page to resolve a relative URL against, so one links\n * only when `baseUrl` is given, resolved onto its origin; a fragment, such as\n * `BLOCKED_HREF`, never resolves.\n */\nexport const slackLinkUrl = (href: string, baseUrl?: string): string | null => {\n assertSlackBaseUrl(baseUrl);\n const url = sanitizeNavigationHref(href);\n if (url === null) {\n return null;\n }\n if (isAbsoluteHttpUrl(url) || isMailtoUrl(url)) {\n return url;\n }\n const resolved = baseUrl === undefined ? null : resolvedOnBase(url, baseUrl);\n return resolved === null ? null : slackLinkUrl(resolved);\n};\n\n/**\n * Slack mrkdwn link, `<url|label>`, or a bare `<url>` when `label` is omitted.\n *\n * URL and label are both escaped so `&` and `>` cannot break Slack's link\n * parser, and a `|` in the URL is percent-encoded so it cannot end the URL\n * early. A URL {@link slackLinkUrl} rejects degrades to plain escaped text\n * with no link.\n */\nexport const link = (url: string, label?: string, baseUrl?: string): string => {\n const sanitized = slackLinkUrl(url, baseUrl);\n if (!sanitized) {\n return escapeMrkdwn(label ?? url);\n }\n const safeUrl = escapeMrkdwn(sanitized).replaceAll('|', '%7C');\n if (!label) {\n return `<${safeUrl}>`;\n }\n return `<${safeUrl}|${escapeMrkdwn(label)}>`;\n};\n\n/**\n * Truncates `value` to `max` UTF-16 code units at a grapheme boundary,\n * appending an ellipsis when it had to cut. Pass a `SLACK_LIMITS` constant as\n * the budget.\n */\nexport const clampSlackText = (value: string, max: number): string => {\n if (value.length <= max) {\n return value;\n }\n const budget = max <= 1 ? max : max - 1;\n let end = 0;\n for (const { index, segment } of new Intl.Segmenter(undefined, {\n granularity: 'grapheme',\n }).segment(value)) {\n if (index + segment.length > budget) {\n break;\n }\n end = index + segment.length;\n }\n const head = value.slice(0, end);\n return max <= 1 ? head : `${head.trimEnd()}…`;\n};\n\n// A `<…>` link or mention and an entity, each matched where it starts.\nconst LINK_TOKEN_RE = /<[^<>\\n]*>/y;\nconst ENTITY_TOKEN_RE = /&(?:amp|lt|gt);/y;\n\n// The end of the token `re` matches at `index`, or `undefined`.\nconst tokenEnd = (\n value: string,\n re: RegExp,\n index: number\n): number | undefined => {\n re.lastIndex = index;\n return re.test(value) ? re.lastIndex : undefined;\n};\n\n/**\n * {@link clampSlackText} for `mrkdwn`: never cuts inside a `<…>` link or\n * mention or an entity. Formatting marks are left as they fall; Slack prints an\n * unclosed one as written.\n */\nexport const clampMrkdwn = (value: string, max: number): string => {\n const clamped = clampSlackText(value, max);\n if (clamped === value || max <= 1) {\n return clamped;\n }\n // Entity first: a link holds no `<` of its own, so stepping back to its\n // start cannot land inside an entity, while the reverse could.\n let cut = clamped.length - 1;\n const entity = value.lastIndexOf('&', cut - 1);\n if (entity !== -1 && (tokenEnd(value, ENTITY_TOKEN_RE, entity) ?? 0) > cut) {\n cut = entity;\n }\n const link = value.lastIndexOf('<', cut - 1);\n if (link !== -1 && (tokenEnd(value, LINK_TOKEN_RE, link) ?? 0) > cut) {\n cut = link;\n }\n return `${value.slice(0, cut).trimEnd()}…`;\n};\n\n/**\n * `value` cut to `max` UTF-16 code units, never through a surrogate pair. For\n * opaque values a host reads back, which an ellipsis would change.\n */\nexport const cutSlackValue = (value: string, max: number): string => {\n const cut = value.slice(0, max);\n return /[\\ud800-\\udbff]$/.test(cut) ? cut.slice(0, -1) : cut;\n};\n\n/**\n * Collapses whitespace and clamps to `SLACK_LIMITS.headerTextChars`. Header\n * text is `plain_text`, so no markdown survives — do not pre-format it.\n */\nexport const formatHeaderText = (value: string): string =>\n clampSlackText(\n value.replace(/\\s+/g, ' ').trim(),\n SLACK_LIMITS.headerTextChars\n );\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { type SlackAssetCollector, type SlackAssetRequest, createSlackAssetCollector, isSlackReachableImageUrl, } from './assets.js';
|
|
2
|
-
export { type SlackActionElement, type SlackActionsBlock, type SlackBlock, type SlackButtonElement, type SlackCheckboxesElement, type SlackContextBlock, type SlackDividerBlock, type SlackFileReference, type SlackHeaderBlock, type SlackHeaderLevel, type SlackImageBlock, type SlackImageElement, type SlackMrkdwnTextObject, type SlackMultiStaticSelectElement, type SlackOptionGroup, type SlackOptionObject, type SlackOverflowElement, type SlackPlainTextObject, type SlackRadioButtonsElement, type SlackRawTextElement, type SlackRichTextBlock, type SlackRichTextBlockElement, type SlackRichTextInline, type SlackRichTextLink, type SlackRichTextList, type SlackRichTextPreformatted, type SlackRichTextQuote, type SlackRichTextSection, type SlackRichTextStyle, type SlackRichTextTag, type SlackRichTextText, type SlackSectionAccessory, type SlackSectionBlock, type SlackStaticSelectElement, type SlackTableBlock, type SlackTableCell, type SlackTableColumnSetting, type SlackTagColor, type SlackTextObject, type SlackVideoBlock, SLACK_LIMITS, } from './blocks.js';
|
|
2
|
+
export { type SlackActionElement, type SlackActionsBlock, type SlackBlock, type SlackButtonElement, type SlackCheckboxesElement, type SlackContainerBlock, type SlackContainerChildBlock, type SlackContextBlock, type SlackDividerBlock, type SlackFileReference, type SlackHeaderBlock, type SlackHeaderLevel, type SlackImageBlock, type SlackImageElement, type SlackMrkdwnTextObject, type SlackMultiStaticSelectElement, type SlackOptionGroup, type SlackOptionObject, type SlackOverflowElement, type SlackPlainTextObject, type SlackRadioButtonsElement, type SlackRawTextElement, type SlackRichTextBlock, type SlackRichTextBlockElement, type SlackRichTextInline, type SlackRichTextLink, type SlackRichTextList, type SlackRichTextPreformatted, type SlackRichTextQuote, type SlackRichTextSection, type SlackRichTextStyle, type SlackRichTextTag, type SlackRichTextText, type SlackSectionAccessory, type SlackSectionBlock, type SlackStaticSelectElement, type SlackTableBlock, type SlackTableCell, type SlackTableColumnSetting, type SlackTagColor, type SlackTextObject, type SlackVideoBlock, SLACK_LIMITS, } from './blocks.js';
|
|
3
|
+
export { type SlackContainerOptions, slackContainer } from './container.js';
|
|
3
4
|
export { type SlackEnvelopeDispatcher, type SlackEnvelopeOptions, type SlackEnvelopeResult, renderSlackEnvelope, } from './envelope.js';
|
|
4
|
-
export { bold, clampSlackText, code, codeBlock, escapeMrkdwn, isAbsoluteHttpUrl, italic, link, slackLinkUrl, strike, } from './format.js';
|
|
5
|
+
export { type SlackLinkOptions, bold, clampSlackText, code, codeBlock, escapeMrkdwn, isAbsoluteHttpUrl, italic, link, slackLinkUrl, strike, } from './format.js';
|
|
5
6
|
export { markdownContentToSlackBlocks } from './markdown_content.js';
|
|
7
|
+
export { isModeledSlackBlockType, isUnmodeledSlackBlock, unmodeledSlackBlock, } from './unmodeled.js';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/render/slack/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,EAClC,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,MAAM,GACP,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/render/slack/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,U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,MAAM,GACP,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { createSlackAssetCollector, isSlackReachableImageUrl, } from './assets.js';
|
|
8
8
|
export { SLACK_LIMITS, } from './blocks.js';
|
|
9
|
+
export { slackContainer } from './container.js';
|
|
9
10
|
export { renderSlackEnvelope, } from './envelope.js';
|
|
10
11
|
export { bold, clampSlackText, code, codeBlock, escapeMrkdwn, isAbsoluteHttpUrl, italic, link, slackLinkUrl, strike, } from './format.js';
|
|
11
12
|
export { markdownContentToSlackBlocks } from './markdown_content.js';
|
|
13
|
+
export { isModeledSlackBlockType, isUnmodeledSlackBlock, unmodeledSlackBlock, } from './unmodeled.js';
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/render/slack/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAGL,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/render/slack/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAGL,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EA2CL,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAA8B,cAAc,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAIL,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,MAAM,GACP,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,aAAa,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\nexport {\n type SlackAssetCollector,\n type SlackAssetRequest,\n createSlackAssetCollector,\n isSlackReachableImageUrl,\n} from './assets';\nexport {\n type SlackActionElement,\n type SlackActionsBlock,\n type SlackBlock,\n type SlackButtonElement,\n type SlackCheckboxesElement,\n type SlackContainerBlock,\n type SlackContainerChildBlock,\n type SlackContextBlock,\n type SlackDividerBlock,\n type SlackFileReference,\n type SlackHeaderBlock,\n type SlackHeaderLevel,\n type SlackImageBlock,\n type SlackImageElement,\n type SlackMrkdwnTextObject,\n type SlackMultiStaticSelectElement,\n type SlackOptionGroup,\n type SlackOptionObject,\n type SlackOverflowElement,\n type SlackPlainTextObject,\n type SlackRadioButtonsElement,\n type SlackRawTextElement,\n type SlackRichTextBlock,\n type SlackRichTextBlockElement,\n type SlackRichTextInline,\n type SlackRichTextLink,\n type SlackRichTextList,\n type SlackRichTextPreformatted,\n type SlackRichTextQuote,\n type SlackRichTextSection,\n type SlackRichTextStyle,\n type SlackRichTextTag,\n type SlackRichTextText,\n type SlackSectionAccessory,\n type SlackSectionBlock,\n type SlackStaticSelectElement,\n type SlackTableBlock,\n type SlackTableCell,\n type SlackTableColumnSetting,\n type SlackTagColor,\n type SlackTextObject,\n type SlackVideoBlock,\n SLACK_LIMITS,\n} from './blocks';\nexport { type SlackContainerOptions, slackContainer } from './container';\nexport {\n type SlackEnvelopeDispatcher,\n type SlackEnvelopeOptions,\n type SlackEnvelopeResult,\n renderSlackEnvelope,\n} from './envelope';\n\nexport {\n type SlackLinkOptions,\n bold,\n clampSlackText,\n code,\n codeBlock,\n escapeMrkdwn,\n isAbsoluteHttpUrl,\n italic,\n link,\n slackLinkUrl,\n strike,\n} from './format';\n\nexport { markdownContentToSlackBlocks } from './markdown_content';\n\nexport {\n isModeledSlackBlockType,\n isUnmodeledSlackBlock,\n unmodeledSlackBlock,\n} from './unmodeled';\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MarkdownContent } from '../../define/markdown_content.js';
|
|
2
2
|
import { type SlackBlock } from './blocks.js';
|
|
3
|
+
import { type SlackLinkOptions } from './format.js';
|
|
3
4
|
/**
|
|
4
5
|
* Builder content as Block Kit: paragraphs, headings, lists, quotes, and code
|
|
5
6
|
* as `rich_text`, tables as `table` blocks, and thematic breaks as `divider`
|
|
@@ -7,11 +8,11 @@ import { type SlackBlock } from './blocks.js';
|
|
|
7
8
|
* item's. A run of rich-text blocks shares one `rich_text` block. Source from
|
|
8
9
|
* `md.authored` is parsed as GFM and translated the same way.
|
|
9
10
|
*/
|
|
10
|
-
export declare const markdownContentToSlackBlocks: (content: MarkdownContent) => SlackBlock[];
|
|
11
|
+
export declare const markdownContentToSlackBlocks: (content: MarkdownContent, options?: SlackLinkOptions) => SlackBlock[];
|
|
11
12
|
/**
|
|
12
13
|
* GFM as Block Kit, parsed as CommonMark with GFM and translated as
|
|
13
14
|
* {@link markdownContentToSlackBlocks} translates builder content. Source past
|
|
14
15
|
* the parse budget that `md.authored` applies prints as literal paragraphs.
|
|
15
16
|
*/
|
|
16
|
-
export declare const gfmToSlackBlocks: (gfm: string) => SlackBlock[];
|
|
17
|
+
export declare const gfmToSlackBlocks: (gfm: string, options?: SlackLinkOptions) => SlackBlock[];
|
|
17
18
|
//# sourceMappingURL=markdown_content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown_content.d.ts","sourceRoot":"","sources":["../../../src/render/slack/markdown_content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown_content.d.ts","sourceRoot":"","sources":["../../../src/render/slack/markdown_content.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE,OAAO,EAEL,KAAK,UAAU,EAOhB,MAAM,UAAU,CAAC;AAClB,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,UAAU,CAAC;AAkblB;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,SAAS,eAAe,EACxB,UAAS,gBAAqB,KAC7B,UAAU,EAC6D,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,MAAM,EACX,UAAS,gBAAqB,KAC7B,UAAU,EAA6D,CAAC"}
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
5
|
* 2.0.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import { parseGfmBlocks } from '../markdown/format.js';
|
|
7
|
+
import { gfmBlocks, resolvedMarkdownBlocks } from '../markdown/blocks.js';
|
|
9
8
|
import { SLACK_LIMITS, } from './blocks.js';
|
|
10
|
-
import { clampSlackText, slackLinkUrl } from './format.js';
|
|
9
|
+
import { assertSlackBaseUrl, clampSlackText, slackLinkUrl, } from './format.js';
|
|
11
10
|
const footnoteLabel = ({ identifier, label, }) => `[^${label ?? identifier}]`;
|
|
12
11
|
const plainText = (node) => {
|
|
13
12
|
if ('value' in node) {
|
|
@@ -107,7 +106,8 @@ const unquoted = (node) => node.type === 'blockquote' ? node.children.flatMap(un
|
|
|
107
106
|
// nested list follows at the next indent; any other block, such as a table,
|
|
108
107
|
// follows on its own; what the item holds after either follows unbulleted,
|
|
109
108
|
// since a Slack list item cannot resume; and the list resumes at its next
|
|
110
|
-
// number.
|
|
109
|
+
// number. An empty item keeps its number, so the list resumes past it. A task
|
|
110
|
+
// item's first line leads with its box.
|
|
111
111
|
const listPieces = (list, indent) => {
|
|
112
112
|
const style = list.ordered ? 'ordered' : 'bullet';
|
|
113
113
|
const out = [];
|
|
@@ -167,6 +167,11 @@ const listPieces = (list, indent) => {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
emit();
|
|
170
|
+
if (item.children.length === 0) {
|
|
171
|
+
flush();
|
|
172
|
+
number += 1;
|
|
173
|
+
offset = number - 1;
|
|
174
|
+
}
|
|
170
175
|
}
|
|
171
176
|
flush();
|
|
172
177
|
return out;
|
|
@@ -289,68 +294,22 @@ const blockPieces = (node) => {
|
|
|
289
294
|
return [];
|
|
290
295
|
}
|
|
291
296
|
};
|
|
292
|
-
// Each
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
switch (node.type) {
|
|
309
|
-
case 'linkReference':
|
|
310
|
-
return {
|
|
311
|
-
type: 'link',
|
|
312
|
-
url: definitions.get(node.identifier)?.url ?? '',
|
|
313
|
-
children: node.children.map(resolve),
|
|
314
|
-
};
|
|
315
|
-
case 'imageReference':
|
|
316
|
-
return {
|
|
317
|
-
type: 'image',
|
|
318
|
-
url: definitions.get(node.identifier)?.url ?? '',
|
|
319
|
-
alt: node.alt ?? null,
|
|
320
|
-
};
|
|
321
|
-
default:
|
|
322
|
-
return 'children' in node
|
|
323
|
-
? { ...node, children: node.children.map(resolve) }
|
|
324
|
-
: node;
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
return blocks.map(resolve);
|
|
328
|
-
};
|
|
329
|
-
const lines = (text) => text.replace(/\r\n?/g, '\n');
|
|
330
|
-
const literalParagraphs = (text) => lines(text)
|
|
331
|
-
.split(/\n[ \t]*\n/)
|
|
332
|
-
.filter((paragraph) => paragraph.trim() !== '')
|
|
333
|
-
.map((paragraph) => ({
|
|
334
|
-
type: 'paragraph',
|
|
335
|
-
children: [{ type: 'text', value: paragraph.trim() }],
|
|
336
|
-
}));
|
|
337
|
-
// Source past the parse budget prints as its literal paragraphs.
|
|
338
|
-
const gfmBlocks = (gfm) => {
|
|
339
|
-
const parsed = parseGfmBlocks(lines(gfm));
|
|
340
|
-
return parsed === null ? literalParagraphs(gfm) : withReferences(parsed);
|
|
341
|
-
};
|
|
342
|
-
// Markdown printed as written is read as the GFM it holds; authored source
|
|
343
|
-
// that sanitizing left inert is never parsed.
|
|
344
|
-
const expanded = (node) => {
|
|
345
|
-
if (node.type === VERBATIM_TYPE) {
|
|
346
|
-
const { value, source } = node;
|
|
347
|
-
return source === undefined ? gfmBlocks(value) : literalParagraphs(source);
|
|
348
|
-
}
|
|
349
|
-
return 'children' in node
|
|
350
|
-
? [{ ...node, children: node.children.flatMap(expanded) }]
|
|
351
|
-
: [node];
|
|
352
|
-
};
|
|
353
|
-
const toSlackBlocks = (nodes) => {
|
|
297
|
+
// Each relative link resolved against `baseUrl`, ahead of `linkRuns`. An
|
|
298
|
+
// image's source is left alone: Slack draws none inline.
|
|
299
|
+
const rebased = (node, baseUrl) => ({
|
|
300
|
+
...node,
|
|
301
|
+
...('children' in node && {
|
|
302
|
+
children: node.children.map((child) => rebased(child, baseUrl)),
|
|
303
|
+
}),
|
|
304
|
+
...(node.type === 'link' && {
|
|
305
|
+
url: slackLinkUrl(node.url, baseUrl) ?? node.url,
|
|
306
|
+
}),
|
|
307
|
+
});
|
|
308
|
+
const toSlackBlocks = (input, { baseUrl }) => {
|
|
309
|
+
assertSlackBaseUrl(baseUrl);
|
|
310
|
+
const nodes = baseUrl === undefined
|
|
311
|
+
? input
|
|
312
|
+
: input.map((node) => rebased(node, baseUrl));
|
|
354
313
|
const blocks = [];
|
|
355
314
|
let elements = [];
|
|
356
315
|
const flush = () => {
|
|
@@ -394,11 +353,11 @@ const toSlackBlocks = (nodes) => {
|
|
|
394
353
|
* item's. A run of rich-text blocks shares one `rich_text` block. Source from
|
|
395
354
|
* `md.authored` is parsed as GFM and translated the same way.
|
|
396
355
|
*/
|
|
397
|
-
export const markdownContentToSlackBlocks = (content) => toSlackBlocks(
|
|
356
|
+
export const markdownContentToSlackBlocks = (content, options = {}) => toSlackBlocks(resolvedMarkdownBlocks(content), options);
|
|
398
357
|
/**
|
|
399
358
|
* GFM as Block Kit, parsed as CommonMark with GFM and translated as
|
|
400
359
|
* {@link markdownContentToSlackBlocks} translates builder content. Source past
|
|
401
360
|
* the parse budget that `md.authored` applies prints as literal paragraphs.
|
|
402
361
|
*/
|
|
403
|
-
export const gfmToSlackBlocks = (gfm) => toSlackBlocks(gfmBlocks(gfm));
|
|
362
|
+
export const gfmToSlackBlocks = (gfm, options = {}) => toSlackBlocks(gfmBlocks(gfm), options);
|
|
404
363
|
//# sourceMappingURL=markdown_content.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown_content.js","sourceRoot":"","sources":["../../../src/render/slack/markdown_content.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EACL,YAAY,GAQb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;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,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;IACxB,CA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gBAAgB,GAAG,CAAC,CAClC;4BACD,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;yBAC7B;qBACF;oBACH,CAAC,CAAC,OAAO,CACZ;aACF,CAAC,CAAC;QACL,CAAC;QACD,QAAQ,GAAG,EAAE,CAAC;IAChB,CAAC,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACN,KAAK,EAAE,CAAC;gBACR,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC;IACR,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,OAAwB,EACV,EAAE,CAChB,aAAa,CACV,cAAc,CAAC,OAAO,CAAmB,CAAC,OAAO,CAChD,QAAQ,CACQ,CACnB,CAAC;AAEJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAgB,EAAE,CAC5D,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,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// 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. A task 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 }\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"]}
|
|
1
|
+
{"version":3,"file":"markdown_content.js","sourceRoot":"","sources":["../../../src/render/slack/markdown_content.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEvE,OAAO,EACL,YAAY,GAQb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,kBAAkB,EAClB,cAAc,EAEd,YAAY,GACb,MAAM,UAAU,CAAC;AAElB,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,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;IACxB,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;QACtC,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACzE,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,KAAyB,EAAkC,EAAE,CAC3E,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,K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AAC,KAAK,GAAG,CAAC,CAAC,EAAE,IAAI,KAAK,mBAAmB;oBAC/C,CAAC,CAAC;wBACE,GAAG,OAAO;wBACV,QAAQ,EAAE;4BACR,GAAG,WAAW,CACZ,OAAO,CAAC,QAAQ,EAChB,YAAY,CAAC,gBAAgB,GAAG,CAAC,CAClC;4BACD,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;yBAC7B;qBACF;oBACH,CAAC,CAAC,OAAO,CACZ;aACF,CAAC,CAAC;QACL,CAAC;QACD,QAAQ,GAAG,EAAE,CAAC;IAChB,CAAC,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACN,KAAK,EAAE,CAAC;gBACR,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC;IACR,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,OAAwB,EACxB,UAA4B,EAAE,EAChB,EAAE,CAChB,aAAa,CAAC,sBAAsB,CAAC,OAAO,CAAkB,EAAE,OAAO,CAAC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,GAAW,EACX,UAA4B,EAAE,EAChB,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAkB,EAAE,OAAO,CAAC,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// 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 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 { gfmBlocks, resolvedMarkdownBlocks } from '../markdown/blocks';\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 {\n assertSlackBaseUrl,\n clampSlackText,\n type SlackLinkOptions,\n slackLinkUrl,\n} 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 relative link resolved against `baseUrl`, ahead of `linkRuns`. An\n// image's source is left alone: Slack draws none inline.\nconst rebased = (node: Nodes, baseUrl: string): Nodes =>\n ({\n ...node,\n ...('children' in node && {\n children: node.children.map((child) => rebased(child, baseUrl)),\n }),\n ...(node.type === 'link' && {\n url: slackLinkUrl(node.url, baseUrl) ?? node.url,\n }),\n }) as Nodes;\n\nconst toSlackBlocks = (\n input: readonly RootContent[],\n { baseUrl }: SlackLinkOptions\n): SlackBlock[] => {\n assertSlackBaseUrl(baseUrl);\n const nodes =\n baseUrl === undefined\n ? input\n : input.map((node) => rebased(node, baseUrl) as RootContent);\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 options: SlackLinkOptions = {}\n): SlackBlock[] =>\n toSlackBlocks(resolvedMarkdownBlocks(content) as RootContent[], options);\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 = (\n gfm: string,\n options: SlackLinkOptions = {}\n): SlackBlock[] => toSlackBlocks(gfmBlocks(gfm) as RootContent[], options);\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SlackBlock, SlackContainerChildBlock } from './blocks.js';
|
|
2
|
+
/** Whether Isomer models Block Kit blocks of `type`, so a renderer returns them as a {@link SlackBlock} without {@link unmodeledSlackBlock}. */
|
|
3
|
+
export declare const isModeledSlackBlockType: (type: string) => type is SlackBlock["type"];
|
|
4
|
+
/**
|
|
5
|
+
* A Block Kit block Isomer does not model yet, typed so a `slack` renderer can return it or put it in a container's `child_blocks`.
|
|
6
|
+
*
|
|
7
|
+
* The envelope passes it through unfitted, so Slack rejects the whole message if it breaks a limit, or if Slack does not accept it inside a container. A literal `type` Isomer models does not compile: return that block unwrapped. Pass the block's interface as `TBlock` to check its fields.
|
|
8
|
+
*/
|
|
9
|
+
export declare const unmodeledSlackBlock: <const TBlock extends {
|
|
10
|
+
readonly type: string;
|
|
11
|
+
}>(block: TBlock & (TBlock["type"] extends SlackBlock["type"] ? {
|
|
12
|
+
readonly "Isomer models this block type: return it without unmodeledSlackBlock": never;
|
|
13
|
+
} : unknown)) => SlackContainerChildBlock;
|
|
14
|
+
/** Whether `block` came from {@link unmodeledSlackBlock}. The mark is a symbol key, so it never reaches the JSON sent to Slack. */
|
|
15
|
+
export declare const isUnmodeledSlackBlock: (block: unknown) => boolean;
|
|
16
|
+
//# sourceMappingURL=unmodeled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unmodeled.d.ts","sourceRoot":"","sources":["../../../src/render/slack/unmodeled.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAiBrE,gJAAgJ;AAChJ,eAAO,MAAM,uBAAuB,GAClC,MAAM,MAAM,KACX,IAAI,IAAI,UAAU,CAAC,MAAM,CACqC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,KAAK,CAAC,MAAM,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAE9C,OAAO,MAAM,GACX,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,GACtC;IACE,QAAQ,CAAC,sEAAsE,EAAE,KAAK,CAAC;CACxF,GACD,OAAO,CAAC,KACb,wBACuE,CAAC;AAE3E,mIAAmI;AACnI,eAAO,MAAM,qBAAqB,GAAI,OAAO,OAAO,KAAG,OAGG,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
|
+
* 2.0.
|
|
6
|
+
*/
|
|
7
|
+
const UNMODELED = Symbol.for('elastic.isomer.slack_unmodeled_block');
|
|
8
|
+
const MODELED_BLOCK_TYPES = {
|
|
9
|
+
actions: true,
|
|
10
|
+
container: true,
|
|
11
|
+
context: true,
|
|
12
|
+
divider: true,
|
|
13
|
+
header: true,
|
|
14
|
+
image: true,
|
|
15
|
+
rich_text: true,
|
|
16
|
+
section: true,
|
|
17
|
+
table: true,
|
|
18
|
+
video: true,
|
|
19
|
+
};
|
|
20
|
+
/** Whether Isomer models Block Kit blocks of `type`, so a renderer returns them as a {@link SlackBlock} without {@link unmodeledSlackBlock}. */
|
|
21
|
+
export const isModeledSlackBlockType = (type) => Object.prototype.hasOwnProperty.call(MODELED_BLOCK_TYPES, type);
|
|
22
|
+
/**
|
|
23
|
+
* A Block Kit block Isomer does not model yet, typed so a `slack` renderer can return it or put it in a container's `child_blocks`.
|
|
24
|
+
*
|
|
25
|
+
* The envelope passes it through unfitted, so Slack rejects the whole message if it breaks a limit, or if Slack does not accept it inside a container. A literal `type` Isomer models does not compile: return that block unwrapped. Pass the block's interface as `TBlock` to check its fields.
|
|
26
|
+
*/
|
|
27
|
+
export const unmodeledSlackBlock = (block) => ({ ...block, [UNMODELED]: true });
|
|
28
|
+
/** Whether `block` came from {@link unmodeledSlackBlock}. The mark is a symbol key, so it never reaches the JSON sent to Slack. */
|
|
29
|
+
export const isUnmodeledSlackBlock = (block) => typeof block === 'object' &&
|
|
30
|
+
block !== null &&
|
|
31
|
+
block[UNMODELED] === true;
|
|
32
|
+
//# sourceMappingURL=unmodeled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unmodeled.js","sourceRoot":"","sources":["../../../src/render/slack/unmodeled.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;AAErE,MAAM,mBAAmB,GAA+C;IACtE,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;IACb,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF,gJAAgJ;AAChJ,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,IAAY,EACgB,EAAE,CAC9B,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAGjC,KAKc,EACY,EAAE,CAC5B,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAwC,CAAC;AAE3E,mIAAmI;AACnI,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAc,EAAW,EAAE,CAC/D,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACb,KAAmC,CAAC,SAAS,CAAC,KAAK,IAAI,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\nimport type { SlackBlock, SlackContainerChildBlock } from './blocks';\n\nconst UNMODELED = Symbol.for('elastic.isomer.slack_unmodeled_block');\n\nconst MODELED_BLOCK_TYPES: Readonly<Record<SlackBlock['type'], true>> = {\n actions: true,\n container: true,\n context: true,\n divider: true,\n header: true,\n image: true,\n rich_text: true,\n section: true,\n table: true,\n video: true,\n};\n\n/** Whether Isomer models Block Kit blocks of `type`, so a renderer returns them as a {@link SlackBlock} without {@link unmodeledSlackBlock}. */\nexport const isModeledSlackBlockType = (\n type: string\n): type is SlackBlock['type'] =>\n Object.prototype.hasOwnProperty.call(MODELED_BLOCK_TYPES, type);\n\n/**\n * A Block Kit block Isomer does not model yet, typed so a `slack` renderer can return it or put it in a container's `child_blocks`.\n *\n * The envelope passes it through unfitted, so Slack rejects the whole message if it breaks a limit, or if Slack does not accept it inside a container. A literal `type` Isomer models does not compile: return that block unwrapped. Pass the block's interface as `TBlock` to check its fields.\n */\nexport const unmodeledSlackBlock = <\n const TBlock extends { readonly type: string },\n>(\n block: TBlock &\n (TBlock['type'] extends SlackBlock['type']\n ? {\n readonly 'Isomer models this block type: return it without unmodeledSlackBlock': never;\n }\n : unknown)\n): SlackContainerChildBlock =>\n ({ ...block, [UNMODELED]: true }) as unknown as SlackContainerChildBlock;\n\n/** Whether `block` came from {@link unmodeledSlackBlock}. The mark is a symbol key, so it never reaches the JSON sent to Slack. */\nexport const isUnmodeledSlackBlock = (block: unknown): boolean =>\n typeof block === 'object' &&\n block !== null &&\n (block as { [UNMODELED]?: unknown })[UNMODELED] === true;\n"]}
|
|
@@ -11,6 +11,8 @@ import type { ValidationResult } from '../validate/validation.js';
|
|
|
11
11
|
* cross-pack nesting case cannot tell a dropped child from an empty one.
|
|
12
12
|
*/
|
|
13
13
|
export declare const CONFORMANCE_FOREIGN_MARKER = "isomerConformanceForeign";
|
|
14
|
+
/** The `title` {@link PrimitiveConformanceHarness.wrapComposition} must give its composition. */
|
|
15
|
+
export declare const CONFORMANCE_FIXTURE_TITLE = "Conformance fixture";
|
|
14
16
|
/** One example node, paired with the definition that published it. */
|
|
15
17
|
export interface PrimitiveConformanceExample {
|
|
16
18
|
readonly definition: AnyPrimitiveDefinition;
|
|
@@ -60,7 +62,7 @@ export interface PrimitiveConformanceSlackResult {
|
|
|
60
62
|
export interface PrimitiveConformanceHarness {
|
|
61
63
|
/**
|
|
62
64
|
* The smallest composition that carries one node. Its `title` must be
|
|
63
|
-
*
|
|
65
|
+
* {@link CONFORMANCE_FIXTURE_TITLE}, which the envelope cases look for as
|
|
64
66
|
* `CONFORMANCE FIXTURE` in text and `# Conformance fixture` in markdown.
|
|
65
67
|
*/
|
|
66
68
|
wrapComposition(node: PrimitiveNode): Composition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../src/testing/conformance.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EACV,sBAAsB,EACtB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAOpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../src/testing/conformance.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EACV,sBAAsB,EACtB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAOpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAMzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;GAIG;A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ACpB,WAAW,EAAE,WAAW,GACvB,+BAA+B,CAAC;IACnC,iGAAiG;IACjG,yBAAyB,CAAC,CACxB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,kCAAkC,CAAC,CAAC;CAChD;AAED,2CAA2C;AAC3C,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,EAAE,CACZ,OAAO,EAAE,2BAA2B,EACpC,OAAO,EAAE,2BAA2B,KACjC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED,8DAA8D;AAC9D,eAAO,MAAM,uBAAuB,GAClC,aAAa,SAAS,sBAAsB,EAAE,KAC7C,SAAS,2BAA2B,EASpC,CAAC;AAEJ,mEAAmE;AACnE,eAAO,MAAM,wBAAwB,GACnC,aAAa,SAAS,sBAAsB,EAAE,KAC7C,SAAS,CAAC,2BAA2B,GAAG,wBAAwB,CAAC,EAMjE,CAAC;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,GAC3C,aAAa,SAAS,sBAAsB,EAAE,KAC7C,IAsDF,CAAC;AAqCF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,wBAAwB,EA4OxE,CAAC"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import assert from 'node:assert/strict';
|
|
14
14
|
import { exampleNodes, primitiveExamples } from '../define/primitive_example.js';
|
|
15
15
|
import { anchoredNodes, anchorValue, NODE_ANCHOR_ATTRIBUTE, nodeType, } from '../render/anchors.js';
|
|
16
|
+
import { isModeledSlackBlockType, isUnmodeledSlackBlock, } from '../render/slack/unmodeled.js';
|
|
16
17
|
import { checkInputBudget } from '../validate/input_budget.js';
|
|
17
18
|
/**
|
|
18
19
|
* The foreign node {@link PrimitiveConformanceHarness.nestForeignChild}
|
|
@@ -20,6 +21,8 @@ import { checkInputBudget } from '../validate/input_budget.js';
|
|
|
20
21
|
* cross-pack nesting case cannot tell a dropped child from an empty one.
|
|
21
22
|
*/
|
|
22
23
|
export const CONFORMANCE_FOREIGN_MARKER = 'isomerConformanceForeign';
|
|
24
|
+
/** The `title` {@link PrimitiveConformanceHarness.wrapComposition} must give its composition. */
|
|
25
|
+
export const CONFORMANCE_FIXTURE_TITLE = 'Conformance fixture';
|
|
23
26
|
/** Every definition's examples, flattened to one row each. */
|
|
24
27
|
export const examplesFromDefinitions = (definitions) => definitions.flatMap((definition) => primitiveExamples(definition).map(({ name, node }, exampleIndex) => ({
|
|
25
28
|
definition,
|
|
@@ -168,6 +171,17 @@ export const primitiveConformanceCases = [
|
|
|
168
171
|
}
|
|
169
172
|
},
|
|
170
173
|
},
|
|
174
|
+
{
|
|
175
|
+
name: 'wraps only Slack blocks Isomer does not model',
|
|
176
|
+
run: (example, harness) => {
|
|
177
|
+
for (const { type } of harness
|
|
178
|
+
.renderSlack(example.node)
|
|
179
|
+
.flatMap((block) => block.type === 'container' ? [block, ...block.child_blocks] : [block])
|
|
180
|
+
.filter(isUnmodeledSlackBlock)) {
|
|
181
|
+
assert.ok(!isModeledSlackBlockType(type), `Isomer models \`${type}\` blocks: return this one without \`unmodeledSlackBlock\`. ${previewHint(example)}`);
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
},
|
|
171
185
|
{
|
|
172
186
|
name: 'renders through snapshot primitive dispatch without throwing',
|
|
173
187
|
run: ({ type, exampleIndex, node }, harness) => {
|