@fundamental-engine/core 0.4.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/LICENSE +21 -0
- package/README.md +128 -0
- package/dist/agents/element-agent.d.ts +38 -0
- package/dist/agents/element-agent.d.ts.map +1 -0
- package/dist/agents/element-agent.js +70 -0
- package/dist/agents/element-agent.js.map +1 -0
- package/dist/agents/event-agent.d.ts +47 -0
- package/dist/agents/event-agent.d.ts.map +1 -0
- package/dist/agents/event-agent.js +82 -0
- package/dist/agents/event-agent.js.map +1 -0
- package/dist/agents/index.d.ts +17 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +57 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/region-agents.d.ts +40 -0
- package/dist/agents/region-agents.d.ts.map +1 -0
- package/dist/agents/region-agents.js +22 -0
- package/dist/agents/region-agents.js.map +1 -0
- package/dist/agents/relationship.d.ts +55 -0
- package/dist/agents/relationship.d.ts.map +1 -0
- package/dist/agents/relationship.js +40 -0
- package/dist/agents/relationship.js.map +1 -0
- package/dist/agents/user-agent.d.ts +57 -0
- package/dist/agents/user-agent.d.ts.map +1 -0
- package/dist/agents/user-agent.js +45 -0
- package/dist/agents/user-agent.js.map +1 -0
- package/dist/config/forces.config.d.ts +101 -0
- package/dist/config/forces.config.d.ts.map +1 -0
- package/dist/config/forces.config.js +239 -0
- package/dist/config/forces.config.js.map +1 -0
- package/dist/config/manual.d.ts +134 -0
- package/dist/config/manual.d.ts.map +1 -0
- package/dist/config/manual.js +604 -0
- package/dist/config/manual.js.map +1 -0
- package/dist/config/palettes.d.ts +18 -0
- package/dist/config/palettes.d.ts.map +1 -0
- package/dist/config/palettes.js +34 -0
- package/dist/config/palettes.js.map +1 -0
- package/dist/config/presets.d.ts +48 -0
- package/dist/config/presets.d.ts.map +1 -0
- package/dist/config/presets.js +87 -0
- package/dist/config/presets.js.map +1 -0
- package/dist/config/tokens.d.ts +3 -0
- package/dist/config/tokens.d.ts.map +1 -0
- package/dist/config/tokens.js +16 -0
- package/dist/config/tokens.js.map +1 -0
- package/dist/conformance/expectations.d.ts +40 -0
- package/dist/conformance/expectations.d.ts.map +1 -0
- package/dist/conformance/expectations.js +347 -0
- package/dist/conformance/expectations.js.map +1 -0
- package/dist/conformance/experiments.d.ts +17 -0
- package/dist/conformance/experiments.d.ts.map +1 -0
- package/dist/conformance/experiments.js +875 -0
- package/dist/conformance/experiments.js.map +1 -0
- package/dist/conformance/run.d.ts +18 -0
- package/dist/conformance/run.d.ts.map +1 -0
- package/dist/conformance/run.js +240 -0
- package/dist/conformance/run.js.map +1 -0
- package/dist/conformance/types.d.ts +100 -0
- package/dist/conformance/types.d.ts.map +1 -0
- package/dist/conformance/types.js +2 -0
- package/dist/conformance/types.js.map +1 -0
- package/dist/contracts/guards.d.ts +51 -0
- package/dist/contracts/guards.d.ts.map +1 -0
- package/dist/contracts/guards.js +100 -0
- package/dist/contracts/guards.js.map +1 -0
- package/dist/contracts/index.d.ts +18 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +107 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/passport.d.ts +88 -0
- package/dist/contracts/passport.d.ts.map +1 -0
- package/dist/contracts/passport.js +135 -0
- package/dist/contracts/passport.js.map +1 -0
- package/dist/contracts/types.d.ts +120 -0
- package/dist/contracts/types.d.ts.map +1 -0
- package/dist/contracts/types.js +24 -0
- package/dist/contracts/types.js.map +1 -0
- package/dist/core/accretion.d.ts +50 -0
- package/dist/core/accretion.d.ts.map +1 -0
- package/dist/core/accretion.js +98 -0
- package/dist/core/accretion.js.map +1 -0
- package/dist/core/agents.d.ts +31 -0
- package/dist/core/agents.d.ts.map +1 -0
- package/dist/core/agents.js +51 -0
- package/dist/core/agents.js.map +1 -0
- package/dist/core/attention.d.ts +72 -0
- package/dist/core/attention.d.ts.map +1 -0
- package/dist/core/attention.js +122 -0
- package/dist/core/attention.js.map +1 -0
- package/dist/core/causality.d.ts +38 -0
- package/dist/core/causality.d.ts.map +1 -0
- package/dist/core/causality.js +64 -0
- package/dist/core/causality.js.map +1 -0
- package/dist/core/conditions.d.ts +10 -0
- package/dist/core/conditions.d.ts.map +1 -0
- package/dist/core/conditions.js +22 -0
- package/dist/core/conditions.js.map +1 -0
- package/dist/core/currents.d.ts +53 -0
- package/dist/core/currents.d.ts.map +1 -0
- package/dist/core/currents.js +65 -0
- package/dist/core/currents.js.map +1 -0
- package/dist/core/dock.d.ts +35 -0
- package/dist/core/dock.d.ts.map +1 -0
- package/dist/core/dock.js +39 -0
- package/dist/core/dock.js.map +1 -0
- package/dist/core/events.d.ts +23 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +34 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/feedback-sink.d.ts +32 -0
- package/dist/core/feedback-sink.d.ts.map +1 -0
- package/dist/core/feedback-sink.js +53 -0
- package/dist/core/feedback-sink.js.map +1 -0
- package/dist/core/feedback.d.ts +11 -0
- package/dist/core/feedback.d.ts.map +1 -0
- package/dist/core/feedback.js +16 -0
- package/dist/core/feedback.js.map +1 -0
- package/dist/core/field-store.d.ts +26 -0
- package/dist/core/field-store.d.ts.map +1 -0
- package/dist/core/field-store.js +54 -0
- package/dist/core/field-store.js.map +1 -0
- package/dist/core/field.d.ts +18 -0
- package/dist/core/field.d.ts.map +1 -0
- package/dist/core/field.js +1943 -0
- package/dist/core/field.js.map +1 -0
- package/dist/core/fieldline-seeds.d.ts +25 -0
- package/dist/core/fieldline-seeds.d.ts.map +1 -0
- package/dist/core/fieldline-seeds.js +32 -0
- package/dist/core/fieldline-seeds.js.map +1 -0
- package/dist/core/fieldlines.d.ts +75 -0
- package/dist/core/fieldlines.d.ts.map +1 -0
- package/dist/core/fieldlines.js +111 -0
- package/dist/core/fieldlines.js.map +1 -0
- package/dist/core/flow.d.ts +38 -0
- package/dist/core/flow.d.ts.map +1 -0
- package/dist/core/flow.js +27 -0
- package/dist/core/flow.js.map +1 -0
- package/dist/core/formations.d.ts +11 -0
- package/dist/core/formations.d.ts.map +1 -0
- package/dist/core/formations.js +22 -0
- package/dist/core/formations.js.map +1 -0
- package/dist/core/geometry.d.ts +67 -0
- package/dist/core/geometry.d.ts.map +1 -0
- package/dist/core/geometry.js +68 -0
- package/dist/core/geometry.js.map +1 -0
- package/dist/core/heatmap.d.ts +22 -0
- package/dist/core/heatmap.d.ts.map +1 -0
- package/dist/core/heatmap.js +55 -0
- package/dist/core/heatmap.js.map +1 -0
- package/dist/core/host.d.ts +46 -0
- package/dist/core/host.d.ts.map +1 -0
- package/dist/core/host.js +11 -0
- package/dist/core/host.js.map +1 -0
- package/dist/core/integrator.d.ts +24 -0
- package/dist/core/integrator.d.ts.map +1 -0
- package/dist/core/integrator.js +375 -0
- package/dist/core/integrator.js.map +1 -0
- package/dist/core/math.d.ts +37 -0
- package/dist/core/math.d.ts.map +1 -0
- package/dist/core/math.js +77 -0
- package/dist/core/math.js.map +1 -0
- package/dist/core/reactions.d.ts +32 -0
- package/dist/core/reactions.d.ts.map +1 -0
- package/dist/core/reactions.js +45 -0
- package/dist/core/reactions.js.map +1 -0
- package/dist/core/registry.d.ts +13 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +20 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/render-backend.d.ts +46 -0
- package/dist/core/render-backend.d.ts.map +1 -0
- package/dist/core/render-backend.js +75 -0
- package/dist/core/render-backend.js.map +1 -0
- package/dist/core/render-modes.d.ts +42 -0
- package/dist/core/render-modes.d.ts.map +1 -0
- package/dist/core/render-modes.js +141 -0
- package/dist/core/render-modes.js.map +1 -0
- package/dist/core/reservoir.d.ts +43 -0
- package/dist/core/reservoir.d.ts.map +1 -0
- package/dist/core/reservoir.js +207 -0
- package/dist/core/reservoir.js.map +1 -0
- package/dist/core/scalar-grid.d.ts +51 -0
- package/dist/core/scalar-grid.d.ts.map +1 -0
- package/dist/core/scalar-grid.js +146 -0
- package/dist/core/scalar-grid.js.map +1 -0
- package/dist/core/scanner.d.ts +59 -0
- package/dist/core/scanner.d.ts.map +1 -0
- package/dist/core/scanner.js +260 -0
- package/dist/core/scanner.js.map +1 -0
- package/dist/core/shadow.d.ts +69 -0
- package/dist/core/shadow.d.ts.map +1 -0
- package/dist/core/shadow.js +84 -0
- package/dist/core/shadow.js.map +1 -0
- package/dist/core/spatial-hash.d.ts +30 -0
- package/dist/core/spatial-hash.d.ts.map +1 -0
- package/dist/core/spatial-hash.js +64 -0
- package/dist/core/spatial-hash.js.map +1 -0
- package/dist/core/streamlines.d.ts +29 -0
- package/dist/core/streamlines.d.ts.map +1 -0
- package/dist/core/streamlines.js +70 -0
- package/dist/core/streamlines.js.map +1 -0
- package/dist/core/surface.d.ts +19 -0
- package/dist/core/surface.d.ts.map +1 -0
- package/dist/core/surface.js +21 -0
- package/dist/core/surface.js.map +1 -0
- package/dist/core/temporal.d.ts +110 -0
- package/dist/core/temporal.d.ts.map +1 -0
- package/dist/core/temporal.js +139 -0
- package/dist/core/temporal.js.map +1 -0
- package/dist/core/thermo.d.ts +48 -0
- package/dist/core/thermo.d.ts.map +1 -0
- package/dist/core/thermo.js +48 -0
- package/dist/core/thermo.js.map +1 -0
- package/dist/core/types.d.ts +610 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/weights.d.ts +111 -0
- package/dist/core/weights.d.ts.map +1 -0
- package/dist/core/weights.js +128 -0
- package/dist/core/weights.js.map +1 -0
- package/dist/diagnostics/energy.d.ts +21 -0
- package/dist/diagnostics/energy.d.ts.map +1 -0
- package/dist/diagnostics/energy.js +27 -0
- package/dist/diagnostics/energy.js.map +1 -0
- package/dist/diagnostics/fields.d.ts +23 -0
- package/dist/diagnostics/fields.d.ts.map +1 -0
- package/dist/diagnostics/fields.js +30 -0
- package/dist/diagnostics/fields.js.map +1 -0
- package/dist/diagnostics/index.d.ts +46 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +23 -0
- package/dist/diagnostics/index.js.map +1 -0
- package/dist/diagnostics/modes.d.ts +108 -0
- package/dist/diagnostics/modes.d.ts.map +1 -0
- package/dist/diagnostics/modes.js +181 -0
- package/dist/diagnostics/modes.js.map +1 -0
- package/dist/diagnostics/potential.d.ts +30 -0
- package/dist/diagnostics/potential.d.ts.map +1 -0
- package/dist/diagnostics/potential.js +43 -0
- package/dist/diagnostics/potential.js.map +1 -0
- package/dist/diagnostics/probes.d.ts +31 -0
- package/dist/diagnostics/probes.d.ts.map +1 -0
- package/dist/diagnostics/probes.js +61 -0
- package/dist/diagnostics/probes.js.map +1 -0
- package/dist/diagnostics/render.d.ts +49 -0
- package/dist/diagnostics/render.d.ts.map +1 -0
- package/dist/diagnostics/render.js +132 -0
- package/dist/diagnostics/render.js.map +1 -0
- package/dist/export.d.ts +18 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +17 -0
- package/dist/export.js.map +1 -0
- package/dist/forces/extended.d.ts +121 -0
- package/dist/forces/extended.d.ts.map +1 -0
- package/dist/forces/extended.js +674 -0
- package/dist/forces/extended.js.map +1 -0
- package/dist/forces/index.d.ts +33 -0
- package/dist/forces/index.d.ts.map +1 -0
- package/dist/forces/index.js +237 -0
- package/dist/forces/index.js.map +1 -0
- package/dist/forces/natural.d.ts +106 -0
- package/dist/forces/natural.d.ts.map +1 -0
- package/dist/forces/natural.js +385 -0
- package/dist/forces/natural.js.map +1 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect/budget.d.ts +17 -0
- package/dist/inspect/budget.d.ts.map +1 -0
- package/dist/inspect/budget.js +19 -0
- package/dist/inspect/budget.js.map +1 -0
- package/dist/inspect/index.d.ts +10 -0
- package/dist/inspect/index.d.ts.map +1 -0
- package/dist/inspect/index.js +10 -0
- package/dist/inspect/index.js.map +1 -0
- package/dist/inspect/report.d.ts +17 -0
- package/dist/inspect/report.d.ts.map +1 -0
- package/dist/inspect/report.js +44 -0
- package/dist/inspect/report.js.map +1 -0
- package/dist/inspect/snapshot.d.ts +21 -0
- package/dist/inspect/snapshot.d.ts.map +1 -0
- package/dist/inspect/snapshot.js +30 -0
- package/dist/inspect/snapshot.js.map +1 -0
- package/dist/recipes/catalog.d.ts +51 -0
- package/dist/recipes/catalog.d.ts.map +1 -0
- package/dist/recipes/catalog.js +1496 -0
- package/dist/recipes/catalog.js.map +1 -0
- package/dist/recipes/charge.d.ts +18 -0
- package/dist/recipes/charge.d.ts.map +1 -0
- package/dist/recipes/charge.js +27 -0
- package/dist/recipes/charge.js.map +1 -0
- package/dist/recipes/compile.d.ts +93 -0
- package/dist/recipes/compile.d.ts.map +1 -0
- package/dist/recipes/compile.js +113 -0
- package/dist/recipes/compile.js.map +1 -0
- package/dist/recipes/explain.d.ts +8 -0
- package/dist/recipes/explain.d.ts.map +1 -0
- package/dist/recipes/explain.js +46 -0
- package/dist/recipes/explain.js.map +1 -0
- package/dist/recipes/gallery.d.ts +6 -0
- package/dist/recipes/gallery.d.ts.map +1 -0
- package/dist/recipes/gallery.js +6 -0
- package/dist/recipes/gallery.js.map +1 -0
- package/dist/recipes/gravity.d.ts +16 -0
- package/dist/recipes/gravity.d.ts.map +1 -0
- package/dist/recipes/gravity.js +27 -0
- package/dist/recipes/gravity.js.map +1 -0
- package/dist/recipes/index.d.ts +18 -0
- package/dist/recipes/index.d.ts.map +1 -0
- package/dist/recipes/index.js +36 -0
- package/dist/recipes/index.js.map +1 -0
- package/dist/recipes/intent.d.ts +44 -0
- package/dist/recipes/intent.d.ts.map +1 -0
- package/dist/recipes/intent.js +46 -0
- package/dist/recipes/intent.js.map +1 -0
- package/dist/recipes/schema.d.ts +103 -0
- package/dist/recipes/schema.d.ts.map +1 -0
- package/dist/recipes/schema.js +123 -0
- package/dist/recipes/schema.js.map +1 -0
- package/dist/recipes/wayfinding.d.ts +39 -0
- package/dist/recipes/wayfinding.d.ts.map +1 -0
- package/dist/recipes/wayfinding.js +77 -0
- package/dist/recipes/wayfinding.js.map +1 -0
- package/dist/semantic/index.d.ts +13 -0
- package/dist/semantic/index.d.ts.map +1 -0
- package/dist/semantic/index.js +31 -0
- package/dist/semantic/index.js.map +1 -0
- package/dist/semantic/layers.d.ts +24 -0
- package/dist/semantic/layers.d.ts.map +1 -0
- package/dist/semantic/layers.js +27 -0
- package/dist/semantic/layers.js.map +1 -0
- package/dist/semantic/materials.d.ts +20 -0
- package/dist/semantic/materials.d.ts.map +1 -0
- package/dist/semantic/materials.js +17 -0
- package/dist/semantic/materials.js.map +1 -0
- package/dist/semantic/states.d.ts +11 -0
- package/dist/semantic/states.d.ts.map +1 -0
- package/dist/semantic/states.js +26 -0
- package/dist/semantic/states.js.map +1 -0
- package/dist/visual/channels.d.ts +71 -0
- package/dist/visual/channels.d.ts.map +1 -0
- package/dist/visual/channels.js +70 -0
- package/dist/visual/channels.js.map +1 -0
- package/dist/visual/index.d.ts +39 -0
- package/dist/visual/index.d.ts.map +1 -0
- package/dist/visual/index.js +30 -0
- package/dist/visual/index.js.map +1 -0
- package/dist/visual/lint.d.ts +41 -0
- package/dist/visual/lint.d.ts.map +1 -0
- package/dist/visual/lint.js +58 -0
- package/dist/visual/lint.js.map +1 -0
- package/dist/visual/mapping.d.ts +13 -0
- package/dist/visual/mapping.d.ts.map +1 -0
- package/dist/visual/mapping.js +43 -0
- package/dist/visual/mapping.js.map +1 -0
- package/dist/visual/semantic-text.d.ts +28 -0
- package/dist/visual/semantic-text.d.ts.map +1 -0
- package/dist/visual/semantic-text.js +36 -0
- package/dist/visual/semantic-text.js.map +1 -0
- package/dist/visual/tokens.d.ts +23 -0
- package/dist/visual/tokens.d.ts.map +1 -0
- package/dist/visual/tokens.js +54 -0
- package/dist/visual/tokens.js.map +1 -0
- package/dist/visual/visualization.d.ts +31 -0
- package/dist/visual/visualization.d.ts.map +1 -0
- package/dist/visual/visualization.js +47 -0
- package/dist/visual/visualization.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shaped-source geometry (field-systems plan, Stage A).
|
|
3
|
+
*
|
|
4
|
+
* A body is not a point. These pure helpers derive the geometry a shaped source needs
|
|
5
|
+
* from the rect we already measure each frame: the nearest point on the element's box
|
|
6
|
+
* (so matter shells the shape instead of collapsing to its centre), the signed distance
|
|
7
|
+
* to the box (negative inside), and the two poles of a dipole laid along the body's
|
|
8
|
+
* heading (so `magnetism`/`charge` can draw and act as real N→S / +→− fields).
|
|
9
|
+
*
|
|
10
|
+
* Nothing here touches particles or velocity. Stage B (the field-line render) and Stage C
|
|
11
|
+
* (shaped force sampling) consume these; this stage is groundwork with golden tests.
|
|
12
|
+
*/
|
|
13
|
+
import type { Vec2 } from './types.ts';
|
|
14
|
+
/** Guard against divide-by-zero when sampling a field at a pole (1px, sub-pixel). */
|
|
15
|
+
export declare const EPS = 1;
|
|
16
|
+
/** An axis-aligned box: centre + half-extents. The force-facing subset of `Body`. */
|
|
17
|
+
export interface Rect {
|
|
18
|
+
cx: number;
|
|
19
|
+
cy: number;
|
|
20
|
+
hw: number;
|
|
21
|
+
hh: number;
|
|
22
|
+
}
|
|
23
|
+
/** A box plus its heading and polarity — what `polePair` reads off a `Body`. */
|
|
24
|
+
export interface AxisRect extends Rect {
|
|
25
|
+
/** unit heading (cos θ, sin θ) from `data-angle`. */
|
|
26
|
+
ux: number;
|
|
27
|
+
uy: number;
|
|
28
|
+
/** polarity sign; which end carries the + / N pole. */
|
|
29
|
+
spin: number;
|
|
30
|
+
}
|
|
31
|
+
/** One pole of a dipole: a position and a signed charge (±1). */
|
|
32
|
+
export interface Pole {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
q: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The nearest point of the filled box to `(px, py)`. Outside the box this is the closest
|
|
39
|
+
* boundary point; inside, it is the point itself (the box is solid, so distance is zero).
|
|
40
|
+
* Shaped attract/gravity pull toward this instead of the centre, so matter gathers in a
|
|
41
|
+
* shell around the element rather than a blob at its middle.
|
|
42
|
+
*/
|
|
43
|
+
export declare function nearestOnRect(px: number, py: number, r: Rect): Vec2;
|
|
44
|
+
/**
|
|
45
|
+
* Signed distance from `(px, py)` to the box: negative inside, zero on the edge, positive
|
|
46
|
+
* outside (the standard 2D box SDF). Falloffs key off this so the field references the
|
|
47
|
+
* element's surface, not an arbitrary centre distance.
|
|
48
|
+
*/
|
|
49
|
+
export declare function sdfRect(px: number, py: number, r: Rect): number;
|
|
50
|
+
/**
|
|
51
|
+
* The two poles of the body's dipole, laid on its heading axis at the box edge. The `+`
|
|
52
|
+
* (N) pole sits at the `+(ux, uy)` end, the `−` (S) pole at the other; `spin < 0` swaps
|
|
53
|
+
* them. `reach` is the centre-to-edge distance along the heading (the ray/box exit), so a
|
|
54
|
+
* wide element makes a long magnet and a tall one a short, fat magnet. Strength is applied
|
|
55
|
+
* by the consumer (`field()`), not here — this returns geometry and polarity only.
|
|
56
|
+
*/
|
|
57
|
+
export declare function polePair(b: AxisRect): [Pole, Pole];
|
|
58
|
+
/**
|
|
59
|
+
* The in-plane field of a set of poles at `(x, y)`: the superposition of each pole's
|
|
60
|
+
* radial `q/d²` monopole field (away from `+`, toward `−`). For the two poles of a body
|
|
61
|
+
* this is the classic dipole, whose streamlines are the bar-magnet (N→S) and
|
|
62
|
+
* electric-dipole (+→−) field-line diagrams. `EPS` floors the distance at a pole so the
|
|
63
|
+
* sample never divides by zero. Direction carries the geometry; magnitude (scaled by the
|
|
64
|
+
* body's strength downstream) sets line density and the tracer's min-strength cutoff.
|
|
65
|
+
*/
|
|
66
|
+
export declare function dipoleField(poles: readonly Pole[], x: number, y: number): Vec2;
|
|
67
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/core/geometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,qFAAqF;AACrF,eAAO,MAAM,GAAG,IAAI,CAAC;AAErB,qFAAqF;AACrF,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,gFAAgF;AAChF,MAAM,WAAW,QAAS,SAAQ,IAAI;IACpC,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,iEAAiE;AACjE,MAAM,WAAW,IAAI;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAKnE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAM/D;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAWlD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAY9E"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { clamp } from "./math.js";
|
|
2
|
+
/** Guard against divide-by-zero when sampling a field at a pole (1px, sub-pixel). */
|
|
3
|
+
export const EPS = 1;
|
|
4
|
+
/**
|
|
5
|
+
* The nearest point of the filled box to `(px, py)`. Outside the box this is the closest
|
|
6
|
+
* boundary point; inside, it is the point itself (the box is solid, so distance is zero).
|
|
7
|
+
* Shaped attract/gravity pull toward this instead of the centre, so matter gathers in a
|
|
8
|
+
* shell around the element rather than a blob at its middle.
|
|
9
|
+
*/
|
|
10
|
+
export function nearestOnRect(px, py, r) {
|
|
11
|
+
return {
|
|
12
|
+
x: clamp(px, r.cx - r.hw, r.cx + r.hw),
|
|
13
|
+
y: clamp(py, r.cy - r.hh, r.cy + r.hh),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Signed distance from `(px, py)` to the box: negative inside, zero on the edge, positive
|
|
18
|
+
* outside (the standard 2D box SDF). Falloffs key off this so the field references the
|
|
19
|
+
* element's surface, not an arbitrary centre distance.
|
|
20
|
+
*/
|
|
21
|
+
export function sdfRect(px, py, r) {
|
|
22
|
+
const dx = Math.abs(px - r.cx) - r.hw;
|
|
23
|
+
const dy = Math.abs(py - r.cy) - r.hh;
|
|
24
|
+
const outside = Math.hypot(Math.max(dx, 0), Math.max(dy, 0));
|
|
25
|
+
const inside = Math.min(Math.max(dx, dy), 0);
|
|
26
|
+
return outside + inside;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The two poles of the body's dipole, laid on its heading axis at the box edge. The `+`
|
|
30
|
+
* (N) pole sits at the `+(ux, uy)` end, the `−` (S) pole at the other; `spin < 0` swaps
|
|
31
|
+
* them. `reach` is the centre-to-edge distance along the heading (the ray/box exit), so a
|
|
32
|
+
* wide element makes a long magnet and a tall one a short, fat magnet. Strength is applied
|
|
33
|
+
* by the consumer (`field()`), not here — this returns geometry and polarity only.
|
|
34
|
+
*/
|
|
35
|
+
export function polePair(b) {
|
|
36
|
+
const tx = b.ux !== 0 ? b.hw / Math.abs(b.ux) : Infinity;
|
|
37
|
+
const ty = b.uy !== 0 ? b.hh / Math.abs(b.uy) : Infinity;
|
|
38
|
+
const reach = Math.min(tx, ty); // centre → box edge along the heading
|
|
39
|
+
const ax = b.ux * reach;
|
|
40
|
+
const ay = b.uy * reach;
|
|
41
|
+
const s = b.spin < 0 ? -1 : 1;
|
|
42
|
+
return [
|
|
43
|
+
{ x: b.cx + ax, y: b.cy + ay, q: s },
|
|
44
|
+
{ x: b.cx - ax, y: b.cy - ay, q: -s },
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The in-plane field of a set of poles at `(x, y)`: the superposition of each pole's
|
|
49
|
+
* radial `q/d²` monopole field (away from `+`, toward `−`). For the two poles of a body
|
|
50
|
+
* this is the classic dipole, whose streamlines are the bar-magnet (N→S) and
|
|
51
|
+
* electric-dipole (+→−) field-line diagrams. `EPS` floors the distance at a pole so the
|
|
52
|
+
* sample never divides by zero. Direction carries the geometry; magnitude (scaled by the
|
|
53
|
+
* body's strength downstream) sets line density and the tracer's min-strength cutoff.
|
|
54
|
+
*/
|
|
55
|
+
export function dipoleField(poles, x, y) {
|
|
56
|
+
let fx = 0;
|
|
57
|
+
let fy = 0;
|
|
58
|
+
for (const p of poles) {
|
|
59
|
+
const dx = x - p.x;
|
|
60
|
+
const dy = y - p.y;
|
|
61
|
+
const d = Math.max(EPS, Math.hypot(dx, dy));
|
|
62
|
+
const k = p.q / (d * d); // radial monopole, 1/d² falloff
|
|
63
|
+
fx += (dx / d) * k;
|
|
64
|
+
fy += (dy / d) * k;
|
|
65
|
+
}
|
|
66
|
+
return { x: fx, y: fy };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/core/geometry.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,qFAAqF;AACrF,MAAM,CAAC,MAAM,GAAG,GAAG,CA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KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAC5C,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gCAAgC;QACzD,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACnB,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Particle } from './types.ts';
|
|
2
|
+
export declare class Heatmap {
|
|
3
|
+
private grid;
|
|
4
|
+
/** eased running peak, for flicker-free normalization. */
|
|
5
|
+
private peak;
|
|
6
|
+
/** grid resolution in px (the render samples on this lattice). */
|
|
7
|
+
readonly cell = 24;
|
|
8
|
+
constructor(width: number, height: number);
|
|
9
|
+
resize(width: number, height: number): void;
|
|
10
|
+
/**
|
|
11
|
+
* Zero every cell in the accumulation buffer and reset the peak tracker. Called by
|
|
12
|
+
* `setHeatmap(false)` so that re-enabling starts with a clean slate rather than
|
|
13
|
+
* carrying over stale density from a previous active period. Also the right call after
|
|
14
|
+
* a hard field reset where continuity of the heat history would be misleading.
|
|
15
|
+
*/
|
|
16
|
+
clear(): void;
|
|
17
|
+
/** Deposit the current particle field, decay + blur, and track the peak. Call once a frame. */
|
|
18
|
+
update(particles: readonly Particle[]): void;
|
|
19
|
+
/** Normalized density ∈ [0, 1] at a point — for the glow render and DOM write-back. */
|
|
20
|
+
norm(x: number, y: number): number;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=heatmap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heatmap.d.ts","sourceRoot":"","sources":["../../src/core/heatmap.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM3C,qBAAa,OAAO;IAClB,OAAO,CAAC,IAAI,CAAiB;IAC7B,0DAA0D;IAC1D,OAAO,CAAC,IAAI,CAAQ;IACpB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,MAAQ;gBAET,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAIzC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAI3C;;;;;OAKG;IACH,KAAK,IAAI,IAAI;IAKb,+FAA+F;IAC/F,MAAM,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI;IAU5C,uFAAuF;IACvF,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;CAGnC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heatmaps (field-systems plan, H1) — a scalar field buffer that reveals where field state
|
|
3
|
+
* accumulates, rendered as a diagnostic/ambient layer and sampled back into DOM. NOT a force:
|
|
4
|
+
* it measures, it does not push (docs/engine-reference/forces-fields-plan.md, D5).
|
|
5
|
+
*
|
|
6
|
+
* H1 ships the **density** layer: each frame every particle deposits into a coarse grid that
|
|
7
|
+
* decays and lightly blurs, so the buffer tracks where matter currently gathers. Values are
|
|
8
|
+
* normalized to [0, 1] by an eased running peak, so the glow render and the
|
|
9
|
+
* `--field-heatmap-density` write-back are stable and resolution-independent. Built on the
|
|
10
|
+
* existing class-[C] `ScalarGridImpl`, the same buffer the diffuse/wave/memory forces use.
|
|
11
|
+
*/
|
|
12
|
+
import { ScalarGridImpl } from "./scalar-grid.js";
|
|
13
|
+
import { clamp } from "./math.js";
|
|
14
|
+
const CELL = 24; // grid resolution in px — coarse, so the per-frame deposit + render is cheap
|
|
15
|
+
const DECAY = 0.12; // per-frame fade: high enough that the map tracks the CURRENT density
|
|
16
|
+
const BLUR = 0.22; // light diffusion, for a smooth glow rather than blocky cells
|
|
17
|
+
export class Heatmap {
|
|
18
|
+
grid;
|
|
19
|
+
/** eased running peak, for flicker-free normalization. */
|
|
20
|
+
peak = 1e-3;
|
|
21
|
+
/** grid resolution in px (the render samples on this lattice). */
|
|
22
|
+
cell = CELL;
|
|
23
|
+
constructor(width, height) {
|
|
24
|
+
this.grid = new ScalarGridImpl(Math.max(1, width), Math.max(1, height), 'diffuse', CELL);
|
|
25
|
+
}
|
|
26
|
+
resize(width, height) {
|
|
27
|
+
this.grid.resize(width, height);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Zero every cell in the accumulation buffer and reset the peak tracker. Called by
|
|
31
|
+
* `setHeatmap(false)` so that re-enabling starts with a clean slate rather than
|
|
32
|
+
* carrying over stale density from a previous active period. Also the right call after
|
|
33
|
+
* a hard field reset where continuity of the heat history would be misleading.
|
|
34
|
+
*/
|
|
35
|
+
clear() {
|
|
36
|
+
this.grid.clear();
|
|
37
|
+
this.peak = 1e-3;
|
|
38
|
+
}
|
|
39
|
+
/** Deposit the current particle field, decay + blur, and track the peak. Call once a frame. */
|
|
40
|
+
update(particles) {
|
|
41
|
+
for (const p of particles)
|
|
42
|
+
this.grid.deposit(p.x, p.y, 1);
|
|
43
|
+
this.grid.stepDiffuse(BLUR, DECAY);
|
|
44
|
+
const m = this.grid.max();
|
|
45
|
+
// ease the peak up fast (so a sudden spike normalizes promptly) and down slowly (so the
|
|
46
|
+
// map doesn't flare as the field empties); floored so we never divide by zero.
|
|
47
|
+
const k = m > this.peak ? 0.25 : 0.03;
|
|
48
|
+
this.peak += (Math.max(m, 1e-3) - this.peak) * k;
|
|
49
|
+
}
|
|
50
|
+
/** Normalized density ∈ [0, 1] at a point — for the glow render and DOM write-back. */
|
|
51
|
+
norm(x, y) {
|
|
52
|
+
return clamp(this.grid.sample(x, y) / this.peak, 0, 1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=heatmap.js.map
|
|
@@ -0,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C;QACnC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1B,wFAAwF;QACxF,+EAA+E;QAC/E,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACtC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC;IAED,uFAAuF;IACvF,IAAI,CAAC,CAAS,EAAE,CAAS;QACvB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldHost — the renderer/environment seam (Phase: frontier). `createField`'s engine is
|
|
3
|
+
* renderer-agnostic: every DOM-global touchpoint (viewport size, scroll, rAF, reduced-motion,
|
|
4
|
+
* visibility, the scan root, and event wiring) goes through this injected host instead of `window` /
|
|
5
|
+
* `document` / `requestAnimationFrame` directly. `browserHost()` (in `@fundamental-engine/platform`)
|
|
6
|
+
* binds it to the browser; an alternative host could drive the same engine from a headless renderer,
|
|
7
|
+
* a different document, or a test harness. This interface is pure types — no globals — so `field.ts`
|
|
8
|
+
* imports zero DOM (enforced by `dom-boundary.test.ts`).
|
|
9
|
+
*/
|
|
10
|
+
/** The host's current viewport, in CSS px plus device-pixel ratio. */
|
|
11
|
+
export interface HostViewport {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
dpr: number;
|
|
15
|
+
}
|
|
16
|
+
export interface FieldHost {
|
|
17
|
+
/** the subtree scanned for `[data-body]` / `[data-move]` / `[data-on]` / `[data-hot]` / `[data-formation]`. */
|
|
18
|
+
root: ParentNode;
|
|
19
|
+
/** the current viewport size + DPR (read each resize). */
|
|
20
|
+
viewport(): HostViewport;
|
|
21
|
+
/** current vertical scroll offset in px. */
|
|
22
|
+
scrollY(): number;
|
|
23
|
+
/** the scrollable height of the page (cached by the caller — reading it forces reflow). */
|
|
24
|
+
scrollHeight(): number;
|
|
25
|
+
/** whether the user prefers reduced motion (freezes the sim). */
|
|
26
|
+
reducedMotion(): boolean;
|
|
27
|
+
/** whether the surface is hidden (backgrounded tab) — pauses the loop. */
|
|
28
|
+
hidden(): boolean;
|
|
29
|
+
/** schedule the next frame; returns a handle. */
|
|
30
|
+
raf(cb: (t: number) => void): number;
|
|
31
|
+
/** cancel a scheduled frame. */
|
|
32
|
+
cancelRaf(id: number): void;
|
|
33
|
+
/** an offscreen canvas for the heatmap buffer. */
|
|
34
|
+
createCanvas(): HTMLCanvasElement;
|
|
35
|
+
/** subscribe to viewport-resize; returns an unsubscribe. */
|
|
36
|
+
onResize(cb: () => void): () => void;
|
|
37
|
+
/** subscribe to scroll; returns an unsubscribe. */
|
|
38
|
+
onScroll(cb: () => void): () => void;
|
|
39
|
+
/** subscribe to surface visibility changes; returns an unsubscribe. */
|
|
40
|
+
onVisibility(cb: () => void): () => void;
|
|
41
|
+
/** subscribe to user input activity (pointer/wheel/key/touch); returns an unsubscribe. */
|
|
42
|
+
onInput(cb: () => void): () => void;
|
|
43
|
+
/** subscribe to a composed shadow-DOM body event by name; returns an unsubscribe. */
|
|
44
|
+
onBodyEvent(type: string, cb: (e: Event) => void): () => void;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/core/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,SAAS;IACxB,+GAA+G;IAC/G,IAAI,EAAE,UAAU,CAAC;IACjB,0DAA0D;IAC1D,QAAQ,IAAI,YAAY,CAAC;IACzB,4CAA4C;IAC5C,OAAO,IAAI,MAAM,CAAC;IAClB,2FAA2F;IAC3F,YAAY,IAAI,MAAM,CAAC;IACvB,iEAAiE;IACjE,aAAa,IAAI,OAAO,CAAC;IACzB,0EAA0E;IAC1E,MAAM,IAAI,OAAO,CAAC;IAClB,iDAAiD;IACjD,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,CAAC;IACrC,gCAAgC;IAChC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kDAAkD;IAClD,YAAY,IAAI,iBAAiB,CAAC;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IACrC,mDAAmD;IACnD,QAAQ,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IACrC,uEAAuE;IACvE,YAAY,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IACzC,0FAA0F;IAC1F,OAAO,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IACpC,qFAAqF;IACrF,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC/D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FieldHost — the renderer/environment seam (Phase: frontier). `createField`'s engine is
|
|
3
|
+
* renderer-agnostic: every DOM-global touchpoint (viewport size, scroll, rAF, reduced-motion,
|
|
4
|
+
* visibility, the scan root, and event wiring) goes through this injected host instead of `window` /
|
|
5
|
+
* `document` / `requestAnimationFrame` directly. `browserHost()` (in `@fundamental-engine/platform`)
|
|
6
|
+
* binds it to the browser; an alternative host could drive the same engine from a headless renderer,
|
|
7
|
+
* a different document, or a test harness. This interface is pure types — no globals — so `field.ts`
|
|
8
|
+
* imports zero DOM (enforced by `dom-boundary.test.ts`).
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/core/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The integrator — advances the field one tick (§2.2, §7).
|
|
3
|
+
*
|
|
4
|
+
* For each free particle: apply DOM-body forces (§4), the formation bias (§7),
|
|
5
|
+
* then integrate and damp. Under first-class mass (§21.3) each additive body force is
|
|
6
|
+
* scaled by `1/m` as it applies, while velocity-replacing (`kinematic`) forces are left
|
|
7
|
+
* untouched. Reduced motion (`dt = 0`) freezes the sim (§18).
|
|
8
|
+
*/
|
|
9
|
+
import type { Body, ConditionRegistry, Env, ForceRegistry } from './types.ts';
|
|
10
|
+
import type { FieldStore } from './field-store.ts';
|
|
11
|
+
import { type Wave } from './currents.ts';
|
|
12
|
+
export declare const FRICTION = 0.95;
|
|
13
|
+
export declare const HEAT_DECAY = 0.972;
|
|
14
|
+
export interface StepInput {
|
|
15
|
+
store: FieldStore;
|
|
16
|
+
bodies: readonly Body[];
|
|
17
|
+
env: Env;
|
|
18
|
+
forces: ForceRegistry;
|
|
19
|
+
conditions: ConditionRegistry;
|
|
20
|
+
/** the carrier waves — free particles drift along their slope (§2.3). */
|
|
21
|
+
waves?: readonly Wave[];
|
|
22
|
+
}
|
|
23
|
+
export declare function step(input: StepInput): void;
|
|
24
|
+
//# sourceMappingURL=integrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrator.d.ts","sourceRoot":"","sources":["../../src/core/integrator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAS,aAAa,EAAY,MAAM,YAAY,CAAC;AAC/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAsB,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAK9D,eAAO,MAAM,QAAQ,OAAO,CAAC;AAC7B,eAAO,MAAM,UAAU,QAAQ,CAAC;AAGhC,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;IACxB,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;CACzB;AA2CD,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CA6S3C"}
|