@copilotkit/shared 2.0.0-rc.4 → 2.0.0-rc.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -15
- package/dist/a2ui-envelope.cjs +2 -2
- package/dist/a2ui-envelope.cjs.map +1 -1
- package/dist/a2ui-envelope.d.cts +1 -1
- package/dist/a2ui-envelope.d.cts.map +1 -1
- package/dist/a2ui-envelope.d.mts +1 -1
- package/dist/a2ui-envelope.d.mts.map +1 -1
- package/dist/a2ui-envelope.mjs +2 -2
- package/dist/a2ui-envelope.mjs.map +1 -1
- package/dist/a2ui-prompts.cjs +21 -62
- package/dist/a2ui-prompts.cjs.map +1 -1
- package/dist/a2ui-prompts.d.cts +8 -1
- package/dist/a2ui-prompts.d.cts.map +1 -1
- package/dist/a2ui-prompts.d.mts +8 -1
- package/dist/a2ui-prompts.d.mts.map +1 -1
- package/dist/a2ui-prompts.mjs +22 -62
- package/dist/a2ui-prompts.mjs.map +1 -1
- package/dist/attachments/types.d.cts +1 -3
- package/dist/attachments/types.d.cts.map +1 -1
- package/dist/attachments/types.d.mts +1 -3
- package/dist/attachments/types.d.mts.map +1 -1
- package/dist/attachments/utils.cjs +16 -5
- package/dist/attachments/utils.cjs.map +1 -1
- package/dist/attachments/utils.d.cts +3 -1
- package/dist/attachments/utils.d.cts.map +1 -1
- package/dist/attachments/utils.d.mts +3 -1
- package/dist/attachments/utils.d.mts.map +1 -1
- package/dist/attachments/utils.mjs +16 -5
- package/dist/attachments/utils.mjs.map +1 -1
- package/dist/finalize-events.cjs +16 -0
- package/dist/finalize-events.cjs.map +1 -1
- package/dist/finalize-events.d.cts.map +1 -1
- package/dist/finalize-events.d.mts.map +1 -1
- package/dist/finalize-events.mjs +16 -0
- package/dist/finalize-events.mjs.map +1 -1
- package/dist/generative-ui/basic-functions.cjs +1 -1
- package/dist/generative-ui/basic-functions.cjs.map +1 -1
- package/dist/generative-ui/basic-functions.mjs +1 -1
- package/dist/generative-ui/basic-functions.mjs.map +1 -1
- package/dist/generative-ui/catalog/catalog-export.cjs +329 -0
- package/dist/generative-ui/catalog/catalog-export.cjs.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.d.cts +92 -0
- package/dist/generative-ui/catalog/catalog-export.d.cts.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.d.mts +92 -0
- package/dist/generative-ui/catalog/catalog-export.d.mts.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.mjs +328 -0
- package/dist/generative-ui/catalog/catalog-export.mjs.map +1 -0
- package/dist/generative-ui/catalog/catalog.cjs +315 -0
- package/dist/generative-ui/catalog/catalog.cjs.map +1 -0
- package/dist/generative-ui/catalog/catalog.d.cts +407 -0
- package/dist/generative-ui/catalog/catalog.d.cts.map +1 -0
- package/dist/generative-ui/catalog/catalog.d.mts +407 -0
- package/dist/generative-ui/catalog/catalog.d.mts.map +1 -0
- package/dist/generative-ui/catalog/catalog.mjs +312 -0
- package/dist/generative-ui/catalog/catalog.mjs.map +1 -0
- package/dist/generative-ui/catalog/errors.cjs +13 -0
- package/dist/generative-ui/catalog/errors.cjs.map +1 -0
- package/dist/generative-ui/catalog/errors.d.cts +46 -0
- package/dist/generative-ui/catalog/errors.d.cts.map +1 -0
- package/dist/generative-ui/catalog/errors.d.mts +46 -0
- package/dist/generative-ui/catalog/errors.d.mts.map +1 -0
- package/dist/generative-ui/catalog/errors.mjs +12 -0
- package/dist/generative-ui/catalog/errors.mjs.map +1 -0
- package/dist/generative-ui/catalog/index.d.mts +6 -0
- package/dist/generative-ui/catalog/json-schema.cjs +16 -0
- package/dist/generative-ui/catalog/json-schema.cjs.map +1 -0
- package/dist/generative-ui/catalog/json-schema.d.cts +12 -0
- package/dist/generative-ui/catalog/json-schema.d.cts.map +1 -0
- package/dist/generative-ui/catalog/json-schema.d.mts +12 -0
- package/dist/generative-ui/catalog/json-schema.d.mts.map +1 -0
- package/dist/generative-ui/catalog/json-schema.mjs +16 -0
- package/dist/generative-ui/catalog/json-schema.mjs.map +1 -0
- package/dist/generative-ui/catalog/refs.cjs +21 -0
- package/dist/generative-ui/catalog/refs.cjs.map +1 -0
- package/dist/generative-ui/catalog/refs.d.cts +55 -0
- package/dist/generative-ui/catalog/refs.d.cts.map +1 -0
- package/dist/generative-ui/catalog/refs.d.mts +55 -0
- package/dist/generative-ui/catalog/refs.d.mts.map +1 -0
- package/dist/generative-ui/catalog/refs.mjs +18 -0
- package/dist/generative-ui/catalog/refs.mjs.map +1 -0
- package/dist/generative-ui/catalog/schema.cjs +74 -0
- package/dist/generative-ui/catalog/schema.cjs.map +1 -0
- package/dist/generative-ui/catalog/schema.d.cts +43 -0
- package/dist/generative-ui/catalog/schema.d.cts.map +1 -0
- package/dist/generative-ui/catalog/schema.d.mts +43 -0
- package/dist/generative-ui/catalog/schema.d.mts.map +1 -0
- package/dist/generative-ui/catalog/schema.mjs +68 -0
- package/dist/generative-ui/catalog/schema.mjs.map +1 -0
- package/dist/generative-ui/child-refs.cjs +3 -3
- package/dist/generative-ui/child-refs.cjs.map +1 -1
- package/dist/generative-ui/child-refs.d.cts.map +1 -1
- package/dist/generative-ui/child-refs.d.mts.map +1 -1
- package/dist/generative-ui/child-refs.mjs +3 -3
- package/dist/generative-ui/child-refs.mjs.map +1 -1
- package/dist/generative-ui/clone-value.cjs +364 -0
- package/dist/generative-ui/clone-value.cjs.map +1 -0
- package/dist/generative-ui/clone-value.d.cts +51 -0
- package/dist/generative-ui/clone-value.d.cts.map +1 -0
- package/dist/generative-ui/clone-value.d.mts +51 -0
- package/dist/generative-ui/clone-value.d.mts.map +1 -0
- package/dist/generative-ui/clone-value.mjs +363 -0
- package/dist/generative-ui/clone-value.mjs.map +1 -0
- package/dist/generative-ui/compact-schema.cjs +187 -0
- package/dist/generative-ui/compact-schema.cjs.map +1 -0
- package/dist/generative-ui/compact-schema.d.cts +55 -0
- package/dist/generative-ui/compact-schema.d.cts.map +1 -0
- package/dist/generative-ui/compact-schema.d.mts +55 -0
- package/dist/generative-ui/compact-schema.d.mts.map +1 -0
- package/dist/generative-ui/compact-schema.mjs +185 -0
- package/dist/generative-ui/compact-schema.mjs.map +1 -0
- package/dist/generative-ui/index.cjs +286 -0
- package/dist/generative-ui/index.d.cts +39 -0
- package/dist/generative-ui/index.d.mts +41 -0
- package/dist/generative-ui/index.mjs +40 -0
- package/dist/generative-ui/is-record.cjs +6 -1
- package/dist/generative-ui/is-record.cjs.map +1 -1
- package/dist/generative-ui/is-record.d.cts +8 -0
- package/dist/generative-ui/is-record.d.cts.map +1 -0
- package/dist/generative-ui/is-record.d.mts +8 -0
- package/dist/generative-ui/is-record.d.mts.map +1 -0
- package/dist/generative-ui/is-record.mjs +6 -2
- package/dist/generative-ui/is-record.mjs.map +1 -1
- package/dist/generative-ui/prompt-spec.cjs +225 -0
- package/dist/generative-ui/prompt-spec.cjs.map +1 -0
- package/dist/generative-ui/prompt-spec.d.cts +94 -0
- package/dist/generative-ui/prompt-spec.d.cts.map +1 -0
- package/dist/generative-ui/prompt-spec.d.mts +94 -0
- package/dist/generative-ui/prompt-spec.d.mts.map +1 -0
- package/dist/generative-ui/prompt-spec.mjs +220 -0
- package/dist/generative-ui/prompt-spec.mjs.map +1 -0
- package/dist/generative-ui/prompt.cjs +10 -36
- package/dist/generative-ui/prompt.cjs.map +1 -1
- package/dist/generative-ui/prompt.d.cts +2 -1
- package/dist/generative-ui/prompt.d.cts.map +1 -1
- package/dist/generative-ui/prompt.d.mts +2 -1
- package/dist/generative-ui/prompt.d.mts.map +1 -1
- package/dist/generative-ui/prompt.mjs +12 -38
- package/dist/generative-ui/prompt.mjs.map +1 -1
- package/dist/generative-ui/render-ui-args.cjs +1 -0
- package/dist/generative-ui/render-ui-args.cjs.map +1 -1
- package/dist/generative-ui/render-ui-args.d.cts.map +1 -1
- package/dist/generative-ui/render-ui-args.d.mts.map +1 -1
- package/dist/generative-ui/render-ui-args.mjs +1 -0
- package/dist/generative-ui/render-ui-args.mjs.map +1 -1
- package/dist/generative-ui/schema-render.cjs +243 -0
- package/dist/generative-ui/schema-render.cjs.map +1 -0
- package/dist/generative-ui/schema-render.d.cts +44 -0
- package/dist/generative-ui/schema-render.d.cts.map +1 -0
- package/dist/generative-ui/schema-render.d.mts +44 -0
- package/dist/generative-ui/schema-render.d.mts.map +1 -0
- package/dist/generative-ui/schema-render.mjs +240 -0
- package/dist/generative-ui/schema-render.mjs.map +1 -0
- package/dist/generative-ui/standard/chart-config.cjs +347 -0
- package/dist/generative-ui/standard/chart-config.cjs.map +1 -0
- package/dist/generative-ui/standard/chart-config.d.cts +97 -0
- package/dist/generative-ui/standard/chart-config.d.cts.map +1 -0
- package/dist/generative-ui/standard/chart-config.d.mts +97 -0
- package/dist/generative-ui/standard/chart-config.d.mts.map +1 -0
- package/dist/generative-ui/standard/chart-config.mjs +342 -0
- package/dist/generative-ui/standard/chart-config.mjs.map +1 -0
- package/dist/generative-ui/standard/chart.cjs +56 -0
- package/dist/generative-ui/standard/chart.cjs.map +1 -0
- package/dist/generative-ui/standard/chart.d.cts +62 -0
- package/dist/generative-ui/standard/chart.d.cts.map +1 -0
- package/dist/generative-ui/standard/chart.d.mts +62 -0
- package/dist/generative-ui/standard/chart.d.mts.map +1 -0
- package/dist/generative-ui/standard/chart.mjs +54 -0
- package/dist/generative-ui/standard/chart.mjs.map +1 -0
- package/dist/generative-ui/standard/checks.cjs +74 -0
- package/dist/generative-ui/standard/checks.cjs.map +1 -0
- package/dist/generative-ui/standard/checks.d.cts +56 -0
- package/dist/generative-ui/standard/checks.d.cts.map +1 -0
- package/dist/generative-ui/standard/checks.d.mts +56 -0
- package/dist/generative-ui/standard/checks.d.mts.map +1 -0
- package/dist/generative-ui/standard/checks.mjs +71 -0
- package/dist/generative-ui/standard/checks.mjs.map +1 -0
- package/dist/generative-ui/standard/components.cjs +23 -0
- package/dist/generative-ui/standard/components.cjs.map +1 -0
- package/dist/generative-ui/standard/components.d.cts +24 -0
- package/dist/generative-ui/standard/components.d.cts.map +1 -0
- package/dist/generative-ui/standard/components.d.mts +24 -0
- package/dist/generative-ui/standard/components.d.mts.map +1 -0
- package/dist/generative-ui/standard/components.mjs +22 -0
- package/dist/generative-ui/standard/components.mjs.map +1 -0
- package/dist/generative-ui/standard/composites.cjs +143 -0
- package/dist/generative-ui/standard/composites.cjs.map +1 -0
- package/dist/generative-ui/standard/composites.d.cts +233 -0
- package/dist/generative-ui/standard/composites.d.cts.map +1 -0
- package/dist/generative-ui/standard/composites.d.mts +233 -0
- package/dist/generative-ui/standard/composites.d.mts.map +1 -0
- package/dist/generative-ui/standard/composites.mjs +132 -0
- package/dist/generative-ui/standard/composites.mjs.map +1 -0
- package/dist/generative-ui/standard/data.cjs +176 -0
- package/dist/generative-ui/standard/data.cjs.map +1 -0
- package/dist/generative-ui/standard/data.d.cts +365 -0
- package/dist/generative-ui/standard/data.d.cts.map +1 -0
- package/dist/generative-ui/standard/data.d.mts +365 -0
- package/dist/generative-ui/standard/data.d.mts.map +1 -0
- package/dist/generative-ui/standard/data.mjs +167 -0
- package/dist/generative-ui/standard/data.mjs.map +1 -0
- package/dist/generative-ui/standard/declarations.cjs +40 -0
- package/dist/generative-ui/standard/declarations.cjs.map +1 -0
- package/dist/generative-ui/standard/declarations.d.cts +2570 -0
- package/dist/generative-ui/standard/declarations.d.cts.map +1 -0
- package/dist/generative-ui/standard/declarations.d.mts +2571 -0
- package/dist/generative-ui/standard/declarations.d.mts.map +1 -0
- package/dist/generative-ui/standard/declarations.mjs +39 -0
- package/dist/generative-ui/standard/declarations.mjs.map +1 -0
- package/dist/generative-ui/standard/feedback.cjs +97 -0
- package/dist/generative-ui/standard/feedback.cjs.map +1 -0
- package/dist/generative-ui/standard/feedback.d.cts +133 -0
- package/dist/generative-ui/standard/feedback.d.cts.map +1 -0
- package/dist/generative-ui/standard/feedback.d.mts +133 -0
- package/dist/generative-ui/standard/feedback.d.mts.map +1 -0
- package/dist/generative-ui/standard/feedback.mjs +90 -0
- package/dist/generative-ui/standard/feedback.mjs.map +1 -0
- package/dist/generative-ui/standard/index.d.mts +20 -0
- package/dist/generative-ui/standard/inputs.cjs +333 -0
- package/dist/generative-ui/standard/inputs.cjs.map +1 -0
- package/dist/generative-ui/standard/inputs.d.cts +1128 -0
- package/dist/generative-ui/standard/inputs.d.cts.map +1 -0
- package/dist/generative-ui/standard/inputs.d.mts +1128 -0
- package/dist/generative-ui/standard/inputs.d.mts.map +1 -0
- package/dist/generative-ui/standard/inputs.mjs +318 -0
- package/dist/generative-ui/standard/inputs.mjs.map +1 -0
- package/dist/generative-ui/standard/layout.cjs +289 -0
- package/dist/generative-ui/standard/layout.cjs.map +1 -0
- package/dist/generative-ui/standard/layout.d.cts +1974 -0
- package/dist/generative-ui/standard/layout.d.cts.map +1 -0
- package/dist/generative-ui/standard/layout.d.mts +1975 -0
- package/dist/generative-ui/standard/layout.d.mts.map +1 -0
- package/dist/generative-ui/standard/layout.mjs +269 -0
- package/dist/generative-ui/standard/layout.mjs.map +1 -0
- package/dist/generative-ui/standard/map-helpers.cjs +104 -0
- package/dist/generative-ui/standard/map-helpers.cjs.map +1 -0
- package/dist/generative-ui/standard/map-helpers.d.cts +88 -0
- package/dist/generative-ui/standard/map-helpers.d.cts.map +1 -0
- package/dist/generative-ui/standard/map-helpers.d.mts +88 -0
- package/dist/generative-ui/standard/map-helpers.d.mts.map +1 -0
- package/dist/generative-ui/standard/map-helpers.mjs +95 -0
- package/dist/generative-ui/standard/map-helpers.mjs.map +1 -0
- package/dist/generative-ui/standard/map.cjs +27 -0
- package/dist/generative-ui/standard/map.cjs.map +1 -0
- package/dist/generative-ui/standard/map.d.cts +31 -0
- package/dist/generative-ui/standard/map.d.cts.map +1 -0
- package/dist/generative-ui/standard/map.d.mts +31 -0
- package/dist/generative-ui/standard/map.d.mts.map +1 -0
- package/dist/generative-ui/standard/map.mjs +25 -0
- package/dist/generative-ui/standard/map.mjs.map +1 -0
- package/dist/generative-ui/standard/media.cjs +215 -0
- package/dist/generative-ui/standard/media.cjs.map +1 -0
- package/dist/generative-ui/standard/media.d.cts +396 -0
- package/dist/generative-ui/standard/media.d.cts.map +1 -0
- package/dist/generative-ui/standard/media.d.mts +396 -0
- package/dist/generative-ui/standard/media.d.mts.map +1 -0
- package/dist/generative-ui/standard/media.mjs +205 -0
- package/dist/generative-ui/standard/media.mjs.map +1 -0
- package/dist/generative-ui/standard/parameter-order.cjs +231 -0
- package/dist/generative-ui/standard/parameter-order.cjs.map +1 -0
- package/dist/generative-ui/standard/parameter-order.d.cts +84 -0
- package/dist/generative-ui/standard/parameter-order.d.cts.map +1 -0
- package/dist/generative-ui/standard/parameter-order.d.mts +84 -0
- package/dist/generative-ui/standard/parameter-order.d.mts.map +1 -0
- package/dist/generative-ui/standard/parameter-order.mjs +230 -0
- package/dist/generative-ui/standard/parameter-order.mjs.map +1 -0
- package/dist/generative-ui/standard/style-helpers.cjs +151 -0
- package/dist/generative-ui/standard/style-helpers.cjs.map +1 -0
- package/dist/generative-ui/standard/style-helpers.d.cts +56 -0
- package/dist/generative-ui/standard/style-helpers.d.cts.map +1 -0
- package/dist/generative-ui/standard/style-helpers.d.mts +56 -0
- package/dist/generative-ui/standard/style-helpers.d.mts.map +1 -0
- package/dist/generative-ui/standard/style-helpers.mjs +142 -0
- package/dist/generative-ui/standard/style-helpers.mjs.map +1 -0
- package/dist/generative-ui/standard/styles.cjs +62 -0
- package/dist/generative-ui/standard/styles.cjs.map +1 -0
- package/dist/generative-ui/standard/styles.d.cts +17 -0
- package/dist/generative-ui/standard/styles.d.cts.map +1 -0
- package/dist/generative-ui/standard/styles.d.mts +17 -0
- package/dist/generative-ui/standard/styles.d.mts.map +1 -0
- package/dist/generative-ui/standard/styles.mjs +60 -0
- package/dist/generative-ui/standard/styles.mjs.map +1 -0
- package/dist/generative-ui/standard/text.cjs +226 -0
- package/dist/generative-ui/standard/text.cjs.map +1 -0
- package/dist/generative-ui/standard/text.d.cts +522 -0
- package/dist/generative-ui/standard/text.d.cts.map +1 -0
- package/dist/generative-ui/standard/text.d.mts +522 -0
- package/dist/generative-ui/standard/text.d.mts.map +1 -0
- package/dist/generative-ui/standard/text.mjs +209 -0
- package/dist/generative-ui/standard/text.mjs.map +1 -0
- package/dist/generative-ui/standard/theme.cjs +115 -0
- package/dist/generative-ui/standard/theme.cjs.map +1 -0
- package/dist/generative-ui/standard/theme.d.cts +60 -0
- package/dist/generative-ui/standard/theme.d.cts.map +1 -0
- package/dist/generative-ui/standard/theme.d.mts +60 -0
- package/dist/generative-ui/standard/theme.d.mts.map +1 -0
- package/dist/generative-ui/standard/theme.mjs +112 -0
- package/dist/generative-ui/standard/theme.mjs.map +1 -0
- package/dist/generative-ui/standard/tokens.cjs +336 -0
- package/dist/generative-ui/standard/tokens.cjs.map +1 -0
- package/dist/generative-ui/standard/tokens.d.cts +76 -0
- package/dist/generative-ui/standard/tokens.d.cts.map +1 -0
- package/dist/generative-ui/standard/tokens.d.mts +76 -0
- package/dist/generative-ui/standard/tokens.d.mts.map +1 -0
- package/dist/generative-ui/standard/tokens.mjs +305 -0
- package/dist/generative-ui/standard/tokens.mjs.map +1 -0
- package/dist/generative-ui/standard/url.cjs +54 -0
- package/dist/generative-ui/standard/url.cjs.map +1 -0
- package/dist/generative-ui/standard/url.d.cts +32 -0
- package/dist/generative-ui/standard/url.d.cts.map +1 -0
- package/dist/generative-ui/standard/url.d.mts +32 -0
- package/dist/generative-ui/standard/url.d.mts.map +1 -0
- package/dist/generative-ui/standard/url.mjs +50 -0
- package/dist/generative-ui/standard/url.mjs.map +1 -0
- package/dist/generative-ui/thrown.cjs +69 -0
- package/dist/generative-ui/thrown.cjs.map +1 -0
- package/dist/generative-ui/thrown.d.cts +21 -0
- package/dist/generative-ui/thrown.d.cts.map +1 -0
- package/dist/generative-ui/thrown.d.mts +21 -0
- package/dist/generative-ui/thrown.d.mts.map +1 -0
- package/dist/generative-ui/thrown.mjs +67 -0
- package/dist/generative-ui/thrown.mjs.map +1 -0
- package/dist/generative-ui/types.cjs +2 -2
- package/dist/generative-ui/types.cjs.map +1 -1
- package/dist/generative-ui/types.d.cts +7 -7
- package/dist/generative-ui/types.d.cts.map +1 -1
- package/dist/generative-ui/types.d.mts +7 -7
- package/dist/generative-ui/types.d.mts.map +1 -1
- package/dist/generative-ui/types.mjs +2 -2
- package/dist/generative-ui/types.mjs.map +1 -1
- package/dist/generative-ui/validate-operation.cjs +2 -2
- package/dist/generative-ui/validate-operation.cjs.map +1 -1
- package/dist/generative-ui/validate-operation.mjs +2 -2
- package/dist/generative-ui/validate-operation.mjs.map +1 -1
- package/dist/index.cjs +18 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -16
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +17 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +10 -8
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1233 -456
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/standard-schema.cjs +20 -7
- package/dist/standard-schema.cjs.map +1 -1
- package/dist/standard-schema.d.cts +15 -16
- package/dist/standard-schema.d.cts.map +1 -1
- package/dist/standard-schema.d.mts +15 -16
- package/dist/standard-schema.d.mts.map +1 -1
- package/dist/standard-schema.mjs +20 -8
- package/dist/standard-schema.mjs.map +1 -1
- package/dist/telemetry/lambda-client.cjs +1 -1
- package/dist/telemetry/lambda-client.cjs.map +1 -1
- package/dist/telemetry/lambda-client.d.cts.map +1 -1
- package/dist/telemetry/lambda-client.d.mts.map +1 -1
- package/dist/telemetry/lambda-client.mjs +1 -1
- package/dist/telemetry/lambda-client.mjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.cjs +0 -5
- package/dist/telemetry/telemetry-disabled.cjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.cts +0 -5
- package/dist/telemetry/telemetry-disabled.d.cts.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.mts +0 -5
- package/dist/telemetry/telemetry-disabled.d.mts.map +1 -1
- package/dist/telemetry/telemetry-disabled.mjs +0 -5
- package/dist/telemetry/telemetry-disabled.mjs.map +1 -1
- package/dist/types/message.d.cts +1 -18
- package/dist/types/message.d.cts.map +1 -1
- package/dist/types/message.d.mts +1 -18
- package/dist/types/message.d.mts.map +1 -1
- package/dist/utils/errors.cjs +5 -42
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/utils/errors.d.cts +16 -34
- package/dist/utils/errors.d.cts.map +1 -1
- package/dist/utils/errors.d.mts +16 -34
- package/dist/utils/errors.d.mts.map +1 -1
- package/dist/utils/errors.mjs +6 -41
- package/dist/utils/errors.mjs.map +1 -1
- package/dist/utils/index.cjs +0 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +4 -6
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +4 -6
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +4 -6
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/inspector-visibility.cjs +25 -3
- package/dist/utils/inspector-visibility.cjs.map +1 -1
- package/dist/utils/inspector-visibility.d.cts +26 -3
- package/dist/utils/inspector-visibility.d.cts.map +1 -1
- package/dist/utils/inspector-visibility.d.mts +26 -3
- package/dist/utils/inspector-visibility.d.mts.map +1 -1
- package/dist/utils/inspector-visibility.mjs +25 -4
- package/dist/utils/inspector-visibility.mjs.map +1 -1
- package/dist/utils/json-schema.cjs +4 -79
- package/dist/utils/json-schema.cjs.map +1 -1
- package/dist/utils/json-schema.d.cts +1 -4
- package/dist/utils/json-schema.d.cts.map +1 -1
- package/dist/utils/json-schema.d.mts +1 -4
- package/dist/utils/json-schema.d.mts.map +1 -1
- package/dist/utils/json-schema.mjs +5 -78
- package/dist/utils/json-schema.mjs.map +1 -1
- package/dist/utils/random-id.cjs +13 -26
- package/dist/utils/random-id.cjs.map +1 -1
- package/dist/utils/random-id.d.cts +6 -3
- package/dist/utils/random-id.d.cts.map +1 -1
- package/dist/utils/random-id.d.mts +6 -3
- package/dist/utils/random-id.d.mts.map +1 -1
- package/dist/utils/random-id.mjs +14 -25
- package/dist/utils/random-id.mjs.map +1 -1
- package/package.json +19 -32
- package/scripts/verify-cjs-exports.cjs +1 -1
- package/src/__tests__/a2ui-envelope.test.ts +18 -13
- package/src/__tests__/a2ui-prompts.test.ts +47 -14
- package/src/__tests__/fixtures/prompt-goldens.json +354 -0
- package/src/__tests__/prompt-spec.test.ts +191 -0
- package/src/__tests__/root-entry-browser-safety.test.ts +5 -7
- package/src/__tests__/schema-render.test.ts +323 -0
- package/src/__tests__/standard-schema.test.ts +61 -101
- package/src/a2ui-envelope.ts +7 -6
- package/src/a2ui-prompts.ts +47 -96
- package/src/attachments/__tests__/utils.test.ts +22 -0
- package/src/attachments/types.ts +1 -3
- package/src/attachments/utils.ts +23 -5
- package/src/finalize-events.ts +16 -0
- package/src/generative-ui/__tests__/clone-value-differential.test.ts +480 -0
- package/src/generative-ui/__tests__/clone-value.test.ts +226 -0
- package/src/generative-ui/__tests__/render-ui-args.test.ts +7 -7
- package/src/generative-ui/__tests__/validate-operation.test.ts +19 -13
- package/src/generative-ui/base.ts +9 -0
- package/src/generative-ui/basic-functions.ts +1 -1
- package/src/generative-ui/catalog/catalog-export.ts +478 -0
- package/src/generative-ui/catalog/catalog.ts +1167 -0
- package/src/generative-ui/catalog/errors.ts +102 -0
- package/src/generative-ui/catalog/index.ts +6 -0
- package/src/generative-ui/catalog/json-schema.ts +14 -0
- package/src/generative-ui/catalog/refs.ts +87 -0
- package/src/generative-ui/catalog/schema.ts +107 -0
- package/src/generative-ui/child-refs.ts +5 -4
- package/src/generative-ui/clone-value.ts +511 -0
- package/src/generative-ui/compact-schema.ts +277 -0
- package/src/generative-ui/index.ts +14 -0
- package/src/generative-ui/is-record.ts +6 -1
- package/src/generative-ui/prompt-spec.ts +335 -0
- package/src/generative-ui/prompt.ts +25 -75
- package/src/generative-ui/render-ui-args.ts +3 -0
- package/src/generative-ui/schema-render.ts +378 -0
- package/src/generative-ui/standard/__tests__/standard-helpers.test.ts +407 -0
- package/src/generative-ui/standard/__tests__/theme.test.ts +61 -0
- package/src/generative-ui/standard/__tests__/tokens.test.ts +139 -0
- package/src/generative-ui/standard/chart-config.ts +434 -0
- package/src/generative-ui/standard/chart.ts +79 -0
- package/src/generative-ui/standard/checks.ts +98 -0
- package/src/generative-ui/standard/components.ts +35 -0
- package/src/generative-ui/standard/composites.ts +158 -0
- package/src/generative-ui/standard/data.ts +213 -0
- package/src/generative-ui/standard/declarations.ts +57 -0
- package/src/generative-ui/standard/feedback.ts +105 -0
- package/src/generative-ui/standard/index.ts +55 -0
- package/src/generative-ui/standard/inputs.ts +423 -0
- package/src/generative-ui/standard/layout.ts +312 -0
- package/src/generative-ui/standard/map-helpers.ts +155 -0
- package/src/generative-ui/standard/map.ts +32 -0
- package/src/generative-ui/standard/media.ts +265 -0
- package/src/generative-ui/standard/parameter-order.ts +155 -0
- package/src/generative-ui/standard/style-helpers.ts +170 -0
- package/src/generative-ui/standard/styles.ts +79 -0
- package/src/generative-ui/standard/text.ts +210 -0
- package/src/generative-ui/standard/theme.ts +198 -0
- package/src/generative-ui/standard/tokens.ts +317 -0
- package/src/generative-ui/standard/url.ts +51 -0
- package/src/generative-ui/thrown.ts +90 -0
- package/src/generative-ui/types.ts +10 -7
- package/src/generative-ui/validate-operation.ts +2 -2
- package/src/index.ts +9 -17
- package/src/standard-schema.ts +24 -27
- package/src/telemetry/lambda-client.ts +8 -3
- package/src/telemetry/model-host.test.ts +2 -5
- package/src/telemetry/telemetry-disabled.ts +0 -5
- package/src/types/message.ts +1 -19
- package/src/utils/__tests__/errors.test.ts +44 -0
- package/src/utils/__tests__/json-schema.test.ts +3 -479
- package/src/utils/__tests__/random-id.test.ts +37 -0
- package/src/utils/errors.ts +28 -85
- package/src/utils/index.ts +0 -2
- package/src/utils/inspector-visibility.test.ts +26 -0
- package/src/utils/inspector-visibility.ts +35 -3
- package/src/utils/json-schema.ts +5 -152
- package/src/utils/random-id.ts +17 -37
- package/tsconfig.json +3 -1
- package/tsdown.config.ts +2 -19
- package/dist/event-transforms/index.cjs +0 -15
- package/dist/event-transforms/index.d.cts +0 -4
- package/dist/event-transforms/index.d.mts +0 -4
- package/dist/event-transforms/index.mjs +0 -5
- package/dist/event-transforms/open-generative-ui-middleware.cjs +0 -286
- package/dist/event-transforms/open-generative-ui-middleware.cjs.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.cts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.mts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.mjs +0 -283
- package/dist/event-transforms/open-generative-ui-middleware.mjs.map +0 -1
- package/dist/event-transforms/recorded-events.cjs +0 -59
- package/dist/event-transforms/recorded-events.cjs.map +0 -1
- package/dist/event-transforms/recorded-events.d.cts +0 -23
- package/dist/event-transforms/recorded-events.d.cts.map +0 -1
- package/dist/event-transforms/recorded-events.d.mts +0 -23
- package/dist/event-transforms/recorded-events.d.mts.map +0 -1
- package/dist/event-transforms/recorded-events.mjs +0 -58
- package/dist/event-transforms/recorded-events.mjs.map +0 -1
- package/dist/telemetry/events.d.cts +0 -72
- package/dist/telemetry/events.d.cts.map +0 -1
- package/dist/telemetry/events.d.mts +0 -72
- package/dist/telemetry/events.d.mts.map +0 -1
- package/dist/telemetry/index.cjs +0 -18
- package/dist/telemetry/index.d.cts +0 -5
- package/dist/telemetry/index.d.mts +0 -5
- package/dist/telemetry/index.mjs +0 -6
- package/dist/telemetry/telemetry-client.cjs +0 -165
- package/dist/telemetry/telemetry-client.cjs.map +0 -1
- package/dist/telemetry/telemetry-client.d.cts +0 -87
- package/dist/telemetry/telemetry-client.d.cts.map +0 -1
- package/dist/telemetry/telemetry-client.d.mts +0 -87
- package/dist/telemetry/telemetry-client.d.mts.map +0 -1
- package/dist/telemetry/telemetry-client.mjs +0 -164
- package/dist/telemetry/telemetry-client.mjs.map +0 -1
- package/dist/telemetry/utils.cjs +0 -14
- package/dist/telemetry/utils.cjs.map +0 -1
- package/dist/telemetry/utils.mjs +0 -13
- package/dist/telemetry/utils.mjs.map +0 -1
- package/dist/utils/conditions.cjs +0 -32
- package/dist/utils/conditions.cjs.map +0 -1
- package/dist/utils/conditions.d.cts +0 -31
- package/dist/utils/conditions.d.cts.map +0 -1
- package/dist/utils/conditions.d.mts +0 -31
- package/dist/utils/conditions.d.mts.map +0 -1
- package/dist/utils/conditions.mjs +0 -31
- package/dist/utils/conditions.mjs.map +0 -1
- package/dist/utils/console-styling.cjs +0 -91
- package/dist/utils/console-styling.cjs.map +0 -1
- package/dist/utils/console-styling.d.cts +0 -65
- package/dist/utils/console-styling.d.cts.map +0 -1
- package/dist/utils/console-styling.d.mts +0 -65
- package/dist/utils/console-styling.d.mts.map +0 -1
- package/dist/utils/console-styling.mjs +0 -85
- package/dist/utils/console-styling.mjs.map +0 -1
- package/src/__tests__/zod-regression.test.ts +0 -319
- package/src/event-transforms/index.ts +0 -5
- package/src/event-transforms/open-generative-ui-middleware.ts +0 -392
- package/src/event-transforms/recorded-events.test.ts +0 -166
- package/src/event-transforms/recorded-events.ts +0 -74
- package/src/telemetry/events.ts +0 -68
- package/src/telemetry/index.ts +0 -9
- package/src/telemetry/telemetry-blank-license-identity.test.ts +0 -128
- package/src/telemetry/telemetry-client.test.ts +0 -798
- package/src/telemetry/telemetry-client.ts +0 -328
- package/src/telemetry/utils.ts +0 -15
- package/src/utils/__tests__/conditions.test.ts +0 -161
- package/src/utils/conditions.ts +0 -116
- package/src/utils/console-styling.ts +0 -126
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { defined, layoutStyle, px, radiusStyle } from "../style-helpers";
|
|
3
|
+
import { faviconSrc, hostOf, openUrl, safeHref } from "../url";
|
|
4
|
+
import {
|
|
5
|
+
chartConfig,
|
|
6
|
+
makeFormatter,
|
|
7
|
+
normalizeSeries,
|
|
8
|
+
resolveCssColor,
|
|
9
|
+
withAlpha,
|
|
10
|
+
} from "../chart-config";
|
|
11
|
+
import {
|
|
12
|
+
guardNumericFilter,
|
|
13
|
+
guardStyleFilters,
|
|
14
|
+
isMapLibre,
|
|
15
|
+
isValidMarker,
|
|
16
|
+
} from "../map-helpers";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The shared tests run in node, which has no DOM. The chart helpers only
|
|
20
|
+
* pass the element to `getComputedStyle`, which these tests stub or leave
|
|
21
|
+
* out, so an empty object stands in for it.
|
|
22
|
+
*/
|
|
23
|
+
function stubElement() {
|
|
24
|
+
return {} as Element;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Stubs `getComputedStyle` with fixed custom property values. */
|
|
28
|
+
function stubCustomProperties(values: Record<string, string>) {
|
|
29
|
+
vi.stubGlobal("getComputedStyle", () => ({
|
|
30
|
+
getPropertyValue: (name: string) => values[name] ?? "",
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
vi.unstubAllGlobals();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe("layoutStyle", () => {
|
|
39
|
+
it("maps the layout props to flex container CSS and leaves out unset props", () => {
|
|
40
|
+
const style = layoutStyle({
|
|
41
|
+
align: "center",
|
|
42
|
+
justify: "spaceBetween",
|
|
43
|
+
padding: 2,
|
|
44
|
+
});
|
|
45
|
+
expect(style).toEqual({
|
|
46
|
+
display: "flex",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
justifyContent: "space-between",
|
|
49
|
+
padding: "calc(var(--spacing, 0.25rem) * 2)",
|
|
50
|
+
minWidth: 0,
|
|
51
|
+
maxWidth: "100%",
|
|
52
|
+
boxSizing: "border-box",
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("removes the padding for flush and sets overflow for scrollable and clip", () => {
|
|
57
|
+
expect(layoutStyle({ padding: 4, flush: true })).toMatchObject({
|
|
58
|
+
padding: 0,
|
|
59
|
+
});
|
|
60
|
+
expect(layoutStyle({ scrollable: true, clip: true })).toMatchObject({
|
|
61
|
+
overflow: "auto",
|
|
62
|
+
});
|
|
63
|
+
expect(layoutStyle({ clip: true })).toMatchObject({ overflow: "hidden" });
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("lets rowGap and columnGap win over gap, with no shorthand to override them", () => {
|
|
67
|
+
// A renderer can apply a style object in sorted key order, so a `gap`
|
|
68
|
+
// next to `columnGap` would be written last and erase it.
|
|
69
|
+
const both = layoutStyle({ gap: 2, columnGap: 6 });
|
|
70
|
+
expect(both).toMatchObject({
|
|
71
|
+
rowGap: "calc(var(--spacing, 0.25rem) * 2)",
|
|
72
|
+
columnGap: "calc(var(--spacing, 0.25rem) * 6)",
|
|
73
|
+
});
|
|
74
|
+
expect(both).not.toHaveProperty("gap");
|
|
75
|
+
const rowOnly = layoutStyle({ rowGap: 1 });
|
|
76
|
+
expect(rowOnly).toMatchObject({
|
|
77
|
+
rowGap: "calc(var(--spacing, 0.25rem) * 1)",
|
|
78
|
+
});
|
|
79
|
+
expect(rowOnly).not.toHaveProperty("columnGap");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("keeps the gap shorthand when no longhand is set", () => {
|
|
83
|
+
expect(layoutStyle({ gap: 3 })).toMatchObject({
|
|
84
|
+
gap: "calc(var(--spacing, 0.25rem) * 3)",
|
|
85
|
+
});
|
|
86
|
+
expect(layoutStyle({ disableAutoSpacing: true })).toMatchObject({ gap: 0 });
|
|
87
|
+
expect(layoutStyle({})).not.toHaveProperty("gap");
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe("radiusStyle", () => {
|
|
92
|
+
it("gives one border radius for a token or a number", () => {
|
|
93
|
+
expect(radiusStyle("lg")).toEqual({
|
|
94
|
+
borderRadius: "var(--a2ui-radius-lg, 12px)",
|
|
95
|
+
});
|
|
96
|
+
expect(radiusStyle(8)).toEqual({ borderRadius: "8px" });
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("gives one radius for each corner of a corner object", () => {
|
|
100
|
+
expect(
|
|
101
|
+
radiusStyle({
|
|
102
|
+
topLeft: "lg",
|
|
103
|
+
topRight: "2px",
|
|
104
|
+
bottomLeft: "full",
|
|
105
|
+
bottomRight: "0",
|
|
106
|
+
}),
|
|
107
|
+
).toEqual({
|
|
108
|
+
borderTopLeftRadius: "var(--a2ui-radius-lg, 12px)",
|
|
109
|
+
borderTopRightRadius: "2px",
|
|
110
|
+
borderBottomLeftRadius: "9999px",
|
|
111
|
+
borderBottomRightRadius: "0",
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("gives no CSS when the radius is not set", () => {
|
|
116
|
+
expect(radiusStyle(undefined)).toEqual({});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("px and defined", () => {
|
|
121
|
+
it("gives pixels for a number and passes a string through", () => {
|
|
122
|
+
expect(px(12)).toBe("12px");
|
|
123
|
+
expect(px("1rem")).toBe("1rem");
|
|
124
|
+
expect(px(undefined)).toBeUndefined();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("drops undefined entries and keeps zero", () => {
|
|
128
|
+
expect(defined({ margin: 0, padding: undefined, color: "red" })).toEqual({
|
|
129
|
+
margin: 0,
|
|
130
|
+
color: "red",
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe("safeHref", () => {
|
|
136
|
+
it.each([
|
|
137
|
+
[" https://example.com/a ", "https://example.com/a"],
|
|
138
|
+
["http://example.com", "http://example.com"],
|
|
139
|
+
["HTTPS://EXAMPLE.COM", "HTTPS://EXAMPLE.COM"],
|
|
140
|
+
["mailto:team@example.com", "mailto:team@example.com"],
|
|
141
|
+
])("accepts %s", (url, expected) => {
|
|
142
|
+
expect(safeHref(url)).toBe(expected);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it.each(["javascript:alert(1)", " data:text/html,hi", "/relative/path"])(
|
|
146
|
+
"rejects %s",
|
|
147
|
+
(url) => {
|
|
148
|
+
expect(safeHref(url)).toBeUndefined();
|
|
149
|
+
},
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe("hostOf and faviconSrc", () => {
|
|
154
|
+
it("reads the host of a URL with or without a scheme", () => {
|
|
155
|
+
expect(hostOf("https://docs.example.com/page?q=1")).toBe(
|
|
156
|
+
"docs.example.com",
|
|
157
|
+
);
|
|
158
|
+
expect(hostOf("example.com/page")).toBe("example.com");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("gives undefined for text that is not a URL", () => {
|
|
162
|
+
expect(hostOf("")).toBeUndefined();
|
|
163
|
+
expect(hostOf("http://")).toBeUndefined();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("builds the favicon URL with the host encoded", () => {
|
|
167
|
+
expect(faviconSrc("a b.com")).toBe(
|
|
168
|
+
"https://www.google.com/s2/favicons?domain=a%20b.com&sz=64",
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe("openUrl", () => {
|
|
174
|
+
it("opens a safe URL in a new tab without an opener", () => {
|
|
175
|
+
const open = vi.fn();
|
|
176
|
+
vi.stubGlobal("window", { open });
|
|
177
|
+
openUrl(" https://example.com ");
|
|
178
|
+
expect(open).toHaveBeenCalledWith(
|
|
179
|
+
"https://example.com",
|
|
180
|
+
"_blank",
|
|
181
|
+
"noopener,noreferrer",
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("ignores an unsafe scheme", () => {
|
|
186
|
+
const open = vi.fn();
|
|
187
|
+
vi.stubGlobal("window", { open });
|
|
188
|
+
openUrl("javascript:alert(1)");
|
|
189
|
+
expect(open).not.toHaveBeenCalled();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it("does nothing on the server, where there is no window", () => {
|
|
193
|
+
expect(() => openUrl("https://example.com")).not.toThrow();
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe("chartConfig", () => {
|
|
198
|
+
it("maps a bar chart to chart.js labels, datasets and colors", () => {
|
|
199
|
+
const config = chartConfig(
|
|
200
|
+
{
|
|
201
|
+
xKey: "month",
|
|
202
|
+
data: [
|
|
203
|
+
{ month: "Jan", cost: 290 },
|
|
204
|
+
{ month: "Feb", cost: 580 },
|
|
205
|
+
],
|
|
206
|
+
series: [{ key: "cost", label: "Monthly cost" }],
|
|
207
|
+
},
|
|
208
|
+
stubElement(),
|
|
209
|
+
);
|
|
210
|
+
expect(config).toMatchObject({
|
|
211
|
+
type: "bar",
|
|
212
|
+
data: {
|
|
213
|
+
labels: ["Jan", "Feb"],
|
|
214
|
+
datasets: [
|
|
215
|
+
{
|
|
216
|
+
label: "Monthly cost",
|
|
217
|
+
data: [290, 580],
|
|
218
|
+
// Without a computed style, a color token falls back to its default.
|
|
219
|
+
backgroundColor: "#7fb0f2",
|
|
220
|
+
borderRadius: 4,
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
options: { indexAxis: "x" },
|
|
225
|
+
});
|
|
226
|
+
expect(config.plugins).toBeUndefined();
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("maps a pie chart to one dataset with a palette color for each slice", () => {
|
|
230
|
+
const config = chartConfig(
|
|
231
|
+
{
|
|
232
|
+
chartType: "pie",
|
|
233
|
+
xKey: "name",
|
|
234
|
+
data: [
|
|
235
|
+
{ name: "A", share: 0.6 },
|
|
236
|
+
{ name: "B", share: 0.4 },
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
stubElement(),
|
|
240
|
+
);
|
|
241
|
+
expect(config).toMatchObject({
|
|
242
|
+
type: "pie",
|
|
243
|
+
data: {
|
|
244
|
+
labels: ["A", "B"],
|
|
245
|
+
datasets: [
|
|
246
|
+
{
|
|
247
|
+
label: "share",
|
|
248
|
+
data: [0.6, 0.4],
|
|
249
|
+
backgroundColor: ["#7fb0f2", "#2f6fd1"],
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
options: { cutout: 0, radius: "80%", circumference: 360 },
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it("paints with the color that the element's custom property sets", () => {
|
|
258
|
+
stubCustomProperties({ "--a2ui-chart-1": "#ff0000" });
|
|
259
|
+
const config = chartConfig(
|
|
260
|
+
{ xKey: "q", data: [{ q: "Q1", a: 1 }] },
|
|
261
|
+
stubElement(),
|
|
262
|
+
);
|
|
263
|
+
expect(config).toMatchObject({
|
|
264
|
+
data: { datasets: [{ backgroundColor: "#ff0000" }] },
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("adds the value labels plugin only when showValueLabels is set", () => {
|
|
269
|
+
const config = chartConfig(
|
|
270
|
+
{ xKey: "q", data: [{ q: "Q1", a: 1 }], showValueLabels: true },
|
|
271
|
+
stubElement(),
|
|
272
|
+
);
|
|
273
|
+
expect(config).toMatchObject({ plugins: [{ id: "a2uiValueLabels" }] });
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
describe("normalizeSeries", () => {
|
|
278
|
+
it("charts every number field except the x key when no series is set", () => {
|
|
279
|
+
expect(
|
|
280
|
+
normalizeSeries(
|
|
281
|
+
undefined,
|
|
282
|
+
[{ day: "Mon", food: 3, rent: 10, note: "x" }],
|
|
283
|
+
"day",
|
|
284
|
+
),
|
|
285
|
+
).toEqual([
|
|
286
|
+
{ key: "food", label: "food", color: "var(--a2ui-chart-1, #7fb0f2)" },
|
|
287
|
+
{ key: "rent", label: "rent", color: "var(--a2ui-chart-2, #2f6fd1)" },
|
|
288
|
+
]);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
describe("makeFormatter", () => {
|
|
293
|
+
it("gives no formatter when no format is set", () => {
|
|
294
|
+
expect(makeFormatter(undefined, undefined)).toBeUndefined();
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it("formats currency in USD by default, compact from 10,000", () => {
|
|
298
|
+
const format = makeFormatter("currency", undefined)!;
|
|
299
|
+
expect(format(290)).toBe("$290");
|
|
300
|
+
expect(format(16_000)).toBe("$16K");
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it("formats a fraction as a percentage and uses the requested currency", () => {
|
|
304
|
+
expect(makeFormatter("percent", undefined)!(0.25)).toBe("25%");
|
|
305
|
+
expect(makeFormatter("currency", "EUR")!(40)).toBe("€40");
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("falls back to plain numbers for an unknown currency code", () => {
|
|
309
|
+
expect(makeFormatter("currency", "not-a-code")!(1290)).toBe("1,290");
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it("prints a value that is not a number as text", () => {
|
|
313
|
+
const format = makeFormatter("number", undefined)!;
|
|
314
|
+
expect(format("n/a")).toBe("n/a");
|
|
315
|
+
expect(format(null)).toBe("");
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
describe("resolveCssColor and withAlpha", () => {
|
|
320
|
+
it("reads a var() token from the computed style, else its fallback", () => {
|
|
321
|
+
stubCustomProperties({ "--brand": "#123456" });
|
|
322
|
+
expect(resolveCssColor("var(--brand, #000000)", stubElement())).toBe(
|
|
323
|
+
"#123456",
|
|
324
|
+
);
|
|
325
|
+
expect(resolveCssColor("var(--unset, #abcdef)", stubElement())).toBe(
|
|
326
|
+
"#abcdef",
|
|
327
|
+
);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it("passes a plain color through", () => {
|
|
331
|
+
expect(resolveCssColor("rebeccapurple", stubElement())).toBe(
|
|
332
|
+
"rebeccapurple",
|
|
333
|
+
);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it("adds an alpha channel to a #rrggbb color only", () => {
|
|
337
|
+
expect(withAlpha("#ff0000", 0.2)).toBe("#ff000033");
|
|
338
|
+
expect(withAlpha("red", 0.2)).toBe("red");
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
describe("guardNumericFilter and guardStyleFilters", () => {
|
|
343
|
+
it("guards numeric property comparisons with a has check, at any depth", () => {
|
|
344
|
+
expect(guardNumericFilter([">=", ["get", "ref_length"], 2])).toEqual([
|
|
345
|
+
"all",
|
|
346
|
+
["has", "ref_length"],
|
|
347
|
+
[">=", ["get", "ref_length"], 2],
|
|
348
|
+
]);
|
|
349
|
+
expect(
|
|
350
|
+
guardNumericFilter([
|
|
351
|
+
"all",
|
|
352
|
+
["==", "class", "road"],
|
|
353
|
+
["<", ["get", "rank"], 3],
|
|
354
|
+
]),
|
|
355
|
+
).toEqual([
|
|
356
|
+
"all",
|
|
357
|
+
["==", "class", "road"],
|
|
358
|
+
["all", ["has", "rank"], ["<", ["get", "rank"], 3]],
|
|
359
|
+
]);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it("leaves comparisons that do not compare a property with a number", () => {
|
|
363
|
+
expect(guardNumericFilter(["==", ["get", "class"], "road"])).toEqual([
|
|
364
|
+
"==",
|
|
365
|
+
["get", "class"],
|
|
366
|
+
"road",
|
|
367
|
+
]);
|
|
368
|
+
expect(guardNumericFilter([">", ["zoom"], 3])).toEqual([">", ["zoom"], 3]);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it("guards the filter of each style layer and keeps layers without one", () => {
|
|
372
|
+
const style = {
|
|
373
|
+
layers: [{ id: "a", filter: [">", ["get", "n"], 1] }, { id: "b" }],
|
|
374
|
+
};
|
|
375
|
+
expect(guardStyleFilters(style)).toEqual({
|
|
376
|
+
layers: [
|
|
377
|
+
{ id: "a", filter: ["all", ["has", "n"], [">", ["get", "n"], 1]] },
|
|
378
|
+
{ id: "b" },
|
|
379
|
+
],
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it("returns a style without layers as it is", () => {
|
|
384
|
+
const style: { version: number; layers?: object[] } = { version: 8 };
|
|
385
|
+
expect(guardStyleFilters(style)).toBe(style);
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
describe("isValidMarker and isMapLibre", () => {
|
|
390
|
+
it("accepts a marker with finite coordinates only", () => {
|
|
391
|
+
expect(isValidMarker({ label: "Vienna", lat: 48.2, lng: 16.37 })).toBe(
|
|
392
|
+
true,
|
|
393
|
+
);
|
|
394
|
+
expect(isValidMarker({ label: "Nowhere", lat: Number.NaN, lng: 0 })).toBe(
|
|
395
|
+
false,
|
|
396
|
+
);
|
|
397
|
+
expect(
|
|
398
|
+
isValidMarker({ label: "Far", lat: 0, lng: Number.POSITIVE_INFINITY }),
|
|
399
|
+
).toBe(false);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
it("recognizes a module with a Map constructor", () => {
|
|
403
|
+
expect(isMapLibre({ Map: class {} })).toBe(true);
|
|
404
|
+
expect(isMapLibre({ Map: "not a constructor" })).toBe(false);
|
|
405
|
+
expect(isMapLibre(null)).toBe(false);
|
|
406
|
+
});
|
|
407
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { DARK_THEME_CSS, themeStyleSheet } from "../theme";
|
|
3
|
+
import type { GenerativeUITheme } from "../theme";
|
|
4
|
+
|
|
5
|
+
describe("themeStyleSheet", () => {
|
|
6
|
+
it("gives nothing for a theme without variables", () => {
|
|
7
|
+
expect(themeStyleSheet(undefined)).toBeUndefined();
|
|
8
|
+
expect(themeStyleSheet({ mapStyle: "https://x/style" })).toBeUndefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("puts top-level values on the themed surface and dark values in dark mode", () => {
|
|
12
|
+
const sheet = themeStyleSheet({
|
|
13
|
+
"--a2ui-color-accent": "#d97706",
|
|
14
|
+
dark: { "--a2ui-color-panel": "#1f2937", mapStyle: "https://x/dark" },
|
|
15
|
+
})!;
|
|
16
|
+
const self = `.a2ui-surface[data-a2ui-theme="${sheet.id}"]`;
|
|
17
|
+
expect(sheet.css).toBe(
|
|
18
|
+
`${self}{--a2ui-color-accent:#d97706}:where(.dark) ${self},${self}:where(.dark){--a2ui-color-panel:#1f2937}`,
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("gives the same id for the same theme, and another id for another theme", () => {
|
|
23
|
+
const theme: GenerativeUITheme = { "--a2ui-color-accent": "red" };
|
|
24
|
+
expect(themeStyleSheet(theme)!.id).toBe(themeStyleSheet({ ...theme })!.id);
|
|
25
|
+
expect(themeStyleSheet(theme)!.id).not.toBe(
|
|
26
|
+
themeStyleSheet({ "--a2ui-color-accent": "blue" })!.id,
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("leaves out values and names that could break out of the rule", () => {
|
|
31
|
+
const theme = {
|
|
32
|
+
"--a2ui-color-accent": "red}</style><script>alert(1)</script>",
|
|
33
|
+
"--a2ui-color-panel": "#fff;color:red",
|
|
34
|
+
"color: red; --a2ui-x": "#000",
|
|
35
|
+
"--a2ui-color-focus": "#3b9bff",
|
|
36
|
+
} as GenerativeUITheme;
|
|
37
|
+
const sheet = themeStyleSheet(theme)!;
|
|
38
|
+
expect(sheet.css).toBe(
|
|
39
|
+
`.a2ui-surface[data-a2ui-theme="${sheet.id}"]{--a2ui-color-focus:#3b9bff}`,
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("the built-in dark values", () => {
|
|
45
|
+
it("apply under a .dark class, with no specificity, so any theme rule wins", () => {
|
|
46
|
+
expect(
|
|
47
|
+
DARK_THEME_CSS.startsWith(
|
|
48
|
+
":where(.dark .a2ui-surface,.a2ui-surface.dark){",
|
|
49
|
+
),
|
|
50
|
+
).toBe(true);
|
|
51
|
+
expect(DARK_THEME_CSS).toContain("--a2ui-color-surface:#1f1f1f");
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("theme rule strength", () => {
|
|
56
|
+
it("is stronger than an app rule on .a2ui-surface, so theme values win", () => {
|
|
57
|
+
const sheet = themeStyleSheet({ "--a2ui-color-accent": "red" })!;
|
|
58
|
+
// Two classes or attributes: one more than `.a2ui-surface` alone.
|
|
59
|
+
expect(sheet.css.startsWith(".a2ui-surface[data-a2ui-theme=")).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
FONT_FAMILY,
|
|
4
|
+
STANDARD_CATALOG_ID,
|
|
5
|
+
TEXT_SIZES,
|
|
6
|
+
TITLE_SIZES,
|
|
7
|
+
backgroundColor,
|
|
8
|
+
borderColor,
|
|
9
|
+
panelBackground,
|
|
10
|
+
radius,
|
|
11
|
+
spacing,
|
|
12
|
+
textColor,
|
|
13
|
+
textFont,
|
|
14
|
+
titleFont,
|
|
15
|
+
} from "../tokens";
|
|
16
|
+
import { STANDARD_CSS } from "../styles";
|
|
17
|
+
|
|
18
|
+
describe("standard tokens", () => {
|
|
19
|
+
it("maps numbers to 4px steps and passes strings through", () => {
|
|
20
|
+
expect(spacing(3)).toBe("calc(var(--spacing, 0.25rem) * 3)");
|
|
21
|
+
expect(spacing("12px")).toBe("12px");
|
|
22
|
+
expect(spacing(undefined)).toBeUndefined();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("maps radius tokens and passes raw values through", () => {
|
|
26
|
+
expect(radius("lg")).toBe("var(--a2ui-radius-lg, 12px)");
|
|
27
|
+
expect(radius("full")).toBe("9999px");
|
|
28
|
+
expect(radius(6)).toBe("6px");
|
|
29
|
+
expect(radius("3px 4px")).toBe("3px 4px");
|
|
30
|
+
expect(radius(undefined)).toBeUndefined();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("maps semantic colors and passes raw CSS through", () => {
|
|
34
|
+
expect(textColor("secondary")).toBe(
|
|
35
|
+
"var(--a2ui-color-text-secondary, #5d5d5d)",
|
|
36
|
+
);
|
|
37
|
+
expect(textColor("#123")).toBe("#123");
|
|
38
|
+
expect(textColor(undefined)).toBeUndefined();
|
|
39
|
+
expect(backgroundColor("surface-secondary")).toBe(
|
|
40
|
+
"var(--a2ui-color-surface-secondary, #f7f7f8)",
|
|
41
|
+
);
|
|
42
|
+
expect(backgroundColor("rebeccapurple")).toBe("rebeccapurple");
|
|
43
|
+
expect(borderColor("subtle")).toBe(
|
|
44
|
+
"var(--a2ui-color-border-subtle, rgba(0, 0, 0, 0.05))",
|
|
45
|
+
);
|
|
46
|
+
expect(borderColor("default")).toBe(
|
|
47
|
+
"var(--a2ui-color-border-default, rgba(0, 0, 0, 0.1))",
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("does not read inherited object keys as tokens", () => {
|
|
52
|
+
expect(textColor("constructor")).toBe("constructor");
|
|
53
|
+
expect(radius("toString")).toBe("toString");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("maps background and text tokens to their fallback values", () => {
|
|
57
|
+
expect(backgroundColor("surface")).toBe("var(--a2ui-color-surface, #fff)");
|
|
58
|
+
expect(backgroundColor("surface-soft")).toContain("#fcfcfc");
|
|
59
|
+
expect(backgroundColor("surface-tertiary")).toContain("#ececec");
|
|
60
|
+
expect(backgroundColor("info")).toContain("rgba(0, 104, 188, 0.08)");
|
|
61
|
+
expect(backgroundColor("success-solid")).toContain("#00805d");
|
|
62
|
+
expect(textColor("default")).toContain("#0d0d0d");
|
|
63
|
+
expect(textColor("tertiary")).toContain("#8e8e8e");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("gives a panel in a Card the inner panel fill or a lighter tint", () => {
|
|
67
|
+
expect(panelBackground("surface-soft")).toBe(
|
|
68
|
+
"var(--a2ui-color-panel, rgb(252, 252, 252))",
|
|
69
|
+
);
|
|
70
|
+
expect(panelBackground("danger")).toBe(
|
|
71
|
+
"var(--a2ui-color-danger-soft, rgba(193, 50, 44, 0.06))",
|
|
72
|
+
);
|
|
73
|
+
expect(panelBackground("info-solid")).toBe(
|
|
74
|
+
"var(--a2ui-color-info-solid, #0068bc)",
|
|
75
|
+
);
|
|
76
|
+
expect(panelBackground(undefined)).toBeUndefined();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("has the size lists", () => {
|
|
80
|
+
expect(TITLE_SIZES).toEqual([
|
|
81
|
+
"sm",
|
|
82
|
+
"md",
|
|
83
|
+
"lg",
|
|
84
|
+
"xl",
|
|
85
|
+
"2xl",
|
|
86
|
+
"3xl",
|
|
87
|
+
"4xl",
|
|
88
|
+
"5xl",
|
|
89
|
+
]);
|
|
90
|
+
expect(TEXT_SIZES).toEqual(["3xs", "2xs", "xs", "sm", "md", "lg"]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("uses md as the default font size", () => {
|
|
94
|
+
expect(titleFont()).toEqual({
|
|
95
|
+
fontSize: "1em",
|
|
96
|
+
lineHeight: 1.5,
|
|
97
|
+
fontWeight: 600,
|
|
98
|
+
});
|
|
99
|
+
expect(textFont()).toEqual({ fontSize: "1em", lineHeight: 1.625 });
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("gives the type scale in em of the host size", () => {
|
|
103
|
+
expect(titleFont("2xl")).toEqual({
|
|
104
|
+
fontSize: "1.5em",
|
|
105
|
+
lineHeight: 1.333,
|
|
106
|
+
fontWeight: 600,
|
|
107
|
+
});
|
|
108
|
+
expect(titleFont("lg").fontSize).toBe("1.125em");
|
|
109
|
+
expect(textFont("sm")).toEqual({ fontSize: ".875em", lineHeight: 1.429 });
|
|
110
|
+
expect(textFont("3xs").fontSize).toBe(".625em");
|
|
111
|
+
expect(textFont("2xs").fontSize).toBe(".6875em");
|
|
112
|
+
expect(textFont("xs").fontSize).toBe(".75em");
|
|
113
|
+
expect(textFont("lg").fontSize).toBe("1.125em");
|
|
114
|
+
expect(FONT_FAMILY).toContain("-apple-system, ui-sans-serif, system-ui");
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("lets the surface inherit the typography of the host", () => {
|
|
118
|
+
expect(STANDARD_CSS).toContain(".a2ui-surface{font:inherit;color:inherit}");
|
|
119
|
+
expect(STANDARD_CSS).not.toContain("font-family");
|
|
120
|
+
expect(STANDARD_CSS).toContain(
|
|
121
|
+
":where(.a2ui-surface) :where(h2){font-size:1.5em;font-weight:600;line-height:1.3}",
|
|
122
|
+
);
|
|
123
|
+
// The list reset belongs to the List component, not to Markdown.
|
|
124
|
+
expect(STANDARD_CSS).not.toMatch(/\.a2ui-surface :is\(ul,ol\)/);
|
|
125
|
+
expect(STANDARD_CSS).toContain(
|
|
126
|
+
'[data-a2ui-row="spaceBetween"]>[data-a2ui-text]:last-child:not(:first-child){text-align:right',
|
|
127
|
+
);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("gives a focusable scroll container a visible focus ring", () => {
|
|
131
|
+
expect(STANDARD_CSS).toContain(
|
|
132
|
+
"[data-a2ui-scroll]:focus-visible{outline:2px solid var(--a2ui-color-focus, #0285ff);outline-offset:2px}",
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("uses the documented catalog id", () => {
|
|
137
|
+
expect(STANDARD_CATALOG_ID).toBe("copilotkit/standard@1");
|
|
138
|
+
});
|
|
139
|
+
});
|