@a2ui/web_core 0.8.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.
Files changed (225) hide show
  1. package/README.md +13 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/src/v0_8/data/guards.d.ts +24 -0
  4. package/dist/src/v0_8/data/guards.d.ts.map +1 -0
  5. package/dist/src/v0_8/data/guards.js +153 -0
  6. package/dist/src/v0_8/data/guards.js.map +1 -0
  7. package/dist/src/v0_8/data/model-processor.d.ts +79 -0
  8. package/dist/src/v0_8/data/model-processor.d.ts.map +1 -0
  9. package/dist/src/v0_8/data/model-processor.js +627 -0
  10. package/dist/src/v0_8/data/model-processor.js.map +1 -0
  11. package/dist/src/v0_8/events/base.d.ts +24 -0
  12. package/dist/src/v0_8/events/base.d.ts.map +1 -0
  13. package/dist/src/v0_8/events/base.js +17 -0
  14. package/dist/src/v0_8/events/base.js.map +1 -0
  15. package/dist/src/v0_8/events/index.d.ts +18 -0
  16. package/dist/src/v0_8/events/index.d.ts.map +1 -0
  17. package/dist/src/v0_8/events/index.js +18 -0
  18. package/dist/src/v0_8/events/index.js.map +1 -0
  19. package/dist/src/v0_8/events/validation-event.d.ts +46 -0
  20. package/dist/src/v0_8/events/validation-event.d.ts.map +1 -0
  21. package/dist/src/v0_8/events/validation-event.js +33 -0
  22. package/dist/src/v0_8/events/validation-event.js.map +1 -0
  23. package/dist/src/v0_8/index.d.ts +743 -0
  24. package/dist/src/v0_8/index.d.ts.map +1 -0
  25. package/dist/src/v0_8/index.js +12 -0
  26. package/dist/src/v0_8/index.js.map +1 -0
  27. package/dist/src/v0_8/schemas/a2ui_client_capabilities_schema.json +23 -0
  28. package/dist/src/v0_8/schemas/catalog_description_schema.json +34 -0
  29. package/dist/src/v0_8/schemas/client_to_server.json +53 -0
  30. package/dist/src/v0_8/schemas/server_to_client.json +148 -0
  31. package/dist/src/v0_8/schemas/server_to_client_with_standard_catalog.json +823 -0
  32. package/dist/src/v0_8/schemas/standard_catalog_definition.json +772 -0
  33. package/dist/src/v0_8/styles/behavior.d.ts +2 -0
  34. package/dist/src/v0_8/styles/behavior.d.ts.map +1 -0
  35. package/dist/src/v0_8/styles/behavior.js +54 -0
  36. package/dist/src/v0_8/styles/behavior.js.map +1 -0
  37. package/dist/src/v0_8/styles/border.d.ts +2 -0
  38. package/dist/src/v0_8/styles/border.d.ts.map +1 -0
  39. package/dist/src/v0_8/styles/border.js +41 -0
  40. package/dist/src/v0_8/styles/border.js.map +1 -0
  41. package/dist/src/v0_8/styles/colors.d.ts +2 -0
  42. package/dist/src/v0_8/styles/colors.d.ts.map +1 -0
  43. package/dist/src/v0_8/styles/colors.js +80 -0
  44. package/dist/src/v0_8/styles/colors.js.map +1 -0
  45. package/dist/src/v0_8/styles/icons.d.ts +11 -0
  46. package/dist/src/v0_8/styles/icons.d.ts.map +1 -0
  47. package/dist/src/v0_8/styles/icons.js +60 -0
  48. package/dist/src/v0_8/styles/icons.js.map +1 -0
  49. package/dist/src/v0_8/styles/index.d.ts +3 -0
  50. package/dist/src/v0_8/styles/index.d.ts.map +1 -0
  51. package/dist/src/v0_8/styles/index.js +35 -0
  52. package/dist/src/v0_8/styles/index.js.map +1 -0
  53. package/dist/src/v0_8/styles/layout.d.ts +2 -0
  54. package/dist/src/v0_8/styles/layout.d.ts.map +1 -0
  55. package/dist/src/v0_8/styles/layout.js +232 -0
  56. package/dist/src/v0_8/styles/layout.js.map +1 -0
  57. package/dist/src/v0_8/styles/opacity.d.ts +2 -0
  58. package/dist/src/v0_8/styles/opacity.d.ts.map +1 -0
  59. package/dist/src/v0_8/styles/opacity.js +24 -0
  60. package/dist/src/v0_8/styles/opacity.js.map +1 -0
  61. package/dist/src/v0_8/styles/shared.d.ts +2 -0
  62. package/dist/src/v0_8/styles/shared.d.ts.map +1 -0
  63. package/dist/src/v0_8/styles/shared.js +17 -0
  64. package/dist/src/v0_8/styles/shared.js.map +1 -0
  65. package/dist/src/v0_8/styles/type.d.ts +2 -0
  66. package/dist/src/v0_8/styles/type.d.ts.map +1 -0
  67. package/dist/src/v0_8/styles/type.js +156 -0
  68. package/dist/src/v0_8/styles/type.js.map +1 -0
  69. package/dist/src/v0_8/styles/utils.d.ts +6 -0
  70. package/dist/src/v0_8/styles/utils.d.ts.map +1 -0
  71. package/dist/src/v0_8/styles/utils.js +81 -0
  72. package/dist/src/v0_8/styles/utils.js.map +1 -0
  73. package/dist/src/v0_8/types/client-event.d.ts +66 -0
  74. package/dist/src/v0_8/types/client-event.d.ts.map +1 -0
  75. package/dist/src/v0_8/types/client-event.js +17 -0
  76. package/dist/src/v0_8/types/client-event.js.map +1 -0
  77. package/dist/src/v0_8/types/colors.d.ts +25 -0
  78. package/dist/src/v0_8/types/colors.d.ts.map +1 -0
  79. package/dist/src/v0_8/types/colors.js +19 -0
  80. package/dist/src/v0_8/types/colors.js.map +1 -0
  81. package/dist/src/v0_8/types/components.d.ts +176 -0
  82. package/dist/src/v0_8/types/components.d.ts.map +1 -0
  83. package/dist/src/v0_8/types/components.js +17 -0
  84. package/dist/src/v0_8/types/components.js.map +1 -0
  85. package/dist/src/v0_8/types/primitives.d.ts +43 -0
  86. package/dist/src/v0_8/types/primitives.d.ts.map +1 -0
  87. package/dist/src/v0_8/types/primitives.js +17 -0
  88. package/dist/src/v0_8/types/primitives.js.map +1 -0
  89. package/dist/src/v0_8/types/types.d.ts +411 -0
  90. package/dist/src/v0_8/types/types.d.ts.map +1 -0
  91. package/dist/src/v0_8/types/types.js +17 -0
  92. package/dist/src/v0_8/types/types.js.map +1 -0
  93. package/dist/src/v0_9/catalog/types.d.ts +27 -0
  94. package/dist/src/v0_9/catalog/types.d.ts.map +1 -0
  95. package/dist/src/v0_9/catalog/types.js +11 -0
  96. package/dist/src/v0_9/catalog/types.js.map +1 -0
  97. package/dist/src/v0_9/common/events.d.ts +24 -0
  98. package/dist/src/v0_9/common/events.d.ts.map +1 -0
  99. package/dist/src/v0_9/common/events.js +29 -0
  100. package/dist/src/v0_9/common/events.js.map +1 -0
  101. package/dist/src/v0_9/index.d.ts +11 -0
  102. package/dist/src/v0_9/index.d.ts.map +1 -0
  103. package/dist/src/v0_9/index.js +11 -0
  104. package/dist/src/v0_9/index.js.map +1 -0
  105. package/dist/src/v0_9/processing/message-processor.d.ts +34 -0
  106. package/dist/src/v0_9/processing/message-processor.d.ts.map +1 -0
  107. package/dist/src/v0_9/processing/message-processor.js +128 -0
  108. package/dist/src/v0_9/processing/message-processor.js.map +1 -0
  109. package/dist/src/v0_9/processing/message-processor.test.d.ts +2 -0
  110. package/dist/src/v0_9/processing/message-processor.test.d.ts.map +1 -0
  111. package/dist/src/v0_9/processing/message-processor.test.js +112 -0
  112. package/dist/src/v0_9/processing/message-processor.test.js.map +1 -0
  113. package/dist/src/v0_9/rendering/component-context.d.ts +17 -0
  114. package/dist/src/v0_9/rendering/component-context.d.ts.map +1 -0
  115. package/dist/src/v0_9/rendering/component-context.js +21 -0
  116. package/dist/src/v0_9/rendering/component-context.js.map +1 -0
  117. package/dist/src/v0_9/rendering/data-context.d.ts +37 -0
  118. package/dist/src/v0_9/rendering/data-context.d.ts.map +1 -0
  119. package/dist/src/v0_9/rendering/data-context.js +97 -0
  120. package/dist/src/v0_9/rendering/data-context.js.map +1 -0
  121. package/dist/src/v0_9/rendering/data-context.test.d.ts +2 -0
  122. package/dist/src/v0_9/rendering/data-context.test.d.ts.map +1 -0
  123. package/dist/src/v0_9/rendering/data-context.test.js +71 -0
  124. package/dist/src/v0_9/rendering/data-context.test.js.map +1 -0
  125. package/dist/src/v0_9/schema/common-types.d.ts +608 -0
  126. package/dist/src/v0_9/schema/common-types.d.ts.map +1 -0
  127. package/dist/src/v0_9/schema/common-types.js +92 -0
  128. package/dist/src/v0_9/schema/common-types.js.map +1 -0
  129. package/dist/src/v0_9/schema/index.d.ts +3 -0
  130. package/dist/src/v0_9/schema/index.d.ts.map +1 -0
  131. package/dist/src/v0_9/schema/index.js +3 -0
  132. package/dist/src/v0_9/schema/index.js.map +1 -0
  133. package/dist/src/v0_9/schema/server-to-client.d.ts +84 -0
  134. package/dist/src/v0_9/schema/server-to-client.d.ts.map +1 -0
  135. package/dist/src/v0_9/schema/server-to-client.js +21 -0
  136. package/dist/src/v0_9/schema/server-to-client.js.map +1 -0
  137. package/dist/src/v0_9/state/component-model.d.ts +16 -0
  138. package/dist/src/v0_9/state/component-model.d.ts.map +1 -0
  139. package/dist/src/v0_9/state/component-model.js +24 -0
  140. package/dist/src/v0_9/state/component-model.js.map +1 -0
  141. package/dist/src/v0_9/state/component-model.test.d.ts +2 -0
  142. package/dist/src/v0_9/state/component-model.test.d.ts.map +1 -0
  143. package/dist/src/v0_9/state/component-model.test.js +39 -0
  144. package/dist/src/v0_9/state/component-model.test.js.map +1 -0
  145. package/dist/src/v0_9/state/data-model.d.ts +47 -0
  146. package/dist/src/v0_9/state/data-model.d.ts.map +1 -0
  147. package/dist/src/v0_9/state/data-model.js +191 -0
  148. package/dist/src/v0_9/state/data-model.js.map +1 -0
  149. package/dist/src/v0_9/state/data-model.test.d.ts +2 -0
  150. package/dist/src/v0_9/state/data-model.test.d.ts.map +1 -0
  151. package/dist/src/v0_9/state/data-model.test.js +204 -0
  152. package/dist/src/v0_9/state/data-model.test.js.map +1 -0
  153. package/dist/src/v0_9/state/surface-components-model.d.ts +19 -0
  154. package/dist/src/v0_9/state/surface-components-model.d.ts.map +1 -0
  155. package/dist/src/v0_9/state/surface-components-model.js +42 -0
  156. package/dist/src/v0_9/state/surface-components-model.js.map +1 -0
  157. package/dist/src/v0_9/state/surface-components-model.test.d.ts +2 -0
  158. package/dist/src/v0_9/state/surface-components-model.test.d.ts.map +1 -0
  159. package/dist/src/v0_9/state/surface-components-model.test.js +49 -0
  160. package/dist/src/v0_9/state/surface-components-model.test.js.map +1 -0
  161. package/dist/src/v0_9/state/surface-group-model.d.ts +25 -0
  162. package/dist/src/v0_9/state/surface-group-model.d.ts.map +1 -0
  163. package/dist/src/v0_9/state/surface-group-model.js +56 -0
  164. package/dist/src/v0_9/state/surface-group-model.js.map +1 -0
  165. package/dist/src/v0_9/state/surface-group-model.test.d.ts +2 -0
  166. package/dist/src/v0_9/state/surface-group-model.test.d.ts.map +1 -0
  167. package/dist/src/v0_9/state/surface-group-model.test.js +67 -0
  168. package/dist/src/v0_9/state/surface-group-model.test.js.map +1 -0
  169. package/dist/src/v0_9/state/surface-model.d.ts +23 -0
  170. package/dist/src/v0_9/state/surface-model.d.ts.map +1 -0
  171. package/dist/src/v0_9/state/surface-model.js +28 -0
  172. package/dist/src/v0_9/state/surface-model.js.map +1 -0
  173. package/dist/src/v0_9/state/surface-model.test.d.ts +2 -0
  174. package/dist/src/v0_9/state/surface-model.test.d.ts.map +1 -0
  175. package/dist/src/v0_9/state/surface-model.test.js +39 -0
  176. package/dist/src/v0_9/state/surface-model.test.js.map +1 -0
  177. package/dist/src/v0_9/test/test-utils.d.ts +8 -0
  178. package/dist/src/v0_9/test/test-utils.d.ts.map +1 -0
  179. package/dist/src/v0_9/test/test-utils.js +18 -0
  180. package/dist/src/v0_9/test/test-utils.js.map +1 -0
  181. package/package.json +94 -0
  182. package/src/v0_8/data/guards.ts +236 -0
  183. package/src/v0_8/data/model-processor.ts +855 -0
  184. package/src/v0_8/events/base.ts +24 -0
  185. package/src/v0_8/events/index.ts +18 -0
  186. package/src/v0_8/events/validation-event.ts +66 -0
  187. package/src/v0_8/index.ts +12 -0
  188. package/src/v0_8/schemas/server_to_client_with_standard_catalog.json +823 -0
  189. package/src/v0_8/styles/behavior.ts +55 -0
  190. package/src/v0_8/styles/border.ts +42 -0
  191. package/src/v0_8/styles/colors.ts +100 -0
  192. package/src/v0_8/styles/icons.ts +60 -0
  193. package/src/v0_8/styles/index.ts +37 -0
  194. package/src/v0_8/styles/layout.ts +235 -0
  195. package/src/v0_8/styles/opacity.ts +24 -0
  196. package/src/v0_8/styles/shared.ts +17 -0
  197. package/src/v0_8/styles/type.ts +156 -0
  198. package/src/v0_8/styles/utils.ts +104 -0
  199. package/src/v0_8/types/client-event.ts +80 -0
  200. package/src/v0_8/types/colors.ts +66 -0
  201. package/src/v0_8/types/components.ts +213 -0
  202. package/src/v0_8/types/primitives.ts +60 -0
  203. package/src/v0_8/types/types.ts +557 -0
  204. package/src/v0_9/catalog/types.ts +38 -0
  205. package/src/v0_9/common/events.ts +44 -0
  206. package/src/v0_9/index.ts +12 -0
  207. package/src/v0_9/processing/message-processor.test.ts +133 -0
  208. package/src/v0_9/processing/message-processor.ts +150 -0
  209. package/src/v0_9/rendering/component-context.ts +36 -0
  210. package/src/v0_9/rendering/data-context.test.ts +85 -0
  211. package/src/v0_9/rendering/data-context.ts +110 -0
  212. package/src/v0_9/schema/common-types.ts +125 -0
  213. package/src/v0_9/schema/index.ts +2 -0
  214. package/src/v0_9/schema/server-to-client.ts +23 -0
  215. package/src/v0_9/state/component-model.test.ts +50 -0
  216. package/src/v0_9/state/component-model.ts +32 -0
  217. package/src/v0_9/state/data-model.test.ts +257 -0
  218. package/src/v0_9/state/data-model.ts +239 -0
  219. package/src/v0_9/state/surface-components-model.test.ts +59 -0
  220. package/src/v0_9/state/surface-components-model.ts +48 -0
  221. package/src/v0_9/state/surface-group-model.test.ts +82 -0
  222. package/src/v0_9/state/surface-group-model.ts +66 -0
  223. package/src/v0_9/state/surface-model.test.ts +44 -0
  224. package/src/v0_9/state/surface-model.ts +39 -0
  225. package/src/v0_9/test/test-utils.ts +22 -0
