@elastic/isomer-sdk 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.txt +0 -286
- package/README.md +13 -2
- package/THIRD_PARTY_LICENSES.md +1 -885
- package/dist/author/authored_fields.d.ts +93 -18
- package/dist/author/authored_fields.d.ts.map +1 -1
- package/dist/author/authored_fields.js +63 -43
- package/dist/author/authored_fields.js.map +1 -1
- package/dist/author/authoring_input.d.ts +7 -0
- package/dist/author/authoring_input.d.ts.map +1 -0
- package/dist/author/authoring_input.js +66 -0
- package/dist/author/authoring_input.js.map +1 -0
- package/dist/author/authoring_model.d.ts +33 -0
- package/dist/author/authoring_model.d.ts.map +1 -0
- package/dist/author/authoring_model.js +142 -0
- package/dist/author/authoring_model.js.map +1 -0
- package/dist/author/declarations.d.ts +13 -0
- package/dist/author/declarations.d.ts.map +1 -0
- package/dist/author/declarations.js +288 -0
- package/dist/author/declarations.js.map +1 -0
- package/dist/author/index.d.ts +4 -1
- package/dist/author/index.d.ts.map +1 -1
- package/dist/author/index.js +4 -1
- package/dist/author/index.js.map +1 -1
- package/dist/author/jsx_shim.d.ts +50 -30
- package/dist/author/jsx_shim.d.ts.map +1 -1
- package/dist/author/jsx_shim.js +146 -138
- package/dist/author/jsx_shim.js.map +1 -1
- package/dist/author/print_jsx.d.ts +19 -0
- package/dist/author/print_jsx.d.ts.map +1 -0
- package/dist/author/print_jsx.js +372 -0
- package/dist/author/print_jsx.js.map +1 -0
- package/dist/author/prompt.d.ts +2 -2
- package/dist/author/prompt.d.ts.map +1 -1
- package/dist/author/prompt.js +7 -2
- package/dist/author/prompt.js.map +1 -1
- package/dist/author/schema_to_typescript.d.ts +37 -0
- package/dist/author/schema_to_typescript.d.ts.map +1 -0
- package/dist/author/schema_to_typescript.js +289 -0
- package/dist/author/schema_to_typescript.js.map +1 -0
- package/dist/cjs/author/authored_fields.js +68 -47
- package/dist/cjs/author/authored_fields.js.map +1 -1
- package/dist/cjs/author/authoring_input.js +70 -0
- package/dist/cjs/author/authoring_input.js.map +1 -0
- package/dist/cjs/author/authoring_model.js +149 -0
- package/dist/cjs/author/authoring_model.js.map +1 -0
- package/dist/cjs/author/declarations.js +292 -0
- package/dist/cjs/author/declarations.js.map +1 -0
- package/dist/cjs/author/index.js +10 -1
- package/dist/cjs/author/index.js.map +1 -1
- package/dist/cjs/author/jsx_shim.js +148 -140
- package/dist/cjs/author/jsx_shim.js.map +1 -1
- package/dist/cjs/author/print_jsx.js +378 -0
- package/dist/cjs/author/print_jsx.js.map +1 -0
- package/dist/cjs/author/prompt.js +7 -2
- package/dist/cjs/author/prompt.js.map +1 -1
- package/dist/cjs/author/schema_to_typescript.js +298 -0
- package/dist/cjs/author/schema_to_typescript.js.map +1 -0
- package/dist/cjs/composition/body_node_base.js +11 -4
- package/dist/cjs/composition/body_node_base.js.map +1 -1
- package/dist/cjs/composition/error.js +2 -0
- package/dist/cjs/composition/error.js.map +1 -1
- package/dist/cjs/composition/index.js +2 -1
- package/dist/cjs/composition/index.js.map +1 -1
- package/dist/cjs/composition/structured_value.js.map +1 -1
- package/dist/cjs/define/frame.js +2 -3
- package/dist/cjs/define/frame.js.map +1 -1
- package/dist/cjs/define/index.js +7 -1
- package/dist/cjs/define/index.js.map +1 -1
- package/dist/cjs/define/primitive_example.js +26 -0
- package/dist/cjs/define/primitive_example.js.map +1 -0
- package/dist/cjs/define/primitive_icon.js +17 -0
- package/dist/cjs/define/primitive_icon.js.map +1 -0
- package/dist/cjs/define/primitive_module.js +24 -7
- package/dist/cjs/define/primitive_module.js.map +1 -1
- package/dist/cjs/define/slack_assets.js.map +1 -1
- package/dist/cjs/entries/index.js +8 -2
- package/dist/cjs/entries/index.js.map +1 -1
- package/dist/cjs/entries/markdown.js +2 -1
- package/dist/cjs/entries/markdown.js.map +1 -1
- package/dist/cjs/entries/slack.js +1 -2
- package/dist/cjs/entries/slack.js.map +1 -1
- package/dist/cjs/pack/capabilities.js +17 -11
- package/dist/cjs/pack/capabilities.js.map +1 -1
- package/dist/cjs/pack/compose.js +4 -1
- package/dist/cjs/pack/compose.js.map +1 -1
- package/dist/cjs/pack/index.js +2 -1
- package/dist/cjs/pack/index.js.map +1 -1
- package/dist/cjs/pack/primitive_pack.js +27 -5
- package/dist/cjs/pack/primitive_pack.js.map +1 -1
- package/dist/cjs/render/anchors.js +1 -1
- package/dist/cjs/render/anchors.js.map +1 -1
- package/dist/cjs/render/format_number.js +2 -1
- package/dist/cjs/render/format_number.js.map +1 -1
- package/dist/cjs/render/html/envelope.js +12 -6
- package/dist/cjs/render/html/envelope.js.map +1 -1
- package/dist/cjs/render/layout_check.js.map +1 -1
- package/dist/cjs/render/markdown/builder.js +18 -8
- package/dist/cjs/render/markdown/builder.js.map +1 -1
- package/dist/cjs/render/markdown/format.js +70 -30
- package/dist/cjs/render/markdown/format.js.map +1 -1
- package/dist/cjs/render/markdown/host_tags.js +67 -0
- package/dist/cjs/render/markdown/host_tags.js.map +1 -0
- package/dist/cjs/render/markdown/index.js +3 -1
- package/dist/cjs/render/markdown/index.js.map +1 -1
- package/dist/cjs/render/markdown/split.js +325 -0
- package/dist/cjs/render/markdown/split.js.map +1 -0
- package/dist/cjs/render/primitive_dispatch.js +11 -25
- package/dist/cjs/render/primitive_dispatch.js.map +1 -1
- package/dist/cjs/render/react/content.js +3 -1
- package/dist/cjs/render/react/content.js.map +1 -1
- package/dist/cjs/render/slack/format.js +1 -601
- package/dist/cjs/render/slack/format.js.map +1 -1
- package/dist/cjs/render/slack/index.js +1 -2
- package/dist/cjs/render/slack/index.js.map +1 -1
- package/dist/cjs/render/slack/markdown_content.js +172 -115
- package/dist/cjs/render/slack/markdown_content.js.map +1 -1
- package/dist/cjs/testing/conformance.js +40 -24
- package/dist/cjs/testing/conformance.js.map +1 -1
- package/dist/cjs/testing/icon.js +248 -0
- package/dist/cjs/testing/icon.js.map +1 -0
- package/dist/cjs/testing/index.js +3 -1
- package/dist/cjs/testing/index.js.map +1 -1
- package/dist/cjs/testing/registration.js +5 -3
- package/dist/cjs/testing/registration.js.map +1 -1
- package/dist/cjs/validate/authoring_schema.js +17 -1
- package/dist/cjs/validate/authoring_schema.js.map +1 -1
- package/dist/cjs/validate/index.js +2 -1
- package/dist/cjs/validate/index.js.map +1 -1
- package/dist/cjs/validate/json_schema.js +10 -3
- package/dist/cjs/validate/json_schema.js.map +1 -1
- package/dist/cjs/validate/url.js +2 -1
- package/dist/cjs/validate/url.js.map +1 -1
- package/dist/cjs/validate/validation.js +2 -45
- package/dist/cjs/validate/validation.js.map +1 -1
- package/dist/composition/body_node_base.d.ts +7 -6
- package/dist/composition/body_node_base.d.ts.map +1 -1
- package/dist/composition/body_node_base.js +10 -3
- package/dist/composition/body_node_base.js.map +1 -1
- package/dist/composition/error.d.ts +2 -0
- package/dist/composition/error.d.ts.map +1 -1
- package/dist/composition/error.js +2 -0
- package/dist/composition/error.js.map +1 -1
- package/dist/composition/index.d.ts +1 -1
- package/dist/composition/index.d.ts.map +1 -1
- package/dist/composition/index.js +1 -1
- package/dist/composition/index.js.map +1 -1
- package/dist/composition/structured_value.d.ts +3 -3
- package/dist/composition/structured_value.d.ts.map +1 -1
- package/dist/composition/structured_value.js.map +1 -1
- package/dist/define/frame.d.ts +9 -20
- package/dist/define/frame.d.ts.map +1 -1
- package/dist/define/frame.js +2 -3
- package/dist/define/frame.js.map +1 -1
- package/dist/define/index.d.ts +3 -1
- package/dist/define/index.d.ts.map +1 -1
- package/dist/define/index.js +3 -1
- package/dist/define/index.js.map +1 -1
- package/dist/define/primitive_example.d.ts +30 -0
- package/dist/define/primitive_example.d.ts.map +1 -0
- package/dist/define/primitive_example.js +21 -0
- package/dist/define/primitive_example.js.map +1 -0
- package/dist/define/primitive_icon.d.ts +11 -0
- package/dist/define/primitive_icon.d.ts.map +1 -0
- package/dist/define/primitive_icon.js +14 -0
- package/dist/define/primitive_icon.js.map +1 -0
- package/dist/define/primitive_module.d.ts +45 -24
- package/dist/define/primitive_module.d.ts.map +1 -1
- package/dist/define/primitive_module.js +24 -7
- package/dist/define/primitive_module.js.map +1 -1
- package/dist/define/slack_assets.d.ts +1 -1
- package/dist/define/slack_assets.d.ts.map +1 -1
- package/dist/define/slack_assets.js.map +1 -1
- package/dist/entries/index.d.ts +3 -3
- package/dist/entries/index.d.ts.map +1 -1
- package/dist/entries/index.js +3 -3
- package/dist/entries/index.js.map +1 -1
- package/dist/entries/markdown.d.ts +1 -1
- package/dist/entries/markdown.d.ts.map +1 -1
- package/dist/entries/markdown.js +1 -1
- package/dist/entries/markdown.js.map +1 -1
- package/dist/entries/slack.d.ts +1 -1
- package/dist/entries/slack.d.ts.map +1 -1
- package/dist/entries/slack.js +1 -1
- package/dist/entries/slack.js.map +1 -1
- package/dist/pack/capabilities.d.ts +24 -10
- package/dist/pack/capabilities.d.ts.map +1 -1
- package/dist/pack/capabilities.js +17 -11
- package/dist/pack/capabilities.js.map +1 -1
- package/dist/pack/compose.d.ts +4 -1
- package/dist/pack/compose.d.ts.map +1 -1
- package/dist/pack/compose.js +4 -1
- package/dist/pack/compose.js.map +1 -1
- package/dist/pack/index.d.ts +2 -2
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +2 -2
- package/dist/pack/index.js.map +1 -1
- package/dist/pack/primitive_pack.d.ts +14 -3
- package/dist/pack/primitive_pack.d.ts.map +1 -1
- package/dist/pack/primitive_pack.js +25 -4
- package/dist/pack/primitive_pack.js.map +1 -1
- package/dist/render/anchors.d.ts +2 -2
- package/dist/render/anchors.d.ts.map +1 -1
- package/dist/render/anchors.js +1 -1
- package/dist/render/anchors.js.map +1 -1
- package/dist/render/format_number.d.ts.map +1 -1
- package/dist/render/format_number.js +2 -1
- package/dist/render/format_number.js.map +1 -1
- package/dist/render/html/envelope.d.ts +3 -3
- package/dist/render/html/envelope.js +12 -6
- package/dist/render/html/envelope.js.map +1 -1
- package/dist/render/layout_check.d.ts +1 -1
- package/dist/render/layout_check.d.ts.map +1 -1
- package/dist/render/layout_check.js.map +1 -1
- package/dist/render/markdown/builder.d.ts +5 -4
- package/dist/render/markdown/builder.d.ts.map +1 -1
- package/dist/render/markdown/builder.js +16 -7
- package/dist/render/markdown/builder.js.map +1 -1
- package/dist/render/markdown/format.d.ts +9 -0
- package/dist/render/markdown/format.d.ts.map +1 -1
- package/dist/render/markdown/format.js +67 -31
- package/dist/render/markdown/format.js.map +1 -1
- package/dist/render/markdown/host_tags.d.ts +14 -0
- package/dist/render/markdown/host_tags.d.ts.map +1 -0
- package/dist/render/markdown/host_tags.js +63 -0
- package/dist/render/markdown/host_tags.js.map +1 -0
- package/dist/render/markdown/index.d.ts +1 -0
- package/dist/render/markdown/index.d.ts.map +1 -1
- package/dist/render/markdown/index.js +1 -0
- package/dist/render/markdown/index.js.map +1 -1
- package/dist/render/markdown/split.d.ts +32 -0
- package/dist/render/markdown/split.d.ts.map +1 -0
- package/dist/render/markdown/split.js +321 -0
- package/dist/render/markdown/split.js.map +1 -0
- package/dist/render/primitive_dispatch.d.ts +6 -6
- package/dist/render/primitive_dispatch.d.ts.map +1 -1
- package/dist/render/primitive_dispatch.js +12 -26
- package/dist/render/primitive_dispatch.js.map +1 -1
- package/dist/render/react/content.d.ts +1 -1
- package/dist/render/react/content.d.ts.map +1 -1
- package/dist/render/react/content.js +3 -1
- package/dist/render/react/content.js.map +1 -1
- package/dist/render/slack/format.d.ts +0 -25
- package/dist/render/slack/format.d.ts.map +1 -1
- package/dist/render/slack/format.js +1 -599
- package/dist/render/slack/format.js.map +1 -1
- package/dist/render/slack/index.d.ts +1 -1
- package/dist/render/slack/index.d.ts.map +1 -1
- package/dist/render/slack/index.js +1 -1
- package/dist/render/slack/index.js.map +1 -1
- package/dist/render/slack/markdown_content.d.ts +10 -4
- package/dist/render/slack/markdown_content.d.ts.map +1 -1
- package/dist/render/slack/markdown_content.js +169 -113
- package/dist/render/slack/markdown_content.js.map +1 -1
- package/dist/testing/conformance.d.ts +19 -14
- package/dist/testing/conformance.d.ts.map +1 -1
- package/dist/testing/conformance.js +40 -24
- package/dist/testing/conformance.js.map +1 -1
- package/dist/testing/icon.d.ts +11 -0
- package/dist/testing/icon.d.ts.map +1 -0
- package/dist/testing/icon.js +244 -0
- package/dist/testing/icon.js.map +1 -0
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/registration.d.ts +1 -1
- package/dist/testing/registration.d.ts.map +1 -1
- package/dist/testing/registration.js +6 -4
- package/dist/testing/registration.js.map +1 -1
- package/dist/validate/authoring_schema.d.ts +6 -0
- package/dist/validate/authoring_schema.d.ts.map +1 -1
- package/dist/validate/authoring_schema.js +15 -0
- package/dist/validate/authoring_schema.js.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +1 -1
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/json_schema.d.ts.map +1 -1
- package/dist/validate/json_schema.js +10 -3
- package/dist/validate/json_schema.js.map +1 -1
- package/dist/validate/url.d.ts.map +1 -1
- package/dist/validate/url.js +2 -1
- package/dist/validate/url.js.map +1 -1
- package/dist/validate/validation.d.ts +1 -11
- package/dist/validate/validation.d.ts.map +1 -1
- package/dist/validate/validation.js +3 -46
- package/dist/validate/validation.js.map +1 -1
- package/package.json +3 -2
package/dist/define/frame.js
CHANGED
|
@@ -13,16 +13,15 @@ export const bindFrame = (frame) => {
|
|
|
13
13
|
const themeFor = (mode) => mode === 'dark' ? frame.theme.dark : frame.theme.light;
|
|
14
14
|
return {
|
|
15
15
|
defaultWidth: frame.defaultWidth,
|
|
16
|
-
sizesFromNodeHeights: frame.sizesFromNodeHeights ?? true,
|
|
17
16
|
estimateHeight: (composition, dispatcher) => frame.estimateHeight(composition, dispatcher),
|
|
18
17
|
validateBody: (body) => frame.validateBody?.(body) ?? [],
|
|
19
18
|
resolveTheme: (mode) => themeFor(mode),
|
|
20
19
|
render: (composition, viewport, dispatcher) => {
|
|
21
20
|
const theme = themeFor(viewport.mode);
|
|
22
21
|
const { title, subtitle, theme: mode } = composition;
|
|
23
|
-
return frame.wrap({ title, subtitle, theme: mode }, composition.body.map((node, index) => dispatcher.
|
|
22
|
+
return frame.wrap({ title, subtitle, theme: mode }, composition.body.map((node, index) => dispatcher.renderSnapshot(node, `body-${index}`)), { ...viewport, theme });
|
|
24
23
|
},
|
|
25
|
-
renderNode: (node, dispatcher) => dispatcher.
|
|
24
|
+
renderNode: (node, dispatcher) => dispatcher.renderSnapshot(node, node.type),
|
|
26
25
|
};
|
|
27
26
|
};
|
|
28
27
|
//# sourceMappingURL=frame.js.map
|
package/dist/define/frame.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/define/frame.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyLH;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAS,KAAoB,EAAc,EAAE;IACpE,MAAM,QAAQ,GAAG,CAAC,IAA6B,EAAU,EAAE,CACzD,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;IACzD,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,IAAI,IAAI;QACxD,cAAc,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,CAC1C,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,UAAU,CAAC;QAC/C,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE;QACxD,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtC,MAAM,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE;YAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACtC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC;YACrD,OAAO,KAAK,CAAC,IAAI,CACf,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAChC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACnC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,KAAK,EAAE,CAAC,CAC5C,EACD,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,CACvB,CAAC;QACJ,CAAC;QACD,UAAU,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;KACxE,CAAC;AACJ,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// The frame an `svg` render is drawn inside, and the geometry that sizes it.\n// Frame is a runtime input, not a pack asset: vocabulary is additive, the\n// document is exclusive.\n\nimport type { ReactNode } from 'react';\n\nimport type { RenderTheme } from '../composition/named_color';\nimport type { PrimitiveNode } from '../composition/node';\n\n/**\n * A frame's palette, per mode. An image has no media queries, so it must\n * commit to one; `auto` resolves light.\n */\nexport interface ThemePair<TTheme> {\n light: TTheme;\n dark: TTheme;\n}\n\n/**\n * Geometry and resolved theme a frame draws within.\n *\n * Named for the viewport rather than the frame because {@link Frame.wrap}\n * draws *a* frame within it; the two would otherwise read as the same thing.\n */\nexport interface FrameViewport<TTheme> {\n width: number;\n height: number;\n /** Resolved from {@link Frame.theme} for `mode`. */\n theme: TTheme;\n /** What the caller asked for, before resolution. `undefined` and `auto` both resolve light. */\n mode: RenderTheme | undefined;\n}\n\n/**\n * The two dispatcher methods a frame needs.\n *\n * The render context the nodes are drawn with is bound by the caller rather\n * than passed here: it carries the class-name resolution that pairs with the\n * stylesheet emitted alongside the frame's output, which is the surface's\n * concern and not the document's. Generic in `TNode` so a helper can be\n * written against a narrowed node union while the runtime holds the erased form.\n */\nexport interface FrameDispatcher<TNode extends PrimitiveNode = PrimitiveNode> {\n /** Draws one node on the `svg` surface. `key` must be unique among its siblings. */\n renderSvg(node: TNode, key: string): ReactNode;\n /** The node's height in pixels; `0` when it is hidden from `svg` or its primitive declares no `metrics.svgHeight`. */\n estimateSvgHeight(node: TNode): number;\n}\n\n/**\n * What {@link Frame.wrap} is told about the composition it draws around.\n *\n * The body is withheld, and {@link bindFrame} copies only these fields into a\n * fresh value, so the surround cannot branch on a pack's node types.\n */\nexport interface FrameHeader {\n title?: string | undefined;\n subtitle?: string | undefined;\n /** The caller's preference, not a resolved palette. Use {@link FrameViewport.theme} to draw. */\n theme?: RenderTheme | undefined;\n}\n\n/** {@link FrameHeader} plus the body, for the sizing and validation hooks. */\nexport interface FrameComposition extends FrameHeader {\n /** Raw nodes, for measuring and checking only. {@link FrameBody} is what gets drawn. */\n body: PrimitiveNode[];\n}\n\n/**\n * Body nodes already rendered to elements, ready to be surrounded.\n *\n * Distinct from `Composition.body`, which is the raw {@link PrimitiveNode}\n * array a frame never sees.\n */\nexport type FrameBody = readonly ReactNode[];\n\n/**\n * A document an `svg` render can produce: its geometry, the surround it draws\n * around the body, and whatever it requires of a composition it is asked to\n * draw.\n *\n * A host registers frames with the runtime and picks one per render. That is\n * what lets one runtime serve a 760px card, a 1920x1080 slide, and a\n * host-branded variant of either from the same vocabulary — and what keeps a\n * vocabulary pack additive, since nothing about a primitive decides the frame.\n * A frame is named by the key a host registers it under, not by a field it\n * carries.\n */\nexport interface Frame<TTheme> {\n /** Width used when the caller passes none. */\n defaultWidth: number;\n /**\n * Whether {@link Frame.estimateHeight} sums per-node heights, and so\n * under-sizes the frame for a node whose primitive declares no\n * `metrics.svgHeight` — `dispatcher.estimateSvgHeight` returns `0` for those.\n *\n * Defaults to `true`, because the gap is silent and a frame that measures\n * nodes is the normal case. A fixed-size frame sets `false` once and stops\n * the missing `svgHeight` warning reporting a metric nothing reads.\n */\n sizesFromNodeHeights?: boolean;\n /**\n * Palette per mode. Frame and palette vary independently — a branded card is\n * this geometry with a host's colors — so a host overrides one by spreading\n * this value rather than rebuilding anything.\n */\n theme: ThemePair<TTheme>;\n /**\n * Height for this body when the caller passes none, in the geometry this\n * document defines. See {@link Frame.sizesFromNodeHeights} for what it may\n * assume of the nodes.\n */\n estimateHeight(\n composition: FrameComposition,\n dispatcher: FrameDispatcher\n ): number;\n /**\n * What this document requires of a body. A slide document's\n * exactly-one-`slideFrame` rule is the example.\n *\n * Returned rather than thrown so a caller can decide what to do with it, but\n * note where it is *not* checked: composition validation is frame-agnostic,\n * and has to be, because the same composition can be valid in one frame and\n * not another. Only the `svg` surface consults this, on the frame a render\n * actually names, and raises before drawing. A host that wants the answer\n * earlier asks the frame directly.\n */\n validateBody?(body: readonly PrimitiveNode[]): readonly string[];\n /**\n * Draws the surround around the already-rendered body nodes, including a\n * title header if this document wants one.\n *\n * Takes the nodes as an array rather than a single `ReactNode` so a frame\n * that draws no surround can return its one root element — image layout\n * starts from a single element, and an array or a fragment is not one.\n *\n * Declared property-style, so it is checked contravariantly in `TTheme` under\n * `strictFunctionTypes`. A method signature is bivariant, which would admit a\n * frame needing a richer theme into a slot typed for a narrower one, where it\n * would read a token nothing supplies.\n */\n wrap: (\n header: FrameHeader,\n body: FrameBody,\n viewport: FrameViewport<TTheme>\n ) => ReactNode;\n}\n\n/**\n * A {@link Frame} as the runtime stores it, with its theme resolved away.\n *\n * The erasure is a closure rather than a type parameter because the runtime\n * dispatches nodes through one inventory keyed by node type, which has no\n * single theme to name. A runtime's frames are homogeneous in `TTheme`, so the\n * palette is known where it is resolved and only the resolved result is stored.\n */\nexport interface BoundFrame {\n readonly defaultWidth: number;\n /** See {@link Frame.sizesFromNodeHeights}; defaulted at binding. */\n readonly sizesFromNodeHeights: boolean;\n /** See {@link Frame.estimateHeight}. */\n estimateHeight(\n composition: FrameComposition,\n dispatcher: FrameDispatcher\n ): number;\n /** See {@link Frame.validateBody}; empty when this frame states no rule. */\n validateBody(body: readonly PrimitiveNode[]): readonly string[];\n /**\n * Resolves {@link Frame.theme} for `mode`, erased to `unknown` like the rest\n * of this type. Lets a caller hand the palette to a primitive's `env.theme`\n * without itself knowing `TTheme`.\n */\n resolveTheme(mode: RenderTheme | undefined): unknown;\n /** Renders the body and its surround at `viewport`'s geometry. */\n render(\n composition: FrameComposition,\n viewport: { width: number; height: number; mode: RenderTheme | undefined },\n dispatcher: FrameDispatcher\n ): ReactNode;\n /** One node, no surround. */\n renderNode(node: PrimitiveNode, dispatcher: FrameDispatcher): ReactNode;\n}\n\n/**\n * Erases a {@link Frame}'s `TTheme` into a {@link BoundFrame}, resolving the\n * palette per render and composing the generic body walk with the frame's own\n * surround.\n */\nexport const bindFrame = <TTheme>(frame: Frame<TTheme>): BoundFrame => {\n const themeFor = (mode: RenderTheme | undefined): TTheme =>\n mode === 'dark' ? frame.theme.dark : frame.theme.light;\n return {\n defaultWidth: frame.defaultWidth,\n sizesFromNodeHeights: frame.sizesFromNodeHeights ?? true,\n estimateHeight: (composition, dispatcher) =>\n frame.estimateHeight(composition, dispatcher),\n validateBody: (body) => frame.validateBody?.(body) ?? [],\n resolveTheme: (mode) => themeFor(mode),\n render: (composition, viewport, dispatcher) => {\n const theme = themeFor(viewport.mode);\n const { title, subtitle, theme: mode } = composition;\n return frame.wrap(\n { title, subtitle, theme: mode },\n composition.body.map((node, index) =>\n dispatcher.renderSvg(node, `body-${index}`)\n ),\n { ...viewport, theme }\n );\n },\n renderNode: (node, dispatcher) => dispatcher.renderSvg(node, node.type),\n };\n};\n"]}
|
|
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,EAAE,UAAU,EAAE,EAAE,CAC/B,UAAU,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;KAC7C,CAAC;AACJ,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// The frame a `snapshot` render is drawn inside, and the geometry that sizes it.\n// Frame is a runtime input, not a pack asset: vocabulary is additive, the\n// document is exclusive.\n\nimport type { ReactNode } from 'react';\n\nimport type { RenderTheme } from '../composition/named_color';\nimport type { PrimitiveNode } from '../composition/node';\n\n/**\n * A frame's palette, per mode. An image has no media queries, so it must\n * commit to one; `auto` resolves light.\n */\nexport interface ThemePair<TTheme> {\n light: TTheme;\n dark: TTheme;\n}\n\n/**\n * Geometry and resolved theme a frame draws within.\n *\n * Named for the viewport rather than the frame because {@link Frame.wrap}\n * draws *a* frame within it; the two would otherwise read as the same thing.\n */\nexport interface FrameViewport<TTheme> {\n width: number;\n height: number;\n /** Resolved from {@link Frame.theme} for `mode`. */\n theme: TTheme;\n /** What the caller asked for, before resolution. `undefined` and `auto` both resolve light. */\n mode: RenderTheme | undefined;\n}\n\n/**\n * The two dispatcher methods a frame needs.\n *\n * The render context the nodes are drawn with is bound by the caller rather\n * than passed here: it carries the class-name resolution that pairs with the\n * stylesheet emitted alongside the frame's output, which is the surface's\n * concern and not the document's. Generic in `TNode` so a helper can be\n * written against a narrowed node union while the runtime holds the erased form.\n */\nexport interface FrameDispatcher<TNode extends PrimitiveNode = PrimitiveNode> {\n /** Draws one node on the `snapshot` surface. `key` must be unique among its siblings. */\n renderSnapshot(node: TNode, key: string): ReactNode;\n /** The node's height in pixels; `0` when it is hidden from `snapshot` or its primitive declares no `metrics.snapshotHeight`. */\n estimateSnapshotHeight(node: TNode): number;\n}\n\n/**\n * What {@link Frame.wrap} is told about the composition it draws around.\n *\n * The body is withheld, and {@link bindFrame} copies only these fields into a\n * fresh value, so the surround cannot branch on a pack's node types.\n */\nexport interface FrameHeader {\n title?: string | undefined;\n subtitle?: string | undefined;\n /** The caller's preference, not a resolved palette. Use {@link FrameViewport.theme} to draw. */\n theme?: RenderTheme | undefined;\n}\n\n/** {@link FrameHeader} plus the body, for the sizing and validation hooks. */\nexport interface FrameComposition extends FrameHeader {\n /** Raw nodes, for measuring and checking only. {@link FrameBody} is what gets drawn. */\n body: PrimitiveNode[];\n}\n\n/**\n * Body nodes already rendered to elements, ready to be surrounded.\n *\n * Distinct from `Composition.body`, which is the raw {@link PrimitiveNode}\n * array a frame never sees.\n */\nexport type FrameBody = readonly ReactNode[];\n\n/**\n * A document a `snapshot` render can produce: its geometry, the surround it draws\n * around the body, and whatever it requires of a composition it is asked to\n * draw.\n *\n * A host registers frames with the runtime and picks one per render. That is\n * what lets one runtime serve a 760px card, a 1920x1080 slide, and a\n * host-branded variant of either from the same vocabulary — and what keeps a\n * vocabulary pack additive, since nothing about a primitive decides the frame.\n * A frame is named by the key a host registers it under, not by a field it\n * carries.\n */\nexport interface Frame<TTheme> {\n /** Width used when the caller passes none. */\n defaultWidth: number;\n /**\n * Palette per mode. Frame and palette vary independently — a branded card is\n * this geometry with a host's colors — so a host overrides one by spreading\n * this value rather than rebuilding anything.\n */\n theme: ThemePair<TTheme>;\n /**\n * Height for this body when the caller passes none, in the geometry this\n * document defines. Calling {@link FrameDispatcher.estimateSnapshotHeight} is\n * what makes a missing `metrics.snapshotHeight` size the frame short: that\n * method returns `0` for a node whose primitive declares none.\n */\n estimateHeight(\n composition: FrameComposition,\n dispatcher: FrameDispatcher\n ): number;\n /**\n * What this document requires of a body. A slide document's\n * exactly-one-`slideFrame` rule is the example.\n *\n * Returned rather than thrown so a caller can decide what to do with it, but\n * note where it is *not* checked: composition validation is frame-agnostic,\n * and has to be, because the same composition can be valid in one frame and\n * not another. Only the `snapshot` surface consults this, on the frame a render\n * actually names, and raises before drawing. A host that wants the answer\n * earlier asks the frame directly.\n */\n validateBody?(body: readonly PrimitiveNode[]): readonly string[];\n /**\n * Draws the surround around the already-rendered body nodes, including a\n * title header if this document wants one.\n *\n * Takes the nodes as an array rather than a single `ReactNode` so a frame\n * that draws no surround can return its one root element — image layout\n * starts from a single element, and an array or a fragment is not one.\n *\n * Declared property-style, so it is checked contravariantly in `TTheme` under\n * `strictFunctionTypes`. A method signature is bivariant, which would admit a\n * frame needing a richer theme into a slot typed for a narrower one, where it\n * would read a token nothing supplies.\n */\n wrap: (\n header: FrameHeader,\n body: FrameBody,\n viewport: FrameViewport<TTheme>\n ) => ReactNode;\n}\n\n/**\n * A {@link Frame} as the runtime stores it, with its theme resolved away.\n *\n * The erasure is a closure rather than a type parameter because the runtime\n * dispatches nodes through one inventory keyed by node type, which has no\n * single theme to name. A runtime's frames are homogeneous in `TTheme`, so the\n * palette is known where it is resolved and only the resolved result is stored.\n */\nexport interface BoundFrame {\n readonly defaultWidth: number;\n /** See {@link Frame.estimateHeight}. */\n estimateHeight(\n composition: FrameComposition,\n dispatcher: FrameDispatcher\n ): number;\n /** See {@link Frame.validateBody}; empty when this frame states no rule. */\n validateBody(body: readonly PrimitiveNode[]): readonly string[];\n /**\n * Resolves {@link Frame.theme} for `mode`, erased to `unknown` like the rest\n * of this type. Lets a caller hand the palette to a primitive's `env.theme`\n * without itself knowing `TTheme`.\n */\n resolveTheme(mode: RenderTheme | undefined): unknown;\n /** Renders the body and its surround at `viewport`'s geometry. */\n render(\n composition: FrameComposition,\n viewport: { width: number; height: number; mode: RenderTheme | undefined },\n dispatcher: FrameDispatcher\n ): ReactNode;\n /** One node, no surround. */\n renderNode(node: PrimitiveNode, dispatcher: FrameDispatcher): ReactNode;\n}\n\n/**\n * Erases a {@link Frame}'s `TTheme` into a {@link BoundFrame}, resolving the\n * palette per render and composing the generic body walk with the frame's own\n * surround.\n */\nexport const bindFrame = <TTheme>(frame: Frame<TTheme>): BoundFrame => {\n const themeFor = (mode: RenderTheme | undefined): TTheme =>\n mode === 'dark' ? frame.theme.dark : frame.theme.light;\n return {\n defaultWidth: frame.defaultWidth,\n estimateHeight: (composition, dispatcher) =>\n frame.estimateHeight(composition, dispatcher),\n validateBody: (body) => frame.validateBody?.(body) ?? [],\n resolveTheme: (mode) => themeFor(mode),\n render: (composition, viewport, dispatcher) => {\n const theme = themeFor(viewport.mode);\n const { title, subtitle, theme: mode } = composition;\n return frame.wrap(\n { title, subtitle, theme: mode },\n composition.body.map((node, index) =>\n dispatcher.renderSnapshot(node, `body-${index}`)\n ),\n { ...viewport, theme }\n );\n },\n renderNode: (node, dispatcher) =>\n dispatcher.renderSnapshot(node, node.type),\n };\n};\n"]}
|
package/dist/define/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { type BoundFrame, type Frame, type FrameBody, type FrameComposition, type FrameDispatcher, type FrameHeader, type FrameViewport, type ThemePair, bindFrame, } from './frame.js';
|
|
2
2
|
export { type MarkdownBlock, type MarkdownContent, type MarkdownInline, type MarkdownInlineInput, } from './markdown_content.js';
|
|
3
|
-
export { type
|
|
3
|
+
export { type ExampleNode, type NormalizedPrimitiveExample, type PrimitiveExample, exampleNodes, primitiveExamples, } from './primitive_example.js';
|
|
4
|
+
export { type PrimitiveIcon, ICON_VARS } from './primitive_icon.js';
|
|
5
|
+
export { type AnyPrimitiveDefinition, type DefaultPackTypes, type OptionalSurface, type PackTypes, type PrimitiveCatalogEntry, type PrimitiveChildRef, type PrimitiveDefinition, type PrimitiveMetrics, type PrimitiveNode, type PrimitiveRenderContext, type PrimitiveSchema, type PrimitiveStyleCollectionContext, type PrimitiveStyleCollector, type ReactContextArg, type Renderer, type Renderers, type RenderScope, type StyledRenderContext, type StyleHandle, type SurfaceMap, type ThemeTokenPath, type WithNodeFields, OPTIONAL_SURFACES, bodyNodeIdSchema, bodyNodeSurfacesSchema, definePrimitive, definePrimitiveFor, unresolvedBodyNodeSchema, validateWithSchema, } from './primitive_module.js';
|
|
4
6
|
export { type SlackAssetCollector, type SlackAssetRequest, } from './slack_assets.js';
|
|
5
7
|
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, } from './slack_blocks.js';
|
|
6
8
|
export { declaredFieldsNote, formatZodIssues } from './zod_format.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/define/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB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AClB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/define/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,0BAA0B,EAC/B,KAAK,gBAAgB,EACrB,YAAY,EACZ,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,+BAA+B,EACpC,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB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indFrame, } from './frame.js';
|
|
8
|
-
export {
|
|
8
|
+
export { exampleNodes, primitiveExamples, } from './primitive_example.js';
|
|
9
|
+
export { ICON_VARS } from './primitive_icon.js';
|
|
10
|
+
export { OPTIONAL_SURFACES, bodyNodeIdSchema, bodyNodeSurfacesSchema, definePrimitive, definePrimitiveFor, unresolvedBodyNodeSchema, validateWithSchema, } from './primitive_module.js';
|
|
9
11
|
export { declaredFieldsNote, formatZodIssues } from './zod_format.js';
|
|
10
12
|
export { requiredString, z } from './zod_helpers.js';
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
package/dist/define/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/define/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EASL,SAAS,GACV,MAAM,SAAS,CAAC;AAOjB,OAAO,EAuBL,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AA+C5B,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,CAAC,EAAE,MAAM,eAAe,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 BoundFrame,\n type Frame,\n type FrameBody,\n type FrameComposition,\n type FrameDispatcher,\n type FrameHeader,\n type FrameViewport,\n type ThemePair,\n bindFrame,\n} from './frame';\nexport {\n type MarkdownBlock,\n type MarkdownContent,\n type MarkdownInline,\n type MarkdownInlineInput,\n} from './markdown_content';\nexport {\n type AnyPrimitiveDefinition,\n type DefaultPackTypes,\n type OptionalSurface,\n type PackTypes,\n type PrimitiveCatalogEntry,\n type PrimitiveChildRef,\n type PrimitiveDefinition,\n type PrimitiveMetrics,\n type PrimitiveNode,\n type PrimitiveRenderContext,\n type PrimitiveSchema,\n type PrimitiveStyleCollectionContext,\n type PrimitiveStyleCollector,\n type ReactContextArg,\n type Renderer,\n type Renderers,\n type RenderScope,\n type StyledRenderContext,\n type StyleHandle,\n type SurfaceMap,\n type ThemeTokenPath,\n type WithNodeFields,\n bodyNodeIdSchema,\n bodyNodeSurfacesSchema,\n definePrimitive,\n definePrimitiveFor,\n unresolvedBodyNodeSchema,\n validateWithSchema,\n} from './primitive_module';\nexport {\n type SlackAssetCollector,\n type SlackAssetRequest,\n} from './slack_assets';\nexport {\n type SlackActionElement,\n type SlackActionsBlock,\n type SlackBlock,\n type SlackButtonElement,\n type SlackCheckboxesElement,\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} from './slack_blocks';\nexport { declaredFieldsNote, formatZodIssues } from './zod_format';\nexport { requiredString, z } from './zod_helpers';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/define/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EASL,SAAS,GACV,MAAM,SAAS,CAAC;AAOjB,OAAO,EAIL,YAAY,EACZ,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAsB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAuBL,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AA+C5B,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,CAAC,EAAE,MAAM,eAAe,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 BoundFrame,\n type Frame,\n type FrameBody,\n type FrameComposition,\n type FrameDispatcher,\n type FrameHeader,\n type FrameViewport,\n type ThemePair,\n bindFrame,\n} from './frame';\nexport {\n type MarkdownBlock,\n type MarkdownContent,\n type MarkdownInline,\n type MarkdownInlineInput,\n} from './markdown_content';\nexport {\n type ExampleNode,\n type NormalizedPrimitiveExample,\n type PrimitiveExample,\n exampleNodes,\n primitiveExamples,\n} from './primitive_example';\nexport { type PrimitiveIcon, ICON_VARS } from './primitive_icon';\nexport {\n type AnyPrimitiveDefinition,\n type DefaultPackTypes,\n type OptionalSurface,\n type PackTypes,\n type PrimitiveCatalogEntry,\n type PrimitiveChildRef,\n type PrimitiveDefinition,\n type PrimitiveMetrics,\n type PrimitiveNode,\n type PrimitiveRenderContext,\n type PrimitiveSchema,\n type PrimitiveStyleCollectionContext,\n type PrimitiveStyleCollector,\n type ReactContextArg,\n type Renderer,\n type Renderers,\n type RenderScope,\n type StyledRenderContext,\n type StyleHandle,\n type SurfaceMap,\n type ThemeTokenPath,\n type WithNodeFields,\n OPTIONAL_SURFACES,\n bodyNodeIdSchema,\n bodyNodeSurfacesSchema,\n definePrimitive,\n definePrimitiveFor,\n unresolvedBodyNodeSchema,\n validateWithSchema,\n} from './primitive_module';\nexport {\n type SlackAssetCollector,\n type SlackAssetRequest,\n} from './slack_assets';\nexport {\n type SlackActionElement,\n type SlackActionsBlock,\n type SlackBlock,\n type SlackButtonElement,\n type SlackCheckboxesElement,\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} from './slack_blocks';\nexport { declaredFieldsNote, formatZodIssues } from './zod_format';\nexport { requiredString, z } from './zod_helpers';\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PrimitiveNode } from '../composition/node.js';
|
|
2
|
+
/** A published example with a name hosts can list it by. */
|
|
3
|
+
export interface PrimitiveExample<TNode extends PrimitiveNode = PrimitiveNode> {
|
|
4
|
+
/** Short and unique within the primitive, such as `Warning tone`. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** What the example demonstrates. */
|
|
7
|
+
description?: string;
|
|
8
|
+
node: TNode;
|
|
9
|
+
/** Never set: an entry is a bare node exactly when it has a `type`. */
|
|
10
|
+
type?: never;
|
|
11
|
+
}
|
|
12
|
+
/** An entry of `examples` read as one shape; `name` is absent for a bare node. */
|
|
13
|
+
export interface NormalizedPrimitiveExample<TNode extends PrimitiveNode = PrimitiveNode> {
|
|
14
|
+
name?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
node: TNode;
|
|
17
|
+
}
|
|
18
|
+
/** The node type an `examples` entry holds. */
|
|
19
|
+
export type ExampleNode<TEntry> = TEntry extends PrimitiveExample<infer TNode> ? TNode : TEntry;
|
|
20
|
+
interface WithExamples {
|
|
21
|
+
readonly examples: readonly (PrimitiveNode | PrimitiveExample)[];
|
|
22
|
+
}
|
|
23
|
+
/** Distributes over a union of definitions, so a mixed registry keeps every node type. */
|
|
24
|
+
type NodeOf<TDefinition extends WithExamples> = ExampleNode<TDefinition['examples'][number]>;
|
|
25
|
+
/** A definition's examples, bare or named, as {@link NormalizedPrimitiveExample}s. */
|
|
26
|
+
export declare const primitiveExamples: <TDefinition extends WithExamples>({ examples, }: TDefinition) => NormalizedPrimitiveExample<NodeOf<TDefinition>>[];
|
|
27
|
+
/** A definition's example nodes, without names. */
|
|
28
|
+
export declare const exampleNodes: <TDefinition extends WithExamples>({ examples, }: TDefinition) => NodeOf<TDefinition>[];
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=primitive_example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive_example.d.ts","sourceRoot":"","sources":["../../src/define/primitive_example.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,4DAA4D;AAC5D,MAAM,WAAW,gBAAgB,CAAC,KAAK,SAAS,aAAa,GAAG,aAAa;IAC3E,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,KAAK,CAAC;IACZ,uEAAuE;IACvE,IAAI,CAAC,EAAE,KAAK,CAAC;CACd;AAED,kFAAkF;AAClF,MAAM,WAAW,0BAA0B,CACzC,KAAK,SAAS,aAAa,GAAG,aAAa;IAE3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,KAAK,CAAC;CACb;AAED,+CAA+C;AAC/C,MAAM,MAAM,WAAW,CAAC,MAAM,IAC5B,MAAM,SAAS,gBAAgB,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC;AAEhE,UAAU,YAAY;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,aAAa,GAAG,gBAAgB,CAAC,EAAE,CAAC;CAClE;AAED,0FAA0F;AAC1F,KAAK,MAAM,CAAC,WAAW,SAAS,YAAY,IAAI,WAAW,CACzD,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAChC,CAAC;AAkBF,sFAAsF;AACtF,eAAO,MAAM,iBAAiB,GAAI,WAAW,SAAS,YAAY,EAAE,eAEjE,WAAW,KAAG,0BAA0B,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EACc,CAAC;AAE/E,mDAAmD;AACnD,eAAO,MAAM,YAAY,GAAI,WAAW,SAAS,YAAY,EAAE,eAE5D,WAAW,KAAG,MAAM,CAAC,WAAW,CAAC,EACqC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 isPrimitiveExample = (entry) => !('type' in entry) && 'node' in entry;
|
|
8
|
+
const normalize = (entry) => {
|
|
9
|
+
if (!isPrimitiveExample(entry)) {
|
|
10
|
+
return { node: entry };
|
|
11
|
+
}
|
|
12
|
+
const { name, description, node } = entry;
|
|
13
|
+
return description === undefined
|
|
14
|
+
? { name, node }
|
|
15
|
+
: { name, description, node };
|
|
16
|
+
};
|
|
17
|
+
/** A definition's examples, bare or named, as {@link NormalizedPrimitiveExample}s. */
|
|
18
|
+
export const primitiveExamples = ({ examples, }) => examples.map(normalize);
|
|
19
|
+
/** A definition's example nodes, without names. */
|
|
20
|
+
export const exampleNodes = ({ examples, }) => examples.map((entry) => normalize(entry).node);
|
|
21
|
+
//# sourceMappingURL=primitive_example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive_example.js","sourceRoot":"","sources":["../../src/define/primitive_example.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqCH,MAAM,kBAAkB,GAAG,CACzB,KAAuC,EACZ,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,MAAM,IAAI,KAAK,CAAC;AAEtE,MAAM,SAAS,GAAG,CAChB,KAAuC,EACX,EAAE;IAC9B,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAC1C,OAAO,WAAW,KAAK,SAAS;QAC9B,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE;QAChB,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAClC,CAAC,CAAC;AAEF,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAmC,EAClE,QAAQ,GACI,EAAqD,EAAE,CACnE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAsD,CAAC;AAE/E,mDAAmD;AACnD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAmC,EAC7D,QAAQ,GACI,EAAyB,EAAE,CACvC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAA0B,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 { PrimitiveNode } from '../composition/node';\n\n/** A published example with a name hosts can list it by. */\nexport interface PrimitiveExample<TNode extends PrimitiveNode = PrimitiveNode> {\n /** Short and unique within the primitive, such as `Warning tone`. */\n name: string;\n /** What the example demonstrates. */\n description?: string;\n node: TNode;\n /** Never set: an entry is a bare node exactly when it has a `type`. */\n type?: never;\n}\n\n/** An entry of `examples` read as one shape; `name` is absent for a bare node. */\nexport interface NormalizedPrimitiveExample<\n TNode extends PrimitiveNode = PrimitiveNode,\n> {\n name?: string;\n description?: string;\n node: TNode;\n}\n\n/** The node type an `examples` entry holds. */\nexport type ExampleNode<TEntry> =\n TEntry extends PrimitiveExample<infer TNode> ? TNode : TEntry;\n\ninterface WithExamples {\n readonly examples: readonly (PrimitiveNode | PrimitiveExample)[];\n}\n\n/** Distributes over a union of definitions, so a mixed registry keeps every node type. */\ntype NodeOf<TDefinition extends WithExamples> = ExampleNode<\n TDefinition['examples'][number]\n>;\n\nconst isPrimitiveExample = (\n entry: PrimitiveNode | PrimitiveExample\n): entry is PrimitiveExample => !('type' in entry) && 'node' in entry;\n\nconst normalize = (\n entry: PrimitiveNode | PrimitiveExample\n): NormalizedPrimitiveExample => {\n if (!isPrimitiveExample(entry)) {\n return { node: entry };\n }\n const { name, description, node } = entry;\n return description === undefined\n ? { name, node }\n : { name, description, node };\n};\n\n/** A definition's examples, bare or named, as {@link NormalizedPrimitiveExample}s. */\nexport const primitiveExamples = <TDefinition extends WithExamples>({\n examples,\n}: TDefinition): NormalizedPrimitiveExample<NodeOf<TDefinition>>[] =>\n examples.map(normalize) as NormalizedPrimitiveExample<NodeOf<TDefinition>>[];\n\n/** A definition's example nodes, without names. */\nexport const exampleNodes = <TDefinition extends WithExamples>({\n examples,\n}: TDefinition): NodeOf<TDefinition>[] =>\n examples.map((entry) => normalize(entry).node) as NodeOf<TDefinition>[];\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A 16×16 glyph a host shows beside the primitive: static SVG, inlinable without a renderer.
|
|
3
|
+
*
|
|
4
|
+
* Colours go through {@link ICON_VARS}, optionally with a `currentColor` or hex fallback; `assertPackIconsValid` from `./testing` enforces the rules.
|
|
5
|
+
*/
|
|
6
|
+
export interface PrimitiveIcon {
|
|
7
|
+
svg: string;
|
|
8
|
+
}
|
|
9
|
+
/** The colour slots an icon may paint with, which a host sets per theme and mode. */
|
|
10
|
+
export declare const ICON_VARS: readonly ["--isomer-icon-accent", "--isomer-icon-bg", "--isomer-icon-fg", "--isomer-icon-muted"];
|
|
11
|
+
//# sourceMappingURL=primitive_icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive_icon.d.ts","sourceRoot":"","sources":["../../src/define/primitive_icon.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,qFAAqF;AACrF,eAAO,MAAM,SAAS,kGAKZ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
/** The colour slots an icon may paint with, which a host sets per theme and mode. */
|
|
8
|
+
export const ICON_VARS = [
|
|
9
|
+
'--isomer-icon-accent',
|
|
10
|
+
'--isomer-icon-bg',
|
|
11
|
+
'--isomer-icon-fg',
|
|
12
|
+
'--isomer-icon-muted',
|
|
13
|
+
];
|
|
14
|
+
//# sourceMappingURL=primitive_icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive_icon.js","sourceRoot":"","sources":["../../src/define/primitive_icon.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,qFAAqF;AACrF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,sBAAsB;IACtB,kBAAkB;IAClB,kBAAkB;IAClB,qBAAqB;CACb,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/**\n * A 16×16 glyph a host shows beside the primitive: static SVG, inlinable without a renderer.\n *\n * Colours go through {@link ICON_VARS}, optionally with a `currentColor` or hex fallback; `assertPackIconsValid` from `./testing` enforces the rules.\n */\nexport interface PrimitiveIcon {\n svg: string;\n}\n\n/** The colour slots an icon may paint with, which a host sets per theme and mode. */\nexport const ICON_VARS = [\n '--isomer-icon-accent',\n '--isomer-icon-bg',\n '--isomer-icon-fg',\n '--isomer-icon-muted',\n] as const;\n"]}
|
|
@@ -5,6 +5,8 @@ import { type ChildNodeRef, type SurfaceName } from '../composition/body_node_ba
|
|
|
5
5
|
import type { PrimitiveNode } from '../composition/node.js';
|
|
6
6
|
import type { ValidationError } from '../composition/validation_error.js';
|
|
7
7
|
import type { MarkdownContent } from './markdown_content.js';
|
|
8
|
+
import type { PrimitiveExample } from './primitive_example.js';
|
|
9
|
+
import type { PrimitiveIcon } from './primitive_icon.js';
|
|
8
10
|
import type { SlackAssetCollector } from './slack_assets.js';
|
|
9
11
|
import type { SlackBlock } from './slack_blocks.js';
|
|
10
12
|
export type { PrimitiveNode };
|
|
@@ -12,10 +14,20 @@ export type { PrimitiveNode };
|
|
|
12
14
|
* A primitive's entry in the catalog the authoring prompt is built from.
|
|
13
15
|
*
|
|
14
16
|
* Written for the model rather than for a developer: `useWhen` and `avoidWhen`
|
|
15
|
-
* are what steer it away from reaching for the wrong primitive.
|
|
17
|
+
* are what steer it away from reaching for the wrong primitive. `name` is the
|
|
18
|
+
* one host-facing field, and the prompt never prints it.
|
|
16
19
|
*/
|
|
17
20
|
export interface PrimitiveCatalogEntry {
|
|
18
21
|
type: string;
|
|
22
|
+
/** Short name a host shows for the primitive, e.g. `Stat group`. Absent means the host derives one from `type`. */
|
|
23
|
+
name?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Description of this primitive's `$def` in the authoring JSON Schema.
|
|
26
|
+
*
|
|
27
|
+
* `z.toJSONSchema` drops refinements, so a cross-field rule is restated here.
|
|
28
|
+
* {@link definePrimitive} copies `schema.description` when this is omitted.
|
|
29
|
+
*/
|
|
30
|
+
description?: string;
|
|
19
31
|
/** One line on what the primitive is for, in the model's voice. */
|
|
20
32
|
purpose: string;
|
|
21
33
|
/** Situations that call for this primitive. Phrase each as a user intent, not a shape. */
|
|
@@ -53,7 +65,7 @@ export interface PrimitiveRenderContext {
|
|
|
53
65
|
* still answer the question on its own. See `docs/rendering.md`.
|
|
54
66
|
*/
|
|
55
67
|
enhancements?: ReadonlySet<string>;
|
|
56
|
-
/** Turns on `nodeAnchor` outside an HTML surface render, on the React and `
|
|
68
|
+
/** Turns on `nodeAnchor` outside an HTML surface render, on the React and `snapshot` surfaces; inside one, the surface decides. */
|
|
57
69
|
anchors?: boolean;
|
|
58
70
|
/** Raises an interaction for the host to route. Absent means render non-interactively. */
|
|
59
71
|
onEvent?: (event: ActionEventRef) => void;
|
|
@@ -127,9 +139,9 @@ export interface SurfaceMap<T extends PackTypes = DefaultPackTypes> {
|
|
|
127
139
|
scope: RenderScope<T>;
|
|
128
140
|
/**
|
|
129
141
|
* The frame's resolved palette, when this render is reached through the
|
|
130
|
-
* `
|
|
142
|
+
* `snapshot` surface. A bare `react`/`html` render has no {@link Frame} to
|
|
131
143
|
* resolve one from, so it is absent there — a pack that needs a
|
|
132
|
-
* literal color outside `
|
|
144
|
+
* literal color outside `snapshot` still goes through `context`.
|
|
133
145
|
*/
|
|
134
146
|
theme?: T['theme'];
|
|
135
147
|
};
|
|
@@ -139,9 +151,9 @@ export interface SurfaceMap<T extends PackTypes = DefaultPackTypes> {
|
|
|
139
151
|
* Identical to `react`, and served by the same renderer: an image backend
|
|
140
152
|
* lays out the pack's DOM tree and stylesheet rather than a second tree
|
|
141
153
|
* authored for it. The surface stays separate so a node can be hidden from
|
|
142
|
-
*
|
|
154
|
+
* snapshots alone, and so a {@link Frame} has something to draw inside.
|
|
143
155
|
*/
|
|
144
|
-
|
|
156
|
+
snapshot: {
|
|
145
157
|
env: {
|
|
146
158
|
context: T['context'];
|
|
147
159
|
scope: RenderScope<T>;
|
|
@@ -156,12 +168,12 @@ export interface SurfaceMap<T extends PackTypes = DefaultPackTypes> {
|
|
|
156
168
|
};
|
|
157
169
|
output: string;
|
|
158
170
|
};
|
|
159
|
-
/**
|
|
171
|
+
/** Content built with `md`, escaped where it lands; authored Markdown source goes through `md.authored`. */
|
|
160
172
|
markdown: {
|
|
161
173
|
env: {
|
|
162
174
|
scope: RenderScope<T>;
|
|
163
175
|
};
|
|
164
|
-
output:
|
|
176
|
+
output: MarkdownContent;
|
|
165
177
|
};
|
|
166
178
|
/**
|
|
167
179
|
* Returns one payload or several, so a primitive need not wrap a single
|
|
@@ -193,12 +205,12 @@ export interface RenderScope<T extends PackTypes = DefaultPackTypes> {
|
|
|
193
205
|
collectStyles(node: PrimitiveNode, styles: PrimitiveStyleCollector, context: PrimitiveStyleCollectionContext): void;
|
|
194
206
|
renderText(node: PrimitiveNode): string;
|
|
195
207
|
renderMarkdown(node: PrimitiveNode): string;
|
|
196
|
-
/** A child as content, for a container building with `md
|
|
208
|
+
/** A child as content, for a container building with `md`. */
|
|
197
209
|
renderMarkdownContent(node: PrimitiveNode): MarkdownContent;
|
|
198
210
|
/** Empty when the node is hidden from `slack`, `sanitize` drops it, or its renderer returns nothing; a node with no `slack` renderer degrades through its markdown. */
|
|
199
211
|
renderSlack(node: PrimitiveNode, collector?: T['slackCollector']): readonly T['slackBlock'][];
|
|
200
|
-
/** `0` when the node is hidden from `
|
|
201
|
-
|
|
212
|
+
/** `0` when the node is hidden from `snapshot` or its primitive declares no `metrics.snapshotHeight`. */
|
|
213
|
+
estimateSnapshotHeight(node: PrimitiveNode): number;
|
|
202
214
|
/** Appends schema failures under `path` to `errors`, each naming `node`'s type. */
|
|
203
215
|
validate(node: PrimitiveNode, path: string, errors: ValidationError[]): void;
|
|
204
216
|
}
|
|
@@ -215,15 +227,17 @@ export type Renderer<TNode extends PrimitiveNode, S extends SurfaceName, T exten
|
|
|
215
227
|
*
|
|
216
228
|
* Only `slack`, and even that stays optional per primitive: the dispatcher
|
|
217
229
|
* converts the mandatory markdown to Block Kit, so a missing Slack renderer
|
|
218
|
-
* degrades rather than disappearing. `
|
|
230
|
+
* degrades rather than disappearing. `snapshot` is not here because no primitive
|
|
219
231
|
* implements it — the surface reuses `react`.
|
|
220
232
|
*/
|
|
221
|
-
export
|
|
233
|
+
export declare const OPTIONAL_SURFACES: readonly ["slack"];
|
|
234
|
+
/** One of the {@link OPTIONAL_SURFACES}. */
|
|
235
|
+
export type OptionalSurface = (typeof OPTIONAL_SURFACES)[number];
|
|
222
236
|
/**
|
|
223
237
|
* One renderer per surface a primitive implements.
|
|
224
238
|
*
|
|
225
239
|
* `react`, `text`, and `markdown` are always required: those three are what
|
|
226
|
-
* make "every composition degrades" true. `react` serves the `
|
|
240
|
+
* make "every composition degrades" true. `react` serves the `snapshot` surface
|
|
227
241
|
* too, so targeting images costs a primitive nothing.
|
|
228
242
|
*
|
|
229
243
|
* `slack` is declared method-style deliberately: method parameters are checked
|
|
@@ -241,7 +255,7 @@ export interface Renderers<TNode extends PrimitiveNode, T extends PackTypes = De
|
|
|
241
255
|
}): string;
|
|
242
256
|
markdown(node: TNode, env: {
|
|
243
257
|
scope: RenderScope<T>;
|
|
244
|
-
}):
|
|
258
|
+
}): MarkdownContent;
|
|
245
259
|
slack?(node: TNode, env: {
|
|
246
260
|
collector?: T['slackCollector'];
|
|
247
261
|
scope: RenderScope<T>;
|
|
@@ -250,12 +264,12 @@ export interface Renderers<TNode extends PrimitiveNode, T extends PackTypes = De
|
|
|
250
264
|
/**
|
|
251
265
|
* Measurements a frame can ask of a node before drawing it.
|
|
252
266
|
*
|
|
253
|
-
* `
|
|
254
|
-
*
|
|
267
|
+
* `snapshotHeight` is optional. The height estimate is `0` when it is missing, so
|
|
268
|
+
* a frame that sums node heights sizes short.
|
|
255
269
|
*/
|
|
256
270
|
export interface PrimitiveMetrics<TNode extends PrimitiveNode> {
|
|
257
271
|
/** The node's drawn height in pixels at the frame's width. */
|
|
258
|
-
|
|
272
|
+
snapshotHeight?: (node: TNode) => number;
|
|
259
273
|
}
|
|
260
274
|
/**
|
|
261
275
|
* Every primitive's schema is an object schema, because {@link definePrimitive}
|
|
@@ -292,8 +306,14 @@ export interface PrimitiveDefinition<TNode extends PrimitiveNode, T extends Pack
|
|
|
292
306
|
type: TNode['type'];
|
|
293
307
|
/** How the authoring prompt describes this primitive to the model. */
|
|
294
308
|
catalog: PrimitiveCatalogEntry;
|
|
295
|
-
/**
|
|
296
|
-
|
|
309
|
+
/** Host-facing glyph, never shown to the model. Absent means the host supplies its own. */
|
|
310
|
+
icon?: PrimitiveIcon;
|
|
311
|
+
/**
|
|
312
|
+
* Driven by the conformance harness, bare or named; read them with
|
|
313
|
+
* `exampleNodes` or `primitiveExamples`. The catalog `example` is what the
|
|
314
|
+
* prompt shows.
|
|
315
|
+
*/
|
|
316
|
+
examples: readonly (TNode | PrimitiveExample<TNode>)[];
|
|
297
317
|
/**
|
|
298
318
|
* This primitive on its own. A container declares
|
|
299
319
|
* {@link PrimitiveDefinition.schemaFor} as well, and uses
|
|
@@ -310,7 +330,7 @@ export interface PrimitiveDefinition<TNode extends PrimitiveNode, T extends Pack
|
|
|
310
330
|
* exactly one union.
|
|
311
331
|
*/
|
|
312
332
|
schemaFor?: (bodyNodeSchema: ZodType<unknown>) => PrimitiveSchema;
|
|
313
|
-
/** One function per surface; `react` serves `
|
|
333
|
+
/** One function per surface; `react` serves `snapshot` as well. */
|
|
314
334
|
renderers: Renderers<TNode, T>;
|
|
315
335
|
/** Sizing a frame can ask for before drawing. Absent means it cannot be measured. */
|
|
316
336
|
metrics?: PrimitiveMetrics<TNode>;
|
|
@@ -353,12 +373,13 @@ export interface PrimitiveDefinition<TNode extends PrimitiveNode, T extends Pack
|
|
|
353
373
|
export interface AnyPrimitiveDefinition {
|
|
354
374
|
type: string;
|
|
355
375
|
catalog: PrimitiveCatalogEntry;
|
|
356
|
-
|
|
376
|
+
icon?: PrimitiveIcon;
|
|
377
|
+
examples: readonly (PrimitiveNode | PrimitiveExample)[];
|
|
357
378
|
schema: PrimitiveSchema;
|
|
358
379
|
schemaFor?: (bodyNodeSchema: ZodType<unknown>) => PrimitiveSchema;
|
|
359
380
|
renderers: Record<'react' | 'text' | 'markdown', unknown> & Partial<Record<'slack', unknown>>;
|
|
360
381
|
metrics?: {
|
|
361
|
-
|
|
382
|
+
snapshotHeight?: unknown;
|
|
362
383
|
};
|
|
363
384
|
sanitize?: unknown;
|
|
364
385
|
children?: unknown;
|
|
@@ -372,7 +393,7 @@ export declare const bodyNodeIdSchema: z.ZodString;
|
|
|
372
393
|
/** The `surfaces` allowlist on a node. Absent means every surface; empty is rejected. */
|
|
373
394
|
export declare const bodyNodeSurfacesSchema: z.ZodArray<z.ZodEnum<{
|
|
374
395
|
react: "react";
|
|
375
|
-
|
|
396
|
+
snapshot: "snapshot";
|
|
376
397
|
text: "text";
|
|
377
398
|
markdown: "markdown";
|
|
378
399
|
slack: "slack";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitive_module.d.ts","sourceRoot":"","sources":["../../src/define/primitive_module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,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5
|
* 2.0.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import {
|
|
8
|
+
import { SURFACE_NAMES, } from '../composition/body_node_base.js';
|
|
9
9
|
import { ISOMER_ERROR_CODES, IsomerError } from '../composition/error.js';
|
|
10
10
|
import { formatZodIssues, oneOf } from './zod_format.js';
|
|
11
11
|
import { requiredString } from './zod_helpers.js';
|
|
12
|
+
/**
|
|
13
|
+
* The surface a pack may declare beyond the mandatory three.
|
|
14
|
+
*
|
|
15
|
+
* Only `slack`, and even that stays optional per primitive: the dispatcher
|
|
16
|
+
* converts the mandatory markdown to Block Kit, so a missing Slack renderer
|
|
17
|
+
* degrades rather than disappearing. `snapshot` is not here because no primitive
|
|
18
|
+
* implements it — the surface reuses `react`.
|
|
19
|
+
*/
|
|
20
|
+
export const OPTIONAL_SURFACES = [
|
|
21
|
+
'slack',
|
|
22
|
+
];
|
|
12
23
|
/** Parses `node` against `schema`, appending path-prefixed messages to `errors`. */
|
|
13
24
|
export const validateWithSchema = (schema, node, path, errors) => {
|
|
14
25
|
const result = schema.safeParse(node, { reportInput: true });
|
|
@@ -20,8 +31,8 @@ export const validateWithSchema = (schema, node, path, errors) => {
|
|
|
20
31
|
export const bodyNodeIdSchema = requiredString('must be a non-empty string');
|
|
21
32
|
/** The `surfaces` allowlist on a node. Absent means every surface; empty is rejected. */
|
|
22
33
|
export const bodyNodeSurfacesSchema = z
|
|
23
|
-
.array(z.enum(
|
|
24
|
-
error: () => oneOf(
|
|
34
|
+
.array(z.enum(SURFACE_NAMES, {
|
|
35
|
+
error: () => oneOf(SURFACE_NAMES),
|
|
25
36
|
}))
|
|
26
37
|
.min(1, { error: 'must contain at least one surface' });
|
|
27
38
|
/**
|
|
@@ -47,10 +58,14 @@ export const unresolvedBodyNodeSchema = z.looseObject({
|
|
|
47
58
|
* {@link PackTypes}, so each primitive names only `TNode`.
|
|
48
59
|
*/
|
|
49
60
|
export const definePrimitive = (definition) => {
|
|
50
|
-
const { schemaFor } = definition;
|
|
61
|
+
const { schemaFor, schema, catalog } = definition;
|
|
62
|
+
const described = catalog.description === undefined ? schema.description : undefined;
|
|
51
63
|
return {
|
|
52
64
|
...definition,
|
|
53
|
-
|
|
65
|
+
...(described === undefined
|
|
66
|
+
? {}
|
|
67
|
+
: { catalog: { ...catalog, description: described } }),
|
|
68
|
+
schema: withNodeFields(schema),
|
|
54
69
|
// Both forms get the node fields, or a container would accept `id` and
|
|
55
70
|
// `surfaces` standalone and reject them inside a composition.
|
|
56
71
|
...(schemaFor
|
|
@@ -81,11 +96,13 @@ const NODE_FIELDS = {
|
|
|
81
96
|
const isNodeField = (schema) => {
|
|
82
97
|
let current = schema;
|
|
83
98
|
while (current && typeof current === 'object') {
|
|
84
|
-
if (Object.hasOwn(current, NODE_FIELD))
|
|
99
|
+
if (Object.hasOwn(current, NODE_FIELD)) {
|
|
85
100
|
return true;
|
|
101
|
+
}
|
|
86
102
|
const { def } = current;
|
|
87
|
-
if (def?.type !== 'optional')
|
|
103
|
+
if (def?.type !== 'optional') {
|
|
88
104
|
return false;
|
|
105
|
+
}
|
|
89
106
|
current = def.innerType;
|
|
90
107
|
}
|
|
91
108
|
return false;
|