@n3rdw1z4rd/core 0.22.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +59 -4
  2. package/dist/astar.d.ts +1 -3
  3. package/dist/astar.js +1 -2
  4. package/dist/canvas-renderer.d.ts +1 -3
  5. package/dist/canvas-renderer.js +1 -2
  6. package/dist/clock.d.ts +1 -3
  7. package/dist/clock.js +1 -2
  8. package/dist/color-palette.d.ts +1 -3
  9. package/dist/color-palette.js +1 -2
  10. package/dist/color.d.ts +1 -3
  11. package/dist/color.js +1 -2
  12. package/dist/disposable.d.ts +1 -3
  13. package/dist/disposable.js +1 -2
  14. package/dist/dungeon-generator.d.ts +2 -4
  15. package/dist/dungeon-generator.js +3 -4
  16. package/dist/ecs.d.ts +1 -3
  17. package/dist/ecs.js +1 -2
  18. package/dist/emitter.d.ts +1 -3
  19. package/dist/emitter.js +1 -2
  20. package/dist/event-queue.d.ts +1 -3
  21. package/dist/event-queue.js +1 -2
  22. package/dist/graph/doc.d.ts +2 -4
  23. package/dist/graph/doc.js +1 -2
  24. package/dist/graph/evaluate.d.ts +1 -3
  25. package/dist/graph/evaluate.js +1 -2
  26. package/dist/graph/index.d.ts +4 -4
  27. package/dist/graph/index.js +4 -4
  28. package/dist/graph/node.d.ts +7 -9
  29. package/dist/graph/node.js +1 -2
  30. package/dist/graph/nodes.d.ts +1 -3
  31. package/dist/graph/nodes.js +1 -2
  32. package/dist/graph/script.d.ts +37 -40
  33. package/dist/graph/script.js +14 -60
  34. package/dist/graph/sources.d.ts +1 -3
  35. package/dist/graph/sources.js +1 -2
  36. package/dist/graph/subgraph.d.ts +2 -4
  37. package/dist/graph/subgraph.js +1 -2
  38. package/dist/graph/types.d.ts +3 -5
  39. package/dist/graph/types.js +2 -3
  40. package/dist/graph.cjs +22 -77
  41. package/dist/graph.d.cts +44 -61
  42. package/dist/index.cjs +27 -52
  43. package/dist/index.d.cts +1 -63
  44. package/dist/index.d.ts +10 -10
  45. package/dist/index.js +14 -14
  46. package/dist/input/_input.d.ts +1 -3
  47. package/dist/input/_input.js +1 -2
  48. package/dist/input/action-map.d.ts +1 -3
  49. package/dist/input/action-map.js +1 -2
  50. package/dist/input/bindings.d.ts +1 -3
  51. package/dist/input/bindings.js +1 -2
  52. package/dist/input/gestures.d.ts +1 -3
  53. package/dist/input/gestures.js +1 -2
  54. package/dist/input/index.d.ts +1 -1
  55. package/dist/input/index.js +1 -1
  56. package/dist/input/input-action-map.d.ts +3 -5
  57. package/dist/input/input-action-map.js +3 -4
  58. package/dist/input/input.d.ts +2 -4
  59. package/dist/input/input.js +2 -3
  60. package/dist/log.d.ts +1 -3
  61. package/dist/log.js +1 -2
  62. package/dist/map2d.d.ts +1 -3
  63. package/dist/map2d.js +1 -2
  64. package/dist/{map3d-CHDJiq5T.d.cts → map3d-DRHhbrFn.d.cts} +0 -8
  65. package/dist/map3d.d.ts +1 -3
  66. package/dist/map3d.js +1 -2
  67. package/dist/math.d.ts +1 -3
  68. package/dist/math.js +1 -2
  69. package/dist/misc.d.ts +1 -3
  70. package/dist/misc.js +1 -2
  71. package/dist/observable.d.ts +1 -3
  72. package/dist/observable.js +1 -2
  73. package/dist/particle-renderer.d.ts +1 -3
  74. package/dist/particle-renderer.js +1 -2
  75. package/dist/particle-system-2d.d.ts +1 -3
  76. package/dist/particle-system-2d.js +3 -4
  77. package/dist/random.d.ts +1 -3
  78. package/dist/random.js +1 -2
  79. package/dist/rectangle.d.ts +1 -3
  80. package/dist/rectangle.js +1 -2
  81. package/dist/{rng-Dhqq7owV.cjs → rng-edL6atS3.cjs} +3 -6
  82. package/dist/rng.d.ts +1 -3
  83. package/dist/rng.js +2 -3
  84. package/dist/signal.d.ts +1 -3
  85. package/dist/signal.js +1 -2
  86. package/dist/spatial-partition-2d.d.ts +1 -3
  87. package/dist/spatial-partition-2d.js +1 -2
  88. package/dist/{spatial-partition-3d-CmSCL87Z.cjs → spatial-partition-3d-D1uyJVhM.cjs} +7 -13
  89. package/dist/spatial-partition-3d.d.ts +1 -3
  90. package/dist/spatial-partition-3d.js +1 -2
  91. package/dist/three/adaptive-grid.d.ts +1 -3
  92. package/dist/three/adaptive-grid.js +1 -2
  93. package/dist/three/asteroid-mesh.d.ts +1 -3
  94. package/dist/three/asteroid-mesh.js +1 -2
  95. package/dist/three/camera-rig.d.ts +1 -3
  96. package/dist/three/camera-rig.js +1 -2
  97. package/dist/three/cube-sphere-geometry.d.ts +1 -3
  98. package/dist/three/cube-sphere-geometry.js +1 -2
  99. package/dist/three/ecs.d.ts +1 -3
  100. package/dist/three/ecs.js +1 -2
  101. package/dist/three/editor-camera.d.ts +1 -3
  102. package/dist/three/editor-camera.js +1 -2
  103. package/dist/three/index.d.ts +4 -4
  104. package/dist/three/index.js +1 -1
  105. package/dist/three/particle-system-3d.d.ts +1 -3
  106. package/dist/three/particle-system-3d.js +3 -4
  107. package/dist/three/picking.d.ts +2 -4
  108. package/dist/three/picking.js +1 -2
  109. package/dist/three/renderer.d.ts +1 -3
  110. package/dist/three/renderer.js +1 -2
  111. package/dist/three/schema.d.ts +0 -2
  112. package/dist/three/schema.js +1 -2
  113. package/dist/three/starfield.d.ts +1 -3
  114. package/dist/three/starfield.js +1 -2
  115. package/dist/three/texture-atlas.d.ts +1 -3
  116. package/dist/three/texture-atlas.js +1 -2
  117. package/dist/three/texture-utils.d.ts +1 -3
  118. package/dist/three/texture-utils.js +1 -2
  119. package/dist/three/voxel-geometry.d.ts +2 -4
  120. package/dist/three/voxel-geometry.js +2 -3
  121. package/dist/three/voxel-mesh.d.ts +1 -3
  122. package/dist/three/voxel-mesh.js +1 -2
  123. package/dist/three/world.d.ts +0 -2
  124. package/dist/three/world.js +1 -2
  125. package/dist/three.cjs +18 -34
  126. package/dist/three.d.cts +1 -33
  127. package/dist/tilemap.d.ts +1 -3
  128. package/dist/tilemap.js +1 -2
  129. package/dist/types.d.ts +1 -3
  130. package/dist/vector.d.ts +1 -3
  131. package/dist/vector.js +1 -2
  132. package/dist/vite.cjs +1 -2
  133. package/dist/vite.d.cts +1 -3
  134. package/dist/vite.d.ts +1 -3
  135. package/dist/vite.js +1 -2
  136. package/dist/webgl-renderer.d.ts +1 -3
  137. package/dist/webgl-renderer.js +1 -2
  138. package/dist/webgl.d.ts +1 -3
  139. package/dist/webgl.js +1 -2
  140. package/dist/worker-interface.d.ts +1 -3
  141. package/dist/worker-interface.js +1 -2
  142. package/package.json +6 -6
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @n3rdw1z4rd/core
2
2
 
