@adobe/data 0.9.68 → 0.9.70
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/dist/cache/functions/hashing/blob-to-hash.js +59 -11
- package/dist/cache/functions/hashing/blob-to-hash.js.map +1 -1
- package/dist/cache/functions/hashing/hashing.test.js +59 -0
- package/dist/cache/functions/hashing/hashing.test.js.map +1 -1
- package/dist/ecs/database/concurrency/concurrency-strategy.d.ts +10 -10
- package/dist/ecs/database/concurrency/immediate-concurrency.d.ts +3 -3
- package/dist/ecs/database/concurrency/immediate-concurrency.js +9 -9
- package/dist/ecs/database/concurrency/immediate-concurrency.js.map +1 -1
- package/dist/ecs/database/concurrency/roll-forward-concurrency.js +4 -4
- package/dist/ecs/database/concurrency/roll-forward-concurrency.js.map +1 -1
- package/dist/ecs/database/database.d.ts +5 -5
- package/dist/ecs/database/observed/create-observed-database.js +5 -5
- package/dist/ecs/database/observed/create-observed-database.js.map +1 -1
- package/dist/ecs/database/public/create-transaction-dispatcher.d.ts +4 -4
- package/dist/ecs/database/public/create-transaction-dispatcher.js +15 -15
- package/dist/ecs/database/public/create-transaction-dispatcher.js.map +1 -1
- package/dist/ecs/database/reconciling/create-rebase-replay-applier.js +3 -3
- package/dist/ecs/database/reconciling/create-rebase-replay-applier.js.map +1 -1
- package/dist/ecs/database/transactional-store/coalesce-actions.js +2 -2
- package/dist/ecs/database/transactional-store/coalesce-actions.js.map +1 -1
- package/dist/ecs/database/transactional-store/coalesce-actions.test.js +57 -57
- package/dist/ecs/database/transactional-store/coalesce-actions.test.js.map +1 -1
- package/dist/ecs/database/transactional-store/create-transactional-store.js +13 -13
- package/dist/ecs/database/transactional-store/create-transactional-store.js.map +1 -1
- package/dist/ecs/database/transactional-store/create-transactional-store.test.js +51 -51
- package/dist/ecs/database/transactional-store/create-transactional-store.test.js.map +1 -1
- package/dist/ecs/database/transactional-store/transaction-options.d.ts +3 -3
- package/dist/ecs/database/transactional-store/transactional-store.d.ts +4 -4
- package/dist/ecs/entity/is-ephemeral.d.ts +3 -0
- package/dist/ecs/entity/is-ephemeral.js +4 -1
- package/dist/ecs/entity/is-ephemeral.js.map +1 -1
- package/dist/ecs/entity/is-ephemeral.test.js +22 -5
- package/dist/ecs/entity/is-ephemeral.test.js.map +1 -1
- package/dist/ecs/entity/public.d.ts +1 -1
- package/dist/ecs/entity/public.js +1 -1
- package/dist/ecs/entity/public.js.map +1 -1
- package/dist/ecs/optional-components.d.ts +3 -1
- package/dist/ecs/persistence-service/create-storage-persistence-service.js +1 -1
- package/dist/ecs/persistence-service/create-storage-persistence-service.js.map +1 -1
- package/dist/ecs/plugins/scheduler/scheduler.js +9 -2
- package/dist/ecs/plugins/scheduler/scheduler.js.map +1 -1
- package/dist/ecs/store/archetype-row.d.ts +16 -0
- package/dist/ecs/store/archetype-row.js +2 -0
- package/dist/ecs/store/archetype-row.js.map +1 -0
- package/dist/ecs/store/core/create-core.js +15 -10
- package/dist/ecs/store/core/create-core.js.map +1 -1
- package/dist/ecs/store/index.d.ts +1 -0
- package/dist/ecs/store/index.js.map +1 -1
- package/dist/ecs/store/public/create-store.js +5 -5
- package/dist/ecs/store/public/create-store.js.map +1 -1
- package/dist/ecs/store/store.js +6 -0
- package/dist/ecs/store/store.js.map +1 -1
- package/dist/ecs/undo-redo-service/create-undo-redo-service.js +1 -1
- package/dist/ecs/undo-redo-service/create-undo-redo-service.js.map +1 -1
- package/dist/math/mat4x4/functions.js +6 -3
- package/dist/math/mat4x4/functions.js.map +1 -1
- package/dist/math/quat/index.d.ts +1 -3
- package/dist/math/quat/schema.d.ts +3 -0
- package/dist/math/quat/schema.js +4 -0
- package/dist/math/quat/schema.js.map +1 -1
- package/dist/observe/with-batch.js +7 -6
- package/dist/observe/with-batch.js.map +1 -1
- package/dist/observe/with-batch.test.js +11 -0
- package/dist/observe/with-batch.test.js.map +1 -1
- package/dist/observe/with-deduplicate-data.js +4 -2
- package/dist/observe/with-deduplicate-data.js.map +1 -1
- package/dist/observe/with-deduplicate-data.test.d.ts +1 -0
- package/dist/observe/with-deduplicate-data.test.js +39 -0
- package/dist/observe/with-deduplicate-data.test.js.map +1 -0
- package/dist/observe/with-filter.d.ts +4 -3
- package/dist/observe/with-filter.js +3 -2
- package/dist/observe/with-filter.js.map +1 -1
- package/dist/observe/with-filter.type-test.d.ts +1 -0
- package/dist/observe/with-filter.type-test.js +14 -0
- package/dist/observe/with-filter.type-test.js.map +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/schema.d.ts +7 -0
- package/dist/service/ui-service/public.d.ts +1 -0
- package/dist/service/ui-service/public.js +1 -0
- package/dist/service/ui-service/public.js.map +1 -1
- package/dist/service/ui-service/restrict.d.ts +17 -0
- package/dist/service/ui-service/restrict.js +5 -0
- package/dist/service/ui-service/restrict.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typed-buffer/register-typed-buffer-codecs.js +4 -4
- package/dist/typed-buffer/register-typed-buffer-codecs.js.map +1 -1
- package/dist/typed-buffer/structs/index.d.ts +2 -0
- package/dist/typed-buffer/structs/index.js +2 -0
- package/dist/typed-buffer/structs/index.js.map +1 -1
- package/dist/typed-buffer/structs/wgsl-struct-fields.d.ts +17 -0
- package/dist/typed-buffer/structs/wgsl-struct-fields.js +58 -0
- package/dist/typed-buffer/structs/wgsl-struct-fields.js.map +1 -0
- package/package.json +2 -1
- package/references/data-lit/package.json +1 -1
- package/references/data-lit/src/elements/database-element.ts +22 -7
- package/references/data-lit/src/hooks/use-drag-transaction.ts +2 -2
- package/references/data-lit/src/hooks/use-pointer-observe.ts +2 -2
- package/references/data-lit-tictactoe/package.json +1 -1
- package/references/data-lit-tictactoe/src/elements/tictactoe-app/tictactoe-app.ts +1 -1
- package/references/data-react/package.json +1 -1
- package/references/data-react-hello/package.json +3 -2
- package/references/data-react-pixie/package.json +1 -1
- package/dist/service/async-data-service/index.d.ts +0 -1
- package/dist/service/async-data-service/index.js +0 -3
- package/dist/service/async-data-service/index.js.map +0 -1
|
@@ -15,7 +15,7 @@ export function registerTypedBufferCodecs() {
|
|
|
15
15
|
serialize: (data) => {
|
|
16
16
|
const { type, schema, capacity } = data;
|
|
17
17
|
try {
|
|
18
|
-
if (type === "const" || schema.ephemeral) {
|
|
18
|
+
if (type === "const" || (schema.nonPersistent ?? schema.ephemeral)) {
|
|
19
19
|
return { json: { type, schema, capacity } };
|
|
20
20
|
}
|
|
21
21
|
else if (type === "array") {
|
|
@@ -46,7 +46,7 @@ export function registerTypedBufferCodecs() {
|
|
|
46
46
|
const buffer = isEnum
|
|
47
47
|
? createEnumBuffer(schema, capacity)
|
|
48
48
|
: createArrayBuffer(schema, capacity);
|
|
49
|
-
if (schema.ephemeral) {
|
|
49
|
+
if ((schema.nonPersistent ?? schema.ephemeral)) {
|
|
50
50
|
if (schema.default !== undefined && schema.default !== 0) {
|
|
51
51
|
for (let i = 0; i < capacity; i++) {
|
|
52
52
|
buffer.set(i, schema.default);
|
|
@@ -62,7 +62,7 @@ export function registerTypedBufferCodecs() {
|
|
|
62
62
|
}
|
|
63
63
|
else if (type === "enum") {
|
|
64
64
|
const buffer = createEnumBuffer(schema, capacity);
|
|
65
|
-
if (!schema.ephemeral) {
|
|
65
|
+
if (!(schema.nonPersistent ?? schema.ephemeral)) {
|
|
66
66
|
if (binary[0]) {
|
|
67
67
|
copyViewBytes(binary[0], buffer.getTypedArray());
|
|
68
68
|
}
|
|
@@ -76,7 +76,7 @@ export function registerTypedBufferCodecs() {
|
|
|
76
76
|
}
|
|
77
77
|
else if (type === "number" || type === "struct") {
|
|
78
78
|
const buffer = type === "number" ? createNumberBuffer(schema, capacity) : createStructBuffer(schema, capacity);
|
|
79
|
-
if (schema.ephemeral) {
|
|
79
|
+
if ((schema.nonPersistent ?? schema.ephemeral)) {
|
|
80
80
|
if (schema.default !== undefined && schema.default !== 0) {
|
|
81
81
|
for (let i = 0; i < capacity; i++) {
|
|
82
82
|
buffer.set(i, schema.default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-typed-buffer-codecs.js","sourceRoot":"","sources":["../../src/typed-buffer/register-typed-buffer-codecs.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,UAAU,yBAAyB;IACrC,aAAa,CAAmB;QAC5B,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,aAAa;QACxB,SAAS,EAAE,CAAC,IAAsB,EAAE,EAAE;YAClC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;YACxC,IAAI,CAAC;gBACD,IAAI,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"register-typed-buffer-codecs.js","sourceRoot":"","sources":["../../src/typed-buffer/register-typed-buffer-codecs.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAE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C,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBAC/G,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC7C,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;wBACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;4BAChC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;wBAClC,CAAC;oBACL,CAAC;gBACL,CAAC;qBACI,CAAC;oBACF,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;gBACrD,CAAC;gBACD,OAAO,MAAM,CAAC;YAClB,CAAC;iBACI,CAAC;gBACF,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;YAC7C,CAAC;QACL,CAAC;KACJ,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
export { assertStruct } from "./assert-struct.js";
|
|
2
3
|
export { getStructLayout } from "./get-struct-layout.js";
|
|
3
4
|
export * from "./struct-layout.js";
|
|
5
|
+
export { wgslStructFields } from "./wgsl-struct-fields.js";
|
|
4
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/typed-buffer/structs/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/typed-buffer/structs/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Schema } from "../../schema/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generates WGSL struct field declarations from a JSON Schema object type.
|
|
4
|
+
*
|
|
5
|
+
* Maps each property to the appropriate WGSL type (f32, vec3f, mat4x4f, etc.)
|
|
6
|
+
* using the same schema that drives host-side TypedBuffer layout — so the host
|
|
7
|
+
* struct and the WGSL struct are guaranteed to agree on field order and types.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```ts
|
|
11
|
+
* const source = `
|
|
12
|
+
* struct MyUniforms {
|
|
13
|
+
* ${wgslStructFields(MyUniforms.schema)}
|
|
14
|
+
* }`;
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const wgslStructFields: (schema: Schema) => string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
const primitiveWgslType = (schema) => {
|
|
3
|
+
if (schema.type === "number")
|
|
4
|
+
return "f32";
|
|
5
|
+
if (schema.type === "integer") {
|
|
6
|
+
return schema.minimum !== undefined && schema.minimum >= 0 ? "u32" : "i32";
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
const fieldWgslType = (schema) => {
|
|
11
|
+
const prim = primitiveWgslType(schema);
|
|
12
|
+
if (prim)
|
|
13
|
+
return prim;
|
|
14
|
+
if (schema.type === "array" &&
|
|
15
|
+
schema.items !== undefined &&
|
|
16
|
+
!Array.isArray(schema.items) &&
|
|
17
|
+
schema.minItems === schema.maxItems &&
|
|
18
|
+
schema.minItems !== undefined) {
|
|
19
|
+
const elemType = primitiveWgslType(schema.items);
|
|
20
|
+
if (!elemType)
|
|
21
|
+
return null;
|
|
22
|
+
const n = schema.minItems;
|
|
23
|
+
const suffix = elemType === "f32" ? "f" : elemType === "i32" ? "i" : "u";
|
|
24
|
+
if (n === 16 && suffix === "f")
|
|
25
|
+
return "mat4x4f";
|
|
26
|
+
if (n === 2 || n === 3 || n === 4)
|
|
27
|
+
return `vec${n}${suffix}`;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Generates WGSL struct field declarations from a JSON Schema object type.
|
|
33
|
+
*
|
|
34
|
+
* Maps each property to the appropriate WGSL type (f32, vec3f, mat4x4f, etc.)
|
|
35
|
+
* using the same schema that drives host-side TypedBuffer layout — so the host
|
|
36
|
+
* struct and the WGSL struct are guaranteed to agree on field order and types.
|
|
37
|
+
*
|
|
38
|
+
* Usage:
|
|
39
|
+
* ```ts
|
|
40
|
+
* const source = `
|
|
41
|
+
* struct MyUniforms {
|
|
42
|
+
* ${wgslStructFields(MyUniforms.schema)}
|
|
43
|
+
* }`;
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export const wgslStructFields = (schema) => {
|
|
47
|
+
if (schema.type !== "object" || !schema.properties)
|
|
48
|
+
return "";
|
|
49
|
+
return Object.entries(schema.properties)
|
|
50
|
+
.map(([name, fieldSchema]) => {
|
|
51
|
+
const type = fieldWgslType(fieldSchema);
|
|
52
|
+
if (!type)
|
|
53
|
+
throw new Error(`Cannot map schema field "${name}" to a WGSL type`);
|
|
54
|
+
return ` ${name}: ${type},`;
|
|
55
|
+
})
|
|
56
|
+
.join("\n");
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=wgsl-struct-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgsl-struct-fields.js","sourceRoot":"","sources":["../../../src/typed-buffer/structs/wgsl-struct-fields.ts"],"names":[],"mappings":"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,CAAC,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE;IACvD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAC9D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;SACnC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE;QACzB,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,kBAAkB,CAAC,CAAC;QAC/E,OAAO,OAAO,IAAI,KAAK,IAAI,GAAG,CAAC;IACnC,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AACpB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/data",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.70",
|
|
4
4
|
"description": "Adobe data oriented programming library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -185,6 +185,7 @@
|
|
|
185
185
|
"pre-commit": "lint-staged",
|
|
186
186
|
"publish-public": "pnpm build && pnpm publish --no-git-checks --access public",
|
|
187
187
|
"perftest": "node dist/perftest/index.js",
|
|
188
|
+
"check:emit": "node scripts/emit-stripinternal/check.mjs",
|
|
188
189
|
"test": "vitest --run",
|
|
189
190
|
"test:ci": "SKIP_PERF=1 vitest --run",
|
|
190
191
|
"asbuild:debug": "asc assembly/index.ts -o dist/assembly/index.wasm --target debug --enable simd && echo built dist/assembly/index.wasm",
|
|
@@ -9,8 +9,23 @@ import { attachDecorator, withHooks } from '../index.js';
|
|
|
9
9
|
|
|
10
10
|
export abstract class DatabaseElement<P extends Database.Plugin> extends LitElement {
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* The live database, fully typed. Set by an ancestor via DI (`.database=…`)
|
|
14
|
+
* or created from `plugin` on connect. Bootstrap containers — those that own
|
|
15
|
+
* a controller or drive a streaming (async-generator) transaction — read
|
|
16
|
+
* this directly; pure widgets use the restricted `service` view below.
|
|
17
|
+
*/
|
|
12
18
|
@property({ type: Object, reflect: false })
|
|
13
|
-
|
|
19
|
+
database!: Database.Plugin.ToDatabase<P>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* UI-restricted view of {@link database} for pure-widget rendering: every
|
|
23
|
+
* transaction / mutator is rewritten to fire-and-forget `void` so a widget
|
|
24
|
+
* can never await on or read back a mutation; reads go through `observe`.
|
|
25
|
+
*/
|
|
26
|
+
get service(): UIService.FromService<Database.Plugin.ToDatabase<P>> {
|
|
27
|
+
return UIService.restrict(this.database);
|
|
28
|
+
}
|
|
14
29
|
|
|
15
30
|
constructor() {
|
|
16
31
|
super();
|
|
@@ -20,18 +35,18 @@ export abstract class DatabaseElement<P extends Database.Plugin> extends LitElem
|
|
|
20
35
|
abstract get plugin(): P;
|
|
21
36
|
|
|
22
37
|
connectedCallback(): void {
|
|
23
|
-
if (!this.
|
|
24
|
-
const
|
|
25
|
-
this.
|
|
38
|
+
if (!this.database) {
|
|
39
|
+
const ancestor = this.findAncestorDatabase();
|
|
40
|
+
this.database = ancestor?.extend(this.plugin) ?? Database.create(this.plugin);
|
|
26
41
|
}
|
|
27
42
|
super.connectedCallback();
|
|
28
43
|
}
|
|
29
44
|
|
|
30
45
|
protected findAncestorDatabase(): Database | void {
|
|
31
46
|
for (const element of iterateSelfAndAncestors(this)) {
|
|
32
|
-
const {
|
|
33
|
-
if (Database.is(
|
|
34
|
-
return
|
|
47
|
+
const { database } = element as Partial<DatabaseElement<any>>;
|
|
48
|
+
if (Database.is(database)) {
|
|
49
|
+
return database;
|
|
35
50
|
}
|
|
36
51
|
}
|
|
37
52
|
}
|
|
@@ -5,12 +5,12 @@ import { useEffect } from "./use-effect.js";
|
|
|
5
5
|
import type { AsyncArgsProvider } from '@adobe/data/ecs';
|
|
6
6
|
import { Observe } from '@adobe/data/observe';
|
|
7
7
|
|
|
8
|
-
export type DragTransactionProps<T> = DragObserveProps & {
|
|
8
|
+
export type DragTransactionProps<T extends {} | null> = DragObserveProps & {
|
|
9
9
|
transaction: (asyncArgs: AsyncArgsProvider<T>) => void;
|
|
10
10
|
update: (drag: DragMove | DragEnd) => T | void;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export function useDragTransaction<T>(props: DragTransactionProps<T>, dependencies: unknown[]) {
|
|
13
|
+
export function useDragTransaction<T extends {} | null>(props: DragTransactionProps<T>, dependencies: unknown[]) {
|
|
14
14
|
const { transaction, update } = props;
|
|
15
15
|
const dragObserve = useDragObserve(props, dependencies);
|
|
16
16
|
const startDragTransaction = () => {
|
|
@@ -17,8 +17,8 @@ import { useMemo } from "./use-memo.js";
|
|
|
17
17
|
* ### Driving a never-ending presence transaction
|
|
18
18
|
*
|
|
19
19
|
* Pair with `Observe.toAsyncGenerator` to feed a never-ending async-generator
|
|
20
|
-
* transaction. Each `yield` becomes
|
|
21
|
-
* service forwards as `kind: "
|
|
20
|
+
* transaction. Each `yield` becomes an intermediate envelope that the sync
|
|
21
|
+
* service forwards as `kind: "intermediate"`. The reconciler's `(userId, id)`
|
|
22
22
|
* compound key replaces the previous sample, so each peer has at most one
|
|
23
23
|
* outstanding cursor sample at any time.
|
|
24
24
|
*
|
|
@@ -14,5 +14,5 @@ type TictactoeService = Database.Plugin.ToDatabase<typeof tictactoePlugin>;
|
|
|
14
14
|
*/
|
|
15
15
|
export const Tictactoe = <S extends TictactoeService>(args: { service: S }): TemplateResult => {
|
|
16
16
|
void import("./tictactoe-app-element.js");
|
|
17
|
-
return html`<tictactoe-app .
|
|
17
|
+
return html`<tictactoe-app .database=${args.service}></tictactoe-app>`;
|
|
18
18
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-react-hello",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.70",
|
|
4
4
|
"description": "Hello World sample - click counter using @adobe/data-react",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": true,
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/react": "^19",
|
|
20
20
|
"@types/react-dom": "^19",
|
|
21
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
21
22
|
"typescript": "^5.8.3",
|
|
22
23
|
"vite": "^5.1.1",
|
|
23
|
-
"
|
|
24
|
+
"vite-plugin-checker": "^0.12.0"
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as AsyncDataService from "./public.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/service/async-data-service/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC"}
|