@typeonce/oxlint-plugin-ritmo 0.12.0 → 0.14.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 +71 -0
- package/README.md +29 -7
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/rules/handle-tick-result.d.ts +3 -3
- package/dist/rules/handle-tick-result.js +8 -7
- package/dist/rules/handle-tick-result.js.map +1 -1
- package/dist/rules/keep-simulation-headless.d.ts.map +1 -1
- package/dist/rules/keep-simulation-headless.js +6 -3
- package/dist/rules/keep-simulation-headless.js.map +1 -1
- package/dist/rules/no-infinity-in-simulation-data.js +1 -1
- package/dist/rules/no-infinity-in-simulation-data.js.map +1 -1
- package/dist/rules/no-state-spread.d.ts +8 -0
- package/dist/rules/no-state-spread.d.ts.map +1 -0
- package/dist/rules/no-state-spread.js +44 -0
- package/dist/rules/no-state-spread.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +7 -3
- package/src/rules/handle-tick-result.ts +9 -7
- package/src/rules/keep-simulation-headless.ts +8 -3
- package/src/rules/no-infinity-in-simulation-data.ts +1 -1
- package/src/rules/no-state-spread.ts +47 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
# @typeonce/oxlint-plugin-ritmo
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 70d054e: **Rewind a runtime in memory, for rollback netcode and client prediction.** `runtime.checkpoint(simulate)` marks the world between ticks, and `runtime.rewind(checkpoint)` puts it back exactly: ticking `simulate` again gives the same results, bit for bit, as a runtime that never rewound (entity ids, values and their change ticks, relations, scopes, resources, machines, queued commands, unread events, and the read positions of `simulate`'s systems). See the `Checkpoint` module, and the skill's new `playbooks/netcode.md`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const history = new Map<number, Checkpoint.Checkpoint<typeof Root>>();
|
|
11
|
+
history.set(tick, runtime.checkpoint(simulate));
|
|
12
|
+
runtime.tick(simulate);
|
|
13
|
+
|
|
14
|
+
// Real input for an earlier tick differs from the guess: go back and run again.
|
|
15
|
+
const rewound = runtime.rewind(history.get(wrongTick)!);
|
|
16
|
+
if (!rewound.ok) resync(rewound.error); // Released: older than the window
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- Taking a checkpoint copies only resources, machines, and queues; the first change to a page of values, an entity, a relation, or a scope after it keeps what it replaced. The runtime keeps the last `checkpoints` (a new option of `Game.Runtime.make`, `Checkpoint.defaultWindow` = 16 by default); an older one, one newer than a checkpoint rewound to, and every one taken before a `restore` fail with `Released`. A checkpoint of another runtime fails with `OtherRuntime`.
|
|
20
|
+
- A schedule that would not rewind does not compile, and the error (`__fixCheckpoint__`) names the fix: a service that is neither an input source (`snapshot()`) nor plain data, a system with `local` state (in its state transitions too), or a schedule widened to a schedule type.
|
|
21
|
+
- Systems and inspectors outside the rewound schedule, like renderers, see a rewind as ordinary changes. An entity the rewind took away and the ticks after it brought back under the same id is seen as changed, never as despawned and spawned again, so `RenderSync` keeps its node.
|
|
22
|
+
- **`runtime.checksum()`**: a fingerprint of what `snapshot()` saves, as 16 hex digits, that does not depend on how the world was built (component order, object key order). Peers compare it to catch a desync; gated like `snapshot`, and returns a `Result`.
|
|
23
|
+
- `Schedule.Source<Data>` and `Schedule.IsPlain<T>`: the input-source shape and the plain-data check that replays and checkpoints share. `Schedule.SystemsIn` is exported.
|
|
24
|
+
|
|
25
|
+
**Devtools:**
|
|
26
|
+
|
|
27
|
+
- **Breaking: `Replay.Source` and `Replay.IsPlain` moved to core**, as `Schedule.Source` and `Schedule.IsPlain`.
|
|
28
|
+
|
|
29
|
+
```diff
|
|
30
|
+
-const Controls = Descriptor.Service<Replay.Source<Input>>()("Game/Controls")
|
|
31
|
+
+import type * as Schedule from "@typeonce/ritmo/Schedule"
|
|
32
|
+
+const Controls = Descriptor.Service<Schedule.Source<Input>>()("Game/Controls")
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- **Breaking: replay checkpoint hashes are `runtime.checksum()`.** Replays recorded with an earlier version report every checkpoint as diverged; record them again. A runtime passed to `Replay.recorder` or `Replay.session` needs `checksum`, which every runtime with `snapshot` has.
|
|
36
|
+
|
|
37
|
+
**Lint:** `handle-tick-result` also reports a dropped `runtime.rewind(...)` result: a released checkpoint changes nothing, and the ticks meant to run again would run on top of the present.
|
|
38
|
+
|
|
39
|
+
- dbfbd9d: **New package: `@typeonce/ritmo-netcode`, online multiplayer.** A session per peer exchanges inputs over a `NetworkLink` and ticks the simulation with every seat's input: `Netcode.rollback` runs at once on guesses and rolls back with the runtime's checkpoints when real input contradicts one; `Netcode.lockstep` waits for every seat. Seat 0 starts the match and every resync from one save that every peer restores at the same tick; `session.rate` slows the peer that runs ahead; peers compare checksums of confirmed ticks, and a mismatch stops the session with `Desynced` until `resync()`.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const seats = Netcode.seats(PlayerInput, { count: 2, idle }) // the simulation's input source
|
|
43
|
+
const session = Netcode.rollback(runtime, { simulate, seats: seats.value, seat, links: [WebSocketNetworkLink.make(socket)], hostClock, step })
|
|
44
|
+
FixedLoop.start({ ..., rate: session.value.rate, update: session.value.update({ input: readInput, onHalted: report }) })
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- Transports: `WebSocketNetworkLink.make(socket)` (a relay; the browser's, Node's, Deno's, or Bun's WebSocket), `WebRtcNetworkLink.make(channel)` (between peers), `MemoryNetworkLink.make(...)` (seeded latency, jitter, and loss, for headless tests), or any `{ send, receive, status }`.
|
|
48
|
+
- What does not compile: a rollback simulation that cannot be rewound, one whose requirements the runtime does not provide, and a runtime that cannot save. What fails at construction, as a typed `Result`: a seat out of range, seats another session took or the runtime does not provide, and a `maxRollback` beyond the checkpoints the runtime keeps.
|
|
49
|
+
- The skill's `playbooks/netcode.md` now drives the package instead of a hand-written loop.
|
|
50
|
+
|
|
51
|
+
**Core:**
|
|
52
|
+
|
|
53
|
+
- `FixedLoop.start` takes `rate`, read once per frame, within `FixedLoop.rateRange` (0.9 to 1.1): how fast host time runs into the accumulator, for a networked session's pacing. A value outside the range stops the loop with an `InvalidRate` failure, a new member of `FixedLoop.Failure`.
|
|
54
|
+
- **`runtime.restore` sets the next entity id to the save's**, where it used to keep the higher of the save's and the runtime's own. The same save restored in two runtimes now allocates the same ids afterwards, whatever each held before; peers of a networked game need it. A handle kept from before a restore may now name an entity spawned after it: drop handles across a restore, as their ids could already name restored entities.
|
|
55
|
+
|
|
56
|
+
**Lint:** `keep-simulation-headless` reports `WebSocket`, `RTCPeerConnection`, and `RTCDataChannel` with their own message: online play runs the simulation under a netcode session, and remote input goes through `Netcode.seats`, never `runtime.send(...)`.
|
|
57
|
+
|
|
58
|
+
**Devtools:** `Desync.compare(mine, theirs)` lists every difference between two saves of a tick, entities by id and values by path: the report for a `Desynced` session made with `keepSnapshots: true`.
|
|
59
|
+
|
|
60
|
+
## 0.13.0
|
|
61
|
+
|
|
62
|
+
### Minor Changes
|
|
63
|
+
|
|
64
|
+
- 791b52a: **`ritmo/no-state-spread`** reports `_tag` set over a spread of the previous state, such as `{ ...ground, _tag: "air", vy: 2 }`: the old state's fields survive at runtime while the new state's type hides them. Move an entity state with `cell.transition({ from, to, data })`, queue a state machine's move with the new state's fields (`nextMachines.x.set({ _tag, ...fields })`), or write the new state's fields out. Spreads that change fields of the same state are not reported. Turn it on for every file:
|
|
65
|
+
|
|
66
|
+
```jsonc
|
|
67
|
+
"ritmo/no-state-spread": "error"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- 835f6ba: `ritmo/no-infinity-in-simulation-data` no longer names `Decode`: its fix is a nullable number schema from the game's schema library.
|
|
73
|
+
|
|
3
74
|
## 0.12.0
|
|
4
75
|
|
|
5
76
|
## 0.11.0
|
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ Ritmo's types reject wrong calls, and its devtools lints reject wrong runs. Thes
|
|
|
6
6
|
|
|
7
7
|
- simulation code that reads the wall clock, `Math.random`, engine-dependent math, or the page;
|
|
8
8
|
- data that cannot be saved;
|
|
9
|
+
- state values that keep a previous state's fields;
|
|
9
10
|
- runtime results that are dropped.
|
|
10
11
|
|
|
11
12
|
Every report says what goes wrong and which Ritmo API to use instead.
|
|
@@ -26,7 +27,8 @@ Register the plugin and turn the rules on in `.oxlintrc.json`. The simulation ru
|
|
|
26
27
|
"rules": {
|
|
27
28
|
"ritmo/handle-tick-result": "error",
|
|
28
29
|
"ritmo/prefix-descriptor-and-system-names": "error",
|
|
29
|
-
"ritmo/use-cell-value": "error"
|
|
30
|
+
"ritmo/use-cell-value": "error",
|
|
31
|
+
"ritmo/no-state-spread": "error"
|
|
30
32
|
},
|
|
31
33
|
"overrides": [
|
|
32
34
|
{
|
|
@@ -60,9 +62,10 @@ const started = performance.now()
|
|
|
60
62
|
| [`use-ops-for-math`](#ritmouse-ops-for-math) | simulation | `Math.sin`, `Math.hypot`, `a ** b`, ... | `Ops` |
|
|
61
63
|
| [`keep-simulation-headless`](#ritmokeep-simulation-headless) | simulation | page globals, host I/O, renderer imports | input and data from the host, drawing in a render schedule |
|
|
62
64
|
| [`no-infinity-in-simulation-data`](#ritmono-infinity-in-simulation-data) | simulation | `Infinity` / `NaN` in object literals | `null` |
|
|
63
|
-
| [`handle-tick-result`](#ritmohandle-tick-result) | everywhere | a dropped `runtime.tick(...)` / `restore(...)` result | check `.ok` |
|
|
65
|
+
| [`handle-tick-result`](#ritmohandle-tick-result) | everywhere | a dropped `runtime.tick(...)` / `restore(...)` / `rewind(...)` result | check `.ok` |
|
|
64
66
|
| [`prefix-descriptor-and-system-names`](#ritmoprefix-descriptor-and-system-names) | everywhere | `"Position"`, `Game.System("Move", ...)` | `"Game/Position"` |
|
|
65
67
|
| [`use-cell-value`](#ritmouse-cell-value) | everywhere | `cell.present ? cell.get() : undefined` | `cell.value()` |
|
|
68
|
+
| [`no-state-spread`](#ritmono-state-spread) | everywhere | `{ ...ground, _tag: "air", vy }` | `cell.transition({ from, to, data })`, `nextMachines.x.set({ _tag, ...fields })`, or the new state's fields written out |
|
|
66
69
|
|
|
67
70
|
## Simulation rules
|
|
68
71
|
|
|
@@ -121,7 +124,8 @@ The simulation runs in tests, bots, replays, and on servers, where there is no p
|
|
|
121
124
|
| Reported | Setup instead |
|
|
122
125
|
|---|---|
|
|
123
126
|
| Page globals: `window`, `document`, `navigator`, `matchMedia`, ... | Capture input in the host with `Keyboard`, `Gamepad`, `Pointer`, or `Touch` (merged with `Controls`) from `@typeonce/ritmo-browser` and `InputCapture` into a resource that systems read. Pass page state (size, settings) in with `runtime.send(...)` or a resource. |
|
|
124
|
-
| Host I/O: `localStorage`, `fetch`, `
|
|
127
|
+
| Host I/O: `localStorage`, `fetch`, `location`, ... | Do the I/O in host code and pass the result in with `runtime.send(...)` or a resource. Save and load the world in the host with `runtime.snapshot()` and `runtime.restore(...)`. |
|
|
128
|
+
| Connections to other peers: `WebSocket`, `RTCPeerConnection`, `RTCDataChannel` | For online play, run the simulation under a [`@typeonce/ritmo-netcode`](https://github.com/typeonce-dev/ritmo/blob/main/packages/netcode/README.md) session: host code opens the connection and wraps it in a link, and remote input reaches the simulation through `Netcode.seats`, never `runtime.send(...)`. |
|
|
125
129
|
| Renderer and UI imports, types included: `pixi.js`, `three`, `@typeonce/ritmo-render`, `react`, `preact`, ... | Draw from a render schedule in render code: mirror entities into nodes with `RenderSync` and a `NodeRegistry` from `@typeonce/ritmo-render`, and declare renderer services (a node registry) and their types there; renderer nodes stay in the registry, never in components. The schema and simulation systems name no renderer type, so another renderer can replace this one. |
|
|
126
130
|
|
|
127
131
|
Locals and fields with these names (`term.window`, a `location` parameter) are not globals and are not reported.
|
|
@@ -130,14 +134,14 @@ Options: `{ "packages": ["@my-game/canvas"] }` adds the game's own renderer or U
|
|
|
130
134
|
|
|
131
135
|
### `ritmo/no-infinity-in-simulation-data`
|
|
132
136
|
|
|
133
|
-
`JSON.stringify` turns `Infinity` and `NaN` into `null`, and
|
|
137
|
+
`JSON.stringify` turns `Infinity` and `NaN` into `null`, and a number schema rejects `null`, so a world holding them saves but no longer loads (devtools also warns `non-finite-value`).
|
|
134
138
|
|
|
135
139
|
```ts
|
|
136
140
|
dash: { remaining: 0, since: Infinity } // reported
|
|
137
141
|
{ remaining: Infinity, duration: Infinity, permanent: true } // reported
|
|
138
142
|
|
|
139
143
|
// instead
|
|
140
|
-
dash: { remaining: 0, since: null } // since: number | null,
|
|
144
|
+
dash: { remaining: 0, since: null } // since: number | null, with a nullable number schema
|
|
141
145
|
{ timer: null } // timer: { remaining: number; duration: number } | null
|
|
142
146
|
```
|
|
143
147
|
|
|
@@ -147,21 +151,24 @@ Catches `Infinity`, `-Infinity`, `NaN`, and `Number.POSITIVE_INFINITY` / `NEGATI
|
|
|
147
151
|
|
|
148
152
|
### `ritmo/handle-tick-result`
|
|
149
153
|
|
|
150
|
-
`runtime.tick(...)` returns a `Result`: a system that fails stops the tick, and the failure comes back here. `runtime.restore(...)` returns one too: an invalid save leaves the previous world in place. Dropping
|
|
154
|
+
`runtime.tick(...)` returns a `Result`: a system that fails stops the tick, and the failure comes back here. `runtime.restore(...)` returns one too: an invalid save leaves the previous world in place. So does `runtime.rewind(...)`: a checkpoint the runtime let go of changes nothing, and the ticks meant to run again run on top of the present. Dropping any of them hides the failure.
|
|
151
155
|
|
|
152
156
|
```ts
|
|
153
157
|
runtime.tick(update) // reported
|
|
154
158
|
runtime.restore(save) // reported
|
|
159
|
+
runtime.rewind(checkpoint) // reported
|
|
155
160
|
|
|
156
161
|
// instead
|
|
157
162
|
const ran = runtime.tick(update)
|
|
158
163
|
if (!ran.ok) console.error(ran.error) // names the system and why
|
|
159
164
|
const restored = runtime.restore(save)
|
|
160
165
|
if (!restored.ok) showLoadError(restored.error)
|
|
166
|
+
const rewound = runtime.rewind(checkpoint)
|
|
167
|
+
if (!rewound.ok) resync(rewound.error) // Released or OtherRuntime
|
|
161
168
|
void runtime.tick(render) // ignored on purpose
|
|
162
169
|
```
|
|
163
170
|
|
|
164
|
-
Catches `tick(...)`, `tryTick(...)`, and `
|
|
171
|
+
Catches `tick(...)`, `tryTick(...)`, `restore(...)`, and `rewind(...)` used as a statement on a receiver named like a runtime (`runtime`, `game.runtime`, `worldRuntime`). Game wrappers with other names (`town.restore(...)`) are not reported. Option: `{ "runtimePattern": "^(runtime|world)$" }` (a case-insensitive regular expression for the receiver's name; default `runtime$`).
|
|
165
172
|
|
|
166
173
|
### `ritmo/prefix-descriptor-and-system-names`
|
|
167
174
|
|
|
@@ -189,4 +196,19 @@ const dash = target.data.dash.value()
|
|
|
189
196
|
|
|
190
197
|
Check `cell.present` alone to branch without reading.
|
|
191
198
|
|
|
199
|
+
### `ritmo/no-state-spread`
|
|
200
|
+
|
|
201
|
+
A tagged value, such as the value of a `Descriptor.EntityState` component or of a `Game.StateMachine`, changes state with the new state's own fields. Setting `_tag` over a spread of the previous state keeps every field of that state at runtime, while the new state's type hides them: they come back when the value is saved, compared, or spread again.
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
const popped = { ...ground, _tag: "air", vy: 2 } // reported: `platform` survives in the air
|
|
205
|
+
|
|
206
|
+
// instead
|
|
207
|
+
data.contact.transition({ from: "ground", to: "air", data: { vy: 2, coyote: 0 } })
|
|
208
|
+
nextMachines.mode.set({ _tag: "Exploring" }) // a machine's move, not { ...talking, _tag: "Exploring" }
|
|
209
|
+
const popped = { _tag: "air", vy: 2, coyote: 0 } // in a pure function
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Spreading the previous value to change fields of the same state (`{ ...air, vy: air.vy - 1 }`) is not reported, nor is a `_tag` written before the spread (`{ _tag: to, ...data }`).
|
|
213
|
+
|
|
192
214
|
Source: https://github.com/typeonce-dev/ritmo
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Types catch wrong calls and devtools catch wrong runs; these rules catch
|
|
5
5
|
* the source patterns neither can see: simulation code that reads the wall
|
|
6
6
|
* clock, `Math.random`, engine-dependent math, or the page, data that cannot
|
|
7
|
-
* be saved,
|
|
7
|
+
* be saved, state values that keep a previous state's fields, and runtime
|
|
8
|
+
* results that are dropped. Every report names the
|
|
8
9
|
* Ritmo API to use instead.
|
|
9
10
|
*
|
|
10
11
|
* Register the plugin in `.oxlintrc.json` with `"jsPlugins":
|
|
@@ -17,7 +18,8 @@
|
|
|
17
18
|
* `ritmo/use-random-for-randomness`, `ritmo/use-ops-for-math`,
|
|
18
19
|
* `ritmo/keep-simulation-headless`, `ritmo/no-infinity-in-simulation-data`.
|
|
19
20
|
* - Every file: `ritmo/handle-tick-result`,
|
|
20
|
-
* `ritmo/prefix-descriptor-and-system-names`, `ritmo/use-cell-value
|
|
21
|
+
* `ritmo/prefix-descriptor-and-system-names`, `ritmo/use-cell-value`,
|
|
22
|
+
* `ritmo/no-state-spread`.
|
|
21
23
|
*
|
|
22
24
|
* @module oxlint-plugin-ritmo
|
|
23
25
|
*/
|
|
@@ -25,6 +27,7 @@ import { definePlugin } from "@oxlint/plugins";
|
|
|
25
27
|
import handleTickResult from "./rules/handle-tick-result.js";
|
|
26
28
|
import keepSimulationHeadless from "./rules/keep-simulation-headless.js";
|
|
27
29
|
import noInfinityInSimulationData from "./rules/no-infinity-in-simulation-data.js";
|
|
30
|
+
import noStateSpread from "./rules/no-state-spread.js";
|
|
28
31
|
import prefixDescriptorAndSystemNames from "./rules/prefix-descriptor-and-system-names.js";
|
|
29
32
|
import useCellValue from "./rules/use-cell-value.js";
|
|
30
33
|
import useClockForTime from "./rules/use-clock-for-time.js";
|
|
@@ -40,7 +43,8 @@ export default definePlugin({
|
|
|
40
43
|
"no-infinity-in-simulation-data": noInfinityInSimulationData,
|
|
41
44
|
"handle-tick-result": handleTickResult,
|
|
42
45
|
"prefix-descriptor-and-system-names": prefixDescriptorAndSystemNames,
|
|
43
|
-
"use-cell-value": useCellValue
|
|
46
|
+
"use-cell-value": useCellValue,
|
|
47
|
+
"no-state-spread": noStateSpread
|
|
44
48
|
}
|
|
45
49
|
});
|
|
46
50
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,gBAAgB,MAAM,+BAA+B,CAAA;AAC5D,OAAO,sBAAsB,MAAM,qCAAqC,CAAA;AACxE,OAAO,0BAA0B,MAAM,2CAA2C,CAAA;AAClF,OAAO,aAAa,MAAM,4BAA4B,CAAA;AACtD,OAAO,8BAA8B,MAAM,+CAA+C,CAAA;AAC1F,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAC3D,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,sBAAsB,MAAM,sCAAsC,CAAA;AAEzE,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;IACvB,KAAK,EAAE;QACL,oBAAoB,EAAE,eAAe;QACrC,2BAA2B,EAAE,sBAAsB;QACnD,kBAAkB,EAAE,aAAa;QACjC,0BAA0B,EAAE,sBAAsB;QAClD,gCAAgC,EAAE,0BAA0B;QAC5D,oBAAoB,EAAE,gBAAgB;QACtC,oCAAoC,EAAE,8BAA8B;QACpE,gBAAgB,EAAE,YAAY;QAC9B,iBAAiB,EAAE,aAAa;KACjC;CACF,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The result of `runtime.tick(...)`, `tryTick(...)`,
|
|
3
|
-
* failed system
|
|
4
|
-
* the failure.
|
|
2
|
+
* The result of `runtime.tick(...)`, `tryTick(...)`, `restore(...)`, and
|
|
3
|
+
* `rewind(...)` is read: a failed system, an invalid save, or a released
|
|
4
|
+
* checkpoint comes back as data, and dropping it hides the failure.
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: import("@oxlint/plugins").Rule;
|
|
7
7
|
export default _default;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { defineRule } from "@oxlint/plugins";
|
|
2
2
|
import { calledMethod, docsUrl, receiverName } from "../internal/ast.js";
|
|
3
3
|
/**
|
|
4
|
-
* The result of `runtime.tick(...)`, `tryTick(...)`,
|
|
5
|
-
* failed system
|
|
6
|
-
* the failure.
|
|
4
|
+
* The result of `runtime.tick(...)`, `tryTick(...)`, `restore(...)`, and
|
|
5
|
+
* `rewind(...)` is read: a failed system, an invalid save, or a released
|
|
6
|
+
* checkpoint comes back as data, and dropping it hides the failure.
|
|
7
7
|
*/
|
|
8
8
|
export default defineRule({
|
|
9
9
|
meta: {
|
|
10
10
|
type: "problem",
|
|
11
11
|
docs: {
|
|
12
|
-
description: "Check the Result of runtime.tick(...), tryTick(...), and
|
|
12
|
+
description: "Check the Result of runtime.tick(...), tryTick(...), restore(...), and rewind(...) instead of dropping it.",
|
|
13
13
|
url: docsUrl("handle-tick-result")
|
|
14
14
|
},
|
|
15
15
|
messages: {
|
|
16
16
|
tick: "The result of `{{call}}(...)` is dropped. A system that fails stops the tick and returns the failure here, so it goes unnoticed and the world is left half-updated. Check it: `const ran = {{call}}(...); if (!ran.ok) ...` (`ran.error` names the system and why). Write `void {{call}}(...)` to ignore it on purpose.",
|
|
17
|
-
restore: "The result of `{{call}}(...)` is dropped. A save that fails to load leaves the previous world in place, unnoticed. Check it: `const restored = {{call}}(data); if (!restored.ok) ...` (`restored.error` says what was invalid). Write `void {{call}}(...)` to ignore it on purpose."
|
|
17
|
+
restore: "The result of `{{call}}(...)` is dropped. A save that fails to load leaves the previous world in place, unnoticed. Check it: `const restored = {{call}}(data); if (!restored.ok) ...` (`restored.error` says what was invalid). Write `void {{call}}(...)` to ignore it on purpose.",
|
|
18
|
+
rewind: "The result of `{{call}}(...)` is dropped. A checkpoint the runtime let go of (older than its window, or taken before a rewind to an older one or a restore) changes nothing, so the ticks run next are run on top of the present instead of again, unnoticed. Check it: `const rewound = {{call}}(checkpoint); if (!rewound.ok) ...` (`rewound.error` says why), and resynchronize, for example by loading a peer's save. Write `void {{call}}(...)` to ignore it on purpose."
|
|
18
19
|
},
|
|
19
20
|
schema: [
|
|
20
21
|
{
|
|
@@ -38,14 +39,14 @@ export default defineRule({
|
|
|
38
39
|
if (call.type !== "CallExpression" || call.callee.type !== "MemberExpression" || call.arguments.length === 0)
|
|
39
40
|
return;
|
|
40
41
|
const method = calledMethod(call);
|
|
41
|
-
if (method !== "tick" && method !== "tryTick" && method !== "restore")
|
|
42
|
+
if (method !== "tick" && method !== "tryTick" && method !== "restore" && method !== "rewind")
|
|
42
43
|
return;
|
|
43
44
|
const receiver = receiverName(call.callee.object);
|
|
44
45
|
if (receiver === undefined || !runtime.test(receiver))
|
|
45
46
|
return;
|
|
46
47
|
context.report({
|
|
47
48
|
node,
|
|
48
|
-
messageId: method === "restore"
|
|
49
|
+
messageId: method === "restore" || method === "rewind" ? method : "tick",
|
|
49
50
|
data: { call: context.sourceCode.getText(call.callee) }
|
|
50
51
|
});
|
|
51
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-tick-result.js","sourceRoot":"","sources":["../../src/rules/handle-tick-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAMxE;;;;GAIG;AACH,eAAe,UAAU,CAAC;IACxB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAA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MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,QAAQ;oBAAE,OAAM;gBACpG,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;gBACjD,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;oBAAE,OAAM;gBAC7D,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;oBACxE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;iBACxD,CAAC,CAAA;YACJ,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keep-simulation-headless.d.ts","sourceRoot":"","sources":["../../src/rules/keep-simulation-headless.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keep-simulation-headless.d.ts","sourceRoot":"","sources":["../../src/rules/keep-simulation-headless.ts"],"names":[],"mappings":"AAgCA;;;;;GAKG"}
|
|
@@ -5,10 +5,12 @@ const page = new Set([
|
|
|
5
5
|
"window", "document", "navigator", "screen", "matchMedia", "getComputedStyle", "devicePixelRatio",
|
|
6
6
|
"innerWidth", "innerHeight", "addEventListener", "removeEventListener", "alert", "confirm", "prompt"
|
|
7
7
|
]);
|
|
8
|
-
/** Globals that do host I/O: storage,
|
|
8
|
+
/** Globals that do host I/O: storage, requests, navigation. */
|
|
9
9
|
const io = new Set([
|
|
10
|
-
"localStorage", "sessionStorage", "indexedDB", "caches", "fetch", "XMLHttpRequest", "
|
|
10
|
+
"localStorage", "sessionStorage", "indexedDB", "caches", "fetch", "XMLHttpRequest", "EventSource", "location", "history"
|
|
11
11
|
]);
|
|
12
|
+
/** Globals that connect to other peers: what online play goes through a netcode session for. */
|
|
13
|
+
const network = new Set(["WebSocket", "RTCPeerConnection", "RTCDataChannel"]);
|
|
12
14
|
/** Renderer and UI packages, by exact name. */
|
|
13
15
|
const renderers = new Set([
|
|
14
16
|
"@typeonce/ritmo-render", "@typeonce/ritmo-pixi", "pixi.js", "three", "react", "react-dom", "preact",
|
|
@@ -32,6 +34,7 @@ export default defineRule({
|
|
|
32
34
|
messages: {
|
|
33
35
|
page: "`{{name}}` is the page, which tests, bots, and replays do not have. Capture input in the host with `Keyboard`, `Pointer`, or `Touch` from `@typeonce/ritmo-browser` and `InputCapture` into a resource, and read that resource in systems. Pass other page state (size, settings) in from host code with `runtime.send(...)` or a resource.",
|
|
34
36
|
io: "`{{name}}` is host I/O, which tests, bots, and replays do not have and cannot reproduce. Do the I/O in host code and pass the result in with `runtime.send(...)` or a resource; save and load the world in host code with `runtime.snapshot()` and `runtime.restore(...)`.",
|
|
37
|
+
network: "`{{name}}` is a connection to other peers, which tests, bots, and replays do not have. For other players' input, run the simulation under a session of `@typeonce/ritmo-netcode` (`Netcode.rollback` or `Netcode.lockstep`): host code opens the connection and wraps it in a link (`WebSocketNetworkLink`, `WebRtcNetworkLink`), and remote input reaches the simulation through `Netcode.seats`, never `runtime.send(...)`, which a rollback would read on the wrong tick.",
|
|
35
38
|
renderer: "The simulation imports `{{source}}`, a renderer or UI package, so it no longer runs headless. Draw from a render schedule in render code: mirror entities into nodes with `RenderSync` and a `NodeRegistry` from `@typeonce/ritmo-render`, and declare its services (a node registry) there. Renderer nodes stay in the registry, never in components.",
|
|
36
39
|
rendererType: "The simulation names a type from `{{source}}`, a renderer or UI package, so it is tied to that renderer and another one cannot replace it. Declare renderer services (a node registry) and their types in render code; services are not registered in the schema. Renderer nodes stay in the registry, never in components."
|
|
37
40
|
},
|
|
@@ -74,7 +77,7 @@ export default defineRule({
|
|
|
74
77
|
checkSource(node, stringValue(node.source));
|
|
75
78
|
},
|
|
76
79
|
Identifier(node) {
|
|
77
|
-
const kind = page.has(node.name) ? "page" : io.has(node.name) ? "io" : undefined;
|
|
80
|
+
const kind = page.has(node.name) ? "page" : io.has(node.name) ? "io" : network.has(node.name) ? "network" : undefined;
|
|
78
81
|
if (kind === undefined)
|
|
79
82
|
return;
|
|
80
83
|
// `typeof window` in a type runs nothing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keep-simulation-headless.js","sourceRoot":"","sources":["../../src/rules/keep-simulation-headless.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAE9F,mDAAmD;AACnD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC;IACnB,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB;IACjG,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ;CACrG,CAAC,CAAA;AAEF
|
|
1
|
+
{"version":3,"file":"keep-simulation-headless.js","sourceRoot":"","sources":["../../src/rules/keep-simulation-headless.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAE9F,mDAAmD;AACnD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC;IACnB,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB;IACjG,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,OAAO,EAAE,SAAS,EAAE,QAA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,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -24,7 +24,7 @@ export default defineRule({
|
|
|
24
24
|
url: docsUrl("no-infinity-in-simulation-data")
|
|
25
25
|
},
|
|
26
26
|
messages: {
|
|
27
|
-
nonFinite: "`{{key}}: {{value}}` cannot be saved: JSON turns it into null and
|
|
27
|
+
nonFinite: "`{{key}}: {{value}}` cannot be saved: JSON turns it into null and a number schema rejects it, so the save no longer loads (and devtools warns `non-finite-value`). Use `null` for \"never\" or \"no limit\": type the field `number | null` and give it a nullable number schema. For a value that only some entities have (a timer on a non-permanent pool), make that part optional: `timer: { remaining: number; duration: number } | null`."
|
|
28
28
|
},
|
|
29
29
|
schema: []
|
|
30
30
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-infinity-in-simulation-data.js","sourceRoot":"","sources":["../../src/rules/no-infinity-in-simulation-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAE9E,8EAA8E;AAC9E,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,IAAiB,EAAW,EAAE;IACjE,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,GAAG,IAAI,IAAI,CAAC,QAAQ,KAAK,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;IACjI,IAAI,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC1G,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,Q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,KAAK,CAAA;IACvF,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;;GAGG;AACH,eAAe,UAAU,CAAC;IACxB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,yEAAyE;YACtF,GAAG,EAAE,OAAO,CAAC,gCAAgC,CAAC;SAC/C;QACD,QAAQ,EAAE;YACR,SAAS,EACP,ibAAib;SACpb;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,QAAQ,CAAC,IAAI;gBACX,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC;oBAAE,OAAM;gBACnE,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,WAAW;oBACtB,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;iBACnG,CAAC,CAAA;YACJ,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tagged value changes state by writing the new state's fields, never by
|
|
3
|
+
* re-tagging a spread of the old one: the old state's fields would survive at
|
|
4
|
+
* runtime while the type hides them.
|
|
5
|
+
*/
|
|
6
|
+
declare const _default: import("@oxlint/plugins").Rule;
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=no-state-spread.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-state-spread.d.ts","sourceRoot":"","sources":["../../src/rules/no-state-spread.ts"],"names":[],"mappings":"AAUA;;;;GAIG"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
import { docsUrl, stringValue } from "../internal/ast.js";
|
|
3
|
+
/** The `_tag` property of an object literal, if it has one written out. */
|
|
4
|
+
const isTag = (node) => node.type === "Property" && node.kind === "init" &&
|
|
5
|
+
((!node.computed && node.key.type === "Identifier" && node.key.name === "_tag") || stringValue(node.key) === "_tag");
|
|
6
|
+
/**
|
|
7
|
+
* A tagged value changes state by writing the new state's fields, never by
|
|
8
|
+
* re-tagging a spread of the old one: the old state's fields would survive at
|
|
9
|
+
* runtime while the type hides them.
|
|
10
|
+
*/
|
|
11
|
+
export default defineRule({
|
|
12
|
+
meta: {
|
|
13
|
+
type: "problem",
|
|
14
|
+
docs: {
|
|
15
|
+
description: "Build a new state's value from its own fields, not by spreading the previous state and changing `_tag`.",
|
|
16
|
+
url: docsUrl("no-state-spread")
|
|
17
|
+
},
|
|
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 `cell.transition({ 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
|
+
},
|
|
21
|
+
schema: []
|
|
22
|
+
},
|
|
23
|
+
create(context) {
|
|
24
|
+
const text = (node) => context.sourceCode.getText(node);
|
|
25
|
+
return {
|
|
26
|
+
ObjectExpression(node) {
|
|
27
|
+
let spread;
|
|
28
|
+
for (const property of node.properties) {
|
|
29
|
+
if (property.type === "SpreadElement") {
|
|
30
|
+
spread = property;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (spread === undefined || !isTag(property))
|
|
34
|
+
continue;
|
|
35
|
+
// `{ ...value, _tag: value._tag }` keeps the state it spreads.
|
|
36
|
+
if (text(property.value) === `${text(spread.argument)}._tag`)
|
|
37
|
+
continue;
|
|
38
|
+
context.report({ node: property, messageId: "spread", data: { spread: text(spread.argument) } });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=no-state-spread.js.map
|
|
@@ -0,0 +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,8kBAA8kB;SACjlB;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,MAAM,IAAI,GAAG,CAAC,IAAiB,EAAU,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC5E,OAAO;YACL,gBAAgB,CAAC,IAAI;gBACnB,IAAI,MAAwC,CAAA;gBAC5C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACvC,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;wBACtC,MAAM,GAAG,QAAQ,CAAA;wBACjB,SAAQ;oBACV,CAAC;oBACD,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;wBAAE,SAAQ;oBACtD,+DAA+D;oBAC/D,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO;wBAAE,SAAQ;oBACtE,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAA;gBAClG,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Types catch wrong calls and devtools catch wrong runs; these rules catch
|
|
5
5
|
* the source patterns neither can see: simulation code that reads the wall
|
|
6
6
|
* clock, `Math.random`, engine-dependent math, or the page, data that cannot
|
|
7
|
-
* be saved,
|
|
7
|
+
* be saved, state values that keep a previous state's fields, and runtime
|
|
8
|
+
* results that are dropped. Every report names the
|
|
8
9
|
* Ritmo API to use instead.
|
|
9
10
|
*
|
|
10
11
|
* Register the plugin in `.oxlintrc.json` with `"jsPlugins":
|
|
@@ -17,7 +18,8 @@
|
|
|
17
18
|
* `ritmo/use-random-for-randomness`, `ritmo/use-ops-for-math`,
|
|
18
19
|
* `ritmo/keep-simulation-headless`, `ritmo/no-infinity-in-simulation-data`.
|
|
19
20
|
* - Every file: `ritmo/handle-tick-result`,
|
|
20
|
-
* `ritmo/prefix-descriptor-and-system-names`, `ritmo/use-cell-value
|
|
21
|
+
* `ritmo/prefix-descriptor-and-system-names`, `ritmo/use-cell-value`,
|
|
22
|
+
* `ritmo/no-state-spread`.
|
|
21
23
|
*
|
|
22
24
|
* @module oxlint-plugin-ritmo
|
|
23
25
|
*/
|
|
@@ -26,6 +28,7 @@ import { definePlugin } from "@oxlint/plugins"
|
|
|
26
28
|
import handleTickResult from "./rules/handle-tick-result.ts"
|
|
27
29
|
import keepSimulationHeadless from "./rules/keep-simulation-headless.ts"
|
|
28
30
|
import noInfinityInSimulationData from "./rules/no-infinity-in-simulation-data.ts"
|
|
31
|
+
import noStateSpread from "./rules/no-state-spread.ts"
|
|
29
32
|
import prefixDescriptorAndSystemNames from "./rules/prefix-descriptor-and-system-names.ts"
|
|
30
33
|
import useCellValue from "./rules/use-cell-value.ts"
|
|
31
34
|
import useClockForTime from "./rules/use-clock-for-time.ts"
|
|
@@ -42,6 +45,7 @@ export default definePlugin({
|
|
|
42
45
|
"no-infinity-in-simulation-data": noInfinityInSimulationData,
|
|
43
46
|
"handle-tick-result": handleTickResult,
|
|
44
47
|
"prefix-descriptor-and-system-names": prefixDescriptorAndSystemNames,
|
|
45
|
-
"use-cell-value": useCellValue
|
|
48
|
+
"use-cell-value": useCellValue,
|
|
49
|
+
"no-state-spread": noStateSpread
|
|
46
50
|
}
|
|
47
51
|
})
|
|
@@ -7,22 +7,24 @@ interface Options {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* The result of `runtime.tick(...)`, `tryTick(...)`,
|
|
11
|
-
* failed system
|
|
12
|
-
* the failure.
|
|
10
|
+
* The result of `runtime.tick(...)`, `tryTick(...)`, `restore(...)`, and
|
|
11
|
+
* `rewind(...)` is read: a failed system, an invalid save, or a released
|
|
12
|
+
* checkpoint comes back as data, and dropping it hides the failure.
|
|
13
13
|
*/
|
|
14
14
|
export default defineRule({
|
|
15
15
|
meta: {
|
|
16
16
|
type: "problem",
|
|
17
17
|
docs: {
|
|
18
|
-
description: "Check the Result of runtime.tick(...), tryTick(...), and
|
|
18
|
+
description: "Check the Result of runtime.tick(...), tryTick(...), restore(...), and rewind(...) instead of dropping it.",
|
|
19
19
|
url: docsUrl("handle-tick-result")
|
|
20
20
|
},
|
|
21
21
|
messages: {
|
|
22
22
|
tick:
|
|
23
23
|
"The result of `{{call}}(...)` is dropped. A system that fails stops the tick and returns the failure here, so it goes unnoticed and the world is left half-updated. Check it: `const ran = {{call}}(...); if (!ran.ok) ...` (`ran.error` names the system and why). Write `void {{call}}(...)` to ignore it on purpose.",
|
|
24
24
|
restore:
|
|
25
|
-
"The result of `{{call}}(...)` is dropped. A save that fails to load leaves the previous world in place, unnoticed. Check it: `const restored = {{call}}(data); if (!restored.ok) ...` (`restored.error` says what was invalid). Write `void {{call}}(...)` to ignore it on purpose."
|
|
25
|
+
"The result of `{{call}}(...)` is dropped. A save that fails to load leaves the previous world in place, unnoticed. Check it: `const restored = {{call}}(data); if (!restored.ok) ...` (`restored.error` says what was invalid). Write `void {{call}}(...)` to ignore it on purpose.",
|
|
26
|
+
rewind:
|
|
27
|
+
"The result of `{{call}}(...)` is dropped. A checkpoint the runtime let go of (older than its window, or taken before a rewind to an older one or a restore) changes nothing, so the ticks run next are run on top of the present instead of again, unnoticed. Check it: `const rewound = {{call}}(checkpoint); if (!rewound.ok) ...` (`rewound.error` says why), and resynchronize, for example by loading a peer's save. Write `void {{call}}(...)` to ignore it on purpose."
|
|
26
28
|
},
|
|
27
29
|
schema: [
|
|
28
30
|
{
|
|
@@ -45,12 +47,12 @@ export default defineRule({
|
|
|
45
47
|
const call = node.expression
|
|
46
48
|
if (call.type !== "CallExpression" || call.callee.type !== "MemberExpression" || call.arguments.length === 0) return
|
|
47
49
|
const method = calledMethod(call)
|
|
48
|
-
if (method !== "tick" && method !== "tryTick" && method !== "restore") return
|
|
50
|
+
if (method !== "tick" && method !== "tryTick" && method !== "restore" && method !== "rewind") return
|
|
49
51
|
const receiver = receiverName(call.callee.object)
|
|
50
52
|
if (receiver === undefined || !runtime.test(receiver)) return
|
|
51
53
|
context.report({
|
|
52
54
|
node,
|
|
53
|
-
messageId: method === "restore"
|
|
55
|
+
messageId: method === "restore" || method === "rewind" ? method : "tick",
|
|
54
56
|
data: { call: context.sourceCode.getText(call.callee) }
|
|
55
57
|
})
|
|
56
58
|
}
|
|
@@ -9,11 +9,14 @@ const page = new Set([
|
|
|
9
9
|
"innerWidth", "innerHeight", "addEventListener", "removeEventListener", "alert", "confirm", "prompt"
|
|
10
10
|
])
|
|
11
11
|
|
|
12
|
-
/** Globals that do host I/O: storage,
|
|
12
|
+
/** Globals that do host I/O: storage, requests, navigation. */
|
|
13
13
|
const io = new Set([
|
|
14
|
-
"localStorage", "sessionStorage", "indexedDB", "caches", "fetch", "XMLHttpRequest", "
|
|
14
|
+
"localStorage", "sessionStorage", "indexedDB", "caches", "fetch", "XMLHttpRequest", "EventSource", "location", "history"
|
|
15
15
|
])
|
|
16
16
|
|
|
17
|
+
/** Globals that connect to other peers: what online play goes through a netcode session for. */
|
|
18
|
+
const network = new Set(["WebSocket", "RTCPeerConnection", "RTCDataChannel"])
|
|
19
|
+
|
|
17
20
|
/** Renderer and UI packages, by exact name. */
|
|
18
21
|
const renderers = new Set([
|
|
19
22
|
"@typeonce/ritmo-render", "@typeonce/ritmo-pixi", "pixi.js", "three", "react", "react-dom", "preact",
|
|
@@ -45,6 +48,8 @@ export default defineRule({
|
|
|
45
48
|
"`{{name}}` is the page, which tests, bots, and replays do not have. Capture input in the host with `Keyboard`, `Pointer`, or `Touch` from `@typeonce/ritmo-browser` and `InputCapture` into a resource, and read that resource in systems. Pass other page state (size, settings) in from host code with `runtime.send(...)` or a resource.",
|
|
46
49
|
io:
|
|
47
50
|
"`{{name}}` is host I/O, which tests, bots, and replays do not have and cannot reproduce. Do the I/O in host code and pass the result in with `runtime.send(...)` or a resource; save and load the world in host code with `runtime.snapshot()` and `runtime.restore(...)`.",
|
|
51
|
+
network:
|
|
52
|
+
"`{{name}}` is a connection to other peers, which tests, bots, and replays do not have. For other players' input, run the simulation under a session of `@typeonce/ritmo-netcode` (`Netcode.rollback` or `Netcode.lockstep`): host code opens the connection and wraps it in a link (`WebSocketNetworkLink`, `WebRtcNetworkLink`), and remote input reaches the simulation through `Netcode.seats`, never `runtime.send(...)`, which a rollback would read on the wrong tick.",
|
|
48
53
|
renderer:
|
|
49
54
|
"The simulation imports `{{source}}`, a renderer or UI package, so it no longer runs headless. Draw from a render schedule in render code: mirror entities into nodes with `RenderSync` and a `NodeRegistry` from `@typeonce/ritmo-render`, and declare its services (a node registry) there. Renderer nodes stay in the registry, never in components.",
|
|
50
55
|
rendererType:
|
|
@@ -88,7 +93,7 @@ export default defineRule({
|
|
|
88
93
|
checkSource(node, stringValue(node.source))
|
|
89
94
|
},
|
|
90
95
|
Identifier(node) {
|
|
91
|
-
const kind = page.has(node.name) ? "page" : io.has(node.name) ? "io" : undefined
|
|
96
|
+
const kind = page.has(node.name) ? "page" : io.has(node.name) ? "io" : network.has(node.name) ? "network" : undefined
|
|
92
97
|
if (kind === undefined) return
|
|
93
98
|
// `typeof window` in a type runs nothing.
|
|
94
99
|
if (node.parent.type === "TSTypeQuery" || node.parent.type === "TSQualifiedName") return
|
|
@@ -27,7 +27,7 @@ export default defineRule({
|
|
|
27
27
|
},
|
|
28
28
|
messages: {
|
|
29
29
|
nonFinite:
|
|
30
|
-
"`{{key}}: {{value}}` cannot be saved: JSON turns it into null and
|
|
30
|
+
"`{{key}}: {{value}}` cannot be saved: JSON turns it into null and a number schema rejects it, so the save no longer loads (and devtools warns `non-finite-value`). Use `null` for \"never\" or \"no limit\": type the field `number | null` and give it a nullable number schema. For a value that only some entities have (a timer on a non-permanent pool), make that part optional: `timer: { remaining: number; duration: number } | null`."
|
|
31
31
|
},
|
|
32
32
|
schema: []
|
|
33
33
|
},
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins"
|
|
2
|
+
import type { ESTree } from "@oxlint/plugins"
|
|
3
|
+
|
|
4
|
+
import { docsUrl, stringValue } from "../internal/ast.ts"
|
|
5
|
+
|
|
6
|
+
/** The `_tag` property of an object literal, if it has one written out. */
|
|
7
|
+
const isTag = (node: ESTree.Node): node is ESTree.ObjectProperty =>
|
|
8
|
+
node.type === "Property" && node.kind === "init" &&
|
|
9
|
+
((!node.computed && node.key.type === "Identifier" && node.key.name === "_tag") || stringValue(node.key) === "_tag")
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A tagged value changes state by writing the new state's fields, never by
|
|
13
|
+
* re-tagging a spread of the old one: the old state's fields would survive at
|
|
14
|
+
* runtime while the type hides them.
|
|
15
|
+
*/
|
|
16
|
+
export default defineRule({
|
|
17
|
+
meta: {
|
|
18
|
+
type: "problem",
|
|
19
|
+
docs: {
|
|
20
|
+
description: "Build a new state's value from its own fields, not by spreading the previous state and changing `_tag`.",
|
|
21
|
+
url: docsUrl("no-state-spread")
|
|
22
|
+
},
|
|
23
|
+
messages: {
|
|
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 `cell.transition({ 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
|
+
},
|
|
27
|
+
schema: []
|
|
28
|
+
},
|
|
29
|
+
create(context) {
|
|
30
|
+
const text = (node: ESTree.Node): string => context.sourceCode.getText(node)
|
|
31
|
+
return {
|
|
32
|
+
ObjectExpression(node) {
|
|
33
|
+
let spread: ESTree.SpreadElement | undefined
|
|
34
|
+
for (const property of node.properties) {
|
|
35
|
+
if (property.type === "SpreadElement") {
|
|
36
|
+
spread = property
|
|
37
|
+
continue
|
|
38
|
+
}
|
|
39
|
+
if (spread === undefined || !isTag(property)) continue
|
|
40
|
+
// `{ ...value, _tag: value._tag }` keeps the state it spreads.
|
|
41
|
+
if (text(property.value) === `${text(spread.argument)}._tag`) continue
|
|
42
|
+
context.report({ node: property, messageId: "spread", data: { spread: text(spread.argument) } })
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
})
|