@dcl/ecs 1.0.0-20220506152015.commit-2dd9f0a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +18 -0
  2. package/dist/built-in-types/ArrayType.d.ts +3 -0
  3. package/dist/built-in-types/ArrayType.d.ts.map +1 -0
  4. package/dist/built-in-types/ArrayType.js +23 -0
  5. package/dist/built-in-types/ArrayType.js.map +1 -0
  6. package/dist/built-in-types/EcsType.d.ts +6 -0
  7. package/dist/built-in-types/EcsType.d.ts.map +1 -0
  8. package/dist/built-in-types/EcsType.js +3 -0
  9. package/dist/built-in-types/EcsType.js.map +1 -0
  10. package/dist/built-in-types/MapType.d.ts +10 -0
  11. package/dist/built-in-types/MapType.d.ts.map +1 -0
  12. package/dist/built-in-types/MapType.js +24 -0
  13. package/dist/built-in-types/MapType.js.map +1 -0
  14. package/dist/built-in-types/Optional.d.ts +3 -0
  15. package/dist/built-in-types/Optional.d.ts.map +1 -0
  16. package/dist/built-in-types/Optional.js +24 -0
  17. package/dist/built-in-types/Optional.js.map +1 -0
  18. package/dist/built-in-types/basic/Boolean.d.ts +3 -0
  19. package/dist/built-in-types/basic/Boolean.d.ts.map +1 -0
  20. package/dist/built-in-types/basic/Boolean.js +12 -0
  21. package/dist/built-in-types/basic/Boolean.js.map +1 -0
  22. package/dist/built-in-types/basic/Enum.d.ts +3 -0
  23. package/dist/built-in-types/basic/Enum.d.ts.map +1 -0
  24. package/dist/built-in-types/basic/Enum.js +15 -0
  25. package/dist/built-in-types/basic/Enum.js.map +1 -0
  26. package/dist/built-in-types/basic/Float.d.ts +4 -0
  27. package/dist/built-in-types/basic/Float.d.ts.map +1 -0
  28. package/dist/built-in-types/basic/Float.js +20 -0
  29. package/dist/built-in-types/basic/Float.js.map +1 -0
  30. package/dist/built-in-types/basic/Integer.d.ts +6 -0
  31. package/dist/built-in-types/basic/Integer.d.ts.map +1 -0
  32. package/dist/built-in-types/basic/Integer.js +44 -0
  33. package/dist/built-in-types/basic/Integer.js.map +1 -0
  34. package/dist/built-in-types/basic/String.d.ts +4 -0
  35. package/dist/built-in-types/basic/String.d.ts.map +1 -0
  36. package/dist/built-in-types/basic/String.js +13 -0
  37. package/dist/built-in-types/basic/String.js.map +1 -0
  38. package/dist/built-in-types/index.d.ts +10 -0
  39. package/dist/built-in-types/index.d.ts.map +1 -0
  40. package/dist/built-in-types/index.js +26 -0
  41. package/dist/built-in-types/index.js.map +1 -0
  42. package/dist/built-in-types/typing.d.ts +17 -0
  43. package/dist/built-in-types/typing.d.ts.map +1 -0
  44. package/dist/built-in-types/typing.js +3 -0
  45. package/dist/built-in-types/typing.js.map +1 -0
  46. package/dist/components/definitions/BoxShape.proto +13 -0
  47. package/dist/components/definitions/README.md +0 -0
  48. package/dist/components/definitions/Transform.md +0 -0
  49. package/dist/components/generated/BoxShape.d.ts +5 -0
  50. package/dist/components/generated/BoxShape.d.ts.map +1 -0
  51. package/dist/components/generated/BoxShape.js +17 -0
  52. package/dist/components/generated/BoxShape.js.map +1 -0
  53. package/dist/components/generated/index.d.ts +5 -0
  54. package/dist/components/generated/index.d.ts.map +1 -0
  55. package/dist/components/generated/index.js +34 -0
  56. package/dist/components/generated/index.js.map +1 -0
  57. package/dist/components/generated/pb/BoxShape.d.ts +13 -0
  58. package/dist/components/generated/pb/BoxShape.d.ts.map +1 -0
  59. package/dist/components/generated/pb/BoxShape.js +91 -0
  60. package/dist/components/generated/pb/BoxShape.js.map +1 -0
  61. package/dist/components/index.d.ts +11 -0
  62. package/dist/components/index.d.ts.map +1 -0
  63. package/dist/components/index.js +26 -0
  64. package/dist/components/index.js.map +1 -0
  65. package/dist/components/legacy/Transform.d.ts +10 -0
  66. package/dist/components/legacy/Transform.d.ts.map +1 -0
  67. package/dist/components/legacy/Transform.js +29 -0
  68. package/dist/components/legacy/Transform.js.map +1 -0
  69. package/dist/components/legacy/index.d.ts +10 -0
  70. package/dist/components/legacy/index.d.ts.map +1 -0
  71. package/dist/components/legacy/index.js +14 -0
  72. package/dist/components/legacy/index.js.map +1 -0
  73. package/dist/components/legacy/types.d.ts +52 -0
  74. package/dist/components/legacy/types.d.ts.map +1 -0
  75. package/dist/components/legacy/types.js +57 -0
  76. package/dist/components/legacy/types.js.map +1 -0
  77. package/dist/components/types.d.ts +4 -0
  78. package/dist/components/types.d.ts.map +1 -0
  79. package/dist/components/types.js +8 -0
  80. package/dist/components/types.js.map +1 -0
  81. package/dist/ecs.api.json +418 -0
  82. package/dist/engine/component.d.ts +26 -0
  83. package/dist/engine/component.d.ts.map +1 -0
  84. package/dist/engine/component.js +103 -0
  85. package/dist/engine/component.js.map +1 -0
  86. package/dist/engine/entity-utils.d.ts +8 -0
  87. package/dist/engine/entity-utils.d.ts.map +1 -0
  88. package/dist/engine/entity-utils.js +22 -0
  89. package/dist/engine/entity-utils.js.map +1 -0
  90. package/dist/engine/entity.d.ts +18 -0
  91. package/dist/engine/entity.d.ts.map +1 -0
  92. package/dist/engine/entity.js +80 -0
  93. package/dist/engine/entity.js.map +1 -0
  94. package/dist/engine/index.d.ts +46 -0
  95. package/dist/engine/index.d.ts.map +1 -0
  96. package/dist/engine/index.js +139 -0
  97. package/dist/engine/index.js.map +1 -0
  98. package/dist/engine/types.d.ts +10 -0
  99. package/dist/engine/types.d.ts.map +1 -0
  100. package/dist/engine/types.js +3 -0
  101. package/dist/engine/types.js.map +1 -0
  102. package/dist/engine/utils.d.ts +4 -0
  103. package/dist/engine/utils.d.ts.map +1 -0
  104. package/dist/engine/utils.js +17 -0
  105. package/dist/engine/utils.js.map +1 -0
  106. package/dist/index.d.ts +2 -0
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +18 -0
  109. package/dist/index.js.map +1 -0
  110. package/dist/serialization/ByteBuffer/index.d.ts +120 -0
  111. package/dist/serialization/ByteBuffer/index.d.ts.map +1 -0
  112. package/dist/serialization/ByteBuffer/index.js +272 -0
  113. package/dist/serialization/ByteBuffer/index.js.map +1 -0
  114. package/dist/serialization/crdt/componentOperation.d.ts +26 -0
  115. package/dist/serialization/crdt/componentOperation.d.ts.map +1 -0
  116. package/dist/serialization/crdt/componentOperation.js +46 -0
  117. package/dist/serialization/crdt/componentOperation.js.map +1 -0
  118. package/dist/serialization/wireMessage.d.ts +40 -0
  119. package/dist/serialization/wireMessage.d.ts.map +1 -0
  120. package/dist/serialization/wireMessage.js +57 -0
  121. package/dist/serialization/wireMessage.js.map +1 -0
  122. package/dist/systems/crdt/index.d.ts +12 -0
  123. package/dist/systems/crdt/index.d.ts.map +1 -0
  124. package/dist/systems/crdt/index.js +121 -0
  125. package/dist/systems/crdt/index.js.map +1 -0
  126. package/dist/systems/crdt/transport.d.ts +2 -0
  127. package/dist/systems/crdt/transport.d.ts.map +1 -0
  128. package/dist/systems/crdt/transport.js +8 -0
  129. package/dist/systems/crdt/transport.js.map +1 -0
  130. package/dist/systems/crdt/utils.d.ts +14 -0
  131. package/dist/systems/crdt/utils.d.ts.map +1 -0
  132. package/dist/systems/crdt/utils.js +54 -0
  133. package/dist/systems/crdt/utils.js.map +1 -0
  134. package/dist/tsdoc-metadata.json +11 -0
  135. package/package.json +45 -0