3
- A personal, browser-facing TypeScript toolkit consolidated out of several game/graphics side projects: math helpers and a deterministic, seedable RNG, an event emitter (TODO: emitter replaced), two ECS flavors, procedural generation (pathfinding, dungeon layout), a "particle life" simulation in 2D and 3D, raw WebGL helpers, and a set of Three.js helpers (camera rigs, voxel meshing, texture atlases, procedural meshes).
3
+ A personal, browser-facing TypeScript toolkit consolidated out of several game/graphics side projects: math helpers and a deterministic, seedable RNG, event helpers, an event-based input system with action maps, two ECS flavors, procedural generation (pathfinding, dungeon layout), a "particle life" simulation in 2D and 3D, raw WebGL helpers, a node graph format and evaluator (`core/graph`), and a set of Three.js helpers (`core/three`: a scene `World` with component schemas, editor camera and picking, camera rigs, voxel meshing, texture atlases, procedural meshes).
4
4
 
5
5
  Nothing here is trying to be a general-purpose framework - it's the shared plumbing that kept getting copy-pasted between projects, pulled into one place so it only has to be fixed once.
6
6
 
@@ -32,7 +32,7 @@ This package ships ESM and CJS builds plus `.d.ts` types (built with `tsdown`).
32
32
 
33
33
  ### Browser vs. Node
34
34
 
35
- The data and logic modules load and run anywhere, including Node (the tests run there): math, `Random`/`Rng`, `Vector`, `Rectangle`, `Map2D`/`Map3D`/`Tilemap`, `findPath` (A*), the dungeon generator, `ECS`, the event helpers (`Emitter`, `Observable`, `Signal`, `EventQueue`, `Disposable`), `Color` and color palettes, the spatial partitions and the particle simulations.
35
+ The data and logic modules load and run anywhere, including Node (the tests run there): math, `Random`/`Rng`, `Vector`, `Rectangle`, `Map2D`/`Map3D`/`Tilemap`, `findPath` (A*), the dungeon generator, `ECS`, the event helpers (`Emitter`, `Observable`, `Signal`, `EventQueue`, `Disposable`), `Color` and color palettes, the spatial partitions, the particle simulations, and all of `@n3rdw1z4rd/core/graph` (in a page, a worker or Node).
36
36
 
