@typeonce/ritmo 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +2 -0
  2. package/dist/Brand.d.ts +9 -4
  3. package/dist/Brand.d.ts.map +1 -1
  4. package/dist/Brand.js +9 -4
  5. package/dist/Brand.js.map +1 -1
  6. package/dist/Clock.d.ts +186 -0
  7. package/dist/Clock.d.ts.map +1 -0
  8. package/dist/Clock.js +111 -0
  9. package/dist/Clock.js.map +1 -0
  10. package/dist/Command.d.ts +157 -33
  11. package/dist/Command.d.ts.map +1 -1
  12. package/dist/Command.js +49 -15
  13. package/dist/Command.js.map +1 -1
  14. package/dist/Debug.d.ts +104 -12
  15. package/dist/Debug.d.ts.map +1 -1
  16. package/dist/Debug.js.map +1 -1
  17. package/dist/Decode.d.ts +1 -1
  18. package/dist/Decode.js +1 -1
  19. package/dist/Descriptor.d.ts +31 -21
  20. package/dist/Descriptor.d.ts.map +1 -1
  21. package/dist/Descriptor.js +21 -12
  22. package/dist/Descriptor.js.map +1 -1
  23. package/dist/Entity.d.ts +14 -5
  24. package/dist/Entity.d.ts.map +1 -1
  25. package/dist/Entity.js +2 -2
  26. package/dist/Entity.js.map +1 -1
  27. package/dist/EntityScope.d.ts +6 -0
  28. package/dist/EntityScope.d.ts.map +1 -1
  29. package/dist/EntityScope.js +6 -0
  30. package/dist/EntityScope.js.map +1 -1
  31. package/dist/HostClock.d.ts +49 -0
  32. package/dist/HostClock.d.ts.map +1 -0
  33. package/dist/HostClock.js +46 -0
  34. package/dist/HostClock.js.map +1 -0
  35. package/dist/Inspector.d.ts +7 -1
  36. package/dist/Inspector.d.ts.map +1 -1
  37. package/dist/Inspector.js.map +1 -1
  38. package/dist/Machine.d.ts +12 -3
  39. package/dist/Machine.d.ts.map +1 -1
  40. package/dist/Machine.js +4 -1
  41. package/dist/Machine.js.map +1 -1
  42. package/dist/Query.d.ts +28 -24
  43. package/dist/Query.d.ts.map +1 -1
  44. package/dist/Query.js +0 -24
  45. package/dist/Query.js.map +1 -1
  46. package/dist/Runtime.d.ts +36 -16
  47. package/dist/Runtime.d.ts.map +1 -1
  48. package/dist/Runtime.js +230 -67
  49. package/dist/Runtime.js.map +1 -1
  50. package/dist/Schedule.d.ts +217 -10
  51. package/dist/Schedule.d.ts.map +1 -1
  52. package/dist/Schedule.js +5 -0
  53. package/dist/Schedule.js.map +1 -1
  54. package/dist/Schema.d.ts +61 -25
  55. package/dist/Schema.d.ts.map +1 -1
  56. package/dist/Schema.js +0 -8
  57. package/dist/Schema.js.map +1 -1
  58. package/dist/System.d.ts +149 -52
  59. package/dist/System.d.ts.map +1 -1
  60. package/dist/System.js +52 -6
  61. package/dist/System.js.map +1 -1
  62. package/dist/index.d.ts +8 -7
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +8 -7
  65. package/dist/index.js.map +1 -1
  66. package/dist/internal/cells.d.ts +3 -3
  67. package/dist/internal/cells.d.ts.map +1 -1
  68. package/dist/internal/cells.js +9 -11
  69. package/dist/internal/cells.js.map +1 -1
  70. package/dist/internal/debug.d.ts +6 -0
  71. package/dist/internal/debug.d.ts.map +1 -1
  72. package/dist/internal/debug.js +95 -1
  73. package/dist/internal/debug.js.map +1 -1
  74. package/dist/internal/game.d.ts.map +1 -1
  75. package/dist/internal/game.js +9 -2
  76. package/dist/internal/game.js.map +1 -1
  77. package/dist/internal/order.d.ts +10 -0
  78. package/dist/internal/order.d.ts.map +1 -0
  79. package/dist/internal/order.js +120 -0
  80. package/dist/internal/order.js.map +1 -0
  81. package/dist/internal/queries.js +2 -2
  82. package/dist/internal/queries.js.map +1 -1
  83. package/package.json +1 -1
  84. package/src/Brand.ts +9 -4
  85. package/src/Clock.ts +311 -0
  86. package/src/Command.ts +271 -73
  87. package/src/Debug.ts +111 -10
  88. package/src/Decode.ts +1 -1
  89. package/src/Descriptor.ts +37 -27
  90. package/src/Entity.ts +15 -5
  91. package/src/EntityScope.ts +6 -0
  92. package/src/HostClock.ts +64 -0
  93. package/src/Inspector.ts +7 -2
  94. package/src/Machine.ts +13 -3
  95. package/src/Query.ts +41 -33
  96. package/src/Runtime.ts +273 -91
  97. package/src/Schedule.ts +380 -13
  98. package/src/Schema.ts +70 -41
  99. package/src/System.ts +174 -88
  100. package/src/index.ts +8 -7
  101. package/src/internal/cells.ts +10 -12
  102. package/src/internal/debug.ts +104 -4
  103. package/src/internal/game.ts +11 -3
  104. package/src/internal/order.ts +140 -0
  105. package/src/internal/queries.ts +3 -3
  106. package/dist/Definition.d.ts +0 -99
  107. package/dist/Definition.d.ts.map +0 -1
  108. package/dist/Definition.js +0 -68
  109. package/dist/Definition.js.map +0 -1
  110. package/dist/Feature.d.ts +0 -106
  111. package/dist/Feature.d.ts.map +0 -1
  112. package/dist/Feature.js +0 -87
  113. package/dist/Feature.js.map +0 -1
  114. package/dist/Fx.d.ts +0 -128
  115. package/dist/Fx.d.ts.map +0 -1
  116. package/dist/Fx.js +0 -112
  117. package/dist/Fx.js.map +0 -1
  118. package/dist/internal/definition.d.ts +0 -17
  119. package/dist/internal/definition.d.ts.map +0 -1
  120. package/dist/internal/definition.js +0 -25
  121. package/dist/internal/definition.js.map +0 -1
  122. package/src/Definition.ts +0 -106
  123. package/src/Feature.ts +0 -241
  124. package/src/Fx.ts +0 -176
  125. package/src/internal/definition.ts +0 -56