@@ -0,0 +1,418 @@
1
+ {
2
+ "metadata": {
3
+ "toolPackage": "@microsoft/api-extractor",
4
+ "toolVersion": "7.23.1",
5
+ "schemaVersion": 1005,
6
+ "oldestForwardsCompatibleVersion": 1001,
7
+ "tsdocConfig": {
8
+ "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
9
+ "noStandardTags": true,
10
+ "tagDefinitions": [
11
+ {
12
+ "tagName": "@alpha",
13
+ "syntaxKind": "modifier"
14
+ },
15
+ {
16
+ "tagName": "@beta",
17
+ "syntaxKind": "modifier"
18
+ },
19
+ {
20
+ "tagName": "@defaultValue",
21
+ "syntaxKind": "block"
22
+ },
23
+ {
24
+ "tagName": "@decorator",
25
+ "syntaxKind": "block",
26
+ "allowMultiple": true
27
+ },
28
+ {
29
+ "tagName": "@deprecated",
30
+ "syntaxKind": "block"
31
+ },
32
+ {
33
+ "tagName": "@eventProperty",
34
+ "syntaxKind": "modifier"
35
+ },
36
+ {
37
+ "tagName": "@example",
38
+ "syntaxKind": "block",
39
+ "allowMultiple": true
40
+ },
41
+ {
42
+ "tagName": "@experimental",
43
+ "syntaxKind": "modifier"
44
+ },
45
+ {
46
+ "tagName": "@inheritDoc",
47
+ "syntaxKind": "inline"
48
+ },
49
+ {
50
+ "tagName": "@internal",
51
+ "syntaxKind": "modifier"
52
+ },
53
+ {
54
+ "tagName": "@label",
55
+ "syntaxKind": "inline"
56
+ },
57
+ {
58
+ "tagName": "@link",
59
+ "syntaxKind": "inline",
60
+ "allowMultiple": true
61
+ },
62
+ {
63
+ "tagName": "@override",
64
+ "syntaxKind": "modifier"
65
+ },
66
+ {
67
+ "tagName": "@packageDocumentation",
68
+ "syntaxKind": "modifier"
69
+ },
70
+ {
71
+ "tagName": "@param",
72
+ "syntaxKind": "block",
73
+ "allowMultiple": true
74
+ },
75
+ {
76
+ "tagName": "@privateRemarks",
77
+ "syntaxKind": "block"
78
+ },
79
+ {
80
+ "tagName": "@public",
81
+ "syntaxKind": "modifier"
82
+ },
83
+ {
84
+ "tagName": "@readonly",
85
+ "syntaxKind": "modifier"
86
+ },
87
+ {
88
+ "tagName": "@remarks",
89
+ "syntaxKind": "block"
90
+ },
91
+ {
92
+ "tagName": "@returns",
93
+ "syntaxKind": "block"
94
+ },
95
+ {
96
+ "tagName": "@sealed",
97
+ "syntaxKind": "modifier"
98
+ },
99
+ {
100
+ "tagName": "@see",
101
+ "syntaxKind": "block"
102
+ },
103
+ {
104
+ "tagName": "@throws",
105
+ "syntaxKind": "block",
106
+ "allowMultiple": true
107
+ },
108
+ {
109
+ "tagName": "@typeParam",
110
+ "syntaxKind": "block",
111
+ "allowMultiple": true
112
+ },
113
+ {
114
+ "tagName": "@virtual",
115
+ "syntaxKind": "modifier"
116
+ },
117
+ {
118
+ "tagName": "@betaDocumentation",
119
+ "syntaxKind": "modifier"
120
+ },
121
+ {
122
+ "tagName": "@internalRemarks",
123
+ "syntaxKind": "block"
124
+ },
125
+ {
126
+ "tagName": "@preapproved",
127
+ "syntaxKind": "modifier"
128
+ }
129
+ ],
130
+ "supportForTags": {
131
+ "@alpha": true,
132
+ "@beta": true,
133
+ "@defaultValue": true,
134
+ "@decorator": true,
135
+ "@deprecated": true,
136
+ "@eventProperty": true,
137
+ "@example": true,
138
+ "@experimental": true,
139
+ "@inheritDoc": true,
140
+ "@internal": true,
141
+ "@label": true,
142
+ "@link": true,
143
+ "@override": true,
144
+ "@packageDocumentation": true,
145
+ "@param": true,
146
+ "@privateRemarks": true,
147
+ "@public": true,
148
+ "@readonly": true,
149
+ "@remarks": true,
150
+ "@returns": true,
151
+ "@sealed": true,
152
+ "@see": true,
153
+ "@throws": true,
154
+ "@typeParam": true,
155
+ "@virtual": true,
156
+ "@betaDocumentation": true,
157
+ "@internalRemarks": true,
158
+ "@preapproved": true
159
+ },
160
+ "reportUnsupportedHtmlElements": false
161
+ }
162
+ },
163
+ "kind": "Package",
164
+ "canonicalReference": "@dcl/ecs!",
165
+ "docComment": "",
166
+ "name": "@dcl/ecs",
167
+ "members": [
168
+ {
169
+ "kind": "EntryPoint",
170
+ "canonicalReference": "@dcl/ecs!",
171
+ "name": "",
172
+ "members": [
173
+ {
174
+ "kind": "Function",
175
+ "canonicalReference": "@dcl/ecs!Engine:function(1)",
176
+ "docComment": "/**\n * @public\n */\n",
177
+ "excerptTokens": [
178
+ {
179
+ "kind": "Content",
180
+ "text": "export declare function Engine(): "
181
+ },
182
+ {
183
+ "kind": "Reference",
184
+ "text": "Engine",
185
+ "canonicalReference": "@dcl/ecs!Engine:type"
186
+ },
187
+ {
188
+ "kind": "Content",
189
+ "text": ";"
190
+ }
191
+ ],
192
+ "returnTypeTokenRange": {
193
+ "startIndex": 1,
194
+ "endIndex": 2
195
+ },
196
+ "releaseTag": "Public",
197
+ "overloadIndex": 1,
198
+ "parameters": [],
199
+ "name": "Engine"
200
+ },
201
+ {
202
+ "kind": "TypeAlias",
203
+ "canonicalReference": "@dcl/ecs!Engine:type",
204
+ "docComment": "/**\n * @public\n */\n",
205
+ "excerptTokens": [
206
+ {
207
+ "kind": "Content",
208
+ "text": "export declare type Engine = "
209
+ },
210
+ {
211
+ "kind": "Content",
212
+ "text": "{\n addEntity(dynamic?: boolean): "
213
+ },
214
+ {
215
+ "kind": "Reference",
216
+ "text": "Entity",
217
+ "canonicalReference": "@dcl/ecs!Entity:type"
218
+ },
219
+ {
220
+ "kind": "Content",
221
+ "text": ";\n addDynamicEntity(): "
222
+ },
223
+ {
224
+ "kind": "Reference",
225
+ "text": "Entity",
226
+ "canonicalReference": "@dcl/ecs!Entity:type"
227
+ },
228
+ {
229
+ "kind": "Content",
230
+ "text": ";\n removeEntity(entity: "
231
+ },
232
+ {
233
+ "kind": "Reference",
234
+ "text": "Entity",
235
+ "canonicalReference": "@dcl/ecs!Entity:type"
236
+ },
237
+ {
238
+ "kind": "Content",
239
+ "text": "): void;\n addSystem(system: "
240
+ },
241
+ {
242
+ "kind": "Reference",
243
+ "text": "Update",
244
+ "canonicalReference": "@dcl/ecs!Update:type"
245
+ },
246
+ {
247
+ "kind": "Content",
248
+ "text": "): void;\n defineComponent<T extends "
249
+ },
250
+ {
251
+ "kind": "Reference",
252
+ "text": "EcsType",
253
+ "canonicalReference": "@dcl/ecs!EcsType:type"
254
+ },
255
+ {
256
+ "kind": "Content",
257
+ "text": ">(componentId: number, spec: T): "
258
+ },
259
+ {
260
+ "kind": "Reference",
261
+ "text": "ComponentDefinition",
262
+ "canonicalReference": "@dcl/ecs!ComponentDefinition:type"
263
+ },
264
+ {
265
+ "kind": "Content",
266
+ "text": "<T>;\n mutableGroupOf<T extends ["
267
+ },
268
+ {
269
+ "kind": "Reference",
270
+ "text": "ComponentDefinition",
271
+ "canonicalReference": "@dcl/ecs!ComponentDefinition:type"
272
+ },
273
+ {
274
+ "kind": "Content",
275
+ "text": ", ..."
276
+ },
277
+ {
278
+ "kind": "Reference",
279
+ "text": "ComponentDefinition",
280
+ "canonicalReference": "@dcl/ecs!ComponentDefinition:type"
281
+ },
282
+ {
283
+ "kind": "Content",
284
+ "text": "[]]>(...components: T): "
285
+ },
286
+ {
287
+ "kind": "Reference",
288
+ "text": "Iterable",
289
+ "canonicalReference": "!Iterable:interface"
290
+ },
291
+ {
292
+ "kind": "Content",
293
+ "text": "<["
294
+ },
295
+ {
296
+ "kind": "Reference",
297
+ "text": "Entity",
298
+ "canonicalReference": "@dcl/ecs!Entity:type"
299
+ },
300
+ {
301
+ "kind": "Content",
302
+ "text": ", ..."
303
+ },
304
+ {
305
+ "kind": "Reference",
306
+ "text": "ComponentEcsType",
307
+ "canonicalReference": "@dcl/ecs!ComponentEcsType:type"
308
+ },
309
+ {
310
+ "kind": "Content",
311
+ "text": "<T>]>;\n groupOf<T extends ["
312
+ },
313
+ {
314
+ "kind": "Reference",
315
+ "text": "ComponentDefinition",
316
+ "canonicalReference": "@dcl/ecs!ComponentDefinition:type"
317
+ },
318
+ {
319
+ "kind": "Content",
320
+ "text": ", ..."
321
+ },
322
+ {
323
+ "kind": "Reference",
324
+ "text": "ComponentDefinition",
325
+ "canonicalReference": "@dcl/ecs!ComponentDefinition:type"
326
+ },
327
+ {
328
+ "kind": "Content",
329
+ "text": "[]]>(...components: T): "
330
+ },
331
+ {
332
+ "kind": "Reference",
333
+ "text": "Iterable",
334
+ "canonicalReference": "!Iterable:interface"
335
+ },
336
+ {
337
+ "kind": "Content",
338
+ "text": "<["
339
+ },
340
+ {
341
+ "kind": "Reference",
342
+ "text": "Entity",
343
+ "canonicalReference": "@dcl/ecs!Entity:type"
344
+ },
345
+ {
346
+ "kind": "Content",
347
+ "text": ", ..."
348
+ },
349
+ {
350
+ "kind": "Reference",
351
+ "text": "DeepReadonly",
352
+ "canonicalReference": "@dcl/ecs!DeepReadonly:type"
353
+ },
354
+ {
355
+ "kind": "Content",
356
+ "text": "<"
357
+ },
358
+ {
359
+ "kind": "Reference",
360
+ "text": "ComponentEcsType",
361
+ "canonicalReference": "@dcl/ecs!ComponentEcsType:type"
362
+ },
363
+ {
364
+ "kind": "Content",
365
+ "text": "<T>>]>;\n getComponent<T extends "
366
+ },
367
+ {
368
+ "kind": "Reference",
369
+ "text": "EcsType",
370
+ "canonicalReference": "@dcl/ecs!EcsType:type"
371
+ },
372
+ {
373
+ "kind": "Content",
374
+ "text": ">(componentId: number): "
375
+ },
376
+ {
377
+ "kind": "Reference",
378
+ "text": "ComponentDefinition",
379
+ "canonicalReference": "@dcl/ecs!ComponentDefinition:type"
380
+ },
381
+ {
382
+ "kind": "Content",
383
+ "text": "<T>;\n update(dt: number): void;\n baseComponents: "
384
+ },
385
+ {
386
+ "kind": "Reference",
387
+ "text": "ReturnType",
388
+ "canonicalReference": "!ReturnType:type"
389
+ },
390
+ {
391
+ "kind": "Content",
392
+ "text": "<typeof "
393
+ },
394
+ {
395
+ "kind": "Reference",
396
+ "text": "defineSdkComponents",
397
+ "canonicalReference": "@dcl/ecs!defineSdkComponents:function"
398
+ },
399
+ {
400
+ "kind": "Content",
401
+ "text": ">;\n}"
402
+ },
403
+ {
404
+ "kind": "Content",
405
+ "text": ";"
406
+ }
407
+ ],
408
+ "releaseTag": "Public",
409
+ "name": "Engine",
410
+ "typeTokenRange": {
411
+ "startIndex": 1,
412
+ "endIndex": 44
413
+ }
414
+ }
415
+ ]
416
+ }
417
+ ]
418
+ }
@@ -0,0 +1,26 @@
1
+ import { EcsType } from '../built-in-types';
2
+ import { ByteBuffer } from '../serialization/ByteBuffer';
3
+ import { Entity } from './entity';
4
+ import { DeepReadonly } from './types';
5
+ export declare type EcsResult<T extends EcsType> = T extends EcsType ? ReturnType<T['deserialize']> : never;
6
+ export declare type ComponentType<T extends EcsType> = EcsResult<T>;
7
+ export declare type ComponentDefinition<T extends EcsType = EcsType<any>> = {
8
+ _id: number;
9
+ has(entity: Entity): boolean;
10
+ getFrom(entity: Entity): DeepReadonly<ComponentType<T>>;
11
+ getOrNull(entity: Entity): DeepReadonly<ComponentType<T>> | null;
12
+ create(entity: Entity, val: ComponentType<T>): ComponentType<T>;
13
+ mutable(entity: Entity): ComponentType<T>;
14
+ createOrReplace(entity: Entity, val: ComponentType<T>): ComponentType<T>;
15
+ deleteFrom(entity: Entity): ComponentType<T> | null;
16
+ upsertFromBinary(entity: Entity, data: ByteBuffer): ComponentType<T> | null;
17
+ updateFromBinary(entity: Entity, data: ByteBuffer): ComponentType<T> | null;
18
+ toBinary(entity: Entity): ByteBuffer;
19
+ writeToByteBuffer(entity: Entity, buffer: ByteBuffer): void;
20
+ iterator(): Iterable<[Entity, ComponentType<T>]>;
21
+ dirtyIterator(): Iterable<Entity>;
22
+ clearDirty(): void;
23
+ isDirty(entity: Entity): boolean;
24
+ };
25
+ export declare function defineComponent<T extends EcsType>(componentId: number, spec: T): ComponentDefinition<T>;
26
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/engine/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAoB,MAAM,6BAA6B,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,oBAAY,SAAS,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,OAAO,GACxD,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,GAC5B,KAAK,CAAA;AAET,oBAAY,aAAa,CAAC,CAAC,SAAS,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAA;AAE3D,oBAAY,mBAAmB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI;IAClE,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,MA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eAAe,CAAC,CAAC,SAAS,OAAO,EAC/C,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,CAAC,GAEN,mBAAmB,CAAC,CAAC,CAAC,CAwHxB"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineComponent = void 0;
4
+ const ByteBuffer_1 = require("../serialization/ByteBuffer");
5
+ const utils_1 = require("./utils");
6
+ function defineComponent(componentId, spec
7
+ // meta: { syncFlags }
8
+ ) {
9
+ const data = new Map();
10
+ const dirtyIterator = new Set();
11
+ return {
12
+ _id: componentId,
13
+ isDirty: function (entity) {
14
+ return dirtyIterator.has(entity);
15
+ },
16
+ has: function (entity) {
17
+ return data.has(entity);
18
+ },
19
+ deleteFrom: function (entity) {
20
+ const component = data.get(entity);
21
+ data.delete(entity);
22
+ dirtyIterator.add(entity);
23
+ return component || null;
24
+ },
25
+ getOrNull: function (entity) {
26
+ const component = data.get(entity);
27
+ return component ? (0, utils_1.deepReadonly)(component) : null;
28
+ },
29
+ getFrom: function (entity) {
30
+ const component = data.get(entity);
31
+ if (!component) {
32
+ throw new Error(`[getFrom] Component ${componentId} for ${entity} not found`);
33
+ }
34
+ return (0, utils_1.deepReadonly)(component);
35
+ },
36
+ create: function (entity, value) {
37
+ const component = data.get(entity);
38
+ if (component) {
39
+ throw new Error(`[create] Component ${componentId} for ${entity} already exists`);
40
+ }
41
+ data.set(entity, value);
42
+ dirtyIterator.add(entity);
43
+ return value;
44
+ },
45
+ createOrReplace: function (entity, value) {
46
+ data.set(entity, value);
47
+ dirtyIterator.add(entity);
48
+ return value;
49
+ },
50
+ mutable: function (entity) {
51
+ const component = data.get(entity);
52
+ if (!component) {
53
+ throw new Error(`[mutable] Component ${componentId} for ${entity} not found`);
54
+ }
55
+ dirtyIterator.add(entity);
56
+ return component;
57
+ },
58
+ iterator: function* () {
59
+ for (const [entity, component] of data) {
60
+ yield [entity, component];
61
+ }
62
+ },
63
+ dirtyIterator: function* () {
64
+ for (const entity of dirtyIterator) {
65
+ yield entity;
66
+ }
67
+ },
68
+ toBinary(entity) {
69
+ const component = data.get(entity);
70
+ if (!component) {
71
+ throw new Error(`Component ${componentId} for ${entity} not found`);
72
+ }
73
+ const writeBuffer = (0, ByteBuffer_1.createByteBuffer)();
74
+ spec.serialize(component, writeBuffer);
75
+ return writeBuffer;
76
+ },
77
+ writeToByteBuffer(entity, buffer) {
78
+ const component = data.get(entity);
79
+ if (!component) {
80
+ throw new Error(`[toBinary] Component ${componentId} for ${entity} not found`);
81
+ }
82
+ spec.serialize(component, buffer);
83
+ },
84
+ updateFromBinary(entity, buffer) {
85
+ const component = data.get(entity);
86
+ if (!component) {
87
+ throw new Error(`[updateFromBinary] Component ${componentId} for ${entity} not found`);
88
+ }
89
+ return this.upsertFromBinary(entity, buffer);
90
+ },
91
+ upsertFromBinary(entity, buffer) {
92
+ const newValue = spec.deserialize(buffer);
93
+ data.set(entity, newValue);
94
+ dirtyIterator.add(entity);
95
+ return newValue;
96
+ },
97
+ clearDirty: function () {
98
+ dirtyIterator.clear();
99
+ }
100
+ };
101
+ }
102
+ exports.defineComponent = defineComponent;
103
+ //# sourceMappingURL=component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/engine/component.ts"],"names":[],"mappings":";;;AACA,4DAA0E;AAE1E,mCAAsC;AAuCtC,SAAgB,eAAe,CAC7B,WAAmB,EACnB,IAAO;AACP,sBAAsB;;IAEtB,MAAM,IAAI,GAAG,IAAI,GAAG,EAA4B,CAAA;IAChD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAA;IAEvC,OAAO;QACL,GAAG,EAAE,WAAW;QAChB,OAAO,EAAE,UAAU,MAAc;YAC/B,OAAO,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAClC,CAAC;QACD,GAAG,EAAE,UAAU,MAAc;YAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,C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C;QACD,gBAAgB,CACd,MAAc,EACd,MAAkB;YAElB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YAClC,IAAI,CAAC,SAAS,EAAE;gBACd,MAAM,IAAI,KAAK,CACb,gCAAgC,WAAW,QAAQ,MAAM,YAAY,CACtE,CAAA;aACF;YACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC9C,CAAC;QACD,gBAAgB,CACd,MAAc,EACd,MAAkB;YAElB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;YACzC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;YAC1B,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACzB,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,UAAU,EAAE;YACV,aAAa,CAAC,KAAK,EAAE,CAAA;QACvB,CAAC;KACF,CAAA;AACH,CAAC;AA5HD,0CA4HC"}
@@ -0,0 +1,8 @@
1
+ import { Entity } from './entity';
2
+ export declare namespace EntityUtils {
3
+ const MAX_ENTITIES = 10000;
4
+ function getOffset(): number;
5
+ function isStaticEntity(entity: Entity): boolean;
6
+ }
7
+ export default EntityUtils;
8
+ //# sourceMappingURL=entity-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-utils.d.ts","sourceRoot":"","sources":["../../src/engine/entity-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,yBAAiB,WAAW,CAAC;IACpB,MAAM,YAAY,QAAQ,CAAA;IAGjC,SAAgB,SAAS,WAIxB;IAGD,SAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,WAG5C;CACF;AAED,eAAe,WAAW,CAAA"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityUtils = void 0;
4
+ var EntityUtils;
5
+ (function (EntityUtils) {
6
+ EntityUtils.MAX_ENTITIES = 10000;
7
+ let offset = EntityUtils.MAX_ENTITIES;
8
+ function getOffset() {
9
+ const off = offset + 1;
10
+ offset += EntityUtils.MAX_ENTITIES;
11
+ return off;
12
+ }
13
+ EntityUtils.getOffset = getOffset;
14
+ const STATIC_ENTITIES = [0, EntityUtils.MAX_ENTITIES];
15
+ function isStaticEntity(entity) {
16
+ const [min, max] = STATIC_ENTITIES;
17
+ return entity >= min && entity <= max;
18
+ }
19
+ EntityUtils.isStaticEntity = isStaticEntity;
20
+ })(EntityUtils = exports.EntityUtils || (exports.EntityUtils = {}));
21
+ exports.default = EntityUtils;
22
+ //# sourceMappingURL=entity-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-utils.js","sourceRoot":"","sources":["../../src/engine/entity-utils.ts"],"names":[],"mappings":";;;AAEA,IAAiB,WAAW,CAe3B;AAfD,WAAiB,WAAW;IACb,wBAAY,GAAG,KAAK,CAAA;IAEjC,IAAI,MAAM,GAAW,YAAA,YAAY,CAAA;IACjC,SAAgB,SAAS;QACvB,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,CAAA;QACtB,MAAM,IAAI,YAAA,YAAY,CAAA;QACtB,OAAO,GAAG,CAAA;IACZ,CAAC;IAJe,qBAAS,YAIxB,CAAA;IAED,MAAM,eAAe,GAAG,CAAC,CAAC,EAAE,YAAA,YAAY,CAAC,CAAA;IACzC,SAAgB,cAAc,CAAC,MAAc;QAC3C,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,eAAe,CAAA;QAClC,OAAO,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,CAAA;IACvC,CAAC;IAHe,0BAAc,iBAG7B,CAAA;AACH,CAAC,EAfgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAe3B;AAED,kBAAe,WAAW,CAAA"}
@@ -0,0 +1,18 @@
1
+ declare const entitySymbol: unique symbol;
2
+ export declare type Entity = number & {
3
+ [entitySymbol]: true;
4
+ };
5
+ export declare function EntityContainer(): {
6
+ generateEntity(dynamic?: boolean): Entity;
7
+ removeEntity(entity: Entity): void;
8
+ getUnusedEntities(): Set<Entity>;
9
+ getUsedEntities(): Set<Entity>;
10
+ };
11
+ declare function Entity(withOffset?: boolean): {
12
+ getUnusedEntities(): Set<Entity>;
13
+ getUsedEntities(): Set<Entity>;
14
+ generateEntity: () => Entity;
15
+ removeEntity: (entity: Entity) => void;
16
+ };
17
+ export {};
18
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/engine/entity.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,YAAY,EAAE,OAAO,MAAM,CAAA;AACzC,oBAAY,MAAM,GAAG,MAAM,GAAG;IAAE,CAAC,YAAY,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AAEtD,wBAAgB,eAAe;6BAIH,OAAO,GAAW,MAAM;yBAI3B,MAAM,GAAG,IAAI;yBAIb,IAAI,MAAM,CAAC;uBAMb,IAAI,MAAM,CAAC;EAOjC;AAED,iBAAS,MAAM,CAAC,UAAU,GAAE,OAAe;;;0BAUd,MAAM;2BA0BH,MAAM;EAgBrC"}