37
37
  These need a browser when used (importing them is still safe anywhere): `CanvasRenderer`, `ParticleRenderer`, `WebGlRenderer` and the WebGL helpers, `Input`, `InputActionMap`, `WorkerInterface`, `Clock.start()`, `Color.fromName()` and `GetUrlParams()`, plus anything in `@n3rdw1z4rd/core/three` that renders or loads textures.
38
38
 
@@ -98,12 +98,67 @@ const move = controls.getVector("move_left", "move_right", "move_forward", "move
98
98
 
99
99
  Keyboard, mouse and pen, touch gestures, gamepads (each its own device for local multiplayer) and WebXR controllers (`controls.attachXR(session)`) all feed the same actions. `repeat` keeps a held action pressing again like a held key in a text field (`{ repeat: true }`; the `ui_*` directions repeat by default), `controls.gestures.events` says where the last frame's taps and swipes happened, `controls.actions.toJSON()` / `load()` save rebinds, and `controls.captureBinding()` waits for the next input for rebinding menus.
100
100
 
101
- Three.js helpers come from the `three` subpath:
101
+ ## Three.js helpers (`@n3rdw1z4rd/core/three`)
102
+
103
+ A scene `World` for editors and games: entities are three.js `Object3D`s (tracked by their `uuid`, so ids stay stable), components are declared with schemas, and the whole scene saves and loads as JSON.
104
+
105
+ ```ts
106
+ import { World, component, field, defineComponent } from "@n3rdw1z4rd/core/three";
107
+
108
+ @component("RigidBody")
109
+ class RigidBody {
110
+ @field({ type: "enum", options: ["dynamic", "fixed"] }) kind = "dynamic";
111
+ @field({ min: 0, step: 0.1 }) mass = 1;
112
+ }
113
+
114
+ // or as plain data (no decorators: works in workers and user scripts)
115
+ const Health = defineComponent("Health", { value: { type: "number", default: 100, min: 0 } });
116
+
117
+ const world = new World();
118
+ const ball = world.create("ball"); // an Object3D; parent it to build a hierarchy
119
+ world.addComponent(ball, RigidBody, { mass: 2 });
120
+ world.query(RigidBody); // entities with a RigidBody
121
+ const saved = world.serialize(); // JSON-safe; world.load(saved) restores it
122
+ ```
123
+
124
+ Schemas are what let an editor work with components it has never seen: an inspector, a serializer or graph nodes can be generated from them. Class components use standard (TC39) decorators; until browsers run them natively, the `decorators()` Vite plugin from `@n3rdw1z4rd/core/vite` lowers them.
125
+
126
+ For editors: `EditorCamera` (orthographic or perspective; pan, zoom-at-cursor, orbit, fit, with `zoom` in screen px per world unit), `AdaptiveGrid` (a grid that keeps its spacing readable at any zoom), `pickEntity(world, camera, x, y)` (the entity under a screen point) and `Renderer` (a `WebGLRenderer` that uses the device pixel ratio and can size itself to its parent). Also: `CameraRig`, voxel meshing, texture atlases, `AsteroidMesh`, `CubeSphereGeometry`, a starfield and a 3D particle system.
127
+
128
+ ## Node graphs (`@n3rdw1z4rd/core/graph`)
129
+
130
+ A graph document format, typed pins, node types (built-in or written as scripts) and a lazy, memoized evaluator. It has no DOM, so it runs in a page, a worker or Node.
102
131
 
103
132
  ```ts
104
- import { CameraRig } from "@n3rdw1z4rd/core/three";
133
+ import { createGraph, createNodeRegistry, addNode, connect, GraphEvaluator } from "@n3rdw1z4rd/core/graph";
134
+
135
+ const nodes = createNodeRegistry(); // the built-ins: values, math, lists, ...
136
+ const graph = createGraph(); // { format: "n3rdw1z4rd.graph", nodes, links, ... }
137
+ const grid = addNode(graph, nodes.get("list/grid2d")!, [0, 0], { cols: 3, rows: 2 });
138
+ const count = addNode(graph, nodes.get("list/count")!, [240, 0]);
139
+ connect(graph, nodes, { node: grid.id, port: "points" }, { node: count.id, port: "list" });
140
+
141
+ const { results } = await new GraphEvaluator(nodes).evaluate(graph);
142
+ results.get(count.id)!.outputs.count; // 6
105
143
  ```
106
144
 
145
+ - **Pins are typed** (`number`, `vec2`, `color`, `string`, `boolean`, `any`, your own via `portTypes.define()`), and `T[]` is a list. A list wired into a single-value input **broadcasts**: the node runs once per item (several lists pair up; the longest wins). A `multi` input takes any number of wires.
146
+ - **Evaluation is lazy and local**: only what the output nodes need is evaluated, results are memoized between evaluations, and a node that throws gets an error without stopping the rest. A multi input leaves out a source that failed; downstream nodes are marked `skipped`. Nodes can be `disabled`, and `animate` nodes re-run every frame (`evaluate(graph, { frame })`).
147
+ - **Nodes can be scripts.** A node type is an ES module with its interface and a `run()`; `compileNodeScript(type, source)` turns it into a node type, and every built-in carries an equivalent `source`, so an editor can show any node's code and let you fork it:
148
+
149
+ ```js
150
+ export const title = 'Double';
151
+ export const inputs = { value: { type: 'number', default: 1 } };
152
+ export const outputs = { value: 'number' };
153
+ export function run({ value }, params, ctx) { return { value: value * 2 }; }
154
+ ```
155
+
156
+ A host can also declare its own **module kinds** (`compileNodeScript(type, source, { kinds })`): a module that exports hooks instead of `run` (say, an `update(self, dt)` the host calls every frame) becomes a node with a `run` the host provides, typically one that outputs the node's params and source for the host to run later. apparatus's behaviours (`setup` / `step` / `enter` / `exit` on a physics body) are one.
157
+ - **Subgraphs**: `collapseToSubgraph(graph, nodes, ids, title)` turns a selection into a reusable node type (the wires crossing the selection become its pins); `expandSubgraph()` undoes it, and `registerSubgraphs()` restores the types from a saved document.
158
+ - **Documents** are plain JSON (`normalizeGraph()` checks and fills in one you've loaded): nodes, links, groups, subgraph definitions and embedded scripts.
159
+
160
+ [apparatus](https://github.com/n3rdw1z4rd/apparatus) is built on it: a node graph editor where the graph is a 2D physics scene.
161
+
107
162
  The optional stylesheet (reset + dark defaults) is shipped as plain CSS:
108
163
 
109
164
  ```ts
package/dist/astar.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { XY } from "./types.js";
2
- //#region src/astar.d.ts
3
2
  /**
4
3
  * Cost of stepping onto tile (x, y). Return `Infinity` for blocked tiles. Costs should be >= 1
5
4
  * (the heuristic assumes it); use larger values for slower terrain or occupied tiles.
@@ -40,5 +39,4 @@ export interface PathOptions {
40
39
  *
41
40
  * @category Pathfinding & Procedural
42
41
  */
43
- export declare function findPath(start: XY, goal: XY, cost: StepCost, options?: PathOptions): XY[];
44
- //#endregion
42
+ export declare function findPath(start: XY, goal: XY, cost: StepCost, options?: PathOptions): XY[];
package/dist/astar.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SQRT2 } from "./math.js";
2
2
  import { Heap } from "heap-js";
3
- //#region src/astar.ts
3
+ // src/astar.ts
4
4
  const DEFAULT_MAX_NODES = 1e4;
5
5
  const DIRECTIONS = [
6
6
  [0, -1],
@@ -114,5 +114,4 @@ function buildPath(end) {
114
114
  });
115
115
  return path.reverse();
116
116
  }
117
- //#endregion
118
117
  export { findPath };
@@ -1,5 +1,4 @@
1
1
  import { XY } from "./types.js";
2
- //#region src/canvas-renderer.d.ts
3
2
  /**
4
3
  * Anything a 2D context accepts as a fill or stroke style: a CSS color string, a gradient or a pattern.
5
4
  *
@@ -153,5 +152,4 @@ export declare class CanvasRenderer {
153
152
  * on (`x`, `y`).
154
153
  */
155
154
  drawSprite(x: number, y: number, image: CanvasImageSource, width: number, height: number, params?: SpriteParams): void;
156
- }
157
- //#endregion
155
+ }
@@ -1,5 +1,5 @@
1
1
  import { PI, TAU, clamp } from "./math.js";
2
- //#region src/canvas-renderer.ts
2
+ // src/canvas-renderer.ts
3
3
  /**
4
4
  * Fill / stroke color used when {@link DrawParams.color} is not given.
5
5
  *
@@ -203,5 +203,4 @@ var CanvasRenderer = class {
203
203
  else this.context.drawImage(image, x, y, width, height);
204
204
  }
205
205
  };
206
- //#endregion
207
206
  export { CanvasRenderer, DEFAULT_COLOR, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_PIXEL_SIZE, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE };
package/dist/clock.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/clock.d.ts
2
1
  /**
3
2
  * Milliseconds in one second.
4
3
  *
@@ -65,5 +64,4 @@ export declare class Clock {
65
64
  /** Stops the loop started by {@link Clock.start}. Timing state is kept until the next `start()`. */
66
65
  stop(): void;
67
66
  private _reset;
68
- }
69
- //#endregion
67
+ }
package/dist/clock.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/clock.ts
1
+ // src/clock.ts
2
2
  /**
3
3
  * Milliseconds in one second.
4
4
  *
@@ -104,5 +104,4 @@ var Clock = class {
104
104
  this._fpsFrames = 0;
105
105
  }
106
106
  };
107
- //#endregion
108
107
  export { Clock, ONE_SECOND };
@@ -1,4 +1,3 @@
1
- //#region src/color-palette.d.ts
2
1
  /**
3
2
  * Color as `[r, g, b]`, each 0-255.
4
3
  * @category Color
@@ -21,5 +20,4 @@ export type ColorPalette = readonly number[];
21
20
  * White is always included via the grayscale ramp.
22
21
  * @category Color
23
22
  */
24
- export declare function buildColorPalette(grayscaleSteps?: number, colorSteps?: number, ...colors: RGB[]): ColorPalette;
25
- //#endregion
23
+ export declare function buildColorPalette(grayscaleSteps?: number, colorSteps?: number, ...colors: RGB[]): ColorPalette;
@@ -1,4 +1,4 @@
1
- //#region src/color-palette.ts
1
+ // src/color-palette.ts
2
2
  const DEFAULT_COLORS = [
3
3
  [
4
4
  237,
@@ -108,5 +108,4 @@ function buildColorPalette(grayscaleSteps = 8, colorSteps = 4, ...colors) {
108
108
  for (const rgb of colorList) palette.push(...colorRamp(rgb, colorSteps));
109
109
  return palette;
110
110
  }
111
- //#endregion
112
111
  export { buildColorPalette };
package/dist/color.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/color.d.ts
2
1
  /**
3
2
  * RGBA color with 8-bit channels (integers 0-255), kept in sync with an 8-digit hex string.
4
3
  * Setting a channel rounds and clamps it to 0-255.
@@ -86,5 +85,4 @@ export declare class Color {
86
85
  static fromName(name: string): Color;
87
86
  /** new fully transparent black (0, 0, 0, 0) */
88
87
  static get TRANSPARENT(): Color;
89
- }
90
- //#endregion
88
+ }
package/dist/color.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { clamp } from "./math.js";
2
2
  import { log } from "./log.js";
3
- //#region src/color.ts
3
+ // src/color.ts
4
4
  /**
5
5
  * RGBA color with 8-bit channels (integers 0-255), kept in sync with an 8-digit hex string.
6
6
  * Setting a channel rounds and clamps it to 0-255.
@@ -220,5 +220,4 @@ var Color = class Color {
220
220
  return new Color(0, 0, 0, 0);
221
221
  }
222
222
  };
223
- //#endregion
224
223
  export { Color };
@@ -1,4 +1,3 @@
1
- //#region src/disposable.d.ts
2
1
  /**
3
2
  * Collects cleanup functions (e.g. the unsubscribe functions returned by {@link Observable.subscribe}
4
3
  * and {@link Signal.subscribe}) and runs them all at once.
@@ -23,5 +22,4 @@ export declare class Disposable {
23
22
  * reused afterwards.
24
23
  */
25
24
  dispose(): void;
26
- }
27
- //#endregion
25
+ }
@@ -1,4 +1,4 @@
1
- //#region src/disposable.ts
1
+ // src/disposable.ts
2
2
  /**
3
3
  * Collects cleanup functions (e.g. the unsubscribe functions returned by {@link Observable.subscribe}
4
4
  * and {@link Signal.subscribe}) and runs them all at once.
@@ -28,5 +28,4 @@ var Disposable = class {
28
28
  while (this.disposers.length) this.disposers.pop()?.();
29
29
  }
30
30
  };
31
- //#endregion
32
31
  export { Disposable };
@@ -1,7 +1,6 @@
1
- import { XY } from "./types.js";
2
1
  import { Map2D } from "./map2d.js";
3
2
  import { Rectangle } from "./rectangle.js";
4
- //#region src/dungeon-generator.d.ts
3
+ import { XY } from "./types.js";
5
4
  /**
6
5
  * Two rooms to be joined by a corridor.
7
6
  *
@@ -138,5 +137,4 @@ export declare function GenerateDoors(map: Map2D, paths: XY[][], params?: DoorsP
138
137
  *
139
138
  * @category Pathfinding & Procedural
140
139
  */
141
- export declare function GenerateWalls(map: Map2D): XY[];
142
- //#endregion
140
+ export declare function GenerateWalls(map: Map2D): XY[];
@@ -1,11 +1,11 @@
1
- import { distance2d, squaredDistance } from "./math.js";
2
1
  import { findPath } from "./astar.js";
3
- import { log } from "./log.js";
4
2
  import { Map2D } from "./map2d.js";
5
3
  import { rng } from "./rng.js";
4
+ import { log } from "./log.js";
5
+ import { distance2d, squaredDistance } from "./math.js";
6
6
  import { Rectangle } from "./rectangle.js";
7
7
  import { Heap } from "heap-js";
8
- //#region src/dungeon-generator.ts
8
+ // src/dungeon-generator.ts
9
9
  /**
10
10
  * Tile value for empty (unused) space.
11
11
  *
@@ -284,5 +284,4 @@ function GenerateWalls(map) {
284
284
  });
285
285
  return [...walls.values()];
286
286
  }
287
- //#endregion
288
287
  export { GenerateDoors, GenerateRooms, GenerateWalls, TILE_EMPTY, TILE_FLOOR, TILE_PATH };
package/dist/ecs.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/ecs.d.ts
2
1
  /**
3
2
  * An entity id: a plain integer handed out by {@link ECS.createEntity}.
4
3
  *
@@ -83,5 +82,4 @@ export declare class ECS {
83
82
  *
84
83
  * @category ECS
85
84
  */
86
- export declare const ecs: ECS;
87
- //#endregion
85
+ export declare const ecs: ECS;
package/dist/ecs.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/ecs.ts
1
+ // src/ecs.ts
2
2
  /**
3
3
  * A minimal entity-component store. Entities are integers; components are class instances stored
4
4
  * per class, and {@link ECS.query} iterates the entities that have every requested component.
@@ -97,5 +97,4 @@ var ECS = class {
97
97
  * @category ECS
98
98
  */
99
99
  const ecs = new ECS();
100
- //#endregion
101
100
  export { ECS, ecs };
package/dist/emitter.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/emitter.d.ts
2
1
  /**
3
2
  * An {@link Emitter} listener: called with the emitted arguments, followed by the event name.
4
3
  *
@@ -36,5 +35,4 @@ export declare class Emitter {
36
35
  * once), or every listener of `eventName` when `listener` is left out. Returns `this`.
37
36
  */
38
37
  off(eventName: string, listener?: Listener): this;
39
- }
40
- //#endregion
38
+ }
package/dist/emitter.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/emitter.ts
1
+ // src/emitter.ts
2
2
  /**
3
3
  * A string-keyed event emitter. Listeners get the emitted arguments followed by the event name,
4
4
  * so one listener can tell apart the events it was added to.
@@ -50,5 +50,4 @@ var Emitter = class {
50
50
  return this;
51
51
  }
52
52
  };
53
- //#endregion
54
53
  export { Emitter };
@@ -1,4 +1,3 @@
1
- //#region src/event-queue.d.ts
2
1
  /**
3
2
  * A buffered queue of events: producers `emit()` events, and a consumer reads them later (e.g.
4
3
  * once per frame) with `drain()`, or with `consume()` followed by `clear()`.
@@ -25,5 +24,4 @@ export declare class EventQueue<T> {
25
24
  drain(): T[];
26
25
  /** number of queued events */
27
26
  get size(): number;
28
- }
29
- //#endregion
27
+ }
@@ -1,4 +1,4 @@
1
- //#region src/event-queue.ts
1
+ // src/event-queue.ts
2
2
  /**
3
3
  * A buffered queue of events: producers `emit()` events, and a consumer reads them later (e.g.
4
4
  * once per frame) with `drain()`, or with `consume()` followed by `clear()`.
@@ -36,5 +36,4 @@ var EventQueue = class {
36
36
  return this.events.length;
37
37
  }
38
38
  };
39
- //#endregion
40
39
  export { EventQueue };
@@ -1,6 +1,5 @@
1
- import { TypeRegistry } from "./types.js";
2
1
  import { NodeDef, NodeRegistry } from "./node.js";
3
- //#region src/graph/doc.d.ts
2
+ import { TypeRegistry } from "./types.js";
4
3
  /**
5
4
  * The graph document: plain JSON, saved and shared as-is.
6
5
  *
@@ -137,5 +136,4 @@ export declare function canConnect(doc: GraphDoc, registry: NodeRegistry, from:
137
136
  */
138
137
  export declare function connect(doc: GraphDoc, registry: NodeRegistry, from: PortRef, to: PortRef, types?: TypeRegistry): GraphLink;
139
138
  /** @category Graph */
140
- export declare function disconnect(doc: GraphDoc, linkId: string): void;
141
- //#endregion
139
+ export declare function disconnect(doc: GraphDoc, linkId: string): void;
package/dist/graph/doc.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { portTypes } from "./types.js";
2
- //#region src/graph/doc.ts
2
+ // src/graph/doc.ts
3
3
  /**
4
4
  * The graph document: plain JSON, saved and shared as-is.
5
5
  *
@@ -169,5 +169,4 @@ function reaches(doc, start, target) {
169
169
  function clone(v) {
170
170
  return v !== null && typeof v === "object" ? structuredClone(v) : v;
171
171
  }
172
- //#endregion
173
172
  export { GRAPH_FORMAT, GRAPH_VERSION, addNode, canConnect, connect, createGraph, disconnect, getNode, graphId, linkInto, linksInto, normalizeGraph, removeNode };
@@ -1,6 +1,5 @@
1
- import { NodeRegistry } from "./node.js";
2
1
  import { GraphDoc } from "./doc.js";
3
- //#region src/graph/evaluate.d.ts
2
+ import { NodeRegistry } from "./node.js";
4
3
  /**
5
4
  * Evaluates a graph: runs the nodes the outputs depend on, in dependency order, passing
6
5
  * values along the links.
@@ -110,5 +109,4 @@ export interface EvaluateResult {
110
109
  ran: string[];
111
110
  results: Map<string, NodeResult>;
112
111
  }
113
- //#endregion
114
112
  export type { GraphDoc };
@@ -1,5 +1,5 @@
1
1
  import { getNode, linksInto } from "./doc.js";
2
- //#region src/graph/evaluate.ts
2
+ // src/graph/evaluate.ts
3
3
  /**
4
4
  * Evaluates a graph: runs the nodes the outputs depend on, in dependency order, passing
5
5
  * values along the links.
@@ -315,5 +315,4 @@ function safeKey(parts) {
315
315
  }
316
316
  }
317
317
  const now = () => typeof performance !== "undefined" ? performance.now() : Date.now();
318
- //#endregion
319
318
  export { GraphEvaluator, OUTPUT_LISTS };
@@ -1,9 +1,9 @@
1
- import { ParsedType, PortTypeDef, TypeRegistry, parseType, portTypes } from "./types.js";
2
- import { NodeDef, NodeRegistry, NodeSpec, Param, ParamSpec, Port, PortSpec, RunContext, RunFn, WidgetSpec, defineNode } from "./node.js";
3
1
  import { ConnectCheck, GRAPH_FORMAT, GRAPH_VERSION, GraphDoc, GraphGroup, GraphLink, GraphNode, PortRef, SubgraphDef, addNode, canConnect, connect, createGraph, disconnect, getNode, graphId, linkInto, linksInto, normalizeGraph, removeNode } from "./doc.js";
4
2
  import { EvaluateOptions, EvaluateResult, FrameInfo, GraphEvaluator, NodeResult, OUTPUT_LISTS } from "./evaluate.js";
3
+ import { NodeDef, NodeRegistry, NodeSpec, Param, ParamSpec, Port, PortSpec, RunContext, RunFn, WidgetSpec, defineNode } from "./node.js";
5
4
  import { BUILTIN_NODES, createNodeRegistry } from "./nodes.js";
6
- import { BEHAVIOR_HOOKS, BehaviorValue, SCRIPT_NODE_TEMPLATE, behaviorRun, compileNodeScript } from "./script.js";
5
+ import { ModuleKind, SCRIPT_NODE_TEMPLATE, ScriptOptions, compileNodeScript } from "./script.js";
7
6
  import { BUILTIN_SOURCES } from "./sources.js";
8
7
  import { collapseToSubgraph, expandSubgraph, freeSubgraphType, registerSubgraphs, subgraphSpec } from "./subgraph.js";
9
- export { BEHAVIOR_HOOKS, BUILTIN_NODES, BUILTIN_SOURCES, BehaviorValue, ConnectCheck, EvaluateOptions, EvaluateResult, FrameInfo, GRAPH_FORMAT, GRAPH_VERSION, GraphDoc, GraphEvaluator, GraphGroup, GraphLink, GraphNode, NodeDef, NodeRegistry, NodeResult, NodeSpec, OUTPUT_LISTS, Param, ParamSpec, ParsedType, Port, PortRef, PortSpec, PortTypeDef, RunContext, RunFn, SCRIPT_NODE_TEMPLATE, SubgraphDef, TypeRegistry, WidgetSpec, addNode, behaviorRun, canConnect, collapseToSubgraph, compileNodeScript, connect, createGraph, createNodeRegistry, defineNode, disconnect, expandSubgraph, freeSubgraphType, getNode, graphId, linkInto, linksInto, normalizeGraph, parseType, portTypes, registerSubgraphs, removeNode, subgraphSpec };
8
+ import { ParsedType, PortTypeDef, TypeRegistry, parseType, portTypes } from "./types.js";
9
+ export { BUILTIN_NODES, BUILTIN_SOURCES, ConnectCheck, EvaluateOptions, EvaluateResult, FrameInfo, GRAPH_FORMAT, GRAPH_VERSION, GraphDoc, GraphEvaluator, GraphGroup, GraphLink, GraphNode, ModuleKind, NodeDef, NodeRegistry, NodeResult, NodeSpec, OUTPUT_LISTS, Param, ParamSpec, ParsedType, Port, PortRef, PortSpec, PortTypeDef, RunContext, RunFn, SCRIPT_NODE_TEMPLATE, ScriptOptions, SubgraphDef, TypeRegistry, WidgetSpec, addNode, canConnect, collapseToSubgraph, compileNodeScript, connect, createGraph, createNodeRegistry, defineNode, disconnect, expandSubgraph, freeSubgraphType, getNode, graphId, linkInto, linksInto, normalizeGraph, parseType, portTypes, registerSubgraphs, removeNode, subgraphSpec };
@@ -1,9 +1,9 @@
1
- import { TypeRegistry, parseType, portTypes } from "./types.js";
2
1
  import { GRAPH_FORMAT, GRAPH_VERSION, addNode, canConnect, connect, createGraph, disconnect, getNode, graphId, linkInto, linksInto, normalizeGraph, removeNode } from "./doc.js";
3
2
  import { GraphEvaluator, OUTPUT_LISTS } from "./evaluate.js";
4
3
  import { NodeRegistry, defineNode } from "./node.js";
5
- import { BUILTIN_SOURCES } from "./sources.js";
6
4
  import { BUILTIN_NODES, createNodeRegistry } from "./nodes.js";
7
- import { BEHAVIOR_HOOKS, SCRIPT_NODE_TEMPLATE, behaviorRun, compileNodeScript } from "./script.js";
5
+ import { SCRIPT_NODE_TEMPLATE, compileNodeScript } from "./script.js";
6
+ import { BUILTIN_SOURCES } from "./sources.js";
8
7
  import { collapseToSubgraph, expandSubgraph, freeSubgraphType, registerSubgraphs, subgraphSpec } from "./subgraph.js";
9
- export { BEHAVIOR_HOOKS, BUILTIN_NODES, BUILTIN_SOURCES, GRAPH_FORMAT, GRAPH_VERSION, GraphEvaluator, NodeRegistry, OUTPUT_LISTS, SCRIPT_NODE_TEMPLATE, TypeRegistry, addNode, behaviorRun, canConnect, collapseToSubgraph, compileNodeScript, connect, createGraph, createNodeRegistry, defineNode, disconnect, expandSubgraph, freeSubgraphType, getNode, graphId, linkInto, linksInto, normalizeGraph, parseType, portTypes, registerSubgraphs, removeNode, subgraphSpec };
8
+ import { TypeRegistry, parseType, portTypes } from "./types.js";
9
+ export { BUILTIN_NODES, BUILTIN_SOURCES, GRAPH_FORMAT, GRAPH_VERSION, GraphEvaluator, NodeRegistry, OUTPUT_LISTS, SCRIPT_NODE_TEMPLATE, TypeRegistry, addNode, canConnect, collapseToSubgraph, compileNodeScript, connect, createGraph, createNodeRegistry, defineNode, disconnect, expandSubgraph, freeSubgraphType, getNode, graphId, linkInto, linksInto, normalizeGraph, parseType, portTypes, registerSubgraphs, removeNode, subgraphSpec };
@@ -1,5 +1,4 @@
1
1
  import { ParsedType } from "./types.js";
2
- //#region src/graph/node.d.ts
3
2
  /**
4
3
  * Node definitions: a node is a function with a typed interface.
5
4
  *
@@ -14,11 +13,11 @@ import { ParsedType } from "./types.js";
14
13
  *
15
14
  * ```ts
16
15
  * defineNode({
17
- * type: 'shapes/ball',
18
- * inputs: { at: 'vec2', radius: { type: 'number', default: 8, min: 0.5 } },
19
- * params: { color: { type: 'color', default: '#e8554e' } },
20
- * outputs: { entity: 'entity' },
21
- * run: ({ at, radius }, { color }) => ({ entity: { shape: 'ball', x: at.x, y: at.y, r: radius, color } }),
16
+ * type: 'math/lerp',
17
+ * inputs: { a: 'number', b: { type: 'number', default: 1 } },
18
+ * params: { t: { type: 'number', default: 0.5, min: 0, max: 1, step: 0.05 } },
19
+ * outputs: { value: 'number' },
20
+ * run: ({ a, b }, { t }) => ({ value: a + (b - a) * t }),
22
21
  * });
23
22
  * ```
24
23
  *
@@ -53,7 +52,7 @@ export type ParamSpec = {
53
52
  export interface RunContext {
54
53
  /** the node instance's id */
55
54
  nodeId: string;
56
- /** the node's type, and its source module (if it has one) — behaviour nodes pass these on */
55
+ /** the node's type, and its source module (if it has one), for nodes whose output carries their own code */
57
56
  type: string;
58
57
  source?: string;
59
58
  /** while broadcasting over lists: this call's index (else 0) and the call count (else 1) */
@@ -149,5 +148,4 @@ export declare class NodeRegistry {
149
148
  all(): NodeDef[];
150
149
  /** Called when a type is registered (or replaced) or removed; returns an unsubscribe. */
151
150
  onChange(listener: (def: NodeDef, removed: boolean) => void): () => void;
152
- }
153
- //#endregion
151
+ }
@@ -1,5 +1,5 @@
1
1
  import { parseType } from "./types.js";
2
- //#region src/graph/node.ts
2
+ // src/graph/node.ts
3
3
  let revisionCounter = 0;
4
4
  function port(name, spec) {
5
5
  const s = typeof spec === "string" ? { type: spec } : spec;
@@ -90,5 +90,4 @@ var NodeRegistry = class {
90
90
  return () => this.listeners.delete(listener);
91
91
  }
92
92
  };
93
- //#endregion
94
93
  export { NodeRegistry, defineNode };
@@ -1,5 +1,4 @@
1
1
  import { NodeRegistry, NodeSpec } from "./node.js";
2
- //#region src/graph/nodes.d.ts
3
2
  /** @category Graph */
4
3
  export declare const BUILTIN_NODES: NodeSpec[];
5
4
  /**
@@ -7,5 +6,4 @@ export declare const BUILTIN_NODES: NodeSpec[];
7
6
  *
8
7
  * @category Graph
9
8
  */
10
- export declare function createNodeRegistry(): NodeRegistry;
11
- //#endregion
9
+ export declare function createNodeRegistry(): NodeRegistry;
@@ -1,7 +1,7 @@
1
1
  import { Rng } from "../rng.js";
2
2
  import { NodeRegistry } from "./node.js";
3
3
  import { BUILTIN_SOURCES } from "./sources.js";
4
- //#region src/graph/nodes.ts
4
+ // src/graph/nodes.ts
5
5
  const v2 = (x = 0, y = 0) => ({
6
6
  x,
7
7
  y
@@ -395,5 +395,4 @@ function createNodeRegistry() {
395
395
  });
396
396
  return registry;
397
397
  }
398
- //#endregion
399
398
  export { BUILTIN_NODES, createNodeRegistry };