@typeonce/oxlint-plugin-ritmo 0.19.1 → 0.21.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.
- package/CHANGELOG.md +53 -0
- package/README.md +7 -7
- package/dist/rules/no-state-spread.js +1 -1
- package/dist/rules/no-state-spread.js.map +1 -1
- package/dist/rules/use-random-for-randomness.js +1 -1
- package/dist/rules/use-random-for-randomness.js.map +1 -1
- package/package.json +2 -2
- package/src/rules/no-state-spread.ts +1 -1
- package/src/rules/use-random-for-randomness.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @typeonce/oxlint-plugin-ritmo
|
|
2
2
|
|
|
3
|
+
## 0.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d1d864d: **Breaking: the packages require Node 22 or newer (Node 20 reached end of life on 2026-04-30).** `engines.node` is `>=22` for `@typeonce/ritmo`, `-browser`, `-render`, `-pixi`, `-math`, and `-netcode`; `>=22.12` for `@typeonce/oxlint-plugin-ritmo` (oxlint's own floor); `>=22.15` for `@typeonce/ritmo-devtools` (unchanged); and `>=22.19` for `@typeonce/ritmo-tools` (what `@effect/platform-node` needs). On Node 20, upgrade Node: `nvm install 22` (or 24), or `"node": ">=22"` in your CI's setup step.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 87466e9: **Breaking: a query's `each()` returns entities, and values are read through `queries.x.data`. Matches, their `data` cells, and `entity.proof` are gone.** Iterating no longer keeps an object per entity and query, so loops over many entities run up to 3x faster, a game-shaped frame about 2x faster, and memory no longer grows with each query.
|
|
12
|
+
|
|
13
|
+
```diff
|
|
14
|
+
-for (const { data } of queries.movers.each()) {
|
|
15
|
+
- const velocity = data.velocity.get()
|
|
16
|
+
- data.position.update((position) => ({ x: position.x + velocity.x, y: position.y + velocity.y }))
|
|
17
|
+
-}
|
|
18
|
+
+const { data } = queries.movers
|
|
19
|
+
+for (const entity of queries.movers.each()) {
|
|
20
|
+
+ const velocity = data.velocity.get(entity)
|
|
21
|
+
+ data.position.update(entity, (position) => ({ x: position.x + velocity.x, y: position.y + velocity.y }))
|
|
22
|
+
+}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Every slot method takes the entity first. The fix for each old form:
|
|
26
|
+
|
|
27
|
+
| Before | After |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `match.data.x.get()` | `data.x.get(entity)` |
|
|
30
|
+
| `data.x.set(value)`, `update(f)` | `data.x.set(entity, value)`, `update(entity, f)` |
|
|
31
|
+
| `data.x.setRaw(raw)`, `updateRaw(f)` | `data.x.setRaw(entity, raw)`, `updateRaw(entity, f)` |
|
|
32
|
+
| `data.state.transition({ from, to })` | `data.state.transition(entity, { from, to })` |
|
|
33
|
+
| `data.state.update({ state, data })` | `data.state.update(entity, { state, data })` |
|
|
34
|
+
| `data.sprite?.get()` | `data.sprite.get(entity)`, `undefined` when it lacks the component |
|
|
35
|
+
| `data.note !== undefined` | `data.note.has(entity)` |
|
|
36
|
+
| `commands.despawn(match.entity)` | `commands.despawn(entity)` |
|
|
37
|
+
| `match.entity.id` | `entity.id` |
|
|
38
|
+
| `found.value.data.x.get()` after `queries.q.get(id)` | `queries.q.data.x.get(found.value)` |
|
|
39
|
+
| `QueryMatch<S, Q>` | `QueryEntity<S, Q>`, with `QueryData<Q>` for the slots |
|
|
40
|
+
| `Query.Cells<Q>` | `QueryData<Q>` |
|
|
41
|
+
| `WriteCellForDescriptor<D>` | `WriteSlotOf<D>` |
|
|
42
|
+
| `match.entity.proof.position` | `data.position.get(entity)` |
|
|
43
|
+
|
|
44
|
+
`single()`, `singleOptional()`, `get`, `getHandle`, `children`, and `descendants` return entities too. `ReadCell` and `WriteCell` remain for resources.
|
|
45
|
+
|
|
46
|
+
`Entity.EntityRef` now takes `<S, Root, Proves, Lacks, Relates>`. `Entity.EntityMut`, `Entity.ref`, and `Entity.mut` are removed: only a query produces an entity.
|
|
47
|
+
|
|
48
|
+
The type checks are the same or stricter: a read slot has no `set`, a slot rejects an id or an entity whose query does not prove its component, and entities carry their proofs to `commands`.
|
|
49
|
+
|
|
50
|
+
**Kept values changed.** `queries.x.data` kept past its run throws, as a kept match did. A kept entity no longer throws by itself: it keeps naming its entity, reading its current value, and throws once the entity no longer holds the component. It never reads another entity, since ids are never reused, but it does not re-check the query, so an entity that left through `without` stays readable. To follow an entity across runs and re-check the query, keep `entity.id` and resolve it with `queries.x.get(id)`, as before.
|
|
51
|
+
|
|
52
|
+
`RenderSync` callbacks are unchanged: `context.data.x.get()` still works. Lint messages name the new forms.
|
|
53
|
+
|
|
54
|
+
## 0.20.0
|
|
55
|
+
|
|
3
56
|
## 0.19.1
|
|
4
57
|
|
|
5
58
|
## 0.19.0
|
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ const started = performance.now()
|
|
|
69
69
|
| [`no-brand-cast`](#ritmono-brand-cast) | simulation | `raw as UserId`, `1 as Random.State` | the schema or constructor that brands it |
|
|
70
70
|
| [`handle-runtime-result`](#ritmohandle-runtime-result) | everywhere | a dropped or unchecked `runtime.tick(...)` / `restore(...)` / `rewind(...)` / `snapshot()` / `checksum()` result | check `.ok` |
|
|
71
71
|
| [`prefix-descriptor-and-system-names`](#ritmoprefix-descriptor-and-system-names) | everywhere | `"Position"`, `Game.System("Move", ...)` | `"Game/Position"` |
|
|
72
|
-
| [`no-state-spread`](#ritmono-state-spread) | everywhere | `{ ...ground, _tag: "air", vy }` | `
|
|
72
|
+
| [`no-state-spread`](#ritmono-state-spread) | everywhere | `{ ...ground, _tag: "air", vy }` | `data.state.transition(entity, { from, to, data })`, `nextMachines.x.set({ _tag, ...fields })`, or the new state's fields written out |
|
|
73
73
|
|
|
74
74
|
## Simulation rules
|
|
75
75
|
|
|
@@ -103,7 +103,7 @@ const crit = random.next() < 0.1
|
|
|
103
103
|
const kind = random.pick(kinds)
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
Catches `Math.random()`, `crypto.getRandomValues()`, and `crypto.randomUUID()`. For an id, the world already has one: use the entity's id (`
|
|
106
|
+
Catches `Math.random()`, `crypto.getRandomValues()`, and `crypto.randomUUID()`. For an id, the world already has one: use the entity's id (`entity.id`, kept as `Game.Entity.handle(...)`) or a counter in a resource. An id that must be unique across devices or runs (an account item, a save slot) is made in host code, where `crypto.randomUUID()` is fine, and passed in with `runtime.send(...)`.
|
|
107
107
|
|
|
108
108
|
### `ritmo/use-ops-for-math`
|
|
109
109
|
|
|
@@ -164,15 +164,15 @@ A timer counted down by `dt` adds a rounded float every tick, so it ends a step
|
|
|
164
164
|
|
|
165
165
|
```ts
|
|
166
166
|
cooldown.remaining -= dt // reported
|
|
167
|
-
data.buff.set({ ...buff, left: buff.left - time.dt })
|
|
167
|
+
data.buff.set(entity, { ...buff, left: buff.left - time.dt }) // reported
|
|
168
168
|
|
|
169
169
|
// instead: ready: Clock.Deadline<60> | null, its schema narrowing with Clock.isDeadline(step)
|
|
170
170
|
const cooldown = Clock.duration(step, 0.5)
|
|
171
171
|
const time = resources.time.get()
|
|
172
|
-
const { ready } = data.weapon.get()
|
|
172
|
+
const { ready } = data.weapon.get(entity)
|
|
173
173
|
if (ready === null || Clock.reached(time, ready)) {
|
|
174
174
|
fire()
|
|
175
|
-
data.weapon.set({ ready: Clock.deadline(time, cooldown) })
|
|
175
|
+
data.weapon.set(entity, { ready: Clock.deadline(time, cooldown) })
|
|
176
176
|
}
|
|
177
177
|
const bar = ready === null ? 0 : Clock.remaining(time, ready) / Clock.steps(cooldown) // a readout
|
|
178
178
|
```
|
|
@@ -184,7 +184,7 @@ const GameplayTime = Clock.resource("Game/GameplayTime", step)
|
|
|
184
184
|
const gameplayClock = Clock.system(Game, { name: "Game/GameplayClock", resource: GameplayTime, hold: [inHitStop] })
|
|
185
185
|
|
|
186
186
|
// A deadline on GameplayTime waits while inHitStop passes, and saves and rolls back like any deadline
|
|
187
|
-
data.enemy.set({ attackAt: Clock.deadline(gameplay, windup) })
|
|
187
|
+
data.enemy.set(entity, { attackAt: Clock.deadline(gameplay, windup) })
|
|
188
188
|
```
|
|
189
189
|
|
|
190
190
|
Time scaled by a fraction (a 0.3x slow motion) has no whole step to end on, so a float is right there: keep it and disable the line with the reason (`// oxlint-disable-next-line ritmo/no-float-timers -- scaled by slow motion`). A value counted up by `dt` is reported too, since it drifts the same way: `Clock.elapsed(time)` is the exact seconds of a clock.
|
|
@@ -264,7 +264,7 @@ A tagged value, such as the value of a `Descriptor.EntityState` component or of
|
|
|
264
264
|
const popped = { ...ground, _tag: "air", vy: 2 } // reported: `platform` survives in the air
|
|
265
265
|
|
|
266
266
|
// instead
|
|
267
|
-
data.contact.transition({ from: "ground", to: "air", data: { vy: 2, coyote: 0 } })
|
|
267
|
+
data.contact.transition(entity, { from: "ground", to: "air", data: { vy: 2, coyote: 0 } })
|
|
268
268
|
nextMachines.mode.set({ _tag: "Exploring" }) // a machine's move, not { ...talking, _tag: "Exploring" }
|
|
269
269
|
const popped = { _tag: "air", vy: 2, coyote: 0 } // in a pure function
|
|
270
270
|
```
|
|
@@ -16,7 +16,7 @@ export default defineRule({
|
|
|
16
16
|
url: docsUrl("no-state-spread")
|
|
17
17
|
},
|
|
18
18
|
messages: {
|
|
19
|
-
spread: "This sets `_tag` over a spread of `{{spread}}`: every field of the previous state survives at runtime, though the type of the new state hides it, so it comes back when the value is saved, compared, or spread again. Move an entity state with `
|
|
19
|
+
spread: "This sets `_tag` over a spread of `{{spread}}`: every field of the previous state survives at runtime, though the type of the new state hides it, so it comes back when the value is saved, compared, or spread again. Move an entity state with `data.state.transition(entity, { from, to, data })`, which takes the new state's fields; queue a state machine's move with the new state's fields, `nextMachines.mode.set({ _tag: \"Talking\", speaker, page: 0 })`; anywhere else, write the new state's fields out: `{ _tag: \"air\", vy, coyote }`. Spread the previous value only to change fields of the same state."
|
|
20
20
|
},
|
|
21
21
|
schema: []
|
|
22
22
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-state-spread.js","sourceRoot":"","sources":["../../src/rules/no-state-spread.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEzD,2EAA2E;AAC3E,MAAM,KAAK,GAAG,CAAC,IAAiB,EAAiC,EAAE,CACjE,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;IAChD,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,CAAA;AAEtH;;;;GAIG;AACH,eAAe,UAAU,CAAC;IACxB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,yGAAyG;YACtH,GAAG,EAAE,OAAO,CAAC,iBAAiB,CAAC;SAChC;QACD,QAAQ,EAAE;YACR,MAAM,EACJ,
|
|
1
|
+
{"version":3,"file":"no-state-spread.js","sourceRoot":"","sources":["../../src/rules/no-state-spread.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEzD,2EAA2E;AAC3E,MAAM,KAAK,GAAG,CAAC,IAAiB,EAAiC,EAAE,CACjE,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;IAChD,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,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|
|
14
14
|
messages: {
|
|
15
15
|
random: "{{call}} cannot be seeded or saved, so the run cannot replay. Draw from the world's Random resource: `const random = Random.draw(resources.rng)` (declare `rng: Game.System.writeResource(Rng)`), then `random.next()`, `random.range(min, max)`, `random.integer(min, max)`, `random.pick(items)`, or `random.shuffle(items)`.",
|
|
16
|
-
uuid: "crypto.randomUUID() cannot replay. For an id within the world, use the entity's id (`
|
|
16
|
+
uuid: "crypto.randomUUID() cannot replay. For an id within the world, use the entity's id (`entity.id`, kept as `Game.Entity.handle(...)`) or a counter in a resource. For an id unique across devices or runs (an account item, a save slot), make it in host code and pass it in with `runtime.send(...)`, so the replay records it."
|
|
17
17
|
},
|
|
18
18
|
schema: []
|
|
19
19
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-random-for-randomness.js","sourceRoot":"","sources":["../../src/rules/use-random-for-randomness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;;GAGG;AACH,eAAe,UAAU,CAAC;IACxB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,yFAAyF;YACtG,GAAG,EAAE,OAAO,CAAC,2BAA2B,CAAC;SAC1C;QACD,QAAQ,EAAE;YACR,MAAM,EACJ,iUAAiU;YACnU,IAAI,EACF,
|
|
1
|
+
{"version":3,"file":"use-random-for-randomness.js","sourceRoot":"","sources":["../../src/rules/use-random-for-randomness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;;GAGG;AACH,eAAe,UAAU,CAAC;IACxB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,yFAAyF;YACtG,GAAG,EAAE,OAAO,CAAC,2BAA2B,CAAC;SAC1C;QACD,QAAQ,EAAE;YACR,MAAM,EACJ,iUAAiU;YACnU,IAAI,EACF,iUAAiU;SACpU;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,gBAAgB,CAAC,IAAI;gBACnB,IAAI,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,QAAQ,EAAE,CAAC;oBACrD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,CAAC,CAAA;oBAC9E,OAAM;gBACR,CAAC;gBACD,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;gBACpD,IAAI,MAAM,KAAK,iBAAiB;oBAAE,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE,EAAE,CAAC,CAAA;gBAC3H,IAAI,MAAM,KAAK,YAAY;oBAAE,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAA;YAC1E,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typeonce/oxlint-plugin-ritmo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Oxlint rules for Ritmo games: deterministic, headless simulation code and checked runtime results",
|
|
5
5
|
"author": "Sandro Maglione",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"oxlint": ">=1.86.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
51
|
+
"node": ">=22.12"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "tsc -b tsconfig.json --pretty false",
|
|
@@ -22,7 +22,7 @@ export default defineRule({
|
|
|
22
22
|
},
|
|
23
23
|
messages: {
|
|
24
24
|
spread:
|
|
25
|
-
"This sets `_tag` over a spread of `{{spread}}`: every field of the previous state survives at runtime, though the type of the new state hides it, so it comes back when the value is saved, compared, or spread again. Move an entity state with `
|
|
25
|
+
"This sets `_tag` over a spread of `{{spread}}`: every field of the previous state survives at runtime, though the type of the new state hides it, so it comes back when the value is saved, compared, or spread again. Move an entity state with `data.state.transition(entity, { from, to, data })`, which takes the new state's fields; queue a state machine's move with the new state's fields, `nextMachines.mode.set({ _tag: \"Talking\", speaker, page: 0 })`; anywhere else, write the new state's fields out: `{ _tag: \"air\", vy, coyote }`. Spread the previous value only to change fields of the same state."
|
|
26
26
|
},
|
|
27
27
|
schema: []
|
|
28
28
|
},
|
|
@@ -17,7 +17,7 @@ export default defineRule({
|
|
|
17
17
|
random:
|
|
18
18
|
"{{call}} cannot be seeded or saved, so the run cannot replay. Draw from the world's Random resource: `const random = Random.draw(resources.rng)` (declare `rng: Game.System.writeResource(Rng)`), then `random.next()`, `random.range(min, max)`, `random.integer(min, max)`, `random.pick(items)`, or `random.shuffle(items)`.",
|
|
19
19
|
uuid:
|
|
20
|
-
"crypto.randomUUID() cannot replay. For an id within the world, use the entity's id (`
|
|
20
|
+
"crypto.randomUUID() cannot replay. For an id within the world, use the entity's id (`entity.id`, kept as `Game.Entity.handle(...)`) or a counter in a resource. For an id unique across devices or runs (an account item, a save slot), make it in host code and pass it in with `runtime.send(...)`, so the replay records it."
|
|
21
21
|
},
|
|
22
22
|
schema: []
|
|
23
23
|
},
|