@typeonce/oxlint-plugin-ritmo 0.9.0 → 0.11.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 +5 -5
- package/dist/rules/handle-tick-result.d.ts +1 -1
- package/dist/rules/handle-tick-result.js +1 -1
- package/dist/rules/keep-simulation-headless.d.ts +3 -2
- package/dist/rules/keep-simulation-headless.d.ts.map +1 -1
- package/dist/rules/keep-simulation-headless.js +12 -12
- package/dist/rules/keep-simulation-headless.js.map +1 -1
- package/dist/rules/prefix-descriptor-and-system-names.d.ts +2 -2
- package/dist/rules/prefix-descriptor-and-system-names.js +2 -2
- package/package.json +2 -1
- package/src/rules/handle-tick-result.ts +1 -1
- package/src/rules/keep-simulation-headless.ts +12 -9
- package/src/rules/prefix-descriptor-and-system-names.ts +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @typeonce/oxlint-plugin-ritmo
|
|
2
|
+
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e46f284: **Documentation pass over every public module.** Every export has JSDoc saying what it is for and which neighbouring API to use instead; examples that no longer compiled (`Session.make` without `hostClock`, `Replay.session`, the `Pointer` rebind) are fixed; `Debug.Lint` lists every lint code the runtime emits. The `stale-target` lint's fix now names `queries.x.getHandle(handle)`.
|
|
8
|
+
|
|
9
|
+
## 0.10.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 388a696: **The Ritmo skill routes each change to a playbook, and simulation code names no renderer type.**
|
|
14
|
+
|
|
15
|
+
- **Breaking: `ritmo/keep-simulation-headless` reports type-only renderer imports** (`import type { Container } from "pixi.js"`, `export type ... from "three"`) and subpath imports of `@typeonce/ritmo-render` and `@typeonce/ritmo-pixi`. A schema that names a renderer type ties the simulation to that renderer. Move the renderer service (a `Descriptor.Service<NodeRegistry.NodeRegistry<Sprite>>()(...)`) and the systems that use it into render code; services are not registered in the schema, so nothing else changes:
|
|
16
|
+
|
|
17
|
+
```diff
|
|
18
|
+
-// src/game/schema.ts
|
|
19
|
+
-import type { Sprite } from "pixi.js"
|
|
20
|
+
-export const Sprites = Descriptor.Service<NodeRegistry.NodeRegistry<Sprite>>()("Game/Sprites")
|
|
21
|
+
+// src/render/sprites.ts
|
|
22
|
+
+import type { Sprite } from "pixi.js"
|
|
23
|
+
+export const Sprites = Descriptor.Service<NodeRegistry.NodeRegistry<Sprite>>()("Game/Sprites")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- **The skill in `skills/ritmo` now has playbooks**: one per kind of change (a mechanic, content, UI and rendering, a bug fix, a refactor, state and upgrades), each a short list of steps that ends with the check that proves it. `SKILL.md` routes to them and keeps the principles. A game that already links the skill folder gets them on upgrade.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 7002f4d: **Everything a game's agent needs now ships with the packages, and `ritmo-devtools lint` reports simulation modules the lint rules miss.**
|
|
31
|
+
|
|
32
|
+
- **Breaking: `ritmo-devtools lint` fails on an uncovered simulation module.** Every module the entry loads that the `ritmo/keep-simulation-headless` override in `.oxlintrc.json` does not cover is reported as `uncovered-simulation-module`, and the command exits 1. Add the module (or its folder) to the simulation override's `"files"`, or stop importing values from it. Modules loaded only inside `lintTarget` are not checked. Requires Node 22.15 or newer (`engines.node` is now `>=22.15`).
|
|
33
|
+
- **An agent skill ships with `@typeonce/ritmo`** in `skills/ritmo/SKILL.md`, for every change: where the docs are, and principles for where a game's code and state belong. Link it into the folder the game's agent reads skills from, for example `ln -s ../../node_modules/@typeonce/ritmo/skills/ritmo .agents/skills/ritmo`. `SETUP.md` in `@typeonce/ritmo` is the one-time setup: the base packages and checks every game uses, the add-ons, and linking the skill.
|
|
34
|
+
- **Every package ships its `CHANGELOG.md`.** The upgrade notes for 0.8.0 and 0.9.0 are in the `@typeonce/ritmo` changelog.
|
|
35
|
+
- **JSDoc corrections.** Examples no longer provide randomness or time as services (use the `Random` resource and `Clock`), the `Command` module example declares its commands, inspector docs state that `added`/`changed` reads report records since the inspector's previous evaluation, and every example uses prefixed names (`"Game/Position"`). Guidance that lived only in the repository's guides (spawn order, `ReadonlyValue` helpers, re-entering a state, `thisTick` and plugin systems, service effects and rollback) is now in the JSDoc.
|
|
36
|
+
- Package READMEs link other packages' READMEs by GitHub URL, so the links work on npm.
|
|
37
|
+
|
|
38
|
+
## 0.9.0
|
|
39
|
+
|
|
40
|
+
### Minor Changes
|
|
41
|
+
|
|
42
|
+
- 003b902: **New package: `@typeonce/oxlint-plugin-ritmo`, oxlint rules for Ritmo games.**
|
|
43
|
+
|
|
44
|
+
Types reject wrong calls and devtools lints reject wrong runs; these rules catch the source patterns neither can see. Every report says what goes wrong and the Ritmo API to use instead.
|
|
45
|
+
|
|
46
|
+
Simulation files (listed in an `overrides` entry, so host, render, and unrelated files keep using the platform):
|
|
47
|
+
|
|
48
|
+
- `ritmo/use-clock-for-time`: `Date.now()`, `performance.now()`, `new Date()`, and timers; read the `Clock` resource.
|
|
49
|
+
- `ritmo/use-random-for-randomness`: `Math.random()` and `crypto` randomness; draw with `Random.draw(resources.rng)`.
|
|
50
|
+
- `ritmo/use-ops-for-math`: `Math.sin`, `Math.hypot`, `a ** b`, and the other functions engines approximate; use `Ops` (fixes itself once `Ops` is imported).
|
|
51
|
+
- `ritmo/keep-simulation-headless`: page globals, host I/O, and renderer or UI imports; take input and data from the host, draw in a render schedule.
|
|
52
|
+
- `ritmo/no-infinity-in-simulation-data`: `Infinity` and `NaN` in object literals, which cannot be saved and loaded; use `null`.
|
|
53
|
+
|
|
54
|
+
Every file:
|
|
55
|
+
|
|
56
|
+
- `ritmo/handle-tick-result`: a dropped `runtime.tick(...)`, `tryTick(...)`, or `restore(...)` result.
|
|
57
|
+
- `ritmo/prefix-descriptor-and-system-names`: names without a `Game/` prefix.
|
|
58
|
+
- `ritmo/use-cell-value`: `cell.present ? cell.get() : undefined`; use `cell.value()` (fixes itself).
|
|
59
|
+
|
|
60
|
+
```jsonc
|
|
61
|
+
{
|
|
62
|
+
"jsPlugins": ["@typeonce/oxlint-plugin-ritmo"],
|
|
63
|
+
"rules": { "ritmo/handle-tick-result": "error" },
|
|
64
|
+
"overrides": [
|
|
65
|
+
{
|
|
66
|
+
"files": ["src/sim/**"],
|
|
67
|
+
"rules": { "ritmo/use-ops-for-math": "error" }
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
```
|
package/README.md
CHANGED
|
@@ -14,11 +14,11 @@ Every report says what goes wrong and which Ritmo API to use instead.
|
|
|
14
14
|
pnpm add -D @typeonce/oxlint-plugin-ritmo oxlint
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Released together with [`@typeonce/ritmo`](https://
|
|
17
|
+
Released together with [`@typeonce/ritmo`](https://github.com/typeonce-dev/ritmo/blob/main/packages/core/README.md), always with the same version. Requires oxlint 1.86 or newer.
|
|
18
18
|
|
|
19
19
|
## Setup
|
|
20
20
|
|
|
21
|
-
Register the plugin and turn the rules on in `.oxlintrc.json`. The simulation rules go in an `overrides` entry that lists the game's simulation files: the code its fixed-step schedules run, which must replay exactly and run headless. Host, render, UI, tool, and unrelated files are not listed, so they keep using the platform freely.
|
|
21
|
+
Register the plugin and turn the rules on in `.oxlintrc.json`. The simulation rules go in an `overrides` entry that lists the game's simulation files: the code its fixed-step schedules run, which must replay exactly and run headless. Host, render, UI, tool, and unrelated files are not listed, so they keep using the platform freely. A file the override does not list gets no simulation checks, so list folders rather than single files, and run `ritmo-devtools lint` from `@typeonce/ritmo-devtools`: it reports every module the simulation loads that the override misses.
|
|
22
22
|
|
|
23
23
|
```jsonc
|
|
24
24
|
{
|
|
@@ -100,7 +100,7 @@ Catches `Math.random()`, `crypto.getRandomValues()`, and `crypto.randomUUID()`.
|
|
|
100
100
|
|
|
101
101
|
### `ritmo/use-ops-for-math`
|
|
102
102
|
|
|
103
|
-
The spec lets engines approximate `Math.sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `exp`, `expm1`, `log`, `log2`, `log10`, `log1p`, `cbrt`, `pow`, `hypot`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, and `a ** b`, and they do: Chrome, Safari, macOS, and Linux disagree in the last bit, and a simulation grows that bit into a different run. [`Ops`](
|
|
103
|
+
The spec lets engines approximate `Math.sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `exp`, `expm1`, `log`, `log2`, `log10`, `log1p`, `cbrt`, `pow`, `hypot`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, and `a ** b`, and they do: Chrome, Safari, macOS, and Linux disagree in the last bit, and a simulation grows that bit into a different run. [`Ops`](https://github.com/typeonce-dev/ritmo/blob/main/packages/math/README.md#determinism-across-devices) from `@typeonce/ritmo-math` has each of them as a port that returns the same bits everywhere.
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
106
|
const turn = Math.atan2(Math.sin(b - a), Math.cos(b - a)) // reported
|
|
@@ -120,9 +120,9 @@ The simulation runs in tests, bots, replays, and on servers, where there is no p
|
|
|
120
120
|
|
|
121
121
|
| Reported | Setup instead |
|
|
122
122
|
|---|---|
|
|
123
|
-
| Page globals: `window`, `document`, `navigator`, `matchMedia`, ... | Capture input in the host with `Keyboard`, `Pointer`, or `Touch` from `@typeonce/ritmo-browser` and `InputCapture` into a resource that systems read. Pass page state (size, settings) in with `runtime.send(...)` or a resource. |
|
|
123
|
+
| 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
124
|
| Host I/O: `localStorage`, `fetch`, `WebSocket`, `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(...)`. |
|
|
125
|
-
| Renderer and UI imports: `pixi.js`, `three`, `@typeonce/ritmo-render`, `react`, `preact`, ... | Draw from a render schedule in
|
|
125
|
+
| 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
126
|
|
|
127
127
|
Locals and fields with these names (`term.window`, a `location` parameter) are not globals and are not reported.
|
|
128
128
|
|
|
@@ -1,7 +1,7 @@
|
|
|
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(...)` and `
|
|
4
|
+
* The result of `runtime.tick(...)`, `tryTick(...)`, and `restore(...)` is read: a
|
|
5
5
|
* failed system or an invalid save comes back as data, and dropping it hides
|
|
6
6
|
* the failure.
|
|
7
7
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Simulation code runs headless (tests, bots, replays, servers): it never
|
|
3
|
-
* touches the page, does host I/O, or imports a renderer
|
|
4
|
-
*
|
|
3
|
+
* touches the page, does host I/O, or imports a renderer, not even a type,
|
|
4
|
+
* so another renderer can replace the current one. The host feeds it input
|
|
5
|
+
* and data, and render code draws it.
|
|
5
6
|
*/
|
|
6
7
|
declare const _default: import("@oxlint/plugins").Rule;
|
|
7
8
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keep-simulation-headless.d.ts","sourceRoot":"","sources":["../../src/rules/keep-simulation-headless.ts"],"names":[],"mappings":"AA6BA
|
|
1
|
+
{"version":3,"file":"keep-simulation-headless.d.ts","sourceRoot":"","sources":["../../src/rules/keep-simulation-headless.ts"],"names":[],"mappings":"AA6BA;;;;;GAKG"}
|
|
@@ -15,11 +15,12 @@ const renderers = new Set([
|
|
|
15
15
|
"vue", "svelte", "solid-js", "phaser", "konva", "p5", "babylonjs", "@babylonjs/core"
|
|
16
16
|
]);
|
|
17
17
|
/** Renderer and UI packages, by scope or subpath. */
|
|
18
|
-
const rendererPrefixes = ["@pixi/", "@preact/", "@react-three/", "three/", "react-dom/", "preact/", "@babylonjs/", "solid-js/"];
|
|
18
|
+
const rendererPrefixes = ["@typeonce/ritmo-render/", "@typeonce/ritmo-pixi/", "@pixi/", "@preact/", "@react-three/", "three/", "react-dom/", "preact/", "@babylonjs/", "solid-js/"];
|
|
19
19
|
/**
|
|
20
20
|
* Simulation code runs headless (tests, bots, replays, servers): it never
|
|
21
|
-
* touches the page, does host I/O, or imports a renderer
|
|
22
|
-
*
|
|
21
|
+
* touches the page, does host I/O, or imports a renderer, not even a type,
|
|
22
|
+
* so another renderer can replace the current one. The host feeds it input
|
|
23
|
+
* and data, and render code draws it.
|
|
23
24
|
*/
|
|
24
25
|
export default defineRule({
|
|
25
26
|
meta: {
|
|
@@ -31,7 +32,8 @@ export default defineRule({
|
|
|
31
32
|
messages: {
|
|
32
33
|
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.",
|
|
33
34
|
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(...)`.",
|
|
34
|
-
renderer: "The simulation imports `{{source}}`, a renderer or UI package, so it no longer runs headless. Draw from a render schedule in
|
|
35
|
+
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
|
+
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."
|
|
35
37
|
},
|
|
36
38
|
schema: [
|
|
37
39
|
{
|
|
@@ -53,22 +55,20 @@ export default defineRule({
|
|
|
53
55
|
const isRenderer = (source) => renderers.has(source) ||
|
|
54
56
|
rendererPrefixes.some((prefix) => source.startsWith(prefix)) ||
|
|
55
57
|
extra.some((entry) => (entry.endsWith("/") ? source.startsWith(entry) : source === entry || source.startsWith(`${entry}/`)));
|
|
56
|
-
const checkSource = (node, source) => {
|
|
58
|
+
const checkSource = (node, source, onlyTypes = false) => {
|
|
57
59
|
if (source !== undefined && isRenderer(source))
|
|
58
|
-
context.report({ node, messageId: "renderer", data: { source } });
|
|
60
|
+
context.report({ node, messageId: onlyTypes ? "rendererType" : "renderer", data: { source } });
|
|
59
61
|
};
|
|
60
62
|
return {
|
|
61
63
|
ImportDeclaration(node) {
|
|
62
|
-
|
|
63
|
-
checkSource(node, node.source.value);
|
|
64
|
+
checkSource(node, node.source.value, importsOnlyTypes(node));
|
|
64
65
|
},
|
|
65
66
|
ExportNamedDeclaration(node) {
|
|
66
|
-
if (node.source !== null
|
|
67
|
-
checkSource(node, node.source.value);
|
|
67
|
+
if (node.source !== null)
|
|
68
|
+
checkSource(node, node.source.value, node.exportKind === "type");
|
|
68
69
|
},
|
|
69
70
|
ExportAllDeclaration(node) {
|
|
70
|
-
|
|
71
|
-
checkSource(node, node.source.value);
|
|
71
|
+
checkSource(node, node.source.value, node.exportKind === "type");
|
|
72
72
|
},
|
|
73
73
|
ImportExpression(node) {
|
|
74
74
|
checkSource(node, stringValue(node.source));
|
|
@@ -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,8DAA8D;AAC9D,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC;IACjB,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS;CACtI,CAAC,CAAA;AAEF,+CAA+C;AAC/C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,wBAAwB,EAAE,sBAAsB,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ;IACpG,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,iBAAiB;CACrF,CAAC,CAAA;AAEF,qDAAqD;AACrD,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,CAAC,CAAA;
|
|
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,gBAA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AE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;YACtE,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Names Ritmo registers (descriptors, systems, state machines, scopes,
|
|
3
|
-
* plugin systems) carry a
|
|
4
|
-
* packages it uses never clash.
|
|
3
|
+
* plugin systems) carry a `<Game>/` prefix (the game's or package's name),
|
|
4
|
+
* so names from a game and from the packages it uses never clash.
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: import("@oxlint/plugins").Rule;
|
|
7
7
|
export default _default;
|
|
@@ -35,8 +35,8 @@ const namesIn = (node) => {
|
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* Names Ritmo registers (descriptors, systems, state machines, scopes,
|
|
38
|
-
* plugin systems) carry a
|
|
39
|
-
* packages it uses never clash.
|
|
38
|
+
* plugin systems) carry a `<Game>/` prefix (the game's or package's name),
|
|
39
|
+
* so names from a game and from the packages it uses never clash.
|
|
40
40
|
*/
|
|
41
41
|
export default defineRule({
|
|
42
42
|
meta: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typeonce/oxlint-plugin-ritmo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"src/**/*.ts",
|
|
28
28
|
"dist",
|
|
29
29
|
"README.md",
|
|
30
|
+
"CHANGELOG.md",
|
|
30
31
|
"LICENSE"
|
|
31
32
|
],
|
|
32
33
|
"exports": {
|
|
@@ -7,7 +7,7 @@ interface Options {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* The result of `runtime.tick(...)` and `
|
|
10
|
+
* The result of `runtime.tick(...)`, `tryTick(...)`, and `restore(...)` is read: a
|
|
11
11
|
* failed system or an invalid save comes back as data, and dropping it hides
|
|
12
12
|
* the failure.
|
|
13
13
|
*/
|
|
@@ -21,7 +21,7 @@ const renderers = new Set([
|
|
|
21
21
|
])
|
|
22
22
|
|
|
23
23
|
/** Renderer and UI packages, by scope or subpath. */
|
|
24
|
-
const rendererPrefixes = ["@pixi/", "@preact/", "@react-three/", "three/", "react-dom/", "preact/", "@babylonjs/", "solid-js/"]
|
|
24
|
+
const rendererPrefixes = ["@typeonce/ritmo-render/", "@typeonce/ritmo-pixi/", "@pixi/", "@preact/", "@react-three/", "three/", "react-dom/", "preact/", "@babylonjs/", "solid-js/"]
|
|
25
25
|
|
|
26
26
|
interface Options {
|
|
27
27
|
readonly packages?: ReadonlyArray<string>
|
|
@@ -29,8 +29,9 @@ interface Options {
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Simulation code runs headless (tests, bots, replays, servers): it never
|
|
32
|
-
* touches the page, does host I/O, or imports a renderer
|
|
33
|
-
*
|
|
32
|
+
* touches the page, does host I/O, or imports a renderer, not even a type,
|
|
33
|
+
* so another renderer can replace the current one. The host feeds it input
|
|
34
|
+
* and data, and render code draws it.
|
|
34
35
|
*/
|
|
35
36
|
export default defineRule({
|
|
36
37
|
meta: {
|
|
@@ -45,7 +46,9 @@ export default defineRule({
|
|
|
45
46
|
io:
|
|
46
47
|
"`{{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(...)`.",
|
|
47
48
|
renderer:
|
|
48
|
-
"The simulation imports `{{source}}`, a renderer or UI package, so it no longer runs headless. Draw from a render schedule in
|
|
49
|
+
"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
|
+
rendererType:
|
|
51
|
+
"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."
|
|
49
52
|
},
|
|
50
53
|
schema: [
|
|
51
54
|
{
|
|
@@ -68,18 +71,18 @@ export default defineRule({
|
|
|
68
71
|
renderers.has(source) ||
|
|
69
72
|
rendererPrefixes.some((prefix) => source.startsWith(prefix)) ||
|
|
70
73
|
extra.some((entry) => (entry.endsWith("/") ? source.startsWith(entry) : source === entry || source.startsWith(`${entry}/`)))
|
|
71
|
-
const checkSource = (node: ESTree.Node, source: string | undefined): void => {
|
|
72
|
-
if (source !== undefined && isRenderer(source)) context.report({ node, messageId: "renderer", data: { source } })
|
|
74
|
+
const checkSource = (node: ESTree.Node, source: string | undefined, onlyTypes = false): void => {
|
|
75
|
+
if (source !== undefined && isRenderer(source)) context.report({ node, messageId: onlyTypes ? "rendererType" : "renderer", data: { source } })
|
|
73
76
|
}
|
|
74
77
|
return {
|
|
75
78
|
ImportDeclaration(node) {
|
|
76
|
-
|
|
79
|
+
checkSource(node, node.source.value, importsOnlyTypes(node))
|
|
77
80
|
},
|
|
78
81
|
ExportNamedDeclaration(node) {
|
|
79
|
-
if (node.source !== null
|
|
82
|
+
if (node.source !== null) checkSource(node, node.source.value, node.exportKind === "type")
|
|
80
83
|
},
|
|
81
84
|
ExportAllDeclaration(node) {
|
|
82
|
-
|
|
85
|
+
checkSource(node, node.source.value, node.exportKind === "type")
|
|
83
86
|
},
|
|
84
87
|
ImportExpression(node) {
|
|
85
88
|
checkSource(node, stringValue(node.source))
|
|
@@ -40,8 +40,8 @@ const namesIn = (node: ESTree.CallExpression): ReadonlyArray<ESTree.Node> => {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Names Ritmo registers (descriptors, systems, state machines, scopes,
|
|
43
|
-
* plugin systems) carry a
|
|
44
|
-
* packages it uses never clash.
|
|
43
|
+
* plugin systems) carry a `<Game>/` prefix (the game's or package's name),
|
|
44
|
+
* so names from a game and from the packages it uses never clash.
|
|
45
45
|
*/
|
|
46
46
|
export default defineRule({
|
|
47
47
|
meta: {
|