@zsherman/viz 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +373 -0
  3. package/README.md +13 -2
  4. package/THIRD_PARTY_NOTICES.md +79 -0
  5. package/dist/dom/flow/flow.js +370 -0
  6. package/dist/dom/flow/flow.styles.js +158 -0
  7. package/dist/dom/flow/index.js +4 -0
  8. package/dist/dom/flow/layout.js +51 -0
  9. package/dist/dom/geo-map/geo-map.js +1037 -0
  10. package/dist/dom/geo-map/geo-map.styles.js +184 -0
  11. package/dist/dom/geo-map/geometry.js +231 -0
  12. package/dist/dom/geo-map/index.js +3 -0
  13. package/dist/dom/geo-map/types.js +0 -0
  14. package/dist/dom/geo-map/world.js +15 -0
  15. package/dist/dom/index.js +6 -0
  16. package/dist/solid/flow/flow.jsx +180 -0
  17. package/dist/solid/flow/flow.styles.jsx +158 -0
  18. package/dist/solid/flow/index.jsx +4 -0
  19. package/dist/solid/flow/layout.jsx +51 -0
  20. package/dist/solid/geo-map/geo-map.jsx +698 -0
  21. package/dist/solid/geo-map/geo-map.styles.jsx +184 -0
  22. package/dist/solid/geo-map/geometry.jsx +231 -0
  23. package/dist/solid/geo-map/index.jsx +3 -0
  24. package/dist/solid/geo-map/types.jsx +0 -0
  25. package/dist/solid/geo-map/world.jsx +15 -0
  26. package/dist/solid/index.jsx +6 -0
  27. package/dist/styles.css +1 -0
  28. package/dist/types/flow/flow.d.ts +92 -0
  29. package/dist/types/flow/flow.styles.d.ts +137 -0
  30. package/dist/types/flow/index.d.ts +6 -0
  31. package/dist/types/flow/layout.d.ts +47 -0
  32. package/dist/types/geo-map/geo-map.d.ts +70 -0
  33. package/dist/types/geo-map/geo-map.styles.d.ts +188 -0
  34. package/dist/types/geo-map/geometry.d.ts +116 -0
  35. package/dist/types/geo-map/index.d.ts +4 -0
  36. package/dist/types/geo-map/types.d.ts +103 -0
  37. package/dist/types/geo-map/world.d.ts +11 -0
  38. package/dist/types/index.d.ts +2 -0
  39. package/docs/api.json +297 -0
  40. package/docs/flow.md +255 -0
  41. package/docs/geo-map.md +320 -0
  42. package/docs/llms.txt +43 -0
  43. package/docs/search-index.json +64 -0
  44. package/package.json +66 -4
