@n3rdw1z4rd/core 0.23.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.
- package/dist/astar.d.ts +1 -3
- package/dist/astar.js +1 -2
- package/dist/canvas-renderer.d.ts +1 -3
- package/dist/canvas-renderer.js +1 -2
- package/dist/clock.d.ts +1 -3
- package/dist/clock.js +1 -2
- package/dist/color-palette.d.ts +1 -3
- package/dist/color-palette.js +1 -2
- package/dist/color.d.ts +1 -3
- package/dist/color.js +1 -2
- package/dist/disposable.d.ts +1 -3
- package/dist/disposable.js +1 -2
- package/dist/dungeon-generator.d.ts +2 -4
- package/dist/dungeon-generator.js +3 -4
- package/dist/ecs.d.ts +1 -3
- package/dist/ecs.js +1 -2
- package/dist/emitter.d.ts +1 -3
- package/dist/emitter.js +1 -2
- package/dist/event-queue.d.ts +1 -3
- package/dist/event-queue.js +1 -2
- package/dist/graph/doc.d.ts +2 -4
- package/dist/graph/doc.js +1 -2
- package/dist/graph/evaluate.d.ts +1 -3
- package/dist/graph/evaluate.js +1 -2
- package/dist/graph/index.d.ts +2 -2
- package/dist/graph/index.js +2 -2
- package/dist/graph/node.d.ts +1 -3
- package/dist/graph/node.js +1 -2
- package/dist/graph/nodes.d.ts +1 -3
- package/dist/graph/nodes.js +1 -2
- package/dist/graph/script.d.ts +1 -3
- package/dist/graph/script.js +1 -2
- package/dist/graph/sources.d.ts +1 -3
- package/dist/graph/sources.js +1 -2
- package/dist/graph/subgraph.d.ts +2 -4
- package/dist/graph/subgraph.js +1 -2
- package/dist/graph/types.d.ts +1 -3
- package/dist/graph/types.js +1 -2
- package/dist/graph.cjs +9 -17
- package/dist/graph.d.cts +1 -17
- package/dist/index.cjs +27 -52
- package/dist/index.d.cts +1 -63
- package/dist/index.d.ts +10 -10
- package/dist/index.js +14 -14
- package/dist/input/_input.d.ts +1 -3
- package/dist/input/_input.js +1 -2
- package/dist/input/action-map.d.ts +1 -3
- package/dist/input/action-map.js +1 -2
- package/dist/input/bindings.d.ts +1 -3
- package/dist/input/bindings.js +1 -2
- package/dist/input/gestures.d.ts +1 -3
- package/dist/input/gestures.js +1 -2
- package/dist/input/index.d.ts +1 -1
- package/dist/input/index.js +1 -1
- package/dist/input/input-action-map.d.ts +3 -5
- package/dist/input/input-action-map.js +3 -4
- package/dist/input/input.d.ts +2 -4
- package/dist/input/input.js +2 -3
- package/dist/log.d.ts +1 -3
- package/dist/log.js +1 -2
- package/dist/map2d.d.ts +1 -3
- package/dist/map2d.js +1 -2
- package/dist/{map3d-CHDJiq5T.d.cts → map3d-DRHhbrFn.d.cts} +0 -8
- package/dist/map3d.d.ts +1 -3
- package/dist/map3d.js +1 -2
- package/dist/math.d.ts +1 -3
- package/dist/math.js +1 -2
- package/dist/misc.d.ts +1 -3
- package/dist/misc.js +1 -2
- package/dist/observable.d.ts +1 -3
- package/dist/observable.js +1 -2
- package/dist/particle-renderer.d.ts +1 -3
- package/dist/particle-renderer.js +1 -2
- package/dist/particle-system-2d.d.ts +1 -3
- package/dist/particle-system-2d.js +3 -4
- package/dist/random.d.ts +1 -3
- package/dist/random.js +1 -2
- package/dist/rectangle.d.ts +1 -3
- package/dist/rectangle.js +1 -2
- package/dist/{rng-Dhqq7owV.cjs → rng-edL6atS3.cjs} +3 -6
- package/dist/rng.d.ts +1 -3
- package/dist/rng.js +2 -3
- package/dist/signal.d.ts +1 -3
- package/dist/signal.js +1 -2
- package/dist/spatial-partition-2d.d.ts +1 -3
- package/dist/spatial-partition-2d.js +1 -2
- package/dist/{spatial-partition-3d-CmSCL87Z.cjs → spatial-partition-3d-D1uyJVhM.cjs} +7 -13
- package/dist/spatial-partition-3d.d.ts +1 -3
- package/dist/spatial-partition-3d.js +1 -2
- package/dist/three/adaptive-grid.d.ts +1 -3
- package/dist/three/adaptive-grid.js +1 -2
- package/dist/three/asteroid-mesh.d.ts +1 -3
- package/dist/three/asteroid-mesh.js +1 -2
- package/dist/three/camera-rig.d.ts +1 -3
- package/dist/three/camera-rig.js +1 -2
- package/dist/three/cube-sphere-geometry.d.ts +1 -3
- package/dist/three/cube-sphere-geometry.js +1 -2
- package/dist/three/ecs.d.ts +1 -3
- package/dist/three/ecs.js +1 -2
- package/dist/three/editor-camera.d.ts +1 -3
- package/dist/three/editor-camera.js +1 -2
- package/dist/three/index.d.ts +4 -4
- package/dist/three/index.js +1 -1
- package/dist/three/particle-system-3d.d.ts +1 -3
- package/dist/three/particle-system-3d.js +3 -4
- package/dist/three/picking.d.ts +2 -4
- package/dist/three/picking.js +1 -2
- package/dist/three/renderer.d.ts +1 -3
- package/dist/three/renderer.js +1 -2
- package/dist/three/schema.d.ts +0 -2
- package/dist/three/schema.js +1 -2
- package/dist/three/starfield.d.ts +1 -3
- package/dist/three/starfield.js +1 -2
- package/dist/three/texture-atlas.d.ts +1 -3
- package/dist/three/texture-atlas.js +1 -2
- package/dist/three/texture-utils.d.ts +1 -3
- package/dist/three/texture-utils.js +1 -2
- package/dist/three/voxel-geometry.d.ts +2 -4
- package/dist/three/voxel-geometry.js +2 -3
- package/dist/three/voxel-mesh.d.ts +1 -3
- package/dist/three/voxel-mesh.js +1 -2
- package/dist/three/world.d.ts +0 -2
- package/dist/three/world.js +1 -2
- package/dist/three.cjs +18 -34
- package/dist/three.d.cts +1 -33
- package/dist/tilemap.d.ts +1 -3
- package/dist/tilemap.js +1 -2
- package/dist/types.d.ts +1 -3
- package/dist/vector.d.ts +1 -3
- package/dist/vector.js +1 -2
- package/dist/vite.cjs +1 -2
- package/dist/vite.d.cts +1 -3
- package/dist/vite.d.ts +1 -3
- package/dist/vite.js +1 -2
- package/dist/webgl-renderer.d.ts +1 -3
- package/dist/webgl-renderer.js +1 -2
- package/dist/webgl.d.ts +1 -3
- package/dist/webgl.js +1 -2
- package/dist/worker-interface.d.ts +1 -3
- package/dist/worker-interface.js +1 -2
- package/package.json +6 -6
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
|
-
|
|
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
|
+
}
|
package/dist/canvas-renderer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PI, TAU, clamp } from "./math.js";
|
|
2
|
-
|
|
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
package/dist/color-palette.d.ts
CHANGED
|
@@ -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;
|
package/dist/color-palette.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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 };
|
package/dist/disposable.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/dist/disposable.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 };
|
package/dist/event-queue.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/dist/event-queue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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 };
|
package/dist/graph/doc.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { TypeRegistry } from "./types.js";
|
|
2
1
|
import { NodeDef, NodeRegistry } from "./node.js";
|
|
3
|
-
|
|
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
|
-
|
|
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 };
|
package/dist/graph/evaluate.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { NodeRegistry } from "./node.js";
|
|
2
1
|
import { GraphDoc } from "./doc.js";
|
|
3
|
-
|
|
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 };
|
package/dist/graph/evaluate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNode, linksInto } from "./doc.js";
|
|
2
|
-
|
|
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 };
|
package/dist/graph/index.d.ts
CHANGED
|
@@ -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
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";
|
|
8
|
+
import { ParsedType, PortTypeDef, TypeRegistry, parseType, portTypes } from "./types.js";
|
|
9
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 };
|
package/dist/graph/index.js
CHANGED
|
@@ -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
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";
|
|
8
|
+
import { TypeRegistry, parseType, portTypes } from "./types.js";
|
|
9
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 };
|
package/dist/graph/node.d.ts
CHANGED
|
@@ -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
|
*
|
|
@@ -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
|
+
}
|
package/dist/graph/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseType } from "./types.js";
|
|
2
|
-
|
|
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 };
|
package/dist/graph/nodes.d.ts
CHANGED
|
@@ -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;
|
package/dist/graph/nodes.js
CHANGED
|
@@ -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
|
-
|
|
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 };
|
package/dist/graph/script.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { NodeDef, NodeSpec } from "./node.js";
|
|
2
|
-
//#region src/graph/script.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Script nodes: a node type written as a plain ES module, compiled at runtime.
|
|
5
4
|
*
|
|
@@ -59,5 +58,4 @@ export interface ScriptOptions {
|
|
|
59
58
|
*/
|
|
60
59
|
export declare function compileNodeScript(type: string, source: string, options?: ScriptOptions): Promise<NodeDef>;
|
|
61
60
|
/** A starting point for a new script node. @category Graph */
|
|
62
|
-
export declare const SCRIPT_NODE_TEMPLATE = "// A node is a function with a typed interface.\n// inputs: pins wired from other nodes (an unconnected one uses its widget value / default)\n// params: widgets on the node\n// outputs: what run() returns\n// A \"type[]\" pin takes (or gives) a whole list; a list wired into a plain pin runs\n// run() once per item and collects the results into lists.\n\nexport const inputs = {\n a: { type: 'number', default: 1 },\n b: { type: 'number', default: 2 },\n};\n\nexport const params = {\n scale: { type: 'number', default: 1, min: 0, max: 10, step: 0.1 },\n};\n\nexport const outputs = {\n result: 'number',\n};\n\nexport function run({ a, b }, { scale }, ctx) {\n return { result: (a + b) * scale };\n}\n";
|
|
63
|
-
//#endregion
|
|
61
|
+
export declare const SCRIPT_NODE_TEMPLATE = "// A node is a function with a typed interface.\n// inputs: pins wired from other nodes (an unconnected one uses its widget value / default)\n// params: widgets on the node\n// outputs: what run() returns\n// A \"type[]\" pin takes (or gives) a whole list; a list wired into a plain pin runs\n// run() once per item and collects the results into lists.\n\nexport const inputs = {\n a: { type: 'number', default: 1 },\n b: { type: 'number', default: 2 },\n};\n\nexport const params = {\n scale: { type: 'number', default: 1, min: 0, max: 10, step: 0.1 },\n};\n\nexport const outputs = {\n result: 'number',\n};\n\nexport function run({ a, b }, { scale }, ctx) {\n return { result: (a + b) * scale };\n}\n";
|
package/dist/graph/script.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineNode } from "./node.js";
|
|
2
|
-
|
|
2
|
+
// src/graph/script.ts
|
|
3
3
|
/**
|
|
4
4
|
* Compiles a script node's source into a node type named `type`.
|
|
5
5
|
*
|
|
@@ -62,5 +62,4 @@ export function run({ a, b }, { scale }, ctx) {
|
|
|
62
62
|
return { result: (a + b) * scale };
|
|
63
63
|
}
|
|
64
64
|
`;
|
|
65
|
-
//#endregion
|
|
66
65
|
export { SCRIPT_NODE_TEMPLATE, compileNodeScript };
|
package/dist/graph/sources.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/graph/sources.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The built-in nodes as script modules: the same interface and behaviour as the TypeScript
|
|
4
3
|
* definitions in `nodes.ts`, written self-contained so the editor can show a built-in's code
|
|
@@ -7,5 +6,4 @@
|
|
|
7
6
|
* @module
|
|
8
7
|
*/
|
|
9
8
|
/** @category Graph */
|
|
10
|
-
export declare const BUILTIN_SOURCES: Record<string, string>;
|
|
11
|
-
//#endregion
|
|
9
|
+
export declare const BUILTIN_SOURCES: Record<string, string>;
|
package/dist/graph/sources.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/graph/sources.ts
|
|
2
2
|
/**
|
|
3
3
|
* The built-in nodes as script modules: the same interface and behaviour as the TypeScript
|
|
4
4
|
* definitions in `nodes.ts`, written self-contained so the editor can show a built-in's code
|
|
@@ -259,5 +259,4 @@ export function run({ list, every, offset }) {
|
|
|
259
259
|
}
|
|
260
260
|
`
|
|
261
261
|
};
|
|
262
|
-
//#endregion
|
|
263
262
|
export { BUILTIN_SOURCES };
|
package/dist/graph/subgraph.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { NodeRegistry, NodeSpec } from "./node.js";
|
|
2
1
|
import { GraphDoc, GraphNode, SubgraphDef } from "./doc.js";
|
|
3
|
-
|
|
2
|
+
import { NodeRegistry, NodeSpec } from "./node.js";
|
|
4
3
|
/**
|
|
5
4
|
* Subgraphs: a selection of nodes collapsed into one node type. The inner graph is stored in
|
|
6
5
|
* `doc.subgraphs[type]` with its interface — every wire that crossed the selection's edge
|
|
@@ -32,5 +31,4 @@ export declare function collapseToSubgraph(doc: GraphDoc, registry: NodeRegistry
|
|
|
32
31
|
* `defs`: where the definitions are (default: `doc.subgraphs`; pass the top-level document's
|
|
33
32
|
* when `doc` is itself a subgraph's inner graph).
|
|
34
33
|
*/
|
|
35
|
-
export declare function expandSubgraph(doc: GraphDoc, nodeId: string, defs?: Record<string, SubgraphDef> | undefined): string[];
|
|
36
|
-
//#endregion
|
|
34
|
+
export declare function expandSubgraph(doc: GraphDoc, nodeId: string, defs?: Record<string, SubgraphDef> | undefined): string[];
|
package/dist/graph/subgraph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getNode, graphId } from "./doc.js";
|
|
2
2
|
import { GraphEvaluator, OUTPUT_LISTS } from "./evaluate.js";
|
|
3
|
-
|
|
3
|
+
// src/graph/subgraph.ts
|
|
4
4
|
/**
|
|
5
5
|
* Subgraphs: a selection of nodes collapsed into one node type. The inner graph is stored in
|
|
6
6
|
* `doc.subgraphs[type]` with its interface — every wire that crossed the selection's edge
|
|
@@ -276,5 +276,4 @@ function expandSubgraph(doc, nodeId, defs = doc.subgraphs) {
|
|
|
276
276
|
doc.nodes = doc.nodes.filter((n) => n.id !== nodeId);
|
|
277
277
|
return [...ids.values()];
|
|
278
278
|
}
|
|
279
|
-
//#endregion
|
|
280
279
|
export { collapseToSubgraph, expandSubgraph, freeSubgraphType, registerSubgraphs, subgraphSpec };
|
package/dist/graph/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/graph/types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Pin types. A type is a name (`number`, `vec2`, your own…) with a color for the editor;
|
|
4
3
|
* a trailing `[]` in a port declaration (`vec2[]`) makes the port a **list port** — it takes
|
|
@@ -52,5 +51,4 @@ export declare class TypeRegistry {
|
|
|
52
51
|
*
|
|
53
52
|
* @category Graph
|
|
54
53
|
*/
|
|
55
|
-
export declare const portTypes: TypeRegistry;
|
|
56
|
-
//#endregion
|
|
54
|
+
export declare const portTypes: TypeRegistry;
|
package/dist/graph/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/graph/types.ts
|
|
2
2
|
/** @category Graph */
|
|
3
3
|
function parseType(type) {
|
|
4
4
|
const t = type.trim();
|
|
@@ -63,5 +63,4 @@ portTypes.define("string", "#e86fb0");
|
|
|
63
63
|
portTypes.define("color", "#f2a541");
|
|
64
64
|
portTypes.define("vec2", "#4ea8de");
|
|
65
65
|
portTypes.define("vec3", "#9b6dde");
|
|
66
|
-
//#endregion
|
|
67
66
|
export { TypeRegistry, parseType, portTypes };
|
package/dist/graph.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rng = require("./rng-
|
|
3
|
-
|
|
2
|
+
const require_rng = require("./rng-edL6atS3.cjs");
|
|
3
|
+
// src/graph/types.ts
|
|
4
4
|
/** @category Graph */
|
|
5
5
|
function parseType(type) {
|
|
6
6
|
const t = type.trim();
|
|
@@ -65,8 +65,7 @@ portTypes.define("string", "#e86fb0");
|
|
|
65
65
|
portTypes.define("color", "#f2a541");
|
|
66
66
|
portTypes.define("vec2", "#4ea8de");
|
|
67
67
|
portTypes.define("vec3", "#9b6dde");
|
|
68
|
-
|
|
69
|
-
//#region src/graph/doc.ts
|
|
68
|
+
// src/graph/doc.ts
|
|
70
69
|
/**
|
|
71
70
|
* The graph document: plain JSON, saved and shared as-is.
|
|
72
71
|
*
|
|
@@ -236,8 +235,7 @@ function reaches(doc, start, target) {
|
|
|
236
235
|
function clone(v) {
|
|
237
236
|
return v !== null && typeof v === "object" ? structuredClone(v) : v;
|
|
238
237
|
}
|
|
239
|
-
|
|
240
|
-
//#region src/graph/evaluate.ts
|
|
238
|
+
// src/graph/evaluate.ts
|
|
241
239
|
/**
|
|
242
240
|
* Evaluates a graph: runs the nodes the outputs depend on, in dependency order, passing
|
|
243
241
|
* values along the links.
|
|
@@ -553,8 +551,7 @@ function safeKey(parts) {
|
|
|
553
551
|
}
|
|
554
552
|
}
|
|
555
553
|
const now = () => typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
556
|
-
|
|
557
|
-
//#region src/graph/node.ts
|
|
554
|
+
// src/graph/node.ts
|
|
558
555
|
let revisionCounter = 0;
|
|
559
556
|
function port(name, spec) {
|
|
560
557
|
const s = typeof spec === "string" ? { type: spec } : spec;
|
|
@@ -645,8 +642,7 @@ var NodeRegistry = class {
|
|
|
645
642
|
return () => this.listeners.delete(listener);
|
|
646
643
|
}
|
|
647
644
|
};
|
|
648
|
-
|
|
649
|
-
//#region src/graph/sources.ts
|
|
645
|
+
// src/graph/sources.ts
|
|
650
646
|
/**
|
|
651
647
|
* The built-in nodes as script modules: the same interface and behaviour as the TypeScript
|
|
652
648
|
* definitions in `nodes.ts`, written self-contained so the editor can show a built-in's code
|
|
@@ -907,8 +903,7 @@ export function run({ list, every, offset }) {
|
|
|
907
903
|
}
|
|
908
904
|
`
|
|
909
905
|
};
|
|
910
|
-
|
|
911
|
-
//#region src/graph/nodes.ts
|
|
906
|
+
// src/graph/nodes.ts
|
|
912
907
|
const v2 = (x = 0, y = 0) => ({
|
|
913
908
|
x,
|
|
914
909
|
y
|
|
@@ -1302,8 +1297,7 @@ function createNodeRegistry() {
|
|
|
1302
1297
|
});
|
|
1303
1298
|
return registry;
|
|
1304
1299
|
}
|
|
1305
|
-
|
|
1306
|
-
//#region src/graph/script.ts
|
|
1300
|
+
// src/graph/script.ts
|
|
1307
1301
|
/**
|
|
1308
1302
|
* Compiles a script node's source into a node type named `type`.
|
|
1309
1303
|
*
|
|
@@ -1366,8 +1360,7 @@ export function run({ a, b }, { scale }, ctx) {
|
|
|
1366
1360
|
return { result: (a + b) * scale };
|
|
1367
1361
|
}
|
|
1368
1362
|
`;
|
|
1369
|
-
|
|
1370
|
-
//#region src/graph/subgraph.ts
|
|
1363
|
+
// src/graph/subgraph.ts
|
|
1371
1364
|
/**
|
|
1372
1365
|
* Subgraphs: a selection of nodes collapsed into one node type. The inner graph is stored in
|
|
1373
1366
|
* `doc.subgraphs[type]` with its interface — every wire that crossed the selection's edge
|
|
@@ -1643,7 +1636,6 @@ function expandSubgraph(doc, nodeId, defs = doc.subgraphs) {
|
|
|
1643
1636
|
doc.nodes = doc.nodes.filter((n) => n.id !== nodeId);
|
|
1644
1637
|
return [...ids.values()];
|
|
1645
1638
|
}
|
|
1646
|
-
//#endregion
|
|
1647
1639
|
exports.BUILTIN_NODES = BUILTIN_NODES;
|
|
1648
1640
|
exports.BUILTIN_SOURCES = BUILTIN_SOURCES;
|
|
1649
1641
|
exports.GRAPH_FORMAT = GRAPH_FORMAT;
|