@adobe/data 0.2.9 → 0.2.11
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/README.md +310 -0
- package/dist/cache/functions/bind-functions.d.ts +6 -0
- package/dist/cache/functions/bind-functions.js +33 -0
- package/dist/cache/functions/bind-functions.js.map +1 -0
- package/dist/cache/functions/omit.d.ts +1 -0
- package/dist/cache/functions/omit.js +29 -0
- package/dist/cache/functions/omit.js.map +1 -0
- package/dist/cache/functions/types.d.ts +1 -0
- package/dist/cache/functions/types.js +23 -0
- package/dist/cache/functions/types.js.map +1 -0
- package/dist/cache/memory-allocator.js +23 -1
- package/dist/cache/memory-allocator.js.map +1 -1
- package/dist/core/data.d.ts +22 -0
- package/dist/core/data.js +52 -0
- package/dist/core/data.js.map +1 -0
- package/dist/core/data.test.d.ts +1 -0
- package/dist/core/data.test.js +48 -0
- package/dist/core/data.test.js.map +1 -0
- package/dist/core/functions/array-equals.d.ts +1 -0
- package/dist/core/functions/array-equals.js +34 -0
- package/dist/core/functions/array-equals.js.map +1 -0
- package/dist/core/functions/deep-merge.d.ts +32 -0
- package/dist/core/functions/deep-merge.js +54 -0
- package/dist/core/functions/deep-merge.js.map +1 -0
- package/dist/core/functions/deep-merge.test.d.ts +1 -0
- package/dist/core/functions/deep-merge.test.js +94 -0
- package/dist/core/functions/deep-merge.test.js.map +1 -0
- package/dist/core/functions/index.d.ts +3 -0
- package/dist/core/functions/index.js +25 -0
- package/dist/core/functions/index.js.map +1 -0
- package/dist/core/functions/is-async-generator.d.ts +1 -0
- package/dist/core/functions/is-async-generator.js +25 -0
- package/dist/core/functions/is-async-generator.js.map +1 -0
- package/dist/core/functions/is-promise.d.ts +1 -0
- package/dist/core/functions/is-promise.js +26 -0
- package/dist/core/functions/is-promise.js.map +1 -0
- package/dist/core/functions/with-validation.d.ts +5 -0
- package/dist/core/functions/with-validation.js +38 -0
- package/dist/core/functions/with-validation.js.map +1 -0
- package/dist/core/functions/with-validation.test.d.ts +1 -0
- package/dist/core/functions/with-validation.test.js +96 -0
- package/dist/core/functions/with-validation.test.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +25 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/schema/dynamic/dynamic-schema.d.ts +27 -0
- package/dist/core/schema/dynamic/dynamic-schema.js +2 -0
- package/dist/core/schema/dynamic/dynamic-schema.js.map +1 -0
- package/dist/core/schema/dynamic/enumerate-patches.d.ts +9 -0
- package/dist/core/schema/dynamic/enumerate-patches.js +50 -0
- package/dist/core/schema/dynamic/enumerate-patches.js.map +1 -0
- package/dist/core/schema/dynamic/enumerate-patches.test.d.ts +134 -0
- package/dist/core/schema/dynamic/enumerate-patches.test.js +209 -0
- package/dist/core/schema/dynamic/enumerate-patches.test.js.map +1 -0
- package/dist/core/schema/dynamic/get-dynamic-schema.d.ts +5 -0
- package/dist/core/schema/dynamic/get-dynamic-schema.js +26 -0
- package/dist/core/schema/dynamic/get-dynamic-schema.js.map +1 -0
- package/dist/core/schema/dynamic/get-dynamic-schema.test.d.ts +1 -0
- package/dist/core/schema/dynamic/get-dynamic-schema.test.js +94 -0
- package/dist/core/schema/dynamic/get-dynamic-schema.test.js.map +1 -0
- package/dist/core/schema/dynamic/index.d.ts +1 -0
- package/dist/core/schema/dynamic/index.js +2 -0
- package/dist/core/schema/dynamic/index.js.map +1 -0
- package/dist/core/schema/dynamic/schema-path-value-path.d.ts +5 -0
- package/dist/core/schema/dynamic/schema-path-value-path.js +12 -0
- package/dist/core/schema/dynamic/schema-path-value-path.js.map +1 -0
- package/dist/core/schema/dynamic-schema.d.ts +27 -0
- package/dist/core/schema/dynamic-schema.js +2 -0
- package/dist/core/schema/dynamic-schema.js.map +1 -0
- package/dist/core/schema/index.d.ts +4 -0
- package/dist/core/schema/index.js +26 -0
- package/dist/core/schema/index.js.map +1 -0
- package/dist/core/schema/schema.d.ts +122 -0
- package/dist/core/schema/schema.js +34 -0
- package/dist/core/schema/schema.js.map +1 -0
- package/dist/core/schema/schemas.d.ts +45 -0
- package/dist/core/schema/schemas.js +39 -0
- package/dist/core/schema/schemas.js.map +1 -0
- package/dist/core/schema/ui-schema.d.ts +25 -0
- package/dist/core/schema/ui-schema.js +2 -0
- package/dist/core/schema/ui-schema.js.map +1 -0
- package/dist/core/schema/validation/is-valid.d.ts +2 -0
- package/dist/core/schema/validation/is-valid.js +14 -0
- package/dist/core/schema/validation/is-valid.js.map +1 -0
- package/dist/core/schema/validation/is-valid.test.d.ts +1 -0
- package/dist/core/schema/validation/is-valid.test.js +40 -0
- package/dist/core/schema/validation/is-valid.test.js.map +1 -0
- package/dist/core/schema/validation/validate.d.ts +2 -0
- package/dist/core/schema/validation/validate.js +38 -0
- package/dist/core/schema/validation/validate.js.map +1 -0
- package/dist/core/schema/validation/validate.test.d.ts +1 -0
- package/dist/core/schema/validation/validate.test.js +106 -0
- package/dist/core/schema/validation/validate.test.js.map +1 -0
- package/dist/core/schema/validation/with-validation.d.ts +5 -0
- package/dist/core/schema/validation/with-validation.js +16 -0
- package/dist/core/schema/validation/with-validation.js.map +1 -0
- package/dist/core/schema/validation/with-validation.test.d.ts +1 -0
- package/dist/core/schema/validation/with-validation.test.js +96 -0
- package/dist/core/schema/validation/with-validation.test.js.map +1 -0
- package/dist/core/schema.d.ts +86 -0
- package/dist/core/schema.js +33 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/schema.test.d.ts +1 -0
- package/dist/core/schema.test.js +16 -0
- package/dist/core/schema.test.js.map +1 -0
- package/dist/core/schemas.d.ts +45 -0
- package/dist/core/schemas.js +39 -0
- package/dist/core/schemas.js.map +1 -0
- package/dist/ecs/action-ecs/action-ecs.d.ts +19 -0
- package/dist/ecs/action-ecs/action-ecs.js +203 -0
- package/dist/ecs/action-ecs/action-ecs.js.map +1 -0
- package/dist/ecs/action-ecs/action-ecs.test.d.ts +1 -0
- package/dist/ecs/action-ecs/action-ecs.test.js +362 -0
- package/dist/ecs/action-ecs/action-ecs.test.js.map +1 -0
- package/dist/ecs/action-ecs/action-types.d.ts +106 -0
- package/dist/ecs/action-ecs/action-types.js +19 -0
- package/dist/ecs/action-ecs/action-types.js.map +1 -0
- package/dist/ecs/action-ecs/index.d.ts +2 -0
- package/dist/ecs/action-ecs/index.js +23 -0
- package/dist/ecs/action-ecs/index.js.map +1 -0
- package/dist/ecs/core-ecs/core-ecs-serialization.test.d.ts +1 -0
- package/dist/ecs/core-ecs/core-ecs-serialization.test.js +230 -0
- package/dist/ecs/core-ecs/core-ecs-serialization.test.js.map +1 -0
- package/dist/ecs/core-ecs/core-ecs-types.d.ts +141 -0
- package/dist/ecs/core-ecs/core-ecs-types.js +23 -0
- package/dist/ecs/core-ecs/core-ecs-types.js.map +1 -0
- package/dist/ecs/core-ecs/core-ecs.d.ts +7 -0
- package/dist/ecs/core-ecs/core-ecs.js +492 -0
- package/dist/ecs/core-ecs/core-ecs.js.map +1 -0
- package/dist/ecs/core-ecs/core-ecs.test.d.ts +1 -0
- package/dist/ecs/core-ecs/core-ecs.test.js +425 -0
- package/dist/ecs/core-ecs/core-ecs.test.js.map +1 -0
- package/dist/ecs/core-ecs/index.d.ts +1 -0
- package/dist/ecs/core-ecs/index.js +2 -0
- package/dist/ecs/core-ecs/index.js.map +1 -0
- package/dist/ecs/database/database-schema/create-database-schema-test.js +0 -2
- package/dist/ecs/database/database-schema/create-database-schema-test.js.map +1 -1
- package/dist/ecs/ecs/ecs-types.d.ts +132 -0
- package/dist/ecs/ecs/ecs-types.js +23 -0
- package/dist/ecs/ecs/ecs-types.js.map +1 -0
- package/dist/ecs/ecs/ecs-where-functions.d.ts +6 -0
- package/dist/ecs/ecs/ecs-where-functions.js +91 -0
- package/dist/ecs/ecs/ecs-where-functions.js.map +1 -0
- package/dist/ecs/ecs/ecs.d.ts +13 -0
- package/dist/ecs/ecs/ecs.js +177 -0
- package/dist/ecs/ecs/ecs.js.map +1 -0
- package/dist/ecs/ecs/ecs.test.d.ts +1 -0
- package/dist/ecs/ecs/ecs.test.js +399 -0
- package/dist/ecs/ecs/ecs.test.js.map +1 -0
- package/dist/ecs/ecs/index.d.ts +3 -0
- package/dist/ecs/ecs/index.js +3 -0
- package/dist/ecs/ecs/index.js.map +1 -0
- package/dist/ecs/entity-location-table/create-entity-location-table.js +5 -3
- package/dist/ecs/entity-location-table/create-entity-location-table.js.map +1 -1
- package/dist/ecs/store/core/create-core.js +4 -0
- package/dist/ecs/store/core/create-core.js.map +1 -1
- package/dist/ecs/transaction-ecs/index.d.ts +2 -0
- package/dist/ecs/transaction-ecs/index.js +24 -0
- package/dist/ecs/transaction-ecs/index.js.map +1 -0
- package/dist/ecs/transaction-ecs/transaction-ecs.d.ts +11 -0
- package/dist/ecs/transaction-ecs/transaction-ecs.js +184 -0
- package/dist/ecs/transaction-ecs/transaction-ecs.js.map +1 -0
- package/dist/ecs/transaction-ecs/transaction-ecs.test.d.ts +1 -0
- package/dist/ecs/transaction-ecs/transaction-ecs.test.js +599 -0
- package/dist/ecs/transaction-ecs/transaction-ecs.test.js.map +1 -0
- package/dist/ecs/transaction-ecs/transaction-types.d.ts +135 -0
- package/dist/ecs/transaction-ecs/transaction-types.js +2 -0
- package/dist/ecs/transaction-ecs/transaction-types.js.map +1 -0
- package/dist/ecs/transaction-ecs/transactions.d.ts +5 -0
- package/dist/ecs/transaction-ecs/transactions.js +158 -0
- package/dist/ecs/transaction-ecs/transactions.js.map +1 -0
- package/dist/internal/array-buffer-like/grow.d.ts +1 -1
- package/dist/internal/array-buffer-like/grow.js +1 -49
- package/dist/internal/array-buffer-like/grow.js.map +1 -1
- package/dist/internal/shared-array-buffer/create-shared-array-buffer.d.ts +1 -0
- package/dist/internal/shared-array-buffer/create-shared-array-buffer.js +28 -0
- package/dist/internal/shared-array-buffer/create-shared-array-buffer.js.map +1 -0
- package/dist/internal/typed-array/get-byte-size.d.ts +1 -1
- package/dist/package.json +129 -0
- package/dist/schema/schema.d.ts +1 -0
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +23 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/schemas.d.ts +45 -0
- package/dist/schemas/schemas.js +39 -0
- package/dist/schemas/schemas.js.map +1 -0
- package/dist/service/sequential-action.d.ts +18 -0
- package/dist/service/sequential-action.js +45 -0
- package/dist/service/sequential-action.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typed-buffer/create-number-buffer.js +2 -1
- package/dist/typed-buffer/create-number-buffer.js.map +1 -1
- package/dist/typed-buffer/create-struct-buffer.js +3 -2
- package/dist/typed-buffer/create-struct-buffer.js.map +1 -1
- package/package.json +1 -1
- package/dist/ecs/database/database-schema/create-database-from-schema.d.ts +0 -12
- package/dist/ecs/database/database-schema/create-database-from-schema.js +0 -8
- package/dist/ecs/database/database-schema/create-database-from-schema.js.map +0 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Data, FromSchema, Schema } from "../../core/index.js";
|
|
2
|
+
import { Observe } from "../../observe/types.js";
|
|
3
|
+
import { Simplify } from "../../types/types.js";
|
|
4
|
+
import { EntityCreateValues, Entity, EntityValues, EntityUpdateValues, CoreComponents } from "../core-ecs/core-ecs-types.js";
|
|
5
|
+
import { Archetype, ECS, ECSArchetypes, ECSComponents, ECSResources, ECSWrite, SelectOptions } from "../ecs/ecs-types.js";
|
|
6
|
+
export interface TransactionECS<C extends ECSComponents, // name => Component Value Type
|
|
7
|
+
A extends ECSArchetypes, // name => Entity Values Type
|
|
8
|
+
R extends ECSResources> extends Pick<ECS<C, A, R>, "components" | "archetypes" | "getComponentValue" | "getArchetype" | "getEntityValues" | "countEntities" | "selectEntities" | "selectEntityValues" | "toJSON">, TransactionProvider<C, A, R> {
|
|
9
|
+
resources: {
|
|
10
|
+
+readonly [K in keyof R]: R[K];
|
|
11
|
+
};
|
|
12
|
+
withComponents<S extends {
|
|
13
|
+
[K: string]: Schema;
|
|
14
|
+
}, T = {
|
|
15
|
+
-readonly [K in keyof S]: FromSchema<S[K]>;
|
|
16
|
+
}>(components: S): TransactionECS<Simplify<C & T>, A, R>;
|
|
17
|
+
withArchetypes<S extends {
|
|
18
|
+
[K: string]: ReadonlyArray<keyof C>;
|
|
19
|
+
}>(archetypes: S): TransactionECS<C, Simplify<A & {
|
|
20
|
+
[AN in keyof S]: Archetype<{
|
|
21
|
+
[PN in S[AN][number]]: C[PN];
|
|
22
|
+
}>;
|
|
23
|
+
}>, R>;
|
|
24
|
+
withResources<S extends {
|
|
25
|
+
[K: string]: Data;
|
|
26
|
+
}>(resources: S): TransactionECS<C, A, Simplify<R & S>>;
|
|
27
|
+
observe: TransactionObservables<C, A, R>;
|
|
28
|
+
}
|
|
29
|
+
export interface TransactionObservables<C extends ECSComponents = any, // name => Component Value Type
|
|
30
|
+
A extends ECSArchetypes = any, // name => Entity Values Type
|
|
31
|
+
R extends ECSResources = any> {
|
|
32
|
+
transactions: Observe<TransactionCommit<C>>;
|
|
33
|
+
resource: {
|
|
34
|
+
<K extends keyof R>(key: K): Observe<R[K]>;
|
|
35
|
+
} & {
|
|
36
|
+
[K in keyof R]: Observe<R[K]>;
|
|
37
|
+
};
|
|
38
|
+
entityValues<A extends Archetype>(id: Entity, archetype: A & Partial<EntityValues<C>>): Observe<EntityValuesFor<A> | null | undefined>;
|
|
39
|
+
entityValues(id: Entity): Observe<EntityValues<C> | undefined>;
|
|
40
|
+
entityChanges(entity: Entity): Observe<void>;
|
|
41
|
+
componentChanges<K extends keyof C>(component: K): Observe<void>;
|
|
42
|
+
archetypeChanges<A extends CoreComponents>(archetype: Archetype<A>): Observe<void>;
|
|
43
|
+
archetypeEntities<A extends CoreComponents>(archetype: Archetype<A>, options?: Omit<SelectOptions<C, A>, "components">): Observe<Entity[]>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Options when creating an ECSTransaction.
|
|
47
|
+
*/
|
|
48
|
+
export interface TransactionOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Will this transaction be added to the undo stack?
|
|
51
|
+
* Defaults to true.
|
|
52
|
+
*/
|
|
53
|
+
undoable?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* When was this transactions created in UTC time.
|
|
56
|
+
*/
|
|
57
|
+
createdTime?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The unique identifier for the user creating the transaction.
|
|
60
|
+
*/
|
|
61
|
+
createdBy?: string;
|
|
62
|
+
}
|
|
63
|
+
interface TransactionProvider<C extends ECSComponents, // name => Component Value Type
|
|
64
|
+
A extends ECSArchetypes, // name => Entity Values Type
|
|
65
|
+
R extends ECSResources> {
|
|
66
|
+
createTransaction(options?: TransactionOptions): Transaction<C, A, R>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Type alias for a CreateOperation in the ECS (Entity Component System).
|
|
70
|
+
* Represents an operation to create a new entity with the specified components.
|
|
71
|
+
* @template C - Components used by the entity.
|
|
72
|
+
*/
|
|
73
|
+
export type TransactionCreateOperation<C> = {
|
|
74
|
+
type: "create";
|
|
75
|
+
values: EntityCreateValues<C>;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Type alias for an UpdateOperation in the ECS (Entity Component System).
|
|
79
|
+
* Represents an operation to update an existing entity with the specified components.
|
|
80
|
+
* @template C - Components used by the entity.
|
|
81
|
+
*/
|
|
82
|
+
export type TransactionUpdateOperation<C> = {
|
|
83
|
+
type: "update";
|
|
84
|
+
entity: Entity;
|
|
85
|
+
values: EntityUpdateValues<C>;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Type alias for a DeleteOperation in the ECS (Entity Component System).
|
|
89
|
+
* Represents an operation to delete an existing entity.
|
|
90
|
+
*/
|
|
91
|
+
export type TransactionDeleteOperation = {
|
|
92
|
+
type: "delete";
|
|
93
|
+
entity: Entity;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Type alias for a WriteOperation in the ECS (Entity Component System).
|
|
97
|
+
* Represents an operation to create, update, or delete an entity.
|
|
98
|
+
* @template C - Components used by the entity.
|
|
99
|
+
*/
|
|
100
|
+
export type TransactionWriteOperation<C> = TransactionCreateOperation<C> | TransactionUpdateOperation<C> | TransactionDeleteOperation;
|
|
101
|
+
/**
|
|
102
|
+
* Represents a completed transaction in the ECS, which can either be a commit or a cancel.
|
|
103
|
+
* @template C - Components used in the transaction.
|
|
104
|
+
*/
|
|
105
|
+
export type TransactionComplete<C> = TransactionCommit<C> | TransactionCancel;
|
|
106
|
+
/**
|
|
107
|
+
* Represents a committed transaction in the ECS.
|
|
108
|
+
* @template C - Components used in the transaction.
|
|
109
|
+
*/
|
|
110
|
+
export interface TransactionCommit<C> {
|
|
111
|
+
committed: true;
|
|
112
|
+
options: TransactionOptions;
|
|
113
|
+
redoOperations: TransactionWriteOperation<C>[];
|
|
114
|
+
undoOperations: TransactionWriteOperation<C>[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Represents a cancelled transaction in the ECS.
|
|
118
|
+
*/
|
|
119
|
+
export interface TransactionCancel {
|
|
120
|
+
committed: false;
|
|
121
|
+
options: TransactionOptions;
|
|
122
|
+
}
|
|
123
|
+
export interface Transaction<C extends ECSComponents, // name => Component Value Type
|
|
124
|
+
A extends ECSArchetypes, // name => Entity Values Type
|
|
125
|
+
R extends ECSResources> extends TransactionProvider<C, A, R>, ECSWrite<C> {
|
|
126
|
+
readonly ecs: TransactionECS<C, A, R>;
|
|
127
|
+
readonly options: Required<TransactionOptions>;
|
|
128
|
+
readonly resources: {
|
|
129
|
+
-readonly [K in keyof R]: R[K];
|
|
130
|
+
};
|
|
131
|
+
batch(operations: TransactionWriteOperation<C>[]): this;
|
|
132
|
+
commit(): TransactionCommit<C>;
|
|
133
|
+
cancel(): TransactionCancel;
|
|
134
|
+
}
|
|
135
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-types.js","sourceRoot":"","sources":["../../../src/ecs/transaction-ecs/transaction-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ECS, ECSArchetypes, ECSComponents, ECSResources } from "../ecs/ecs-types.js";
|
|
2
|
+
import { Transaction, TransactionChanges, TransactionCommit, TransactionECS, TransactionOptions } from "./transaction-types.js";
|
|
3
|
+
export declare function createECSTransaction<C extends ECSComponents, // name => Component Value Type
|
|
4
|
+
A extends ECSArchetypes, // name => Entity Values Type
|
|
5
|
+
R extends ECSResources>(tecs: TransactionECS<C, A, R>, ecs: ECS<C, A, R>, options: Required<TransactionOptions>, transactionCommmitted: (value: TransactionCommit<C>, changes: TransactionChanges<C>) => void, parent?: Transaction<C, A, R>): Transaction<C, A, R>;
|
|
@@ -0,0 +1,158 @@
|
|
|
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 whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.*/
|
|
22
|
+
import { DELETE } from "../core-ecs/core-ecs.js";
|
|
23
|
+
export function createECSTransaction(tecs, ecs, options, transactionCommmitted, parent) {
|
|
24
|
+
const write = parent ?? ecs;
|
|
25
|
+
const redoOperations = [];
|
|
26
|
+
const undoOperationsInReverseOrder = [];
|
|
27
|
+
const changed = {
|
|
28
|
+
entities: new Set(),
|
|
29
|
+
components: new Set(),
|
|
30
|
+
archetypes: new Set(),
|
|
31
|
+
};
|
|
32
|
+
function createEntity(archetype, values) {
|
|
33
|
+
const entity = archetype && values
|
|
34
|
+
? write.createEntity(archetype, values)
|
|
35
|
+
: write.createEntity();
|
|
36
|
+
redoOperations.push({
|
|
37
|
+
type: "create",
|
|
38
|
+
values: (values ?? {}),
|
|
39
|
+
});
|
|
40
|
+
undoOperationsInReverseOrder.push({ type: "delete", entity });
|
|
41
|
+
changed.entities.add(entity);
|
|
42
|
+
changed.archetypes.add(ecs.getEntityArchetype(entity));
|
|
43
|
+
for (const key in values) {
|
|
44
|
+
changed.components.add(key);
|
|
45
|
+
}
|
|
46
|
+
return entity;
|
|
47
|
+
}
|
|
48
|
+
function updateEntity(entity, values) {
|
|
49
|
+
const oldValues = ecs.getEntityValues(entity);
|
|
50
|
+
const replacedValues = {};
|
|
51
|
+
for (const name in values) {
|
|
52
|
+
const newValue = values[name];
|
|
53
|
+
let oldValue = oldValues[name];
|
|
54
|
+
if (newValue !== oldValue) {
|
|
55
|
+
if (oldValue === undefined) {
|
|
56
|
+
oldValue = DELETE;
|
|
57
|
+
}
|
|
58
|
+
replacedValues[name] = oldValue;
|
|
59
|
+
changed.components.add(name);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
changed.entities.add(entity);
|
|
63
|
+
changed.archetypes.add(ecs.getEntityArchetype(entity));
|
|
64
|
+
write.updateEntity(entity, values);
|
|
65
|
+
// archetype may have changed after update so we need to add new one.
|
|
66
|
+
changed.archetypes.add(ecs.getEntityArchetype(entity));
|
|
67
|
+
// maybe collapse adjacent updates to same entity.
|
|
68
|
+
const lastUndoOperation = undoOperationsInReverseOrder[undoOperationsInReverseOrder.length - 1];
|
|
69
|
+
if (lastUndoOperation?.type === "update" &&
|
|
70
|
+
lastUndoOperation.entity === entity) {
|
|
71
|
+
const lastRedoOperation = redoOperations[redoOperations.length - 1];
|
|
72
|
+
lastRedoOperation.values = { ...lastRedoOperation.values, ...values };
|
|
73
|
+
lastUndoOperation.values = {
|
|
74
|
+
...replacedValues,
|
|
75
|
+
...lastUndoOperation.values,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
redoOperations.push({ type: "update", entity, values });
|
|
80
|
+
undoOperationsInReverseOrder.push({
|
|
81
|
+
type: "update",
|
|
82
|
+
entity,
|
|
83
|
+
values: replacedValues,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function deleteEntity(entity) {
|
|
88
|
+
changed.archetypes.add(ecs.getEntityArchetype(entity));
|
|
89
|
+
changed.entities.add(entity);
|
|
90
|
+
const { id: _ignore, ...oldValues } = ecs.getEntityValues(entity);
|
|
91
|
+
for (const key in oldValues) {
|
|
92
|
+
changed.components.add(key);
|
|
93
|
+
}
|
|
94
|
+
write.deleteEntity(entity);
|
|
95
|
+
redoOperations.push({ type: "delete", entity });
|
|
96
|
+
undoOperationsInReverseOrder.push({ type: "create", values: oldValues });
|
|
97
|
+
}
|
|
98
|
+
function batch(operations) {
|
|
99
|
+
for (const operation of operations) {
|
|
100
|
+
switch (operation.type) {
|
|
101
|
+
case "create": {
|
|
102
|
+
const archetype = ecs.getArchetype("id", ...Object.keys(operation.values));
|
|
103
|
+
createEntity(archetype, operation.values);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "update":
|
|
107
|
+
updateEntity(operation.entity, operation.values);
|
|
108
|
+
break;
|
|
109
|
+
case "delete":
|
|
110
|
+
deleteEntity(operation.entity);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return transaction;
|
|
115
|
+
}
|
|
116
|
+
function complete(committed) {
|
|
117
|
+
const undoOperations = undoOperationsInReverseOrder.slice(0).reverse();
|
|
118
|
+
if (!committed) {
|
|
119
|
+
batch(undoOperations);
|
|
120
|
+
}
|
|
121
|
+
if (committed) {
|
|
122
|
+
const result = { committed, options, redoOperations, undoOperations };
|
|
123
|
+
if (!parent && committed) {
|
|
124
|
+
transactionCommmitted(result, changed);
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return { committed, options };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const setComponentValue = (id, component, value) => {
|
|
133
|
+
updateEntity(id, { [component]: value });
|
|
134
|
+
};
|
|
135
|
+
const transaction = {
|
|
136
|
+
ecs: tecs,
|
|
137
|
+
options,
|
|
138
|
+
resources: new Proxy(ecs.resources, {
|
|
139
|
+
set: (_target, p, value, _receiver) => {
|
|
140
|
+
const archetype = ecs.getArchetype("id", p);
|
|
141
|
+
const [table] = ecs.getTables(archetype, { mode: "read", exact: true });
|
|
142
|
+
const id = table.columns.id.get(0);
|
|
143
|
+
updateEntity(id, { [p]: value });
|
|
144
|
+
return true;
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
setComponentValue,
|
|
148
|
+
createTransaction: () => createECSTransaction(tecs, ecs, options, transactionCommmitted, transaction),
|
|
149
|
+
batch,
|
|
150
|
+
commit: () => complete(true),
|
|
151
|
+
cancel: () => complete(false),
|
|
152
|
+
createEntity,
|
|
153
|
+
updateEntity,
|
|
154
|
+
deleteEntity,
|
|
155
|
+
};
|
|
156
|
+
return transaction;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=transactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../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KAAK,CAAC,GAAG,CAAC,SAAS,EAAE;YAClC,GAAG,EAAE,CACH,OAA6B,EAC7B,CAAkB,EAClB,KAAU,EACV,SAAc,EACL,EAAE;gBACX,MAAM,SAAS,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAY,CAAC,CAAC;gBACvD,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBACxE,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBACnC,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,CAAY,CAAC,EAAE,KAAK,EAAS,CAAC,CAAC;gBACnD,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC;QACF,iBAAiB;QACjB,iBAAiB,EAAE,GAAG,EAAE,CACtB,oBAAoB,CAClB,IAAI,EACJ,GAAG,EACH,OAAO,EACP,qBAAqB,EACrB,WAAW,CACZ;QACH,KAAK;QACL,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC5B,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC7B,YAAY;QACZ,YAAY;QACZ,YAAY;KACb,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function grow<T extends ArrayBufferLike>(arrayBuffer: T, newCapacity: number
|
|
1
|
+
export declare function grow<T extends ArrayBufferLike>(arrayBuffer: T, newCapacity: number): T;
|
|
@@ -1,53 +1,5 @@
|
|
|
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 whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.*/
|
|
22
1
|
import { copy } from "./copy.js";
|
|
23
|
-
|
|
24
|
-
import { isSharedArrayBuffer } from "./is-shared-array-buffer.js";
|
|
25
|
-
export function grow(arrayBuffer, newCapacity, createNewIfNeeded = false) {
|
|
26
|
-
if (newCapacity <= arrayBuffer.byteLength) {
|
|
27
|
-
throw new Error("Cannot shrink");
|
|
28
|
-
}
|
|
29
|
-
if (isSharedArrayBuffer(arrayBuffer)) {
|
|
30
|
-
if (arrayBuffer.maxByteLength >= newCapacity) {
|
|
31
|
-
arrayBuffer.grow(newCapacity);
|
|
32
|
-
return arrayBuffer;
|
|
33
|
-
}
|
|
34
|
-
if (createNewIfNeeded) {
|
|
35
|
-
const newArrayBuffer = new SharedArrayBuffer(newCapacity);
|
|
36
|
-
copy(arrayBuffer, newArrayBuffer);
|
|
37
|
-
return newArrayBuffer;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else if (isArrayBuffer(arrayBuffer)) {
|
|
41
|
-
if (arrayBuffer.maxByteLength >= newCapacity) {
|
|
42
|
-
arrayBuffer.resize(newCapacity);
|
|
43
|
-
return arrayBuffer;
|
|
44
|
-
}
|
|
45
|
-
if (createNewIfNeeded) {
|
|
46
|
-
const newArrayBuffer = new ArrayBuffer(newCapacity);
|
|
47
|
-
copy(arrayBuffer, newArrayBuffer);
|
|
48
|
-
return newArrayBuffer;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
2
|
+
export function grow(arrayBuffer, newCapacity) {
|
|
51
3
|
// create a new array buffer using the same constructor, copy the data, and return it
|
|
52
4
|
const constructor = arrayBuffer.constructor;
|
|
53
5
|
const newArrayBuffer = new constructor(newCapacity);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grow.js","sourceRoot":"","sources":["../../../src/internal/array-buffer-like/grow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grow.js","sourceRoot":"","sources":["../../../src/internal/array-buffer-like/grow.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,MAAM,UAAU,IAAI,CAA4B,WAAc,EAAE,WAAmB;IAC/E,qFAAqF;IACrF,MAAM,WAAW,GAAG,WAAW,CAAC,WAAsC,CAAC;IACvE,MAAM,cAAc,GAAG,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAClC,OAAO,cAAc,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createSharedArrayBuffer(sizeInBytes: number): ArrayBuffer | SharedArrayBuffer;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.*/
|
|
22
|
+
export function createSharedArrayBuffer(sizeInBytes) {
|
|
23
|
+
if (typeof globalThis.SharedArrayBuffer === 'undefined') {
|
|
24
|
+
return new ArrayBuffer(sizeInBytes);
|
|
25
|
+
}
|
|
26
|
+
return new SharedArrayBuffer(sizeInBytes);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=create-shared-array-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-shared-array-buffer.js","sourceRoot":"","sources":["../../../src/internal/shared-array-buffer/create-shared-array-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,MAAM,UAAU,uBAAuB,CAAC,WAAmB;IACvD,IAAI,OAAO,UAAU,CAAC,iBAAiB,KAAK,WAAW,EAAE,CAAC;QACtD,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,IAAI,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { TypedArrayConstructor } from "../../types/typed-array-constructer.js";
|
|
2
|
-
export declare const getByteSize: (typedArrayConstructor: TypedArrayConstructor) =>
|
|
2
|
+
export declare const getByteSize: (typedArrayConstructor: TypedArrayConstructor) => 1 | 2 | 4 | 8;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adobe/data",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Adobe data oriented programming library",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": true,
|
|
7
|
+
"private": false,
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "pnpm build-assembly && run-p build:*",
|
|
10
|
+
"build:code": "pnpm copy && tsc -b",
|
|
11
|
+
"build:apidocs": "typedoc",
|
|
12
|
+
"build-assembly": "run-p asbuild:release",
|
|
13
|
+
"clean": "rm -rf dist build node_modules",
|
|
14
|
+
"copy": "mkdir -p dist && cp README.md dist && sed '/publish\":/d' package.json > dist/package.json",
|
|
15
|
+
"deploy-docs": "pnpm build && ./scripts/deploy-docs.sh",
|
|
16
|
+
"dev": "run-p dev:*",
|
|
17
|
+
"dev:build": "pnpm copy && tsc -b -w --preserveWatchOutput",
|
|
18
|
+
"dev:test": "pnpm test",
|
|
19
|
+
"dev:apidocs": "nodemon -w README.md -w dist -x typedoc --delay 100",
|
|
20
|
+
"dev:assembly": "nodemon -w assembly -e ts -x pnpm run asbuild:release --delay 100",
|
|
21
|
+
"lint": "pnpm eslint .",
|
|
22
|
+
"lint-fix": "pnpm eslint . --fix",
|
|
23
|
+
"debug": "vitest --inspect-brk --no-file-parallelism --test-timeout 1000000",
|
|
24
|
+
"link": "pnpm build && pnpm link --global",
|
|
25
|
+
"bump": "pnpm version patch --no-git-tag-version && git commit -am 'bumped patch version' && pnpm run publish",
|
|
26
|
+
"pre-commit": "lint-staged",
|
|
27
|
+
"perftest": "node dist/perftest/index.js",
|
|
28
|
+
"test": "vitest",
|
|
29
|
+
"asbuild:debug": "asc assembly/index.ts -o dist/assembly/index.wasm --target debug --enable simd && echo built dist/assembly/index.wasm",
|
|
30
|
+
"asbuild:release": "asc assembly/index.ts -o dist/assembly/index.wasm --target release --enable simd --optimize && echo built dist/assembly/index.wasm",
|
|
31
|
+
"start": "npx serve ."
|
|
32
|
+
},
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"./cache": {
|
|
39
|
+
"import": "./dist/cache/index.js",
|
|
40
|
+
"types": "./dist/cache/index.d.ts"
|
|
41
|
+
},
|
|
42
|
+
"./schema": {
|
|
43
|
+
"import": "./dist/schema/index.js",
|
|
44
|
+
"types": "./dist/schema/index.d.ts"
|
|
45
|
+
},
|
|
46
|
+
"./types": {
|
|
47
|
+
"import": "./dist/types/index.js",
|
|
48
|
+
"types": "./dist/types/index.d.ts"
|
|
49
|
+
},
|
|
50
|
+
"./observe": {
|
|
51
|
+
"import": "./dist/observe/index.js",
|
|
52
|
+
"types": "./dist/observe/index.d.ts"
|
|
53
|
+
},
|
|
54
|
+
"./ecs": {
|
|
55
|
+
"import": "./dist/ecs/index.js",
|
|
56
|
+
"types": "./dist/ecs/index.d.ts"
|
|
57
|
+
},
|
|
58
|
+
"./old-ecs": {
|
|
59
|
+
"import": "./dist/old-ecs/index.js",
|
|
60
|
+
"types": "./dist/old-ecs/index.d.ts"
|
|
61
|
+
},
|
|
62
|
+
"./lit": {
|
|
63
|
+
"import": "./dist/lit/index.js",
|
|
64
|
+
"types": "./dist/lit/index.d.ts"
|
|
65
|
+
},
|
|
66
|
+
"./service": {
|
|
67
|
+
"import": "./dist/service/index.js",
|
|
68
|
+
"types": "./dist/service/index.d.ts"
|
|
69
|
+
},
|
|
70
|
+
"./table": {
|
|
71
|
+
"import": "./dist/table/index.js",
|
|
72
|
+
"types": "./dist/table/index.d.ts"
|
|
73
|
+
},
|
|
74
|
+
"./typed-buffer": {
|
|
75
|
+
"import": "./dist/typed-buffer/index.js",
|
|
76
|
+
"types": "./dist/typed-buffer/index.d.ts"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@assemblyscript/loader": "^0.27.30",
|
|
81
|
+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
82
|
+
"@types/jsonpath": "^0.2.4",
|
|
83
|
+
"@types/uuid": "^10.0.0",
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
85
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
86
|
+
"@vitest/browser": "^1.6.0",
|
|
87
|
+
"@webgpu/types": "^0.1.61",
|
|
88
|
+
"assemblyscript": "^0.27.30",
|
|
89
|
+
"eslint": "^8.56.0",
|
|
90
|
+
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
91
|
+
"eslint-config-prettier": "^9.1.0",
|
|
92
|
+
"eslint-formatter-pretty": "^5.0.0",
|
|
93
|
+
"eslint-plugin-header": "^3.1.1",
|
|
94
|
+
"eslint-plugin-import": "^2.29.1",
|
|
95
|
+
"eslint-plugin-lit": "^1.11.0",
|
|
96
|
+
"eslint-plugin-lit-a11y": "^4.1.2",
|
|
97
|
+
"eslint-plugin-notice": "^0.9.10",
|
|
98
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
99
|
+
"glob": "^10.3.10",
|
|
100
|
+
"jsdom": "^24.1.0",
|
|
101
|
+
"lint-staged": "^13.2.2",
|
|
102
|
+
"nodemon": "^3.1.7",
|
|
103
|
+
"npm-run-all": "^4.1.5",
|
|
104
|
+
"playwright": "^1.46.1",
|
|
105
|
+
"prettier": "^3.2.5",
|
|
106
|
+
"prettier-package-json": "^2.8.0",
|
|
107
|
+
"pretty-quick": "^4.0.0",
|
|
108
|
+
"riteway": "v8.0.0-RC4",
|
|
109
|
+
"stylelint": "^16.2.1",
|
|
110
|
+
"stylelint-config-standard": "^36.0.0",
|
|
111
|
+
"typedoc": "^0.26.7",
|
|
112
|
+
"typescript": "^5.8.3",
|
|
113
|
+
"uuid": "^10.0.0",
|
|
114
|
+
"vite": "^5.1.1",
|
|
115
|
+
"vitest": "^1.6.0",
|
|
116
|
+
"webdriverio": "^9.0.9"
|
|
117
|
+
},
|
|
118
|
+
"lint-staged": {
|
|
119
|
+
"*.ts": "pnpm lint:ts && pnpm lint:css",
|
|
120
|
+
"*.css": "pnpm lint:css",
|
|
121
|
+
"package.json": "pnpm lint:packagejson"
|
|
122
|
+
},
|
|
123
|
+
"dependencies": {
|
|
124
|
+
"@cfworker/json-schema": "^4.1.1",
|
|
125
|
+
"@lit/context": "^1.1.5",
|
|
126
|
+
"jsonpath": "^1.1.1",
|
|
127
|
+
"lit": "^3.3.0"
|
|
128
|
+
}
|
|
129
|
+
}
|
package/dist/schema/schema.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export type FromSchemas<T> = {
|
|
|
59
59
|
[K in keyof T]: FromSchema<T[K]>;
|
|
60
60
|
};
|
|
61
61
|
export type FromSchema<T, Depth extends number = 5> = DeepReadonly<Depth extends 0 ? any : T extends {
|
|
62
|
+
type?: undefined;
|
|
62
63
|
default: infer D;
|
|
63
64
|
} ? D : T extends {
|
|
64
65
|
const: infer Const;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../core/schemas.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
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 whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.*/
|
|
22
|
+
export * from "../core/schemas.js";
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AACX,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Schema } from "../core/index.js";
|
|
2
|
+
export declare function Nullable<T extends Schema>(schema: T): {
|
|
3
|
+
oneOf: [T, {
|
|
4
|
+
type: "null";
|
|
5
|
+
}];
|
|
6
|
+
};
|
|
7
|
+
export declare function Tuple<T extends Schema, N extends number>(items: T, length: N): {
|
|
8
|
+
readonly type: "array";
|
|
9
|
+
readonly items: T;
|
|
10
|
+
readonly minItems: N;
|
|
11
|
+
readonly maxItems: N;
|
|
12
|
+
};
|
|
13
|
+
export declare const TrueSchema: {
|
|
14
|
+
readonly const: true;
|
|
15
|
+
};
|
|
16
|
+
export declare const BooleanSchema: {
|
|
17
|
+
readonly type: "boolean";
|
|
18
|
+
};
|
|
19
|
+
export declare const Float32Schema: {
|
|
20
|
+
readonly type: "number";
|
|
21
|
+
readonly precision: 1;
|
|
22
|
+
};
|
|
23
|
+
export declare const Float64Schema: {
|
|
24
|
+
readonly type: "number";
|
|
25
|
+
readonly precision: 2;
|
|
26
|
+
};
|
|
27
|
+
export declare const TimeSchema: {
|
|
28
|
+
readonly type: "number";
|
|
29
|
+
readonly precision: 2;
|
|
30
|
+
};
|
|
31
|
+
export declare const Uint8Schema: {
|
|
32
|
+
readonly type: "integer";
|
|
33
|
+
readonly minimum: 0;
|
|
34
|
+
readonly maximum: 255;
|
|
35
|
+
};
|
|
36
|
+
export declare const Uint16Schema: {
|
|
37
|
+
readonly type: "integer";
|
|
38
|
+
readonly minimum: 0;
|
|
39
|
+
readonly maximum: 65535;
|
|
40
|
+
};
|
|
41
|
+
export declare const Uint32Schema: {
|
|
42
|
+
readonly type: "integer";
|
|
43
|
+
readonly minimum: 0;
|
|
44
|
+
readonly maximum: 4294967295;
|
|
45
|
+
};
|