@elastic/isomer-sdk 0.0.0 → 0.2.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/LICENSE.txt +93 -0
- package/NOTICE.txt +1861 -0
- package/README.md +69 -0
- package/THIRD_PARTY_LICENSES.md +957 -0
- package/dist/author/authored_fields.d.ts +153 -0
- package/dist/author/authored_fields.d.ts.map +1 -0
- package/dist/author/authored_fields.js +227 -0
- package/dist/author/authored_fields.js.map +1 -0
- 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 +60 -0
- package/dist/author/authoring_input.js.map +1 -0
- package/dist/author/authoring_model.d.ts +27 -0
- package/dist/author/authoring_model.d.ts.map +1 -0
- package/dist/author/authoring_model.js +98 -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 +277 -0
- package/dist/author/declarations.js.map +1 -0
- package/dist/author/index.d.ts +7 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +12 -0
- package/dist/author/index.js.map +1 -0
- package/dist/author/jsx.d.ts +21 -0
- package/dist/author/jsx.d.ts.map +1 -0
- package/dist/author/jsx.js +20 -0
- package/dist/author/jsx.js.map +1 -0
- package/dist/author/jsx_shim.d.ts +117 -0
- package/dist/author/jsx_shim.d.ts.map +1 -0
- package/dist/author/jsx_shim.js +270 -0
- package/dist/author/jsx_shim.js.map +1 -0
- package/dist/author/prompt.d.ts +58 -0
- package/dist/author/prompt.d.ts.map +1 -0
- package/dist/author/prompt.js +148 -0
- package/dist/author/prompt.js.map +1 -0
- 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 +286 -0
- package/dist/author/schema_to_typescript.js.map +1 -0
- package/dist/cjs/author/authored_fields.js +233 -0
- package/dist/cjs/author/authored_fields.js.map +1 -0
- package/dist/cjs/author/authoring_input.js +64 -0
- package/dist/cjs/author/authoring_input.js.map +1 -0
- package/dist/cjs/author/authoring_model.js +104 -0
- package/dist/cjs/author/authoring_model.js.map +1 -0
- package/dist/cjs/author/declarations.js +281 -0
- package/dist/cjs/author/declarations.js.map +1 -0
- package/dist/cjs/author/index.js +25 -0
- package/dist/cjs/author/index.js.map +1 -0
- package/dist/cjs/author/jsx.js +24 -0
- package/dist/cjs/author/jsx.js.map +1 -0
- package/dist/cjs/author/jsx_shim.js +276 -0
- package/dist/cjs/author/jsx_shim.js.map +1 -0
- package/dist/cjs/author/prompt.js +153 -0
- package/dist/cjs/author/prompt.js.map +1 -0
- package/dist/cjs/author/schema_to_typescript.js +295 -0
- package/dist/cjs/author/schema_to_typescript.js.map +1 -0
- package/dist/cjs/composition/action_event.js +9 -0
- package/dist/cjs/composition/action_event.js.map +1 -0
- package/dist/cjs/composition/body_node_base.js +112 -0
- package/dist/cjs/composition/body_node_base.js.map +1 -0
- package/dist/cjs/composition/composition.js +9 -0
- package/dist/cjs/composition/composition.js.map +1 -0
- package/dist/cjs/composition/error.js +73 -0
- package/dist/cjs/composition/error.js.map +1 -0
- package/dist/cjs/composition/index.js +32 -0
- package/dist/cjs/composition/index.js.map +1 -0
- package/dist/cjs/composition/map_nodes.js +85 -0
- package/dist/cjs/composition/map_nodes.js.map +1 -0
- package/dist/cjs/composition/named_color.js +20 -0
- package/dist/cjs/composition/named_color.js.map +1 -0
- package/dist/cjs/composition/node.js +9 -0
- package/dist/cjs/composition/node.js.map +1 -0
- package/dist/cjs/composition/one_line.js +23 -0
- package/dist/cjs/composition/one_line.js.map +1 -0
- package/dist/cjs/composition/structured_value.js +21 -0
- package/dist/cjs/composition/structured_value.js.map +1 -0
- package/dist/cjs/composition/validation_error.js +40 -0
- package/dist/cjs/composition/validation_error.js.map +1 -0
- package/dist/cjs/define/frame.js +31 -0
- package/dist/cjs/define/frame.js.map +1 -0
- package/dist/cjs/define/index.js +31 -0
- package/dist/cjs/define/index.js.map +1 -0
- package/dist/cjs/define/markdown_content.js +12 -0
- package/dist/cjs/define/markdown_content.js.map +1 -0
- 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 +118 -0
- package/dist/cjs/define/primitive_module.js.map +1 -0
- package/dist/cjs/define/slack_assets.js +9 -0
- package/dist/cjs/define/slack_assets.js.map +1 -0
- package/dist/cjs/define/slack_blocks.js +9 -0
- package/dist/cjs/define/slack_blocks.js.map +1 -0
- package/dist/cjs/define/zod_format.js +122 -0
- package/dist/cjs/define/zod_format.js.map +1 -0
- package/dist/cjs/define/zod_helpers.js +26 -0
- package/dist/cjs/define/zod_helpers.js.map +1 -0
- package/dist/cjs/entries/html.js +12 -0
- package/dist/cjs/entries/html.js.map +1 -0
- package/dist/cjs/entries/index.js +80 -0
- package/dist/cjs/entries/index.js.map +1 -0
- package/dist/cjs/entries/markdown.js +14 -0
- package/dist/cjs/entries/markdown.js.map +1 -0
- package/dist/cjs/entries/react.js +20 -0
- package/dist/cjs/entries/react.js.map +1 -0
- package/dist/cjs/entries/slack.js +25 -0
- package/dist/cjs/entries/slack.js.map +1 -0
- package/dist/cjs/entries/text.js +12 -0
- package/dist/cjs/entries/text.js.map +1 -0
- package/dist/cjs/pack/capabilities.js +40 -0
- package/dist/cjs/pack/capabilities.js.map +1 -0
- package/dist/cjs/pack/compose.js +59 -0
- package/dist/cjs/pack/compose.js.map +1 -0
- package/dist/cjs/pack/enhancements.js +65 -0
- package/dist/cjs/pack/enhancements.js.map +1 -0
- package/dist/cjs/pack/index.js +18 -0
- package/dist/cjs/pack/index.js.map +1 -0
- package/dist/cjs/pack/primitive_pack.js +97 -0
- package/dist/cjs/pack/primitive_pack.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/render/anchors.js +167 -0
- package/dist/cjs/render/anchors.js.map +1 -0
- package/dist/cjs/render/context_view.js +54 -0
- package/dist/cjs/render/context_view.js.map +1 -0
- package/dist/cjs/render/format_display_value.js +143 -0
- package/dist/cjs/render/format_display_value.js.map +1 -0
- package/dist/cjs/render/format_number.js +46 -0
- package/dist/cjs/render/format_number.js.map +1 -0
- package/dist/cjs/render/html/enhancements.js +30 -0
- package/dist/cjs/render/html/enhancements.js.map +1 -0
- package/dist/cjs/render/html/envelope.js +218 -0
- package/dist/cjs/render/html/envelope.js.map +1 -0
- package/dist/cjs/render/html/index.js +12 -0
- package/dist/cjs/render/html/index.js.map +1 -0
- package/dist/cjs/render/index.js +25 -0
- package/dist/cjs/render/index.js.map +1 -0
- package/dist/cjs/render/layout_check.js +133 -0
- package/dist/cjs/render/layout_check.js.map +1 -0
- package/dist/cjs/render/markdown/builder.js +195 -0
- package/dist/cjs/render/markdown/builder.js.map +1 -0
- package/dist/cjs/render/markdown/envelope.js +33 -0
- package/dist/cjs/render/markdown/envelope.js.map +1 -0
- package/dist/cjs/render/markdown/format.js +208 -0
- package/dist/cjs/render/markdown/format.js.map +1 -0
- package/dist/cjs/render/markdown/index.js +15 -0
- package/dist/cjs/render/markdown/index.js.map +1 -0
- package/dist/cjs/render/measure_dom.js +61 -0
- package/dist/cjs/render/measure_dom.js.map +1 -0
- package/dist/cjs/render/payload.js +13 -0
- package/dist/cjs/render/payload.js.map +1 -0
- package/dist/cjs/render/primitive_dispatch.js +173 -0
- package/dist/cjs/render/primitive_dispatch.js.map +1 -0
- package/dist/cjs/render/react/content.js +44 -0
- package/dist/cjs/render/react/content.js.map +1 -0
- package/dist/cjs/render/react/enhancements.js +32 -0
- package/dist/cjs/render/react/enhancements.js.map +1 -0
- package/dist/cjs/render/react/index.js +15 -0
- package/dist/cjs/render/react/index.js.map +1 -0
- package/dist/cjs/render/slack/assets.js +45 -0
- package/dist/cjs/render/slack/assets.js.map +1 -0
- package/dist/cjs/render/slack/blocks.js +80 -0
- package/dist/cjs/render/slack/blocks.js.map +1 -0
- package/dist/cjs/render/slack/envelope.js +551 -0
- package/dist/cjs/render/slack/envelope.js.map +1 -0
- package/dist/cjs/render/slack/format.js +225 -0
- package/dist/cjs/render/slack/format.js.map +1 -0
- package/dist/cjs/render/slack/index.js +30 -0
- package/dist/cjs/render/slack/index.js.map +1 -0
- package/dist/cjs/render/slack/markdown_content.js +409 -0
- package/dist/cjs/render/slack/markdown_content.js.map +1 -0
- package/dist/cjs/render/text/envelope.js +21 -0
- package/dist/cjs/render/text/envelope.js.map +1 -0
- package/dist/cjs/render/text/index.js +12 -0
- package/dist/cjs/render/text/index.js.map +1 -0
- package/dist/cjs/testing/conformance.js +312 -0
- package/dist/cjs/testing/conformance.js.map +1 -0
- package/dist/cjs/testing/icon.js +248 -0
- package/dist/cjs/testing/icon.js.map +1 -0
- package/dist/cjs/testing/index.js +18 -0
- package/dist/cjs/testing/index.js.map +1 -0
- package/dist/cjs/testing/registration.js +142 -0
- package/dist/cjs/testing/registration.js.map +1 -0
- package/dist/cjs/validate/authoring_schema.js +312 -0
- package/dist/cjs/validate/authoring_schema.js.map +1 -0
- package/dist/cjs/validate/composition_schema.js +135 -0
- package/dist/cjs/validate/composition_schema.js.map +1 -0
- package/dist/cjs/validate/index.js +53 -0
- package/dist/cjs/validate/index.js.map +1 -0
- package/dist/cjs/validate/input_budget.js +156 -0
- package/dist/cjs/validate/input_budget.js.map +1 -0
- package/dist/cjs/validate/json_schema.js +72 -0
- package/dist/cjs/validate/json_schema.js.map +1 -0
- package/dist/cjs/validate/node_issues.js +65 -0
- package/dist/cjs/validate/node_issues.js.map +1 -0
- package/dist/cjs/validate/url.js +116 -0
- package/dist/cjs/validate/url.js.map +1 -0
- package/dist/cjs/validate/validation.js +165 -0
- package/dist/cjs/validate/validation.js.map +1 -0
- package/dist/cjs/validate/value_schemas.js +53 -0
- package/dist/cjs/validate/value_schemas.js.map +1 -0
- package/dist/composition/action_event.d.ts +13 -0
- package/dist/composition/action_event.d.ts.map +1 -0
- package/dist/composition/action_event.js +8 -0
- package/dist/composition/action_event.js.map +1 -0
- package/dist/composition/body_node_base.d.ts +72 -0
- package/dist/composition/body_node_base.d.ts.map +1 -0
- package/dist/composition/body_node_base.js +104 -0
- package/dist/composition/body_node_base.js.map +1 -0
- package/dist/composition/composition.d.ts +71 -0
- package/dist/composition/composition.d.ts.map +1 -0
- package/dist/composition/composition.js +8 -0
- package/dist/composition/composition.js.map +1 -0
- package/dist/composition/error.d.ts +61 -0
- package/dist/composition/error.d.ts.map +1 -0
- package/dist/composition/error.js +69 -0
- package/dist/composition/error.js.map +1 -0
- package/dist/composition/index.d.ts +11 -0
- package/dist/composition/index.d.ts.map +1 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/index.js.map +1 -0
- package/dist/composition/map_nodes.d.ts +16 -0
- package/dist/composition/map_nodes.d.ts.map +1 -0
- package/dist/composition/map_nodes.js +81 -0
- package/dist/composition/map_nodes.js.map +1 -0
- package/dist/composition/named_color.d.ts +9 -0
- package/dist/composition/named_color.d.ts.map +1 -0
- package/dist/composition/named_color.js +17 -0
- package/dist/composition/named_color.js.map +1 -0
- package/dist/composition/node.d.ts +11 -0
- package/dist/composition/node.d.ts.map +1 -0
- package/dist/composition/node.js +8 -0
- package/dist/composition/node.js.map +1 -0
- package/dist/composition/one_line.d.ts +7 -0
- package/dist/composition/one_line.d.ts.map +1 -0
- package/dist/composition/one_line.js +17 -0
- package/dist/composition/one_line.js.map +1 -0
- package/dist/composition/structured_value.d.ts +27 -0
- package/dist/composition/structured_value.d.ts.map +1 -0
- package/dist/composition/structured_value.js +18 -0
- package/dist/composition/structured_value.js.map +1 -0
- package/dist/composition/validation_error.d.ts +33 -0
- package/dist/composition/validation_error.d.ts.map +1 -0
- package/dist/composition/validation_error.js +35 -0
- package/dist/composition/validation_error.js.map +1 -0
- package/dist/define/frame.d.ts +155 -0
- package/dist/define/frame.d.ts.map +1 -0
- package/dist/define/frame.js +27 -0
- package/dist/define/frame.js.map +1 -0
- package/dist/define/index.d.ts +10 -0
- package/dist/define/index.d.ts.map +1 -0
- package/dist/define/index.js +13 -0
- package/dist/define/index.js.map +1 -0
- package/dist/define/markdown_content.d.ts +15 -0
- package/dist/define/markdown_content.d.ts.map +1 -0
- package/dist/define/markdown_content.js +9 -0
- package/dist/define/markdown_content.js.map +1 -0
- 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 +435 -0
- package/dist/define/primitive_module.d.ts.map +1 -0
- package/dist/define/primitive_module.js +112 -0
- package/dist/define/primitive_module.js.map +1 -0
- package/dist/define/slack_assets.d.ts +28 -0
- package/dist/define/slack_assets.d.ts.map +1 -0
- package/dist/define/slack_assets.js +8 -0
- package/dist/define/slack_assets.js.map +1 -0
- package/dist/define/slack_blocks.d.ts +234 -0
- package/dist/define/slack_blocks.d.ts.map +1 -0
- package/dist/define/slack_blocks.js +8 -0
- package/dist/define/slack_blocks.js.map +1 -0
- package/dist/define/zod_format.d.ts +33 -0
- package/dist/define/zod_format.d.ts.map +1 -0
- package/dist/define/zod_format.js +114 -0
- package/dist/define/zod_format.js.map +1 -0
- package/dist/define/zod_helpers.d.ts +10 -0
- package/dist/define/zod_helpers.d.ts.map +1 -0
- package/dist/define/zod_helpers.js +22 -0
- package/dist/define/zod_helpers.js.map +1 -0
- package/dist/entries/html.d.ts +3 -0
- package/dist/entries/html.d.ts.map +1 -0
- package/dist/entries/html.js +8 -0
- package/dist/entries/html.js.map +1 -0
- package/dist/entries/index.d.ts +6 -0
- package/dist/entries/index.d.ts.map +1 -0
- package/dist/entries/index.js +12 -0
- package/dist/entries/index.js.map +1 -0
- package/dist/entries/markdown.d.ts +3 -0
- package/dist/entries/markdown.d.ts.map +1 -0
- package/dist/entries/markdown.js +8 -0
- package/dist/entries/markdown.js.map +1 -0
- package/dist/entries/react.d.ts +5 -0
- package/dist/entries/react.d.ts.map +1 -0
- package/dist/entries/react.js +11 -0
- package/dist/entries/react.js.map +1 -0
- package/dist/entries/slack.d.ts +2 -0
- package/dist/entries/slack.d.ts.map +1 -0
- package/dist/entries/slack.js +8 -0
- package/dist/entries/slack.js.map +1 -0
- package/dist/entries/text.d.ts +2 -0
- package/dist/entries/text.d.ts.map +1 -0
- package/dist/entries/text.js +8 -0
- package/dist/entries/text.js.map +1 -0
- package/dist/pack/capabilities.d.ts +41 -0
- package/dist/pack/capabilities.d.ts.map +1 -0
- package/dist/pack/capabilities.js +36 -0
- package/dist/pack/capabilities.js.map +1 -0
- package/dist/pack/compose.d.ts +24 -0
- package/dist/pack/compose.d.ts.map +1 -0
- package/dist/pack/compose.js +55 -0
- package/dist/pack/compose.js.map +1 -0
- package/dist/pack/enhancements.d.ts +65 -0
- package/dist/pack/enhancements.d.ts.map +1 -0
- package/dist/pack/enhancements.js +59 -0
- package/dist/pack/enhancements.js.map +1 -0
- package/dist/pack/index.d.ts +5 -0
- package/dist/pack/index.d.ts.map +1 -0
- package/dist/pack/index.js +11 -0
- package/dist/pack/index.js.map +1 -0
- package/dist/pack/primitive_pack.d.ts +164 -0
- package/dist/pack/primitive_pack.d.ts.map +1 -0
- package/dist/pack/primitive_pack.js +92 -0
- package/dist/pack/primitive_pack.js.map +1 -0
- package/dist/render/anchors.d.ts +82 -0
- package/dist/render/anchors.d.ts.map +1 -0
- package/dist/render/anchors.js +153 -0
- package/dist/render/anchors.js.map +1 -0
- package/dist/render/context_view.d.ts +10 -0
- package/dist/render/context_view.d.ts.map +1 -0
- package/dist/render/context_view.js +49 -0
- package/dist/render/context_view.js.map +1 -0
- package/dist/render/format_display_value.d.ts +20 -0
- package/dist/render/format_display_value.d.ts.map +1 -0
- package/dist/render/format_display_value.js +137 -0
- package/dist/render/format_display_value.js.map +1 -0
- package/dist/render/format_number.d.ts +9 -0
- package/dist/render/format_number.d.ts.map +1 -0
- package/dist/render/format_number.js +42 -0
- package/dist/render/format_number.js.map +1 -0
- package/dist/render/html/enhancements.d.ts +10 -0
- package/dist/render/html/enhancements.d.ts.map +1 -0
- package/dist/render/html/enhancements.js +25 -0
- package/dist/render/html/enhancements.js.map +1 -0
- package/dist/render/html/envelope.d.ts +182 -0
- package/dist/render/html/envelope.d.ts.map +1 -0
- package/dist/render/html/envelope.js +214 -0
- package/dist/render/html/envelope.js.map +1 -0
- package/dist/render/html/index.d.ts +3 -0
- package/dist/render/html/index.d.ts.map +1 -0
- package/dist/render/html/index.js +8 -0
- package/dist/render/html/index.js.map +1 -0
- package/dist/render/index.d.ts +6 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +11 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/layout_check.d.ts +43 -0
- package/dist/render/layout_check.d.ts.map +1 -0
- package/dist/render/layout_check.js +129 -0
- package/dist/render/layout_check.js.map +1 -0
- package/dist/render/markdown/builder.d.ts +46 -0
- package/dist/render/markdown/builder.d.ts.map +1 -0
- package/dist/render/markdown/builder.js +190 -0
- package/dist/render/markdown/builder.js.map +1 -0
- package/dist/render/markdown/envelope.d.ts +20 -0
- package/dist/render/markdown/envelope.d.ts.map +1 -0
- package/dist/render/markdown/envelope.js +29 -0
- package/dist/render/markdown/envelope.js.map +1 -0
- package/dist/render/markdown/format.d.ts +10 -0
- package/dist/render/markdown/format.d.ts.map +1 -0
- package/dist/render/markdown/format.js +202 -0
- package/dist/render/markdown/format.js.map +1 -0
- package/dist/render/markdown/index.d.ts +3 -0
- package/dist/render/markdown/index.d.ts.map +1 -0
- package/dist/render/markdown/index.js +9 -0
- package/dist/render/markdown/index.js.map +1 -0
- package/dist/render/measure_dom.d.ts +10 -0
- package/dist/render/measure_dom.d.ts.map +1 -0
- package/dist/render/measure_dom.js +57 -0
- package/dist/render/measure_dom.js.map +1 -0
- package/dist/render/payload.d.ts +16 -0
- package/dist/render/payload.d.ts.map +1 -0
- package/dist/render/payload.js +9 -0
- package/dist/render/payload.js.map +1 -0
- package/dist/render/primitive_dispatch.d.ts +72 -0
- package/dist/render/primitive_dispatch.d.ts.map +1 -0
- package/dist/render/primitive_dispatch.js +169 -0
- package/dist/render/primitive_dispatch.js.map +1 -0
- package/dist/render/react/content.d.ts +40 -0
- package/dist/render/react/content.d.ts.map +1 -0
- package/dist/render/react/content.js +39 -0
- package/dist/render/react/content.js.map +1 -0
- package/dist/render/react/enhancements.d.ts +15 -0
- package/dist/render/react/enhancements.d.ts.map +1 -0
- package/dist/render/react/enhancements.js +28 -0
- package/dist/render/react/enhancements.js.map +1 -0
- package/dist/render/react/index.d.ts +3 -0
- package/dist/render/react/index.d.ts.map +1 -0
- package/dist/render/react/index.js +9 -0
- package/dist/render/react/index.js.map +1 -0
- package/dist/render/slack/assets.d.ts +16 -0
- package/dist/render/slack/assets.d.ts.map +1 -0
- package/dist/render/slack/assets.js +40 -0
- package/dist/render/slack/assets.js.map +1 -0
- package/dist/render/slack/blocks.d.ts +72 -0
- package/dist/render/slack/blocks.d.ts.map +1 -0
- package/dist/render/slack/blocks.js +77 -0
- package/dist/render/slack/blocks.js.map +1 -0
- package/dist/render/slack/envelope.d.ts +52 -0
- package/dist/render/slack/envelope.d.ts.map +1 -0
- package/dist/render/slack/envelope.js +547 -0
- package/dist/render/slack/envelope.js.map +1 -0
- package/dist/render/slack/format.d.ts +70 -0
- package/dist/render/slack/format.d.ts.map +1 -0
- package/dist/render/slack/format.js +209 -0
- package/dist/render/slack/format.js.map +1 -0
- package/dist/render/slack/index.d.ts +6 -0
- package/dist/render/slack/index.d.ts.map +1 -0
- package/dist/render/slack/index.js +12 -0
- package/dist/render/slack/index.js.map +1 -0
- package/dist/render/slack/markdown_content.d.ts +17 -0
- package/dist/render/slack/markdown_content.d.ts.map +1 -0
- package/dist/render/slack/markdown_content.js +404 -0
- package/dist/render/slack/markdown_content.js.map +1 -0
- package/dist/render/text/envelope.d.ts +15 -0
- package/dist/render/text/envelope.d.ts.map +1 -0
- package/dist/render/text/envelope.js +17 -0
- package/dist/render/text/envelope.js.map +1 -0
- package/dist/render/text/index.d.ts +2 -0
- package/dist/render/text/index.d.ts.map +1 -0
- package/dist/render/text/index.js +8 -0
- package/dist/render/text/index.js.map +1 -0
- package/dist/testing/conformance.d.ts +145 -0
- package/dist/testing/conformance.d.ts.map +1 -0
- package/dist/testing/conformance.js +303 -0
- package/dist/testing/conformance.js.map +1 -0
- 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 +4 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +10 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/registration.d.ts +32 -0
- package/dist/testing/registration.d.ts.map +1 -0
- package/dist/testing/registration.js +105 -0
- package/dist/testing/registration.js.map +1 -0
- package/dist/validate/authoring_schema.d.ts +33 -0
- package/dist/validate/authoring_schema.d.ts.map +1 -0
- package/dist/validate/authoring_schema.js +306 -0
- package/dist/validate/authoring_schema.js.map +1 -0
- package/dist/validate/composition_schema.d.ts +80 -0
- package/dist/validate/composition_schema.d.ts.map +1 -0
- package/dist/validate/composition_schema.js +127 -0
- package/dist/validate/composition_schema.js.map +1 -0
- package/dist/validate/index.d.ts +9 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +15 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/input_budget.d.ts +35 -0
- package/dist/validate/input_budget.d.ts.map +1 -0
- package/dist/validate/input_budget.js +151 -0
- package/dist/validate/input_budget.js.map +1 -0
- package/dist/validate/json_schema.d.ts +32 -0
- package/dist/validate/json_schema.d.ts.map +1 -0
- package/dist/validate/json_schema.js +68 -0
- package/dist/validate/json_schema.js.map +1 -0
- package/dist/validate/node_issues.d.ts +12 -0
- package/dist/validate/node_issues.d.ts.map +1 -0
- package/dist/validate/node_issues.js +61 -0
- package/dist/validate/node_issues.js.map +1 -0
- package/dist/validate/url.d.ts +50 -0
- package/dist/validate/url.d.ts.map +1 -0
- package/dist/validate/url.js +107 -0
- package/dist/validate/url.js.map +1 -0
- package/dist/validate/validation.d.ts +95 -0
- package/dist/validate/validation.d.ts.map +1 -0
- package/dist/validate/validation.js +157 -0
- package/dist/validate/validation.js.map +1 -0
- package/dist/validate/value_schemas.d.ts +53 -0
- package/dist/validate/value_schemas.d.ts.map +1 -0
- package/dist/validate/value_schemas.js +50 -0
- package/dist/validate/value_schemas.js.map +1 -0
- package/package.json +119 -5
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.composePacks = void 0;
|
|
10
|
+
const error_1 = require("../composition/error");
|
|
11
|
+
const primitive_pack_1 = require("./primitive_pack");
|
|
12
|
+
/**
|
|
13
|
+
* Flattens `packs` into one inventory, rejecting cross-pack duplicate node
|
|
14
|
+
* types and duplicate enhancement ids. Every offender is named in one error,
|
|
15
|
+
* so a bad three-pack composition reports all three at once.
|
|
16
|
+
*/
|
|
17
|
+
const composePacks = (packs) => {
|
|
18
|
+
const typeOwners = new Map();
|
|
19
|
+
const enhancementOwners = new Map();
|
|
20
|
+
for (const pack of packs) {
|
|
21
|
+
for (const { type } of pack.primitives) {
|
|
22
|
+
typeOwners.set(type, [...(typeOwners.get(type) ?? []), pack.id]);
|
|
23
|
+
}
|
|
24
|
+
for (const { id } of pack.enhancements) {
|
|
25
|
+
enhancementOwners.set(id, [
|
|
26
|
+
...(enhancementOwners.get(id) ?? []),
|
|
27
|
+
pack.id,
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const repeated = [
|
|
32
|
+
...new Set(packs
|
|
33
|
+
.map(({ id }) => id)
|
|
34
|
+
.filter((id, index, ids) => ids.indexOf(id) !== index)),
|
|
35
|
+
];
|
|
36
|
+
if (repeated.length > 0) {
|
|
37
|
+
throw new error_1.IsomerError('DUPLICATE_PACK_ID', `composePacks: ${repeated.map((id) => `"${id}"`).join(', ')} names more than one pack; pack ids must be unique`);
|
|
38
|
+
}
|
|
39
|
+
assertUnique('DUPLICATE_PRIMITIVE_TYPE', 'primitive type', typeOwners);
|
|
40
|
+
assertUnique('DUPLICATE_ENHANCEMENT', 'enhancement', enhancementOwners);
|
|
41
|
+
const definitions = packs.flatMap((pack) => [...pack.primitives]);
|
|
42
|
+
return Object.freeze({
|
|
43
|
+
definitions: Object.freeze(definitions),
|
|
44
|
+
enhancements: Object.freeze(packs.flatMap((pack) => [...pack.enhancements])),
|
|
45
|
+
icons: (0, primitive_pack_1.iconsByType)(definitions),
|
|
46
|
+
slackAssetTypes: new Set(packs.flatMap((pack) => [...pack.slackAssetTypes])),
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
exports.composePacks = composePacks;
|
|
50
|
+
const assertUnique = (code, noun, owners) => {
|
|
51
|
+
const duplicates = [...owners].filter(([, packs]) => packs.length > 1);
|
|
52
|
+
if (duplicates.length === 0) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
throw new error_1.IsomerError(code, duplicates
|
|
56
|
+
.map(([key, packs]) => `${noun} "${key}" registered by ${packs.map((id) => `"${id}"`).join(' and ')}`)
|
|
57
|
+
.join('; '));
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=compose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../src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E,EAAE,CACf,GAAG,IAAI,KAAK,GAAG,mBAAmB,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CACjF;SACA,IAAI,CAAC,IAAI,CAAC,CACd,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\nimport { IsomerError } from '../composition/error';\nimport type { PrimitiveIcon } from '../define/primitive_icon';\nimport type { AnyPrimitiveDefinition } from '../define/primitive_module';\n\nimport type { EnhancementDefinition } from './enhancements';\nimport { type AnyPrimitivePack, iconsByType } from './primitive_pack';\n\n/**\n * One flattened inventory owned by {@link composePacks}.\n *\n * `definitions` is a stable array identity, which is what the composition\n * schema cache keys on — pass it through rather than flattening packs per call.\n */\nexport interface ComposedPacks {\n readonly definitions: readonly AnyPrimitiveDefinition[];\n readonly enhancements: readonly EnhancementDefinition[];\n /** Every definition's `icon` by type, in one frozen null-prototype dictionary. */\n readonly icons: Readonly<Record<string, PrimitiveIcon>>;\n readonly slackAssetTypes: ReadonlySet<string>;\n}\n\n/**\n * Flattens `packs` into one inventory, rejecting cross-pack duplicate node\n * types and duplicate enhancement ids. Every offender is named in one error,\n * so a bad three-pack composition reports all three at once.\n */\nexport const composePacks = (\n packs: readonly AnyPrimitivePack[]\n): ComposedPacks => {\n const typeOwners = new Map<string, string[]>();\n const enhancementOwners = new Map<string, string[]>();\n for (const pack of packs) {\n for (const { type } of pack.primitives) {\n typeOwners.set(type, [...(typeOwners.get(type) ?? []), pack.id]);\n }\n for (const { id } of pack.enhancements) {\n enhancementOwners.set(id, [\n ...(enhancementOwners.get(id) ?? []),\n pack.id,\n ]);\n }\n }\n const repeated = [\n ...new Set(\n packs\n .map(({ id }) => id)\n .filter((id, index, ids) => ids.indexOf(id) !== index)\n ),\n ];\n if (repeated.length > 0) {\n throw new IsomerError(\n 'DUPLICATE_PACK_ID',\n `composePacks: ${repeated.map((id) => `\"${id}\"`).join(', ')} names more than one pack; pack ids must be unique`\n );\n }\n assertUnique('DUPLICATE_PRIMITIVE_TYPE', 'primitive type', typeOwners);\n assertUnique('DUPLICATE_ENHANCEMENT', 'enhancement', enhancementOwners);\n\n const definitions = packs.flatMap((pack) => [...pack.primitives]);\n return Object.freeze({\n definitions: Object.freeze(definitions),\n enhancements: Object.freeze(\n packs.flatMap((pack) => [...pack.enhancements])\n ),\n icons: iconsByType(definitions),\n slackAssetTypes: new Set(\n packs.flatMap((pack) => [...pack.slackAssetTypes])\n ),\n });\n};\n\nconst assertUnique = (\n code: 'DUPLICATE_ENHANCEMENT' | 'DUPLICATE_PRIMITIVE_TYPE',\n noun: string,\n owners: ReadonlyMap<string, readonly string[]>\n): void => {\n const duplicates = [...owners].filter(([, packs]) => packs.length > 1);\n if (duplicates.length === 0) {\n return;\n }\n throw new IsomerError(\n code,\n duplicates\n .map(\n ([key, packs]) =>\n `${noun} \"${key}\" registered by ${packs.map((id) => `\"${id}\"`).join(' and ')}`\n )\n .join('; ')\n );\n};\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.runEnhancementScript = exports.EMBEDDED_SCRIPT_ATTRIBUTE = exports.scopeScript = exports.resolveEnhancements = void 0;
|
|
10
|
+
const error_1 = require("../composition/error");
|
|
11
|
+
/**
|
|
12
|
+
* The `definitions` that apply to `body`, the first of each id, limited to
|
|
13
|
+
* `requested` ids when given. The HTML and React surfaces both resolve through
|
|
14
|
+
* it, so the two cannot disagree on which enhancements a render carries.
|
|
15
|
+
*/
|
|
16
|
+
const resolveEnhancements = (body, walk, definitions, requested) => {
|
|
17
|
+
const wanted = requested && new Set(requested);
|
|
18
|
+
const ids = new Set();
|
|
19
|
+
return definitions.filter((definition) => {
|
|
20
|
+
if (ids.has(definition.id) ||
|
|
21
|
+
(wanted && !wanted.has(definition.id)) ||
|
|
22
|
+
!definition.appliesTo(body, walk)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
ids.add(definition.id);
|
|
26
|
+
return true;
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
exports.resolveEnhancements = resolveEnhancements;
|
|
30
|
+
/**
|
|
31
|
+
* Wraps one script body in its own function, so its `const`s and a top-level
|
|
32
|
+
* `return` stay its own. Anything that joins script bodies scopes each first.
|
|
33
|
+
*/
|
|
34
|
+
const scopeScript = (body) => `(() => {\n${body}\n})();`;
|
|
35
|
+
exports.scopeScript = scopeScript;
|
|
36
|
+
/** Marks the `<script>` a `scripts: 'embedded'` render emits. */
|
|
37
|
+
exports.EMBEDDED_SCRIPT_ATTRIBUTE = 'data-isomer-script';
|
|
38
|
+
/**
|
|
39
|
+
* Runs a `scripts: 'host'` render's `js` against the
|
|
40
|
+
* `.isomer` section the host inserted.
|
|
41
|
+
*
|
|
42
|
+
* Needed wherever the HTML is inserted by the host rather than parsed with the
|
|
43
|
+
* page, including every shadow root: such a `<script>` never runs, and one
|
|
44
|
+
* that did would find no `document.currentScript`.
|
|
45
|
+
*
|
|
46
|
+
* Compiles with `new Function`, so a strict Content-Security-Policy must allow
|
|
47
|
+
* `'unsafe-eval'`. A host that cannot should render with `scripts: 'embedded'`
|
|
48
|
+
* into light DOM.
|
|
49
|
+
*/
|
|
50
|
+
const runEnhancementScript = (js, root) => {
|
|
51
|
+
// Guards untyped callers; typed ones already handled `querySelector`'s null.
|
|
52
|
+
if (!root) {
|
|
53
|
+
throw new error_1.IsomerError('ENHANCEMENT_ROOT_MISSING', 'runEnhancementScript: no root element; pass the `.isomer` section the render produced');
|
|
54
|
+
}
|
|
55
|
+
if (root.querySelector(`script[${exports.EMBEDDED_SCRIPT_ATTRIBUTE}]`)) {
|
|
56
|
+
console.warn("isomer: this HTML was rendered with scripts: 'embedded'; render with scripts: 'host' so its enhancements run once");
|
|
57
|
+
}
|
|
58
|
+
if (js) {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval -- compiling the render's script is the point.
|
|
60
|
+
const run = new Function('root', js);
|
|
61
|
+
run(root);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.runEnhancementScript = runEnhancementScript;
|
|
65
|
+
//# sourceMappingURL=enhancements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhancements.js","sourceRoot":"","sources":["../../../src/pack/enhancements.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,gDAAmD;AAwCnD;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,CACjC,IAA8B,EAC9B,IAAqB,EACrB,WAA6C,EAC7C,SAA6B,EACJ,EAAE;IAC3B,MAAM,MAAM,GAAG,SAAS,IAAI,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;QACvC,IACE,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACtB,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACtC,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EACjC,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAnBW,QAAA,mBAAmB,uBAmB9B;AAEF;;;GAGG;AACI,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,aAAa,IAAI,SAAS,CAAC;AAAnE,QAAA,WAAW,eAAwD;AAEhF,iEAAiE;AACpD,QAAA,yBAAyB,GAAG,oBAAoB,CAAC;AAE9D;;;;;;;;;;;GAWG;AACI,MAAM,oBAAoB,GAAG,CAAC,EAAU,EAAE,IAAa,EAAQ,EAAE;IACtE,6EAA6E;IAC7E,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,mBAAW,CACnB,0BAA0B,EAC1B,uFAAuF,CACxF,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,aAAa,CAAC,UAAU,iCAAyB,GAAG,CAAC,EAAE,CAAC;QAC/D,OAAO,CAAC,IAAI,CACV,mHAAmH,CACpH,CAAC;IACJ,CAAC;IACD,IAAI,EAAE,EAAE,CAAC;QACP,6GAA6G;QAC7G,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,CAA4B,CAAC;QAChE,GAAG,CAAC,IAAI,CAAC,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;AAlBW,QAAA,oBAAoB,wBAkB/B","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 { ChildNodeWalker } from '../composition/body_node_base';\nimport { IsomerError } from '../composition/error';\nimport type { PrimitiveNode } from '../composition/node';\n\n/**\n * A progressive enhancement any vocabulary pack may declare.\n *\n * Ids are open strings rather than a closed union so a second pack can\n * register one without editing a shared type. Duplicate ids across packs in\n * one runtime are rejected at construction.\n */\nexport interface EnhancementDefinition {\n /** What a renderer tests for via `context.enhancements`. Unique across a runtime's packs. */\n id: string;\n /**\n * Whether this composition has anything for the enhancement to act on.\n * Gating on content rather than the opt-in alone is what keeps a composition\n * with no matching node from shipping the script.\n *\n * `walk` is the composition's child walker, so a match nested inside a\n * container from another pack is still found.\n */\n appliesTo: (body: readonly PrimitiveNode[], walk: ChildNodeWalker) => boolean;\n /**\n * A function body with `root: Element`, the render's `.isomer` section, in\n * scope. It runs in its own function, so a top-level `const` or `return`\n * cannot reach another enhancement. Absent when the host drives the\n * enhancement itself.\n *\n * It must not look for its root through `document.currentScript`, which is\n * `null` inside a shadow root. It must address markup through `data-*`\n * attributes rather than class names: class names are minified per render,\n * and a selector written against one is a contract nothing checks. An event\n * meant for the host sets `composed: true` as well as `bubbles: true`, or it\n * stops at a shadow boundary.\n */\n script?: string;\n /** Renders node anchors when resolved, for an enhancement that finds nodes with `findNodeElementPairs`. */\n anchors?: true;\n}\n\n/**\n * The `definitions` that apply to `body`, the first of each id, limited to\n * `requested` ids when given. The HTML and React surfaces both resolve through\n * it, so the two cannot disagree on which enhancements a render carries.\n */\nexport const resolveEnhancements = (\n body: readonly PrimitiveNode[],\n walk: ChildNodeWalker,\n definitions: readonly EnhancementDefinition[],\n requested?: readonly string[]\n): EnhancementDefinition[] => {\n const wanted = requested && new Set(requested);\n const ids = new Set<string>();\n return definitions.filter((definition) => {\n if (\n ids.has(definition.id) ||\n (wanted && !wanted.has(definition.id)) ||\n !definition.appliesTo(body, walk)\n ) {\n return false;\n }\n ids.add(definition.id);\n return true;\n });\n};\n\n/**\n * Wraps one script body in its own function, so its `const`s and a top-level\n * `return` stay its own. Anything that joins script bodies scopes each first.\n */\nexport const scopeScript = (body: string): string => `(() => {\\n${body}\\n})();`;\n\n/** Marks the `<script>` a `scripts: 'embedded'` render emits. */\nexport const EMBEDDED_SCRIPT_ATTRIBUTE = 'data-isomer-script';\n\n/**\n * Runs a `scripts: 'host'` render's `js` against the\n * `.isomer` section the host inserted.\n *\n * Needed wherever the HTML is inserted by the host rather than parsed with the\n * page, including every shadow root: such a `<script>` never runs, and one\n * that did would find no `document.currentScript`.\n *\n * Compiles with `new Function`, so a strict Content-Security-Policy must allow\n * `'unsafe-eval'`. A host that cannot should render with `scripts: 'embedded'`\n * into light DOM.\n */\nexport const runEnhancementScript = (js: string, root: Element): void => {\n // Guards untyped callers; typed ones already handled `querySelector`'s null.\n if (!root) {\n throw new IsomerError(\n 'ENHANCEMENT_ROOT_MISSING',\n 'runEnhancementScript: no root element; pass the `.isomer` section the render produced'\n );\n }\n if (root.querySelector(`script[${EMBEDDED_SCRIPT_ATTRIBUTE}]`)) {\n console.warn(\n \"isomer: this HTML was rendered with scripts: 'embedded'; render with scripts: 'host' so its enhancements run once\"\n );\n }\n if (js) {\n // eslint-disable-next-line @typescript-eslint/no-implied-eval -- compiling the render's script is the point.\n const run = new Function('root', js) as (root: Element) => void;\n run(root);\n }\n};\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.definePrimitivePack = exports.scopeScript = exports.composePacks = exports.describeCapabilities = void 0;
|
|
10
|
+
var capabilities_1 = require("./capabilities");
|
|
11
|
+
Object.defineProperty(exports, "describeCapabilities", { enumerable: true, get: function () { return capabilities_1.describeCapabilities; } });
|
|
12
|
+
var compose_1 = require("./compose");
|
|
13
|
+
Object.defineProperty(exports, "composePacks", { enumerable: true, get: function () { return compose_1.composePacks; } });
|
|
14
|
+
var enhancements_1 = require("./enhancements");
|
|
15
|
+
Object.defineProperty(exports, "scopeScript", { enumerable: true, get: function () { return enhancements_1.scopeScript; } });
|
|
16
|
+
var primitive_pack_1 = require("./primitive_pack");
|
|
17
|
+
Object.defineProperty(exports, "definePrimitivePack", { enumerable: true, get: function () { return primitive_pack_1.definePrimitivePack; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pack/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+CAKwB;AADtB,oHAAA,oBAAoB,OAAA;AAEtB,qCAA6D;AAAhC,uGAAA,YAAY,OAAA;AACzC,+CAAyE;AAApC,2GAAA,WAAW,OAAA;AAChD,mDAQ0B;AADxB,qHAAA,mBAAmB,OAAA","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 CapabilitySources,\n type HostCapabilities,\n type SurfaceSupport,\n describeCapabilities,\n} from './capabilities';\nexport { type ComposedPacks, composePacks } from './compose';\nexport { type EnhancementDefinition, scopeScript } from './enhancements';\nexport {\n type AnyPrimitivePack,\n type PackAuthoringOptions,\n type PackStyleAdapter,\n type PrimitiveGroup,\n type PrimitivePack,\n type PrimitivePackInput,\n definePrimitivePack,\n} from './primitive_pack';\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.iconsByType = exports.definePrimitivePack = void 0;
|
|
10
|
+
// A primitive pack as a value: a vocabulary, and the optional surfaces every
|
|
11
|
+
// primitive in it implements. Additive: a runtime composes any number of packs,
|
|
12
|
+
// and nothing about a pack decides how a composition is framed.
|
|
13
|
+
const error_1 = require("../composition/error");
|
|
14
|
+
/**
|
|
15
|
+
* Builds a {@link PrimitivePack}.
|
|
16
|
+
*
|
|
17
|
+
* `TTheme` is the palette a frame must supply for this pack's nodes to be drawn
|
|
18
|
+
* on the `snapshot` surface: `definePrimitivePack<CoreTokens>(input)`. Omitted, it is
|
|
19
|
+
* `unknown`, which requires nothing.
|
|
20
|
+
*/
|
|
21
|
+
const definePrimitivePack = (input) => {
|
|
22
|
+
if (input.primitives.length === 0) {
|
|
23
|
+
throw new error_1.IsomerError('EMPTY_PACK', `primitive pack "${input.id}": at least one primitive is required`);
|
|
24
|
+
}
|
|
25
|
+
assertUniquePrimitiveTypes(input.id, input.primitives);
|
|
26
|
+
assertUniqueEnhancementIds(input.id, input.enhancements ?? []);
|
|
27
|
+
const types = new Set(input.primitives.map((definition) => definition.type));
|
|
28
|
+
assertGroupedOnce(input.id, input.authoring?.groups ?? [], types);
|
|
29
|
+
for (const type of input.slackAssetTypes ?? []) {
|
|
30
|
+
if (!types.has(type)) {
|
|
31
|
+
throw new error_1.IsomerError('UNKNOWN_PRIMITIVE_TYPE', `primitive pack "${input.id}": slackAssetTypes names primitive type "${type}", which the pack does not register`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const styleCollector = input.styleCollector ?? input.styleAdapter?.styleCollector;
|
|
35
|
+
return {
|
|
36
|
+
id: input.id,
|
|
37
|
+
surfaces: input.surfaces ?? [],
|
|
38
|
+
primitives: input.primitives,
|
|
39
|
+
types,
|
|
40
|
+
icons: (0, exports.iconsByType)(input.primitives),
|
|
41
|
+
enhancements: input.enhancements ?? [],
|
|
42
|
+
slackAssetTypes: new Set(input.slackAssetTypes ?? []),
|
|
43
|
+
...(input.styleAdapter !== undefined
|
|
44
|
+
? { styleAdapter: input.styleAdapter }
|
|
45
|
+
: {}),
|
|
46
|
+
...(styleCollector !== undefined ? { styleCollector } : {}),
|
|
47
|
+
...(input.authoring !== undefined ? { authoring: input.authoring } : {}),
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
exports.definePrimitivePack = definePrimitivePack;
|
|
51
|
+
/** Each definition's `icon` by type, null-prototype so a type such as `__proto__` is an ordinary key. */
|
|
52
|
+
const iconsByType = (primitives) => {
|
|
53
|
+
const icons = Object.create(null);
|
|
54
|
+
for (const { type, icon } of primitives) {
|
|
55
|
+
if (icon !== undefined) {
|
|
56
|
+
icons[type] = icon;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return Object.freeze(icons);
|
|
60
|
+
};
|
|
61
|
+
exports.iconsByType = iconsByType;
|
|
62
|
+
/** Throws if `primitives` repeats a type. */
|
|
63
|
+
const assertUniquePrimitiveTypes = (id, primitives) => {
|
|
64
|
+
const seen = new Set();
|
|
65
|
+
for (const { type } of primitives) {
|
|
66
|
+
if (seen.has(type)) {
|
|
67
|
+
throw new error_1.IsomerError('DUPLICATE_PRIMITIVE_TYPE', `primitive pack "${id}": primitive type "${type}" registered twice`);
|
|
68
|
+
}
|
|
69
|
+
seen.add(type);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/** Throws if a group names a type outside `types`, or two groups share a type. */
|
|
73
|
+
const assertGroupedOnce = (id, groups, types) => {
|
|
74
|
+
const grouped = new Set();
|
|
75
|
+
for (const { title, types: members } of groups) {
|
|
76
|
+
for (const type of members) {
|
|
77
|
+
if (!types.has(type)) {
|
|
78
|
+
throw new error_1.IsomerError('UNKNOWN_PRIMITIVE_TYPE', `primitive pack "${id}": group "${title}" names primitive type "${type}", which the pack does not register`);
|
|
79
|
+
}
|
|
80
|
+
if (grouped.has(type)) {
|
|
81
|
+
throw new error_1.IsomerError('DUPLICATE_PRIMITIVE_TYPE', `primitive pack "${id}": primitive type "${type}" is in two groups`);
|
|
82
|
+
}
|
|
83
|
+
grouped.add(type);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
/** Throws if this pack registers the same enhancement id twice. */
|
|
88
|
+
const assertUniqueEnhancementIds = (id, enhancements) => {
|
|
89
|
+
const seen = new Set();
|
|
90
|
+
for (const definition of enhancements) {
|
|
91
|
+
if (seen.has(definition.id)) {
|
|
92
|
+
throw new error_1.IsomerError('DUPLICATE_ENHANCEMENT', `primitive pack "${id}": enhancement "${definition.id}" registered twice`);
|
|
93
|
+
}
|
|
94
|
+
seen.add(definition.id);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=primitive_pack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive_pack.js","sourceRoot":"","sources":["../../../src/pack/primitive_pack.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6EAA6E;AAC7E,gFAAgF;AAChF,gEAAgE;AAEhE,gDAAmD;AAsKnD;;;;;;GAMG;AACI,MAAM,mBAAmB,GAAG,CACjC,KAAyB,EACF,EAAE;IACzB,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,mBAAW,CACnB,YAAY,EACZ,mBAAmB,KAAK,CAAC,EAAE,uCAAuC,CACnE,CAAC;IACJ,CAAC;IACD,0BAA0B,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACvD,0BAA0B,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,iBAAiB,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IAClE,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,eAAe,IAAI,EAAE,EAAE,CAAC;QAC/C,IAAI,CA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AAsB,IAAI,oBAAoB,CACpE,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,mEAAmE;AACnE,MAAM,0BAA0B,GAAG,CACjC,EAAU,EACV,YAA8C,EACxC,EAAE;IACR,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;QACtC,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,mBAAW,CACnB,uBAAuB,EACvB,mBAAmB,EAAE,mBAAmB,UAAU,CAAC,EAAE,oBAAoB,CAC1E,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;AACH,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// A primitive pack as a value: a vocabulary, and the optional surfaces every\n// primitive in it implements. Additive: a runtime composes any number of packs,\n// and nothing about a pack decides how a composition is framed.\n\nimport { IsomerError } from '../composition/error';\nimport type { PrimitiveIcon } from '../define/primitive_icon';\nimport type {\n AnyPrimitiveDefinition,\n OptionalSurface,\n StyleHandle,\n} from '../define/primitive_module';\n\nimport type { EnhancementDefinition } from './enhancements';\n\n/**\n * The authoring-schema material a pack contributes for its own primitives.\n *\n * A subset of `AuthoringJsonSchemaOptions`: `$id`, `title`, `description`, and\n * `composition` describe the whole authoring schema a runtime builds, which is\n * a host decision, not a pack one. `pack/` does not import `validate/` for\n * this, so the shape is declared here rather than reused by reference.\n */\nexport interface PackAuthoringOptions {\n /** `$def` id to `description`, for this pack's own primitives. */\n describe?: Readonly<Record<string, string>>;\n /** `$defId.property` paths to drop, from this pack's own primitives. */\n omitProperties?: readonly string[];\n /** Headings an index catalog sorts this pack's primitives under, in order. */\n groups?: readonly PrimitiveGroup[];\n}\n\n/** A titled set of primitive types, listed together in an index catalog. */\nexport interface PrimitiveGroup {\n title: string;\n types: readonly string[];\n}\n\n/**\n * The HTML style-adapter hooks a pack may declare. Typed loosely here so `pack/` does not import `render/`.\n */\nexport type PackStyleAdapter = {\n /** See {@link PrimitivePackInput.styleCollector}. */\n styleCollector?: string;\n /** The hooks of `HTMLStyleAdapter` from `./html`, erased: a fresh collector per render, the context renderers receive, and the stylesheet the collector produced. */\n createCollector: (...args: never[]) => object;\n createRenderContext: (...args: never[]) => unknown;\n renderStyles: (...args: never[]) => string;\n /**\n * Whether `handle` belongs to this adapter's stylesheet. Required for a runtime to combine several packs' CSS: without it their handles cannot be routed and the host must pick one adapter.\n */\n ownsHandle?: (handle: StyleHandle) => boolean;\n};\n\n/** What a pack author passes to {@link definePrimitivePack}. */\nexport interface PrimitivePackInput {\n /** Stable identifier, used in capability reports and error messages. */\n id: string;\n /**\n * The optional surfaces this pack's primitives implement.\n *\n * Only `slack`, and it stays optional per primitive: the dispatcher converts\n * the mandatory markdown to Block Kit, so declaring it reports an intent\n * rather than imposing a requirement. Omit it entirely for a pack that\n * renders Slack through that fallback.\n */\n surfaces?: readonly OptionalSurface[];\n /** This pack's vocabulary. Node types must be unique within it, or construction throws. */\n primitives: readonly AnyPrimitiveDefinition[];\n /**\n * Progressive enhancements this pack's primitives can apply, by id.\n *\n * Declared by the pack because an enhancement is a fact about its\n * vocabulary — a sortable table, a copyable code block — and a host\n * composing packs it did not write cannot be expected to know the ids.\n * The runtime flattens these across packs; duplicate ids are rejected.\n */\n enhancements?: readonly EnhancementDefinition[];\n /**\n * Types that render as a self-contained picture rather than as text.\n *\n * A channel that cannot draw them inline uploads an image instead: the Slack\n * dispatcher swaps such a node for an `image` block and an upload request, so\n * a chart arrives as a PNG rather than as a markdown approximation of one.\n *\n * Declared by the pack because it is a fact about the vocabulary, and a host\n * composing packs it did not write cannot be expected to know it.\n */\n slackAssetTypes?: readonly string[];\n /**\n * Default HTML style adapter for this pack. A runtime that omits\n * `styleAdapter` runs the packs' own adapters, combined when more than one\n * pack declares one and each answers `ownsHandle`. Pass `styleAdapter` on\n * the runtime to replace them all.\n */\n styleAdapter?: PackStyleAdapter;\n /**\n * Names the collector shape this pack's `collectStyles` hooks mutate, so a\n * runtime can reject a pack paired with an adapter of a different tag.\n * Defaults to `styleAdapter.styleCollector`; a pack with neither opts out of\n * the check.\n */\n styleCollector?: string;\n /**\n * This pack's own contribution to the runtime's authoring JSON Schema.\n *\n * Merged across every composed pack, so a host does not hand-merge each\n * pack's `describe`/`omitProperties` into one options object itself. The\n * runtime-level `authoring` option is merged in last and wins on conflict.\n */\n authoring?: PackAuthoringOptions;\n}\n\n/**\n * A pack as the runtime sees it.\n *\n * `TTheme` is the palette this pack's `react` renderers read as `env.theme`\n * when drawn through the `snapshot` surface — a *lower bound* on whatever theme\n * the runtime holding it supplies. It is carried by\n * {@link PrimitivePack.__theme} rather than by any real field, because\n * `primitives` is erased to `AnyPrimitiveDefinition[]` and a heterogeneous\n * inventory has no single node type to be generic over.\n *\n * The bound is declared, not derived: nothing checks it against what the\n * renderers actually read. State it at the definition as\n * `definePrimitivePack<T>(input)`.\n * Bare `PrimitivePack` requires nothing and fits any runtime; a slot that must\n * hold packs of every palette is typed {@link AnyPrimitivePack}.\n */\nexport interface PrimitivePack<TTheme = unknown> {\n /** Unique among the packs a runtime composes, and used in error messages. */\n readonly id: string;\n /** See {@link PrimitivePackInput.surfaces}. */\n readonly surfaces: readonly OptionalSurface[];\n /** See {@link PrimitivePackInput.primitives}. */\n readonly primitives: readonly AnyPrimitiveDefinition[];\n /** Node types this pack owns, for duplicate detection across packs. */\n readonly types: ReadonlySet<string>;\n /**\n * Each primitive's `icon` by type, for the primitives that declare one, so a host listing them need not walk `primitives`.\n *\n * A frozen null-prototype dictionary: an absent type reads `undefined`, even `constructor`. Absent on a pack built by an SDK that predates icons; {@link iconsByType} derives it from `primitives`.\n */\n readonly icons?: Readonly<Record<string, PrimitiveIcon>>;\n /** See {@link PrimitivePackInput.enhancements}. */\n readonly enhancements: readonly EnhancementDefinition[];\n /** See {@link PrimitivePackInput.slackAssetTypes}. */\n readonly slackAssetTypes: ReadonlySet<string>;\n /** See {@link PrimitivePackInput.styleAdapter}. */\n readonly styleAdapter?: PackStyleAdapter;\n /** See {@link PrimitivePackInput.styleCollector}. */\n readonly styleCollector?: string;\n /** See {@link PrimitivePackInput.authoring}. */\n readonly authoring?: PackAuthoringOptions;\n /**\n * Phantom: never present at runtime, never read.\n *\n * A property rather than a method so `strictFunctionTypes` checks it\n * contravariantly. A method signature is bivariant, which would let a pack\n * needing richer tokens sit in a slot supplying fewer and then read a field\n * nothing supplies — the exact failure this marker exists to prevent.\n */\n readonly __theme?: (theme: TTheme) => void;\n}\n\n/**\n * A pack of any palette, for storage positions: `never` is assignable to every\n * requirement, so a slot typed this way holds every pack.\n */\nexport type AnyPrimitivePack = PrimitivePack<never>;\n\n/**\n * Builds a {@link PrimitivePack}.\n *\n * `TTheme` is the palette a frame must supply for this pack's nodes to be drawn\n * on the `snapshot` surface: `definePrimitivePack<CoreTokens>(input)`. Omitted, it is\n * `unknown`, which requires nothing.\n */\nexport const definePrimitivePack = <TTheme = unknown>(\n input: PrimitivePackInput\n): PrimitivePack<TTheme> => {\n if (input.primitives.length === 0) {\n throw new IsomerError(\n 'EMPTY_PACK',\n `primitive pack \"${input.id}\": at least one primitive is required`\n );\n }\n assertUniquePrimitiveTypes(input.id, input.primitives);\n assertUniqueEnhancementIds(input.id, input.enhancements ?? []);\n const types = new Set(input.primitives.map((definition) => definition.type));\n assertGroupedOnce(input.id, input.authoring?.groups ?? [], types);\n for (const type of input.slackAssetTypes ?? []) {\n if (!types.has(type)) {\n throw new IsomerError(\n 'UNKNOWN_PRIMITIVE_TYPE',\n `primitive pack \"${input.id}\": slackAssetTypes names primitive type \"${type}\", which the pack does not register`\n );\n }\n }\n const styleCollector =\n input.styleCollector ?? input.styleAdapter?.styleCollector;\n\n return {\n id: input.id,\n surfaces: input.surfaces ?? [],\n primitives: input.primitives,\n types,\n icons: iconsByType(input.primitives),\n enhancements: input.enhancements ?? [],\n slackAssetTypes: new Set(input.slackAssetTypes ?? []),\n ...(input.styleAdapter !== undefined\n ? { styleAdapter: input.styleAdapter }\n : {}),\n ...(styleCollector !== undefined ? { styleCollector } : {}),\n ...(input.authoring !== undefined ? { authoring: input.authoring } : {}),\n };\n};\n\n/** Each definition's `icon` by type, null-prototype so a type such as `__proto__` is an ordinary key. */\nexport const iconsByType = (\n primitives: readonly AnyPrimitiveDefinition[]\n): Readonly<Record<string, PrimitiveIcon>> => {\n const icons = Object.create(null) as Record<string, PrimitiveIcon>;\n for (const { type, icon } of primitives) {\n if (icon !== undefined) {\n icons[type] = icon;\n }\n }\n return Object.freeze(icons);\n};\n\n/** Throws if `primitives` repeats a type. */\nconst assertUniquePrimitiveTypes = (\n id: string,\n primitives: readonly AnyPrimitiveDefinition[]\n): void => {\n const seen = new Set<string>();\n for (const { type } of primitives) {\n if (seen.has(type)) {\n throw new IsomerError(\n 'DUPLICATE_PRIMITIVE_TYPE',\n `primitive pack \"${id}\": primitive type \"${type}\" registered twice`\n );\n }\n seen.add(type);\n }\n};\n\n/** Throws if a group names a type outside `types`, or two groups share a type. */\nconst assertGroupedOnce = (\n id: string,\n groups: readonly PrimitiveGroup[],\n types: ReadonlySet<string>\n): void => {\n const grouped = new Set<string>();\n for (const { title, types: members } of groups) {\n for (const type of members) {\n if (!types.has(type)) {\n throw new IsomerError(\n 'UNKNOWN_PRIMITIVE_TYPE',\n `primitive pack \"${id}\": group \"${title}\" names primitive type \"${type}\", which the pack does not register`\n );\n }\n if (grouped.has(type)) {\n throw new IsomerError(\n 'DUPLICATE_PRIMITIVE_TYPE',\n `primitive pack \"${id}\": primitive type \"${type}\" is in two groups`\n );\n }\n grouped.add(type);\n }\n }\n};\n\n/** Throws if this pack registers the same enhancement id twice. */\nconst assertUniqueEnhancementIds = (\n id: string,\n enhancements: readonly EnhancementDefinition[]\n): void => {\n const seen = new Set<string>();\n for (const definition of enhancements) {\n if (seen.has(definition.id)) {\n throw new IsomerError(\n 'DUPLICATE_ENHANCEMENT',\n `primitive pack \"${id}\": enhancement \"${definition.id}\" registered twice`\n );\n }\n seen.add(definition.id);\n }\n};\n"]}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.findNodeElementPairs = exports.pairAnchors = exports.nodeType = exports.anchoredNodes = exports.anchoredNodePaths = exports.layoutRoom = exports.LAYOUT_ROOM_ATTRIBUTE = exports.nodeAnchor = exports.withNodeAnchors = exports.withoutAnchors = exports.withAnchors = exports.anchorValue = exports.NODE_ANCHOR_ATTRIBUTE = void 0;
|
|
10
|
+
const body_node_base_1 = require("../composition/body_node_base");
|
|
11
|
+
const context_view_1 = require("./context_view");
|
|
12
|
+
/** The attribute {@link nodeAnchor} sets to a node's type, escaped so HTML parsing leaves it unchanged. */
|
|
13
|
+
exports.NODE_ANCHOR_ATTRIBUTE = 'data-isomer-node';
|
|
14
|
+
/**
|
|
15
|
+
* A node type as its anchor carries it. Every character outside `[A-Za-z0-9_-]`
|
|
16
|
+
* becomes `%<hex code point>;`, so the value survives HTML serialization and
|
|
17
|
+
* parsing unchanged and never throws. A plain identifier stays as it is.
|
|
18
|
+
*/
|
|
19
|
+
const anchorValue = (type) => type.replace(/[^\w-]/gu, (char) => `%${char.codePointAt(0).toString(16)};`);
|
|
20
|
+
exports.anchorValue = anchorValue;
|
|
21
|
+
/** Marks a context whose subtree renders no anchors; see {@link withoutAnchors}. */
|
|
22
|
+
const NO_ANCHORS = Symbol.for('elastic.isomer.anchors_off');
|
|
23
|
+
/**
|
|
24
|
+
* Where an HTML render keeps its anchor decision while it runs. On `globalThis`
|
|
25
|
+
* under a `Symbol.for` key, so an ESM and a CommonJS copy of the SDK share it.
|
|
26
|
+
*/
|
|
27
|
+
const ACTIVE = Symbol.for('elastic.isomer.anchors_active');
|
|
28
|
+
const activeAnchors = () => globalThis[ACTIVE];
|
|
29
|
+
/**
|
|
30
|
+
* Runs `render` with anchors on or off for every {@link nodeAnchor} it reaches,
|
|
31
|
+
* whatever each render context says. The render must be synchronous; the
|
|
32
|
+
* previous state comes back afterwards, even if it throws.
|
|
33
|
+
*/
|
|
34
|
+
const withAnchors = (on, render) => {
|
|
35
|
+
const scope = globalThis;
|
|
36
|
+
const outer = scope[ACTIVE];
|
|
37
|
+
scope[ACTIVE] = on;
|
|
38
|
+
try {
|
|
39
|
+
return render();
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
if (outer === undefined) {
|
|
43
|
+
delete scope[ACTIVE];
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
scope[ACTIVE] = outer;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.withAnchors = withAnchors;
|
|
51
|
+
/**
|
|
52
|
+
* `context` for content a renderer draws that is not one of its `children`,
|
|
53
|
+
* such as an embedded composition: nothing under it renders an anchor.
|
|
54
|
+
*
|
|
55
|
+
* The result is a view of `context`, not a copy: reads go to `context` itself,
|
|
56
|
+
* with methods bound to it, so getters, methods, private state, and
|
|
57
|
+
* `instanceof` behave as before. The mark survives a context derived from it
|
|
58
|
+
* by spreading. A context that is neither an object nor a function is
|
|
59
|
+
* returned as it is.
|
|
60
|
+
*/
|
|
61
|
+
const withoutAnchors = (context) => (0, context_view_1.contextWith)(context, NO_ANCHORS, true);
|
|
62
|
+
exports.withoutAnchors = withoutAnchors;
|
|
63
|
+
/**
|
|
64
|
+
* `context` with node anchors on, as an enhancement declaring `anchors: true`
|
|
65
|
+
* turns them on. A view like {@link withoutAnchors}, which still wins.
|
|
66
|
+
*/
|
|
67
|
+
const withNodeAnchors = (context) => (0, context_view_1.contextWith)(context, 'anchors', true);
|
|
68
|
+
exports.withNodeAnchors = withNodeAnchors;
|
|
69
|
+
const anchorsOn = (context) => {
|
|
70
|
+
const carries = (0, context_view_1.isObjectLike)(context);
|
|
71
|
+
if (carries && Reflect.get(context, NO_ANCHORS) === true) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return (activeAnchors() ??
|
|
75
|
+
(carries && context.anchors === true));
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Props a `react` renderer spreads on its root element so runtime code can find
|
|
79
|
+
* the node with {@link findNodeElementPairs}. Inside an HTML surface render the
|
|
80
|
+
* surface decides; elsewhere, on the React and `snapshot` surfaces, `context.anchors`
|
|
81
|
+
* does. Always empty under {@link withoutAnchors}.
|
|
82
|
+
*/
|
|
83
|
+
const nodeAnchor = (context, { type }) => anchorsOn(context) ? { [exports.NODE_ANCHOR_ATTRIBUTE]: (0, exports.anchorValue)(type) } : {};
|
|
84
|
+
exports.nodeAnchor = nodeAnchor;
|
|
85
|
+
/** The attribute {@link layoutRoom} sets. */
|
|
86
|
+
exports.LAYOUT_ROOM_ATTRIBUTE = 'data-isomer-room';
|
|
87
|
+
/**
|
|
88
|
+
* Props a renderer spreads on an element inside its node that bounds the nodes
|
|
89
|
+
* nested in it, such as a frame's body, so `checkLayout` measures them against
|
|
90
|
+
* it. Rendered when {@link nodeAnchor} would be.
|
|
91
|
+
*/
|
|
92
|
+
const layoutRoom = (context) => anchorsOn(context) ? { [exports.LAYOUT_ROOM_ATTRIBUTE]: '' } : {};
|
|
93
|
+
exports.layoutRoom = layoutRoom;
|
|
94
|
+
/**
|
|
95
|
+
* The nodes of `body` a render on `surface` draws, pre-order, each with its
|
|
96
|
+
* path in validation's `body[0].items[1]` form. Nested nodes follow `react`,
|
|
97
|
+
* as a container renders them through `renderReact` on either surface.
|
|
98
|
+
*/
|
|
99
|
+
const anchoredNodePaths = (body, walk, surface = 'react') => {
|
|
100
|
+
const visit = (node, path) => [
|
|
101
|
+
{ node, path },
|
|
102
|
+
...walk(node).flatMap((child) => (0, body_node_base_1.isVisibleOnSurface)(child.node, 'react')
|
|
103
|
+
? visit(child.node, (0, body_node_base_1.childNodePath)(path, child.path))
|
|
104
|
+
: []),
|
|
105
|
+
];
|
|
106
|
+
return body.flatMap((node, index) => (0, body_node_base_1.isVisibleOnSurface)(node, surface) ? visit(node, `body[${index}]`) : []);
|
|
107
|
+
};
|
|
108
|
+
exports.anchoredNodePaths = anchoredNodePaths;
|
|
109
|
+
/** The `react`-visible nodes of `body`, pre-order: the order their anchors render in. */
|
|
110
|
+
const anchoredNodes = (body, walk) => (0, exports.anchoredNodePaths)(body, walk).map(({ node }) => node);
|
|
111
|
+
exports.anchoredNodes = anchoredNodes;
|
|
112
|
+
/** A node's `type`, when it has one. */
|
|
113
|
+
const nodeType = (node) => {
|
|
114
|
+
const { type } = node;
|
|
115
|
+
return typeof type === 'string' ? type : undefined;
|
|
116
|
+
};
|
|
117
|
+
exports.nodeType = nodeType;
|
|
118
|
+
/**
|
|
119
|
+
* The item each of `nodes` pairs with, from `anchored` in document order: the
|
|
120
|
+
* k-th node of a type pairs with the k-th item whose anchor value is that
|
|
121
|
+
* type's. A type whose node and item counts disagree pairs with nothing.
|
|
122
|
+
*/
|
|
123
|
+
const pairAnchors = (anchored, nodes) => {
|
|
124
|
+
const itemsByValue = new Map();
|
|
125
|
+
for (const [value, item] of anchored) {
|
|
126
|
+
const items = itemsByValue.get(value) ?? [];
|
|
127
|
+
items.push(item);
|
|
128
|
+
itemsByValue.set(value, items);
|
|
129
|
+
}
|
|
130
|
+
const counts = new Map();
|
|
131
|
+
for (const node of nodes) {
|
|
132
|
+
const type = (0, exports.nodeType)(node);
|
|
133
|
+
if (type !== undefined) {
|
|
134
|
+
counts.set(type, (counts.get(type) ?? 0) + 1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const seen = new Map();
|
|
138
|
+
return nodes.map((node) => {
|
|
139
|
+
const type = (0, exports.nodeType)(node);
|
|
140
|
+
if (type === undefined) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
const index = seen.get(type) ?? 0;
|
|
144
|
+
seen.set(type, index + 1);
|
|
145
|
+
const items = itemsByValue.get((0, exports.anchorValue)(type)) ?? [];
|
|
146
|
+
return items.length === counts.get(type) ? items[index] : undefined;
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
exports.pairAnchors = pairAnchors;
|
|
150
|
+
/**
|
|
151
|
+
* Every `react`-visible node of `body`, walked pre-order, with the element
|
|
152
|
+
* its anchor marks under `root`, paired by {@link pairAnchors}. `root` holds
|
|
153
|
+
* one render.
|
|
154
|
+
*
|
|
155
|
+
* Pairing holds because every renderer draws its `children` in the order its
|
|
156
|
+
* definition's `children` returns them. A node that rendered nothing leaves
|
|
157
|
+
* its type unpaired. A node object that appears twice appears twice here,
|
|
158
|
+
* each time with its own element.
|
|
159
|
+
*/
|
|
160
|
+
const findNodeElementPairs = (root, body, walk) => {
|
|
161
|
+
const nodes = (0, exports.anchoredNodes)(body, walk);
|
|
162
|
+
// Read by attribute value, so a type is never read as selector syntax.
|
|
163
|
+
const elements = (0, exports.pairAnchors)(Array.from(root.querySelectorAll(`[${exports.NODE_ANCHOR_ATTRIBUTE}]`), (element) => [element.getAttribute(exports.NODE_ANCHOR_ATTRIBUTE) ?? '', element]), nodes);
|
|
164
|
+
return nodes.map((node, index) => ({ node, element: elements[index] }));
|
|
165
|
+
};
|
|
166
|
+
exports.findNodeElementPairs = findNodeElementPairs;
|
|
167
|
+
//# sourceMappingURL=anchors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchors.js","sour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,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA5BW,QAAA,WAAW,eA4BtB;AAEF;;;;;;;;;GASG;AACI,MAAM,oBAAoB,GAAG,CAClC,IAAgB,EAChB,IAAwB,EACxB,IAAqB,EAC8B,EAAE;IACrD,MAAM,KAAK,GAAG,IAAA,qBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxC,uEAAuE;IACvE,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAC1B,KAAK,CAAC,IAAI,CACR,IAAI,CAAC,gBAAgB,CAAC,IAAI,6BAAqB,GAAG,CAAC,EACnD,CAAC,OAAO,EAAE,EAAE,CACV,CAAC,OAAO,CAAC,YAAY,CAAC,6BAAqB,CAAC,IAAI,EAAE,EAAE,OAAO,CAAU,CACxE,EACD,KAAK,CACN,CAAC;IACF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1E,CAAC,CAAC;AAhBW,QAAA,oBAAoB,wBAgB/B","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 {\n childNodePath,\n type ChildNodeWalker,\n isVisibleOnSurface,\n} from '../composition/body_node_base';\n\nimport { contextWith, isObjectLike } from './context_view';\n\n/** The attribute {@link nodeAnchor} sets to a node's type, escaped so HTML parsing leaves it unchanged. */\nexport const NODE_ANCHOR_ATTRIBUTE = 'data-isomer-node';\n\n/**\n * A node type as its anchor carries it. Every character outside `[A-Za-z0-9_-]`\n * becomes `%<hex code point>;`, so the value survives HTML serialization and\n * parsing unchanged and never throws. A plain identifier stays as it is.\n */\nexport const anchorValue = (type: string): string =>\n type.replace(/[^\\w-]/gu, (char) => `%${char.codePointAt(0)!.toString(16)};`);\n\n/** Marks a context whose subtree renders no anchors; see {@link withoutAnchors}. */\nconst NO_ANCHORS = Symbol.for('elastic.isomer.anchors_off');\n\n/**\n * Where an HTML render keeps its anchor decision while it runs. On `globalThis`\n * under a `Symbol.for` key, so an ESM and a CommonJS copy of the SDK share it.\n */\nconst ACTIVE = Symbol.for('elastic.isomer.anchors_active');\n\ntype AnchorScope = { [ACTIVE]?: boolean };\n\nconst activeAnchors = (): boolean | undefined =>\n (globalThis as AnchorScope)[ACTIVE];\n\n/**\n * Runs `render` with anchors on or off for every {@link nodeAnchor} it reaches,\n * whatever each render context says. The render must be synchronous; the\n * previous state comes back afterwards, even if it throws.\n */\nexport const withAnchors = <TResult>(\n on: boolean,\n render: () => TResult\n): TResult => {\n const scope = globalThis as AnchorScope;\n const outer = scope[ACTIVE];\n scope[ACTIVE] = on;\n try {\n return render();\n } finally {\n if (outer === undefined) {\n delete scope[ACTIVE];\n } else {\n scope[ACTIVE] = outer;\n }\n }\n};\n\n/**\n * `context` for content a renderer draws that is not one of its `children`,\n * such as an embedded composition: nothing under it renders an anchor.\n *\n * The result is a view of `context`, not a copy: reads go to `context` itself,\n * with methods bound to it, so getters, methods, private state, and\n * `instanceof` behave as before. The mark survives a context derived from it\n * by spreading. A context that is neither an object nor a function is\n * returned as it is.\n */\nexport const withoutAnchors = <TContext>(context: TContext): TContext =>\n contextWith(context, NO_ANCHORS, true);\n\n/**\n * `context` with node anchors on, as an enhancement declaring `anchors: true`\n * turns them on. A view like {@link withoutAnchors}, which still wins.\n */\nexport const withNodeAnchors = <TContext>(context: TContext): TContext =>\n contextWith(context, 'anchors', true);\n\nconst anchorsOn = (context: unknown): boolean => {\n const carries = isObjectLike(context);\n if (carries && Reflect.get(context, NO_ANCHORS) === true) {\n return false;\n }\n return (\n activeAnchors() ??\n (carries && (context as { anchors?: unknown }).anchors === true)\n );\n};\n\n/**\n * Props a `react` renderer spreads on its root element so runtime code can find\n * the node with {@link findNodeElementPairs}. Inside an HTML surface render the\n * surface decides; elsewhere, on the React and `snapshot` surfaces, `context.anchors`\n * does. Always empty under {@link withoutAnchors}.\n */\nexport const nodeAnchor = (\n context: unknown,\n { type }: { type: string }\n): Readonly<Record<string, string>> =>\n anchorsOn(context) ? { [NODE_ANCHOR_ATTRIBUTE]: anchorValue(type) } : {};\n\n/** The attribute {@link layoutRoom} sets. */\nexport const LAYOUT_ROOM_ATTRIBUTE = 'data-isomer-room';\n\n/**\n * Props a renderer spreads on an element inside its node that bounds the nodes\n * nested in it, such as a frame's body, so `checkLayout` measures them against\n * it. Rendered when {@link nodeAnchor} would be.\n */\nexport const layoutRoom = (\n context: unknown\n): Readonly<Record<string, string>> =>\n anchorsOn(context) ? { [LAYOUT_ROOM_ATTRIBUTE]: '' } : {};\n\n/**\n * The nodes of `body` a render on `surface` draws, pre-order, each with its\n * path in validation's `body[0].items[1]` form. Nested nodes follow `react`,\n * as a container renders them through `renderReact` on either surface.\n */\nexport const anchoredNodePaths = (\n body: readonly unknown[],\n walk: ChildNodeWalker,\n surface: 'react' | 'snapshot' = 'react'\n): { node: unknown; path: string }[] => {\n const visit = (\n node: unknown,\n path: string\n ): { node: unknown; path: string }[] => [\n { node, path },\n ...walk(node).flatMap((child) =>\n isVisibleOnSurface(child.node, 'react')\n ? visit(child.node, childNodePath(path, child.path))\n : []\n ),\n ];\n return body.flatMap((node, index) =>\n isVisibleOnSurface(node, surface) ? visit(node, `body[${index}]`) : []\n );\n};\n\n/** The `react`-visible nodes of `body`, pre-order: the order their anchors render in. */\nexport const anchoredNodes = (\n body: readonly unknown[],\n walk: ChildNodeWalker\n): unknown[] => anchoredNodePaths(body, walk).map(({ node }) => node);\n\n/** A node's `type`, when it has one. */\nexport const nodeType = (node: unknown): string | undefined => {\n const { type } = node as { type?: unknown };\n return typeof type === 'string' ? type : undefined;\n};\n\n/**\n * The item each of `nodes` pairs with, from `anchored` in document order: the\n * k-th node of a type pairs with the k-th item whose anchor value is that\n * type's. A type whose node and item counts disagree pairs with nothing.\n */\nexport const pairAnchors = <TItem>(\n anchored: Iterable<readonly [value: string, item: TItem]>,\n nodes: readonly unknown[]\n): (TItem | undefined)[] => {\n const itemsByValue = new Map<string, TItem[]>();\n for (const [value, item] of anchored) {\n const items = itemsByValue.get(value) ?? [];\n items.push(item);\n itemsByValue.set(value, items);\n }\n const counts = new Map<string, number>();\n for (const node of nodes) {\n const type = nodeType(node);\n if (type !== undefined) {\n counts.set(type, (counts.get(type) ?? 0) + 1);\n }\n }\n const seen = new Map<string, number>();\n return nodes.map((node) => {\n const type = nodeType(node);\n if (type === undefined) {\n return undefined;\n }\n const index = seen.get(type) ?? 0;\n seen.set(type, index + 1);\n const items = itemsByValue.get(anchorValue(type)) ?? [];\n return items.length === counts.get(type) ? items[index] : undefined;\n });\n};\n\n/**\n * Every `react`-visible node of `body`, walked pre-order, with the element\n * its anchor marks under `root`, paired by {@link pairAnchors}. `root` holds\n * one render.\n *\n * Pairing holds because every renderer draws its `children` in the order its\n * definition's `children` returns them. A node that rendered nothing leaves\n * its type unpaired. A node object that appears twice appears twice here,\n * each time with its own element.\n */\nexport const findNodeElementPairs = (\n root: ParentNode,\n body: readonly unknown[],\n walk: ChildNodeWalker\n): { node: unknown; element: Element | undefined }[] => {\n const nodes = anchoredNodes(body, walk);\n // Read by attribute value, so a type is never read as selector syntax.\n const elements = pairAnchors(\n Array.from(\n root.querySelectorAll(`[${NODE_ANCHOR_ATTRIBUTE}]`),\n (element) =>\n [element.getAttribute(NODE_ANCHOR_ATTRIBUTE) ?? '', element] as const\n ),\n nodes\n );\n return nodes.map((node, index) => ({ node, element: elements[index] }));\n};\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.contextWith = exports.isObjectLike = void 0;
|
|
10
|
+
/** Whether `value` can carry properties: a non-null object or a function. */
|
|
11
|
+
const isObjectLike = (value) => (typeof value === 'object' && value !== null) || typeof value === 'function';
|
|
12
|
+
exports.isObjectLike = isObjectLike;
|
|
13
|
+
/**
|
|
14
|
+
* A view of `context` that reads `key` as `value` and everything else from
|
|
15
|
+
* `context`, with methods bound to it, so getters, private state, and
|
|
16
|
+
* `instanceof` behave as before, and a callable context stays callable. A
|
|
17
|
+
* context that is neither an object nor a function is returned as it is.
|
|
18
|
+
*/
|
|
19
|
+
const contextWith = (context, key, value) => {
|
|
20
|
+
if (!(0, exports.isObjectLike)(context)) {
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
const original = context;
|
|
24
|
+
// An extensible stand-in, so a frozen context cannot trip the proxy invariants. An arrow function has no non-configurable own keys.
|
|
25
|
+
const prototype = Object.getPrototypeOf(original);
|
|
26
|
+
const standIn = (typeof original === 'function'
|
|
27
|
+
? Object.setPrototypeOf(() => undefined, prototype)
|
|
28
|
+
: Object.create(prototype));
|
|
29
|
+
return new Proxy(standIn, {
|
|
30
|
+
apply: (_, self, args) => Reflect.apply(original, self, args),
|
|
31
|
+
get: (_, read) => {
|
|
32
|
+
if (read === key) {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
const found = Reflect.get(original, read, original);
|
|
36
|
+
return typeof found === 'function'
|
|
37
|
+
? found.bind(original)
|
|
38
|
+
: found;
|
|
39
|
+
},
|
|
40
|
+
set: (_, write, next) => Reflect.set(original, write, next, original),
|
|
41
|
+
has: (_, read) => read === key || Reflect.has(original, read),
|
|
42
|
+
ownKeys: () => [...new Set([...Reflect.ownKeys(original), key])],
|
|
43
|
+
getOwnPropertyDescriptor: (_, read) => {
|
|
44
|
+
if (read === key) {
|
|
45
|
+
return { value, enumerable: true, configurable: true, writable: true };
|
|
46
|
+
}
|
|
47
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(original, read);
|
|
48
|
+
return descriptor && { ...descriptor, configurable: true };
|
|
49
|
+
},
|
|
50
|
+
getPrototypeOf: () => Object.getPrototypeOf(original),
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.contextWith = contextWith;
|
|
54
|
+
//# sourceMappingURL=context_view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context_view.js","sourceRoot":"","sources":["../../../src/render/context_view.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6EAA6E;AACtE,MAAM,YAAY,GAAG,CAAC,KAAc,EAAmB,EAAE,CAC9D,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;AADlE,QAAA,YAAY,gBACsD;AAE/E;;;;;GAKG;AACI,MAAM,WAAW,GAAG,CACzB,OAAiB,EACjB,GAAoB,EACpB,KAAc,EACJ,EAAE;IACZ,IAAI,CAAC,IAAA,oBAAY,EAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC;IACzB,oIAAoI;IACpI,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAkB,CAAC;IACnE,MAAM,OAAO,GAAG,CACd,OAAO,QAAQ,KAAK,UAAU;QAC5B,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;QACnD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CACnB,CAAC;IACZ,OAAO,IAAI,KAAK,CAAC,OAAO,EAA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OAAO,UAAU,IAAI,EAAE,GAAG,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QAC7D,CAAC;QACD,cAAc,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAkB;KACvE,CAAa,CAAC;AACjB,CAAC,CAAC;AAxCW,QAAA,WAAW,eAwCtB","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/** Whether `value` can carry properties: a non-null object or a function. */\nexport const isObjectLike = (value: unknown): value is object =>\n (typeof value === 'object' && value !== null) || typeof value === 'function';\n\n/**\n * A view of `context` that reads `key` as `value` and everything else from\n * `context`, with methods bound to it, so getters, private state, and\n * `instanceof` behave as before, and a callable context stays callable. A\n * context that is neither an object nor a function is returned as it is.\n */\nexport const contextWith = <TContext>(\n context: TContext,\n key: string | symbol,\n value: unknown\n): TContext => {\n if (!isObjectLike(context)) {\n return context;\n }\n const original = context;\n // An extensible stand-in, so a frozen context cannot trip the proxy invariants. An arrow function has no non-configurable own keys.\n const prototype = Object.getPrototypeOf(original) as object | null;\n const standIn = (\n typeof original === 'function'\n ? Object.setPrototypeOf(() => undefined, prototype)\n : Object.create(prototype)\n ) as object;\n return new Proxy(standIn, {\n apply: (_, self, args: unknown[]) =>\n Reflect.apply(original as (...rest: unknown[]) => unknown, self, args),\n get: (_, read) => {\n if (read === key) {\n return value;\n }\n const found: unknown = Reflect.get(original, read, original);\n return typeof found === 'function'\n ? (found as (...args: unknown[]) => unknown).bind(original)\n : found;\n },\n set: (_, write, next) => Reflect.set(original, write, next, original),\n has: (_, read) => read === key || Reflect.has(original, read),\n ownKeys: () => [...new Set([...Reflect.ownKeys(original), key])],\n getOwnPropertyDescriptor: (_, read) => {\n if (read === key) {\n return { value, enumerable: true, configurable: true, writable: true };\n }\n const descriptor = Reflect.getOwnPropertyDescriptor(original, read);\n return descriptor && { ...descriptor, configurable: true };\n },\n getPrototypeOf: () => Object.getPrototypeOf(original) as object | null,\n }) as TContext;\n};\n"]}
|