@@ -1 +0,0 @@
1
- {"version":3,"file":"Feature.d.ts","sourceRoot":"","sources":["../src/Feature.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,KAAK,QAAQ,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEtG,KAAK,WAAW,GAAG,gBAAgB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AAEnD,KAAK,UAAU,GAAG;IAChB,QAAQ,C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EAAE,MAAM,CAAC,CAAA;CACnH,KACA,iBAAiB,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,CAOxD,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAClB,IAAI,EACJ,KAAK,CAAC,QAAQ,SAAS,SAAS,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,WACzD;IACT,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAC5B,GAAG,wBAAwB,CAAC,QAAQ,CAAC,KAAG,sBAAsB,CAAC,QAAQ,EAAE,IAAI,CAwC7E,CAAA;AAED,eAAO,MAAM,OAAO;;;CAGnB,CAAA"}
package/dist/Feature.js DELETED
@@ -1,87 +0,0 @@
1
- /**
2
- * Pre-bind features: reusable slices that contribute a schema fragment and the
3
- * schedules that operate on it.
4
- *
5
- * A feature builds its schedules only after the final merged schema is bound,
6
- * and its builder can only reach descriptors from its own fragment and from
7
- * the features it `requires`.
8
- *
9
- * @module Feature
10
- * @docGroup core
11
- *
12
- * @example
13
- * ```ts
14
- * const Combat = Schema.Feature.define("Combat", {
15
- * schema: CombatSchema,
16
- * requires: [Core],
17
- * build: (Game) => ({ update: [Game.Schedule(Attack, Game.Schedule.applyDeferred())] })
18
- * })
19
- *
20
- * const project = Schema.Feature.compose({ root: Root, features: [Core, Combat] })
21
- * const runtime = project.Game.Runtime.make({ services: project.Game.Runtime.services() })
22
- * runtime.tick(...project.schedules.update)
23
- * ```
24
- */
25
- import { buildSchema } from "./internal/fragments.js";
26
- import { makeGame } from "./internal/game.js";
27
- /**
28
- * Defines one pre-bind feature.
29
- */
30
- export const define = (name, options) => ({
31
- kind: "feature",
32
- name,
33
- schema: options.schema,
34
- requires: (options.requires ?? []),
35
- build: options.build,
36
- output: undefined
37
- });
38
- /**
39
- * Composes features into one merged schema and one bound `Game`, then builds
40
- * every feature against it.
41
- *
42
- * Aggregated schedule order is the selected feature order, not dependency
43
- * order. Run them with `runtime.tick(...project.schedules.update)`.
44
- */
45
- export const compose = (options) => {
46
- const featureNames = new Set();
47
- for (const feature of options.features) {
48
- if (featureNames.has(feature.name)) {
49
- throw new Error(`Duplicate feature name: ${feature.name}`);
50
- }
51
- featureNames.add(feature.name);
52
- }
53
- for (const feature of options.features) {
54
- for (const requirement of feature.requires) {
55
- if (!featureNames.has(requirement.name)) {
56
- throw new Error(`Missing required feature: ${requirement.name}`);
57
- }
58
- }
59
- }
60
- const schema = buildSchema(options.features.map((feature) => feature.schema));
61
- const Game = makeGame(schema, options.root);
62
- const features = Object.create(null);
63
- const bootstrap = [];
64
- const update = [];
65
- for (const feature of options.features) {
66
- const built = feature.build(Game);
67
- const normalized = {
68
- ...built,
69
- bootstrap: [...(built.bootstrap ?? [])],
70
- update: [...(built.update ?? [])]
71
- };
72
- bootstrap.push(...normalized.bootstrap);
73
- update.push(...normalized.update);
74
- features[feature.name] = normalized;
75
- }
76
- return {
77
- schema,
78
- Game,
79
- features,
80
- schedules: { bootstrap, update }
81
- };
82
- };
83
- export const Feature = {
84
- define,
85
- compose
86
- };
87
- //# sourceMappingURL=Feature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Feature.js","sourceRoot":"","sources":["../src/Feature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAqI7C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAMpB,IAAU,EACV,OAIC,EACyD,EAAE,CAAC,CAAC;IAC9D,IAAI,EAAE,SAAS;IACf,IAAI;IACJ,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,QAAQ,EAAE,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAa;IAC9C,KAAK,EAAE,OAAO,CAAC,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AAO,CAAC,KAAyE,CAAC,IAAI,CAAC,CAAA;QACtG,MAAM,UAAU,GAAG;YACjB,GAAG,KAAK;YACR,SAAS,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;YACvC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;SAClC,CAAA;QACD,SAAS,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;QACvC,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;QACjC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU,CAAA;IACrC,CAAC;IAED,OAAO;QACL,MAAM;QACN,IAAI;QACJ,QAAQ;QACR,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;KACoB,CAAA;AACxD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,MAAM;IACN,OAAO;CACR,CAAA"}
package/dist/Fx.d.ts DELETED
@@ -1,128 +0,0 @@
1
- /**
2
- * Small explicit effect type used for systems and runtime orchestration.
3
- *
4
- * `Fx` models delayed computation with typed success, failure, and environment
5
- * channels. Expected failures are returned as `Result` values; exceptions are
6
- * reserved for unexpected defects in user code.
7
- *
8
- * Systems that cannot fail return nothing. A system returns an `Fx` when it
9
- * has an expected failure: `Fx.fail(...)` rolls back the system's ECS writes
10
- * and surfaces a typed `SystemFailure` from `runtime.tick(...)`. `map` and
11
- * `flatMap` compose such effects.
12
- *
13
- * @example
14
- * ```ts
15
- * // Build one small delayed computation.
16
- * const program = Fx.map(Fx.succeed(1), (value) => value + 1)
17
- *
18
- * // Execute it explicitly at the runtime boundary.
19
- * const result = Fx.runSync(program)
20
- * ```
21
- *
22
- * @module Fx
23
- * @docGroup runtime
24
- *
25
- * @groupDescription Namespaces
26
- * Grouped helper types that extract success, error, and environment information from effects.
27
- *
28
- * @groupDescription Interfaces
29
- * Public effect contracts used by systems and runtime orchestration.
30
- *
31
- * @groupDescription Type Aliases
32
- * Shared helper types derived from one `Fx` value.
33
- *
34
- * @groupDescription Functions
35
- * Minimal constructors and combinators for explicit delayed computations.
36
- */
37
- import * as Result from "./Result.ts";
38
- /**
39
- * String-literal type id used to mirror Effect's current `~effect/...` style.
40
- */
41
- export type FxTypeId = "~ritmo/Fx";
42
- /**
43
- * Runtime value for the `Fx` type id.
44
- */
45
- declare const fxTypeId: FxTypeId;
46
- /**
47
- * A minimal Effect-style computation used by the runtime.
48
- *
49
- * `Fx<A, E, R>` models a computation that succeeds with `A`, may fail with `E`,
50
- * and requires an environment `R`.
51
- */
52
- export interface Fx<A, E = never, R = unknown> {
53
- readonly [fxTypeId]: {
54
- readonly _A: (_: never) => A;
55
- readonly _E: (_: never) => E;
56
- readonly _R: (_: R) => void;
57
- };
58
- readonly run: (environment: R) => Result.Result<A, E>;
59
- }
60
- /**
61
- * Type-level helpers for `Fx`.
62
- */
63
- export declare namespace Fx {
64
- /**
65
- * Extracts the success type from an effect.
66
- */
67
- type Success<T extends Fx<any, any, any>> = T extends Fx<infer A, infer _E, infer _R> ? A : never;
68
- /**
69
- * Extracts the error type from an effect.
70
- */
71
- type Error<T extends Fx<any, any, any>> = T extends Fx<infer _A, infer E, infer _R> ? E : never;
72
- /**
73
- * Extracts the required environment from an effect.
74
- */
75
- type Context<T extends Fx<any, any, any>> = T extends Fx<infer _A, infer _E, infer R> ? R : never;
76
- }
77
- /**
78
- * Creates an effect that immediately succeeds with a value.
79
- *
80
- * Use this for pure values that should still participate in the typed effect
81
- * composition model.
82
- */
83
- export declare const succeed: <A, R = unknown>(value: A) => Fx<A, never, R>;
84
- /**
85
- * Wraps a synchronous computation in an `Fx`.
86
- *
87
- * This is the most common constructor for system implementations in the current
88
- * runtime because systems are executed synchronously.
89
- */
90
- export declare const sync: <A, R = unknown>(evaluate: () => A) => Fx<A, never, R>;
91
- /**
92
- * Creates an effect that returns one expected failure when run.
93
- */
94
- export declare const fail: <E, R = unknown>(error: E) => Fx<never, E, R>;
95
- /**
96
- * Transforms the success value of an effect.
97
- */
98
- export declare const map: <A, B, E, R>(self: Fx<A, E, R>, f: (value: A) => B) => Fx<B, E, R>;
99
- /**
100
- * Sequences two effects, allowing the second one to depend on the first result.
101
- */
102
- export declare const flatMap: <A, B, E1, E2, R1, R2>(self: Fx<A, E1, R1>, f: (value: A) => Fx<B, E2, R2>) => Fx<B, E1 | E2, R1 & R2>;
103
- /**
104
- * Reads the whole effect environment.
105
- *
106
- * Use this when a system helper wants access to all declared services at once.
107
- */
108
- export declare const access: <R>() => Fx<R, never, R>;
109
- /**
110
- * Reads a single service from the environment by key.
111
- *
112
- * This is useful for small helpers that need one dependency without threading
113
- * the entire environment type manually.
114
- */
115
- export declare const accessService: <R, K extends keyof R>(key: K) => Fx<R[K], never, R>;
116
- /**
117
- * Supplies the environment needed by an effect.
118
- */
119
- export declare const provide: <A, E, R>(self: Fx<A, E, R>, environment: R) => Fx<A, E, unknown>;
120
- /**
121
- * Runs an effect that no longer requires any environment.
122
- *
123
- * The runtime uses this at the edge after it has provided the services declared
124
- * by a system spec.
125
- */
126
- export declare const runSync: <A, E>(self: Fx<A, E, unknown>) => Result.Result<A, E>;
127
- export {};
128
- //# sourceMappingURL=Fx.d.ts.map
package/dist/Fx.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Fx.d.ts","sourceRoot":"","sources":["../src/Fx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAA;AAElC;;GAEG;AACH,QAAA,MAAM,QAAQ,EAAE,QAAsB,CAAA;AAEtC;;;;;GAKG;AACH,MAAM,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG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C,QACvB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,eACJ,CAAC,KACb,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAsC,CAAA;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CACrD,CAAA"}
package/dist/Fx.js DELETED
@@ -1,112 +0,0 @@
1
- /**
2
- * Small explicit effect type used for systems and runtime orchestration.
3
- *
4
- * `Fx` models delayed computation with typed success, failure, and environment
5
- * channels. Expected failures are returned as `Result` values; exceptions are
6
- * reserved for unexpected defects in user code.
7
- *
8
- * Systems that cannot fail return nothing. A system returns an `Fx` when it
9
- * has an expected failure: `Fx.fail(...)` rolls back the system's ECS writes
10
- * and surfaces a typed `SystemFailure` from `runtime.tick(...)`. `map` and
11
- * `flatMap` compose such effects.
12
- *
13
- * @example
14
- * ```ts
15
- * // Build one small delayed computation.
16
- * const program = Fx.map(Fx.succeed(1), (value) => value + 1)
17
- *
18
- * // Execute it explicitly at the runtime boundary.
19
- * const result = Fx.runSync(program)
20
- * ```
21
- *
22
- * @module Fx
23
- * @docGroup runtime
24
- *
25
- * @groupDescription Namespaces
26
- * Grouped helper types that extract success, error, and environment information from effects.
27
- *
28
- * @groupDescription Interfaces
29
- * Public effect contracts used by systems and runtime orchestration.
30
- *
31
- * @groupDescription Type Aliases
32
- * Shared helper types derived from one `Fx` value.
33
- *
34
- * @groupDescription Functions
35
- * Minimal constructors and combinators for explicit delayed computations.
36
- */
37
- import * as Result from "./Result.js";
38
- /**
39
- * Runtime value for the `Fx` type id.
40
- */
41
- const fxTypeId = "~ritmo/Fx";
42
- /**
43
- * Low-level constructor for `Fx`.
44
- *
45
- * All public constructors eventually delegate here so the runtime shape stays
46
- * consistent.
47
- */
48
- const make = (run) => ({
49
- [fxTypeId]: {
50
- _A: (_) => undefined,
51
- _E: (_) => undefined,
52
- _R: (_) => undefined
53
- },
54
- run
55
- });
56
- /**
57
- * Creates an effect that immediately succeeds with a value.
58
- *
59
- * Use this for pure values that should still participate in the typed effect
60
- * composition model.
61
- */
62
- export const succeed = (value) => make(() => Result.success(value));
63
- /**
64
- * Wraps a synchronous computation in an `Fx`.
65
- *
66
- * This is the most common constructor for system implementations in the current
67
- * runtime because systems are executed synchronously.
68
- */
69
- export const sync = (evaluate) => make(() => Result.success(evaluate()));
70
- /**
71
- * Creates an effect that returns one expected failure when run.
72
- */
73
- export const fail = (error) => make(() => Result.failure(error));
74
- /**
75
- * Transforms the success value of an effect.
76
- */
77
- export const map = (self, f) => make((environment) => {
78
- const result = self.run(environment);
79
- return result.ok ? Result.success(f(result.value)) : result;
80
- });
81
- /**
82
- * Sequences two effects, allowing the second one to depend on the first result.
83
- */
84
- export const flatMap = (self, f) => make((environment) => {
85
- const first = self.run(environment);
86
- return first.ok ? f(first.value).run(environment) : first;
87
- });
88
- /**
89
- * Reads the whole effect environment.
90
- *
91
- * Use this when a system helper wants access to all declared services at once.
92
- */
93
- export const access = () => make((environment) => Result.success(environment));
94
- /**
95
- * Reads a single service from the environment by key.
96
- *
97
- * This is useful for small helpers that need one dependency without threading
98
- * the entire environment type manually.
99
- */
100
- export const accessService = (key) => make((environment) => Result.success(environment[key]));
101
- /**
102
- * Supplies the environment needed by an effect.
103
- */
104
- export const provide = (self, environment) => make(() => self.run(environment));
105
- /**
106
- * Runs an effect that no longer requires any environment.
107
- *
108
- * The runtime uses this at the edge after it has provided the services declared
109
- * by a system spec.
110
- */
111
- export const runSync = (self) => self.run(undefined);
112
- //# sourceMappingURL=Fx.js.map
package/dist/Fx.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Fx.js","sourceRoot":"","sources":["../src/Fx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,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AAC7D,CAAC,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,IAAmB,EACnB,CAA8B,EACL,EAAE,CAAC,IAAI,CAAsB,CAAC,WAAW,EAAE,EAAE;IACtE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,WAAiB,CAAC,CAAA;IACzC,OAAO,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,WAAiB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AACjE,CAAC,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAuB,EAAE,CAC7C,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAuB,GAAM,EAAsB,EAAE,CAChF,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAEzD;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,IAAiB,EACjB,WAAc,EACK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAO,IAAuB,EAAuB,EAAE,CAC5E,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA"}
@@ -1,17 +0,0 @@
1
- import * as Result from "../Result.ts";
2
- export type Entry<Value, Error> = Result.Result<Value, Error>;
3
- export type ResultConstructor<Value, Raw, Error> = {
4
- readonly result: (raw: Raw) => Result.Result<Value, Error>;
5
- };
6
- type AnyEntry = Result.Result<any, any>;
7
- export type Entries = Readonly<Record<string, AnyEntry>>;
8
- export type SuccessOf<Input extends Entries> = {
9
- readonly [Key in keyof Input]: Input[Key] extends Result.Result<infer Value, any> ? Value : never;
10
- };
11
- export type ErrorOf<Input extends Entries> = {
12
- readonly [Key in keyof Input]: Input[Key] extends Result.Result<any, infer Error> ? Error | null : never;
13
- };
14
- export declare const entry: <Value, Raw, Error>(constructor: ResultConstructor<Value, Raw, Error>, raw: Raw) => Entry<Value, Error>;
15
- export declare const all: <Input extends Entries>(input: Input) => Result.Result<SuccessOf<Input>, ErrorOf<Input>>;
16
- export {};
17
- //# sourceMappingURL=definition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/internal/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAEtC,MAAM,MAAM,KAAK,CAAC,KAAK,EAAE,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AAE7D,MAAM,MAAM,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI;IACjD,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;CAC3D,CAAA;AAED,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AAEvC,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;AAExD,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,OAAO,IAAI;IAC7C,QAAQ,EAAE,GAAG,IAAI,MAAM,KAAK,GAC1B,KAAK,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,EAAE,GAAG,CAAC,GAAG,KAAK,GAAG,KAAK;CACrE,CAAA;AAED,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,OAAO,IAAI;IAC3C,QAAQ,EAAE,GAAG,IAAI,MAAM,KAAK,GAC1B,KAAK,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK;CAC5E,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,KAAK,EAAE,GAAG,EAAE,KAAK,eACxB,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,OAC5C,GAAG,KACP,KAAK,CAAC,KAAK,EAAE,KAAK,CAA4B,CAAA;AAEjD,eAAO,MAAM,GAAG,GAAI,KAAK,SAAS,OAAO,SAChC,KAAK,KACX,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CA0BhD,CAAA"}
@@ -1,25 +0,0 @@
1
- import * as Result from "../Result.js";
2
- export const entry = (constructor, raw) => constructor.result(raw);
3
- export const all = (input) => {
4
- const values = {};
5
- const errors = {};
6
- let hasFailure = false;
7
- for (const key of Object.keys(input)) {
8
- const entry = input[key];
9
- if (entry === undefined) {
10
- continue;
11
- }
12
- if (entry.ok) {
13
- values[key] = entry.value;
14
- errors[key] = null;
15
- continue;
16
- }
17
- hasFailure = true;
18
- errors[key] = entry.error;
19
- }
20
- if (hasFailure) {
21
- return Result.failure(errors);
22
- }
23
- return Result.success(values);
24
- };
25
- //# sourceMappingURL=definition.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/internal/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAsBtC,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,WAAiD,EACjD,GAAQ,EACa,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAEjD,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,KAAY,EACqC,EAAE;IACnD,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,IAAI,UAAU,GAAG,KAAK,CAAA;IAEtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;QACxB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAQ;QACV,CAAC;QAED,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAA;YACzB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;YAClB,SAAQ;QACV,CAAC;QAED,UAAU,GAAG,IAAI,CAAA;QACjB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAA;IAC3B,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,OAAO,CAAC,MAAwB,CAAC,CAAA;IACjD,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,MAA0B,CAAC,CAAA;AACnD,CAAC,CAAA"}
package/src/Definition.ts DELETED
@@ -1,106 +0,0 @@
1
- /**
2
- * Helpers for validating reusable authored values once and reusing them later.
3
- *
4
- * `Definition` is intended for static or rarely changing authored data such as
5
- * spawn points, collider sizes, arena bounds, or other constants that should
6
- * cross the validation boundary once and then remain branded afterward.
7
- *
8
- * In game code this is the "content setup" companion to runtime/world setup:
9
- * validate authored constants early, keep them in carried form, and then reuse
10
- * them from setup systems, reset systems, or content modules without
11
- * revalidating on every frame.
12
- *
13
- * @example
14
- * ```ts
15
- * // Validate authored constants once when defining the content bundle.
16
- * const player = Definition.all({
17
- * spawn: Definition.entry(Vector2, { x: 32, y: 48 }),
18
- * size: Definition.entry(Size2, { width: 16, height: 16 })
19
- * })
20
- * ```
21
- *
22
- * @module Definition
23
- * @docGroup core
24
- *
25
- * @categoryDescription Definition Types
26
- * Named reusable shapes used to validate and retain authored values.
27
- *
28
- * @categoryDescription Definition Builders
29
- * Helpers that validate one or several authored values through existing constructors.
30
- */
31
- import * as internal from "./internal/definition.ts"
32
- import type * as Result from "./Result.ts"
33
-
34
- /**
35
- * One reusable validated definition entry.
36
- *
37
- * @category Definition Types
38
- */
39
- export type Entry<Value, Error> = internal.Entry<Value, Error>
40
- /**
41
- * Record of named definition entries accepted by {@link all}.
42
- *
43
- * @category Definition Types
44
- */
45
- export type Entries = internal.Entries
46
- /**
47
- * Minimal constructor contract accepted by {@link entry}.
48
- *
49
- * @category Definition Types
50
- */
51
- export type ResultConstructor<Value, Raw, Error> = internal.ResultConstructor<Value, Raw, Error>
52
- /**
53
- * Success shape produced by {@link all}.
54
- *
55
- * @category Definition Types
56
- */
57
- export type SuccessOf<Input extends Entries> = internal.SuccessOf<Input>
58
- /**
59
- * Error shape produced by {@link all}.
60
- *
61
- * @category Definition Types
62
- */
63
- export type ErrorOf<Input extends Entries> = internal.ErrorOf<Input>
64
-
65
- /**
66
- * Validates one reusable authored value through an existing constructor.
67
- *
68
- * Use this for one named authored constant that should cross a constructor
69
- * boundary now and remain in carried form afterward.
70
- *
71
- * @example
72
- * ```ts
73
- * // Validate a single authored position once during content setup.
74
- * const playerSpawn = Definition.entry(Vector2, { x: 32, y: 48 })
75
- * ```
76
- *
77
- * @category Definition Builders
78
- */
79
- export const entry: <Value, Raw, Error>(
80
- constructor: ResultConstructor<Value, Raw, Error>,
81
- raw: Raw
82
- ) => Entry<Value, Error> = internal.entry
83
-
84
- /**
85
- * Validates a named record of reusable authored values at once.
86
- *
87
- * Successful entries are returned under the same keys. Failed entries remain
88
- * keyed so authored-data setup can report exactly which constant was invalid.
89
- *
90
- * Use this when one content bundle or level definition should either validate
91
- * as a whole or report a structured set of authoring failures.
92
- *
93
- * @example
94
- * ```ts
95
- * // Validate one authored content bundle and keep failures keyed by field.
96
- * const definitions = Definition.all({
97
- * spawn: Definition.entry(Vector2, { x: 32, y: 48 }),
98
- * collider: Definition.entry(Size2, { width: 16, height: 16 })
99
- * })
100
- * ```
101
- *
102
- * @category Definition Builders
103
- */
104
- export const all: <Input extends Entries>(
105
- input: Input
106
- ) => Result.Result<SuccessOf<Input>, ErrorOf<Input>> = internal.all