@adobe/data 0.1.2

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 (328) hide show
  1. package/README.md +310 -0
  2. package/assembly/index.d.ts +30 -0
  3. package/assembly/index.js +18 -0
  4. package/assembly/index.wasm +0 -0
  5. package/assembly/index.wasm.map +1 -0
  6. package/assembly-test/assembly.test.d.ts +1 -0
  7. package/assembly-test/assembly.test.js +29 -0
  8. package/assembly-test/assembly.test.js.map +1 -0
  9. package/cache/async-cache.d.ts +15 -0
  10. package/cache/async-cache.js +23 -0
  11. package/cache/async-cache.js.map +1 -0
  12. package/cache/blob-store.d.ts +94 -0
  13. package/cache/blob-store.js +191 -0
  14. package/cache/blob-store.js.map +1 -0
  15. package/cache/blob-store.test.d.ts +1 -0
  16. package/cache/blob-store.test.js +142 -0
  17. package/cache/blob-store.test.js.map +1 -0
  18. package/cache/data-cache.d.ts +38 -0
  19. package/cache/data-cache.js +96 -0
  20. package/cache/data-cache.js.map +1 -0
  21. package/cache/data-cache.test.d.ts +1 -0
  22. package/cache/data-cache.test.js +50 -0
  23. package/cache/data-cache.test.js.map +1 -0
  24. package/cache/expiring-data-cache.d.ts +6 -0
  25. package/cache/expiring-data-cache.js +49 -0
  26. package/cache/expiring-data-cache.js.map +1 -0
  27. package/cache/expiring-data-cache.test.d.ts +1 -0
  28. package/cache/expiring-data-cache.test.js +62 -0
  29. package/cache/expiring-data-cache.test.js.map +1 -0
  30. package/cache/fallback-async-cache.d.ts +7 -0
  31. package/cache/fallback-async-cache.js +22 -0
  32. package/cache/fallback-async-cache.js.map +1 -0
  33. package/cache/functions/bind-functions.d.ts +6 -0
  34. package/cache/functions/bind-functions.js +33 -0
  35. package/cache/functions/bind-functions.js.map +1 -0
  36. package/cache/functions/functions.test.d.ts +1 -0
  37. package/cache/functions/functions.test.js +79 -0
  38. package/cache/functions/functions.test.js.map +1 -0
  39. package/cache/functions/get-cached.d.ts +11 -0
  40. package/cache/functions/get-cached.js +49 -0
  41. package/cache/functions/get-cached.js.map +1 -0
  42. package/cache/functions/get-cached.test.d.ts +1 -0
  43. package/cache/functions/get-cached.test.js +96 -0
  44. package/cache/functions/get-cached.test.js.map +1 -0
  45. package/cache/functions/hashing/blob-to-hash.d.ts +4 -0
  46. package/cache/functions/hashing/blob-to-hash.js +44 -0
  47. package/cache/functions/hashing/blob-to-hash.js.map +1 -0
  48. package/cache/functions/hashing/buffer-to-hash.d.ts +4 -0
  49. package/cache/functions/hashing/buffer-to-hash.js +33 -0
  50. package/cache/functions/hashing/buffer-to-hash.js.map +1 -0
  51. package/cache/functions/hashing/hashing.test.d.ts +1 -0
  52. package/cache/functions/hashing/hashing.test.js +95 -0
  53. package/cache/functions/hashing/hashing.test.js.map +1 -0
  54. package/cache/functions/hashing/index.d.ts +4 -0
  55. package/cache/functions/hashing/index.js +26 -0
  56. package/cache/functions/hashing/index.js.map +1 -0
  57. package/cache/functions/hashing/json-to-hash.d.ts +4 -0
  58. package/cache/functions/hashing/json-to-hash.js +29 -0
  59. package/cache/functions/hashing/json-to-hash.js.map +1 -0
  60. package/cache/functions/hashing/string-to-hash.d.ts +4 -0
  61. package/cache/functions/hashing/string-to-hash.js +37 -0
  62. package/cache/functions/hashing/string-to-hash.js.map +1 -0
  63. package/cache/functions/index.d.ts +5 -0
  64. package/cache/functions/index.js +29 -0
  65. package/cache/functions/index.js.map +1 -0
  66. package/cache/functions/memoize.d.ts +12 -0
  67. package/cache/functions/memoize.js +48 -0
  68. package/cache/functions/memoize.js.map +1 -0
  69. package/cache/functions/omit.d.ts +1 -0
  70. package/cache/functions/omit.js +29 -0
  71. package/cache/functions/omit.js.map +1 -0
  72. package/cache/functions/prevent-parallel-execution.d.ts +7 -0
  73. package/cache/functions/prevent-parallel-execution.js +25 -0
  74. package/cache/functions/prevent-parallel-execution.js.map +1 -0
  75. package/cache/functions/types.d.ts +1 -0
  76. package/cache/functions/types.js +23 -0
  77. package/cache/functions/types.js.map +1 -0
  78. package/cache/get-persistent-cache.d.ts +12 -0
  79. package/cache/get-persistent-cache.js +23 -0
  80. package/cache/get-persistent-cache.js.map +1 -0
  81. package/cache/index.d.ts +3 -0
  82. package/cache/index.js +25 -0
  83. package/cache/index.js.map +1 -0
  84. package/cache/managed-array.d.ts +23 -0
  85. package/cache/managed-array.js +160 -0
  86. package/cache/managed-array.js.map +1 -0
  87. package/cache/managed-async-cache.browser.test.d.ts +1 -0
  88. package/cache/managed-async-cache.browser.test.js +50 -0
  89. package/cache/managed-async-cache.browser.test.js.map +1 -0
  90. package/cache/managed-async-cache.d.ts +4 -0
  91. package/cache/managed-async-cache.js +45 -0
  92. package/cache/managed-async-cache.js.map +1 -0
  93. package/cache/memory-allocator.d.ts +23 -0
  94. package/cache/memory-allocator.js +94 -0
  95. package/cache/memory-allocator.js.map +1 -0
  96. package/cache/memory-async-cache.d.ts +6 -0
  97. package/cache/memory-async-cache.js +23 -0
  98. package/cache/memory-async-cache.js.map +1 -0
  99. package/core/data.d.ts +22 -0
  100. package/core/data.js +52 -0
  101. package/core/data.js.map +1 -0
  102. package/core/data.test.d.ts +1 -0
  103. package/core/data.test.js +48 -0
  104. package/core/data.test.js.map +1 -0
  105. package/core/functions/array-equals.d.ts +1 -0
  106. package/core/functions/array-equals.js +34 -0
  107. package/core/functions/array-equals.js.map +1 -0
  108. package/core/functions/deep-merge.d.ts +31 -0
  109. package/core/functions/deep-merge.js +51 -0
  110. package/core/functions/deep-merge.js.map +1 -0
  111. package/core/functions/deep-merge.test.d.ts +1 -0
  112. package/core/functions/deep-merge.test.js +94 -0
  113. package/core/functions/deep-merge.test.js.map +1 -0
  114. package/core/functions/index.d.ts +4 -0
  115. package/core/functions/index.js +26 -0
  116. package/core/functions/index.js.map +1 -0
  117. package/core/functions/is-async-generator.d.ts +1 -0
  118. package/core/functions/is-async-generator.js +25 -0
  119. package/core/functions/is-async-generator.js.map +1 -0
  120. package/core/functions/is-promise.d.ts +1 -0
  121. package/core/functions/is-promise.js +26 -0
  122. package/core/functions/is-promise.js.map +1 -0
  123. package/core/functions/with-validation.d.ts +5 -0
  124. package/core/functions/with-validation.js +38 -0
  125. package/core/functions/with-validation.js.map +1 -0
  126. package/core/functions/with-validation.test.d.ts +1 -0
  127. package/core/functions/with-validation.test.js +96 -0
  128. package/core/functions/with-validation.test.js.map +1 -0
  129. package/core/index.d.ts +3 -0
  130. package/core/index.js +25 -0
  131. package/core/index.js.map +1 -0
  132. package/core/schema.d.ts +86 -0
  133. package/core/schema.js +33 -0
  134. package/core/schema.js.map +1 -0
  135. package/core/schema.test.d.ts +1 -0
  136. package/core/schema.test.js +16 -0
  137. package/core/schema.test.js.map +1 -0
  138. package/ecs/action-ecs/action-ecs.d.ts +19 -0
  139. package/ecs/action-ecs/action-ecs.js +203 -0
  140. package/ecs/action-ecs/action-ecs.js.map +1 -0
  141. package/ecs/action-ecs/action-ecs.test.d.ts +1 -0
  142. package/ecs/action-ecs/action-ecs.test.js +362 -0
  143. package/ecs/action-ecs/action-ecs.test.js.map +1 -0
  144. package/ecs/action-ecs/action-types.d.ts +106 -0
  145. package/ecs/action-ecs/action-types.js +19 -0
  146. package/ecs/action-ecs/action-types.js.map +1 -0
  147. package/ecs/action-ecs/index.d.ts +2 -0
  148. package/ecs/action-ecs/index.js +23 -0
  149. package/ecs/action-ecs/index.js.map +1 -0
  150. package/ecs/core-ecs/core-ecs-serialization.test.d.ts +1 -0
  151. package/ecs/core-ecs/core-ecs-serialization.test.js +230 -0
  152. package/ecs/core-ecs/core-ecs-serialization.test.js.map +1 -0
  153. package/ecs/core-ecs/core-ecs-types.d.ts +141 -0
  154. package/ecs/core-ecs/core-ecs-types.js +23 -0
  155. package/ecs/core-ecs/core-ecs-types.js.map +1 -0
  156. package/ecs/core-ecs/core-ecs.d.ts +7 -0
  157. package/ecs/core-ecs/core-ecs.js +492 -0
  158. package/ecs/core-ecs/core-ecs.js.map +1 -0
  159. package/ecs/core-ecs/core-ecs.test.d.ts +1 -0
  160. package/ecs/core-ecs/core-ecs.test.js +404 -0
  161. package/ecs/core-ecs/core-ecs.test.js.map +1 -0
  162. package/ecs/core-ecs/index.d.ts +1 -0
  163. package/ecs/core-ecs/index.js +2 -0
  164. package/ecs/core-ecs/index.js.map +1 -0
  165. package/ecs/ecs/ecs-types.d.ts +132 -0
  166. package/ecs/ecs/ecs-types.js +23 -0
  167. package/ecs/ecs/ecs-types.js.map +1 -0
  168. package/ecs/ecs/ecs-where-functions.d.ts +6 -0
  169. package/ecs/ecs/ecs-where-functions.js +91 -0
  170. package/ecs/ecs/ecs-where-functions.js.map +1 -0
  171. package/ecs/ecs/ecs.d.ts +13 -0
  172. package/ecs/ecs/ecs.js +177 -0
  173. package/ecs/ecs/ecs.js.map +1 -0
  174. package/ecs/ecs/ecs.test.d.ts +1 -0
  175. package/ecs/ecs/ecs.test.js +399 -0
  176. package/ecs/ecs/ecs.test.js.map +1 -0
  177. package/ecs/ecs/index.d.ts +3 -0
  178. package/ecs/ecs/index.js +3 -0
  179. package/ecs/ecs/index.js.map +1 -0
  180. package/ecs/index.d.ts +4 -0
  181. package/ecs/index.js +26 -0
  182. package/ecs/index.js.map +1 -0
  183. package/ecs/transaction-ecs/index.d.ts +2 -0
  184. package/ecs/transaction-ecs/index.js +24 -0
  185. package/ecs/transaction-ecs/index.js.map +1 -0
  186. package/ecs/transaction-ecs/transaction-ecs.d.ts +11 -0
  187. package/ecs/transaction-ecs/transaction-ecs.js +184 -0
  188. package/ecs/transaction-ecs/transaction-ecs.js.map +1 -0
  189. package/ecs/transaction-ecs/transaction-ecs.test.d.ts +1 -0
  190. package/ecs/transaction-ecs/transaction-ecs.test.js +599 -0
  191. package/ecs/transaction-ecs/transaction-ecs.test.js.map +1 -0
  192. package/ecs/transaction-ecs/transaction-types.d.ts +135 -0
  193. package/ecs/transaction-ecs/transaction-types.js +2 -0
  194. package/ecs/transaction-ecs/transaction-types.js.map +1 -0
  195. package/ecs/transaction-ecs/transactions.d.ts +5 -0
  196. package/ecs/transaction-ecs/transactions.js +158 -0
  197. package/ecs/transaction-ecs/transactions.js.map +1 -0
  198. package/index.d.ts +1 -0
  199. package/index.js +23 -0
  200. package/index.js.map +1 -0
  201. package/observe/create-observable-event.d.ts +10 -0
  202. package/observe/create-observable-event.js +22 -0
  203. package/observe/create-observable-event.js.map +1 -0
  204. package/observe/create-observable-state.d.ts +7 -0
  205. package/observe/create-observable-state.js +27 -0
  206. package/observe/create-observable-state.js.map +1 -0
  207. package/observe/create-persisted-state.d.ts +11 -0
  208. package/observe/create-persisted-state.js +31 -0
  209. package/observe/create-persisted-state.js.map +1 -0
  210. package/observe/create-persisted-state.test.d.ts +1 -0
  211. package/observe/create-persisted-state.test.js +124 -0
  212. package/observe/create-persisted-state.test.js.map +1 -0
  213. package/observe/from-array.d.ts +5 -0
  214. package/observe/from-array.js +30 -0
  215. package/observe/from-array.js.map +1 -0
  216. package/observe/from-constant.d.ts +5 -0
  217. package/observe/from-constant.js +12 -0
  218. package/observe/from-constant.js.map +1 -0
  219. package/observe/from-element-id.d.ts +7 -0
  220. package/observe/from-element-id.js +70 -0
  221. package/observe/from-element-id.js.map +1 -0
  222. package/observe/from-element-properties-and-events.d.ts +2 -0
  223. package/observe/from-element-properties-and-events.js +18 -0
  224. package/observe/from-element-properties-and-events.js.map +1 -0
  225. package/observe/from-element-property.d.ts +11 -0
  226. package/observe/from-element-property.js +60 -0
  227. package/observe/from-element-property.js.map +1 -0
  228. package/observe/from-promise-with-error.d.ts +7 -0
  229. package/observe/from-promise-with-error.js +27 -0
  230. package/observe/from-promise-with-error.js.map +1 -0
  231. package/observe/from-promise.d.ts +6 -0
  232. package/observe/from-promise.js +22 -0
  233. package/observe/from-promise.js.map +1 -0
  234. package/observe/from-properties.d.ts +10 -0
  235. package/observe/from-properties.js +33 -0
  236. package/observe/from-properties.js.map +1 -0
  237. package/observe/index.d.ts +27 -0
  238. package/observe/index.js +49 -0
  239. package/observe/index.js.map +1 -0
  240. package/observe/observe.test.d.ts +7 -0
  241. package/observe/observe.test.js +417 -0
  242. package/observe/observe.test.js.map +1 -0
  243. package/observe/to-promise.d.ts +8 -0
  244. package/observe/to-promise.js +18 -0
  245. package/observe/to-promise.js.map +1 -0
  246. package/observe/to-properties.d.ts +11 -0
  247. package/observe/to-properties.js +9 -0
  248. package/observe/to-properties.js.map +1 -0
  249. package/observe/types.d.ts +17 -0
  250. package/observe/types.js +2 -0
  251. package/observe/types.js.map +1 -0
  252. package/observe/with-async-map.d.ts +6 -0
  253. package/observe/with-async-map.js +12 -0
  254. package/observe/with-async-map.js.map +1 -0
  255. package/observe/with-cache.d.ts +6 -0
  256. package/observe/with-cache.js +33 -0
  257. package/observe/with-cache.js.map +1 -0
  258. package/observe/with-copy.d.ts +5 -0
  259. package/observe/with-copy.js +10 -0
  260. package/observe/with-copy.js.map +1 -0
  261. package/observe/with-deduplicate-data.d.ts +7 -0
  262. package/observe/with-deduplicate-data.js +18 -0
  263. package/observe/with-deduplicate-data.js.map +1 -0
  264. package/observe/with-deduplicate.d.ts +6 -0
  265. package/observe/with-deduplicate.js +19 -0
  266. package/observe/with-deduplicate.js.map +1 -0
  267. package/observe/with-default.d.ts +6 -0
  268. package/observe/with-default.js +21 -0
  269. package/observe/with-default.js.map +1 -0
  270. package/observe/with-map-data.d.ts +7 -0
  271. package/observe/with-map-data.js +32 -0
  272. package/observe/with-map-data.js.map +1 -0
  273. package/observe/with-map.d.ts +5 -0
  274. package/observe/with-map.js +11 -0
  275. package/observe/with-map.js.map +1 -0
  276. package/observe/with-optional.d.ts +5 -0
  277. package/observe/with-optional.js +20 -0
  278. package/observe/with-optional.js.map +1 -0
  279. package/observe/with-unwrap.d.ts +5 -0
  280. package/observe/with-unwrap.js +26 -0
  281. package/observe/with-unwrap.js.map +1 -0
  282. package/package.json +105 -0
  283. package/perftest/ecs-perf.d.ts +49 -0
  284. package/perftest/ecs-perf.js +230 -0
  285. package/perftest/ecs-perf.js.map +1 -0
  286. package/perftest/helper-functions.d.ts +1 -0
  287. package/perftest/helper-functions.js +31 -0
  288. package/perftest/helper-functions.js.map +1 -0
  289. package/perftest/horizon-perf.d.ts +22 -0
  290. package/perftest/horizon-perf.js +126 -0
  291. package/perftest/horizon-perf.js.map +1 -0
  292. package/perftest/index.d.ts +1 -0
  293. package/perftest/index.js +35 -0
  294. package/perftest/index.js.map +1 -0
  295. package/perftest/perf-test.d.ts +18 -0
  296. package/perftest/perf-test.js +124 -0
  297. package/perftest/perf-test.js.map +1 -0
  298. package/perftest/vanilla-perf.d.ts +38 -0
  299. package/perftest/vanilla-perf.js +128 -0
  300. package/perftest/vanilla-perf.js.map +1 -0
  301. package/schemas/index.d.ts +1 -0
  302. package/schemas/index.js +23 -0
  303. package/schemas/index.js.map +1 -0
  304. package/schemas/schemas.d.ts +45 -0
  305. package/schemas/schemas.js +39 -0
  306. package/schemas/schemas.js.map +1 -0
  307. package/service/add-observable-actions.d.ts +29 -0
  308. package/service/add-observable-actions.js +108 -0
  309. package/service/add-observable-actions.js.map +1 -0
  310. package/service/index.d.ts +4 -0
  311. package/service/index.js +26 -0
  312. package/service/index.js.map +1 -0
  313. package/service/progressive-result.d.ts +96 -0
  314. package/service/progressive-result.js +99 -0
  315. package/service/progressive-result.js.map +1 -0
  316. package/service/sequential-action.d.ts +18 -0
  317. package/service/sequential-action.js +45 -0
  318. package/service/sequential-action.js.map +1 -0
  319. package/service/service.d.ts +4 -0
  320. package/service/service.js +26 -0
  321. package/service/service.js.map +1 -0
  322. package/tsconfig.tsbuildinfo +1 -0
  323. package/types/index.d.ts +1 -0
  324. package/types/index.js +23 -0
  325. package/types/index.js.map +1 -0
  326. package/types/types.d.ts +61 -0
  327. package/types/types.js +27 -0
  328. package/types/types.js.map +1 -0
