@driftengine/script 4.8.1 → 4.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  The `drift/*` capability bindings: what this engine provides to DriftScript, and **the only place the
4
4
  two are coupled**.
5
5
 
6
- **Cost: 37.3 KB gzipped on top of core.** Measured by `scripts/size-gate.test.mjs`, which fails if it
6
+ **Cost: 40.3 KB gzipped on top of core.** Measured by `scripts/size-gate.test.mjs`, which fails if it
7
7
  drifts more than 3% — the number is derived from the same floors that gate asserts, so a README
8
8
  quoting a stale one is a red suite rather than a thing somebody notices.
9
9
 
package/capabilities.json CHANGED
@@ -2704,7 +2704,8 @@
2704
2704
  },
2705
2705
  {
2706
2706
  "name": "component",
2707
- "type": "String"
2707
+ "type": "String",
2708
+ "component": "read"
2708
2709
  }
2709
2710
  ],
2710
2711
  "returns": "bool",
@@ -2730,7 +2731,8 @@
2730
2731
  },
2731
2732
  {
2732
2733
  "name": "component",
2733
- "type": "String"
2734
+ "type": "String",
2735
+ "component": "write"
2734
2736
  }
2735
2737
  ],
2736
2738
  "returns": "void",
@@ -2756,7 +2758,8 @@
2756
2758
  },
2757
2759
  {
2758
2760
  "name": "component",
2759
- "type": "String"
2761
+ "type": "String",
2762
+ "component": "write"
2760
2763
  }
2761
2764
  ],
2762
2765
  "returns": "bool",
@@ -2782,7 +2785,8 @@
2782
2785
  },
2783
2786
  {
2784
2787
  "name": "component",
2785
- "type": "String"
2788
+ "type": "String",
2789
+ "component": "read"
2786
2790
  },
2787
2791
  {
2788
2792
  "name": "field",
@@ -2812,7 +2816,8 @@
2812
2816
  },
2813
2817
  {
2814
2818
  "name": "component",
2815
- "type": "String"
2819
+ "type": "String",
2820
+ "component": "write"
2816
2821
  },
2817
2822
  {
2818
2823
  "name": "field",
@@ -2842,7 +2847,8 @@
2842
2847
  },
2843
2848
  {
2844
2849
  "name": "component",
2845
- "type": "String"
2850
+ "type": "String",
2851
+ "component": "read"
2846
2852
  }
2847
2853
  ],
2848
2854
  "returns": "u32",
@@ -2864,7 +2870,8 @@
2864
2870
  },
2865
2871
  {
2866
2872
  "name": "component",
2867
- "type": "String"
2873
+ "type": "String",
2874
+ "component": "read"
2868
2875
  },
2869
2876
  {
2870
2877
  "name": "index",
@@ -2890,7 +2897,8 @@
2890
2897
  },
2891
2898
  {
2892
2899
  "name": "component",
2893
- "type": "String"
2900
+ "type": "String",
2901
+ "component": "read"
2894
2902
  },
2895
2903
  {
2896
2904
  "name": "fieldX",
@@ -4104,19 +4112,23 @@
4104
4112
  },
4105
4113
  {
4106
4114
  "name": "a",
4107
- "type": "String"
4115
+ "type": "String",
4116
+ "component": "read"
4108
4117
  },
4109
4118
  {
4110
4119
  "name": "b",
4111
- "type": "String"
4120
+ "type": "String",
4121
+ "component": "read"
4112
4122
  },
4113
4123
  {
4114
4124
  "name": "c",
4115
- "type": "String"
4125
+ "type": "String",
4126
+ "component": "read"
4116
4127
  },
4117
4128
  {
4118
4129
  "name": "d",
4119
- "type": "String"
4130
+ "type": "String",
4131
+ "component": "read"
4120
4132
  }
4121
4133
  ],
4122
4134
  "returns": "Cursor",
@@ -4178,7 +4190,8 @@
4178
4190
  },
4179
4191
  {
4180
4192
  "name": "component",
4181
- "type": "String"
4193
+ "type": "String",
4194
+ "component": "read"
4182
4195
  },
