@adobe/data 0.6.3 → 0.7.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/dist/ecs/database/create-database.d.ts +1 -1
- package/dist/ecs/database/create-database.js +123 -198
- package/dist/ecs/database/create-database.js.map +1 -1
- package/dist/ecs/database/create-database.test.js +155 -684
- package/dist/ecs/database/create-database.test.js.map +1 -1
- package/dist/ecs/database/database.d.ts +1 -0
- package/dist/ecs/database/index.d.ts +5 -0
- package/dist/ecs/database/index.js +5 -0
- package/dist/ecs/database/index.js.map +1 -1
- package/dist/ecs/database/observe-select-entities.performance.test.js +6 -5
- package/dist/ecs/database/observe-select-entities.performance.test.js.map +1 -1
- package/dist/ecs/database/observed/create-observed-database.d.ts +7 -0
- package/dist/ecs/database/observed/create-observed-database.js +154 -0
- package/dist/ecs/database/observed/create-observed-database.js.map +1 -0
- package/dist/ecs/database/observed/create-observed-database.test.js +557 -0
- package/dist/ecs/database/observed/create-observed-database.test.js.map +1 -0
- package/dist/ecs/database/observed/observed-database.d.ts +36 -0
- package/dist/ecs/database/observed/observed-database.js +19 -0
- package/dist/ecs/database/observed/observed-database.js.map +1 -0
- package/dist/ecs/database/reconciling/create-reconciling-database.d.ts +8 -0
- package/dist/ecs/database/reconciling/create-reconciling-database.js +146 -0
- package/dist/ecs/database/reconciling/create-reconciling-database.js.map +1 -0
- package/dist/ecs/database/reconciling/create-reconciling-database.test.d.ts +1 -0
- package/dist/ecs/database/reconciling/create-reconciling-database.test.js +94 -0
- package/dist/ecs/database/reconciling/create-reconciling-database.test.js.map +1 -0
- package/dist/ecs/database/reconciling/reconciling-database.d.ts +21 -0
- package/dist/ecs/database/reconciling/reconciling-database.js +22 -0
- package/dist/ecs/database/reconciling/reconciling-database.js.map +1 -0
- package/dist/ecs/database/reconciling/reconciling-entry.d.ts +30 -0
- package/dist/ecs/database/reconciling/reconciling-entry.js +88 -0
- package/dist/ecs/database/reconciling/reconciling-entry.js.map +1 -0
- package/dist/ecs/database/transactional-store/entity-id-preservation.test.d.ts +1 -0
- package/dist/ecs/database/transactional-store/entity-id-preservation.test.js +106 -0
- package/dist/ecs/database/transactional-store/entity-id-preservation.test.js.map +1 -0
- package/dist/ecs/entity/entity.d.ts +8 -0
- package/dist/ecs/entity/entity.js +3 -0
- package/dist/ecs/entity/entity.js.map +1 -0
- package/dist/ecs/entity/u32.d.ts +8 -0
- package/dist/{lit/elements/service-context.js → ecs/entity/u32.js} +3 -3
- package/dist/ecs/entity/u32.js.map +1 -0
- package/dist/ecs/store/store-schema/create-store-schema-test.js +2 -2
- package/dist/ecs/store/store-schema/create-store-schema-test.js.map +1 -1
- package/dist/ecs/store/store-schema/create-store-schema.d.ts +1 -11
- package/dist/ecs/store/store-schema/create-store-schema.js +44 -30
- package/dist/ecs/store/store-schema/create-store-schema.js.map +1 -1
- package/dist/ecs/store/store-schema/index.d.ts +1 -2
- package/dist/ecs/store/store-schema/index.js +20 -23
- package/dist/ecs/store/store-schema/index.js.map +1 -1
- package/dist/ecs/store/store-schema/store-schema.d.ts +1 -12
- package/dist/ecs/store/store-schema/store-schema.js +55 -21
- package/dist/ecs/store/store-schema/store-schema.js.map +1 -1
- package/dist/functions/serialization/index.d.ts +1 -0
- package/dist/functions/serialization/index.js +1 -0
- package/dist/functions/serialization/index.js.map +1 -1
- package/dist/functions/serialization/serialize-to-json.d.ts +9 -0
- package/dist/functions/serialization/serialize-to-json.js +161 -0
- package/dist/functions/serialization/serialize-to-json.js.map +1 -0
- package/dist/functions/serialization/serialize-to-json.test.d.ts +1 -0
- package/dist/functions/serialization/serialize-to-json.test.js +244 -0
- package/dist/functions/serialization/serialize-to-json.test.js.map +1 -0
- package/dist/graphics/frame.d.ts +1 -22
- package/dist/graphics/frame.js +14 -11
- package/dist/graphics/frame.js.map +1 -1
- package/dist/graphics/get-web-gpu-device-and-context.d.ts +1 -2
- package/dist/graphics/get-web-gpu-device-and-context.js +23 -20
- package/dist/graphics/get-web-gpu-device-and-context.js.map +1 -1
- package/dist/graphics/graphics-context.d.ts +1 -5
- package/dist/graphics/graphics-context.js +5 -0
- package/dist/graphics/graphics-context.js.map +1 -1
- package/dist/math/aabb-face/face.d.ts +51 -0
- package/dist/math/aabb-face/face.js +110 -0
- package/dist/math/aabb-face/face.js.map +1 -0
- package/dist/math/aabb-face/face.test.d.ts +1 -0
- package/dist/math/aabb-face/face.test.js +94 -0
- package/dist/math/aabb-face/face.test.js.map +1 -0
- package/dist/math/box/box.d.ts +50 -0
- package/dist/math/box/box.js +23 -0
- package/dist/math/box/box.js.map +1 -0
- package/dist/math/face/face.d.ts +51 -0
- package/dist/math/face/face.js +110 -0
- package/dist/math/face/face.js.map +1 -0
- package/dist/math/face/face.test.d.ts +1 -0
- package/dist/math/face/face.test.js +94 -0
- package/dist/math/face/face.test.js.map +1 -0
- package/dist/math/picking/face.d.ts +1 -0
- package/dist/math/picking/face.js +2 -0
- package/dist/math/picking/face.js.map +1 -0
- package/dist/math/picking/get-closest-entity-to-line.js +1 -1
- package/dist/math/picking/get-closest-entity-to-line.js.map +1 -1
- package/dist/math/picking/get-closest-entity-to-point.js +1 -1
- package/dist/math/picking/get-closest-entity-to-point.js.map +1 -1
- package/dist/math/picking/getClosestEntityToLine.d.ts +4 -0
- package/dist/math/picking/getClosestEntityToLine.js +29 -0
- package/dist/math/picking/getClosestEntityToLine.js.map +1 -0
- package/dist/math/picking/getClosestEntityToPoint.d.ts +4 -0
- package/dist/math/picking/getClosestEntityToPoint.js +27 -0
- package/dist/math/picking/getClosestEntityToPoint.js.map +1 -0
- package/dist/math/picking/getIntersectingEntities.d.ts +12 -0
- package/dist/math/picking/getIntersectingEntities.js +15 -0
- package/dist/math/picking/getIntersectingEntities.js.map +1 -0
- package/dist/math/picking/pick-from-tables.js +1 -1
- package/dist/math/picking/pick-from-tables.js.map +1 -1
- package/dist/math/picking/pick-result.d.ts +4 -2
- package/dist/math/transform/debug-inverse.d.ts +1 -0
- package/dist/math/transform/debug-inverse.js +28 -0
- package/dist/math/transform/debug-inverse.js.map +1 -0
- package/dist/math/transform/debug-quat.d.ts +1 -0
- package/dist/math/transform/debug-quat.js +23 -0
- package/dist/math/transform/debug-quat.js.map +1 -0
- package/dist/math/transform/debug-test.d.ts +1 -0
- package/dist/math/transform/debug-test.js +34 -0
- package/dist/math/transform/debug-test.js.map +1 -0
- package/dist/math/transform/transform.d.ts +58 -0
- package/dist/math/transform/transform.js +101 -0
- package/dist/math/transform/transform.js.map +1 -0
- package/dist/math/transform/transform.test.d.ts +1 -0
- package/dist/math/transform/transform.test.js +309 -0
- package/dist/math/transform/transform.test.js.map +1 -0
- package/dist/samples/todo/services/state-service/create-todo-database.d.ts +1 -1
- package/dist/samples/todo/services/state-service/create-todo-store.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/lit/elements/service-application.d.ts +0 -9
- package/dist/lit/elements/service-application.js +0 -55
- package/dist/lit/elements/service-application.js.map +0 -1
- package/dist/lit/elements/service-context.d.ts +0 -1
- package/dist/lit/elements/service-context.js.map +0 -1
- package/dist/lit/elements/service-element.d.ts +0 -6
- package/dist/lit/elements/service-element.js +0 -43
- package/dist/lit/elements/service-element.js.map +0 -1
- package/dist/table/compact-table.d.ts +0 -7
- package/dist/table/compact-table.js +0 -15
- package/dist/table/compact-table.js.map +0 -1
- package/dist/table/compact-table.test.js +0 -121
- package/dist/table/compact-table.test.js.map +0 -1
- /package/dist/{table/compact-table.test.d.ts → ecs/database/observed/create-observed-database.test.d.ts} +0 -0
|
@@ -4,4 +4,4 @@ import { Database, ToTransactionFunctions, TransactionDeclarations } from "./dat
|
|
|
4
4
|
import { StringKeyof } from "../../types/types.js";
|
|
5
5
|
import { Components } from "../store/components.js";
|
|
6
6
|
import { ArchetypeComponents } from "../store/archetype-components.js";
|
|
7
|
-
export declare function createDatabase<const C extends Components, const R extends ResourceComponents, const A extends ArchetypeComponents<StringKeyof<C>>, const TD extends TransactionDeclarations<C, R, A>>(store: Store<C, R, A>, transactionDeclarations: TD): Database<C, R, A, ToTransactionFunctions<TD>>;
|
|
7
|
+
export declare function createDatabase<const C extends Components, const R extends ResourceComponents, const A extends ArchetypeComponents<StringKeyof<C>>, const TD extends TransactionDeclarations<C, R, A>>(store: Store<C, R, A>, transactionDeclarations: TD, now?: () => number): Database<C, R, A, ToTransactionFunctions<TD>>;
|
|
@@ -1,233 +1,158 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*MIT License
|
|
2
|
+
|
|
3
|
+
© Copyright 2025 Adobe. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.*/
|
|
4
21
|
import { isPromise } from "../../internal/promise/is-promise.js";
|
|
5
22
|
import { isAsyncGenerator } from "../../internal/async-generator/is-async-generator.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const archetypeObservers = new Map();
|
|
13
|
-
const entityObservers = new Map();
|
|
14
|
-
const transactionObservers = new Set();
|
|
15
|
-
// observation interface
|
|
16
|
-
const observeEntity = (entity, minArchetype) => (observer) => {
|
|
17
|
-
if (minArchetype) {
|
|
18
|
-
const originalObserver = observer;
|
|
19
|
-
observer = (values) => {
|
|
20
|
-
if (values) {
|
|
21
|
-
const { archetype } = store.locate(entity);
|
|
22
|
-
if (archetype.id !== minArchetype.id && !archetype.components.isSupersetOf(minArchetype.components)) {
|
|
23
|
-
// when a min archetype is provided the entity will be considered null
|
|
24
|
-
// if the entity does not satisfy the min archetype components.
|
|
25
|
-
values = null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
originalObserver(values);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Call immediately with current values
|
|
32
|
-
observer(store.read(entity));
|
|
33
|
-
// Add to observers for future changes
|
|
34
|
-
const dispose = addToMapSet(entity, entityObservers)(observer);
|
|
35
|
-
return dispose;
|
|
36
|
-
};
|
|
37
|
-
const observeArchetype = (archetype) => addToMapSet(archetype, archetypeObservers);
|
|
38
|
-
const observeComponent = mapEntries(store.componentSchemas, ([component]) => addToMapSet(component, componentObservers));
|
|
39
|
-
// Resource observation - resources are stored as entities with specific archetypes
|
|
40
|
-
const observeResource = Object.fromEntries(Object.entries(store.resources).map(([resource]) => {
|
|
41
|
-
const archetype = store.ensureArchetype(["id", resource]);
|
|
42
|
-
const resourceId = archetype.columns.id.get(0);
|
|
43
|
-
return [resource, withMap(observeEntity(resourceId), (values) => values?.[resource] ?? null)];
|
|
44
|
-
}));
|
|
45
|
-
const observeTransaction = (notify) => {
|
|
46
|
-
transactionObservers.add(notify);
|
|
47
|
-
return () => {
|
|
48
|
-
transactionObservers.delete(notify);
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
const observe = {
|
|
52
|
-
components: observeComponent,
|
|
53
|
-
resources: observeResource,
|
|
54
|
-
transactions: observeTransaction,
|
|
55
|
-
entity: observeEntity,
|
|
56
|
-
archetype: observeArchetype,
|
|
57
|
-
select: observeSelectEntities(transactionalStore, observeTransaction),
|
|
58
|
-
};
|
|
59
|
-
const { execute: transactionDatabaseExecute, resources, ...rest } = transactionalStore;
|
|
60
|
-
const notifyObservers = (result) => {
|
|
61
|
-
// Notify transaction observers
|
|
62
|
-
for (const transactionObserver of transactionObservers) {
|
|
63
|
-
transactionObserver(result);
|
|
64
|
-
}
|
|
65
|
-
// Notify component observers
|
|
66
|
-
for (const changedComponent of result.changedComponents) {
|
|
67
|
-
const observers = componentObservers.get(changedComponent);
|
|
68
|
-
if (observers) {
|
|
69
|
-
for (const observer of observers) {
|
|
70
|
-
observer();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// Notify archetype observers
|
|
75
|
-
for (const changedArchetype of result.changedArchetypes) {
|
|
76
|
-
const observers = archetypeObservers.get(changedArchetype);
|
|
77
|
-
if (observers) {
|
|
78
|
-
for (const observer of observers) {
|
|
79
|
-
observer();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// Notify entity observers
|
|
84
|
-
for (const changedEntity of result.changedEntities.keys()) {
|
|
85
|
-
const observers = entityObservers.get(changedEntity);
|
|
86
|
-
if (observers) {
|
|
87
|
-
const values = store.read(changedEntity);
|
|
88
|
-
for (const observer of observers) {
|
|
89
|
-
observer(values);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
const execute = (handler, options) => {
|
|
95
|
-
const result = transactionDatabaseExecute(handler, options);
|
|
96
|
-
notifyObservers(result);
|
|
97
|
-
return result;
|
|
98
|
-
};
|
|
23
|
+
import { createReconcilingDatabase } from "./reconciling/create-reconciling-database.js";
|
|
24
|
+
export function createDatabase(store, transactionDeclarations, now = Date.now) {
|
|
25
|
+
const reconcilingDatabase = createReconcilingDatabase(store, transactionDeclarations);
|
|
26
|
+
const applyCore = reconcilingDatabase.apply;
|
|
27
|
+
let nextTransactionId = 1;
|
|
28
|
+
const applyEnvelope = (envelope) => applyCore(envelope);
|
|
99
29
|
const transactions = {
|
|
100
30
|
serviceName: "ecs-database-transactions-service",
|
|
101
31
|
};
|
|
102
|
-
for (const
|
|
103
|
-
const transaction = transactionUntyped;
|
|
32
|
+
for (const name of Object.keys(transactionDeclarations)) {
|
|
104
33
|
transactions[name] = (args) => {
|
|
105
|
-
|
|
106
|
-
|
|
34
|
+
const transactionId = nextTransactionId;
|
|
35
|
+
nextTransactionId += 1;
|
|
36
|
+
let hasTransient = false;
|
|
37
|
+
const applyTransient = (payload) => {
|
|
38
|
+
hasTransient = true;
|
|
39
|
+
const timestamp = now();
|
|
40
|
+
applyEnvelope({
|
|
41
|
+
id: transactionId,
|
|
42
|
+
name,
|
|
43
|
+
args: payload,
|
|
44
|
+
time: -timestamp,
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const applyCommit = (payload) => {
|
|
48
|
+
const timestamp = now();
|
|
49
|
+
const result = applyEnvelope({
|
|
50
|
+
id: transactionId,
|
|
51
|
+
name,
|
|
52
|
+
args: payload,
|
|
53
|
+
time: timestamp,
|
|
54
|
+
});
|
|
55
|
+
hasTransient = false;
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
const cancelPending = () => {
|
|
59
|
+
if (!hasTransient) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
applyEnvelope({
|
|
63
|
+
id: transactionId,
|
|
64
|
+
name,
|
|
65
|
+
args: undefined,
|
|
66
|
+
time: 0,
|
|
67
|
+
});
|
|
68
|
+
hasTransient = false;
|
|
69
|
+
};
|
|
70
|
+
if (typeof args === "function") {
|
|
107
71
|
const asyncArgsProvider = args;
|
|
108
|
-
const
|
|
109
|
-
if (isAsyncGenerator(
|
|
110
|
-
const count = 0;
|
|
72
|
+
const providerResult = asyncArgsProvider();
|
|
73
|
+
if (isAsyncGenerator(providerResult)) {
|
|
111
74
|
return new Promise((resolve, reject) => {
|
|
112
75
|
(async () => {
|
|
76
|
+
let lastArgs;
|
|
113
77
|
try {
|
|
114
|
-
let
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// rollback previous transaction.
|
|
120
|
-
execute(t => {
|
|
121
|
-
if (lastTransaction) {
|
|
122
|
-
// Rollback the previous transaction to restore the state before it
|
|
123
|
-
applyOperations(t, lastTransaction.undo);
|
|
124
|
-
}
|
|
125
|
-
}, { transient: true });
|
|
126
|
-
}
|
|
127
|
-
lastTransaction = execute(t => transaction(t, asyncArgs), { transient });
|
|
128
|
-
if (!transient) {
|
|
129
|
-
// this is the last value so we will resolve to it
|
|
130
|
-
resolve(lastTransaction.value);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
// Manually iterate through the generator to capture both yield and return values
|
|
134
|
-
let result = await asyncResult.next();
|
|
135
|
-
// Process yield values one by one with rollback
|
|
136
|
-
// We can't know if a yield is final until the generator completes,
|
|
137
|
-
// so we mark all yields as transient initially
|
|
138
|
-
while (!result.done) {
|
|
139
|
-
// This is a yield value - always transient initially
|
|
140
|
-
executeNext(result.value, true);
|
|
141
|
-
result = await asyncResult.next();
|
|
78
|
+
let iteration = await providerResult.next();
|
|
79
|
+
while (!iteration.done) {
|
|
80
|
+
lastArgs = iteration.value;
|
|
81
|
+
applyTransient(iteration.value);
|
|
82
|
+
iteration = await providerResult.next();
|
|
142
83
|
}
|
|
143
|
-
|
|
144
|
-
|
|
84
|
+
const finalArgs = iteration.value !== undefined ? iteration.value : lastArgs;
|
|
85
|
+
if (finalArgs !== undefined) {
|
|
86
|
+
const commitResult = applyCommit(finalArgs);
|
|
87
|
+
resolve(commitResult?.value);
|
|
145
88
|
}
|
|
146
|
-
else
|
|
147
|
-
|
|
89
|
+
else {
|
|
90
|
+
cancelPending();
|
|
91
|
+
resolve(undefined);
|
|
148
92
|
}
|
|
149
93
|
}
|
|
150
94
|
catch (error) {
|
|
151
|
-
|
|
95
|
+
cancelPending();
|
|
152
96
|
reject(error);
|
|
153
97
|
}
|
|
154
98
|
})();
|
|
155
99
|
});
|
|
156
100
|
}
|
|
157
|
-
|
|
158
|
-
return
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
101
|
+
if (isPromise(providerResult)) {
|
|
102
|
+
return (async () => {
|
|
103
|
+
try {
|
|
104
|
+
const resolved = await providerResult;
|
|
105
|
+
const commitResult = applyCommit(resolved);
|
|
106
|
+
return commitResult?.value;
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
cancelPending();
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
})();
|
|
170
113
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return execute(t => transaction(t, asyncResult));
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
// Synchronous argument
|
|
178
|
-
return execute(t => transaction(t, args)).value;
|
|
114
|
+
const syncResult = applyCommit(providerResult);
|
|
115
|
+
return syncResult?.value;
|
|
179
116
|
}
|
|
117
|
+
const result = applyCommit(args);
|
|
118
|
+
return result?.value;
|
|
180
119
|
};
|
|
181
120
|
}
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
121
|
+
const { apply, cancel, observe, resources, toData: reconcilingToData, fromData: reconcilingFromData, ...storeMethods } = reconcilingDatabase;
|
|
122
|
+
void apply;
|
|
123
|
+
const toData = () => reconcilingToData();
|
|
124
|
+
const fromData = (data) => {
|
|
125
|
+
reconcilingFromData(data);
|
|
126
|
+
let maxId = 0;
|
|
127
|
+
if (typeof data === "object" && data !== null && "appliedEntries" in data) {
|
|
128
|
+
const appliedEntriesData = data.appliedEntries;
|
|
129
|
+
if (Array.isArray(appliedEntriesData)) {
|
|
130
|
+
for (const entry of appliedEntriesData) {
|
|
131
|
+
const rawId = entry?.id;
|
|
132
|
+
if (rawId !== undefined) {
|
|
133
|
+
const idNumber = Number(rawId);
|
|
134
|
+
if (!Number.isNaN(idNumber)) {
|
|
135
|
+
maxId = Math.max(maxId, idNumber);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
192
138
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
value: undefined,
|
|
200
|
-
undo: [],
|
|
201
|
-
redo: [],
|
|
202
|
-
undoable: null,
|
|
203
|
-
};
|
|
204
|
-
notifyObservers(notifyResult);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
nextTransactionId = Math.max(nextTransactionId, maxId + 1);
|
|
142
|
+
};
|
|
143
|
+
const cancelReconcilingEntry = (id) => {
|
|
144
|
+
cancel(id);
|
|
205
145
|
};
|
|
206
|
-
// Return the complete observable store
|
|
207
146
|
const database = {
|
|
208
147
|
serviceName: "ecs-database-service",
|
|
209
|
-
...
|
|
148
|
+
...storeMethods,
|
|
210
149
|
resources,
|
|
211
150
|
transactions,
|
|
212
151
|
observe,
|
|
213
|
-
toData
|
|
214
|
-
fromData
|
|
215
|
-
|
|
216
|
-
notifyAllObserversStoreReloaded();
|
|
217
|
-
},
|
|
152
|
+
toData,
|
|
153
|
+
fromData,
|
|
154
|
+
cancelTransaction: cancelReconcilingEntry,
|
|
218
155
|
};
|
|
219
156
|
return database;
|
|
220
157
|
}
|
|
221
|
-
const addToMapSet = (key, map) => (value) => {
|
|
222
|
-
let set = map.get(key);
|
|
223
|
-
if (set) {
|
|
224
|
-
set.add(value);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
map.set(key, (set = new Set([value])));
|
|
228
|
-
}
|
|
229
|
-
return () => {
|
|
230
|
-
set.delete(value);
|
|
231
|
-
};
|
|
232
|
-
};
|
|
233
158
|
//# sourceMappingURL=create-database.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-database.js","sourceRoot":"","sources":["../../../src/ecs/database/create-database.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-database.js","sourceRoot":"","sources":["../../../src/ecs/database/create-database.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;WAmBW;AAMX,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sDAAsD,CAAC;AAIxF,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAIzF,MAAM,UAAU,cAAc,CAM1B,KAAqB,EACrB,uBAA2B,EAC3B,MAAoB,IAAI,CAAC,GAAG;IAK5B,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC;IAEtF,MAAM,SAAS,GAAG,mBAAmB,CAAC,KAAK,CAAC;IAE5C,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAE1B,MAAM,aAAa,GAAG,CAAC,QAA8C,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE9F,MAAM,YAAY,GAAG;QACjB,WAAW,EAAE,mCAAmC;KAC5B,CAAC;IAEzB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAsB,EAAE,CAAC;QAC1E,YAAoB,CAAC,IAAe,CAAC,GAAG,CAAC,IAAa,EAAE,EAAE;YACvD,MAAM,aAAa,GAAG,iBAAiB,CAAC;YACxC,iBAAiB,IAAI,CAAC,CAAC;YAEvB,IAAI,YAAY,GAAG,KAAK,CAAC;YAEzB,MAAM,cAAc,GAAG,CAAC,OAAgB,E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