@latticexyz/recs 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2 → 2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e
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/chunk-2YR7WENB.js +2 -0
- package/dist/{chunk-A6GOEGXN.js.map → chunk-2YR7WENB.js.map} +1 -1
- package/dist/deprecated/index.js +1 -162
- package/dist/deprecated/index.js.map +1 -1
- package/dist/index.js +1 -411
- package/dist/index.js.map +1 -1
- package/package.json +5 -23
- package/dist/chunk-A6GOEGXN.js +0 -403
- package/dist/deprecated/index.cjs +0 -412
- package/dist/deprecated/index.cjs.map +0 -1
- package/dist/deprecated/index.d.cts +0 -51
- package/dist/index.cjs +0 -836
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -606
- package/dist/types-CAQycjNT.d.cts +0 -224
@@ -1,224 +0,0 @@
|
|
1
|
-
import { Subject } from 'rxjs';
|
2
|
-
import { Opaque } from 'type-fest';
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Type enum is used to specify value types in {@link ComponentSchema} to be able
|
6
|
-
* to access type values in JavaScript in addition to TypeScript type checks.
|
7
|
-
*/
|
8
|
-
declare enum Type {
|
9
|
-
Boolean = 0,
|
10
|
-
Number = 1,
|
11
|
-
OptionalNumber = 2,
|
12
|
-
BigInt = 3,
|
13
|
-
OptionalBigInt = 4,
|
14
|
-
String = 5,
|
15
|
-
OptionalString = 6,
|
16
|
-
NumberArray = 7,
|
17
|
-
OptionalNumberArray = 8,
|
18
|
-
BigIntArray = 9,
|
19
|
-
OptionalBigIntArray = 10,
|
20
|
-
StringArray = 11,
|
21
|
-
OptionalStringArray = 12,
|
22
|
-
Entity = 13,
|
23
|
-
OptionalEntity = 14,
|
24
|
-
EntityArray = 15,
|
25
|
-
OptionalEntityArray = 16,
|
26
|
-
T = 17,
|
27
|
-
OptionalT = 18
|
28
|
-
}
|
29
|
-
/**
|
30
|
-
* Used to specify type of {@link ComponentUpdate}.
|
31
|
-
* - Enter: Update added a value to an entity that did not have a value before
|
32
|
-
* - Exit: Update removed a value from an entity that had a value before
|
33
|
-
* - Update: Update changed a value of an entity that already had a value before. Note: the value doesn't need to be different from the previous value.
|
34
|
-
* - Noop: Update did nothing (removed a value from an entity that did not have a value)
|
35
|
-
*/
|
36
|
-
declare enum UpdateType {
|
37
|
-
Enter = 0,
|
38
|
-
Exit = 1,
|
39
|
-
Update = 2,
|
40
|
-
Noop = 3
|
41
|
-
}
|
42
|
-
/**
|
43
|
-
* Helper constant with all optional {@link Type}s.
|
44
|
-
*/
|
45
|
-
declare const OptionalTypes: Type[];
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Entities are represented as symbols internally for memory efficiency.
|
49
|
-
* To get the entity's string representation, use `getEntityString(entitySymbol)`
|
50
|
-
*/
|
51
|
-
type EntitySymbol = Opaque<symbol, "EntitySymbol">;
|
52
|
-
type Entity = Opaque<string, "Entity">;
|
53
|
-
/**
|
54
|
-
* Used to define the schema of a {@link Component}.
|
55
|
-
* Uses {@link Type} enum to be able to access the component type in JavaScript as well as have TypeScript type checks.
|
56
|
-
*/
|
57
|
-
type Schema = {
|
58
|
-
[key: string]: Type;
|
59
|
-
};
|
60
|
-
/**
|
61
|
-
* Used to add arbitrary metadata to components.
|
62
|
-
*/
|
63
|
-
type Metadata = {
|
64
|
-
[key: string]: unknown;
|
65
|
-
} | undefined;
|
66
|
-
/**
|
67
|
-
* Mapping between JavaScript {@link Type} enum and corresponding TypeScript type.
|
68
|
-
*/
|
69
|
-
type ValueType<T = unknown> = {
|
70
|
-
[Type.Boolean]: boolean;
|
71
|
-
[Type.Number]: number;
|
72
|
-
[Type.BigInt]: bigint;
|
73
|
-
[Type.String]: string;
|
74
|
-
[Type.NumberArray]: number[];
|
75
|
-
[Type.BigIntArray]: bigint[];
|
76
|
-
[Type.StringArray]: string[];
|
77
|
-
[Type.Entity]: Entity;
|
78
|
-
[Type.EntityArray]: Entity[];
|
79
|
-
[Type.OptionalNumber]: number | undefined;
|
80
|
-
[Type.OptionalBigInt]: bigint | undefined;
|
81
|
-
[Type.OptionalBigIntArray]: bigint[] | undefined;
|
82
|
-
[Type.OptionalString]: string | undefined;
|
83
|
-
[Type.OptionalNumberArray]: number[] | undefined;
|
84
|
-
[Type.OptionalStringArray]: string[] | undefined;
|
85
|
-
[Type.OptionalEntity]: Entity | undefined;
|
86
|
-
[Type.OptionalEntityArray]: Entity[] | undefined;
|
87
|
-
[Type.T]: T;
|
88
|
-
[Type.OptionalT]: T | undefined;
|
89
|
-
};
|
90
|
-
/**
|
91
|
-
* Used to infer the TypeScript type of a component value corresponding to a given {@link Schema}.
|
92
|
-
*/
|
93
|
-
type ComponentValue<S extends Schema = Schema, T = unknown> = {
|
94
|
-
[key in keyof S]: ValueType<T>[S[key]];
|
95
|
-
};
|
96
|
-
/**
|
97
|
-
* Type of a component update corresponding to a given {@link Schema}.
|
98
|
-
*/
|
99
|
-
type ComponentUpdate<S extends Schema = Schema, T = unknown> = {
|
100
|
-
entity: Entity;
|
101
|
-
value: [ComponentValue<S, T> | undefined, ComponentValue<S, T> | undefined];
|
102
|
-
component: Component<S, Metadata, T>;
|
103
|
-
};
|
104
|
-
/**
|
105
|
-
* Type of component returned by {@link defineComponent}.
|
106
|
-
*/
|
107
|
-
interface Component<S extends Schema = Schema, M extends Metadata = Metadata, T = unknown> {
|
108
|
-
id: string;
|
109
|
-
values: {
|
110
|
-
[key in keyof S]: Map<EntitySymbol, ValueType<T>[S[key]]>;
|
111
|
-
};
|
112
|
-
schema: S;
|
113
|
-
metadata: M;
|
114
|
-
entities: () => IterableIterator<Entity>;
|
115
|
-
world: World;
|
116
|
-
update$: Subject<ComponentUpdate<S, T>> & {
|
117
|
-
observers: any;
|
118
|
-
};
|
119
|
-
}
|
120
|
-
/**
|
121
|
-
* Type of indexer returned by {@link createIndexer}.
|
122
|
-
*/
|
123
|
-
type Indexer<S extends Schema, M extends Metadata = Metadata, T = unknown> = Component<S, M, T> & {
|
124
|
-
getEntitiesWithValue: (value: ComponentValue<S, T>) => Set<Entity>;
|
125
|
-
};
|
126
|
-
type Components = {
|
127
|
-
[key: string]: Component;
|
128
|
-
};
|
129
|
-
interface ComponentWithStream<S extends Schema, T = unknown> extends Component<S, Metadata, T> {
|
130
|
-
stream$: Subject<{
|
131
|
-
entity: Entity;
|
132
|
-
value: ComponentValue<S, T> | undefined;
|
133
|
-
}>;
|
134
|
-
}
|
135
|
-
type AnyComponentValue = ComponentValue<Schema>;
|
136
|
-
type AnyComponent = Component<Schema>;
|
137
|
-
/**
|
138
|
-
* Type of World returned by {@link createWorld}.
|
139
|
-
*/
|
140
|
-
type World = {
|
141
|
-
registerEntity: (options?: {
|
142
|
-
id?: string;
|
143
|
-
idSuffix?: string;
|
144
|
-
}) => Entity;
|
145
|
-
registerComponent: (component: Component) => void;
|
146
|
-
components: Component[];
|
147
|
-
getEntities: () => IterableIterator<Entity>;
|
148
|
-
dispose: () => void;
|
149
|
-
registerDisposer: (disposer: () => void) => void;
|
150
|
-
hasEntity: (entity: Entity) => boolean;
|
151
|
-
deleteEntity: (entity: Entity) => void;
|
152
|
-
entitySymbols: Set<EntitySymbol>;
|
153
|
-
};
|
154
|
-
declare enum QueryFragmentType {
|
155
|
-
Has = 0,
|
156
|
-
HasValue = 1,
|
157
|
-
Not = 2,
|
158
|
-
NotValue = 3,
|
159
|
-
ProxyRead = 4,
|
160
|
-
ProxyExpand = 5
|
161
|
-
}
|
162
|
-
type HasQueryFragment<T extends Schema> = {
|
163
|
-
type: QueryFragmentType.Has;
|
164
|
-
component: Component<T>;
|
165
|
-
};
|
166
|
-
type HasValueQueryFragment<T extends Schema> = {
|
167
|
-
type: QueryFragmentType.HasValue;
|
168
|
-
component: Component<T>;
|
169
|
-
value: Partial<ComponentValue<T>>;
|
170
|
-
};
|
171
|
-
type NotQueryFragment<T extends Schema> = {
|
172
|
-
type: QueryFragmentType.Not;
|
173
|
-
component: Component<T>;
|
174
|
-
};
|
175
|
-
type NotValueQueryFragment<T extends Schema> = {
|
176
|
-
type: QueryFragmentType.NotValue;
|
177
|
-
component: Component<T>;
|
178
|
-
value: Partial<ComponentValue<T>>;
|
179
|
-
};
|
180
|
-
type ProxyReadQueryFragment = {
|
181
|
-
type: QueryFragmentType.ProxyRead;
|
182
|
-
component: Component<{
|
183
|
-
value: Type.Entity;
|
184
|
-
}>;
|
185
|
-
depth: number;
|
186
|
-
};
|
187
|
-
type ProxyExpandQueryFragment = {
|
188
|
-
type: QueryFragmentType.ProxyExpand;
|
189
|
-
component: Component<{
|
190
|
-
value: Type.Entity;
|
191
|
-
}>;
|
192
|
-
depth: number;
|
193
|
-
};
|
194
|
-
type QueryFragment<T extends Schema = Schema> = HasQueryFragment<T> | HasValueQueryFragment<T> | NotQueryFragment<T> | NotValueQueryFragment<T> | ProxyReadQueryFragment | ProxyExpandQueryFragment;
|
195
|
-
type EntityQueryFragment<T extends Schema = Schema> = HasQueryFragment<T> | HasValueQueryFragment<T> | NotQueryFragment<T> | NotValueQueryFragment<T>;
|
196
|
-
type SettingQueryFragment = ProxyReadQueryFragment | ProxyExpandQueryFragment;
|
197
|
-
type QueryFragments = QueryFragment<Schema>[];
|
198
|
-
type SchemaOf<C extends Component<Schema>> = C extends Component<infer S> ? S : never;
|
199
|
-
type Override<S extends Schema, T = unknown> = {
|
200
|
-
entity: Entity;
|
201
|
-
value: Partial<ComponentValue<S, T>> | null;
|
202
|
-
};
|
203
|
-
/**
|
204
|
-
* Type of overridable component returned by {@link overridableComponent}.
|
205
|
-
*/
|
206
|
-
type OverridableComponent<S extends Schema = Schema, M extends Metadata = Metadata, T = unknown> = Component<S, M, T> & {
|
207
|
-
addOverride: (overrideId: string, update: Override<S, T>) => void;
|
208
|
-
removeOverride: (overrideId: string) => void;
|
209
|
-
};
|
210
|
-
type OptionalType = Type.OptionalNumber | Type.OptionalBigInt | Type.OptionalString | Type.OptionalEntity | Type.OptionalNumberArray | Type.OptionalBigIntArray | Type.OptionalStringArray | Type.OptionalEntityArray;
|
211
|
-
declare function isOptionalType(t: Type): t is OptionalType;
|
212
|
-
type ArrayType = Type.NumberArray | Type.OptionalNumberArray | Type.BigIntArray | Type.OptionalBigIntArray | Type.StringArray | Type.OptionalStringArray | Type.EntityArray | Type.OptionalEntityArray;
|
213
|
-
declare function isArrayType(t: Type): t is ArrayType;
|
214
|
-
type NumberType = Type.Number | Type.OptionalNumber;
|
215
|
-
declare function isNumberType(t: Type): t is NumberType;
|
216
|
-
type EntityType = Type.Entity | Type.OptionalEntity;
|
217
|
-
declare function isEntityType(t: Type): t is EntityType;
|
218
|
-
type Layer = {
|
219
|
-
world: World;
|
220
|
-
components: Record<string, Component<Schema>>;
|
221
|
-
};
|
222
|
-
type Layers = Record<string, Layer>;
|
223
|
-
|
224
|
-
export { type AnyComponentValue as A, type Component as C, type Entity as E, type HasQueryFragment as H, type Indexer as I, type Layer as L, type Metadata as M, type NotQueryFragment as N, type OverridableComponent as O, type ProxyReadQueryFragment as P, type QueryFragment as Q, type Schema as S, Type as T, UpdateType as U, type ValueType as V, type World as W, type ComponentValue as a, type EntitySymbol as b, type ComponentUpdate as c, type HasValueQueryFragment as d, type NotValueQueryFragment as e, type ProxyExpandQueryFragment as f, type Components as g, type ComponentWithStream as h, type AnyComponent as i, QueryFragmentType as j, type EntityQueryFragment as k, type SettingQueryFragment as l, type QueryFragments as m, type SchemaOf as n, type Override as o, type OptionalType as p, isOptionalType as q, type ArrayType as r, isArrayType as s, type NumberType as t, isNumberType as u, type EntityType as v, isEntityType as w, type Layers as x, OptionalTypes as y };
|