4183
4196
  {
4184
4197
  "name": "forWriting",
@@ -26,7 +26,7 @@
26
26
  * should walk backwards, and the doc on `at` says so.
27
27
  */
28
28
  import { ENTITY_INDEX_CEILING, instantiate, } from '@driftengine/entities';
29
- import { defineCapability } from 'driftscript';
29
+ import { defineCapability, } from 'driftscript';
30
30
  export const ECS_MODULE = 'drift/ecs';
31
31
  const define = (module, name, params, returns, effects, deterministic, doc) => defineCapability({
32
32
  module,
@@ -74,6 +74,15 @@ export const ENTITY_TYPES = [
74
74
  * **`read` still answers `f64`**, and that is not an oversight: it reads a component *field*, which
75
75
  * is a number, and typing it as a handle would be the same mistake in the other direction.
76
76
  */
77
+ /*
78
+ * **A parameter that names a component says so, and how** (`component: 'read' | 'write'`), so the
79
+ * compiler counts `ecs.count(world, "Hunger")` as a read of Hunger exactly as the schedule does when
80
+ * the system runs: without it the declaration the host demands was called unused (DS0291), and
81
+ * leaving it out compiled clean and was refused per tick. `without` names one and is not marked —
82
+ * an exclusion never looks inside the component, which is the host's rule and the compiler's. `view`
83
+ * is marked a read: whether it asks to write is a runtime flag, and the write it would need is a
84
+ * declaration the host still checks.
85
+ */
77
86
  export const ECS_CAPABILITIES = [
78
87
  define(ECS_MODULE, 'create', [{ name: 'world', type: 'World' }], 'Entity', ['ecs.write'], false, 'A fresh entity with nothing on it. The handle is exact; do not put one in an `f32`.'),
79
88
  define(ECS_MODULE, 'destroy', [
@@ -87,38 +96,38 @@ export const ECS_CAPABILITIES = [
87
96
  define(ECS_MODULE, 'has', [
88
97
  { name: 'world', type: 'World' },
89
98
  { name: 'entity', type: 'Entity' },
90
- { name: 'component', type: 'String' },
99
+ { name: 'component', type: 'String', component: 'read' },
91
100
  ], 'bool', ['ecs.read'], true, 'Whether an entity carries a component.'),
92
101
  define(ECS_MODULE, 'attach', [
93
102
  { name: 'world', type: 'World' },
94
103
  { name: 'entity', type: 'Entity' },
95
- { name: 'component', type: 'String' },
104
+ { name: 'component', type: 'String', component: 'write' },
96
105
  ], 'void', ['ecs.write'], false, 'Give an entity a component, every field at the zero for its type. Set them with `write`.'),
97
106
  define(ECS_MODULE, 'detach', [
98
107
  { name: 'world', type: 'World' },
99
108
  { name: 'entity', type: 'Entity' },
100
- { name: 'component', type: 'String' },
109
+ { name: 'component', type: 'String', component: 'write' },
101
110
  ], 'bool', ['ecs.write'], false, 'Take a component away. False when it did not have one.'),
102
111
  define(ECS_MODULE, 'read', [
103
112
  { name: 'world', type: 'World' },
104
113
  { name: 'entity', type: 'Entity' },
105
- { name: 'component', type: 'String' },
114
+ { name: 'component', type: 'String', component: 'read' },
106
115
  { name: 'field', type: 'String' },
107
116
  ], 'f64', ['ecs.read'], true, 'One numeric field. Reading a field of a component an entity does not have is 0.'),
108
117
  define(ECS_MODULE, 'write', [
109
118
  { name: 'world', type: 'World' },
110
119
  { name: 'entity', type: 'Entity' },
111
- { name: 'component', type: 'String' },
120
+ { name: 'component', type: 'String', component: 'write' },
112
121
  { name: 'field', type: 'String' },
113
122
  { name: 'value', type: 'f64' },
114
123
  ], 'void', ['ecs.write'], false, 'Set one numeric field.'),
115
124
  define(ECS_MODULE, 'count', [
116
125
  { name: 'world', type: 'World' },
117
- { name: 'component', type: 'String' },
126
+ { name: 'component', type: 'String', component: 'read' },
118
127
  ], 'u32', ['ecs.read'], true, 'How many entities carry a component.'),
119
128
  define(ECS_MODULE, 'at', [
120
129
  { name: 'world', type: 'World' },
121
- { name: 'component', type: 'String' },
130
+ { name: 'component', type: 'String', component: 'read' },
122
131
  { name: 'index', type: 'u32' },
123
132
  ], 'Entity', ['ecs.read'], true, 'The nth entity carrying a component. **The order is insertion modified by swap-removal**, so a walk that removes should count downwards — removing moves the last entity into a position already passed.'),
124
133
  /*
@@ -137,7 +146,7 @@ export const ECS_CAPABILITIES = [
137
146
  */
138
147
  define(ECS_MODULE, 'findNearest', [
139
148
  { name: 'world', type: 'World' },
140
- { name: 'component', type: 'String' },
149
+ { name: 'component', type: 'String', component: 'read' },
141
150
  { name: 'fieldX', type: 'String' },
142
151
  { name: 'fieldY', type: 'String' },
143
152
  { name: 'fieldZ', type: 'String' },
@@ -169,10 +178,10 @@ export const ECS_CAPABILITIES = [
169
178
  export const QUERY_CAPABILITIES = [
170
179
  define(ECS_MODULE, 'query', [
171
180
  { name: 'world', type: 'World' },
172
- { name: 'a', type: 'String' },
173
- { name: 'b', type: 'String' },
174
- { name: 'c', type: 'String' },
175
- { name: 'd', type: 'String' },
181
+ { name: 'a', type: 'String', component: 'read' },
182
+ { name: 'b', type: 'String', component: 'read' },
183
+ { name: 'c', type: 'String', component: 'read' },
184
+ { name: 'd', type: 'String', component: 'read' },
176
185
  ], 'Cursor', ['ecs.read'], true, 'Open a walk over everything carrying these components. The cursor is borrowed from the world’s pool; ending the walk gives it back.'),
177
186
  define(ECS_MODULE, 'without', [
178
187
  { name: 'cursor', type: 'Cursor' },
@@ -181,7 +190,7 @@ export const QUERY_CAPABILITIES = [
181
190
  define(ECS_MODULE, 'next', [{ name: 'cursor', type: 'Cursor' }], 'Entity', ['ecs.read'], true, 'The next entity, or a **negative** number when the walk is done — which also gives the cursor back. Negative rather than zero, because zero is a legal handle.'),
182
191
  define(ECS_MODULE, 'view', [
183
192
  { name: 'world', type: 'World' },
184
- { name: 'component', type: 'String' },
193
+ { name: 'component', type: 'String', component: 'read' },
185
194
  { name: 'forWriting', type: 'bool' },
186
195
  ], 'View', ['ecs.read'], true, 'A component’s live columns. `forWriting` decides which of a system’s declarations is checked — a loop that only reads takes a readable view, and asking for more than the system declared is refused.'),
187
196
  ];
package/dist/index.d.ts CHANGED
@@ -18,4 +18,5 @@ export { CHEMISTRY_CAPABILITIES, CHEMISTRY_COMPONENT, CHEMISTRY_MODULE, CHEMISTR
18
18
  export type { ComponentRegistry, RegisteredModule } from './entityHost.ts';
19
19
  export { assertHostShapes, registerEntityModule } from './entityHost.ts';
20
20
  export type { BindResult, HostServices } from './host.ts';
21
+ export type { XrRuntime } from './bindings/xr.ts';
21
22
  export { ENGINE_MODULES, bindModule, engineImplementations, engineRegistry, engineTarget, } from './host.ts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driftengine/script",
3
- "version": "4.8.1",
3
+ "version": "4.8.3",
4
4
  "description": "The drift/* capability bindings: what this engine provides to DriftScript, and the only place the two are coupled",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -28,20 +28,20 @@
28
28
  ],
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
- "driftscript": "1.16.0"
31
+ "driftscript": "1.17.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@driftengine/ai": "4.8.1",
35
- "@driftengine/animation": "4.8.1",
36
- "@driftengine/audio": "4.8.1",
37
- "@driftengine/chemistry": "4.8.1",
38
- "@driftengine/core": "4.8.1",
39
- "@driftengine/editor": "4.8.1",
40
- "@driftengine/entities": "4.8.1",
41
- "@driftengine/network": "4.8.1",
42
- "@driftengine/terrain": "4.8.1",
43
- "@driftengine/ui2d": "4.8.1",
44
- "@driftengine/xr": "4.8.1"
34
+ "@driftengine/ai": "4.8.3",
35
+ "@driftengine/animation": "4.8.3",
36
+ "@driftengine/audio": "4.8.3",
37
+ "@driftengine/chemistry": "4.8.3",
38
+ "@driftengine/core": "4.8.3",
39
+ "@driftengine/editor": "4.8.3",
40
+ "@driftengine/entities": "4.8.3",
41
+ "@driftengine/network": "4.8.3",
42
+ "@driftengine/terrain": "4.8.3",
43
+ "@driftengine/ui2d": "4.8.3",
44
+ "@driftengine/xr": "4.8.3"
45
45
  },
46
46
  "author": "Drift Technologies",
47
47
  "repository": {
@@ -36,14 +36,19 @@ import {
36
36
  type World,
37
37
  instantiate,
38
38
  } from '@driftengine/entities';
39
- import { type CapabilityDefinition, type OpaqueType, defineCapability } from 'driftscript';
39
+ import {
40
+ type CapabilityDefinition,
41
+ type CapabilityParam,
42
+ type OpaqueType,
43
+ defineCapability,
44
+ } from 'driftscript';
40
45
 
41
46
  export const ECS_MODULE = 'drift/ecs';
42
47
 
43
48
  const define = (
44
49
  module: string,
45
50
  name: string,
46
- params: readonly { name: string; type: string }[],
51
+ params: readonly CapabilityParam[],
47
52
  returns: string,
48
53
  effects: CapabilityDefinition['effects'],
49
54
  deterministic: boolean,
@@ -97,6 +102,15 @@ export const ENTITY_TYPES: readonly OpaqueType[] = [
97
102
  * **`read` still answers `f64`**, and that is not an oversight: it reads a component *field*, which
98
103
  * is a number, and typing it as a handle would be the same mistake in the other direction.
99
104
  */
105
+ /*
106
+ * **A parameter that names a component says so, and how** (`component: 'read' | 'write'`), so the
107
+ * compiler counts `ecs.count(world, "Hunger")` as a read of Hunger exactly as the schedule does when
108
+ * the system runs: without it the declaration the host demands was called unused (DS0291), and
109
+ * leaving it out compiled clean and was refused per tick. `without` names one and is not marked —
110
+ * an exclusion never looks inside the component, which is the host's rule and the compiler's. `view`
111
+ * is marked a read: whether it asks to write is a runtime flag, and the write it would need is a
112
+ * declaration the host still checks.
113
+ */
100
114
  export const ECS_CAPABILITIES: readonly CapabilityDefinition[] = [
101
115
  define(
102
116
  ECS_MODULE,
@@ -137,7 +151,7 @@ export const ECS_CAPABILITIES: readonly CapabilityDefinition[] = [
137
151
  [
138
152
  { name: 'world', type: 'World' },
139
153
  { name: 'entity', type: 'Entity' },
140
- { name: 'component', type: 'String' },
154
+ { name: 'component', type: 'String', component: 'read' },
141
155
  ],
142
156
  'bool',
143
157
  ['ecs.read'],
@@ -150,7 +164,7 @@ export const ECS_CAPABILITIES: readonly CapabilityDefinition[] = [
150
164
  [
151
165
  { name: 'world', type: 'World' },
152
166
  { name: 'entity', type: 'Entity' },
153
- { name: 'component', type: 'String' },
167
+ { name: 'component', type: 'String', component: 'write' },
154
168
  ],
155
169
  'void',
156
170
  ['ecs.write'],
@@ -163,7 +177,7 @@ export const ECS_CAPABILITIES: readonly CapabilityDefinition[] = [
163
177
  [
164
178
  { name: 'world', type: 'World' },
165
179
  { name: 'entity', type: 'Entity' },
166
- { name: 'component', type: 'String' },
180
+ { name: 'component', type: 'String', component: 'write' },
167
181
  ],
168
182
  'bool',
169
183
  ['ecs.write'],
@@ -176,7 +190,7 @@ export const ECS_CAPABILITIES: readonly CapabilityDefinition[] = [
176
190
  [
177
191
  { name: 'world', type: 'World' },
178
192
  { name: 'entity', type: 'Entity' },
179
- { name: 'component', type: 'String' },
193
+ { name: 'component', type: 'String', component: 'read' },
180
194
  { name: 'field', type: 'String' },
181
195
  ],
182
196
  'f64',
@@ -190,7 +204,7 @@ export const ECS_CAPABILITIES: readonly CapabilityDefinition[] = [
190
204
  [
191
205
  { name: 'world', type: 'World' },
192
206
  { name: 'entity', type: 'Entity' },
193
- { name: 'component', type: 'String' },
207
+ { name: 'component', type: 'String', component: 'write' },
194
208
  { name: 'field', type: 'String' },
195
209
  { name: 'value', type: 'f64' },
196
210
  ],
@@ -204,7 +218,7 @@ export const ECS_CAPABILITIES: readonly CapabilityDefinition[] = [
204
218
  'count',
205
219
  [
206
220
  { name: 'world', type: 'World' },
207
- { name: 'component', type: 'String' },
221
+ { name: 'component', type: 'String', component: 'read' },
208
222
  ],
209
223
  'u32',
210
224
  ['ecs.read'],
@@ -216,7 +230,7 @@ export const ECS_CAPABILITIES: readonly CapabilityDefinition[] = [
216
230
  'at',
217
231
  [
218
232
  { name: 'world', type: 'World' },
219
- { name: 'component', type: 'String' },
233
+ { name: 'component', type: 'String', component: 'read' },
220
234
  { name: 'index', type: 'u32' },
221
235
  ],
222
236
  'Entity',
@@ -243,7 +257,7 @@ export const ECS_CAPABILITIES: readonly CapabilityDefinition[] = [
243
257
  'findNearest',
244
258
  [
245
259
  { name: 'world', type: 'World' },
246
- { name: 'component', type: 'String' },
260
+ { name: 'component', type: 'String', component: 'read' },
247
261
  { name: 'fieldX', type: 'String' },
248
262
  { name: 'fieldY', type: 'String' },
249
263
  { name: 'fieldZ', type: 'String' },
@@ -300,10 +314,10 @@ export const QUERY_CAPABILITIES: readonly CapabilityDefinition[] = [
300
314
  'query',
301
315
  [
302
316
  { name: 'world', type: 'World' },
303
- { name: 'a', type: 'String' },
304
- { name: 'b', type: 'String' },
305
- { name: 'c', type: 'String' },
306
- { name: 'd', type: 'String' },
317
+ { name: 'a', type: 'String', component: 'read' },
318
+ { name: 'b', type: 'String', component: 'read' },
319
+ { name: 'c', type: 'String', component: 'read' },
320
+ { name: 'd', type: 'String', component: 'read' },
307
321
  ],
308
322
  'Cursor',
309
323
  ['ecs.read'],
@@ -336,7 +350,7 @@ export const QUERY_CAPABILITIES: readonly CapabilityDefinition[] = [
336
350
  'view',
337
351
  [
338
352
  { name: 'world', type: 'World' },
339
- { name: 'component', type: 'String' },
353
+ { name: 'component', type: 'String', component: 'read' },
340
354
  { name: 'forWriting', type: 'bool' },
341
355
  ],
342
356
  'View',
package/src/index.ts CHANGED
@@ -32,6 +32,8 @@ export type { ComponentRegistry, RegisteredModule } from './entityHost.ts';
32
32
  export { assertHostShapes, registerEntityModule } from './entityHost.ts';
33
33
 
34
34
  export type { BindResult, HostServices } from './host.ts';
35
+ /* What `HostServices.xr` takes, by name, so a host does not spell it `NonNullable<HostServices['xr']>`. */
36
+ export type { XrRuntime } from './bindings/xr.ts';
35
37
  export {
36
38
  ENGINE_MODULES,
37
39
  bindModule,