@adobe/data 0.9.36 → 0.9.39

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 (152) hide show
  1. package/AGENTS.md +91 -0
  2. package/dist/ecs/database/observe-select-deep.d.ts +23 -0
  3. package/dist/ecs/database/observe-select-deep.js +15 -0
  4. package/dist/ecs/database/observe-select-deep.js.map +1 -0
  5. package/dist/ecs/database/observe-select-deep.type-test.js +111 -0
  6. package/dist/ecs/database/observe-select-deep.type-test.js.map +1 -0
  7. package/dist/ecs/persistence-service/create-storage-persistence-service.js +4 -3
  8. package/dist/ecs/persistence-service/create-storage-persistence-service.js.map +1 -1
  9. package/dist/ecs/persistence-service/create-storage-persistence-service.test.js +52 -0
  10. package/dist/ecs/persistence-service/create-storage-persistence-service.test.js.map +1 -0
  11. package/dist/service/agentic-service/link.d.ts +15 -0
  12. package/dist/service/agentic-service/link.js +3 -0
  13. package/dist/service/agentic-service/link.js.map +1 -0
  14. package/dist/service/async-data-service/is-valid.d.ts +3 -1
  15. package/dist/service/async-data-service/is-valid.type-test.d.ts +1 -0
  16. package/dist/service/async-data-service/is-valid.type-test.js +3 -0
  17. package/dist/service/async-data-service/is-valid.type-test.js.map +1 -0
  18. package/dist/service/dynamic-service/semantic-service.d.ts +19 -0
  19. package/dist/service/dynamic-service/semantic-service.js +2 -0
  20. package/dist/service/dynamic-service/semantic-service.js.map +1 -0
  21. package/dist/service/semantic-service/semantic-service.d.ts +19 -0
  22. package/dist/service/semantic-service/semantic-service.js +2 -0
  23. package/dist/service/semantic-service/semantic-service.js.map +1 -0
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +3 -1
  26. package/references/data-lit/README.md +18 -0
  27. package/references/data-lit/package.json +35 -0
  28. package/references/data-lit/src/decorators/apply-decorator.ts +26 -0
  29. package/references/data-lit/src/decorators/apply-service-decorators.ts +15 -0
  30. package/references/data-lit/src/decorators/index.ts +4 -0
  31. package/references/data-lit/src/decorators/require-service.ts +20 -0
  32. package/references/data-lit/src/elements/application-element.ts +42 -0
  33. package/references/data-lit/src/elements/application-host.ts +43 -0
  34. package/references/data-lit/src/elements/database-element.ts +42 -0
  35. package/references/data-lit/src/elements/index.ts +5 -0
  36. package/references/data-lit/src/functions/index.ts +3 -0
  37. package/references/data-lit/src/functions/iterate-self-and-ancestors.ts +23 -0
  38. package/references/data-lit/src/hooks/attach-decorator.ts +32 -0
  39. package/references/data-lit/src/hooks/component/component.ts +12 -0
  40. package/references/data-lit/src/hooks/component/stack.ts +19 -0
  41. package/references/data-lit/src/hooks/index.ts +21 -0
  42. package/references/data-lit/src/hooks/use-connected.ts +41 -0
  43. package/references/data-lit/src/hooks/use-debounce.ts +26 -0
  44. package/references/data-lit/src/hooks/use-drag-observe.ts +59 -0
  45. package/references/data-lit/src/hooks/use-drag-transaction.ts +46 -0
  46. package/references/data-lit/src/hooks/use-draggable.ts +112 -0
  47. package/references/data-lit/src/hooks/use-effect.ts +19 -0
  48. package/references/data-lit/src/hooks/use-element.ts +83 -0
  49. package/references/data-lit/src/hooks/use-memo.ts +16 -0
  50. package/references/data-lit/src/hooks/use-observable-values.ts +10 -0
  51. package/references/data-lit/src/hooks/use-observable.ts +15 -0
  52. package/references/data-lit/src/hooks/use-ref.ts +8 -0
  53. package/references/data-lit/src/hooks/use-resize-observer.ts +31 -0
  54. package/references/data-lit/src/hooks/use-state.ts +19 -0
  55. package/references/data-lit/src/hooks/use-updated.ts +56 -0
  56. package/references/data-lit/src/hooks/use-window-event.ts +16 -0
  57. package/references/data-lit/src/hooks/with-hooks.ts +22 -0
  58. package/references/data-lit/src/index.ts +6 -0
  59. package/references/data-lit/tsconfig.json +11 -0
  60. package/references/data-lit-todo/package.json +30 -0
  61. package/references/data-lit-todo/src/elements/todo-list/todo-list-presentation.ts +22 -0
  62. package/references/data-lit-todo/src/elements/todo-list/todo-list.css.ts +12 -0
  63. package/references/data-lit-todo/src/elements/todo-list/todo-list.ts +45 -0
  64. package/references/data-lit-todo/src/elements/todo-row/index.ts +2 -0
  65. package/references/data-lit-todo/src/elements/todo-row/todo-row-presentation.ts +68 -0
  66. package/references/data-lit-todo/src/elements/todo-row/todo-row.css.ts +49 -0
  67. package/references/data-lit-todo/src/elements/todo-row/todo-row.ts +46 -0
  68. package/references/data-lit-todo/src/elements/todo-toolbar/index.ts +2 -0
  69. package/references/data-lit-todo/src/elements/todo-toolbar/todo-toolbar-presentation.ts +55 -0
  70. package/references/data-lit-todo/src/elements/todo-toolbar/todo-toolbar.css.ts +34 -0
  71. package/references/data-lit-todo/src/elements/todo-toolbar/todo-toolbar.ts +62 -0
  72. package/references/data-lit-todo/src/elements/todo-undo-redo/index.ts +3 -0
  73. package/references/data-lit-todo/src/elements/todo-undo-redo/todo-undo-redo-presentation.ts +41 -0
  74. package/references/data-lit-todo/src/elements/todo-undo-redo/todo-undo-redo.css.ts +12 -0
  75. package/references/data-lit-todo/src/elements/todo-undo-redo/todo-undo-redo.ts +37 -0
  76. package/references/data-lit-todo/src/index.ts +9 -0
  77. package/references/data-lit-todo/src/main.ts +29 -0
  78. package/references/data-lit-todo/src/sample-types.ts +14 -0
  79. package/references/data-lit-todo/src/services/dependent-state-service/create-dependent-state-service.ts +8 -0
  80. package/references/data-lit-todo/src/services/dependent-state-service/dependent-state/all-todos.ts +5 -0
  81. package/references/data-lit-todo/src/services/dependent-state-service/dependent-state/complete-todos.ts +5 -0
  82. package/references/data-lit-todo/src/services/dependent-state-service/dependent-state/incomplete-todos.ts +5 -0
  83. package/references/data-lit-todo/src/services/dependent-state-service/dependent-state/index.ts +4 -0
  84. package/references/data-lit-todo/src/services/dependent-state-service/dependent-state-service.ts +4 -0
  85. package/references/data-lit-todo/src/services/main-service/create-main-service.ts +53 -0
  86. package/references/data-lit-todo/src/services/main-service/todo-main-service.ts +20 -0
  87. package/references/data-lit-todo/src/services/state-service/create-todo-database.ts +16 -0
  88. package/references/data-lit-todo/src/services/state-service/create-todo-store.ts +28 -0
  89. package/references/data-lit-todo/src/services/state-service/todo-state-service.ts +9 -0
  90. package/references/data-lit-todo/src/services/state-service/transactions/create-bulk-todos.ts +12 -0
  91. package/references/data-lit-todo/src/services/state-service/transactions/create-todo.test.ts +17 -0
  92. package/references/data-lit-todo/src/services/state-service/transactions/create-todo.ts +15 -0
  93. package/references/data-lit-todo/src/services/state-service/transactions/delete-all-todos.ts +18 -0
  94. package/references/data-lit-todo/src/services/state-service/transactions/delete-todo.test.ts +25 -0
  95. package/references/data-lit-todo/src/services/state-service/transactions/delete-todo.ts +11 -0
  96. package/references/data-lit-todo/src/services/state-service/transactions/drag-todo.ts +19 -0
  97. package/references/data-lit-todo/src/services/state-service/transactions/index.ts +8 -0
  98. package/references/data-lit-todo/src/services/state-service/transactions/reorder-todos.ts +13 -0
  99. package/references/data-lit-todo/src/services/state-service/transactions/toggle-complete.test.ts +78 -0
  100. package/references/data-lit-todo/src/services/state-service/transactions/toggle-complete.ts +15 -0
  101. package/references/data-lit-todo/src/todo-element.ts +6 -0
  102. package/references/data-lit-todo/src/todo-host.ts +29 -0
  103. package/references/data-lit-todo/src/todo-main-element.ts +40 -0
  104. package/references/data-lit-todo/src/todo-sample.ts +21 -0
  105. package/references/data-lit-todo/tsconfig.json +10 -0
  106. package/references/data-react/README.md +47 -0
  107. package/references/data-react/package.json +36 -0
  108. package/references/data-react/src/context/database-context.tsx +41 -0
  109. package/references/data-react/src/hooks/index.ts +5 -0
  110. package/references/data-react/src/hooks/use-database.ts +13 -0
  111. package/references/data-react/src/hooks/use-observable-values.ts +15 -0
  112. package/references/data-react/src/hooks/use-observable.ts +14 -0
  113. package/references/data-react/src/index.ts +7 -0
  114. package/references/data-react/tsconfig.json +12 -0
  115. package/references/data-react-hello/package.json +25 -0
  116. package/references/data-react-hello/src/App.tsx +13 -0
  117. package/references/data-react-hello/src/Counter.tsx +21 -0
  118. package/references/data-react-hello/src/counter-plugin.ts +14 -0
  119. package/references/data-react-hello/src/main.tsx +9 -0
  120. package/references/data-react-hello/tsconfig.json +16 -0
  121. package/references/data-react-pixie/package.json +28 -0
  122. package/references/data-react-pixie/src/App.tsx +21 -0
  123. package/references/data-react-pixie/src/bunny.png +0 -0
  124. package/references/data-react-pixie/src/filter-toggle.tsx +46 -0
  125. package/references/data-react-pixie/src/filters.ts +22 -0
  126. package/references/data-react-pixie/src/fox.png +0 -0
  127. package/references/data-react-pixie/src/hooks/use-database.ts +6 -0
  128. package/references/data-react-pixie/src/hooks/use-texture.ts +22 -0
  129. package/references/data-react-pixie/src/main.tsx +14 -0
  130. package/references/data-react-pixie/src/pixi-react.d.ts +1 -0
  131. package/references/data-react-pixie/src/pixie-plugin.ts +100 -0
  132. package/references/data-react-pixie/src/sprite-container.tsx +23 -0
  133. package/references/data-react-pixie/src/sprite-urls.ts +9 -0
  134. package/references/data-react-pixie/src/sprite.tsx +35 -0
  135. package/references/data-react-pixie/src/tick.tsx +10 -0
  136. package/references/data-react-pixie/src/vite-env.d.ts +6 -0
  137. package/references/data-react-pixie/tsconfig.json +16 -0
  138. package/dist/LICENSE +0 -21
  139. package/dist/README.md +0 -296
  140. package/dist/package.json +0 -183
  141. package/dist/service/agentic-service/create-from-config.d.ts +0 -45
  142. package/dist/service/agentic-service/create-from-config.js +0 -85
  143. package/dist/service/agentic-service/create-from-config.js.map +0 -1
  144. package/dist/service/agentic-service/create.interface-first-spike.type-test.js +0 -119
  145. package/dist/service/agentic-service/create.interface-first-spike.type-test.js.map +0 -1
  146. package/dist/service/agentic-service/index.d.ts +0 -1
  147. package/dist/service/agentic-service/index.js +0 -3
  148. package/dist/service/agentic-service/index.js.map +0 -1
  149. package/dist/service/dynamic-service/create.interface-first-spike.type-test.js +0 -118
  150. package/dist/service/dynamic-service/create.interface-first-spike.type-test.js.map +0 -1
  151. /package/dist/{service/agentic-service/create.interface-first-spike.type-test.d.ts → ecs/database/observe-select-deep.type-test.d.ts} +0 -0
  152. /package/dist/{service/dynamic-service/create.interface-first-spike.type-test.d.ts → ecs/persistence-service/create-storage-persistence-service.test.d.ts} +0 -0