@@ -0,0 +1,39 @@
1
+ import assert from 'node:assert';
2
+ import { describe, it, beforeEach } from 'node:test';
3
+ import { SurfaceModel } from './surface-model.js';
4
+ import { Catalog } from '../catalog/types.js';
5
+ import { ComponentModel } from './component-model.js';
6
+ import { ComponentContext } from '../rendering/component-context.js';
7
+ describe('SurfaceModel', () => {
8
+ let surface;
9
+ let catalog;
10
+ let actions = [];
11
+ beforeEach(() => {
12
+ actions = [];
13
+ catalog = new Catalog('test-catalog', []);
14
+ surface = new SurfaceModel('surface-1', catalog, {});
15
+ surface.onAction.subscribe(async (action) => {
16
+ actions.push(action);
17
+ });
18
+ });
19
+ it('initializes with empty data model', () => {
20
+ assert.deepStrictEqual(surface.dataModel.get('/'), {});
21
+ });
22
+ it('exposes components model', () => {
23
+ surface.componentsModel.addComponent(new ComponentModel('c1', 'Button', {}));
24
+ assert.ok(surface.componentsModel.get('c1'));
25
+ });
26
+ it('dispatches actions', async () => {
27
+ await surface.dispatchAction({ type: 'click' });
28
+ assert.strictEqual(actions.length, 1);
29
+ assert.strictEqual(actions[0].type, 'click');
30
+ });
31
+ it('creates a component context', () => {
32
+ surface.componentsModel.addComponent(new ComponentModel('root', 'Box', {}));
33
+ const ctx = new ComponentContext(surface, 'root', '/mydata');
34
+ assert.ok(ctx);
35
+ assert.strictEqual(ctx.componentModel.id, 'root');
36
+ assert.strictEqual(ctx.dataContext.path, '/mydata');
37
+ });
38
+ });
39
+ //# sourceMappingURL=surface-model.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surface-model.test.js","sourceRoot":"","sources":["../../../../src/v0_9/state/surface-model.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAQ,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAQ,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAgB,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,OAAmC,CAAC;IACxC,IAAI,OAA8B,CAAC;IACnC,IAAI,OAAO,GAAU,EAAE,CAAC;IAExB,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,GAAG,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAC1C,OAAO,GAAG,IAAI,YAAY,CAAe,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QACnE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAC1C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QAClC,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;QAC7E,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oBAAoB,EAAE,KAAK,IAAI,EAAE;QAClC,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAChD,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACtC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QAC5E,MAAM,GAAG,GAAG,IAAI,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAC7D,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAClD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ComponentContext } from '../rendering/component-context.js';
2
+ import { SurfaceModel } from '../state/surface-model.js';
3
+ import { ComponentApi } from '../catalog/types.js';
4
+ export declare class TestSurfaceModel extends SurfaceModel<ComponentApi> {
5
+ constructor(actionHandler?: any);
6
+ }
7
+ export declare function createTestContext(properties: any, actionHandler?: any): ComponentContext;
8
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../../src/v0_9/test/test-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAW,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAG5D,qBAAa,gBAAiB,SAAQ,YAAY,CAAC,YAAY,CAAC;gBAClD,aAAa,GAAE,GAAqB;CAIjD;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,GAAG,EAAE,aAAa,GAAE,GAAqB,oBAQtF"}
@@ -0,0 +1,18 @@
1
+ import { ComponentContext } from '../rendering/component-context.js';
2
+ import { SurfaceModel } from '../state/surface-model.js';
3
+ import { Catalog } from '../catalog/types.js';
4
+ import { ComponentModel } from '../state/component-model.js';
5
+ export class TestSurfaceModel extends SurfaceModel {
6
+ constructor(actionHandler = async () => { }) {
7
+ super('test', new Catalog('test-catalog', []), {});
8
+ this.onAction.subscribe(actionHandler);
9
+ }
10
+ }
11
+ export function createTestContext(properties, actionHandler = async () => { }) {
12
+ const surface = new TestSurfaceModel(actionHandler);
13
+ const component = new ComponentModel('test-id', 'TestComponent', properties);
14
+ surface.componentsModel.addComponent(component);
15
+ const context = new ComponentContext(surface, 'test-id', '/');
16
+ return context;
17
+ }
18
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../../../src/v0_9/test/test-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAgB,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,MAAM,OAAO,gBAAiB,SAAQ,YAA0B;IAC9D,YAAY,gBAAqB,KAAK,IAAI,EAAE,GAAG,CAAC;QAC9C,KAAK,CAAC,MAAM,EAAE,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,UAAe,EAAE,gBAAqB,KAAK,IAAI,EAAE,GAAG,CAAC;IACrF,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,SAAS,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;IAC7E,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAEhD,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IAE9D,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@a2ui/web_core",
3
+ "version": "0.8.0",
4
+ "description": "A2UI Core Library",
5
+ "main": "./dist/src/v0_8/index.js",
6
+ "types": "./dist/src/v0_8/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/src/v0_8/index.d.ts",
10
+ "default": "./dist/src/v0_8/index.js"
11
+ },
12
+ "./v0_9": {
13
+ "types": "./dist/src/v0_9/index.d.ts",
14
+ "default": "./dist/src/v0_9/index.js"
15
+ },
16
+ "./types/*": {
17
+ "types": "./dist/src/v0_8/types/*.d.ts",
18
+ "default": "./dist/src/v0_8/types/*.js"
19
+ },
20
+ "./data/*": {
21
+ "types": "./dist/src/v0_8/data/*.d.ts",
22
+ "default": "./dist/src/v0_8/data/*.js"
23
+ },
24
+ "./styles/*": {
25
+ "types": "./dist/src/v0_8/styles/*.d.ts",
26
+ "default": "./dist/src/v0_8/styles/*.js"
27
+ },
28
+ "./schemas/*": {
29
+ "default": "./dist/src/v0_8/schemas/*"
30
+ }
31
+ },
32
+ "type": "module",
33
+ "sideEffects": false,
34
+ "files": [
35
+ "dist",
36
+ "src"
37
+ ],
38
+ "scripts": {
39
+ "prepack": "npm run build",
40
+ "build": "wireit",
41
+ "build:tsc": "wireit",
42
+ "test": "wireit"
43
+ },
44
+ "wireit": {
45
+ "copy-spec": {
46
+ "command": "node scripts/copy-spec.js",
47
+ "files": [
48
+ "../../specification/v0_8/json/*.json",
49
+ "scripts/copy-spec.js"
50
+ ],
51
+ "output": [
52
+ "src/v0_8/schemas/*.json"
53
+ ]
54
+ },
55
+ "build": {
56
+ "dependencies": [
57
+ "build:tsc"
58
+ ]
59
+ },
60
+ "build:tsc": {
61
+ "command": "tsc -b --pretty",
62
+ "dependencies": [
63
+ "copy-spec"
64
+ ],
65
+ "files": [
66
+ "src/**/*.ts",
67
+ "src/**/*.json",
68
+ "tsconfig.json"
69
+ ],
70
+ "output": [
71
+ "dist/",
72
+ "!dist/**/*.min.js{,.map}"
73
+ ],
74
+ "clean": "if-file-deleted"
75
+ },
76
+ "test": {
77
+ "command": "node --test dist/**/*.test.js",
78
+ "dependencies": [
79
+ "build"
80
+ ]
81
+ }
82
+ },
83
+ "author": "Google",
84
+ "license": "Apache-2.0",
85
+ "devDependencies": {
86
+ "@types/node": "^24.10.1",
87
+ "typescript": "^5.8.3",
88
+ "wireit": "^0.15.0-pre.2"
89
+ },
90
+ "dependencies": {
91
+ "zod": "^3.25.76",
92
+ "zod-to-json-schema": "^3.25.1"
93
+ }
94
+ }
@@ -0,0 +1,236 @@
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 { BooleanValue, NumberValue, StringValue } from "../types/primitives";
18
+ import {
19
+ AnyComponentNode,
20
+ ComponentArrayReference,
21
+ ResolvedAudioPlayer,
22
+ ResolvedButton,
23
+ ResolvedCard,
24
+ ResolvedCheckbox,
25
+ ResolvedColumn,
26
+ ResolvedDateTimeInput,
27
+ ResolvedDivider,
28
+ ResolvedIcon,
29
+ ResolvedImage,
30
+ ResolvedList,
31
+ ResolvedModal,
32
+ ResolvedMultipleChoice,
33
+ ResolvedRow,
34
+ ResolvedSlider,
35
+ ResolvedTabItem,
36
+ ResolvedTabs,
37
+ ResolvedText,
38
+ ResolvedTextField,
39
+ ResolvedVideo,
40
+ ValueMap,
41
+ } from "../types/types";
42
+
43
+ export function isValueMap(value: unknown): value is ValueMap {
44
+ return isObject(value) && "key" in value;
45
+ }
46
+
47
+ export function isPath(key: string, value: unknown): value is string {
48
+ return key === "path" && typeof value === "string";
49
+ }
50
+
51
+ export function isObject(value: unknown): value is Record<string, unknown> {
52
+ return typeof value === "object" && value !== null && !Array.isArray(value);
53
+ }
54
+
55
+ export function isComponentArrayReference(
56
+ value: unknown
57
+ ): value is ComponentArrayReference {
58
+ if (!isObject(value)) return false;
59
+ return "explicitList" in value || "template" in value;
60
+ }
61
+
62
+ function isStringValue(value: unknown): value is StringValue {
63
+ return (
64
+ isObject(value) &&
65
+ ("path" in value ||
66
+ ("literal" in value && typeof value.literal === "string") ||
67
+ "literalString" in value)
68
+ );
69
+ }
70
+
71
+ function isNumberValue(value: unknown): value is NumberValue {
72
+ return (
73
+ isObject(value) &&
74
+ ("path" in value ||
75
+ ("literal" in value && typeof value.literal === "number") ||
76
+ "literalNumber" in value)
77
+ );
78
+ }
79
+
80
+ function isBooleanValue(value: unknown): value is BooleanValue {
81
+ return (
82
+ isObject(value) &&
83
+ ("path" in value ||
84
+ ("literal" in value && typeof value.literal === "boolean") ||
85
+ "literalBoolean" in value)
86
+ );
87
+ }
88
+
89
+ function isAnyComponentNode(value: unknown): value is AnyComponentNode {
90
+ if (!isObject(value)) return false;
91
+ const hasBaseKeys = "id" in value && "type" in value && "properties" in value;
92
+ if (!hasBaseKeys) return false;
93
+
94
+ return true;
95
+ }
96
+
97
+ export function isResolvedAudioPlayer(
98
+ props: unknown
99
+ ): props is ResolvedAudioPlayer {
100
+ return isObject(props) && "url" in props && isStringValue(props.url);
101
+ }
102
+
103
+ export function isResolvedButton(props: unknown): props is ResolvedButton {
104
+ return (
105
+ isObject(props) &&
106
+ "child" in props &&
107
+ isAnyComponentNode(props.child) &&
108
+ "action" in props
109
+ );
110
+ }
111
+
112
+ export function isResolvedCard(props: unknown): props is ResolvedCard {
113
+ if (!isObject(props)) return false;
114
+ if (!("child" in props)) {
115
+ if (!("children" in props)) {
116
+ return false;
117
+ } else {
118
+ return (
119
+ Array.isArray(props.children) &&
120
+ props.children.every(isAnyComponentNode)
121
+ );
122
+ }
123
+ }
124
+
125
+ return isAnyComponentNode(props.child);
126
+ }
127
+
128
+ export function isResolvedCheckbox(props: unknown): props is ResolvedCheckbox {
129
+ return (
130
+ isObject(props) &&
131
+ "label" in props &&
132
+ isStringValue(props.label) &&
133
+ "value" in props &&
134
+ isBooleanValue(props.value)
135
+ );
136
+ }
137
+
138
+ export function isResolvedColumn(props: unknown): props is ResolvedColumn {
139
+ return (
140
+ isObject(props) &&
141
+ "children" in props &&
142
+ Array.isArray(props.children) &&
143
+ props.children.every(isAnyComponentNode)
144
+ );
145
+ }
146
+
147
+ export function isResolvedDateTimeInput(
148
+ props: unknown
149
+ ): props is ResolvedDateTimeInput {
150
+ return isObject(props) && "value" in props && isStringValue(props.value);
151
+ }
152
+
153
+ export function isResolvedDivider(props: unknown): props is ResolvedDivider {
154
+ // Dividers can have all optional properties, so just checking if
155
+ // it's an object is enough.
156
+ return isObject(props);
157
+ }
158
+
159
+ export function isResolvedImage(props: unknown): props is ResolvedImage {
160
+ return isObject(props) && "url" in props && isStringValue(props.url);
161
+ }
162
+
163
+ export function isResolvedIcon(props: unknown): props is ResolvedIcon {
164
+ return isObject(props) && "name" in props && isStringValue(props.name);
165
+ }
166
+
167
+ export function isResolvedList(props: unknown): props is ResolvedList {
168
+ return (
169
+ isObject(props) &&
170
+ "children" in props &&
171
+ Array.isArray(props.children) &&
172
+ props.children.every(isAnyComponentNode)
173
+ );
174
+ }
175
+
176
+ export function isResolvedModal(props: unknown): props is ResolvedModal {
177
+ return (
178
+ isObject(props) &&
179
+ "entryPointChild" in props &&
180
+ isAnyComponentNode(props.entryPointChild) &&
181
+ "contentChild" in props &&
182
+ isAnyComponentNode(props.contentChild)
183
+ );
184
+ }
185
+
186
+ export function isResolvedMultipleChoice(
187
+ props: unknown
188
+ ): props is ResolvedMultipleChoice {
189
+ return isObject(props) && "selections" in props;
190
+ }
191
+
192
+ export function isResolvedRow(props: unknown): props is ResolvedRow {
193
+ return (
194
+ isObject(props) &&
195
+ "children" in props &&
196
+ Array.isArray(props.children) &&
197
+ props.children.every(isAnyComponentNode)
198
+ );
199
+ }
200
+
201
+ export function isResolvedSlider(props: unknown): props is ResolvedSlider {
202
+ return isObject(props) && "value" in props && isNumberValue(props.value);
203
+ }
204
+
205
+ function isResolvedTabItem(item: unknown): item is ResolvedTabItem {
206
+ return (
207
+ isObject(item) &&
208
+ "title" in item &&
209
+ isStringValue(item.title) &&
210
+ "child" in item &&
211
+ isAnyComponentNode(item.child)
212
+ );
213
+ }
214
+
215
+ export function isResolvedTabs(props: unknown): props is ResolvedTabs {
216
+ return (
217
+ isObject(props) &&
218
+ "tabItems" in props &&
219
+ Array.isArray(props.tabItems) &&
220
+ props.tabItems.every(isResolvedTabItem)
221
+ );
222
+ }
223
+
224
+ export function isResolvedText(props: unknown): props is ResolvedText {
225
+ return isObject(props) && "text" in props && isStringValue(props.text);
226
+ }
227
+
228
+ export function isResolvedTextField(
229
+ props: unknown
230
+ ): props is ResolvedTextField {
231
+ return isObject(props) && "label" in props && isStringValue(props.label);
232
+ }
233
+
234
+ export function isResolvedVideo(props: unknown): props is ResolvedVideo {
235
+ return isObject(props) && "url" in props && isStringValue(props.url);
236
+ }