@@ -0,0 +1,106 @@
1
+ import { FromSchema, Schema } from "../../core/index.js";
2
+ import { Observe } from "../../observe/types.js";
3
+ import { Expand, Simplify } from "../../types/types.js";
4
+ import { Archetype, ECSArchetypes, ECSComponents, ECSResources } from "../ecs/ecs-types.js";
5
+ import { Entity } from "../index.js";
6
+ import { Transaction, TransactionECS, TransactionObservables } from "../transaction-ecs/transaction-types.js";
7
+ export type ECSActionFunctions = Record<string, ActionFunction>;
8
+ export type AsyncArgsProvider<T> = () => Promise<T> | AsyncGenerator<T>;
9
+ /**
10
+ * Represents an ECS with actions that can be applied to it.
11
+ * Actions are functions that can be applied to the ECS to change its state.
12
+ * They are defined in advance using the withActions method.
13
+ * These actions are implemented using transactions which are applied to the
14
+ * underlying TransactionECS.
15
+ */
16
+ export interface ActionECS<C extends ECSComponents = ECSComponents, // name => Component Value Type
17
+ A extends ECSArchetypes = {}, // name => Entity Values Type
18
+ R extends ECSResources = {}, // name => Resource Value Type
19
+ F extends ECSActionFunctions = {}> extends Omit<TransactionECS<C, A, R>, "createTransaction" | "withComponents" | "withArchetypes" | "withResources"> {
20
+ apply(action: Action<F>): void;
21
+ readonly actions: {
22
+ [K in keyof F]: ToActionFunction<F[K]>;
23
+ };
24
+ readonly actionSequences: {
25
+ [K in keyof F]: (...args: Parameters<ToActionFunction<F[K]>>) => ActionSequence<Parameters<ToActionFunction<F[K]>>>;
26
+ };
27
+ withComponents<S extends {
28
+ [K: string]: Schema;
29
+ }, T = {
30
+ -readonly [K in keyof S]: FromSchema<S[K]>;
31
+ }>(components: S): ActionECS<Simplify<C & T>, A, R, F>;
32
+ withArchetypes<S extends {
33
+ [K: string]: ReadonlyArray<keyof C>;
34
+ }>(archetypes: S): ActionECS<C, Simplify<A & {
35
+ -readonly [AN in keyof S]: Archetype<Expand<{
36
+ id: Entity;
37
+ } & {
38
+ [PN in S[AN][number]]: C[PN];
39
+ }>>;
40
+ }>, R, F>;
41
+ withResources<S extends {
42
+ [K: string]: unknown;
43
+ }>(resources: S): ActionECS<C, A, Simplify<R & S>, F>;
44
+ withActions<S extends {
45
+ [K: string]: TransactionFunction<C, A, R, F>;
46
+ }>(transactionFunctions: S): ActionECS<C, A, R, Simplify<F & S>>;
47
+ observe: ActionECSObservables<C, A, R, F>;
48
+ /**
49
+ * The number of transient actions that are currently in progress.
50
+ * This is used for debugging.
51
+ */
52
+ getTransientActionCount: () => number;
53
+ }
54
+ export type ActionECSObservables<C extends ECSComponents = ECSComponents, // name => Component Value Type
55
+ A extends ECSArchetypes = ECSArchetypes, // name => Entity Values Type
56
+ R extends ECSResources = ECSResources, // name => Resource Value Type
57
+ F extends ECSActionFunctions = ECSActionFunctions> = TransactionObservables<C, A, R> & {
58
+ actions: Observe<Action<F>>;
59
+ };
60
+ /**
61
+ * Represents an action which can be applied to an ActionECS.
62
+ */
63
+ export type Action<F extends ECSActionFunctions = any> = {
64
+ type: "transient" | "commit" | "cancel";
65
+ /**
66
+ * The unique time in UTC milliseconds when the action was created.
67
+ */
68
+ createdTime: number;
69
+ /**
70
+ * The unique identifier for the user creating the action.
71
+ */
72
+ createdBy: string;
73
+ /**
74
+ * The name of the action.
75
+ */
76
+ name: keyof F;
77
+ /**
78
+ * The semantic arguments for the action.
79
+ */
80
+ args: Parameters<ToActionFunction<F[keyof F]>>;
81
+ };
82
+ /**
83
+ * Gets the action type for the given ECS.
84
+ */
85
+ export type ActionFor<ECS extends ActionECS<any, any, any, any>> = ECS extends ActionECS<infer C, infer A, infer R, infer F> ? Action<F> : never;
86
+ /**
87
+ * Compares two actions to determine their correct application order.
88
+ * Transient actions are always applied after non-transient actions.
89
+ * Actions are then sorted by time ascending.
90
+ * Actions are then sorted by user ascending.
91
+ * @returns 0 if the actions are equal, -1 if a should be applied before b, 1 if b should be applied before a.
92
+ */
93
+ export declare function compareActionOrder(a: Action, b: Action): number;
94
+ export declare function isSameAction(a: Action, b: Action): boolean;
95
+ export type TransactionFunction<C extends ECSComponents = any, // name => Component Value Type
96
+ A extends ECSArchetypes = any, // name => Entity Values Type
97
+ R extends ECSResources = any, // name => Resource Value Type
98
+ F extends ECSActionFunctions = any> = (this: F, t: Transaction<C, A, R>, ...args: any[]) => void;
99
+ export type ToActionFunction<F> = F extends (t: Transaction<any, any, any>, ...args: infer Args) => void ? ActionFunction<(Args | [AsyncArgsProvider<Args>])> : never;
100
+ type ActionFunction<Args extends any[] = any[]> = (...args: Args) => void;
101
+ export type ActionSequence<Args extends any[] = any[]> = {
102
+ update: (...args: Args) => ActionSequence<Args>;
103
+ commit: () => void;
104
+ cancel: () => void;
105
+ };
106
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Compares two actions to determine their correct application order.
3
+ * Transient actions are always applied after non-transient actions.
4
+ * Actions are then sorted by time ascending.
5
+ * Actions are then sorted by user ascending.
6
+ * @returns 0 if the actions are equal, -1 if a should be applied before b, 1 if b should be applied before a.
7
+ */
8
+ export function compareActionOrder(a, b) {
9
+ if (a.createdTime !== b.createdTime) {
10
+ return a.createdTime - b.createdTime;
11
+ }
12
+ return a.createdBy.localeCompare(b.createdBy, undefined, {
13
+ sensitivity: "variant",
14
+ });
15
+ }
16
+ export function isSameAction(a, b) {
17
+ return a.createdTime === b.createdTime && a.createdBy === b.createdBy;
18
+ }
19
+ //# sourceMappingURL=action-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-types.js","sourceRoot":"","sources":["../../../src/ecs/action-ecs/action-types.ts"],"names":[],"mappings":"AAwIA;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAS,EAAE,CAAS;IACrD,IAAI,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QACpC,OAAO,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC;IACvC,CAAC;IACD,OAAO,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE;QACvD,WAAW,EAAE,SAAS;KACvB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,CAAS,EAAE,CAAS;IAC/C,OAAO,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,CAAC;AACxE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./action-ecs.js";
2
+ export { type ActionECS, type Action, type ActionSequence, type ActionFor, } from "./action-types.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 "./action-ecs.js";
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ecs/action-ecs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AACX,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,230 @@
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 { describe, expect, test } from "vitest";
23
+ import { createCoreECS } from "./core-ecs.js";
24
+ const createEcsWithMassAndSize = (data, precision = 2) => {
25
+ return createCoreECS({ data })
26
+ .withComponents({
27
+ mass: { type: "number", minimum: 0, precision },
28
+ size: { enum: ["small", "medium", "large"] },
29
+ })
30
+ .withResources({
31
+ gravity: 9.8,
32
+ });
33
+ };
34
+ const createEcsWithMassAndSizeAndShape = (data) => {
35
+ return createCoreECS({ data })
36
+ .withComponents({
37
+ mass: { type: "number", minimum: 0, precision: 2 },
38
+ shape: { enum: ["circle", "square", "triangle"] },
39
+ size: { enum: ["small", "medium", "large"] },
40
+ })
41
+ .withResources({
42
+ gravity: 9.8,
43
+ });
44
+ };
45
+ describe("ecs-functions", () => {
46
+ test("toJSON with base64 encoded binary data, mass is float64array", () => {
47
+ const ecs = createEcsWithMassAndSize();
48
+ const physical = ecs.getArchetype("id", "mass", "size");
49
+ for (let i = 1; i < 10; i++) {
50
+ ecs.createEntity(physical, {
51
+ mass: 3123123123121.232 / i,
52
+ size: "medium",
53
+ });
54
+ }
55
+ const data = ecs.toJSON();
56
+ expect(data).toEqual({
57
+ ecs: true,
58
+ version: 4,
59
+ components: {
60
+ id: { type: "integer", minimum: +0, maximum: 4294967295 },
61
+ mass: { type: "number", minimum: +0, precision: 2 },
62
+ size: { enum: ["small", "medium", "large"] },
63
+ gravity: {},
64
+ },
65
+ entities: [1, +0, 2, +0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8],
66
+ tables: [
67
+ { rows: +0, columns: { id: [] } },
68
+ { rows: 1, columns: { gravity: [9.8], id: [+0] } },
69
+ {
70
+ rows: 9,
71
+ columns: {
72
+ // id is not base 64 encoded because the json is shorter.
73
+ id: [1, 2, 3, 4, 5, 6, 7, 8, 9],
74
+ // mass is base 64 encoded because the encoded form is shorter.
75
+ // This one is longer than the
76
+ mass: "24mdJ0W5hkLbiZ0nRbl2QiQN0jRcTG5C24mdJ0W5ZkLiB37s0C1iQiQN0jRcTF5CQwu0CE/4WULbiZ0nRblWQm2zNiPoMlRC",
77
+ // size could be compressed efficiently by any general compression algorithm.
78
+ // we don't expect large data sets to use strings for components so we don't compress it.
79
+ size: [
80
+ "medium",
81
+ "medium",
82
+ "medium",
83
+ "medium",
84
+ "medium",
85
+ "medium",
86
+ "medium",
87
+ "medium",
88
+ "medium",
89
+ ],
90
+ },
91
+ },
92
+ ],
93
+ });
94
+ });
95
+ test("toJSON with base64 encoded binary data, mass is float32array", () => {
96
+ const precision = 1;
97
+ const ecs = createEcsWithMassAndSize(undefined, precision);
98
+ const physical = ecs.getArchetype("id", "mass", "size");
99
+ for (let i = 1; i < 10; i++) {
100
+ ecs.createEntity(physical, {
101
+ mass: 3123123123121.232 / i,
102
+ size: "medium",
103
+ });
104
+ }
105
+ const data = ecs.toJSON();
106
+ expect(data).toEqual({
107
+ ecs: true,
108
+ version: 4,
109
+ components: {
110
+ id: { type: "integer", minimum: +0, maximum: 4294967295 },
111
+ mass: { type: "number", minimum: +0, precision: 1 },
112
+ size: { enum: ["small", "medium", "large"] },
113
+ gravity: {},
114
+ },
115
+ entities: [1, +0, 2, +0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8],
116
+ tables: [
117
+ { rows: +0, columns: { id: [] } },
118
+ { rows: 1, columns: { gravity: [9.8], id: [+0] } },
119
+ {
120
+ rows: 9,
121
+ columns: {
122
+ // id is not base 64 encoded because the json is shorter.
123
+ id: [1, 2, 3, 4, 5, 6, 7, 8, 9],
124
+ // mass is base 64 encoded because the encoded form is shorter.
125
+ mass: "Kco1VCnKtVPiYnJTKco1U4duEVPiYvJSeMLPUinKtVJBl6FS",
126
+ // size could be compressed efficiently by any general compression algorithm.
127
+ // we don't expect large data sets to use strings for components so we don't compress it.
128
+ size: [
129
+ "medium",
130
+ "medium",
131
+ "medium",
132
+ "medium",
133
+ "medium",
134
+ "medium",
135
+ "medium",
136
+ "medium",
137
+ "medium",
138
+ ],
139
+ },
140
+ },
141
+ ],
142
+ });
143
+ });
144
+ test("toJSON and fromJSON round trip", () => {
145
+ const ecs = createEcsWithMassAndSize();
146
+ const physical = ecs.getArchetype("id", "mass", "size");
147
+ for (let i = 1; i < 10; i++) {
148
+ ecs.createEntity(physical, {
149
+ mass: 3123123123121.232 / i,
150
+ size: "medium",
151
+ });
152
+ }
153
+ const data = ecs.toJSON();
154
+ const ecs2 = createEcsWithMassAndSize(data);
155
+ const data2 = ecs2.toJSON();
156
+ expect(data2).toEqual(data);
157
+ });
158
+ test("toJSON and fromJSON round trip with new components", () => {
159
+ const ecs = createEcsWithMassAndSize();
160
+ const physical = ecs.getArchetype("id", "mass", "size");
161
+ for (let i = 1; i < 10; i++) {
162
+ ecs.createEntity(physical, {
163
+ mass: 3123123123121.232 / i,
164
+ size: "medium",
165
+ });
166
+ }
167
+ const data = ecs.toJSON();
168
+ const ecs2 = createEcsWithMassAndSizeAndShape(data);
169
+ const physicalAndShaped = ecs2.getArchetype("id", "mass", "size", "shape");
170
+ ecs2.createEntity(physicalAndShaped, {
171
+ mass: 98,
172
+ size: "medium",
173
+ shape: "circle",
174
+ });
175
+ const data2 = ecs2.toJSON();
176
+ const ecs3 = createEcsWithMassAndSizeAndShape(data2);
177
+ const data3 = ecs3.toJSON();
178
+ expect(data3).toEqual(data2);
179
+ });
180
+ test("verify entity data consistency when changing archetypes", () => {
181
+ const ecs = createEcsWithMassAndSizeAndShape();
182
+ const initialArchetype = ecs.getArchetype("id", "mass");
183
+ const targetArchetype = ecs.getArchetype("id", "mass", "shape");
184
+ // Create 100 entities with just mass
185
+ const entities = [];
186
+ for (let i = 0; i < 100; i++) {
187
+ const entity = ecs.createEntity(initialArchetype, {
188
+ mass: i + 1.5
189
+ });
190
+ entities.push(entity);
191
+ }
192
+ // Update each entity one by one, adding the shape component
193
+ for (let i = 0; i < entities.length; i++) {
194
+ const entity = entities[i];
195
+ const expectedMass = i + 1.5;
196
+ // Update entity to add shape component
197
+ ecs.updateEntity(entity, {
198
+ mass: expectedMass,
199
+ shape: "circle"
200
+ });
201
+ // Verify the entity data immediately after update
202
+ const entityData = ecs.getEntityValues(entity);
203
+ if (!entityData) {
204
+ throw new Error(`Entity ${entity} not found after update`);
205
+ }
206
+ if (entityData.mass !== expectedMass) {
207
+ throw new Error(`Entity ${entity} has incorrect mass. Expected ${expectedMass}, got ${entityData.mass}`);
208
+ }
209
+ if (entityData.shape !== "circle") {
210
+ throw new Error(`Entity ${entity} has incorrect shape. Expected "circle", got ${entityData.shape}`);
211
+ }
212
+ // Also verify all previously updated entities still have correct data
213
+ for (let j = 0; j <= i; j++) {
214
+ const prevEntity = entities[j];
215
+ const prevData = ecs.getEntityValues(prevEntity);
216
+ if (!prevData) {
217
+ throw new Error(`Previously updated entity ${prevEntity} not found`);
218
+ }
219
+ const prevExpectedMass = j + 1.5;
220
+ if (prevData.mass !== prevExpectedMass) {
221
+ throw new Error(`Previously updated entity ${prevEntity} has incorrect mass. Expected ${prevExpectedMass}, got ${prevData.mass}`);
222
+ }
223
+ if (prevData.shape !== "circle") {
224
+ throw new Error(`Previously updated entity ${prevEntity} has incorrect shape. Expected "circle", got ${prevData.shape}`);
225
+ }
226
+ }
227
+ }
228
+ });
229
+ });
230
+ //# sourceMappingURL=core-ecs-serialization.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-ecs-serialization.test.js","sourceRoot":"","sources":["../../../src/ecs/core-ecs/core-ecs-serialization.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,wBAAwB,GAAG,CAAC,IAAc,EAAE,YAAmB,CAAC,EAAE,EAAE;IACxE,OAAO,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC;SAC3B,cAAc,CAAC;QACd,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE;QAC/C,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE;KACpC,CAAC;SACV,aAAa,CAAC;QACb,OAAO,EAAE,GAAG;KACb,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,gCAAgC,GAAG,CAAC,IAAc,EAAE,EAAE;IAC1D,OAAO,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC;SAC3B,cAAc,CAAC;QACd,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;QAClD,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE;QACjD,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE;KACpC,CAAC;S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AQ,EAAE,CAAC;oBACd,MAAM,IAAI,KAAK,CAAC,6BAA6B,UAAU,YAAY,CAAC,CAAC;gBACvE,CAAC;gBACD,MAAM,gBAAgB,GAAG,CAAC,GAAG,GAAG,CAAC;gBAEjC,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;oBACvC,MAAM,IAAI,KAAK,CAAC,6BAA6B,UAAU,iCAAiC,gBAAgB,SAAS,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;gBACpI,CAAC;gBACD,IAAI,QAAQ,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;oBAChC,MAAM,IAAI,KAAK,CAAC,6BAA6B,UAAU,gDAAgD,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;gBAC3H,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,141 @@
1
+ import { Data, FromSchema, Schema } from "../../core/index.js";
2
+ import { DeepReadonly, Simplify } from "../../types/types.js";
3
+ import { NativeArray } from "../../cache/managed-array.js";
4
+ /**
5
+ * An Entity represents a single object within the ECS.
6
+ * It is a unique positive integer identifier that can be used to access the components of the entity.
7
+ */
8
+ export type Entity = number;
9
+ /**
10
+ * Represents all of an entities values for the given ECS components.
11
+ * This will always contain an id property which is the entity id.
12
+ * All other components are optional.
13
+ */
14
+ export type EntityValues<C> = {
15
+ id: number;
16
+ } & {
17
+ [K in keyof C]?: C[K] | undefined;
18
+ };
19
+ /**
20
+ * Represents the values you can use when creating an entity.
21
+ * You cannot provide an id as this is always generated by the ECS.
22
+ */
23
+ export type EntityCreateValues<A> = Omit<A, "id">;
24
+ /**
25
+ * Represents the values you can use when updating an entity.
26
+ * Providing a value of undefined for a component will delete it.
27
+ */
28
+ export type EntityUpdateValues<C> = Omit<{
29
+ [K in keyof C]?: C[K] | undefined;
30
+ }, "id">;
31
+ /**
32
+ * The JSON data type that is used to serialize and deserialize ECS data.
33
+ */
34
+ export type ECSJSON = {
35
+ ecs: true;
36
+ version: number;
37
+ components: Record<string, Schema>;
38
+ entities: readonly number[];
39
+ tables: {
40
+ rows: number;
41
+ columns: Record<string, Data>;
42
+ }[];
43
+ };
44
+ export type CoreComponents = {
45
+ id: number;
46
+ };
47
+ export type CoreResources = {
48
+ [K: string]: Data;
49
+ };
50
+ export interface CoreECS<C extends CoreComponents = CoreComponents, R extends CoreResources = {}> extends CoreECSRead<C, R>, CoreECSWrite<C, R> {
51
+ /**
52
+ * Creates new components within this ecs and returns the same ecs with the new expanded type information.
53
+ */
54
+ withComponents<S extends {
55
+ readonly [K: string]: DeepReadonly<Schema>;
56
+ }, T = {
57
+ -readonly [K in keyof S]: FromSchema<S[K]>;
58
+ }>(components: S): CoreECS<Simplify<C & T>, R>;
59
+ withResources<T extends {
60
+ readonly [K: string]: Data;
61
+ }>(resources: T): CoreECS<C, Simplify<R & T>>;
62
+ }
63
+ export interface CoreECSRead<C extends CoreComponents = CoreComponents, R extends CoreResources = {}> {
64
+ components: {
65
+ readonly [K in keyof C]: Schema;
66
+ };
67
+ resources: R;
68
+ /**
69
+ * Returns the component value for the given entity.
70
+ * @param component the component to read.
71
+ * @param id if not provided, uses the component own entity id as with resources.
72
+ */
73
+ getComponentValue<Name extends keyof C>(id: Entity, component: Name): C[Name] | undefined;
74
+ getArchetype<Components extends (keyof C)[]>(...components: Components): CoreArchetype<{
75
+ [K in Components[number]]: C[K];
76
+ }>;
77
+ getEntityValues(id: Entity): EntityValues<C> | undefined;
78
+ getEntityArchetype(id: Entity): CoreArchetype;
79
+ countEntities<T extends CoreComponents>(archetype: CoreArchetype<T>): number;
80
+ selectEntities<T extends CoreComponents>(archetype: CoreArchetype<T>): Entity[];
81
+ toJSON(): ECSJSON;
82
+ }
83
+ export interface CoreECSWrite<C extends CoreComponents = CoreComponents, R extends CoreResources = {}> {
84
+ createEntity(): Entity;
85
+ createEntity<T extends CoreComponents>(archetype: CoreArchetype<T>, values: Omit<T, "id">): Entity;
86
+ createBatch<T extends CoreComponents>(archetype: CoreArchetype<T>, count: number): Table<T>;
87
+ /**
88
+ * Sets the value of a component for the given entity.
89
+ * @param component the component to write.
90
+ * @param value the value of the component or undefined to delete the component.
91
+ * @param id if not provided, uses the components own entity id as with resources.
92
+ */
93
+ setComponentValue<Name extends keyof C>(id: Entity, component: Name, value: C[Name] | undefined): void;
94
+ /**
95
+ * Gets the tables for the given archetype in read or write mode.
96
+ * @param exact if true, only returns the single table that exactly matches the archetype.
97
+ */
98
+ getTables<T extends CoreComponents>(archetype: CoreArchetype<T>, options: {
99
+ mode: "read" | "write";
100
+ exact?: boolean;
101
+ }): Table<C>[];
102
+ updateEntity(id: Entity, values: EntityUpdateValues<C>): void;
103
+ deleteEntity(id: Entity): void;
104
+ }
105
+ export interface CoreArchetype<C = {
106
+ [K: string]: unknown;
107
+ }> {
108
+ readonly components: (keyof C)[];
109
+ }
110
+ /**
111
+ * A Table represents a collection of entities with the same exact archetype.
112
+ */
113
+ export interface Table<C = {
114
+ [K: string]: unknown;
115
+ }> {
116
+ readonly rows: number;
117
+ readonly columns: {
118
+ [K in keyof C]: Column<C[K]>;
119
+ };
120
+ }
121
+ /**
122
+ * A column represents an array of values for a single component.
123
+ * Each row in the column corresponds to a single entity within the containing Table.
124
+ * The ECS stores data as a structure of arrays.
125
+ */
126
+ export interface Column<T> {
127
+ get(row: number): T;
128
+ set(row: number, value: T): void;
129
+ /**
130
+ * Allows unsafe direct access to the underlying native array if present.
131
+ * Not present for constant columns.
132
+ * For numeric tuples, the array will be of the form [a0, a1, a2, b0, b1, b2, ...]
133
+ */
134
+ native?: NativeArray<T extends number[] ? number : T>;
135
+ /**
136
+ * Is every value in this column the same?
137
+ */
138
+ constant: boolean;
139
+ toJSON(length: number): Data;
140
+ fromJSON(data: Data, length: number): void;
141
+ }
@@ -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 {};
23
+ //# sourceMappingURL=core-ecs-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-ecs-types.js","sourceRoot":"","sources":["../../../src/ecs/core-ecs/core-ecs-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW"}
@@ -0,0 +1,7 @@
1
+ import { MemoryAllocator } from "../../cache/memory-allocator.js";
2
+ import { CoreECS, CoreComponents, ECSJSON, CoreResources } from "./core-ecs-types.js";
3
+ export declare const DELETE: unknown;
4
+ export declare function createCoreECS<C extends CoreComponents, R extends CoreResources>(options?: {
5
+ data?: ECSJSON;
6
+ allocator?: MemoryAllocator;
7
+ }): CoreECS<CoreComponents, {}>;