@motionscript/math 0.1.0-alpha.4 → 0.1.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +132 -92
- package/README.md +39 -33
- package/dist/annotate/angle-mark.d.ts +52 -27
- package/dist/annotate/angle-mark.d.ts.map +1 -1
- package/dist/annotate/angle-mark.js +80 -115
- package/dist/annotate/angle-mark.js.map +1 -1
- package/dist/annotate/curly-brace.d.ts +59 -25
- package/dist/annotate/curly-brace.d.ts.map +1 -1
- package/dist/annotate/curly-brace.js +85 -100
- package/dist/annotate/curly-brace.js.map +1 -1
- package/dist/annotate/emphasis-mark.d.ts +43 -9
- package/dist/annotate/emphasis-mark.d.ts.map +1 -1
- package/dist/annotate/emphasis-mark.js +33 -34
- package/dist/annotate/emphasis-mark.js.map +1 -1
- package/dist/browser/chunks/chunk-ABYBW64J.js +2 -0
- package/dist/browser/chunks/chunk-ABYBW64J.js.map +7 -0
- package/dist/browser/chunks/chunk-K77KLQX4.js +2 -0
- package/dist/browser/chunks/chunk-K77KLQX4.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/tex.js +1 -1
- package/dist/browser/tex.js.map +2 -2
- package/dist/engine.d.ts +26 -19
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +17 -14
- package/dist/engine.js.map +1 -1
- package/dist/kit/component.d.ts +51 -0
- package/dist/kit/component.d.ts.map +1 -0
- package/dist/kit/component.js +30 -0
- package/dist/kit/component.js.map +1 -0
- package/dist/kit/curve.d.ts +22 -11
- package/dist/kit/curve.d.ts.map +1 -1
- package/dist/kit/curve.js +25 -18
- package/dist/kit/curve.js.map +1 -1
- package/dist/kit/field-mark.d.ts +58 -35
- package/dist/kit/field-mark.d.ts.map +1 -1
- package/dist/kit/field-mark.js +100 -120
- package/dist/kit/field-mark.js.map +1 -1
- package/dist/kit/follow.d.ts +67 -29
- package/dist/kit/follow.d.ts.map +1 -1
- package/dist/kit/follow.js +114 -110
- package/dist/kit/follow.js.map +1 -1
- package/dist/kit/furniture.d.ts +3 -1
- package/dist/kit/furniture.d.ts.map +1 -1
- package/dist/kit/furniture.js +5 -0
- package/dist/kit/furniture.js.map +1 -1
- package/dist/kit/graph.d.ts +46 -0
- package/dist/kit/graph.d.ts.map +1 -0
- package/dist/kit/graph.js +90 -0
- package/dist/kit/graph.js.map +1 -0
- package/dist/kit/mark.d.ts +64 -39
- package/dist/kit/mark.d.ts.map +1 -1
- package/dist/kit/mark.js +80 -96
- package/dist/kit/mark.js.map +1 -1
- package/dist/kit/place.d.ts +10 -8
- package/dist/kit/place.d.ts.map +1 -1
- package/dist/kit/place.js +28 -30
- package/dist/kit/place.js.map +1 -1
- package/dist/kit/system.d.ts +27 -29
- package/dist/kit/system.d.ts.map +1 -1
- package/dist/kit/system.js +62 -58
- package/dist/kit/system.js.map +1 -1
- package/dist/kit/withdrawn.d.ts +3 -3
- package/dist/kit/withdrawn.js +3 -3
- package/dist/kit/withdrawn.js.map +1 -1
- package/dist/marks/curve-area.d.ts +24 -18
- package/dist/marks/curve-area.d.ts.map +1 -1
- package/dist/marks/curve-area.js +50 -73
- package/dist/marks/curve-area.js.map +1 -1
- package/dist/marks/drop-lines.d.ts +28 -10
- package/dist/marks/drop-lines.d.ts.map +1 -1
- package/dist/marks/drop-lines.js +37 -52
- package/dist/marks/drop-lines.js.map +1 -1
- package/dist/marks/plot-point.d.ts +37 -20
- package/dist/marks/plot-point.d.ts.map +1 -1
- package/dist/marks/plot-point.js +65 -91
- package/dist/marks/plot-point.js.map +1 -1
- package/dist/marks/riemann-sum.d.ts +30 -26
- package/dist/marks/riemann-sum.d.ts.map +1 -1
- package/dist/marks/riemann-sum.js +57 -85
- package/dist/marks/riemann-sum.js.map +1 -1
- package/dist/marks/tangent-line.d.ts +38 -14
- package/dist/marks/tangent-line.d.ts.map +1 -1
- package/dist/marks/tangent-line.js +73 -87
- package/dist/marks/tangent-line.js.map +1 -1
- package/dist/marks/vector-arrow.d.ts +30 -20
- package/dist/marks/vector-arrow.d.ts.map +1 -1
- package/dist/marks/vector-arrow.js +58 -78
- package/dist/marks/vector-arrow.js.map +1 -1
- package/dist/nodes.d.ts +13 -5
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -6
- package/dist/nodes.js.map +1 -1
- package/dist/plots/function-plot.d.ts +107 -43
- package/dist/plots/function-plot.d.ts.map +1 -1
- package/dist/plots/function-plot.js +146 -177
- package/dist/plots/function-plot.js.map +1 -1
- package/dist/plots/points-plot.d.ts +34 -19
- package/dist/plots/points-plot.d.ts.map +1 -1
- package/dist/plots/points-plot.js +31 -58
- package/dist/plots/points-plot.js.map +1 -1
- package/dist/plots/stream-lines.d.ts +38 -19
- package/dist/plots/stream-lines.d.ts.map +1 -1
- package/dist/plots/stream-lines.js +60 -79
- package/dist/plots/stream-lines.js.map +1 -1
- package/dist/plots/traced-path.d.ts +34 -15
- package/dist/plots/traced-path.d.ts.map +1 -1
- package/dist/plots/traced-path.js +33 -48
- package/dist/plots/traced-path.js.map +1 -1
- package/dist/plots/vector-field.d.ts +31 -11
- package/dist/plots/vector-field.d.ts.map +1 -1
- package/dist/plots/vector-field.js +50 -64
- package/dist/plots/vector-field.js.map +1 -1
- package/dist/structures/network-graph.d.ts +99 -49
- package/dist/structures/network-graph.d.ts.map +1 -1
- package/dist/structures/network-graph.js +168 -217
- package/dist/structures/network-graph.js.map +1 -1
- package/dist/structures/sample-space.d.ts +69 -38
- package/dist/structures/sample-space.d.ts.map +1 -1
- package/dist/structures/sample-space.js +132 -170
- package/dist/structures/sample-space.js.map +1 -1
- package/dist/systems/axes2d.d.ts +126 -37
- package/dist/systems/axes2d.d.ts.map +1 -1
- package/dist/systems/axes2d.js +147 -183
- package/dist/systems/axes2d.js.map +1 -1
- package/dist/systems/number-line.d.ts +51 -28
- package/dist/systems/number-line.d.ts.map +1 -1
- package/dist/systems/number-line.js +82 -118
- package/dist/systems/number-line.js.map +1 -1
- package/dist/systems/number-plane.d.ts +92 -31
- package/dist/systems/number-plane.d.ts.map +1 -1
- package/dist/systems/number-plane.js +142 -149
- package/dist/systems/number-plane.js.map +1 -1
- package/dist/systems/polar-plane.d.ts +47 -26
- package/dist/systems/polar-plane.d.ts.map +1 -1
- package/dist/systems/polar-plane.js +107 -133
- package/dist/systems/polar-plane.js.map +1 -1
- package/dist/tex/index.d.ts.map +1 -1
- package/dist/tex/index.js +1 -0
- package/dist/tex/index.js.map +1 -1
- package/dist/tex/matrix.d.ts +56 -18
- package/dist/tex/matrix.d.ts.map +1 -1
- package/dist/tex/matrix.js +33 -50
- package/dist/tex/matrix.js.map +1 -1
- package/dist/tex/node.d.ts +55 -201
- package/dist/tex/node.d.ts.map +1 -1
- package/dist/tex/node.js +23 -593
- package/dist/tex/node.js.map +1 -1
- package/dist/tex/typeset.d.ts +133 -0
- package/dist/tex/typeset.d.ts.map +1 -0
- package/dist/tex/typeset.js +403 -0
- package/dist/tex/typeset.js.map +1 -0
- package/dist/three/axes3d.d.ts +140 -54
- package/dist/three/axes3d.d.ts.map +1 -1
- package/dist/three/axes3d.js +159 -204
- package/dist/three/axes3d.js.map +1 -1
- package/dist/three/curve-plot3d.d.ts +70 -42
- package/dist/three/curve-plot3d.d.ts.map +1 -1
- package/dist/three/curve-plot3d.js +97 -132
- package/dist/three/curve-plot3d.js.map +1 -1
- package/dist/three/entries.d.ts +17 -0
- package/dist/three/entries.d.ts.map +1 -0
- package/dist/three/entries.js +15 -0
- package/dist/three/entries.js.map +1 -0
- package/dist/three/plot-point3d.d.ts +57 -12
- package/dist/three/plot-point3d.d.ts.map +1 -1
- package/dist/three/plot-point3d.js +27 -53
- package/dist/three/plot-point3d.js.map +1 -1
- package/dist/three/space.d.ts +17 -2
- package/dist/three/space.d.ts.map +1 -1
- package/dist/three/space.js +19 -8
- package/dist/three/space.js.map +1 -1
- package/dist/three/surface-plot3d.d.ts +131 -49
- package/dist/three/surface-plot3d.d.ts.map +1 -1
- package/dist/three/surface-plot3d.js +227 -261
- package/dist/three/surface-plot3d.js.map +1 -1
- package/dist/three/vector-arrow3d.d.ts +58 -16
- package/dist/three/vector-arrow3d.d.ts.map +1 -1
- package/dist/three/vector-arrow3d.js +48 -67
- package/dist/three/vector-arrow3d.js.map +1 -1
- package/package.json +4 -4
- package/src/annotate/angle-mark.ts +95 -105
- package/src/annotate/curly-brace.ts +107 -85
- package/src/annotate/emphasis-mark.ts +55 -26
- package/src/engine.ts +35 -21
- package/src/kit/component.ts +57 -0
- package/src/kit/curve.ts +38 -20
- package/src/kit/field-mark.ts +124 -108
- package/src/kit/follow.ts +146 -120
- package/src/kit/furniture.ts +6 -1
- package/src/kit/graph.ts +116 -0
- package/src/kit/mark.ts +135 -114
- package/src/kit/place.ts +32 -56
- package/src/kit/system.ts +77 -71
- package/src/kit/withdrawn.ts +3 -3
- package/src/marks/curve-area.ts +65 -65
- package/src/marks/drop-lines.ts +50 -42
- package/src/marks/plot-point.ts +77 -82
- package/src/marks/riemann-sum.ts +73 -72
- package/src/marks/tangent-line.ts +87 -71
- package/src/marks/vector-arrow.ts +73 -73
- package/src/nodes.ts +41 -5
- package/src/plots/function-plot.ts +155 -171
- package/src/plots/points-plot.ts +46 -50
- package/src/plots/stream-lines.ts +75 -66
- package/src/plots/traced-path.ts +51 -33
- package/src/plots/vector-field.ts +68 -49
- package/src/structures/network-graph.ts +168 -185
- package/src/structures/sample-space.ts +149 -148
- package/src/systems/axes2d.ts +165 -156
- package/src/systems/number-line.ts +91 -92
- package/src/systems/number-plane.ts +149 -120
- package/src/systems/polar-plane.ts +117 -116
- package/src/tex/index.ts +2 -1
- package/src/tex/matrix.ts +62 -40
- package/src/tex/node.ts +54 -621
- package/src/tex/typeset.ts +461 -0
- package/src/three/axes3d.ts +182 -161
- package/src/three/curve-plot3d.ts +107 -110
- package/src/three/entries.ts +42 -0
- package/src/three/plot-point3d.ts +42 -45
- package/src/three/space.ts +34 -9
- package/src/three/surface-plot3d.ts +312 -323
- package/src/three/vector-arrow3d.ts +65 -54
- package/dist/browser/chunks/chunk-3GJB6AVO.js +0 -2
- package/dist/browser/chunks/chunk-3GJB6AVO.js.map +0 -7
- package/dist/browser/chunks/chunk-D5WHCVBC.js +0 -2
- package/dist/browser/chunks/chunk-D5WHCVBC.js.map +0 -7
- package/dist/browser/chunks/chunk-WL4KEX7Y.js +0 -2
- package/dist/browser/chunks/chunk-WL4KEX7Y.js.map +0 -7
- package/src/kit/placement.ts +0 -8
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type
|
|
3
|
-
import { FieldMark, type FieldProps, type FieldSampler, type FieldStroke } from "../kit/field-mark.js";
|
|
1
|
+
import { type NodeOf, type Fill as _Fill, type FillResolved as _FillResolved, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
|
|
2
|
+
import { type FieldProps } from "../kit/field-mark.js";
|
|
4
3
|
export interface VectorFieldProps extends FieldProps {
|
|
5
4
|
spacing?: number;
|
|
6
5
|
arrowScale?: number;
|
|
@@ -10,14 +9,35 @@ export interface VectorFieldProps extends FieldProps {
|
|
|
10
9
|
* Each arrow is centred on its point and is as long as the field is strong
|
|
11
10
|
* there, up to the spacing.
|
|
12
11
|
*/
|
|
13
|
-
export declare
|
|
12
|
+
export declare const VectorField: import("@motionscript/sdk").Component<"vectorField", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
14
13
|
/** How far apart the arrows stand, in graph units. */
|
|
15
|
-
spacing: number
|
|
14
|
+
spacing: import("@motionscript/sdk").Type<number, number, false>;
|
|
16
15
|
/** How long an arrow is drawn for a vector of length one, in graph units. */
|
|
17
|
-
arrowScale: number
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
arrowScale: import("@motionscript/sdk").Type<number, number, false>;
|
|
17
|
+
expression: import("@motionscript/sdk").Type<string | import("../index.js").PlotSource, import("../index.js").PlotSource, false>;
|
|
18
|
+
params: import("@motionscript/sdk").Type<Readonly<Record<string, number>>, Readonly<Record<string, number>>, false>;
|
|
19
|
+
strengthFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
20
|
+
maxMagnitude: import("@motionscript/sdk").Type<number, number, false>;
|
|
21
|
+
graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
|
|
22
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
23
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
24
|
+
}>, {
|
|
25
|
+
morphTo: readonly ["expression"];
|
|
26
|
+
paramsTo: readonly ["params"];
|
|
27
|
+
strokeTo: readonly ["stroke"];
|
|
28
|
+
shadowTo: readonly ["shadow"];
|
|
29
|
+
}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
30
|
+
/** How far apart the arrows stand, in graph units. */
|
|
31
|
+
spacing: import("@motionscript/sdk").Type<number, number, false>;
|
|
32
|
+
/** How long an arrow is drawn for a vector of length one, in graph units. */
|
|
33
|
+
arrowScale: import("@motionscript/sdk").Type<number, number, false>;
|
|
34
|
+
expression: import("@motionscript/sdk").Type<string | import("../index.js").PlotSource, import("../index.js").PlotSource, false>;
|
|
35
|
+
params: import("@motionscript/sdk").Type<Readonly<Record<string, number>>, Readonly<Record<string, number>>, false>;
|
|
36
|
+
strengthFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
37
|
+
maxMagnitude: import("@motionscript/sdk").Type<number, number, false>;
|
|
38
|
+
graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
|
|
39
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
40
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
41
|
+
}>, null>>;
|
|
42
|
+
export type VectorField = NodeOf<typeof VectorField>;
|
|
23
43
|
//# sourceMappingURL=vector-field.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-field.d.ts","sourceRoot":"","sources":["../../src/plots/vector-field.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"vector-field.d.ts","sourceRoot":"","sources":["../../src/plots/vector-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,MAAM,EAGX,KAAK,IAAI,IAAI,KAAK,EAClB,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACtC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAyE,KAAK,UAAU,EAAyD,MAAM,mBAAmB,CAAC;AAIlL,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AA6BD;;;;GAIG;AACH,eAAO,MAAM,WAAW;IAvBpB,sDAAsD;;IAEtD,6EAA6E;;;;;;;;;;;;;;;IAF7E,sDAAsD;;IAEtD,6EAA6E;;;;;;;;;UA4BX,CAAC;AAEvE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -1,81 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { node, property, strokeProperty } from "@motionscript/sdk";
|
|
8
|
-
import { FieldMark } from "../kit/field-mark.js";
|
|
1
|
+
import { component2d, Types, } from "@motionscript/sdk";
|
|
2
|
+
import { drawField, FIELD_COMMANDS, FIELD_STATE, traceField } from "../kit/field-mark.js";
|
|
9
3
|
import { PLOT_COLOR } from "../kit/furniture.js";
|
|
10
|
-
import {
|
|
4
|
+
import { inkSize, reading, traced } from "../kit/mark.js";
|
|
11
5
|
/** Past this many arrows the spacing is widened, so a field over a huge range is still a field and not a wash. */
|
|
12
6
|
const MAX_ARROWS = 2400;
|
|
13
7
|
/** An arrow's head, as a share of its length and in pixels at most, and the half-angle it opens to. */
|
|
14
8
|
const HEAD_SHARE = 0.38;
|
|
15
9
|
const HEAD_MAX = 11;
|
|
16
10
|
const HEAD_ANGLE = (26 * Math.PI) / 180;
|
|
11
|
+
const state = {
|
|
12
|
+
...FIELD_STATE,
|
|
13
|
+
/** How far apart the arrows stand, in graph units. */
|
|
14
|
+
spacing: Types.number(1, { min: 0.01, step: 0.1 }),
|
|
15
|
+
/** How long an arrow is drawn for a vector of length one, in graph units. */
|
|
16
|
+
arrowScale: Types.number(0.4, { min: 0, step: 0.05 }),
|
|
17
|
+
};
|
|
18
|
+
const ARROWS = {
|
|
19
|
+
own: (s) => `${s.spacing}|${s.arrowScale}`,
|
|
20
|
+
strokes: (s, map, field) => arrows(s, map, field),
|
|
21
|
+
};
|
|
22
|
+
const traceArrows = (s, read) => traceField("vectorField", ARROWS, s, read);
|
|
17
23
|
/**
|
|
18
24
|
* A grid of arrows showing a vector field, two parts in x and y: `(-y, x)`.
|
|
19
25
|
* Each arrow is centred on its point and is as long as the field is strong
|
|
20
26
|
* there, up to the spacing.
|
|
21
27
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
28
|
+
export const VectorField = traced(component2d({
|
|
29
|
+
key: "vectorField",
|
|
30
|
+
state,
|
|
31
|
+
defaults: { stroke: { weight: 2.5, fill: PLOT_COLOR, align: "center", cap: "round", join: "round" }, width: "hug", height: "hug" },
|
|
32
|
+
commands: FIELD_COMMANDS,
|
|
33
|
+
measure: (_measurer, s) => inkSize(traceArrows(s, reading(s)).runs),
|
|
34
|
+
render: (ctx, s) => drawField(ctx, s, traceArrows(s, reading(s))),
|
|
35
|
+
}), (s, read) => traceArrows(s, read).runs);
|
|
36
|
+
function arrows(s, map, field) {
|
|
37
|
+
const [x0, x1] = map.xRange;
|
|
38
|
+
const [y0, y1] = map.yRange;
|
|
39
|
+
let spacing = Math.max(s.spacing, 1e-6);
|
|
40
|
+
const count = () => (Math.floor((x1 - x0) / spacing) + 1) * (Math.floor((y1 - y0) / spacing) + 1);
|
|
41
|
+
while (count() > MAX_ARROWS)
|
|
42
|
+
spacing *= 2;
|
|
43
|
+
const drawn = [];
|
|
44
|
+
const v = { x: 0, y: 0 };
|
|
45
|
+
const longest = spacing * 0.9;
|
|
46
|
+
for (let i = Math.ceil(x0 / spacing - 1e-9); i * spacing <= x1 + 1e-9; i++) {
|
|
47
|
+
for (let j = Math.ceil(y0 / spacing - 1e-9); j * spacing <= y1 + 1e-9; j++) {
|
|
48
|
+
const gx = i * spacing;
|
|
49
|
+
const gy = j * spacing;
|
|
50
|
+
if (!field(gx, gy, v))
|
|
51
|
+
continue;
|
|
52
|
+
const magnitude = Math.hypot(v.x, v.y);
|
|
53
|
+
const length = Math.min(magnitude * s.arrowScale, longest);
|
|
54
|
+
if (!(length > 0))
|
|
55
|
+
continue;
|
|
56
|
+
const hx = ((v.x / magnitude) * length) / 2;
|
|
57
|
+
const hy = ((v.y / magnitude) * length) / 2;
|
|
58
|
+
const tail = map.toPoint(gx - hx, gy - hy);
|
|
59
|
+
const head = map.toPoint(gx + hx, gy + hy);
|
|
60
|
+
drawn.push({ runs: arrow(tail, head), magnitude });
|
|
55
61
|
}
|
|
56
|
-
return drawn;
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
property({ default: 1, min: 0.01, step: 0.1 })
|
|
61
|
-
], VectorField.prototype, "spacing", void 0);
|
|
62
|
-
__decorate([
|
|
63
|
-
property({ default: 0.4, min: 0, step: 0.05 })
|
|
64
|
-
], VectorField.prototype, "arrowScale", void 0);
|
|
65
|
-
__decorate([
|
|
66
|
-
strokeProperty({ default: { weight: 2.5, fill: PLOT_COLOR, align: "center", cap: "round", join: "round" } })
|
|
67
|
-
], VectorField.prototype, "stroke", void 0);
|
|
68
|
-
VectorField = __decorate([
|
|
69
|
-
node({
|
|
70
|
-
key: "vectorField",
|
|
71
|
-
within: SYSTEMS,
|
|
72
|
-
parentKey: "shape",
|
|
73
|
-
forkable: true,
|
|
74
|
-
layout: { children: "freeform", defaultWidthMode: "hug", defaultHeightMode: "hug", acceptsChildren: false },
|
|
75
|
-
seed: { expression: "(-y, x)" },
|
|
76
|
-
})
|
|
77
|
-
], VectorField);
|
|
78
|
-
export { VectorField };
|
|
63
|
+
return drawn;
|
|
64
|
+
}
|
|
79
65
|
/** A shaft and the two barbs of its head, in pixels. */
|
|
80
66
|
function arrow(tail, head) {
|
|
81
67
|
const dx = head.x - tail.x;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-field.js","sourceRoot":"","sources":["../../src/plots/vector-field.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vector-field.js","sourceRoot":"","sources":["../../src/plots/vector-field.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAYR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAA6F,MAAM,mBAAmB,CAAC;AAClL,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AAOzE,kHAAkH;AAClH,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,uGAAuG;AACvG,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,MAAM,UAAU,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AAExC,MAAM,KAAK,GAAG;IACV,GAAG,WAAW;IACd,sDAAsD;IACtD,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAClD,6EAA6E;IAC7E,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;CACxD,CAAC;AAOF,MAAM,MAAM,GAA+B;IACvC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,UAAU,EAAE;IAC1C,OAAO,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,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,KAAa,EAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;IACpH,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,GAAG,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import {\r\n component2d,\r\n Types,\r\n type NodeOf,\r\n type Vector2,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Fill as _Fill,\r\n type FillResolved as _FillResolved,\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n type Shadow as _Shadow,\r\n type ShadowResolved as _ShadowResolved,\r\n type Stroke as _Stroke,\r\n type StrokeResolved as _StrokeResolved,\r\n} from \"@motionscript/sdk\";\r\nimport type { CoordinateMap } from \"../kit/coords\";\r\nimport { drawField, FIELD_COMMANDS, FIELD_STATE, traceField, type FieldDrawing, type FieldProps, type FieldValues, type FieldSampler, type FieldStroke } from \"../kit/field-mark\";\r\nimport { PLOT_COLOR } from \"../kit/furniture\";\r\nimport { inkSize, reading, traced, type MarkReading } from \"../kit/mark\";\r\n\r\nexport interface VectorFieldProps extends FieldProps {\r\n spacing?: number;\r\n arrowScale?: number;\r\n}\r\n\r\n/** Past this many arrows the spacing is widened, so a field over a huge range is still a field and not a wash. */\r\nconst MAX_ARROWS = 2400;\r\n/** An arrow's head, as a share of its length and in pixels at most, and the half-angle it opens to. */\r\nconst HEAD_SHARE = 0.38;\r\nconst HEAD_MAX = 11;\r\nconst HEAD_ANGLE = (26 * Math.PI) / 180;\r\n\r\nconst state = {\r\n ...FIELD_STATE,\r\n /** How far apart the arrows stand, in graph units. */\r\n spacing: Types.number(1, { min: 0.01, step: 0.1 }),\r\n /** How long an arrow is drawn for a vector of length one, in graph units. */\r\n arrowScale: Types.number(0.4, { min: 0, step: 0.05 }),\r\n};\r\n\r\ninterface ArrowsValues extends FieldValues {\r\n readonly spacing: number;\r\n readonly arrowScale: number;\r\n}\r\n\r\nconst ARROWS: FieldDrawing<ArrowsValues> = {\r\n own: (s) => `${s.spacing}|${s.arrowScale}`,\r\n strokes: (s, map, field) => arrows(s, map, field),\r\n};\r\n\r\nconst traceArrows = (s: ArrowsValues, read: MarkReading) => traceField(\"vectorField\", ARROWS, s, read);\r\n\r\n/**\r\n * A grid of arrows showing a vector field, two parts in x and y: `(-y, x)`.\r\n * Each arrow is centred on its point and is as long as the field is strong\r\n * there, up to the spacing.\r\n */\r\nexport const VectorField = traced(component2d({\r\n key: \"vectorField\",\r\n state,\r\n defaults: { stroke: { weight: 2.5, fill: PLOT_COLOR, align: \"center\", cap: \"round\", join: \"round\" }, width: \"hug\", height: \"hug\" },\r\n commands: FIELD_COMMANDS,\r\n measure: (_measurer, s) => inkSize(traceArrows(s, reading(s)).runs),\r\n render: (ctx, s) => drawField(ctx, s, traceArrows(s, reading(s))),\r\n}), (s: ArrowsValues, read: MarkReading) => traceArrows(s, read).runs);\r\n\r\nexport type VectorField = NodeOf<typeof VectorField>;\r\n\r\nfunction arrows(s: ArrowsValues, map: CoordinateMap, field: FieldSampler): FieldStroke[] {\r\n const [x0, x1] = map.xRange;\r\n const [y0, y1] = map.yRange;\r\n let spacing = Math.max(s.spacing, 1e-6);\r\n const count = () => (Math.floor((x1 - x0) / spacing) + 1) * (Math.floor((y1 - y0) / spacing) + 1);\r\n while (count() > MAX_ARROWS) spacing *= 2;\r\n\r\n const drawn: FieldStroke[] = [];\r\n const v: Vector2 = { x: 0, y: 0 };\r\n const longest = spacing * 0.9;\r\n for (let i = Math.ceil(x0 / spacing - 1e-9); i * spacing <= x1 + 1e-9; i++) {\r\n for (let j = Math.ceil(y0 / spacing - 1e-9); j * spacing <= y1 + 1e-9; j++) {\r\n const gx = i * spacing;\r\n const gy = j * spacing;\r\n if (!field(gx, gy, v)) continue;\r\n const magnitude = Math.hypot(v.x, v.y);\r\n const length = Math.min(magnitude * s.arrowScale, longest);\r\n if (!(length > 0)) continue;\r\n const hx = ((v.x / magnitude) * length) / 2;\r\n const hy = ((v.y / magnitude) * length) / 2;\r\n const tail = map.toPoint(gx - hx, gy - hy);\r\n const head = map.toPoint(gx + hx, gy + hy);\r\n drawn.push({ runs: arrow(tail, head), magnitude });\r\n }\r\n }\r\n return drawn;\r\n}\r\n\r\n/** A shaft and the two barbs of its head, in pixels. */\r\nfunction arrow(tail: Vector2, head: Vector2): Vector2[][] {\r\n const dx = head.x - tail.x;\r\n const dy = head.y - tail.y;\r\n const length = Math.hypot(dx, dy);\r\n if (!(length > 0)) return [];\r\n const barb = Math.min(length * HEAD_SHARE, HEAD_MAX);\r\n const back = Math.atan2(dy, dx) + Math.PI;\r\n const at = (angle: number): Vector2 => ({ x: head.x + Math.cos(angle) * barb, y: head.y + Math.sin(angle) * barb });\r\n return [[tail, head], [at(back - HEAD_ANGLE), head, at(back + HEAD_ANGLE)]];\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type PartFill } from "../kit/part-fills.js";
|
|
1
|
+
import { type Color, type Fill, type FillResolved, type NodeOf, type NormalizedColor, type PaintProps, type ShadowResolved, type Size2D, type Stroke, type StrokeResolved, type Values, type Vector2, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow } from "@motionscript/sdk";
|
|
2
|
+
import { type PartFill, type PartFillResolved } from "../kit/part-fills.js";
|
|
3
3
|
import { type GraphEdge, type GraphLayout } from "./graph-layout.js";
|
|
4
4
|
/** A vertex placed by hand, in the graph's box from -1 to 1 each way, y up. */
|
|
5
5
|
export interface GraphPosition {
|
|
@@ -22,6 +22,35 @@ export interface NetworkGraphProps extends PaintProps {
|
|
|
22
22
|
fontFamily?: string;
|
|
23
23
|
partFills?: PartFill[];
|
|
24
24
|
}
|
|
25
|
+
declare const state: {
|
|
26
|
+
vertices: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
27
|
+
edges: import("@motionscript/sdk").Type<GraphEdge[], GraphEdge[], false>;
|
|
28
|
+
/** Draw each edge as an arrow from its `from` to its `to`. */
|
|
29
|
+
directed: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
30
|
+
arrangement: import("@motionscript/sdk").Type<GraphLayout, GraphLayout, false>;
|
|
31
|
+
/** The vertex a tree hangs from; left empty, the first. */
|
|
32
|
+
root: import("@motionscript/sdk").Type<string, string, false>;
|
|
33
|
+
/** Vertices placed by hand, whatever the layout says, in the box from -1 to 1 each way. */
|
|
34
|
+
positions: import("@motionscript/sdk").Type<GraphPosition[], GraphPosition[], false>;
|
|
35
|
+
vertexRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
36
|
+
vertexStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
|
|
37
|
+
labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
38
|
+
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
39
|
+
labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
|
|
40
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
41
|
+
/** Paints for a vertex by its name, or an edge written `a-b`, over the graph's own. */
|
|
42
|
+
partFills: import("@motionscript/sdk").Type<PartFill[], PartFillResolved[], false>;
|
|
43
|
+
/** The arrangement an `arrangeTo` is leaving, and how far it is towards the new one. */
|
|
44
|
+
layoutFrom: import("@motionscript/sdk").Type<string, string, true>;
|
|
45
|
+
layoutMix: import("@motionscript/sdk").Type<number, number, true>;
|
|
46
|
+
fill: import("@motionscript/sdk").Attribute<Fill, FillResolved[]>;
|
|
47
|
+
stroke: import("@motionscript/sdk").Attribute<Stroke, StrokeResolved[]>;
|
|
48
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|
|
49
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
50
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
51
|
+
};
|
|
52
|
+
/** What a graph is drawn from: its own entries, as its fields and its node both read them. */
|
|
53
|
+
export type GraphValues = Values<typeof state>;
|
|
25
54
|
/**
|
|
26
55
|
* Vertices and the edges between them, arranged by a rule: in a circle, by
|
|
27
56
|
* springs, as a tree from `root`, or in a grid. Its `fill` is the vertices and
|
|
@@ -29,55 +58,76 @@ export interface NetworkGraphProps extends PaintProps {
|
|
|
29
58
|
* moves every vertex to where another rule places it; `partFillTo` paints a
|
|
30
59
|
* vertex, or an edge written `a-b`. (`layout` is every node's own box.)
|
|
31
60
|
*/
|
|
32
|
-
export declare
|
|
33
|
-
vertices: string[]
|
|
34
|
-
edges: GraphEdge[]
|
|
61
|
+
export declare const NetworkGraph: import("@motionscript/sdk").Component<"networkGraph", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
62
|
+
vertices: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
63
|
+
edges: import("@motionscript/sdk").Type<GraphEdge[], GraphEdge[], false>;
|
|
35
64
|
/** Draw each edge as an arrow from its `from` to its `to`. */
|
|
36
|
-
directed: boolean
|
|
37
|
-
arrangement: GraphLayout
|
|
65
|
+
directed: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
66
|
+
arrangement: import("@motionscript/sdk").Type<GraphLayout, GraphLayout, false>;
|
|
38
67
|
/** The vertex a tree hangs from; left empty, the first. */
|
|
39
|
-
root: string
|
|
68
|
+
root: import("@motionscript/sdk").Type<string, string, false>;
|
|
40
69
|
/** Vertices placed by hand, whatever the layout says, in the box from -1 to 1 each way. */
|
|
41
|
-
positions: GraphPosition[]
|
|
42
|
-
vertexRadius: number
|
|
43
|
-
vertexStroke: Stroke
|
|
44
|
-
labels: boolean
|
|
45
|
-
labelSize: number
|
|
46
|
-
labelColor: Color
|
|
47
|
-
fontFamily: string
|
|
70
|
+
positions: import("@motionscript/sdk").Type<GraphPosition[], GraphPosition[], false>;
|
|
71
|
+
vertexRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
72
|
+
vertexStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
|
|
73
|
+
labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
74
|
+
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
75
|
+
labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
|
|
76
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
48
77
|
/** Paints for a vertex by its name, or an edge written `a-b`, over the graph's own. */
|
|
49
|
-
partFills: PartFill[]
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
partFillTo
|
|
63
|
-
part: string
|
|
64
|
-
fill: Fill
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
partFills: import("@motionscript/sdk").Type<PartFill[], PartFillResolved[], false>;
|
|
79
|
+
/** The arrangement an `arrangeTo` is leaving, and how far it is towards the new one. */
|
|
80
|
+
layoutFrom: import("@motionscript/sdk").Type<string, string, true>;
|
|
81
|
+
layoutMix: import("@motionscript/sdk").Type<number, number, true>;
|
|
82
|
+
fill: import("@motionscript/sdk").Attribute<Fill, FillResolved[]>;
|
|
83
|
+
stroke: import("@motionscript/sdk").Attribute<Stroke, StrokeResolved[]>;
|
|
84
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|
|
85
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
86
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
87
|
+
}>, {
|
|
88
|
+
readonly arrangeTo: {
|
|
89
|
+
readonly arrangement: import("@motionscript/sdk").Type<GraphLayout | undefined, GraphLayout | undefined, false>;
|
|
90
|
+
};
|
|
91
|
+
readonly partFillTo: {
|
|
92
|
+
readonly part: import("@motionscript/sdk").Type<string, string, false>;
|
|
93
|
+
readonly fill: import("@motionscript/sdk").Type<Fill, Fill, false>;
|
|
94
|
+
};
|
|
95
|
+
readonly fillTo: readonly ["fill"];
|
|
96
|
+
readonly strokeTo: readonly ["stroke"];
|
|
97
|
+
readonly shadowTo: readonly ["shadow"];
|
|
98
|
+
readonly progressTo: readonly ["start", "end"];
|
|
99
|
+
readonly flash: {
|
|
100
|
+
readonly portion: import("@motionscript/sdk").Type<number, number, false>;
|
|
101
|
+
};
|
|
102
|
+
}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
103
|
+
vertices: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
104
|
+
edges: import("@motionscript/sdk").Type<GraphEdge[], GraphEdge[], false>;
|
|
105
|
+
/** Draw each edge as an arrow from its `from` to its `to`. */
|
|
106
|
+
directed: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
107
|
+
arrangement: import("@motionscript/sdk").Type<GraphLayout, GraphLayout, false>;
|
|
108
|
+
/** The vertex a tree hangs from; left empty, the first. */
|
|
109
|
+
root: import("@motionscript/sdk").Type<string, string, false>;
|
|
110
|
+
/** Vertices placed by hand, whatever the layout says, in the box from -1 to 1 each way. */
|
|
111
|
+
positions: import("@motionscript/sdk").Type<GraphPosition[], GraphPosition[], false>;
|
|
112
|
+
vertexRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
113
|
+
vertexStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
|
|
114
|
+
labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
115
|
+
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
116
|
+
labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
|
|
117
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
118
|
+
/** Paints for a vertex by its name, or an edge written `a-b`, over the graph's own. */
|
|
119
|
+
partFills: import("@motionscript/sdk").Type<PartFill[], PartFillResolved[], false>;
|
|
120
|
+
/** The arrangement an `arrangeTo` is leaving, and how far it is towards the new one. */
|
|
121
|
+
layoutFrom: import("@motionscript/sdk").Type<string, string, true>;
|
|
122
|
+
layoutMix: import("@motionscript/sdk").Type<number, number, true>;
|
|
123
|
+
fill: import("@motionscript/sdk").Attribute<Fill, FillResolved[]>;
|
|
124
|
+
stroke: import("@motionscript/sdk").Attribute<Stroke, StrokeResolved[]>;
|
|
125
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|
|
126
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
127
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
128
|
+
}>, null>>;
|
|
129
|
+
export type NetworkGraph = NodeOf<typeof NetworkGraph>;
|
|
130
|
+
/** Where each vertex is drawn in a graph of `size`, in pixels from its centre, y up. */
|
|
131
|
+
export declare function vertexPoints(graph: GraphValues, size: Size2D): Map<string, Vector2>;
|
|
132
|
+
export {};
|
|
83
133
|
//# sourceMappingURL=network-graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-graph.d.ts","sourceRoot":"","sources":["../../src/structures/network-graph.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"network-graph.d.ts","sourceRoot":"","sources":["../../src/structures/network-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,KAAK,EACV,KAAK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