package/AGENTS.md ADDED
@@ -0,0 +1,91 @@
1
+ # @adobe/data — Agent guide
2
+
3
+ Adobe data-oriented programming library. Use this file when editing code in this package or when consuming `@adobe/data` in an application.
4
+
5
+ ## Stack
6
+
7
+ - **Package manager:** pnpm
8
+ - **Build:** TypeScript (`tsc -b`), AssemblyScript for WASM
9
+ - **Test:** Vitest (browser tests use Playwright)
10
+ - **Lint:** ESLint
11
+
12
+ ## Commands (from package root `packages/data`)
13
+
14
+ | Task | Command |
15
+ |------|---------|
16
+ | Build | `pnpm build` |
17
+ | Test (headless, exit when done) | `pnpm test [filename] -- --run` |
18
+ | Test (watch) | `pnpm dev:test` |
19
+ | Lint | `pnpm lint` |
20
+ | Lint fix | `pnpm lint-fix` |
21
+
22
+ Run tests for a single file: `pnpm test create-storage-persistence-service.test.ts -- --run`
23
+
24
+ ## Paradigm and code style
25
+
26
+ - **Data-oriented, functional.** Prefer composition over inheritance. No classes, enums, or inheritance.
27
+ - **Immutable data** by default; mutation allowed only where needed for performance (e.g. ECS internals).
28
+ - **TypeScript:** modern TS, semicolons, `const`/`let`, `??` for nullish coalescing (not `||`).
29
+ - **Separation of concerns:** pure functions and clear module boundaries.
30
+
31
+ ## Package layout and imports
32
+
33
+ Consumers use **subpath exports**. Do not rely on deep paths; use the public entry points:
34
+
35
+ | Import | Purpose |
36
+ |--------|---------|
37
+ | `@adobe/data` | Core: Data, equals, normalize, mutableClone |
38
+ | `@adobe/data/observe` | Observables (fromConstant, fromPromise, withMap, withFilter, etc.) |
39
+ | `@adobe/data/ecs` | ECS: Store, Database, Plugin, createStore, createDatabase |
40
+ | `@adobe/data/cache` | Cache, memoize, hashing, BlobStore |
41
+ | `@adobe/data/schema` | JSON Schema helpers, validation |
42
+ | `@adobe/data/service` | AsyncDataService, service patterns |
43
+ | `@adobe/data/blob` | Blob / BlobRef |
44
+ | `@adobe/data/table` | Table utilities |
45
+ | `@adobe/data/math` | Vec2, Vec3, Vec4, Mat4, etc. |
46
+ | `@adobe/data/types` | Shared types |
47
+ | `@adobe/data/functions` | Serialization and pure helpers |
48
+
49
+ Source lives under `src/` with one main `index.ts` per area; built output is in `dist/`.
50
+
51
+ ## ECS (Entity Component System)
52
+
53
+ - **Store:** low-level, synchronous, direct mutations. No transactions, no observability.
54
+ - **Database:** wraps a Store; **transaction-based** and **observable**. All mutations go through transaction functions; undo/redo and observers are supported.
55
+ - **Plugins:** use `Database.Plugin.create()`. Property order is **enforced at runtime:** `extends` → `services` → `components` → `resources` → `archetypes` → `computed` → `transactions` → `actions` → `systems`. Wrong order throws.
56
+ - **Composition:** one plugin via `extends`; multiple peers via `Database.Plugin.combine(...)`.
57
+ - **Transactions:** synchronous and deterministic. Receive `(store, payload)`. Mutate via `store.update(entity, data)`, `store.resources.x = value`, etc.
58
+ - **Actions:** may be async; call at most one transaction per action to keep undo/redo correct. Callers should not rely on return values for UI flow (data down via Observe, actions for side effects).
59
+
60
+ ## Observables
61
+
62
+ - `Observable<T>` = subscription function `(callback: (value: T) => void) => Unobserve`.
63
+ - May call back synchronously (once) and/or asynchronously. Use `fromConstant`, `fromPromise`, `fromObservableProperties`; modify with `withMap`, `withFilter`, `withDefault`, `withOptional`, `withDeduplicate`.
64
+
65
+ ## Testing
66
+
67
+ - Unit tests live **next to** the code: `<my-file>.test.ts` next to `my-file.ts`.
68
+ - Use Vitest: `describe` for the unit under test, `test`/`it` for the case. Prefer `assert({ given, should, actual, expected })`-style where the project uses it.
69
+ - Before changing behavior: confirm whether the test or the implementation is wrong and state which one you are fixing.
70
+ - Focus on behavior and edge cases; avoid testing types/shapes that TypeScript already enforces.
71
+
72
+ ## Data and schemas
73
+
74
+ - **Data:** immutable, JSON-serializable values. Use `normalize()` for stable keys (e.g. cache keys).
75
+ - **Schemas:** JSON Schema with `as const` so `FromSchema` (or equivalent) can derive TypeScript types. Use schema namespaces for component/resource definitions in ECS.
76
+
77
+ ## Gotchas
78
+
79
+ - **Breaking changes:** Before 1.0.0, minor version bumps may include breaking API changes.
80
+ - **ECS plugin order:** Reordering plugin properties (e.g. putting `transactions` before `components`) will throw at runtime.
81
+ - **BlobStore / BlobRef:** Prefer BlobRef for persistence and cache keys; resolve to Blob when needed.
82
+
83
+ ## References
84
+
85
+ Source for peer packages and sample apps is included under `references/` (when present). Use these as living reference code:
86
+
87
+ - **references/data-lit** — Extra support for Lit-based projects.
88
+ - **references/data-react** — Same but for React.
89
+ - **references/data-lit-todo** — Sample with best practices for Lit apps.
90
+ - **references/data-react-hello** — Minimal starting React sample.
91
+ - **references/data-react-pixie** — Sample of using React Pixie for 2D rendering.
@@ -0,0 +1,23 @@
1
+ import { Observe } from "../../observe/index.js";
2
+ import { StringKeyof } from "../../types/types.js";
3
+ import { RequiredComponents } from "../required-components.js";
4
+ import { Components } from "../store/components.js";
5
+ import { EntitySelectOptions } from "../store/entity-select-options.js";
6
+ import { Database } from "./database.js";
7
+ /**
8
+ * Entity data shape returned by observeSelectDeep.
9
+ * Includes required components (id) and each queried component with its correct type.
10
+ */
11
+ export type SelectDeepEntityData<C, Include extends StringKeyof<C>> = RequiredComponents & {
12
+ readonly [K in Include]: C[K];
13
+ };
14
+ /**
15
+ * Deeply observe entity data for an archetype query.
16
+ *
17
+ * Unlike `db.observe.select` (which returns entity IDs and only triggers on
18
+ * set membership changes), `observeSelectDeep` returns full typed entity data
19
+ * and re-emits whenever ANY included component value changes on any matched entity.
20
+ *
21
+ * This IS NOT an efficient pattern, so use sparingly and with small number of entities.
22
+ */
23
+ export declare const observeSelectDeep: <C extends Components, Include extends StringKeyof<C>>(db: Database<C, any, any, any, any, any, any, any>, include: readonly Include[], options?: EntitySelectOptions<C, Pick<C & RequiredComponents, Include>>) => Observe<readonly SelectDeepEntityData<C, Include>[]>;
@@ -0,0 +1,15 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ /**
3
+ * Deeply observe entity data for an archetype query.
4
+ *
5
+ * Unlike `db.observe.select` (which returns entity IDs and only triggers on
6
+ * set membership changes), `observeSelectDeep` returns full typed entity data
7
+ * and re-emits whenever ANY included component value changes on any matched entity.
8
+ *
9
+ * This IS NOT an efficient pattern, so use sparingly and with small number of entities.
10
+ */
11
+ export const observeSelectDeep = (db, include, options) => {
12
+ // TODO: implementation — returns a stub for now so the type signature compiles.
13
+ return (_notify) => () => { };
14
+ };
15
+ //# sourceMappingURL=observe-select-deep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe-select-deep.js","sourceRoot":"","sources":["../../../src/ecs/database/observe-select-deep.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAkBvD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAI/B,EAAkD,EAClD,OAA2B,EAC3B,OAAuE,EACjB,EAAE;IACxD,gFAAgF;IAChF,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC,CAAC"}
@@ -0,0 +1,111 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { Database } from "./database.js";
3
+ import { observeSelectDeep } from "./observe-select-deep.js";
4
+ /**
5
+ * Type-only tests for observeSelectDeep type inference.
6
+ *
7
+ * These tests verify that:
8
+ * 1. observeSelectDeep infers entity data types from included components
9
+ * 2. Only queried components appear in the result type
10
+ * 3. RequiredComponents (id) is always included
11
+ * 4. The helper type SelectDeepEntityData resolves correctly
12
+ *
13
+ * Note: These are compile-time type checks only — they don't need to execute.
14
+ */
15
+ // ============================================================================
16
+ // SelectDeepEntityData HELPER TYPE
17
+ // ============================================================================
18
+ function testSelectDeepEntityDataType() {
19
+ }
20
+ // ============================================================================
21
+ // BASIC INFERENCE FROM DATABASE
22
+ // ============================================================================
23
+ function testObserveSelectDeepBasicInference() {
24
+ const plugin = Database.Plugin.create({
25
+ components: {
26
+ position: { type: "number" },
27
+ velocity: { type: "number" },
28
+ name: { type: "string" },
29
+ },
30
+ archetypes: {
31
+ Moving: ["position", "velocity"],
32
+ },
33
+ });
34
+ const db = Database.create(plugin);
35
+ // Querying position and velocity should infer correct entity data
36
+ const observed = observeSelectDeep(db, ["position", "velocity"]);
37
+ }
38
+ // ============================================================================
39
+ // SINGLE COMPONENT QUERY
40
+ // ============================================================================
41
+ function testObserveSelectDeepSingleComponent() {
42
+ const plugin = Database.Plugin.create({
43
+ components: {
44
+ position: { type: "number" },
45
+ name: { type: "string" },
46
+ },
47
+ });
48
+ const db = Database.create(plugin);
49
+ // Querying only name should produce id + name
50
+ const observed = observeSelectDeep(db, ["name"]);
51
+ }
52
+ // ============================================================================
53
+ // INVALID COMPONENT NAMES REJECTED
54
+ // ============================================================================
55
+ function testObserveSelectDeepRejectsInvalidComponents() {
56
+ const plugin = Database.Plugin.create({
57
+ components: {
58
+ position: { type: "number" },
59
+ },
60
+ });
61
+ const db = Database.create(plugin);
62
+ // @ts-expect-error - "nonexistent" is not a valid component name
63
+ observeSelectDeep(db, ["nonexistent"]);
64
+ }
65
+ // ============================================================================
66
+ // WITH OPTIONS (where/order)
67
+ // ============================================================================
68
+ function testObserveSelectDeepWithOptions() {
69
+ const plugin = Database.Plugin.create({
70
+ components: {
71
+ position: { type: "number" },
72
+ velocity: { type: "number" },
73
+ name: { type: "string" },
74
+ },
75
+ archetypes: {
76
+ Moving: ["position", "velocity"],
77
+ },
78
+ });
79
+ const db = Database.create(plugin);
80
+ // Should accept where/order options scoped to included components
81
+ const observed = observeSelectDeep(db, ["position", "velocity"], {
82
+ where: { position: { ">": 0 } },
83
+ order: { velocity: true },
84
+ });
85
+ }
86
+ // ============================================================================
87
+ // EXTENDED PLUGIN INFERENCE
88
+ // ============================================================================
89
+ function testObserveSelectDeepWithExtendedPlugin() {
90
+ const basePlugin = Database.Plugin.create({
91
+ components: {
92
+ position: { type: "number" },
93
+ },
94
+ archetypes: {
95
+ Positioned: ["position"],
96
+ },
97
+ });
98
+ const extendedPlugin = Database.Plugin.create({
99
+ extends: basePlugin,
100
+ components: {
101
+ velocity: { type: "number" },
102
+ },
103
+ archetypes: {
104
+ Moving: ["position", "velocity"],
105
+ },
106
+ });
107
+ const db = Database.create(extendedPlugin);
108
+ // Should work with components from both base and extended plugins
109
+ const observed = observeSelectDeep(db, ["position", "velocity"]);
110
+ }
111
+ //# sourceMappingURL=observe-select-deep.type-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe-select-deep.type-test.js","sourceRoot":"","sources":["../../../src/ecs/database/observe-select-deep.type-test.ts"],"names":[],"mappings":"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"}
@@ -1,5 +1,6 @@
1
1
  // © 2026 Adobe. MIT License. See /LICENSE for details.