@@ -0,0 +1,137 @@
1
+ import * as stylex from "@stylexjs/stylex";
2
+ export declare const styles: Readonly<{
3
+ readonly root: Readonly<{
4
+ readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
5
+ readonly position: stylex.StyleXClassNameFor<"position", "relative">;
6
+ readonly width: stylex.StyleXClassNameFor<"width", "100%">;
7
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
8
+ readonly overflow: stylex.StyleXClassNameFor<"overflow", "hidden">;
9
+ readonly borderWidth: stylex.StyleXClassNameFor<"borderWidth", 1>;
10
+ readonly borderStyle: stylex.StyleXClassNameFor<"borderStyle", "solid">;
11
+ readonly borderColor: stylex.StyleXClassNameFor<"borderColor", string>;
12
+ readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
13
+ readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
14
+ readonly fontFamily: stylex.StyleXClassNameFor<"fontFamily", string>;
15
+ readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
16
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
17
+ }>;
18
+ readonly aspect: Readonly<{
19
+ readonly aspectRatio: stylex.StyleXClassNameFor<"aspectRatio", "16 / 9">;
20
+ }>;
21
+ readonly node: Readonly<{
22
+ readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
23
+ readonly display: stylex.StyleXClassNameFor<"display", "flex">;
24
+ readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
25
+ readonly gap: stylex.StyleXClassNameFor<"gap", string>;
26
+ readonly width: stylex.StyleXClassNameFor<"width", "100%">;
27
+ readonly height: stylex.StyleXClassNameFor<"height", "100%">;
28
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
29
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
30
+ readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", string>;
31
+ readonly borderWidth: stylex.StyleXClassNameFor<"borderWidth", 1>;
32
+ readonly borderStyle: stylex.StyleXClassNameFor<"borderStyle", "solid">;
33
+ readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "CanvasText" | "var(--flow-node-edge)">;
34
+ readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
35
+ readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
36
+ readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", "0 0 0 2px var(--sui-accent)" | "var(--sui-shadow-xs)">;
37
+ readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "none" | "solid">;
38
+ readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", "2px">;
39
+ readonly outlineColor: stylex.StyleXClassNameFor<"outlineColor", "Highlight">;
40
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
41
+ readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "start">;
42
+ readonly lineHeight: stylex.StyleXClassNameFor<"lineHeight", string>;
43
+ readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "box-shadow">;
44
+ readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
45
+ }>;
46
+ readonly pending: Readonly<{
47
+ readonly "--flow-ink": stylex.StyleXClassNameFor<"--flow-ink", string>;
48
+ readonly "--flow-node-edge": stylex.StyleXClassNameFor<"--flow-node-edge", string>;
49
+ }>;
50
+ readonly running: Readonly<{
51
+ readonly "--flow-ink": stylex.StyleXClassNameFor<"--flow-ink", string>;
52
+ readonly "--flow-node-edge": stylex.StyleXClassNameFor<"--flow-node-edge", "oklch(0.54 0.264 277)">;
53
+ }>;
54
+ readonly success: Readonly<{
55
+ readonly "--flow-ink": stylex.StyleXClassNameFor<"--flow-ink", string>;
56
+ readonly "--flow-node-edge": stylex.StyleXClassNameFor<"--flow-node-edge", string>;
57
+ }>;
58
+ readonly warning: Readonly<{
59
+ readonly "--flow-ink": stylex.StyleXClassNameFor<"--flow-ink", string>;
60
+ readonly "--flow-node-edge": stylex.StyleXClassNameFor<"--flow-node-edge", "oklch(0.79 0.16 76)">;
61
+ }>;
62
+ readonly error: Readonly<{
63
+ readonly "--flow-ink": stylex.StyleXClassNameFor<"--flow-ink", string>;
64
+ readonly "--flow-node-edge": stylex.StyleXClassNameFor<"--flow-node-edge", "oklch(0.55 0.21 25)">;
65
+ }>;
66
+ readonly plain: Readonly<{
67
+ readonly "--flow-ink": stylex.StyleXClassNameFor<"--flow-ink", string>;
68
+ readonly "--flow-node-edge": stylex.StyleXClassNameFor<"--flow-node-edge", string>;
69
+ }>;
70
+ readonly icon: Readonly<{
71
+ readonly display: stylex.StyleXClassNameFor<"display", "inline-flex">;
72
+ readonly flexShrink: stylex.StyleXClassNameFor<"flexShrink", 0>;
73
+ readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
74
+ readonly justifyContent: stylex.StyleXClassNameFor<"justifyContent", "center">;
75
+ readonly width: stylex.StyleXClassNameFor<"width", "1rem">;
76
+ readonly height: stylex.StyleXClassNameFor<"height", "1rem">;
77
+ readonly color: stylex.StyleXClassNameFor<"color", "CanvasText" | "var(--flow-ink)">;
78
+ }>;
79
+ readonly iconSvg: Readonly<{
80
+ readonly width: stylex.StyleXClassNameFor<"width", "1rem">;
81
+ readonly height: stylex.StyleXClassNameFor<"height", "1rem">;
82
+ }>;
83
+ readonly body: Readonly<{
84
+ readonly display: stylex.StyleXClassNameFor<"display", "flex">;
85
+ readonly flexDirection: stylex.StyleXClassNameFor<"flexDirection", "column">;
86
+ readonly gap: stylex.StyleXClassNameFor<"gap", string>;
87
+ readonly flex: stylex.StyleXClassNameFor<"flex", "1 1 auto">;
88
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
89
+ }>;
90
+ readonly title: Readonly<{
91
+ readonly overflow: stylex.StyleXClassNameFor<"overflow", "hidden">;
92
+ readonly textOverflow: stylex.StyleXClassNameFor<"textOverflow", "ellipsis">;
93
+ readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
94
+ readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
95
+ }>;
96
+ readonly description: Readonly<{
97
+ readonly overflow: stylex.StyleXClassNameFor<"overflow", "hidden">;
98
+ readonly textOverflow: stylex.StyleXClassNameFor<"textOverflow", "ellipsis">;
99
+ readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
100
+ readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
101
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
102
+ }>;
103
+ readonly meta: Readonly<{
104
+ readonly flexShrink: stylex.StyleXClassNameFor<"flexShrink", 0>;
105
+ readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
106
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
107
+ readonly fontVariantNumeric: stylex.StyleXClassNameFor<"fontVariantNumeric", "tabular-nums">;
108
+ }>;
109
+ readonly handle: Readonly<{
110
+ readonly width: stylex.StyleXClassNameFor<"width", "8px">;
111
+ readonly height: stylex.StyleXClassNameFor<"height", "8px">;
112
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", "8px">;
113
+ readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "8px">;
114
+ readonly borderWidth: stylex.StyleXClassNameFor<"borderWidth", 1>;
115
+ readonly borderStyle: stylex.StyleXClassNameFor<"borderStyle", "solid">;
116
+ readonly borderColor: stylex.StyleXClassNameFor<"borderColor", string>;
117
+ readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
118
+ readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
119
+ }>;
120
+ readonly handleHidden: Readonly<{
121
+ readonly opacity: stylex.StyleXClassNameFor<"opacity", 0>;
122
+ readonly pointerEvents: stylex.StyleXClassNameFor<"pointerEvents", "none">;
123
+ }>;
124
+ readonly edge: Readonly<{
125
+ readonly fill: stylex.StyleXClassNameFor<"fill", "none">;
126
+ readonly stroke: stylex.StyleXClassNameFor<"stroke", "CanvasText" | "var(--flow-edge-color)">;
127
+ readonly strokeWidth: stylex.StyleXClassNameFor<"strokeWidth", 1.5>;
128
+ readonly forcedColorAdjust: stylex.StyleXClassNameFor<"forcedColorAdjust", "none">;
129
+ }>;
130
+ readonly flowing: Readonly<{
131
+ readonly strokeDasharray: stylex.StyleXClassNameFor<"strokeDasharray", "8 8">;
132
+ readonly animationName: stylex.StyleXClassNameFor<"animationName", string>;
133
+ readonly animationDuration: stylex.StyleXClassNameFor<"animationDuration", "0.8s">;
134
+ readonly animationTimingFunction: stylex.StyleXClassNameFor<"animationTimingFunction", "linear">;
135
+ readonly animationIterationCount: stylex.StyleXClassNameFor<"animationIterationCount", "infinite">;
136
+ }>;
137
+ }>;
@@ -0,0 +1,6 @@
1
+ export { Flow, FlowBackground, FlowControls, FlowEdge, FlowMiniMap, FlowNode } from "./flow.js";
2
+ export type { FlowEdgeData, FlowEdgeItem, FlowEdgeTypes, FlowNodeData, FlowNodeItem, FlowNodeTypes, FlowProps, FlowStatus, } from "./flow.js";
3
+ export { layoutFlow } from "./layout.js";
4
+ export type { FlowDirection, LayoutEdge, LayoutFlowOptions, LayoutNode } from "./layout.js";
5
+ export { BaseEdge, createEdgeStore, createNodeStore, getBezierPath, getSmoothStepPath, getStraightPath, Handle, Panel, Position, useSolidFlow, } from "@dschz/solid-flow";
6
+ export type { Connection, Edge, EdgeProps, EdgeTypes, Node, NodeProps, NodeTypes, SolidFlowProps, Viewport, XYPosition, } from "@dschz/solid-flow";
@@ -0,0 +1,47 @@
1
+ import { type Node } from "@dschz/solid-flow";
2
+ /** A side of a node, as solid-flow types it on nodes (`Position.Left`, …). */
3
+ type Side = NonNullable<Node["sourcePosition"]>;
4
+ /** Which way the graph flows: left to right (`"LR"`) or top to bottom (`"TB"`). */
5
+ export type FlowDirection = "LR" | "TB";
6
+ export interface LayoutFlowOptions {
7
+ /** @defaultValue "LR" */
8
+ direction?: FlowDirection;
9
+ /** A node's size when it has none (no `width`/`height`, not measured yet). @defaultValue 200 */
10
+ nodeWidth?: number;
11
+ /** @defaultValue 56 */
12
+ nodeHeight?: number;
13
+ /** Space between ranks (columns going right, rows going down), in pixels. @defaultValue 72 */
14
+ rankGap?: number;
15
+ /** Space between nodes in a rank, in pixels. @defaultValue 24 */
16
+ nodeGap?: number;
17
+ }
18
+ /** The fields layout reads from a node; any node type with them works. */
19
+ export interface LayoutNode {
20
+ id: string;
21
+ width?: number;
22
+ height?: number;
23
+ measured?: {
24
+ width?: number;
25
+ height?: number;
26
+ };
27
+ }
28
+ /** The fields layout reads from an edge. */
29
+ export interface LayoutEdge {
30
+ source: string;
31
+ target: string;
32
+ }
33
+ /**
34
+ * The nodes with `position` set by dagre (each node's top left, so a fit view frames them), and their handles
35
+ * on the sides the graph flows through (`targetPosition` left and `sourcePosition` right going `"LR"`; top
36
+ * and bottom going `"TB"`). Edges naming a node that isn't there are left out of the layout. The input isn't
37
+ * changed.
38
+ */
39
+ export declare function layoutFlow<N extends LayoutNode>(nodes: readonly N[], edges: readonly LayoutEdge[], options?: LayoutFlowOptions): Array<N & {
40
+ position: {
41
+ x: number;
42
+ y: number;
43
+ };
44
+ sourcePosition: Side;
45
+ targetPosition: Side;
46
+ }>;
47
+ export {};
@@ -0,0 +1,70 @@
1
+ import type { JSX } from "@solidjs/web";
2
+ import type { GeoMapArcStyle, GeoMapColor, GeoMapConnection, GeoMapController, GeoMapLabels, GeoMapMarker, GeoMapProjection, GeoMapWorld } from "./types.js";
3
+ export interface GeoMapProps<T = unknown> extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "role" | "aria-label" | "aria-roledescription"> {
4
+ /** The map's accessible name: what it shows ("Servers and users, last hour"). */
5
+ label: string;
6
+ /** The places to mark. @defaultValue [] */
7
+ markers?: readonly GeoMapMarker<T>[];
8
+ /** Lines between markers, by their ids. Ones naming a missing marker are left out. @defaultValue [] */
9
+ connections?: readonly GeoMapConnection[];
10
+ /** A flat world or a globe (`"orthographic"`). @defaultValue "naturalEarth" */
11
+ projection?: GeoMapProjection;
12
+ /** How connections are drawn. @defaultValue "greatCircle" */
13
+ arcStyle?: GeoMapArcStyle;
14
+ /** Draws lines of latitude and longitude every 10°. @defaultValue false */
15
+ graticule?: boolean;
16
+ /**
17
+ * The land, as GeoJSON. Without it the map loads Natural Earth's countries (1:110m) on demand, after it
18
+ * mounts; pass `await loadWorld()` (or your own) to draw land on the server too.
19
+ */
20
+ worldData?: GeoMapWorld;
21
+ /** The place a globe faces first, `[longitude, latitude]`. @defaultValue [10, 25] */
22
+ center?: readonly [longitude: number, latitude: number];
23
+ /**
24
+ * What the map shows first: the whole world, or every marker as close as they fit (it follows the markers
25
+ * until someone pans or zooms). @defaultValue "world"
26
+ */
27
+ initialView?: "world" | "markers";
28
+ /** Pan and zoom (a flat map) or turn and zoom (a globe) with the pointer, the wheel and the keys. @defaultValue true */
29
+ interactive?: boolean;
30
+ /** Shows the zoom in, zoom out and Show all buttons (with `interactive`). @defaultValue true */
31
+ controls?: boolean;
32
+ /** The map's height (a number is pixels). Without it the map is twice as wide as it is high. */
33
+ height?: number | string;
34
+ /** The selected marker's id, to control the selection. `null` selects none. */
35
+ selected?: string | null;
36
+ /** The marker selected at first, when the selection isn't controlled. @defaultValue null */
37
+ defaultSelected?: string | null;
38
+ /** Runs when a marker is clicked, or chosen with Enter or Space, with the marker (null when it's chosen again, which clears the selection). */
39
+ onMarkerSelect?: (marker: GeoMapMarker<T> | null) => void;
40
+ /** Runs when a connection is clicked. */
41
+ onConnectionSelect?: (connection: GeoMapConnection) => void;
42
+ /**
43
+ * A marker whose connections stand out while the rest dim, to control the highlight (from a table row
44
+ * your app hovers, say). Without it the marker under the pointer or the keyboard focus is highlighted.
45
+ */
46
+ highlighted?: string | null;
47
+ /** Moves dashes along every connection, from source to target. Still under reduced motion. @defaultValue false */
48
+ animated?: boolean;
49
+ /** The tooltip's content for a marker. Defaults to its name, description and connection count. */
50
+ tooltip?: (marker: GeoMapMarker<T>) => JSX.Element;
51
+ /** Built-in words; also settable for every map through `LocaleProvider`'s `geoMap`. */
52
+ labels?: Partial<GeoMapLabels>;
53
+ /** Receives the map's controller once it mounts: fit, zoom and center from your own controls. */
54
+ controller?: (controller: GeoMapController) => void;
55
+ }
56
+ /** A marker or connection color as CSS: token names become their custom properties. */
57
+ export declare function geoMapColor(c: GeoMapColor): string;
58
+ /**
59
+ * A world map of markers and the connections between them: flat (pan and zoom) or a globe (turn and zoom).
60
+ * Markers are a listbox: Tab reaches the map's markers, arrows move to the nearest one on screen, Enter
61
+ * selects; + and − zoom. Land comes from Natural Earth (loaded on demand) unless `worldData` is given.
62
+ *
63
+ * @example
64
+ * <GeoMap
65
+ * label="Edge servers and the users on them"
66
+ * markers={[{ id: "fra", name: "Frankfurt", latitude: 50.1, longitude: 8.7, group: "server" }]}
67
+ * connections={[{ source: "u1", target: "fra" }]}
68
+ * />
69
+ */
70
+ export declare function GeoMap<T = unknown>(props: GeoMapProps<T>): JSX.Element;
@@ -0,0 +1,188 @@
1
+ import * as stylex from "@stylexjs/stylex";
2
+ export declare const styles: Readonly<{
3
+ readonly root: Readonly<{
4
+ readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
5
+ readonly position: stylex.StyleXClassNameFor<"position", "relative">;
6
+ readonly width: stylex.StyleXClassNameFor<"width", "100%">;
7
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
8
+ readonly overflow: stylex.StyleXClassNameFor<"overflow", "clip">;
9
+ readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
10
+ readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
11
+ readonly fontFamily: stylex.StyleXClassNameFor<"fontFamily", string>;
12
+ readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
13
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
14
+ readonly userSelect: stylex.StyleXClassNameFor<"userSelect", "none">;
15
+ readonly WebkitUserSelect: stylex.StyleXClassNameFor<"WebkitUserSelect", "none">;
16
+ }>;
17
+ readonly aspect: Readonly<{
18
+ readonly aspectRatio: stylex.StyleXClassNameFor<"aspectRatio", "2 / 1">;
19
+ }>;
20
+ readonly interactive: Readonly<{
21
+ readonly touchAction: stylex.StyleXClassNameFor<"touchAction", "none">;
22
+ readonly cursor: stylex.StyleXClassNameFor<"cursor", "grab" | "grabbing">;
23
+ }>;
24
+ readonly svg: Readonly<{
25
+ readonly position: stylex.StyleXClassNameFor<"position", "absolute">;
26
+ readonly inset: stylex.StyleXClassNameFor<"inset", 0>;
27
+ readonly display: stylex.StyleXClassNameFor<"display", "block">;
28
+ readonly width: stylex.StyleXClassNameFor<"width", "100%">;
29
+ readonly height: stylex.StyleXClassNameFor<"height", "100%">;
30
+ readonly overflow: stylex.StyleXClassNameFor<"overflow", "hidden">;
31
+ }>;
32
+ readonly water: Readonly<{
33
+ readonly fill: stylex.StyleXClassNameFor<"fill", string>;
34
+ readonly stroke: stylex.StyleXClassNameFor<"stroke", string>;
35
+ readonly strokeWidth: stylex.StyleXClassNameFor<"strokeWidth", 1>;
36
+ readonly vectorEffect: stylex.StyleXClassNameFor<"vectorEffect", "non-scaling-stroke">;
37
+ }>;
38
+ readonly globe: Readonly<{
39
+ readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "transparent">;
40
+ }>;
41
+ readonly graticule: Readonly<{
42
+ readonly fill: stylex.StyleXClassNameFor<"fill", "none">;
43
+ readonly stroke: stylex.StyleXClassNameFor<"stroke", string>;
44
+ readonly strokeWidth: stylex.StyleXClassNameFor<"strokeWidth", 1>;
45
+ readonly vectorEffect: stylex.StyleXClassNameFor<"vectorEffect", "non-scaling-stroke">;
46
+ }>;
47
+ readonly land: Readonly<{
48
+ readonly fill: stylex.StyleXClassNameFor<"fill", string>;
49
+ readonly stroke: stylex.StyleXClassNameFor<"stroke", string>;
50
+ readonly strokeWidth: stylex.StyleXClassNameFor<"strokeWidth", 0.6>;
51
+ readonly strokeLinejoin: stylex.StyleXClassNameFor<"strokeLinejoin", "round">;
52
+ readonly vectorEffect: stylex.StyleXClassNameFor<"vectorEffect", "non-scaling-stroke">;
53
+ }>;
54
+ readonly connection: Readonly<{
55
+ readonly fill: stylex.StyleXClassNameFor<"fill", "none">;
56
+ readonly stroke: stylex.StyleXClassNameFor<"stroke", "var(--geo-map-color)">;
57
+ readonly strokeWidth: stylex.StyleXClassNameFor<"strokeWidth", "var(--geo-map-weight)">;
58
+ readonly strokeLinecap: stylex.StyleXClassNameFor<"strokeLinecap", "round">;
59
+ readonly strokeOpacity: stylex.StyleXClassNameFor<"strokeOpacity", 0.7>;
60
+ readonly vectorEffect: stylex.StyleXClassNameFor<"vectorEffect", "non-scaling-stroke">;
61
+ readonly forcedColorAdjust: stylex.StyleXClassNameFor<"forcedColorAdjust", "none">;
62
+ readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "stroke-opacity">;
63
+ readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
64
+ }>;
65
+ readonly connectionActive: Readonly<{
66
+ readonly strokeOpacity: stylex.StyleXClassNameFor<"strokeOpacity", 1>;
67
+ }>;
68
+ readonly connectionDimmed: Readonly<{
69
+ readonly strokeOpacity: stylex.StyleXClassNameFor<"strokeOpacity", 0.12>;
70
+ }>;
71
+ readonly connectionHit: Readonly<{
72
+ readonly fill: stylex.StyleXClassNameFor<"fill", "none">;
73
+ readonly stroke: stylex.StyleXClassNameFor<"stroke", "transparent">;
74
+ readonly strokeWidth: stylex.StyleXClassNameFor<"strokeWidth", 10>;
75
+ readonly vectorEffect: stylex.StyleXClassNameFor<"vectorEffect", "non-scaling-stroke">;
76
+ readonly pointerEvents: stylex.StyleXClassNameFor<"pointerEvents", "stroke">;
77
+ readonly cursor: stylex.StyleXClassNameFor<"cursor", "pointer">;
78
+ }>;
79
+ readonly flowing: Readonly<{
80
+ readonly strokeDasharray: stylex.StyleXClassNameFor<"strokeDasharray", "6 6">;
81
+ readonly animationName: stylex.StyleXClassNameFor<"animationName", string>;
82
+ readonly animationDuration: stylex.StyleXClassNameFor<"animationDuration", "0.9s">;
83
+ readonly animationTimingFunction: stylex.StyleXClassNameFor<"animationTimingFunction", "linear">;
84
+ readonly animationIterationCount: stylex.StyleXClassNameFor<"animationIterationCount", "infinite">;
85
+ }>;
86
+ readonly markers: Readonly<{
87
+ readonly position: stylex.StyleXClassNameFor<"position", "absolute">;
88
+ readonly inset: stylex.StyleXClassNameFor<"inset", 0>;
89
+ readonly pointerEvents: stylex.StyleXClassNameFor<"pointerEvents", "none">;
90
+ }>;
91
+ readonly marker: Readonly<{
92
+ readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
93
+ readonly position: stylex.StyleXClassNameFor<"position", "absolute">;
94
+ readonly width: stylex.StyleXClassNameFor<"width", "max(1.5rem, calc(var(--geo-map-radius) * 2px + 6px))">;
95
+ readonly height: stylex.StyleXClassNameFor<"height", "max(1.5rem, calc(var(--geo-map-radius) * 2px + 6px))">;
96
+ readonly marginLeft: stylex.StyleXClassNameFor<"marginLeft", "calc(max(1.5rem, calc(var(--geo-map-radius) * 2px + 6px)) / -2)">;
97
+ readonly marginTop: stylex.StyleXClassNameFor<"marginTop", "calc(max(1.5rem, calc(var(--geo-map-radius) * 2px + 6px)) / -2)">;
98
+ readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
99
+ readonly pointerEvents: stylex.StyleXClassNameFor<"pointerEvents", "auto">;
100
+ readonly cursor: stylex.StyleXClassNameFor<"cursor", "pointer">;
101
+ readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "none" | "solid">;
102
+ readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", "2px">;
103
+ readonly outlineOffset: stylex.StyleXClassNameFor<"outlineOffset", "0px">;
104
+ readonly outlineColor: stylex.StyleXClassNameFor<"outlineColor", string>;
105
+ readonly "::before": stylex.StyleXClassNameFor<"::before", {
106
+ readonly content: "\"\"";
107
+ readonly position: "absolute";
108
+ readonly left: "50%";
109
+ readonly top: "50%";
110
+ readonly boxSizing: "content-box";
111
+ readonly width: "calc(var(--geo-map-radius) * 2px)";
112
+ readonly height: "calc(var(--geo-map-radius) * 2px)";
113
+ readonly marginLeft: "calc(var(--geo-map-radius) * -1px - 1.5px)";
114
+ readonly marginTop: "calc(var(--geo-map-radius) * -1px - 1.5px)";
115
+ readonly borderRadius: stylex.StyleXVar<string>;
116
+ readonly borderWidth: "1.5px";
117
+ readonly borderStyle: "solid";
118
+ readonly borderColor: {
119
+ readonly default: stylex.StyleXVar<string>;
120
+ readonly "@media (forced-colors: active)": "Canvas";
121
+ };
122
+ readonly backgroundColor: {
123
+ readonly default: "var(--geo-map-color)";
124
+ readonly "@media (forced-colors: active)": "CanvasText";
125
+ };
126
+ readonly forcedColorAdjust: "none";
127
+ readonly transitionProperty: "transform, opacity";
128
+ readonly transitionDuration: {
129
+ readonly default: stylex.StyleXVar<string>;
130
+ readonly "@media (prefers-reduced-motion: reduce)": "0s";
131
+ };
132
+ readonly transitionTimingFunction: stylex.StyleXVar<string>;
133
+ readonly transform: {
134
+ readonly default: "none";
135
+ readonly ":where([data-active], :hover)": "scale(1.3)";
136
+ readonly "@media (prefers-reduced-motion: reduce)": "none";
137
+ };
138
+ readonly opacity: {
139
+ readonly default: 1;
140
+ readonly ":where([data-dimmed])": 0.3;
141
+ };
142
+ }>;
143
+ readonly "::after": stylex.StyleXClassNameFor<"::after", {
144
+ readonly content: "\"\"";
145
+ readonly position: "absolute";
146
+ readonly inset: "calc(50% - var(--geo-map-radius) * 1px - 5px)";
147
+ readonly borderRadius: stylex.StyleXVar<string>;
148
+ readonly borderWidth: "2px";
149
+ readonly borderStyle: "solid";
150
+ readonly borderColor: {
151
+ readonly default: "var(--geo-map-color)";
152
+ readonly "@media (forced-colors: active)": "Highlight";
153
+ };
154
+ readonly forcedColorAdjust: "none";
155
+ readonly opacity: {
156
+ readonly default: 0;
157
+ readonly ":where([aria-selected=true])": 1;
158
+ };
159
+ }>;
160
+ }>;
161
+ readonly farSide: Readonly<{
162
+ readonly opacity: stylex.StyleXClassNameFor<"opacity", 0>;
163
+ readonly pointerEvents: stylex.StyleXClassNameFor<"pointerEvents", "none">;
164
+ }>;
165
+ readonly controls: Readonly<{
166
+ readonly position: stylex.StyleXClassNameFor<"position", "absolute">;
167
+ readonly insetInlineEnd: stylex.StyleXClassNameFor<"insetInlineEnd", string>;
168
+ readonly bottom: stylex.StyleXClassNameFor<"bottom", string>;
169
+ readonly display: stylex.StyleXClassNameFor<"display", "flex">;
170
+ readonly flexDirection: stylex.StyleXClassNameFor<"flexDirection", "column">;
171
+ readonly gap: stylex.StyleXClassNameFor<"gap", string>;
172
+ readonly cursor: stylex.StyleXClassNameFor<"cursor", "auto">;
173
+ }>;
174
+ readonly tooltipBody: Readonly<{
175
+ readonly display: stylex.StyleXClassNameFor<"display", "flex">;
176
+ readonly flexDirection: stylex.StyleXClassNameFor<"flexDirection", "column">;
177
+ readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "flex-start">;
178
+ readonly gap: stylex.StyleXClassNameFor<"gap", string>;
179
+ }>;
180
+ readonly tooltipTitle: Readonly<{
181
+ readonly display: stylex.StyleXClassNameFor<"display", "block">;
182
+ readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
183
+ }>;
184
+ readonly tooltipLine: Readonly<{
185
+ readonly display: stylex.StyleXClassNameFor<"display", "block">;
186
+ readonly opacity: stylex.StyleXClassNameFor<"opacity", 0.8>;
187
+ }>;
188
+ }>;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * The GeoMap's geometry: projections, connection arcs, the globe's drag and wheel, and fitting a view to
3
+ * markers. Pure functions of their inputs (d3-geo for the math, no DOM), so they run on the server and in
4
+ * unit tests. A Solid rewrite of hyper-ui's maps (packages/viz/src/{geo-map,connection-map,shared}), where
5
+ * D3 classes owned the DOM; here Solid renders and d3-geo only projects.
6
+ */
7
+ import { type GeoProjection } from "d3-geo";
8
+ import type { GeoMapArcStyle, GeoMapProjection } from "./types.js";
9
+ export type { GeoMapArcStyle, GeoMapProjection };
10
+ /** `[longitude, latitude]` in degrees. */
11
+ export type LonLat = readonly [number, number];
12
+ export type Point = readonly [number, number];
13
+ /** A globe's rotation, as d3's `projection.rotate()`: `[λ, φ, γ]` in degrees. */
14
+ export type Rotation = readonly [number, number, number];
15
+ /** The space kept around the world when it's fitted into the map's box, in pixels. */
16
+ export declare const FIT_PADDING = 8;
17
+ /** A fresh d3 projection of the given kind, before fitting. */
18
+ export declare function baseProjection(type: GeoMapProjection): GeoProjection;
19
+ /**
20
+ * A projection fitted to a `width` × `height` box: the whole world (the sphere) inside it with
21
+ * `FIT_PADDING` around, centered. A globe is turned to `rotation` first and then scaled by `scale` (1 is
22
+ * the fitted disc).
23
+ */
24
+ export declare function fittedProjection(type: GeoMapProjection, width: number, height: number, rotation?: Rotation, scale?: number): GeoProjection;
25
+ /** Whether a point faces the viewer on a globe turned to `rotation` (within 90° of its center). */
26
+ export declare function facesViewer(point: LonLat, rotation: Rotation): boolean;
27
+ /** The rotation that puts `[longitude, latitude]` in the middle of a globe, keeping its roll. */
28
+ export declare function rotationFacing(point: LonLat, roll?: number): Rotation;
29
+ /**
30
+ * A connection between two points on screen, as an SVG path (`connection-map.ts:517-618`):
31
+ *
32
+ * - `straight`: a line.
33
+ * - `quadratic`: a curve whose control point sits off the midpoint, perpendicular to the line, by 0.3 of
34
+ * the distance (always to the same side of the travel direction, so A→B and B→A bow apart).
35
+ * - `greatCircle` on a flat map: a gentler curve (0.2 of the distance), always bowed up the screen, which
36
+ * reads as the shortest way over the globe without wrapping around the map's edge.
37
+ */
38
+ export declare function screenArc(style: GeoMapArcStyle, a: Point, b: Point): string;
39
+ /** How many points a great-circle arc on the globe is sampled at. */
40
+ export declare const ARC_SAMPLES = 50;
41
+ /**
42
+ * A great circle between two places on a globe: `geoInterpolate` sampled at `ARC_SAMPLES` points and
43
+ * projected. Points over the horizon are left out, so an arc that crosses it ends at the edge (hyper-ui
44
+ * dropped the whole arc as soon as one end turned away). Empty when none of it faces the viewer.
45
+ */
46
+ export declare function globeArc(projection: GeoProjection, a: LonLat, b: LonLat): string;
47
+ /** Degrees of rotation per dragged pixel, at a scale of 1. */
48
+ export declare const GLOBE_SENSITIVITY = 0.5;
49
+ export declare const GLOBE_SCALE_MIN = 0.5;
50
+ export declare const GLOBE_SCALE_MAX = 8;
51
+ export interface GlobeView {
52
+ rotation: Rotation;
53
+ /** 1 is the fitted disc. */
54
+ scale: number;
55
+ /** A drag in progress: where the pointer went down and the rotation then. */
56
+ drag: {
57
+ x: number;
58
+ y: number;
59
+ from: Rotation;
60
+ } | null;
61
+ }
62
+ export type GlobeEvent = {
63
+ type: "dragStart";
64
+ x: number;
65
+ y: number;
66
+ } | {
67
+ type: "dragMove";
68
+ x: number;
69
+ y: number;
70
+ } | {
71
+ type: "dragEnd";
72
+ } | {
73
+ type: "scaleBy";
74
+ factor: number;
75
+ } | {
76
+ type: "scaleTo";
77
+ scale: number;
78
+ } | {
79
+ type: "rotateTo";
80
+ rotation: Rotation;
81
+ };
82
+ /** The next globe view for an event; the same object when nothing changed. */
83
+ export declare function globeTransition(view: GlobeView, event: GlobeEvent): GlobeView;
84
+ /** A box on the flat map, in its pixels before zoom (the viewport's canvas units). */
85
+ export interface Rect {
86
+ left: number;
87
+ top: number;
88
+ right: number;
89
+ bottom: number;
90
+ }
91
+ /** The box around projected points, or null for none. */
92
+ export declare function boundsOf(points: readonly Point[]): Rect | null;
93
+ /** A flat map's pan and zoom: the world's top left at `x`, `y` on screen, `zoom` times its fitted size. */
94
+ export interface FlatView {
95
+ x: number;
96
+ y: number;
97
+ zoom: number;
98
+ }
99
+ export declare const FLAT_ZOOM_MIN = 1;
100
+ export declare const FLAT_ZOOM_MAX = 12;
101
+ /**
102
+ * A flat view kept in bounds: zoomed between `FLAT_ZOOM_MIN` and `FLAT_ZOOM_MAX`, and panned no further
103
+ * than the world's edges (at zoom 1 it doesn't move).
104
+ */
105
+ export declare function clampFlat(view: FlatView, width: number, height: number): FlatView;
106
+ /**
107
+ * The flat view that shows `rect` whole and centered with `padding` around it, zoomed in no further than
108
+ * `maxZoom` (a lone marker gets `maxZoom`).
109
+ */
110
+ export declare function fitFlat(rect: Rect, width: number, height: number, padding?: number, maxZoom?: number): FlatView;
111
+ /**
112
+ * The globe view that shows every place: turned to face their middle (the mean of their unit vectors,
113
+ * so places on both sides of the date line average correctly), and scaled until the farthest one sits
114
+ * inside the disc's rim. A spread wider than a hemisphere keeps the fitted disc (scale 1).
115
+ */
116
+ export declare function globeFit(places: readonly LonLat[], roll?: number): Pick<GlobeView, "rotation" | "scale"> | null;
@@ -0,0 +1,4 @@
1
+ export { GeoMap, geoMapColor } from "./geo-map.js";
2
+ export type { GeoMapProps } from "./geo-map.js";
3
+ export type { GeoMapArcStyle, GeoMapProjection, GeoMapColor, GeoMapConnection, GeoMapController, GeoMapFeature, GeoMapGeometry, GeoMapLabels, GeoMapMarker, GeoMapView, GeoMapWorld, } from "./types.js";
4
+ export { loadWorld } from "./world.js";