@a2ui/web_core 0.8.0 → 0.9.1-alpha.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/.tsbuildinfo +1 -0
- package/LICENSE +203 -0
- package/README.md +50 -4
- package/package.json +42 -72
- package/{dist/src → src}/v0_8/data/guards.js +13 -13
- package/src/v0_8/data/guards.test.d.ts +2 -0
- package/src/v0_8/data/guards.test.d.ts.map +1 -0
- package/src/v0_8/data/guards.test.js +174 -0
- package/src/v0_8/data/guards.test.js.map +1 -0
- package/{dist/src → src}/v0_8/data/model-processor.d.ts +1 -1
- package/{dist/src → src}/v0_8/data/model-processor.d.ts.map +1 -1
- package/{dist/src → src}/v0_8/data/model-processor.js +51 -40
- package/src/v0_8/data/model-processor.js.map +1 -0
- package/src/v0_8/data/model-processor.test.d.ts +2 -0
- package/src/v0_8/data/model-processor.test.d.ts.map +1 -0
- package/src/v0_8/data/model-processor.test.js +712 -0
- package/src/v0_8/data/model-processor.test.js.map +1 -0
- package/src/v0_8/errors.d.ts +35 -0
- package/src/v0_8/errors.d.ts.map +1 -0
- package/src/v0_8/errors.js +65 -0
- package/src/v0_8/errors.js.map +1 -0
- package/src/v0_8/events/validation-event.d.ts.map +1 -0
- package/{dist/src → src}/v0_8/events/validation-event.js.map +1 -1
- package/{dist/src → src}/v0_8/index.d.ts +35 -4
- package/{dist/src → src}/v0_8/index.d.ts.map +1 -1
- package/src/v0_8/index.js +28 -0
- package/src/v0_8/index.js.map +1 -0
- package/src/v0_8/schema/common-types.d.ts +1189 -0
- package/src/v0_8/schema/common-types.d.ts.map +1 -0
- package/src/v0_8/schema/common-types.js +381 -0
- package/src/v0_8/schema/common-types.js.map +1 -0
- package/src/v0_8/schema/server-to-client.d.ts +17949 -0
- package/src/v0_8/schema/server-to-client.d.ts.map +1 -0
- package/src/v0_8/schema/server-to-client.js +228 -0
- package/src/v0_8/schema/server-to-client.js.map +1 -0
- package/src/v0_8/schema/verify-schema.test.d.ts +17 -0
- package/src/v0_8/schema/verify-schema.test.d.ts.map +1 -0
- package/src/v0_8/schema/verify-schema.test.js +167 -0
- package/src/v0_8/schema/verify-schema.test.js.map +1 -0
- package/{dist/src → src}/v0_8/schemas/server_to_client.json +1 -1
- package/src/v0_8/schemas/server_to_client_with_standard_catalog.json +817 -787
- package/{dist/src → src}/v0_8/schemas/standard_catalog_definition.json +26 -0
- package/{dist/src → src}/v0_8/styles/behavior.js +13 -13
- package/{dist/src → src}/v0_8/styles/border.js +13 -13
- package/{dist/src → src}/v0_8/styles/colors.js +13 -13
- package/{dist/src → src}/v0_8/styles/colors.js.map +1 -1
- package/src/v0_8/styles/icons.d.ts +11 -0
- package/{dist/src → src}/v0_8/styles/icons.d.ts.map +1 -1
- package/{dist/src → src}/v0_8/styles/icons.js +17 -14
- package/{dist/src → src}/v0_8/styles/icons.js.map +1 -1
- package/src/v0_8/styles/index.js +35 -0
- package/{dist/src → src}/v0_8/styles/layout.js +13 -13
- package/{dist/src → src}/v0_8/styles/layout.js.map +1 -1
- package/src/v0_8/styles/opacity.js +24 -0
- package/src/v0_8/{events/index.ts → styles/shared.js} +3 -4
- package/src/v0_8/styles/styles.test.d.ts +2 -0
- package/src/v0_8/styles/styles.test.d.ts.map +1 -0
- package/src/v0_8/styles/styles.test.js +86 -0
- package/src/v0_8/styles/styles.test.js.map +1 -0
- package/{dist/src → src}/v0_8/styles/type.js +13 -13
- package/{dist/src → src}/v0_8/styles/utils.js +13 -13
- package/{dist/src → src}/v0_8/types/client-event.d.ts +10 -8
- package/src/v0_8/types/client-event.d.ts.map +1 -0
- package/src/v0_8/types/client-event.js +17 -0
- package/src/v0_8/types/colors.js +19 -0
- package/src/v0_8/types/components.d.ts +41 -0
- package/src/v0_8/types/components.d.ts.map +1 -0
- package/src/v0_8/types/components.js +17 -0
- package/src/v0_8/types/primitives.d.ts +9 -0
- package/src/v0_8/types/primitives.d.ts.map +1 -0
- package/src/v0_8/types/primitives.js +17 -0
- package/{dist/src → src}/v0_8/types/types.d.ts +44 -22
- package/src/v0_8/types/types.d.ts.map +1 -0
- package/src/v0_8/types/types.js +17 -0
- package/src/v0_9/basic_catalog/components/basic_components.d.ts +3359 -0
- package/src/v0_9/basic_catalog/components/basic_components.d.ts.map +1 -0
- package/src/v0_9/basic_catalog/components/basic_components.js +448 -0
- package/src/v0_9/basic_catalog/components/basic_components.js.map +1 -0
- package/src/v0_9/basic_catalog/components/basic_components.test.d.ts +2 -0
- package/src/v0_9/basic_catalog/components/basic_components.test.d.ts.map +1 -0
- package/src/v0_9/basic_catalog/components/basic_components.test.js +46 -0
- package/src/v0_9/basic_catalog/components/basic_components.test.js.map +1 -0
- package/src/v0_9/basic_catalog/expressions/expression_parser.d.ts +38 -0
- package/src/v0_9/basic_catalog/expressions/expression_parser.d.ts.map +1 -0
- package/src/v0_9/basic_catalog/expressions/expression_parser.js +294 -0
- package/src/v0_9/basic_catalog/expressions/expression_parser.js.map +1 -0
- package/src/v0_9/basic_catalog/expressions/expression_parser.test.d.ts +2 -0
- package/src/v0_9/basic_catalog/expressions/expression_parser.test.d.ts.map +1 -0
- package/src/v0_9/basic_catalog/expressions/expression_parser.test.js +126 -0
- package/src/v0_9/basic_catalog/expressions/expression_parser.test.js.map +1 -0
- package/src/v0_9/basic_catalog/functions/basic_functions.d.ts +136 -0
- package/src/v0_9/basic_catalog/functions/basic_functions.d.ts.map +1 -0
- package/src/v0_9/basic_catalog/functions/basic_functions.js +316 -0
- package/src/v0_9/basic_catalog/functions/basic_functions.js.map +1 -0
- package/src/v0_9/basic_catalog/functions/basic_functions.test.d.ts +2 -0
- package/src/v0_9/basic_catalog/functions/basic_functions.test.d.ts.map +1 -0
- package/src/v0_9/basic_catalog/functions/basic_functions.test.js +301 -0
- package/src/v0_9/basic_catalog/functions/basic_functions.test.js.map +1 -0
- package/src/v0_9/basic_catalog/functions/basic_functions_api.d.ts +930 -0
- package/src/v0_9/basic_catalog/functions/basic_functions_api.d.ts.map +1 -0
- package/src/v0_9/basic_catalog/functions/basic_functions_api.js +466 -0
- package/src/v0_9/basic_catalog/functions/basic_functions_api.js.map +1 -0
- package/src/v0_9/basic_catalog/index.d.ts +5 -0
- package/src/v0_9/basic_catalog/index.d.ts.map +1 -0
- package/src/v0_9/basic_catalog/index.js +20 -0
- package/src/v0_9/basic_catalog/index.js.map +1 -0
- package/src/v0_9/catalog/function_invoker.d.ts +12 -0
- package/src/v0_9/catalog/function_invoker.d.ts.map +1 -0
- package/src/v0_9/catalog/function_invoker.js +17 -0
- package/src/v0_9/catalog/function_invoker.js.map +1 -0
- package/src/v0_9/catalog/types.d.ts +80 -0
- package/src/v0_9/catalog/types.d.ts.map +1 -0
- package/src/v0_9/catalog/types.js +68 -0
- package/src/v0_9/catalog/types.js.map +1 -0
- package/src/v0_9/catalog/types.test.d.ts +2 -0
- package/src/v0_9/catalog/types.test.d.ts.map +1 -0
- package/src/v0_9/catalog/types.test.js +89 -0
- package/src/v0_9/catalog/types.test.js.map +1 -0
- package/src/v0_9/common/events.d.ts +45 -0
- package/src/v0_9/common/events.d.ts.map +1 -0
- package/src/v0_9/common/events.js +58 -0
- package/src/v0_9/common/events.js.map +1 -0
- package/src/v0_9/common/events.test.d.ts +2 -0
- package/src/v0_9/common/events.test.d.ts.map +1 -0
- package/src/v0_9/common/events.test.js +58 -0
- package/src/v0_9/common/events.test.js.map +1 -0
- package/src/v0_9/errors.d.ts +40 -0
- package/src/v0_9/errors.d.ts.map +1 -0
- package/src/v0_9/errors.js +69 -0
- package/src/v0_9/errors.js.map +1 -0
- package/src/v0_9/index.d.ts +152 -0
- package/src/v0_9/index.d.ts.map +1 -0
- package/src/v0_9/index.js +41 -0
- package/src/v0_9/index.js.map +1 -0
- package/src/v0_9/processing/message-processor.d.ts +70 -0
- package/src/v0_9/processing/message-processor.d.ts.map +1 -0
- package/src/v0_9/processing/message-processor.js +289 -0
- package/src/v0_9/processing/message-processor.js.map +1 -0
- package/src/v0_9/processing/message-processor.test.js +547 -0
- package/src/v0_9/processing/message-processor.test.js.map +1 -0
- package/src/v0_9/reactivity/signals.d.ts +51 -0
- package/src/v0_9/reactivity/signals.d.ts.map +1 -0
- package/src/v0_9/reactivity/signals.js +17 -0
- package/src/v0_9/reactivity/signals.js.map +1 -0
- package/src/{v0_8/events/base.ts → v0_9/reactivity/signals.test.d.ts} +14 -10
- package/src/v0_9/reactivity/signals.test.d.ts.map +1 -0
- package/src/v0_9/reactivity/signals.test.js +108 -0
- package/src/v0_9/reactivity/signals.test.js.map +1 -0
- package/src/v0_9/rendering/component-context.d.ts +37 -0
- package/src/v0_9/rendering/component-context.d.ts.map +1 -0
- package/src/v0_9/rendering/component-context.js +50 -0
- package/src/v0_9/rendering/component-context.js.map +1 -0
- package/src/v0_9/rendering/component-context.test.d.ts +2 -0
- package/src/v0_9/rendering/component-context.test.d.ts.map +1 -0
- package/src/v0_9/rendering/component-context.test.js +68 -0
- package/src/v0_9/rendering/component-context.test.js.map +1 -0
- package/src/v0_9/rendering/data-context.d.ts +99 -0
- package/src/v0_9/rendering/data-context.d.ts.map +1 -0
- package/src/v0_9/rendering/data-context.js +311 -0
- package/src/v0_9/rendering/data-context.js.map +1 -0
- package/src/v0_9/rendering/data-context.test.js +379 -0
- package/src/v0_9/rendering/data-context.test.js.map +1 -0
- package/src/v0_9/rendering/generic-binder.d.ts +122 -0
- package/src/v0_9/rendering/generic-binder.d.ts.map +1 -0
- package/src/v0_9/rendering/generic-binder.js +315 -0
- package/src/v0_9/rendering/generic-binder.js.map +1 -0
- package/src/v0_9/rendering/generic-binder.test.d.ts +2 -0
- package/src/v0_9/rendering/generic-binder.test.d.ts.map +1 -0
- package/src/v0_9/rendering/generic-binder.test.js +166 -0
- package/src/v0_9/rendering/generic-binder.test.js.map +1 -0
- package/src/v0_9/schema/client-capabilities.d.ts +34 -0
- package/src/v0_9/schema/client-capabilities.d.ts.map +1 -0
- package/src/v0_9/schema/client-capabilities.js +17 -0
- package/src/v0_9/schema/client-capabilities.js.map +1 -0
- package/src/v0_9/schema/client-to-server.d.ts +208 -0
- package/src/v0_9/schema/client-to-server.d.ts.map +1 -0
- package/src/v0_9/schema/client-to-server.js +104 -0
- package/src/v0_9/schema/client-to-server.js.map +1 -0
- package/src/v0_9/schema/client-to-server.test.d.ts +2 -0
- package/src/v0_9/schema/client-to-server.test.d.ts.map +1 -0
- package/src/v0_9/schema/client-to-server.test.js +85 -0
- package/src/v0_9/schema/client-to-server.test.js.map +1 -0
- package/{dist/src → src}/v0_9/schema/common-types.d.ts +318 -88
- package/src/v0_9/schema/common-types.d.ts.map +1 -0
- package/src/v0_9/schema/common-types.js +141 -0
- package/src/v0_9/schema/common-types.js.map +1 -0
- package/src/v0_9/schema/index.d.ts +5 -0
- package/src/v0_9/schema/index.d.ts.map +1 -0
- package/src/v0_9/schema/index.js +20 -0
- package/src/v0_9/schema/index.js.map +1 -0
- package/src/v0_9/schema/server-to-client.d.ts +307 -0
- package/src/v0_9/schema/server-to-client.d.ts.map +1 -0
- package/src/v0_9/schema/server-to-client.js +92 -0
- package/src/v0_9/schema/server-to-client.js.map +1 -0
- package/src/v0_9/schema/verify-schema.test.d.ts +17 -0
- package/src/v0_9/schema/verify-schema.test.d.ts.map +1 -0
- package/src/v0_9/schema/verify-schema.test.js +174 -0
- package/src/v0_9/schema/verify-schema.test.js.map +1 -0
- package/src/v0_9/schemas/basic_catalog.json +1387 -0
- package/src/v0_9/schemas/client_capabilities.json +97 -0
- package/src/v0_9/schemas/client_data_model.json +22 -0
- package/src/v0_9/schemas/client_to_server.json +104 -0
- package/src/v0_9/schemas/client_to_server_list.json +19 -0
- package/src/v0_9/schemas/common_types.json +315 -0
- package/src/v0_9/schemas/sample.json +22 -0
- package/src/v0_9/schemas/server_capabilities.json +26 -0
- package/src/v0_9/schemas/server_to_client.json +131 -0
- package/src/v0_9/schemas/server_to_client_list.json +19 -0
- package/src/v0_9/state/component-model.d.ts +36 -0
- package/src/v0_9/state/component-model.d.ts.map +1 -0
- package/src/v0_9/state/component-model.js +65 -0
- package/src/v0_9/state/component-model.js.map +1 -0
- package/{dist/src → src}/v0_9/state/component-model.test.js +23 -0
- package/src/v0_9/state/component-model.test.js.map +1 -0
- package/src/v0_9/state/data-model.d.ts +75 -0
- package/src/v0_9/state/data-model.d.ts.map +1 -0
- package/src/v0_9/state/data-model.js +235 -0
- package/src/v0_9/state/data-model.js.map +1 -0
- package/{dist/src → src}/v0_9/state/data-model.test.js +77 -17
- package/src/v0_9/state/data-model.test.js.map +1 -0
- package/src/v0_9/state/surface-components-model.d.ts +45 -0
- package/src/v0_9/state/surface-components-model.d.ts.map +1 -0
- package/src/v0_9/state/surface-components-model.js +86 -0
- package/src/v0_9/state/surface-components-model.js.map +1 -0
- package/{dist/src → src}/v0_9/state/surface-components-model.test.js +44 -2
- package/src/v0_9/state/surface-components-model.test.js.map +1 -0
- package/{dist/src → src}/v0_9/state/surface-group-model.d.ts +28 -1
- package/src/v0_9/state/surface-group-model.d.ts.map +1 -0
- package/{dist/src → src}/v0_9/state/surface-group-model.js +44 -1
- package/src/v0_9/state/surface-group-model.js.map +1 -0
- package/{dist/src → src}/v0_9/state/surface-group-model.test.js +47 -6
- package/src/v0_9/state/surface-group-model.test.js.map +1 -0
- package/src/v0_9/state/surface-model.d.ts +62 -0
- package/src/v0_9/state/surface-model.d.ts.map +1 -0
- package/src/v0_9/state/surface-model.js +101 -0
- package/src/v0_9/state/surface-model.js.map +1 -0
- package/src/v0_9/state/surface-model.test.js +93 -0
- package/src/v0_9/state/surface-model.test.js.map +1 -0
- package/src/v0_9/test/function_execution.spec.d.ts +17 -0
- package/src/v0_9/test/function_execution.spec.d.ts.map +1 -0
- package/src/v0_9/test/function_execution.spec.js +127 -0
- package/src/v0_9/test/function_execution.spec.js.map +1 -0
- package/src/v0_9/test/test-utils.d.ts.map +1 -0
- package/{dist/src → src}/v0_9/test/test-utils.js +15 -0
- package/src/v0_9/test/test-utils.js.map +1 -0
- package/dist/.tsbuildinfo +0 -1
- package/dist/src/v0_8/data/model-processor.js.map +0 -1
- package/dist/src/v0_8/events/validation-event.d.ts.map +0 -1
- package/dist/src/v0_8/index.js +0 -12
- package/dist/src/v0_8/index.js.map +0 -1
- package/dist/src/v0_8/schemas/server_to_client_with_standard_catalog.json +0 -823
- package/dist/src/v0_8/styles/icons.d.ts +0 -11
- package/dist/src/v0_8/styles/index.js +0 -35
- package/dist/src/v0_8/styles/opacity.js +0 -24
- package/dist/src/v0_8/styles/shared.js +0 -17
- package/dist/src/v0_8/types/client-event.d.ts.map +0 -1
- package/dist/src/v0_8/types/client-event.js +0 -17
- package/dist/src/v0_8/types/colors.js +0 -19
- package/dist/src/v0_8/types/components.d.ts +0 -176
- package/dist/src/v0_8/types/components.d.ts.map +0 -1
- package/dist/src/v0_8/types/components.js +0 -17
- package/dist/src/v0_8/types/primitives.d.ts +0 -43
- package/dist/src/v0_8/types/primitives.d.ts.map +0 -1
- package/dist/src/v0_8/types/primitives.js +0 -17
- package/dist/src/v0_8/types/types.d.ts.map +0 -1
- package/dist/src/v0_8/types/types.js +0 -17
- package/dist/src/v0_9/catalog/types.d.ts +0 -27
- package/dist/src/v0_9/catalog/types.d.ts.map +0 -1
- package/dist/src/v0_9/catalog/types.js +0 -11
- package/dist/src/v0_9/catalog/types.js.map +0 -1
- package/dist/src/v0_9/common/events.d.ts +0 -24
- package/dist/src/v0_9/common/events.d.ts.map +0 -1
- package/dist/src/v0_9/common/events.js +0 -29
- package/dist/src/v0_9/common/events.js.map +0 -1
- package/dist/src/v0_9/index.d.ts +0 -11
- package/dist/src/v0_9/index.d.ts.map +0 -1
- package/dist/src/v0_9/index.js +0 -11
- package/dist/src/v0_9/index.js.map +0 -1
- package/dist/src/v0_9/processing/message-processor.d.ts +0 -34
- package/dist/src/v0_9/processing/message-processor.d.ts.map +0 -1
- package/dist/src/v0_9/processing/message-processor.js +0 -128
- package/dist/src/v0_9/processing/message-processor.js.map +0 -1
- package/dist/src/v0_9/processing/message-processor.test.js +0 -112
- package/dist/src/v0_9/processing/message-processor.test.js.map +0 -1
- package/dist/src/v0_9/rendering/component-context.d.ts +0 -17
- package/dist/src/v0_9/rendering/component-context.d.ts.map +0 -1
- package/dist/src/v0_9/rendering/component-context.js +0 -21
- package/dist/src/v0_9/rendering/component-context.js.map +0 -1
- package/dist/src/v0_9/rendering/data-context.d.ts +0 -37
- package/dist/src/v0_9/rendering/data-context.d.ts.map +0 -1
- package/dist/src/v0_9/rendering/data-context.js +0 -97
- package/dist/src/v0_9/rendering/data-context.js.map +0 -1
- package/dist/src/v0_9/rendering/data-context.test.js +0 -71
- package/dist/src/v0_9/rendering/data-context.test.js.map +0 -1
- package/dist/src/v0_9/schema/common-types.d.ts.map +0 -1
- package/dist/src/v0_9/schema/common-types.js +0 -92
- package/dist/src/v0_9/schema/common-types.js.map +0 -1
- package/dist/src/v0_9/schema/index.d.ts +0 -3
- package/dist/src/v0_9/schema/index.d.ts.map +0 -1
- package/dist/src/v0_9/schema/index.js +0 -3
- package/dist/src/v0_9/schema/index.js.map +0 -1
- package/dist/src/v0_9/schema/server-to-client.d.ts +0 -84
- package/dist/src/v0_9/schema/server-to-client.d.ts.map +0 -1
- package/dist/src/v0_9/schema/server-to-client.js +0 -21
- package/dist/src/v0_9/schema/server-to-client.js.map +0 -1
- package/dist/src/v0_9/state/component-model.d.ts +0 -16
- package/dist/src/v0_9/state/component-model.d.ts.map +0 -1
- package/dist/src/v0_9/state/component-model.js +0 -24
- package/dist/src/v0_9/state/component-model.js.map +0 -1
- package/dist/src/v0_9/state/component-model.test.js.map +0 -1
- package/dist/src/v0_9/state/data-model.d.ts +0 -47
- package/dist/src/v0_9/state/data-model.d.ts.map +0 -1
- package/dist/src/v0_9/state/data-model.js +0 -191
- package/dist/src/v0_9/state/data-model.js.map +0 -1
- package/dist/src/v0_9/state/data-model.test.js.map +0 -1
- package/dist/src/v0_9/state/surface-components-model.d.ts +0 -19
- package/dist/src/v0_9/state/surface-components-model.d.ts.map +0 -1
- package/dist/src/v0_9/state/surface-components-model.js +0 -42
- package/dist/src/v0_9/state/surface-components-model.js.map +0 -1
- package/dist/src/v0_9/state/surface-components-model.test.js.map +0 -1
- package/dist/src/v0_9/state/surface-group-model.d.ts.map +0 -1
- package/dist/src/v0_9/state/surface-group-model.js.map +0 -1
- package/dist/src/v0_9/state/surface-group-model.test.js.map +0 -1
- package/dist/src/v0_9/state/surface-model.d.ts +0 -23
- package/dist/src/v0_9/state/surface-model.d.ts.map +0 -1
- package/dist/src/v0_9/state/surface-model.js +0 -28
- package/dist/src/v0_9/state/surface-model.js.map +0 -1
- package/dist/src/v0_9/state/surface-model.test.js +0 -39
- package/dist/src/v0_9/state/surface-model.test.js.map +0 -1
- package/dist/src/v0_9/test/test-utils.d.ts.map +0 -1
- package/dist/src/v0_9/test/test-utils.js.map +0 -1
- package/src/v0_8/data/guards.ts +0 -236
- package/src/v0_8/data/model-processor.ts +0 -855
- package/src/v0_8/events/validation-event.ts +0 -66
- package/src/v0_8/index.ts +0 -12
- package/src/v0_8/styles/behavior.ts +0 -55
- package/src/v0_8/styles/border.ts +0 -42
- package/src/v0_8/styles/colors.ts +0 -100
- package/src/v0_8/styles/icons.ts +0 -60
- package/src/v0_8/styles/index.ts +0 -37
- package/src/v0_8/styles/layout.ts +0 -235
- package/src/v0_8/styles/opacity.ts +0 -24
- package/src/v0_8/styles/shared.ts +0 -17
- package/src/v0_8/styles/type.ts +0 -156
- package/src/v0_8/styles/utils.ts +0 -104
- package/src/v0_8/types/client-event.ts +0 -80
- package/src/v0_8/types/colors.ts +0 -66
- package/src/v0_8/types/components.ts +0 -213
- package/src/v0_8/types/primitives.ts +0 -60
- package/src/v0_8/types/types.ts +0 -557
- package/src/v0_9/catalog/types.ts +0 -38
- package/src/v0_9/common/events.ts +0 -44
- package/src/v0_9/index.ts +0 -12
- package/src/v0_9/processing/message-processor.test.ts +0 -133
- package/src/v0_9/processing/message-processor.ts +0 -150
- package/src/v0_9/rendering/component-context.ts +0 -36
- package/src/v0_9/rendering/data-context.test.ts +0 -85
- package/src/v0_9/rendering/data-context.ts +0 -110
- package/src/v0_9/schema/common-types.ts +0 -125
- package/src/v0_9/schema/index.ts +0 -2
- package/src/v0_9/schema/server-to-client.ts +0 -23
- package/src/v0_9/state/component-model.test.ts +0 -50
- package/src/v0_9/state/component-model.ts +0 -32
- package/src/v0_9/state/data-model.test.ts +0 -257
- package/src/v0_9/state/data-model.ts +0 -239
- package/src/v0_9/state/surface-components-model.test.ts +0 -59
- package/src/v0_9/state/surface-components-model.ts +0 -48
- package/src/v0_9/state/surface-group-model.test.ts +0 -82
- package/src/v0_9/state/surface-group-model.ts +0 -66
- package/src/v0_9/state/surface-model.test.ts +0 -44
- package/src/v0_9/state/surface-model.ts +0 -39
- package/src/v0_9/test/test-utils.ts +0 -22
- /package/{dist/src → src}/v0_8/data/guards.d.ts +0 -0
- /package/{dist/src → src}/v0_8/data/guards.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/data/guards.js.map +0 -0
- /package/{dist/src → src}/v0_8/events/base.d.ts +0 -0
- /package/{dist/src → src}/v0_8/events/base.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/events/base.js +0 -0
- /package/{dist/src → src}/v0_8/events/base.js.map +0 -0
- /package/{dist/src → src}/v0_8/events/index.d.ts +0 -0
- /package/{dist/src → src}/v0_8/events/index.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/events/index.js +0 -0
- /package/{dist/src → src}/v0_8/events/index.js.map +0 -0
- /package/{dist/src → src}/v0_8/events/validation-event.d.ts +0 -0
- /package/{dist/src → src}/v0_8/events/validation-event.js +0 -0
- /package/{dist/src → src}/v0_8/schemas/a2ui_client_capabilities_schema.json +0 -0
- /package/{dist/src → src}/v0_8/schemas/catalog_description_schema.json +0 -0
- /package/{dist/src → src}/v0_8/schemas/client_to_server.json +0 -0
- /package/{dist/src → src}/v0_8/styles/behavior.d.ts +0 -0
- /package/{dist/src → src}/v0_8/styles/behavior.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/styles/behavior.js.map +0 -0
- /package/{dist/src → src}/v0_8/styles/border.d.ts +0 -0
- /package/{dist/src → src}/v0_8/styles/border.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/styles/border.js.map +0 -0
- /package/{dist/src → src}/v0_8/styles/colors.d.ts +0 -0
- /package/{dist/src → src}/v0_8/styles/colors.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/styles/index.d.ts +0 -0
- /package/{dist/src → src}/v0_8/styles/index.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/styles/index.js.map +0 -0
- /package/{dist/src → src}/v0_8/styles/layout.d.ts +0 -0
- /package/{dist/src → src}/v0_8/styles/layout.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/styles/opacity.d.ts +0 -0
- /package/{dist/src → src}/v0_8/styles/opacity.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/styles/opacity.js.map +0 -0
- /package/{dist/src → src}/v0_8/styles/shared.d.ts +0 -0
- /package/{dist/src → src}/v0_8/styles/shared.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/styles/shared.js.map +0 -0
- /package/{dist/src → src}/v0_8/styles/type.d.ts +0 -0
- /package/{dist/src → src}/v0_8/styles/type.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/styles/type.js.map +0 -0
- /package/{dist/src → src}/v0_8/styles/utils.d.ts +0 -0
- /package/{dist/src → src}/v0_8/styles/utils.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/styles/utils.js.map +0 -0
- /package/{dist/src → src}/v0_8/types/client-event.js.map +0 -0
- /package/{dist/src → src}/v0_8/types/colors.d.ts +0 -0
- /package/{dist/src → src}/v0_8/types/colors.d.ts.map +0 -0
- /package/{dist/src → src}/v0_8/types/colors.js.map +0 -0
- /package/{dist/src → src}/v0_8/types/components.js.map +0 -0
- /package/{dist/src → src}/v0_8/types/primitives.js.map +0 -0
- /package/{dist/src → src}/v0_8/types/types.js.map +0 -0
- /package/{dist/src → src}/v0_9/processing/message-processor.test.d.ts +0 -0
- /package/{dist/src → src}/v0_9/processing/message-processor.test.d.ts.map +0 -0
- /package/{dist/src → src}/v0_9/rendering/data-context.test.d.ts +0 -0
- /package/{dist/src → src}/v0_9/rendering/data-context.test.d.ts.map +0 -0
- /package/{dist/src → src}/v0_9/state/component-model.test.d.ts +0 -0
- /package/{dist/src → src}/v0_9/state/component-model.test.d.ts.map +0 -0
- /package/{dist/src → src}/v0_9/state/data-model.test.d.ts +0 -0
- /package/{dist/src → src}/v0_9/state/data-model.test.d.ts.map +0 -0
- /package/{dist/src → src}/v0_9/state/surface-components-model.test.d.ts +0 -0
- /package/{dist/src → src}/v0_9/state/surface-components-model.test.d.ts.map +0 -0
- /package/{dist/src → src}/v0_9/state/surface-group-model.test.d.ts +0 -0
- /package/{dist/src → src}/v0_9/state/surface-group-model.test.d.ts.map +0 -0
- /package/{dist/src → src}/v0_9/state/surface-model.test.d.ts +0 -0
- /package/{dist/src → src}/v0_9/state/surface-model.test.d.ts.map +0 -0
- /package/{dist/src → src}/v0_9/test/test-utils.d.ts +0 -0
|
@@ -1,855 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2025 Google LLC
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
ServerToClientMessage,
|
|
19
|
-
AnyComponentNode,
|
|
20
|
-
BeginRenderingMessage,
|
|
21
|
-
DataArray,
|
|
22
|
-
DataMap,
|
|
23
|
-
DataModelUpdate,
|
|
24
|
-
DataValue,
|
|
25
|
-
DeleteSurfaceMessage,
|
|
26
|
-
ResolvedMap,
|
|
27
|
-
ResolvedValue,
|
|
28
|
-
Surface,
|
|
29
|
-
SurfaceID,
|
|
30
|
-
SurfaceUpdateMessage,
|
|
31
|
-
MessageProcessor,
|
|
32
|
-
ValueMap,
|
|
33
|
-
DataObject,
|
|
34
|
-
} from "../types/types";
|
|
35
|
-
import {
|
|
36
|
-
isComponentArrayReference,
|
|
37
|
-
isObject,
|
|
38
|
-
isPath,
|
|
39
|
-
isResolvedAudioPlayer,
|
|
40
|
-
isResolvedButton,
|
|
41
|
-
isResolvedCard,
|
|
42
|
-
isResolvedCheckbox,
|
|
43
|
-
isResolvedColumn,
|
|
44
|
-
isResolvedDateTimeInput,
|
|
45
|
-
isResolvedDivider,
|
|
46
|
-
isResolvedIcon,
|
|
47
|
-
isResolvedImage,
|
|
48
|
-
isResolvedList,
|
|
49
|
-
isResolvedModal,
|
|
50
|
-
isResolvedMultipleChoice,
|
|
51
|
-
isResolvedRow,
|
|
52
|
-
isResolvedSlider,
|
|
53
|
-
isResolvedTabs,
|
|
54
|
-
isResolvedText,
|
|
55
|
-
isResolvedTextField,
|
|
56
|
-
isResolvedVideo,
|
|
57
|
-
isValueMap,
|
|
58
|
-
} from "./guards.js";
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Processes and consolidates A2UIProtocolMessage objects into a structured,
|
|
62
|
-
* hierarchical model of UI surfaces.
|
|
63
|
-
*/
|
|
64
|
-
export class A2uiMessageProcessor implements MessageProcessor {
|
|
65
|
-
static readonly DEFAULT_SURFACE_ID = "@default";
|
|
66
|
-
|
|
67
|
-
private mapCtor: MapConstructor = Map;
|
|
68
|
-
private arrayCtor: ArrayConstructor = Array;
|
|
69
|
-
private setCtor: SetConstructor = Set;
|
|
70
|
-
private objCtor: ObjectConstructor = Object;
|
|
71
|
-
private surfaces: Map<SurfaceID, Surface>;
|
|
72
|
-
|
|
73
|
-
constructor(
|
|
74
|
-
readonly opts: {
|
|
75
|
-
mapCtor: MapConstructor;
|
|
76
|
-
arrayCtor: ArrayConstructor;
|
|
77
|
-
setCtor: SetConstructor;
|
|
78
|
-
objCtor: ObjectConstructor;
|
|
79
|
-
} = { mapCtor: Map, arrayCtor: Array, setCtor: Set, objCtor: Object }
|
|
80
|
-
) {
|
|
81
|
-
this.arrayCtor = opts.arrayCtor;
|
|
82
|
-
this.mapCtor = opts.mapCtor;
|
|
83
|
-
this.setCtor = opts.setCtor;
|
|
84
|
-
this.objCtor = opts.objCtor;
|
|
85
|
-
|
|
86
|
-
this.surfaces = new opts.mapCtor();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
getSurfaces(): ReadonlyMap<string, Surface> {
|
|
90
|
-
return this.surfaces;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
clearSurfaces() {
|
|
94
|
-
this.surfaces.clear();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
processMessages(messages: ServerToClientMessage[]): void {
|
|
98
|
-
for (const message of messages) {
|
|
99
|
-
if (message.beginRendering) {
|
|
100
|
-
this.handleBeginRendering(
|
|
101
|
-
message.beginRendering,
|
|
102
|
-
message.beginRendering.surfaceId
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (message.surfaceUpdate) {
|
|
107
|
-
this.handleSurfaceUpdate(
|
|
108
|
-
message.surfaceUpdate,
|
|
109
|
-
message.surfaceUpdate.surfaceId
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (message.dataModelUpdate) {
|
|
114
|
-
this.handleDataModelUpdate(
|
|
115
|
-
message.dataModelUpdate,
|
|
116
|
-
message.dataModelUpdate.surfaceId
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (message.deleteSurface) {
|
|
121
|
-
this.handleDeleteSurface(message.deleteSurface);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Retrieves the data for a given component node and a relative path string.
|
|
128
|
-
* This correctly handles the special `.` path, which refers to the node's
|
|
129
|
-
* own data context.
|
|
130
|
-
*/
|
|
131
|
-
getData(
|
|
132
|
-
node: AnyComponentNode,
|
|
133
|
-
relativePath: string,
|
|
134
|
-
surfaceId = A2uiMessageProcessor.DEFAULT_SURFACE_ID
|
|
135
|
-
): DataValue | null {
|
|
136
|
-
const surface = this.getOrCreateSurface(surfaceId);
|
|
137
|
-
if (!surface) return null;
|
|
138
|
-
|
|
139
|
-
let finalPath: string;
|
|
140
|
-
|
|
141
|
-
// The special `.` path means the final path is the node's data context
|
|
142
|
-
// path and so we return the dataContextPath as-is.
|
|
143
|
-
if (relativePath === "." || relativePath === "") {
|
|
144
|
-
finalPath = node.dataContextPath ?? "/";
|
|
145
|
-
} else {
|
|
146
|
-
// For all other paths, resolve them against the node's context.
|
|
147
|
-
finalPath = this.resolvePath(relativePath, node.dataContextPath);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return this.getDataByPath(surface.dataModel, finalPath);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
setData(
|
|
154
|
-
node: AnyComponentNode | null,
|
|
155
|
-
relativePath: string,
|
|
156
|
-
value: DataValue,
|
|
157
|
-
surfaceId = A2uiMessageProcessor.DEFAULT_SURFACE_ID
|
|
158
|
-
): void {
|
|
159
|
-
if (!node) {
|
|
160
|
-
console.warn("No component node set");
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const surface = this.getOrCreateSurface(surfaceId);
|
|
165
|
-
if (!surface) return;
|
|
166
|
-
|
|
167
|
-
let finalPath: string;
|
|
168
|
-
|
|
169
|
-
// The special `.` path means the final path is the node's data context
|
|
170
|
-
// path and so we return the dataContextPath as-is.
|
|
171
|
-
if (relativePath === "." || relativePath === "") {
|
|
172
|
-
finalPath = node.dataContextPath ?? "/";
|
|
173
|
-
} else {
|
|
174
|
-
// For all other paths, resolve them against the node's context.
|
|
175
|
-
finalPath = this.resolvePath(relativePath, node.dataContextPath);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
this.setDataByPath(surface.dataModel, finalPath, value);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
resolvePath(path: string, dataContextPath?: string): string {
|
|
182
|
-
// If the path is absolute, it overrides any context.
|
|
183
|
-
if (path.startsWith("/")) {
|
|
184
|
-
return path;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (dataContextPath && dataContextPath !== "/") {
|
|
188
|
-
// Ensure there's exactly one slash between the context and the path.
|
|
189
|
-
return dataContextPath.endsWith("/")
|
|
190
|
-
? `${dataContextPath}${path}`
|
|
191
|
-
: `${dataContextPath}/${path}`;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Fallback for no context or root context: make it an absolute path.
|
|
195
|
-
return `/${path}`;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
private parseIfJsonString(value: DataValue): DataValue {
|
|
199
|
-
if (typeof value !== "string") {
|
|
200
|
-
return value;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const trimmedValue = value.trim();
|
|
204
|
-
if (
|
|
205
|
-
(trimmedValue.startsWith("{") && trimmedValue.endsWith("}")) ||
|
|
206
|
-
(trimmedValue.startsWith("[") && trimmedValue.endsWith("]"))
|
|
207
|
-
) {
|
|
208
|
-
try {
|
|
209
|
-
// It looks like JSON, attempt to parse it.
|
|
210
|
-
return JSON.parse(value);
|
|
211
|
-
} catch (e) {
|
|
212
|
-
// It looked like JSON but wasn't. Keep the original string.
|
|
213
|
-
console.warn(
|
|
214
|
-
`Failed to parse potential JSON string: "${value.substring(
|
|
215
|
-
0,
|
|
216
|
-
50
|
|
217
|
-
)}..."`,
|
|
218
|
-
e
|
|
219
|
-
);
|
|
220
|
-
return value; // Return original string
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// It's a string, but not JSON-like.
|
|
225
|
-
return value;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Converts a specific array format [{key: "...", value_string: "..."}, ...]
|
|
230
|
-
* into a standard Map. It also attempts to parse any string values that
|
|
231
|
-
* appear to be stringified JSON.
|
|
232
|
-
*/
|
|
233
|
-
private convertKeyValueArrayToMap(arr: DataArray): DataMap {
|
|
234
|
-
const map = new this.mapCtor<string, DataValue>();
|
|
235
|
-
for (const item of arr) {
|
|
236
|
-
if (!isObject(item) || !("key" in item)) continue;
|
|
237
|
-
|
|
238
|
-
const key = item.key as string;
|
|
239
|
-
|
|
240
|
-
// Find the value, which is in a property prefixed with "value".
|
|
241
|
-
const valueKey = this.findValueKey(item);
|
|
242
|
-
if (!valueKey) continue;
|
|
243
|
-
|
|
244
|
-
let value: DataValue = item[valueKey];
|
|
245
|
-
// It's a valueMap. We must recursively convert it.
|
|
246
|
-
if (valueKey === "valueMap" && Array.isArray(value)) {
|
|
247
|
-
value = this.convertKeyValueArrayToMap(value);
|
|
248
|
-
} else if (typeof value === "string") {
|
|
249
|
-
value = this.parseIfJsonString(value);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
this.setDataByPath(map, key, value);
|
|
253
|
-
}
|
|
254
|
-
return map;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
private setDataByPath(root: DataMap, path: string, value: DataValue): void {
|
|
258
|
-
// Check if the incoming value is the special key-value array format.
|
|
259
|
-
if (
|
|
260
|
-
Array.isArray(value) &&
|
|
261
|
-
(value.length === 0 || (isObject(value[0]) && "key" in value[0]))
|
|
262
|
-
) {
|
|
263
|
-
// Check for "set primitive at path" convention:
|
|
264
|
-
// path: "/messages/123", contents: [{ key: ".", valueString: "hi" }]
|
|
265
|
-
if (value.length === 1 && isObject(value[0]) && value[0].key === ".") {
|
|
266
|
-
const item = value[0];
|
|
267
|
-
const valueKey = this.findValueKey(item);
|
|
268
|
-
|
|
269
|
-
if (valueKey) {
|
|
270
|
-
// Extract the primitive value
|
|
271
|
-
value = item[valueKey];
|
|
272
|
-
|
|
273
|
-
// We must still process this value in case it's a valueMap or
|
|
274
|
-
// a JSON string.
|
|
275
|
-
if (valueKey === "valueMap" && Array.isArray(value)) {
|
|
276
|
-
value = this.convertKeyValueArrayToMap(value);
|
|
277
|
-
} else if (typeof value === "string") {
|
|
278
|
-
value = this.parseIfJsonString(value);
|
|
279
|
-
}
|
|
280
|
-
// Now, `value` is the primitive (e.g., "hi"), and we continue
|
|
281
|
-
// the function.
|
|
282
|
-
} else {
|
|
283
|
-
// Malformed, but fall back to existing behavior.
|
|
284
|
-
value = this.convertKeyValueArrayToMap(value);
|
|
285
|
-
}
|
|
286
|
-
} else {
|
|
287
|
-
value = this.convertKeyValueArrayToMap(value);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const segments = this.normalizePath(path)
|
|
292
|
-
.split("/")
|
|
293
|
-
.filter((s) => s);
|
|
294
|
-
if (segments.length === 0) {
|
|
295
|
-
// Root data can either be a Map or an Object. If we receive an Object,
|
|
296
|
-
// however, we will normalize it to a proper Map.
|
|
297
|
-
if (value instanceof Map || isObject(value)) {
|
|
298
|
-
// Normalize an Object to a Map.
|
|
299
|
-
if (!(value instanceof Map) && isObject(value)) {
|
|
300
|
-
value = new this.mapCtor(Object.entries(value));
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
root.clear();
|
|
304
|
-
for (const [key, v] of value.entries()) {
|
|
305
|
-
root.set(key, v);
|
|
306
|
-
}
|
|
307
|
-
} else {
|
|
308
|
-
console.error("Cannot set root of DataModel to a non-Map value.");
|
|
309
|
-
}
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
let current: DataMap | DataArray = root;
|
|
314
|
-
for (let i = 0; i < segments.length - 1; i++) {
|
|
315
|
-
const segment = segments[i];
|
|
316
|
-
let target: DataValue | undefined;
|
|
317
|
-
|
|
318
|
-
if (current instanceof Map) {
|
|
319
|
-
target = current.get(segment);
|
|
320
|
-
} else if (Array.isArray(current) && /^\d+$/.test(segment)) {
|
|
321
|
-
target = current[parseInt(segment, 10)];
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (
|
|
325
|
-
target === undefined ||
|
|
326
|
-
typeof target !== "object" ||
|
|
327
|
-
target === null
|
|
328
|
-
) {
|
|
329
|
-
target = new this.mapCtor();
|
|
330
|
-
if (current instanceof this.mapCtor) {
|
|
331
|
-
current.set(segment, target);
|
|
332
|
-
} else if (Array.isArray(current)) {
|
|
333
|
-
current[parseInt(segment, 10)] = target;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
current = target as DataMap | DataArray;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
const finalSegment = segments[segments.length - 1];
|
|
340
|
-
const storedValue = value;
|
|
341
|
-
if (current instanceof this.mapCtor) {
|
|
342
|
-
current.set(finalSegment, storedValue);
|
|
343
|
-
} else if (Array.isArray(current) && /^\d+$/.test(finalSegment)) {
|
|
344
|
-
current[parseInt(finalSegment, 10)] = storedValue;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Normalizes a path string into a consistent, slash-delimited format.
|
|
350
|
-
* Converts bracket notation and dot notation in a two-pass.
|
|
351
|
-
* e.g., "bookRecommendations[0].title" -> "/bookRecommendations/0/title"
|
|
352
|
-
* e.g., "book.0.title" -> "/book/0/title"
|
|
353
|
-
*/
|
|
354
|
-
private normalizePath(path: string): string {
|
|
355
|
-
// 1. Replace all bracket accessors `[index]` with dot accessors `.index`
|
|
356
|
-
const dotPath = path.replace(/\[(\d+)\]/g, ".$1");
|
|
357
|
-
|
|
358
|
-
// 2. Split by dots
|
|
359
|
-
const segments = dotPath.split(".");
|
|
360
|
-
|
|
361
|
-
// 3. Join with slashes and ensure it starts with a slash
|
|
362
|
-
return "/" + segments.filter((s) => s.length > 0).join("/");
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
private getDataByPath(root: DataMap, path: string): DataValue | null {
|
|
366
|
-
const segments = this.normalizePath(path)
|
|
367
|
-
.split("/")
|
|
368
|
-
.filter((s) => s);
|
|
369
|
-
|
|
370
|
-
let current: DataValue = root;
|
|
371
|
-
for (const segment of segments) {
|
|
372
|
-
if (current === undefined || current === null) return null;
|
|
373
|
-
|
|
374
|
-
if (current instanceof Map) {
|
|
375
|
-
current = current.get(segment) as DataMap;
|
|
376
|
-
} else if (Array.isArray(current) && /^\d+$/.test(segment)) {
|
|
377
|
-
current = current[parseInt(segment, 10)];
|
|
378
|
-
} else if (isObject(current)) {
|
|
379
|
-
current = current[segment];
|
|
380
|
-
} else {
|
|
381
|
-
// If we need to traverse deeper but `current` is a primitive, the path is invalid.
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
return current;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
private getOrCreateSurface(surfaceId: string): Surface {
|
|
389
|
-
let surface: Surface | undefined = this.surfaces.get(surfaceId);
|
|
390
|
-
if (!surface) {
|
|
391
|
-
surface = new this.objCtor({
|
|
392
|
-
rootComponentId: null,
|
|
393
|
-
componentTree: null,
|
|
394
|
-
dataModel: new this.mapCtor(),
|
|
395
|
-
components: new this.mapCtor(),
|
|
396
|
-
styles: new this.objCtor(),
|
|
397
|
-
}) as Surface;
|
|
398
|
-
|
|
399
|
-
this.surfaces.set(surfaceId, surface);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
return surface;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
private handleBeginRendering(
|
|
406
|
-
message: BeginRenderingMessage,
|
|
407
|
-
surfaceId: SurfaceID
|
|
408
|
-
): void {
|
|
409
|
-
const surface = this.getOrCreateSurface(surfaceId);
|
|
410
|
-
surface.rootComponentId = message.root;
|
|
411
|
-
surface.styles = message.styles ?? {};
|
|
412
|
-
this.rebuildComponentTree(surface);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
private handleSurfaceUpdate(
|
|
416
|
-
message: SurfaceUpdateMessage,
|
|
417
|
-
surfaceId: SurfaceID
|
|
418
|
-
): void {
|
|
419
|
-
const surface = this.getOrCreateSurface(surfaceId);
|
|
420
|
-
for (const component of message.components) {
|
|
421
|
-
surface.components.set(component.id, component);
|
|
422
|
-
}
|
|
423
|
-
this.rebuildComponentTree(surface);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
private handleDataModelUpdate(message: DataModelUpdate, surfaceId: SurfaceID): void {
|
|
427
|
-
const surface = this.getOrCreateSurface(surfaceId);
|
|
428
|
-
const path = message.path ?? "/";
|
|
429
|
-
this.setDataByPath(
|
|
430
|
-
surface.dataModel,
|
|
431
|
-
path,
|
|
432
|
-
message.contents
|
|
433
|
-
);
|
|
434
|
-
this.rebuildComponentTree(surface);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
private handleDeleteSurface(message: DeleteSurfaceMessage): void {
|
|
438
|
-
this.surfaces.delete(message.surfaceId);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* Starts at the root component of the surface and builds out the tree
|
|
443
|
-
* recursively. This process involves resolving all properties of the child
|
|
444
|
-
* components, and expanding on any explicit children lists or templates
|
|
445
|
-
* found in the structure.
|
|
446
|
-
*
|
|
447
|
-
* @param surface The surface to be built.
|
|
448
|
-
*/
|
|
449
|
-
private rebuildComponentTree(surface: Surface): void {
|
|
450
|
-
if (!surface.rootComponentId) {
|
|
451
|
-
surface.componentTree = null;
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// Track visited nodes to avoid circular references.
|
|
456
|
-
const visited = new this.setCtor<string>();
|
|
457
|
-
surface.componentTree = this.buildNodeRecursive(
|
|
458
|
-
surface.rootComponentId,
|
|
459
|
-
surface,
|
|
460
|
-
visited,
|
|
461
|
-
"/",
|
|
462
|
-
"" // Initial idSuffix.
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/** Finds a value key in a map. */
|
|
467
|
-
private findValueKey(value: Record<string, unknown>): string | undefined {
|
|
468
|
-
return Object.keys(value).find((k) => k.startsWith("value"));
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Builds out the nodes recursively.
|
|
473
|
-
*/
|
|
474
|
-
private buildNodeRecursive(
|
|
475
|
-
baseComponentId: string,
|
|
476
|
-
surface: Surface,
|
|
477
|
-
visited: Set<string>,
|
|
478
|
-
dataContextPath: string,
|
|
479
|
-
idSuffix = ""
|
|
480
|
-
): AnyComponentNode | null {
|
|
481
|
-
const fullId = `${baseComponentId}${idSuffix}`; // Construct the full ID
|
|
482
|
-
const { components } = surface;
|
|
483
|
-
|
|
484
|
-
if (!components.has(baseComponentId)) {
|
|
485
|
-
return null;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
if (visited.has(fullId)) {
|
|
489
|
-
throw new Error(`Circular dependency for component "${fullId}".`);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
visited.add(fullId);
|
|
493
|
-
|
|
494
|
-
const componentData = components.get(baseComponentId)!;
|
|
495
|
-
const componentProps = componentData.component ?? {};
|
|
496
|
-
const componentType = Object.keys(componentProps)[0];
|
|
497
|
-
const unresolvedProperties =
|
|
498
|
-
componentProps[componentType as keyof typeof componentProps];
|
|
499
|
-
|
|
500
|
-
// Manually build the resolvedProperties object by resolving each value in
|
|
501
|
-
// the component's properties.
|
|
502
|
-
const resolvedProperties: ResolvedMap = new this.objCtor() as ResolvedMap;
|
|
503
|
-
if (isObject(unresolvedProperties)) {
|
|
504
|
-
for (const [key, value] of Object.entries(unresolvedProperties)) {
|
|
505
|
-
resolvedProperties[key] = this.resolvePropertyValue(
|
|
506
|
-
value,
|
|
507
|
-
surface,
|
|
508
|
-
visited,
|
|
509
|
-
dataContextPath,
|
|
510
|
-
idSuffix
|
|
511
|
-
);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
visited.delete(fullId);
|
|
516
|
-
|
|
517
|
-
// Now that we have the resolved properties in place we can go ahead and
|
|
518
|
-
// ensure that they meet expectations in terms of types and so forth,
|
|
519
|
-
// casting them into the specific shape for usage.
|
|
520
|
-
const baseNode = {
|
|
521
|
-
id: fullId,
|
|
522
|
-
dataContextPath,
|
|
523
|
-
weight: componentData.weight ?? "initial",
|
|
524
|
-
};
|
|
525
|
-
switch (componentType) {
|
|
526
|
-
case "Text":
|
|
527
|
-
if (!isResolvedText(resolvedProperties)) {
|
|
528
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
529
|
-
}
|
|
530
|
-
return new this.objCtor({
|
|
531
|
-
...baseNode,
|
|
532
|
-
type: "Text",
|
|
533
|
-
properties: resolvedProperties,
|
|
534
|
-
}) as AnyComponentNode;
|
|
535
|
-
|
|
536
|
-
case "Image":
|
|
537
|
-
if (!isResolvedImage(resolvedProperties)) {
|
|
538
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
539
|
-
}
|
|
540
|
-
return new this.objCtor({
|
|
541
|
-
...baseNode,
|
|
542
|
-
type: "Image",
|
|
543
|
-
properties: resolvedProperties,
|
|
544
|
-
}) as AnyComponentNode;
|
|
545
|
-
|
|
546
|
-
case "Icon":
|
|
547
|
-
if (!isResolvedIcon(resolvedProperties)) {
|
|
548
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
549
|
-
}
|
|
550
|
-
return new this.objCtor({
|
|
551
|
-
...baseNode,
|
|
552
|
-
type: "Icon",
|
|
553
|
-
properties: resolvedProperties,
|
|
554
|
-
}) as AnyComponentNode;
|
|
555
|
-
|
|
556
|
-
case "Video":
|
|
557
|
-
if (!isResolvedVideo(resolvedProperties)) {
|
|
558
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
559
|
-
}
|
|
560
|
-
return new this.objCtor({
|
|
561
|
-
...baseNode,
|
|
562
|
-
type: "Video",
|
|
563
|
-
properties: resolvedProperties,
|
|
564
|
-
}) as AnyComponentNode;
|
|
565
|
-
|
|
566
|
-
case "AudioPlayer":
|
|
567
|
-
if (!isResolvedAudioPlayer(resolvedProperties)) {
|
|
568
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
569
|
-
}
|
|
570
|
-
return new this.objCtor({
|
|
571
|
-
...baseNode,
|
|
572
|
-
type: "AudioPlayer",
|
|
573
|
-
properties: resolvedProperties,
|
|
574
|
-
}) as AnyComponentNode;
|
|
575
|
-
|
|
576
|
-
case "Row":
|
|
577
|
-
if (!isResolvedRow(resolvedProperties)) {
|
|
578
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
return new this.objCtor({
|
|
582
|
-
...baseNode,
|
|
583
|
-
type: "Row",
|
|
584
|
-
properties: resolvedProperties,
|
|
585
|
-
}) as AnyComponentNode;
|
|
586
|
-
|
|
587
|
-
case "Column":
|
|
588
|
-
if (!isResolvedColumn(resolvedProperties)) {
|
|
589
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
return new this.objCtor({
|
|
593
|
-
...baseNode,
|
|
594
|
-
type: "Column",
|
|
595
|
-
properties: resolvedProperties,
|
|
596
|
-
}) as AnyComponentNode;
|
|
597
|
-
|
|
598
|
-
case "List":
|
|
599
|
-
if (!isResolvedList(resolvedProperties)) {
|
|
600
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
601
|
-
}
|
|
602
|
-
return new this.objCtor({
|
|
603
|
-
...baseNode,
|
|
604
|
-
type: "List",
|
|
605
|
-
properties: resolvedProperties,
|
|
606
|
-
}) as AnyComponentNode;
|
|
607
|
-
|
|
608
|
-
case "Card":
|
|
609
|
-
if (!isResolvedCard(resolvedProperties)) {
|
|
610
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
611
|
-
}
|
|
612
|
-
return new this.objCtor({
|
|
613
|
-
...baseNode,
|
|
614
|
-
type: "Card",
|
|
615
|
-
properties: resolvedProperties,
|
|
616
|
-
}) as AnyComponentNode;
|
|
617
|
-
|
|
618
|
-
case "Tabs":
|
|
619
|
-
if (!isResolvedTabs(resolvedProperties)) {
|
|
620
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
621
|
-
}
|
|
622
|
-
return new this.objCtor({
|
|
623
|
-
...baseNode,
|
|
624
|
-
type: "Tabs",
|
|
625
|
-
properties: resolvedProperties,
|
|
626
|
-
}) as AnyComponentNode;
|
|
627
|
-
|
|
628
|
-
case "Divider":
|
|
629
|
-
if (!isResolvedDivider(resolvedProperties)) {
|
|
630
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
631
|
-
}
|
|
632
|
-
return new this.objCtor({
|
|
633
|
-
...baseNode,
|
|
634
|
-
type: "Divider",
|
|
635
|
-
properties: resolvedProperties,
|
|
636
|
-
}) as AnyComponentNode;
|
|
637
|
-
|
|
638
|
-
case "Modal":
|
|
639
|
-
if (!isResolvedModal(resolvedProperties)) {
|
|
640
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
641
|
-
}
|
|
642
|
-
return new this.objCtor({
|
|
643
|
-
...baseNode,
|
|
644
|
-
type: "Modal",
|
|
645
|
-
properties: resolvedProperties,
|
|
646
|
-
}) as AnyComponentNode;
|
|
647
|
-
|
|
648
|
-
case "Button":
|
|
649
|
-
if (!isResolvedButton(resolvedProperties)) {
|
|
650
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
651
|
-
}
|
|
652
|
-
return new this.objCtor({
|
|
653
|
-
...baseNode,
|
|
654
|
-
type: "Button",
|
|
655
|
-
properties: resolvedProperties,
|
|
656
|
-
}) as AnyComponentNode;
|
|
657
|
-
|
|
658
|
-
case "CheckBox":
|
|
659
|
-
if (!isResolvedCheckbox(resolvedProperties)) {
|
|
660
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
661
|
-
}
|
|
662
|
-
return new this.objCtor({
|
|
663
|
-
...baseNode,
|
|
664
|
-
type: "CheckBox",
|
|
665
|
-
properties: resolvedProperties,
|
|
666
|
-
}) as AnyComponentNode;
|
|
667
|
-
|
|
668
|
-
case "TextField":
|
|
669
|
-
if (!isResolvedTextField(resolvedProperties)) {
|
|
670
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
671
|
-
}
|
|
672
|
-
return new this.objCtor({
|
|
673
|
-
...baseNode,
|
|
674
|
-
type: "TextField",
|
|
675
|
-
properties: resolvedProperties,
|
|
676
|
-
}) as AnyComponentNode;
|
|
677
|
-
|
|
678
|
-
case "DateTimeInput":
|
|
679
|
-
if (!isResolvedDateTimeInput(resolvedProperties)) {
|
|
680
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
681
|
-
}
|
|
682
|
-
return new this.objCtor({
|
|
683
|
-
...baseNode,
|
|
684
|
-
type: "DateTimeInput",
|
|
685
|
-
properties: resolvedProperties,
|
|
686
|
-
}) as AnyComponentNode;
|
|
687
|
-
|
|
688
|
-
case "MultipleChoice":
|
|
689
|
-
if (!isResolvedMultipleChoice(resolvedProperties)) {
|
|
690
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
691
|
-
}
|
|
692
|
-
return new this.objCtor({
|
|
693
|
-
...baseNode,
|
|
694
|
-
type: "MultipleChoice",
|
|
695
|
-
properties: resolvedProperties,
|
|
696
|
-
}) as AnyComponentNode;
|
|
697
|
-
|
|
698
|
-
case "Slider":
|
|
699
|
-
if (!isResolvedSlider(resolvedProperties)) {
|
|
700
|
-
throw new Error(`Invalid data; expected ${componentType}`);
|
|
701
|
-
}
|
|
702
|
-
return new this.objCtor({
|
|
703
|
-
...baseNode,
|
|
704
|
-
type: "Slider",
|
|
705
|
-
properties: resolvedProperties,
|
|
706
|
-
}) as AnyComponentNode;
|
|
707
|
-
|
|
708
|
-
default:
|
|
709
|
-
// Catch-all for other custom component types.
|
|
710
|
-
return new this.objCtor({
|
|
711
|
-
...baseNode,
|
|
712
|
-
type: componentType,
|
|
713
|
-
properties: resolvedProperties,
|
|
714
|
-
}) as AnyComponentNode;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
/**
|
|
719
|
-
* Recursively resolves an individual property value. If a property indicates
|
|
720
|
-
* a child node (a string that matches a component ID), an explicitList of
|
|
721
|
-
* children, or a template, these will be built out here.
|
|
722
|
-
*/
|
|
723
|
-
private resolvePropertyValue(
|
|
724
|
-
value: unknown,
|
|
725
|
-
surface: Surface,
|
|
726
|
-
visited: Set<string>,
|
|
727
|
-
dataContextPath: string,
|
|
728
|
-
idSuffix = ""
|
|
729
|
-
): ResolvedValue {
|
|
730
|
-
// 1. If it's a string that matches a component ID, build that node.
|
|
731
|
-
if (typeof value === "string" && surface.components.has(value)) {
|
|
732
|
-
return this.buildNodeRecursive(
|
|
733
|
-
value,
|
|
734
|
-
surface,
|
|
735
|
-
visited,
|
|
736
|
-
dataContextPath,
|
|
737
|
-
idSuffix
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
// 2. If it's a ComponentArrayReference (e.g., a `children` property),
|
|
742
|
-
// resolve the list and return an array of nodes.
|
|
743
|
-
if (isComponentArrayReference(value)) {
|
|
744
|
-
if (value.explicitList) {
|
|
745
|
-
return value.explicitList.map((id) =>
|
|
746
|
-
this.buildNodeRecursive(
|
|
747
|
-
id,
|
|
748
|
-
surface,
|
|
749
|
-
visited,
|
|
750
|
-
dataContextPath,
|
|
751
|
-
idSuffix
|
|
752
|
-
)
|
|
753
|
-
);
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
if (value.template) {
|
|
757
|
-
const fullDataPath = this.resolvePath(
|
|
758
|
-
value.template.dataBinding,
|
|
759
|
-
dataContextPath
|
|
760
|
-
);
|
|
761
|
-
const data = this.getDataByPath(surface.dataModel, fullDataPath);
|
|
762
|
-
|
|
763
|
-
const template = value.template;
|
|
764
|
-
// Handle Array data.
|
|
765
|
-
if (Array.isArray(data)) {
|
|
766
|
-
return data.map((_, index) => {
|
|
767
|
-
// Create a synthetic ID based on the template ID and the
|
|
768
|
-
// full index path of the data (e.g., template-id:0:1)
|
|
769
|
-
const parentIndices = dataContextPath
|
|
770
|
-
.split("/")
|
|
771
|
-
.filter((segment) => /^\d+$/.test(segment));
|
|
772
|
-
|
|
773
|
-
const newIndices = [...parentIndices, index];
|
|
774
|
-
const newSuffix = `:${newIndices.join(":")}`;
|
|
775
|
-
const childDataContextPath = `${fullDataPath}/${index}`;
|
|
776
|
-
|
|
777
|
-
return this.buildNodeRecursive(
|
|
778
|
-
template.componentId, // baseId
|
|
779
|
-
surface,
|
|
780
|
-
visited,
|
|
781
|
-
childDataContextPath,
|
|
782
|
-
newSuffix // new suffix
|
|
783
|
-
);
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
// Handle Map data.
|
|
788
|
-
const mapCtor = this.mapCtor;
|
|
789
|
-
if (data instanceof mapCtor) {
|
|
790
|
-
return Array.from(data.keys(), (key) => {
|
|
791
|
-
const newSuffix = `:${key}`;
|
|
792
|
-
const childDataContextPath = `${fullDataPath}/${key}`;
|
|
793
|
-
|
|
794
|
-
return this.buildNodeRecursive(
|
|
795
|
-
template.componentId, // baseId
|
|
796
|
-
surface,
|
|
797
|
-
visited,
|
|
798
|
-
childDataContextPath,
|
|
799
|
-
newSuffix // new suffix
|
|
800
|
-
);
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
// Return empty array if the data is not ready yet.
|
|
805
|
-
return new this.arrayCtor();
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
// 3. If it's a plain array, resolve each of its items.
|
|
810
|
-
if (Array.isArray(value)) {
|
|
811
|
-
return value.map((item) =>
|
|
812
|
-
this.resolvePropertyValue(
|
|
813
|
-
item,
|
|
814
|
-
surface,
|
|
815
|
-
visited,
|
|
816
|
-
dataContextPath,
|
|
817
|
-
idSuffix
|
|
818
|
-
)
|
|
819
|
-
);
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
// 4. If it's a plain object, resolve each of its properties.
|
|
823
|
-
if (isObject(value)) {
|
|
824
|
-
const newObj: ResolvedMap = new this.objCtor() as ResolvedMap;
|
|
825
|
-
for (const [key, propValue] of Object.entries(value)) {
|
|
826
|
-
// Special case for paths. Here we might get /item/ or ./ on the front
|
|
827
|
-
// of the path which isn't what we want. In this case we check the
|
|
828
|
-
// dataContextPath and if 1) it's not the default and 2) we also see the
|
|
829
|
-
// path beginning with /item/ or ./we trim it.
|
|
830
|
-
let propertyValue = propValue;
|
|
831
|
-
if (isPath(key, propValue) && dataContextPath !== "/") {
|
|
832
|
-
propertyValue = propValue
|
|
833
|
-
.replace(/^\.?\/item/, "")
|
|
834
|
-
.replace(/^\.?\/text/, "")
|
|
835
|
-
.replace(/^\.?\/label/, "")
|
|
836
|
-
.replace(/^\.?\//, "");
|
|
837
|
-
newObj[key] = propertyValue as ResolvedValue;
|
|
838
|
-
continue;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
newObj[key] = this.resolvePropertyValue(
|
|
842
|
-
propertyValue,
|
|
843
|
-
surface,
|
|
844
|
-
visited,
|
|
845
|
-
dataContextPath,
|
|
846
|
-
idSuffix
|
|
847
|
-
);
|
|
848
|
-
}
|
|
849
|
-
return newObj;
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
// 5. Otherwise, it's a primitive value.
|
|
853
|
-
return value as ResolvedValue;
|
|
854
|
-
}
|
|
855
|
-
}
|