2
2
  import { deserializeFromStorage, serializeToStorage } from "../../functions/serialization/serialize-to-storage.js";
3
+ import { debounce } from "../../internal/function/debounce.js";
3
4
  export const createStoragePersistenceService = async (options) => {
4
5
  const { database, defaultFileId, autoSaveOnChange: autoSave, autoLoadOnStart, storage = sessionStorage } = options;
5
6
  const service = {
@@ -18,10 +19,10 @@ export const createStoragePersistenceService = async (options) => {
18
19
  await service.load();
19
20
  }
20
21
  if (autoSave) {
22
+ const debouncedSave = debounce(() => service.save(), 300);
21
23
  database.observe.transactions(t => {
22
- if (!t.transient) {
23
- service.save();
24
- }
24
+ if (!t.transient)
25
+ debouncedSave();
25
26
  });
26
27
  }
27
28
  return service;
@@ -1 +1 @@
1
- {"version":3,"file":"create-storage-persistence-service.js","sourceRoot":"","sources":["../../../src/ecs/persistence-service/create-storage-persistence-service.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAGvD,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAInH,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,EAAE,OAMrD,EAA+B,EAAE;IAC9B,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;IACnH,MAAM,OAAO,GAAuB;QAChC,WAAW,EAAE,2BAA2B;QACxC,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,EAAE;YACnC,MAAM,kBAAkB,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,EAAE;YACnC,MAAM,IAAI,GAAG,MAAM,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC3D,IAAI,IAAI,EAAE,CAAC;gBACP,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;KACJ,CAAA;IACD,IAAI,eAAe,EAAE,CAAC;QAClB,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACX,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;YAC9B,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,EAAE,CAAC;YACnB,CAAC;QACL,CAAC,CAAC,CAAA;IACN,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC"}
1
+ {"version":3,"file":"create-storage-persistence-service.js","sourceRoot":"","sources":["../../../src/ecs/persistence-service/create-storage-persistence-service.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AACnH,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAI/D,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,EAAE,OAMrD,EAA+B,EAAE;IAC9B,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;IACnH,MAAM,OAAO,GAAuB;QAChC,WAAW,EAAE,2BAA2B;QACxC,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,EAAE;YACnC,MAAM,kBAAkB,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,EAAE;YACnC,MAAM,IAAI,GAAG,MAAM,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC3D,IAAI,IAAI,EAAE,CAAC;gBACP,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;KACJ,CAAA;IACD,IAAI,eAAe,EAAE,CAAC;QAClB,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACX,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;QAC1D,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;YAC9B,IAAI,CAAC,CAAC,CAAC,SAAS;gBAAE,aAAa,EAAE,CAAC;QACtC,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1,52 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
3
+ import { createStoragePersistenceService } from "./create-storage-persistence-service.js";
4
+ import { Database } from "../index.js";
5
+ function createMinimalDatabase() {
6
+ return Database.create(Database.Plugin.create({
7
+ components: {
8
+ n: { type: "number" },
9
+ },
10
+ archetypes: { N: ["n"] },
11
+ transactions: {
12
+ tick(t, _args) {
13
+ t.archetypes.N.insert({ n: 0 });
14
+ },
15
+ },
16
+ }));
17
+ }
18
+ describe("createStoragePersistenceService", () => {
19
+ describe("autoSaveOnChange with rapid transactions", () => {
20
+ beforeEach(() => {
21
+ vi.useFakeTimers();
22
+ });
23
+ afterEach(() => {
24
+ vi.useRealTimers();
25
+ });
26
+ it("given rapid non-transient transactions, invokes save once after debounce window (debounced)", async () => {
27
+ let saveInvokeCount = 0;
28
+ const database = createMinimalDatabase();
29
+ const service = await createStoragePersistenceService({
30
+ database,
31
+ defaultFileId: "test-id",
32
+ autoSaveOnChange: true,
33
+ autoLoadOnStart: false,
34
+ });
35
+ const originalSave = service.save;
36
+ Object.assign(service, {
37
+ save: async (fileId) => {
38
+ saveInvokeCount++;
39
+ return originalSave.call(service, fileId);
40
+ },
41
+ });
42
+ const transactionCount = 5;
43
+ for (let i = 0; i < transactionCount; i++) {
44
+ database.transactions.tick({});
45
+ }
46
+ vi.advanceTimersByTime(350);
47
+ await vi.runAllTimersAsync();
48
+ expect(saveInvokeCount).toBe(1);
49
+ });
50
+ });
51
+ });
52
+ //# sourceMappingURL=create-storage-persistence-service.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-storage-persistence-service.test.js","sourceRoot":"","sources":["../../../src/ecs/persistence-service/create-storage-persistence-service.test.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,SAAS,qBAAqB;IAC1B,OAAO,QAAQ,CAAC,MAAM,CAClB,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;QACnB,UAAU,EAAE;YACR,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SACxB;QACD,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE;QACxB,YAAY,EAAE;YACV,IAAI,CAAC,CAAC,EAAE,KAA4B;gBAChC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACpC,CAAC;SACJ;KACJ,CAAC,CACL,CAAC;AACN,CAAC;AAED,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC7C,QAAQ,CAAC,0CAA0C,EAAE,GAAG,EAAE;QACtD,UAAU,CAAC,GAAG,EAAE;YACZ,EAAE,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,SAAS,CAAC,GAAG,EAAE;YACX,EAAE,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6FAA6F,EAAE,KAAK,IAAI,EAAE;YACzG,IAAI,eAAe,GAAG,CAAC,CAAC;YACxB,MAAM,QAAQ,GAAG,qBAAqB,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,MAAM,+BAA+B,CAAC;gBAClD,QAAQ;gBACR,aAAa,EAAE,SAAS;gBACxB,gBAAgB,EAAE,IAAI;gBACtB,eAAe,EAAE,KAAK;aACzB,CAAC,CAAC;YACH,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;YAClC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;gBACnB,IAAI,EAAE,KAAK,EAAE,MAAe,EAAE,EAAE;oBAC5B,eAAe,EAAE,CAAC;oBAClB,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBAC9C,CAAC;aACJ,CAAC,CAAC;YAEH,MAAM,gBAAgB,GAAG,CAAC,CAAC;YAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC;gBACxC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACnC,CAAC;YAED,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;YAC5B,MAAM,EAAE,CAAC,iBAAiB,EAAE,CAAC;YAE7B,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { AgenticService } from "./agentic-service.js";
2
+ /**
3
+ * A link to another agentic service. Used to expose related services (e.g. parent,
4
+ * children, sibling workflows) so the UI can navigate or delegate to them.
5
+ * Either `service` (in-process) or `serviceId` (resolved by host) must be set.
6
+ */
7
+ export type Link = {
8
+ service: AgenticService;
9
+ label?: string;
10
+ description?: string;
11
+ } | {
12
+ serviceId: string;
13
+ label?: string;
14
+ description?: string;
15
+ };
@@ -0,0 +1,3 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ export {};
3
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/service/agentic-service/link.ts"],"names":[],"mappings":"AAAA,uDAAuD"}
@@ -3,7 +3,9 @@ import { Observe } from "../../observe/index.js";
3
3
  import { Service } from "../service.js";
4
4
  type ValidReturnType<R> = R extends Observe<infer T> ? T extends Data ? true : false : R extends void ? true : R extends Promise<infer P> ? P extends Data | void ? true : false : R extends AsyncGenerator<infer G, any, any> ? G extends Data ? true : false : false;
5
5
  type AllArgsAreData<Args extends readonly any[]> = Args extends readonly [] ? true : Args extends readonly [infer First, ...infer Rest] ? First extends Data ? AllArgsAreData<Rest> : false : Args extends readonly (infer Element)[] ? Element extends Data ? true : false : false;
6
- type IsValidProperty<P> = P extends Observe<infer T> ? T extends Data ? true : false : P extends (...args: infer Args) => infer R ? AllArgsAreData<Args> extends true ? ValidReturnType<R> : false : false;
6
+ type IsValidProperty<P> = P extends Observe<infer T> ? T extends Data ? true : false : P extends (...args: infer Args) => infer R ? AllArgsAreData<Args> extends true ? ValidReturnType<R> : false : P extends object ? keyof P extends never ? false : {
7
+ [K in keyof P]: IsValidProperty<P[K]>;
8
+ } extends Record<keyof P, true> ? true : false : false;
7
9
  type AllPropertiesValid<T extends Service> = {
8
10
  [K in Exclude<keyof T, keyof Service>]: IsValidProperty<T[K]>;
9
11
  } extends Record<Exclude<keyof T, keyof Service>, true> ? true : false;
@@ -0,0 +1,3 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ export {};
3
+ //# sourceMappingURL=is-valid.type-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-valid.type-test.js","sourceRoot":"","sources":["../../../src/service/async-data-service/is-valid.type-test.ts"],"names":[],"mappings":"AAAA,uDAAuD"}
@@ -0,0 +1,19 @@
1
+ import { Observe } from "../../observe/index.js";
2
+ import { Schema } from "../../schema/index.js";
3
+ import { Service } from "../service.js";
4
+ export type SemanticState<S extends Schema = Schema> = {
5
+ schema: S;
6
+ value: Schema.ToType<S>;
7
+ };
8
+ export type SemanticAction<S extends Schema | false = Schema> = {
9
+ schema: S;
10
+ execute: Schema.ToType<S> extends void ? (() => void) : ((state: Schema.ToType<S>) => void);
11
+ };
12
+ export interface SemanticService extends Service {
13
+ states: Observe<{
14
+ [key: string]: SemanticState;
15
+ }>;
16
+ actions: Observe<{
17
+ [key: string]: SemanticAction;
18
+ }>;
19
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=semantic-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-service.js","sourceRoot":"","sources":["../../../src/service/dynamic-service/semantic-service.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import { Observe } from "../../observe/index.js";
2
+ import { Schema } from "../../schema/index.js";
3
+ import { Service } from "../service.js";
4
+ export type SemanticState<S extends Schema = Schema> = {
5
+ schema: S;
6
+ value: Schema.ToType<S>;
7
+ };
8
+ export type SemanticAction<S extends Schema | false = Schema> = {
9
+ schema: S;
10
+ execute: Schema.ToType<S> extends void ? (() => void) : ((state: Schema.ToType<S>) => void);
11
+ };
12
+ export interface SemanticService extends Service {
13
+ states: Observe<{
14
+ [key: string]: SemanticState;
15
+ }>;
16
+ actions: Observe<{
17
+ [key: string]: SemanticAction;
18
+ }>;
19
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=semantic-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-service.js","sourceRoot":"","sources":["../../../src/service/semantic-service/semantic-service.ts"],"names":[],"mappings":""}