@cosmos.gl/deck-layers 3.5.1 → 3.6.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/dist/cosmos-graph-layer.d.ts +71 -4
- package/dist/index.js +239 -114
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -280,6 +280,17 @@ export declare class CosmosGraphLayer<PointDataT = unknown, LinkDataT = unknown>
|
|
|
280
280
|
loadedPairs?: Float32Array | null;
|
|
281
281
|
idToIndex?: Map<string | number, number> | null;
|
|
282
282
|
keptLinks: readonly LinkDataT[] | null;
|
|
283
|
+
/**
|
|
284
|
+
* `getBounds`' measured box: the last one read back (`null` when nothing finite was
|
|
285
|
+
* there), the position texture version it was asked at, and whether a read is on its
|
|
286
|
+
* way. Unset until the first read lands, and again when a new dataset is loaded. The
|
|
287
|
+
* serial counts the datasets loaded: a read of the previous one that lands after the
|
|
288
|
+
* next is dropped.
|
|
289
|
+
*/
|
|
290
|
+
measuredBounds?: [number[], number[]] | null;
|
|
291
|
+
measuredBoundsVersion?: number;
|
|
292
|
+
isMeasuringBounds?: boolean;
|
|
293
|
+
loadSerial?: number;
|
|
283
294
|
/** The view was found unsupported and said so; said once. */
|
|
284
295
|
viewWarned?: boolean;
|
|
285
296
|
linksWarned?: boolean;
|
|
@@ -308,7 +319,40 @@ export declare class CosmosGraphLayer<PointDataT = unknown, LinkDataT = unknown>
|
|
|
308
319
|
onDragStart(info: PickingInfo, event: DragGestureEvent): boolean;
|
|
309
320
|
onDrag(info: PickingInfo, event: DragGestureEvent): boolean;
|
|
310
321
|
onDragEnd(info: PickingInfo, event: DragGestureEvent): boolean;
|
|
311
|
-
/**
|
|
322
|
+
/**
|
|
323
|
+
* The box around the graph's points, `[[minX, minY, 0], [maxX, maxY, 0]]`, for an
|
|
324
|
+
* application to frame the layer with. In space coordinates, before `modelMatrix`: map it
|
|
325
|
+
* through `modelMatrix` (and, on a map, unproject it) before fitting a viewport to it.
|
|
326
|
+
* deck.gl's core does not call it; its mask effect reads it from every mask layer and its
|
|
327
|
+
* collision-filter effect from every layer carrying that extension, each on every frame.
|
|
328
|
+
*
|
|
329
|
+
* `spaceSize` bounds no position — a layout grows past its square as far as its forces
|
|
330
|
+
* take it — so the box is measured from the live positions, read back from the GPU. The
|
|
331
|
+
* read does not stall the frame: it is asynchronous, started by a call that finds the
|
|
332
|
+
* positions changed since the box was measured, one at a time, and the box it returns is
|
|
333
|
+
* the last one measured. While a read is on its way the layer holds the graph's step, as
|
|
334
|
+
* the engine's own render loop holds its frame for a copy: the read that completes a copy
|
|
335
|
+
* waits for every command queued before it, and a step queued behind the copy would be
|
|
336
|
+
* that wait. (A graph the application steps itself is not held.) While points move the
|
|
337
|
+
* box trails the drawn frame, by a frame or so, and a call made before the first read
|
|
338
|
+
* lands — or before the first read of a newly loaded dataset — gets the input box below.
|
|
339
|
+
* When a read lands the layer asks for a redraw, so a consumer reading the box every
|
|
340
|
+
* frame has the new one on the next. A layer nobody asks reads nothing. Absent points
|
|
341
|
+
* (NaN) are left out.
|
|
342
|
+
*
|
|
343
|
+
* Until the graph holds positions (its device is still initializing) or the first read
|
|
344
|
+
* has landed, the box is that of the positions the layer is about to load or has loaded:
|
|
345
|
+
* `initialPositions`, or `getPointPosition` over the point objects, plus the middle half
|
|
346
|
+
* of the space where unseeded points are placed — where the points start, so a view can
|
|
347
|
+
* be framed before the first frame.
|
|
348
|
+
*
|
|
349
|
+
* When there is nothing to measure — no points yet, every point absent, or positions the
|
|
350
|
+
* graph rescales on load (`rescalePositions: true`), which it centres on the space — the
|
|
351
|
+
* box is the space's square, `[[0, 0, 0], [spaceSize, spaceSize, 0]]`: where the graph
|
|
352
|
+
* starts, and what this method returned before layouts could leave the square. It is
|
|
353
|
+
* never `null`; the declared type keeps deck's `Layer.getBounds` contract, so a subclass
|
|
354
|
+
* may still override it with deck's own signature.
|
|
355
|
+
*/
|
|
312
356
|
getBounds(): [number[], number[]] | null;
|
|
313
357
|
finalizeState(context: LayerContext): void;
|
|
314
358
|
/** No deck attributes: cosmos.gl holds every channel and draws them itself. */
|
|
@@ -337,7 +381,28 @@ export declare class CosmosGraphLayer<PointDataT = unknown, LinkDataT = unknown>
|
|
|
337
381
|
* the hover this layer put on it. deck sends no leave to a layer it removes.
|
|
338
382
|
*/
|
|
339
383
|
private _releaseGraph;
|
|
340
|
-
/**
|
|
384
|
+
/**
|
|
385
|
+
* Starts one asynchronous read of the live positions and keeps its box for `getBounds`,
|
|
386
|
+
* stamped with the texture version the read was asked at. A read that lands after the
|
|
387
|
+
* layer let go of the graph is dropped; an empty result (nothing to read, or the point
|
|
388
|
+
* count changed under the copy) leaves the box as it was, and the next call asks again.
|
|
389
|
+
*/
|
|
390
|
+
private _measureBounds;
|
|
391
|
+
/** The space's square, the stand-in extent when there is nothing to measure (see `getBounds`). */
|
|
392
|
+
private _spaceSquare;
|
|
393
|
+
/**
|
|
394
|
+
* Adds the positions the layer would load to `box` (see `getBounds`): the given ones,
|
|
395
|
+
* placed as the engine will place them, and the square unseeded points are drawn in.
|
|
396
|
+
* Nothing when they are rescaled on load.
|
|
397
|
+
*/
|
|
398
|
+
private _addInputPositions;
|
|
399
|
+
/**
|
|
400
|
+
* The length the engine's placement rules are fractions of: the infinite-input edge, the
|
|
401
|
+
* unseeded square, and the stand-in extent. The graph's own, validated, length once
|
|
402
|
+
* there is a graph — from its construction, so the default when its config's `spaceSize`
|
|
403
|
+
* is not a usable size, and authoritative for a provided graph — the config's before.
|
|
404
|
+
* It sizes nothing.
|
|
405
|
+
*/
|
|
341
406
|
private _spaceSize;
|
|
342
407
|
/**
|
|
343
408
|
* The config for a layer-created graph: the prop without the keys deck owns,
|
|
@@ -351,8 +416,10 @@ export declare class CosmosGraphLayer<PointDataT = unknown, LinkDataT = unknown>
|
|
|
351
416
|
* unit) and a translation, per `setViewTransform`'s space → screen formula,
|
|
352
417
|
* inverted. Three anchors through deck's projection — the space origin, its
|
|
353
418
|
* x axis, its y axis — give the scale and tell whether the view is one cosmos
|
|
354
|
-
* can draw: unrotated, unpitched, y up. The
|
|
355
|
-
*
|
|
419
|
+
* can draw: unrotated, unpitched, y up. The translation then follows from where
|
|
420
|
+
* the space origin lands and the world origin cosmos centres its screen on, read
|
|
421
|
+
* from the engine (`spaceSize / 2` on both axes, after the engine's own space-size
|
|
422
|
+
* adjustment). The space origin's pixel is returned too, for mapping the other way.
|
|
356
423
|
*/
|
|
357
424
|
private _viewTransform;
|
|
358
425
|
private _onTimelineTick;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { COORDINATE_SYSTEM as
|
|
2
|
-
import { Graph as
|
|
3
|
-
const
|
|
1
|
+
import { COORDINATE_SYSTEM as it, Layer as nt } from "@deck.gl/core";
|
|
2
|
+
import { Graph as ot, defaultConfigValues as st } from "@cosmos.gl/graph";
|
|
3
|
+
const rt = [
|
|
4
4
|
"enableRenderLoop",
|
|
5
5
|
"backgroundColor",
|
|
6
6
|
"pixelRatio",
|
|
@@ -39,17 +39,17 @@ const et = [
|
|
|
39
39
|
"onDragStart",
|
|
40
40
|
"onDrag",
|
|
41
41
|
"onDragEnd"
|
|
42
|
-
],
|
|
42
|
+
], N = (a) => (e) => e == null || typeof e == "function" || (a === "number" ? typeof e == "number" : Array.isArray(e) || ArrayBuffer.isView(e)), at = {
|
|
43
43
|
points: { type: "object", value: null, optional: !0 },
|
|
44
44
|
links: null,
|
|
45
45
|
getPointId: { type: "accessor", value: null },
|
|
46
46
|
getPointPosition: { type: "accessor", value: null },
|
|
47
|
-
getPointSize: { type: "accessor", value: null, validate:
|
|
48
|
-
getPointColor: { type: "accessor", value: null, validate:
|
|
47
|
+
getPointSize: { type: "accessor", value: null, validate: N("number") },
|
|
48
|
+
getPointColor: { type: "accessor", value: null, validate: N("color") },
|
|
49
49
|
getLinkSource: { type: "accessor", value: (a) => a.source },
|
|
50
50
|
getLinkTarget: { type: "accessor", value: (a) => a.target },
|
|
51
|
-
getLinkColor: { type: "accessor", value: null, validate:
|
|
52
|
-
getLinkWidth: { type: "accessor", value: null, validate:
|
|
51
|
+
getLinkColor: { type: "accessor", value: null, validate: N("color") },
|
|
52
|
+
getLinkWidth: { type: "accessor", value: null, validate: N("number") },
|
|
53
53
|
enablePointDrag: !1,
|
|
54
54
|
dragReheatAlpha: 0.1,
|
|
55
55
|
unpinOnDragEnd: !0,
|
|
@@ -61,8 +61,8 @@ const et = [
|
|
|
61
61
|
onGraphCreated: { type: "function", value: null, optional: !0 },
|
|
62
62
|
onGraphDataLoaded: { type: "function", value: null, optional: !0 },
|
|
63
63
|
// cosmos draws its space coordinates as world coordinates; `modelMatrix` places the space
|
|
64
|
-
coordinateSystem:
|
|
65
|
-
},
|
|
64
|
+
coordinateSystem: it.CARTESIAN
|
|
65
|
+
}, R = (a, e, t) => typeof a == "function" ? a(e, t) : a, W = (a, e) => a !== e && !(typeof a == "function" && typeof e == "function"), lt = (a, e) => {
|
|
66
66
|
if (a === e) return !0;
|
|
67
67
|
if (!a || !e) return !1;
|
|
68
68
|
const t = Object.keys(a);
|
|
@@ -70,27 +70,43 @@ const et = [
|
|
|
70
70
|
const n = a[i], s = e[i];
|
|
71
71
|
return Array.isArray(n) && Array.isArray(s) ? n.length === s.length && n.every((o, r) => o === s[r]) : n === s;
|
|
72
72
|
});
|
|
73
|
-
},
|
|
73
|
+
}, Z = (a, e, t, i) => {
|
|
74
74
|
if (i) {
|
|
75
75
|
const { value: o } = i;
|
|
76
76
|
return o instanceof Float32Array ? o : Float32Array.from(o, (r) => r / 255);
|
|
77
77
|
}
|
|
78
78
|
const n = new Float32Array(a * 4), s = t ?? { length: a };
|
|
79
79
|
for (let o = 0; o < a; o += 1) {
|
|
80
|
-
const r =
|
|
80
|
+
const r = R(e, t == null ? void 0 : t[o], { index: o, data: s, target: [] });
|
|
81
81
|
n[o * 4] = r[0] / 255, n[o * 4 + 1] = r[1] / 255, n[o * 4 + 2] = r[2] / 255, n[o * 4 + 3] = (r[3] ?? 255) / 255;
|
|
82
82
|
}
|
|
83
83
|
return n;
|
|
84
|
-
},
|
|
84
|
+
}, q = (a, e, t, i) => {
|
|
85
85
|
if (i) {
|
|
86
86
|
const { value: o } = i;
|
|
87
87
|
return o instanceof Float32Array ? o : Float32Array.from(o);
|
|
88
88
|
}
|
|
89
89
|
const n = new Float32Array(a), s = t ?? { length: a };
|
|
90
90
|
for (let o = 0; o < a; o += 1)
|
|
91
|
-
n[o] =
|
|
91
|
+
n[o] = R(e, t == null ? void 0 : t[o], { index: o, data: s, target: [] });
|
|
92
92
|
return n;
|
|
93
|
-
},
|
|
93
|
+
}, $ = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap(), D = [0.25, 0.75], dt = 4096, K = (a, e) => {
|
|
94
|
+
const t = Math.fround(a);
|
|
95
|
+
return t === 1 / 0 ? e : t === -1 / 0 ? 0 : t;
|
|
96
|
+
};
|
|
97
|
+
class j {
|
|
98
|
+
constructor() {
|
|
99
|
+
this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0;
|
|
100
|
+
}
|
|
101
|
+
add(e, t) {
|
|
102
|
+
!Number.isFinite(e) || !Number.isFinite(t) || (e < this.minX && (this.minX = e), e > this.maxX && (this.maxX = e), t < this.minY && (this.minY = t), t > this.maxY && (this.maxY = t));
|
|
103
|
+
}
|
|
104
|
+
/** Layer.getBounds' shape, z = 0; `null` when no point was added. */
|
|
105
|
+
bounds() {
|
|
106
|
+
return this.minX > this.maxX ? null : [[this.minX, this.minY, 0], [this.maxX, this.maxY, 0]];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const ut = Symbol("seeded"), J = new Float32Array(0), b = new Float32Array(0), v = (a, e) => a != null || e != null, Q = (a) => a && !Array.isArray(a) ? a.attributes : void 0, tt = (a) => a && !Array.isArray(a) && !(a instanceof Float32Array) ? a.attributes : void 0, O = class O extends nt {
|
|
94
110
|
get isLoaded() {
|
|
95
111
|
var e;
|
|
96
112
|
return super.isLoaded && !!((e = this.state) != null && e.isReady);
|
|
@@ -122,19 +138,19 @@ const et = [
|
|
|
122
138
|
o && (this._releaseGraph(), this._attachGraph(s));
|
|
123
139
|
const r = this.state.graph;
|
|
124
140
|
if (!r) return;
|
|
125
|
-
!s && !o && !
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
128
|
-
const k = !!i.points && !o,
|
|
129
|
-
pointColorUnset: S(
|
|
130
|
-
pointSizeUnset: S(
|
|
131
|
-
linkColorUnset: S(
|
|
132
|
-
linkWidthUnset: S(
|
|
141
|
+
!s && !o && !lt(t.config, i.config) && r.setConfig(this._graphConfig());
|
|
142
|
+
const l = typeof n.updateTriggersChanged == "object" ? n.updateTriggersChanged : void 0, g = (_) => !!(l != null && l.all || l != null && l[_]), d = o || t.points !== i.points || g("getPointPosition"), f = g("getPointId"), u = o || t.links !== i.links || g("getLinkSource") || g("getLinkTarget") || f, c = d || g("getPointColor") || g("getPointSize") || W(t.getPointColor, i.getPointColor) || W(t.getPointSize, i.getPointSize), x = u || g("getLinkColor") || g("getLinkWidth") || W(t.getLinkColor, i.getLinkColor) || W(t.getLinkWidth, i.getLinkWidth);
|
|
143
|
+
if (!d && !u && !c && !x) return;
|
|
144
|
+
const k = !!i.points && !o, y = Q(i.points), C = Q(t.points), m = tt(i.links), p = tt(t.links), S = (_, M) => k && _ && !M, T = {
|
|
145
|
+
pointColorUnset: S(v(i.getPointColor, y == null ? void 0 : y.getPointColor), v(t.getPointColor, C == null ? void 0 : C.getPointColor)),
|
|
146
|
+
pointSizeUnset: S(v(i.getPointSize, y == null ? void 0 : y.getPointSize), v(t.getPointSize, C == null ? void 0 : C.getPointSize)),
|
|
147
|
+
linkColorUnset: S(v(i.getLinkColor, m == null ? void 0 : m.getLinkColor), v(t.getLinkColor, p == null ? void 0 : p.getLinkColor)),
|
|
148
|
+
linkWidthUnset: S(v(i.getLinkWidth, m == null ? void 0 : m.getLinkWidth), v(t.getLinkWidth, p == null ? void 0 : p.getLinkWidth))
|
|
133
149
|
};
|
|
134
|
-
t.points ? this.state.isReady ? this._load({ pointsChanged:
|
|
150
|
+
t.points ? this.state.isReady ? this._load({ pointsChanged: d, linksChanged: u, idsChanged: f, pointStyleChanged: c, linkStyleChanged: x, ...T }) : this.state.isIngestPending = !0 : (t.links && !this.state.linksWarned && (this.state.linksWarned = !0, console.warn("@cosmos.gl/deck-layers: `links` is ignored without `points` — load them into the graph instead")), this.state.isIngestPending = !1, this.state.hasLoaded = !1);
|
|
135
151
|
}
|
|
136
152
|
draw(e) {
|
|
137
|
-
var o, r,
|
|
153
|
+
var o, r, l, g;
|
|
138
154
|
const { graph: t, isReady: i } = this.state;
|
|
139
155
|
if (!t || !i) return;
|
|
140
156
|
const { viewport: n } = this.context, s = this._viewTransform(t, n);
|
|
@@ -142,7 +158,7 @@ const et = [
|
|
|
142
158
|
if (t.setViewTransform(s, [n.width, n.height]), (r = (o = e.shaderModuleProps) == null ? void 0 : o.picking) != null && r.isActive) {
|
|
143
159
|
t.drawToRenderPass(this.context.renderPass, {
|
|
144
160
|
picking: {
|
|
145
|
-
alpha: ((
|
|
161
|
+
alpha: ((g = (l = e.parameters) == null ? void 0 : l.blendColor) == null ? void 0 : g[3]) ?? 1,
|
|
146
162
|
linkIndexOffset: t.graph.pointsNumber ?? 0
|
|
147
163
|
}
|
|
148
164
|
});
|
|
@@ -159,26 +175,62 @@ const et = [
|
|
|
159
175
|
return e.index >= n ? (t.elementType = "link", t.index = e.index - n, t.object = Array.isArray(o) ? (r = this.state.keptLinks) == null ? void 0 : r[t.index] : void 0) : (t.elementType = "point", t.object = Array.isArray(s) ? s[e.index] : void 0), t;
|
|
160
176
|
}
|
|
161
177
|
onDragStart(e, t) {
|
|
162
|
-
var r,
|
|
178
|
+
var r, l, g;
|
|
163
179
|
const { graph: i } = this.state, { enablePointDrag: n, dragReheatAlpha: s } = this.props, o = e;
|
|
164
|
-
return !n || !i || o.elementType !== "point" || e.index < 0 ? !1 : (this.state.draggedPointIndex = e.index, i.setPinnedPoint(e.index, !0), s !== null && i.start(s), (r = t.stopImmediatePropagation) == null || r.call(t), (
|
|
180
|
+
return !n || !i || o.elementType !== "point" || e.index < 0 ? !1 : (this.state.draggedPointIndex = e.index, i.setPinnedPoint(e.index, !0), s !== null && i.start(s), (r = t.stopImmediatePropagation) == null || r.call(t), (g = (l = this.props).onPointDragStart) == null || g.call(l, o), !0);
|
|
165
181
|
}
|
|
166
182
|
onDrag(e, t) {
|
|
167
|
-
var o, r,
|
|
183
|
+
var o, r, l;
|
|
168
184
|
const { graph: i, draggedPointIndex: n } = this.state;
|
|
169
185
|
if (!i || n === null) return !1;
|
|
170
186
|
const s = this._dragPosition(i, e);
|
|
171
|
-
return s && i.setPointPosition(n, s[0], s[1]), (o = t.stopImmediatePropagation) == null || o.call(t), (this.getCurrentLayer() ?? this).setNeedsRedraw(), (
|
|
187
|
+
return s && i.setPointPosition(n, s[0], s[1]), (o = t.stopImmediatePropagation) == null || o.call(t), (this.getCurrentLayer() ?? this).setNeedsRedraw(), (l = (r = this.props).onPointDrag) == null || l.call(r, e), !0;
|
|
172
188
|
}
|
|
173
189
|
onDragEnd(e, t) {
|
|
174
190
|
var s, o, r;
|
|
175
191
|
const { graph: i, draggedPointIndex: n } = this.state;
|
|
176
192
|
return !i || n === null ? !1 : (this.props.unpinOnDragEnd && i.setPinnedPoint(n, !1), this.state.draggedPointIndex = null, (s = t.stopImmediatePropagation) == null || s.call(t), (r = (o = this.props).onPointDragEnd) == null || r.call(o, e), !0);
|
|
177
193
|
}
|
|
178
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* The box around the graph's points, `[[minX, minY, 0], [maxX, maxY, 0]]`, for an
|
|
196
|
+
* application to frame the layer with. In space coordinates, before `modelMatrix`: map it
|
|
197
|
+
* through `modelMatrix` (and, on a map, unproject it) before fitting a viewport to it.
|
|
198
|
+
* deck.gl's core does not call it; its mask effect reads it from every mask layer and its
|
|
199
|
+
* collision-filter effect from every layer carrying that extension, each on every frame.
|
|
200
|
+
*
|
|
201
|
+
* `spaceSize` bounds no position — a layout grows past its square as far as its forces
|
|
202
|
+
* take it — so the box is measured from the live positions, read back from the GPU. The
|
|
203
|
+
* read does not stall the frame: it is asynchronous, started by a call that finds the
|
|
204
|
+
* positions changed since the box was measured, one at a time, and the box it returns is
|
|
205
|
+
* the last one measured. While a read is on its way the layer holds the graph's step, as
|
|
206
|
+
* the engine's own render loop holds its frame for a copy: the read that completes a copy
|
|
207
|
+
* waits for every command queued before it, and a step queued behind the copy would be
|
|
208
|
+
* that wait. (A graph the application steps itself is not held.) While points move the
|
|
209
|
+
* box trails the drawn frame, by a frame or so, and a call made before the first read
|
|
210
|
+
* lands — or before the first read of a newly loaded dataset — gets the input box below.
|
|
211
|
+
* When a read lands the layer asks for a redraw, so a consumer reading the box every
|
|
212
|
+
* frame has the new one on the next. A layer nobody asks reads nothing. Absent points
|
|
213
|
+
* (NaN) are left out.
|
|
214
|
+
*
|
|
215
|
+
* Until the graph holds positions (its device is still initializing) or the first read
|
|
216
|
+
* has landed, the box is that of the positions the layer is about to load or has loaded:
|
|
217
|
+
* `initialPositions`, or `getPointPosition` over the point objects, plus the middle half
|
|
218
|
+
* of the space where unseeded points are placed — where the points start, so a view can
|
|
219
|
+
* be framed before the first frame.
|
|
220
|
+
*
|
|
221
|
+
* When there is nothing to measure — no points yet, every point absent, or positions the
|
|
222
|
+
* graph rescales on load (`rescalePositions: true`), which it centres on the space — the
|
|
223
|
+
* box is the space's square, `[[0, 0, 0], [spaceSize, spaceSize, 0]]`: where the graph
|
|
224
|
+
* starts, and what this method returned before layouts could leave the square. It is
|
|
225
|
+
* never `null`; the declared type keeps deck's `Layer.getBounds` contract, so a subclass
|
|
226
|
+
* may still override it with deck's own signature.
|
|
227
|
+
*/
|
|
179
228
|
getBounds() {
|
|
180
|
-
const e = this.
|
|
181
|
-
|
|
229
|
+
const { state: e } = this, t = e == null ? void 0 : e.graph, i = t == null ? void 0 : t.getPointPositionTexture();
|
|
230
|
+
if (t && i && i.pointCount > 0 && (i.version !== e.measuredBoundsVersion && !e.isMeasuringBounds && this._measureBounds(t, i.version), e.measuredBounds !== void 0))
|
|
231
|
+
return e.measuredBounds ?? this._spaceSquare();
|
|
232
|
+
const n = new j();
|
|
233
|
+
return this._addInputPositions(n), n.bounds() ?? this._spaceSquare();
|
|
182
234
|
}
|
|
183
235
|
finalizeState(e) {
|
|
184
236
|
var t;
|
|
@@ -216,7 +268,7 @@ const et = [
|
|
|
216
268
|
/** Adopts the provided graph, or creates a headless one on deck's device when `provided` is `null`. */
|
|
217
269
|
_attachGraph(e) {
|
|
218
270
|
var n, s;
|
|
219
|
-
const { device: t } = this.context, i = e ?? new
|
|
271
|
+
const { device: t } = this.context, i = e ?? new ot(null, this._graphConfig(), Promise.resolve(t));
|
|
220
272
|
this.setState({
|
|
221
273
|
graph: i,
|
|
222
274
|
providedGraph: e,
|
|
@@ -257,12 +309,79 @@ const et = [
|
|
|
257
309
|
*/
|
|
258
310
|
_releaseGraph() {
|
|
259
311
|
const { graph: e, providedGraph: t, holdsHover: i } = this.state;
|
|
260
|
-
e && t ? i && (e.setHostHoveredPoint(void 0), e.setHostHoveredLink(void 0)) : e && e.destroy(), this.state.graph = void 0, this.state.holdsHover = !1;
|
|
312
|
+
e && t ? i && (e.setHostHoveredPoint(void 0), e.setHostHoveredLink(void 0)) : e && e.destroy(), this.state.graph = void 0, this.state.holdsHover = !1, this.state.measuredBounds = void 0, this.state.measuredBoundsVersion = void 0, this.state.isMeasuringBounds = !1;
|
|
261
313
|
}
|
|
262
|
-
/**
|
|
314
|
+
/**
|
|
315
|
+
* Starts one asynchronous read of the live positions and keeps its box for `getBounds`,
|
|
316
|
+
* stamped with the texture version the read was asked at. A read that lands after the
|
|
317
|
+
* layer let go of the graph is dropped; an empty result (nothing to read, or the point
|
|
318
|
+
* count changed under the copy) leaves the box as it was, and the next call asks again.
|
|
319
|
+
*/
|
|
320
|
+
_measureBounds(e, t) {
|
|
321
|
+
const { state: i } = this, n = i.loadSerial;
|
|
322
|
+
i.isMeasuringBounds = !0, z.set(e, (z.get(e) ?? 0) + 1);
|
|
323
|
+
const s = () => {
|
|
324
|
+
z.set(e, Math.max(0, (z.get(e) ?? 1) - 1));
|
|
325
|
+
};
|
|
326
|
+
e.getPointPositionsAsync().then((o) => {
|
|
327
|
+
if (s(), i.graph !== e) return;
|
|
328
|
+
if (i.isMeasuringBounds = !1, i.loadSerial !== n) {
|
|
329
|
+
(this.getCurrentLayer() ?? this).setNeedsRedraw();
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (o.length === 0) return;
|
|
333
|
+
const r = new j();
|
|
334
|
+
for (let l = 0; l < o.length; l += 2) r.add(o[l], o[l + 1]);
|
|
335
|
+
i.measuredBounds = r.bounds(), i.measuredBoundsVersion = t, (this.getCurrentLayer() ?? this).setNeedsRedraw();
|
|
336
|
+
}, () => {
|
|
337
|
+
s(), i.graph === e && (i.isMeasuringBounds = !1, (this.getCurrentLayer() ?? this).setNeedsRedraw());
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/** The space's square, the stand-in extent when there is nothing to measure (see `getBounds`). */
|
|
341
|
+
_spaceSquare() {
|
|
342
|
+
const e = this._spaceSize();
|
|
343
|
+
return [[0, 0, 0], [e, e, 0]];
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Adds the positions the layer would load to `box` (see `getBounds`): the given ones,
|
|
347
|
+
* placed as the engine will place them, and the square unseeded points are drawn in.
|
|
348
|
+
* Nothing when they are rescaled on load.
|
|
349
|
+
*/
|
|
350
|
+
_addInputPositions(e) {
|
|
351
|
+
var r, l, g;
|
|
352
|
+
const { points: t, getPointPosition: i } = this.props;
|
|
353
|
+
if (!t || ((g = ((l = (r = this.state) == null ? void 0 : r.graph) == null ? void 0 : l.config) ?? this.props.config) == null ? void 0 : g.rescalePositions) === !0) return;
|
|
354
|
+
const n = this._spaceSize(), s = (d, f) => {
|
|
355
|
+
Number.isNaN(d) || Number.isNaN(f) || e.add(K(d, n), K(f, n));
|
|
356
|
+
};
|
|
357
|
+
let o = !1;
|
|
358
|
+
if (Array.isArray(t)) {
|
|
359
|
+
const d = t;
|
|
360
|
+
for (let f = 0; f < d.length; f += 1) {
|
|
361
|
+
const u = { index: f, data: d, target: [] }, c = i ? R(i, d[f], u) : null;
|
|
362
|
+
c ? s(c[0], c[1]) : o = !0;
|
|
363
|
+
}
|
|
364
|
+
} else {
|
|
365
|
+
const { length: d, initialPositions: f } = t;
|
|
366
|
+
if (f)
|
|
367
|
+
for (let u = 0; u < d; u += 1) s(f[u * 2], f[u * 2 + 1]);
|
|
368
|
+
else o = d > 0;
|
|
369
|
+
}
|
|
370
|
+
o && (e.add(n * D[0], n * D[0]), e.add(n * D[1], n * D[1]));
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The length the engine's placement rules are fractions of: the infinite-input edge, the
|
|
374
|
+
* unseeded square, and the stand-in extent. The graph's own, validated, length once
|
|
375
|
+
* there is a graph — from its construction, so the default when its config's `spaceSize`
|
|
376
|
+
* is not a usable size, and authoritative for a provided graph — the config's before.
|
|
377
|
+
* It sizes nothing.
|
|
378
|
+
*/
|
|
263
379
|
_spaceSize() {
|
|
264
|
-
var
|
|
265
|
-
|
|
380
|
+
var i, n, s;
|
|
381
|
+
const e = (n = (i = this.state) == null ? void 0 : i.graph) == null ? void 0 : n.simulation.store.referenceLength;
|
|
382
|
+
if (e !== void 0) return e;
|
|
383
|
+
const t = (s = this.props.config) == null ? void 0 : s.spaceSize;
|
|
384
|
+
return t === void 0 || !Number.isFinite(t) || t <= 0 ? st.spaceSize : Math.max(t, 2);
|
|
266
385
|
}
|
|
267
386
|
/**
|
|
268
387
|
* The config for a layer-created graph: the prop without the keys deck owns,
|
|
@@ -270,7 +389,7 @@ const et = [
|
|
|
270
389
|
*/
|
|
271
390
|
_graphConfig() {
|
|
272
391
|
const e = { ...this.props.config };
|
|
273
|
-
for (const t of
|
|
392
|
+
for (const t of rt) delete e[t];
|
|
274
393
|
return e.pixelRatio = this._pixelRatio(), e;
|
|
275
394
|
}
|
|
276
395
|
/** deck's device pixels per CSS pixel, as its canvas context reports them. */
|
|
@@ -284,27 +403,33 @@ const et = [
|
|
|
284
403
|
* unit) and a translation, per `setViewTransform`'s space → screen formula,
|
|
285
404
|
* inverted. Three anchors through deck's projection — the space origin, its
|
|
286
405
|
* x axis, its y axis — give the scale and tell whether the view is one cosmos
|
|
287
|
-
* can draw: unrotated, unpitched, y up. The
|
|
288
|
-
*
|
|
406
|
+
* can draw: unrotated, unpitched, y up. The translation then follows from where
|
|
407
|
+
* the space origin lands and the world origin cosmos centres its screen on, read
|
|
408
|
+
* from the engine (`spaceSize / 2` on both axes, after the engine's own space-size
|
|
409
|
+
* adjustment). The space origin's pixel is returned too, for mapping the other way.
|
|
289
410
|
*/
|
|
290
411
|
_viewTransform(e, t) {
|
|
291
|
-
const i = e.
|
|
292
|
-
const
|
|
293
|
-
return [
|
|
294
|
-
}, [
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
412
|
+
const { worldOrigin: i } = e.simulation.store, n = dt, s = this.props.modelMatrix, o = (p, S) => {
|
|
413
|
+
const T = s ? s[0] * p + s[4] * S + s[12] : p, _ = s ? s[1] * p + s[5] * S + s[13] : S, M = t.unprojectPosition([T, _, 0]), E = t.project(M);
|
|
414
|
+
return [E[0], E[1]];
|
|
415
|
+
}, [r, l] = o(0, 0), [g, d] = o(n, 0), [f, u] = o(0, n), c = (g - r) / n, x = 1e-3 * Math.max(1, Math.abs(g - r)), k = Math.abs(d - l) > x || Math.abs(f - r) > x, y = u > l;
|
|
416
|
+
if (k || y || !(c > 0))
|
|
417
|
+
return this.state.viewWarned || (this.state.viewWarned = !0, console.warn(
|
|
418
|
+
"@cosmos.gl/deck-layers: cosmos.gl draws under a flat, north-up, y-up view only — use OrthographicView({ flipY: false }) or a map at pitch 0 and bearing 0. The graph is not drawn."
|
|
419
|
+
)), null;
|
|
420
|
+
this.state.viewWarned = !1;
|
|
421
|
+
const [C, m] = i;
|
|
422
|
+
return {
|
|
423
|
+
k: c,
|
|
424
|
+
x: r - c * (t.width / 2 - C),
|
|
425
|
+
y: l - c * (m + t.height / 2),
|
|
426
|
+
originX: r,
|
|
427
|
+
originY: l
|
|
428
|
+
};
|
|
304
429
|
}
|
|
305
430
|
_onTimelineTick(e) {
|
|
306
431
|
const { graph: t, isReady: i } = this.state ?? {};
|
|
307
|
-
!t || !i || !t.isSimulationRunning || (
|
|
432
|
+
!t || !i || !t.isSimulationRunning || ($.get(t) !== e && !z.get(t) && ($.set(t, e), t.step()), (this.getCurrentLayer() ?? this).setNeedsRedraw());
|
|
308
433
|
}
|
|
309
434
|
/**
|
|
310
435
|
* Load mode: puts the layer's `points`, `links` and styles into the graph.
|
|
@@ -313,96 +438,96 @@ const et = [
|
|
|
313
438
|
* positions.
|
|
314
439
|
*/
|
|
315
440
|
_load(e) {
|
|
316
|
-
var
|
|
441
|
+
var F, G;
|
|
317
442
|
const t = this.state.graph;
|
|
318
443
|
if (!t) return;
|
|
319
444
|
const { points: i, links: n, getPointId: s, getPointPosition: o } = this.props;
|
|
320
445
|
if (!i) return;
|
|
321
|
-
const r = !this.state.hasLoaded,
|
|
322
|
-
let
|
|
446
|
+
const r = !this.state.hasLoaded, l = this._spaceSize(), g = () => l * t.simulation.store.getRandomFloat(D[0], D[1]);
|
|
447
|
+
let d, f = null, u, c = null, x = this.state.loadedPositions, k = this.state.idToIndex ?? null;
|
|
323
448
|
if (Array.isArray(i)) {
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
326
|
-
|
|
327
|
-
for (let
|
|
328
|
-
const
|
|
329
|
-
|
|
449
|
+
const h = i;
|
|
450
|
+
if (d = h.length, f = h, r || e.pointsChanged) {
|
|
451
|
+
c = new Float32Array(d * 2), k = s ? /* @__PURE__ */ new Map() : null;
|
|
452
|
+
for (let P = 0; P < d; P += 1) {
|
|
453
|
+
const L = h[P], B = { index: P, data: h, target: [] }, w = o ? R(o, L, B) : null;
|
|
454
|
+
c[P * 2] = w ? w[0] : g(), c[P * 2 + 1] = w ? w[1] : g(), k && s && k.set(R(s, L, B), P);
|
|
330
455
|
}
|
|
331
|
-
|
|
456
|
+
x = h;
|
|
332
457
|
} else if (e.idsChanged && (k = s ? /* @__PURE__ */ new Map() : null, k && s))
|
|
333
|
-
for (let
|
|
334
|
-
const
|
|
335
|
-
k.set(
|
|
458
|
+
for (let P = 0; P < d; P += 1) {
|
|
459
|
+
const L = { index: P, data: h, target: [] };
|
|
460
|
+
k.set(R(s, h[P], L), P);
|
|
336
461
|
}
|
|
337
462
|
} else {
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
if (r ||
|
|
342
|
-
if (
|
|
343
|
-
|
|
463
|
+
const h = i;
|
|
464
|
+
d = h.length, u = h.attributes, k = null;
|
|
465
|
+
const P = h.initialPositions ?? ut;
|
|
466
|
+
if (r || P !== this.state.loadedPositions || d !== this.state.pointCount) {
|
|
467
|
+
if (h.initialPositions)
|
|
468
|
+
c = h.initialPositions;
|
|
344
469
|
else {
|
|
345
|
-
|
|
346
|
-
for (let
|
|
470
|
+
c = new Float32Array(d * 2);
|
|
471
|
+
for (let L = 0; L < c.length; L += 1) c[L] = g();
|
|
347
472
|
}
|
|
348
|
-
|
|
473
|
+
x = P;
|
|
349
474
|
}
|
|
350
475
|
}
|
|
351
|
-
let
|
|
476
|
+
let y = null, C = this.state.linkCount, m = this.state.keptLinks, p;
|
|
352
477
|
if (n instanceof Float32Array || n && !Array.isArray(n) && "pairs" in n) {
|
|
353
|
-
const
|
|
354
|
-
|
|
478
|
+
const h = n instanceof Float32Array ? n : n.pairs;
|
|
479
|
+
p = n instanceof Float32Array ? void 0 : n.attributes, m = null, C = h.length / 2, (r || h !== this.state.loadedPairs) && (y = h);
|
|
355
480
|
} else if (Array.isArray(n)) {
|
|
356
|
-
if (r || e.linksChanged ||
|
|
357
|
-
const
|
|
358
|
-
const
|
|
359
|
-
return typeof
|
|
360
|
-
},
|
|
361
|
-
for (let
|
|
362
|
-
const
|
|
363
|
-
|
|
481
|
+
if (r || e.linksChanged || c) {
|
|
482
|
+
const h = n, { getLinkSource: P, getLinkTarget: L } = this.props, B = (A) => {
|
|
483
|
+
const I = k ? k.get(A) : A;
|
|
484
|
+
return typeof I == "number" && Number.isInteger(I) && I >= 0 && I < d ? I : void 0;
|
|
485
|
+
}, w = [], H = [];
|
|
486
|
+
for (let A = 0; A < h.length; A += 1) {
|
|
487
|
+
const I = h[A], V = { index: A, data: h, target: [] }, X = B(R(P, I, V)), U = B(R(L, I, V));
|
|
488
|
+
X === void 0 || U === void 0 || (w.push(I), H.push(X, U));
|
|
364
489
|
}
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
367
|
-
const
|
|
490
|
+
const Y = h.length - w.length;
|
|
491
|
+
if (Y > 0) {
|
|
492
|
+
const A = k ? "getLinkSource / getLinkTarget against getPointId" : "getLinkSource / getLinkTarget";
|
|
368
493
|
console.warn(
|
|
369
|
-
`@cosmos.gl/deck-layers: dropped ${
|
|
494
|
+
`@cosmos.gl/deck-layers: dropped ${Y} of ${h.length} links whose source or target is not a point — check ${A}`
|
|
370
495
|
);
|
|
371
496
|
}
|
|
372
|
-
|
|
497
|
+
y = Float32Array.from(H), m = w, C = w.length;
|
|
373
498
|
}
|
|
374
499
|
} else
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const { getPointColor: S, getPointSize:
|
|
378
|
-
(
|
|
379
|
-
const
|
|
500
|
+
m = null, C = 0, (r || this.state.loadedPairs !== J) && (y = J);
|
|
501
|
+
c && (t.setPointPositions(c, t.config.rescalePositions === void 0 ? !0 : void 0), this.state.measuredBounds = void 0, this.state.measuredBoundsVersion = void 0, this.state.loadSerial = (this.state.loadSerial ?? 0) + 1), y && t.setLinks(y);
|
|
502
|
+
const { getPointColor: S, getPointSize: T, getLinkColor: _, getLinkWidth: M } = this.props;
|
|
503
|
+
(c || e.pointStyleChanged) && (v(S, u == null ? void 0 : u.getPointColor) ? t.setPointColors(Z(d, S, f, u == null ? void 0 : u.getPointColor)) : e.pointColorUnset && t.setPointColors(b), v(T, u == null ? void 0 : u.getPointSize) ? t.setPointSizes(q(d, T, f, u == null ? void 0 : u.getPointSize)) : e.pointSizeUnset && t.setPointSizes(b)), (y || e.linkStyleChanged) && (v(_, p == null ? void 0 : p.getLinkColor) ? t.setLinkColors(Z(C, _, m, p == null ? void 0 : p.getLinkColor)) : e.linkColorUnset && t.setLinkColors(b), v(M, p == null ? void 0 : p.getLinkWidth) ? t.setLinkWidths(q(C, M, m, p == null ? void 0 : p.getLinkWidth)) : e.linkWidthUnset && t.setLinkWidths(b)), t.render();
|
|
504
|
+
const E = k !== this.state.idToIndex;
|
|
380
505
|
if (this.setState({
|
|
381
506
|
hasLoaded: !0,
|
|
382
|
-
pointCount:
|
|
383
|
-
linkCount:
|
|
384
|
-
keptLinks:
|
|
385
|
-
loadedPositions:
|
|
386
|
-
loadedPairs:
|
|
507
|
+
pointCount: d,
|
|
508
|
+
linkCount: C,
|
|
509
|
+
keptLinks: m,
|
|
510
|
+
loadedPositions: x,
|
|
511
|
+
loadedPairs: y ?? this.state.loadedPairs,
|
|
387
512
|
idToIndex: k
|
|
388
|
-
}),
|
|
513
|
+
}), c || y || E)
|
|
389
514
|
try {
|
|
390
|
-
(G = (
|
|
515
|
+
(G = (F = this.props).onGraphDataLoaded) == null || G.call(F, {
|
|
391
516
|
graph: t,
|
|
392
|
-
pointsLoaded: !!
|
|
393
|
-
linksLoaded: !!
|
|
517
|
+
pointsLoaded: !!c,
|
|
518
|
+
linksLoaded: !!y,
|
|
394
519
|
pointIndexById: k,
|
|
395
|
-
links: Array.isArray(n) ?
|
|
520
|
+
links: Array.isArray(n) ? m : null
|
|
396
521
|
});
|
|
397
|
-
} catch (
|
|
398
|
-
this.raiseError(
|
|
522
|
+
} catch (h) {
|
|
523
|
+
this.raiseError(h, "onGraphDataLoaded");
|
|
399
524
|
}
|
|
400
525
|
}
|
|
401
526
|
};
|
|
402
|
-
|
|
403
|
-
let
|
|
527
|
+
O.layerName = "CosmosGraphLayer", O.defaultProps = at;
|
|
528
|
+
let et = O;
|
|
404
529
|
export {
|
|
405
|
-
|
|
406
|
-
|
|
530
|
+
et as CosmosGraphLayer,
|
|
531
|
+
rt as DECK_OWNED_CONFIG_KEYS
|
|
407
532
|
};
|
|
408
533
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/cosmos-graph-layer.ts"],"sourcesContent":["import { COORDINATE_SYSTEM, Layer } from '@deck.gl/core'\nimport type {\n Accessor,\n AccessorContext,\n BinaryAttribute,\n Color,\n DefaultProps,\n GetPickingInfoParams,\n LayerContext,\n LayerProps,\n PickingInfo,\n UpdateParameters,\n Viewport,\n} from '@deck.gl/core'\nimport { Graph } from '@cosmos.gl/graph'\nimport type { GraphConfig } from '@cosmos.gl/graph'\n\n/**\n * Binary styling channels for binary points, keyed by the accessor each one\n * replaces. Colors are RGBA per point, 4 values each: a `Uint8Array` in\n * 0..255 (deck's convention) is converted, a `Float32Array` is cosmos's own\n * 0..1 and is handed over as it is. Sizes are one value per point, handed\n * over as they are. Values are read tightly packed; `offset` and `stride` are\n * not honoured.\n */\nexport type CosmosPointAttributes = {\n getPointColor?: BinaryAttribute;\n getPointSize?: BinaryAttribute;\n}\n\n/**\n * Points input: an array to run accessors over, or the cosmos-native binary\n * form — a point count plus optional `[x0, y0, x1, y1, …]` initial positions\n * and binary styling channels. Points without given positions are seeded\n * randomly inside the simulation space.\n */\nexport type CosmosGraphPoints<PointDataT> = readonly PointDataT[] | {\n length: number;\n initialPositions?: Float32Array;\n attributes?: CosmosPointAttributes;\n}\n\n/**\n * Binary styling channels for binary links, keyed by the accessor each one\n * replaces, with the same conventions as `CosmosPointAttributes`: colors a\n * `Uint8Array` in 0..255 or a `Float32Array` in 0..1, widths one per link.\n */\nexport type CosmosLinkAttributes = {\n getLinkColor?: BinaryAttribute;\n getLinkWidth?: BinaryAttribute;\n}\n\n/**\n * Links input: an array to run accessors over, the cosmos-native\n * `[source0, target0, source1, target1, …]` array of point indices, or that\n * array as `pairs` with binary styling channels beside it. An array link whose\n * source or target does not resolve to a point is dropped, with one warning\n * per data change; a pair that names no point is skipped by the engine and\n * keeps its index.\n */\nexport type CosmosGraphLinks<LinkDataT> = readonly LinkDataT[] | Float32Array | {\n pairs: Float32Array;\n attributes?: CosmosLinkAttributes;\n}\n\n/**\n * The cosmos.gl config keys deck owns in this embedding — the canvas, the view\n * and its zoom, the frame loop, the pointer and its callbacks. The layer strips\n * them from `config`: deck's view state, controller, event callbacks and\n * `useDevicePixels` are the way to those things.\n */\nexport const DECK_OWNED_CONFIG_KEYS = [\n 'enableRenderLoop', 'backgroundColor', 'pixelRatio', 'showFPSMonitor', 'attribution',\n 'hoveredPointCursor', 'hoveredLinkCursor',\n 'initialZoomLevel', 'enableZoom', 'enableSimulationDuringZoom', 'enableDrag',\n 'fitViewOnInit', 'fitViewDelay', 'fitViewPadding', 'fitViewDuration', 'fitViewByPointsInRect', 'fitViewByPointIndices',\n 'simulationRepulsionFromMouse', 'enableRightClickRepulsion',\n 'onClick', 'onPointClick', 'onLinkClick', 'onBackgroundClick',\n 'onContextMenu', 'onPointContextMenu', 'onLinkContextMenu', 'onBackgroundContextMenu',\n 'onMouseMove', 'onPointMouseOver', 'onPointMouseOut', 'onLinkMouseOver', 'onLinkMouseOut',\n 'onZoomStart', 'onZoom', 'onZoomEnd', 'onDragStart', 'onDrag', 'onDragEnd',\n] as const satisfies readonly (keyof GraphConfig)[]\n\n/**\n * cosmos.gl's configuration as the layer takes it: every key of `GraphConfig`\n * except the ones deck owns (`DECK_OWNED_CONFIG_KEYS`). Rendering keys work as\n * in cosmos.gl, because cosmos.gl does the rendering. The transition keys have\n * no effect: a headless `Graph` applies data changes at once.\n */\nexport type CosmosGraphLayerConfig = Omit<GraphConfig, (typeof DECK_OWNED_CONFIG_KEYS)[number]>\n\n/**\n * What `onGraphDataLoaded` reports: the graph, what the load replaced, and how\n * your data maps to the graph's point and link indices. Per-point and per-link\n * arrays you hand the graph (`setLinkStrength`, `setPointShapes`,\n * `setPointClusters`, …) follow those indices. `links` and `pointIndexById`\n * are the layer's own state: read or copy them, never mutate them.\n */\nexport type CosmosGraphDataLoadedInfo<LinkDataT = unknown> = {\n /** The graph the data was loaded into: layer-created or provided. */\n graph: Graph;\n /**\n * The point positions were replaced, and with them possibly the point count.\n * Per-point arrays sent before this load may no longer line up.\n */\n pointsLoaded: boolean;\n /**\n * The links were replaced. Per-link arrays sent before this load may no longer\n * line up: the engine reuses the last one it was sent whenever its length\n * matches the new link count, in the old order.\n */\n linksLoaded: boolean;\n /**\n * Point `i` is always entry `i` of `points` (or pair `i` of `initialPositions`).\n * With array points and `getPointId`, this maps each id to its index; a repeated\n * id maps to its last point. Otherwise `null`.\n */\n pointIndexById: ReadonlyMap<string | number, number> | null;\n /**\n * Array links: the links the graph holds, in its order — link `i` is\n * `info.links[i]`. Links whose endpoints name no point are not among them, so\n * an index into your `links` array can differ. Binary links, or no `links`\n * prop: `null`, and link `i` is pair `i` of your pair array.\n */\n links: readonly LinkDataT[] | null;\n}\n\n/**\n * Picking info from a CosmosGraphLayer: which kind of element was hit, with `index`\n * counting within that kind (point `i` or link `i`), and `object` the original record\n * for array data.\n */\nexport type CosmosGraphPickingInfo = PickingInfo & {\n elementType?: 'point' | 'link';\n}\n\nexport type CosmosGraphLayerProps<PointDataT = unknown, LinkDataT = unknown> =\n CosmosGraphLayerOwnProps<PointDataT, LinkDataT> & LayerProps\n\ntype CosmosGraphLayerOwnProps<PointDataT, LinkDataT> = {\n /**\n * One entry per point — an array of your objects, or `{ length, initialPositions?, attributes? }`.\n * The layer loads them, with `links` and the styling accessors, into the graph. Omit it to\n * draw the data the graph already holds instead: the layer then writes nothing into the\n * graph, styling accessors included — the mode for an application-loaded `graph`.\n */\n points?: CosmosGraphPoints<PointDataT> | null;\n /** One entry per link — an array of your objects, or a flat point-index pair array. Ignored without `points`. */\n links?: CosmosGraphLinks<LinkDataT> | null;\n /**\n * Stable point id accessor. When provided (with array points), link\n * accessors may return ids instead of point indices.\n */\n getPointId?: Accessor<PointDataT, string | number> | null;\n /**\n * Initial `[x, y]` position accessor for array points, in cosmos space\n * coordinates; points it leaves undefined are seeded randomly.\n */\n getPointPosition?: Accessor<PointDataT, readonly [number, number] | null | undefined> | null;\n /**\n * Point size accessor, in cosmos.gl's units: pixels at zoom 1, scaled with the view\n * when `config.scalePointsOnZoom` is on, times `config.pointSizeScale`. `0` hides the point.\n * Unset, every point draws `config.pointDefaultSize`.\n * @default null\n */\n getPointSize?: Accessor<PointDataT, number> | null;\n /**\n * Point RGBA color accessor, channels in 0..255 (deck's convention; converted for cosmos).\n * Unset, every point draws `config.pointDefaultColor`.\n * @default null\n */\n getPointColor?: Accessor<PointDataT, Color> | null;\n /**\n * Source accessor for array links: a point index, or a point id when\n * `getPointId` is set.\n * @default l => l.source\n */\n getLinkSource?: Accessor<LinkDataT, string | number>;\n /**\n * Target accessor for array links: a point index, or a point id when\n * `getPointId` is set.\n * @default l => l.target\n */\n getLinkTarget?: Accessor<LinkDataT, string | number>;\n /**\n * Link RGBA color accessor, channels in 0..255. Unset, every link draws\n * `config.linkDefaultColor`.\n * @default null\n */\n getLinkColor?: Accessor<LinkDataT, Color> | null;\n /**\n * Link width accessor, in cosmos.gl's units (see `config.scaleLinksOnZoom`, `config.linkWidthScale`).\n * Unset, every link draws `config.linkDefaultWidth`.\n * @default null\n */\n getLinkWidth?: Accessor<LinkDataT, number> | null;\n /**\n * Lets pointer drags grab a point: pinned on drag start, moved with the pointer,\n * released per `unpinOnDragEnd`. View panning is suppressed while a point is\n * grabbed. Needs `pickable`.\n * @default false\n */\n enablePointDrag?: boolean;\n /**\n * Simulation alpha to restart with when a drag starts, so the graph responds\n * to the moving point; `null` leaves the simulation untouched.\n * @default 0.1\n */\n dragReheatAlpha?: number | null;\n /**\n * Release the point on drag end; `false` keeps it pinned where dropped.\n * @default true\n */\n unpinOnDragEnd?: boolean;\n /** Called when a point drag starts. */\n onPointDragStart?: ((info: CosmosGraphPickingInfo) => void) | null;\n /** Called for every pointer move while a point is dragged. */\n onPointDrag?: ((info: CosmosGraphPickingInfo) => void) | null;\n /** Called when a point drag ends. */\n onPointDragEnd?: ((info: CosmosGraphPickingInfo) => void) | null;\n /**\n * cosmos.gl's configuration — forces, space size, rendering options such as\n * `curvedLinks`, `pointDefaultShape`, `linkDefaultArrows`, the simulation\n * callbacks — passed to the layer-created `Graph`. A key left out goes back\n * to the engine default. Ignored when `graph` is provided.\n */\n config?: CosmosGraphLayerConfig;\n /**\n * An application-owned headless `Graph` to draw instead of creating one:\n * `new Graph(null, config, devicePromise)` with the device from deck's\n * `onDeviceInitialized`. The layer steps it while it runs (`pause()` it to\n * take over stepping, then `deck.redraw()` after each manual `step()`) and\n * draws it; it never configures or destroys it — `config` and\n * `onGraphCreated` apply only to a layer-created graph, and teardown is the\n * application's, before `deck.finalize()`.\n *\n * `points` decides who loads the data. Given, the layer loads `points`,\n * `links` and the styling accessors into the graph once the device check has\n * passed, over whatever it held. Omitted, the layer draws the graph's own\n * data and writes nothing. Several layers may draw one graph — it steps once\n * per frame however many draw it — as long as at most one of them loads data.\n */\n graph?: Graph | null;\n /**\n * Called once with the layer-created `Graph` — the whole cosmos.gl API for\n * what the props do not cover: pause, pin, reheat, shapes, clusters, trackers,\n * sparse position writes. Not called for a provided `graph`.\n */\n onGraphCreated?: ((graph: Graph) => void) | null;\n /**\n * Called after each load of `points` or `links` into the graph, once the\n * graph holds the new data — and, with both load flags `false`, when only the\n * id map changed. Use it to send what lines up with the graph's indices —\n * link strengths, shapes, arrows, clusters, pins — again after a reload:\n * `info.pointIndexById` and `info.links` map your data to those indices.\n * Not called when the layer draws a graph's own data (no `points`).\n *\n * The first call comes when the graph is ready (and again after a `graph`\n * swap), later ones during deck's layer update. Calls on `info.graph` are\n * fine in either; defer anything that changes layer props. A throw goes to\n * deck's `onError`, and the load stands.\n */\n onGraphDataLoaded?: ((info: CosmosGraphDataLoadedInfo<LinkDataT>) => void) | null;\n}\n\n/**\n * deck's accessor check takes a function, or a constant of the default's type. A style\n * accessor defaults to unset, so its check also takes the constant: a number or a color.\n */\nconst isStyleAccessor = (constant: 'number' | 'color') => (value: unknown): boolean =>\n value == null || typeof value === 'function' ||\n (constant === 'number' ? typeof value === 'number' : Array.isArray(value) || ArrayBuffer.isView(value))\n\nconst defaultProps: DefaultProps<CosmosGraphLayerProps> = {\n points: { type: 'object', value: null, optional: true },\n links: null,\n getPointId: { type: 'accessor', value: null },\n getPointPosition: { type: 'accessor', value: null },\n getPointSize: { type: 'accessor', value: null, validate: isStyleAccessor('number') },\n getPointColor: { type: 'accessor', value: null, validate: isStyleAccessor('color') },\n getLinkSource: { type: 'accessor', value: (l: unknown) => (l as { source: number }).source },\n getLinkTarget: { type: 'accessor', value: (l: unknown) => (l as { target: number }).target },\n getLinkColor: { type: 'accessor', value: null, validate: isStyleAccessor('color') },\n getLinkWidth: { type: 'accessor', value: null, validate: isStyleAccessor('number') },\n enablePointDrag: false,\n dragReheatAlpha: 0.1,\n unpinOnDragEnd: true,\n onPointDragStart: { type: 'function', value: null, optional: true },\n onPointDrag: { type: 'function', value: null, optional: true },\n onPointDragEnd: { type: 'function', value: null, optional: true },\n config: { type: 'object', value: {}, compare: 2 },\n graph: { type: 'object', value: null, optional: true },\n onGraphCreated: { type: 'function', value: null, optional: true },\n onGraphDataLoaded: { type: 'function', value: null, optional: true },\n // cosmos draws its space coordinates as world coordinates; `modelMatrix` places the space\n coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,\n}\n\n/** The slice of a deck gesture event the drag handlers need. */\ntype DragGestureEvent = {\n stopImmediatePropagation?: () => void;\n}\n\n/** The update-trigger keys the layer reads. */\ntype CosmosUpdateTriggers = {\n all?: unknown;\n getPointId?: unknown;\n getPointPosition?: unknown;\n getPointSize?: unknown;\n getPointColor?: unknown;\n getLinkSource?: unknown;\n getLinkTarget?: unknown;\n getLinkColor?: unknown;\n getLinkWidth?: unknown;\n}\n\n/** Resolves a deck accessor (function or constant) for one object. */\nconst resolveAccessor = <In, Out>(accessor: Accessor<In, Out>, object: In, info: AccessorContext<In>): Out =>\n typeof accessor === 'function' ? (accessor as (o: In, i: AccessorContext<In>) => Out)(object, info) : accessor\n\n/**\n * As deck compares its own accessors: replacing a function counts only through\n * the update trigger; replacing a constant, or switching to or from one, counts.\n */\nconst accessorReplaced = (next: unknown, previous: unknown): boolean =>\n next !== previous && !(typeof next === 'function' && typeof previous === 'function')\n\n/** deck's `compare: 2` for the config: keys shallow, arrays by element. */\nconst configEquals = (a: Record<string, unknown> | undefined, b: Record<string, unknown> | undefined): boolean => {\n if (a === b) return true\n if (!a || !b) return false\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false\n return keys.every((key) => {\n const x = a[key]\n const y = b[key]\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => v === y[i])\n return x === y\n })\n}\n\n/**\n * RGBA per element as cosmos takes it (0..1), from a binary attribute or an\n * accessor. A `Float32Array` attribute is cosmos's own form and passes through.\n */\nconst toColorArray = <In>(\n count: number,\n accessor: Accessor<In, Color> | null,\n objects: readonly In[] | null,\n attribute: BinaryAttribute | undefined\n): Float32Array => {\n if (attribute) {\n const { value } = attribute\n return value instanceof Float32Array ? value : Float32Array.from(value as ArrayLike<number>, (channel) => channel / 255)\n }\n const colors = new Float32Array(count * 4)\n const data = objects ?? { length: count }\n for (let i = 0; i < count; i += 1) {\n const color = resolveAccessor(accessor as Accessor<In, Color>, objects?.[i] as In, { index: i, data, target: [] })\n colors[i * 4] = (color[0] as number) / 255\n colors[i * 4 + 1] = (color[1] as number) / 255\n colors[i * 4 + 2] = (color[2] as number) / 255\n colors[i * 4 + 3] = (color[3] ?? 255) / 255\n }\n return colors\n}\n\n/** One value per element, from a binary attribute (passed through) or an accessor. */\nconst toValueArray = <In>(\n count: number,\n accessor: Accessor<In, number> | null,\n objects: readonly In[] | null,\n attribute: BinaryAttribute | undefined\n): Float32Array => {\n if (attribute) {\n const { value } = attribute\n return value instanceof Float32Array ? value : Float32Array.from(value as ArrayLike<number>)\n }\n const values = new Float32Array(count)\n const data = objects ?? { length: count }\n for (let i = 0; i < count; i += 1) {\n values[i] = resolveAccessor(accessor as Accessor<In, number>, objects?.[i] as In, { index: i, data, target: [] })\n }\n return values\n}\n\n/**\n * When each graph last stepped, by timeline time: layers drawing the same graph\n * share one step per frame instead of each taking their own.\n */\nconst steppedAt = new WeakMap<Graph, number>()\n\n/** What the layer loaded when binary points carried no `initialPositions`: a seed of its own. */\nconst SEEDED = Symbol('seeded')\nconst NO_LINKS = new Float32Array(0)\n/** An empty style array: the engine takes it as no data and draws the config default. */\nconst NO_STYLE = new Float32Array(0)\n\n/** A style channel is the app's per-element data when an accessor or a binary attribute gives it. */\nconst isChannelSet = (accessor: unknown, attribute: BinaryAttribute | undefined): boolean =>\n accessor != null || attribute != null\n\n/** The binary styling channels of a `points` prop, if it is in binary form. */\nconst pointAttributesOf = (points: unknown): CosmosPointAttributes | undefined =>\n points && !Array.isArray(points) ? (points as { attributes?: CosmosPointAttributes }).attributes : undefined\n\n/** The binary styling channels of a `links` prop, if it is `{ pairs, attributes }`. */\nconst linkAttributesOf = (links: unknown): CosmosLinkAttributes | undefined =>\n links && !Array.isArray(links) && !(links instanceof Float32Array)\n ? (links as { attributes?: CosmosLinkAttributes }).attributes\n : undefined\n\n/**\n * The cosmos.gl graph layer: give it points and links, and cosmos.gl lays them\n * out and draws them under deck's camera. The layer creates a headless `Graph`\n * on deck's device (or draws the application's, via `graph`), loads the data —\n * or, without `points`, leaves the graph's own data alone — advances the\n * simulation once per animation frame from deck's shared timeline while it runs\n * (deck goes idle when it settles), hands deck's view to cosmos.gl before each\n * draw and records cosmos.gl's own point and link draws into deck's render\n * pass. Everything cosmos.gl renders is available through `config` and the\n * `Graph` handle: shapes, arrows, dashes, curves, greyout, rings.\n *\n * The view: cosmos.gl's is a uniform scale plus a translation with y up, so\n * the layer draws under an `OrthographicView({ flipY: false })` or a map view\n * at pitch 0 and bearing 0, with `modelMatrix` placing the space in the world.\n * A rotated, pitched or y-down view is reported once and not drawn.\n *\n * Picking is deck's: in deck's pick pass cosmos.gl draws its picking colors\n * (an index per point and per link, hard-edged), so `pickable` gives hover and\n * click with `info.elementType`, `info.index` and, for array data, `info.object`.\n * `autoHighlight` lights the hovered point or link with cosmos.gl's own hover\n * ring and hovered-link width (`config.hoveredPointRingColor`,\n * `config.hoveredLinkWidthIncrease`, `config.hoveredLinkColor`) and leaves focus\n * to the application; `highlightColor` is not used.\n * `enablePointDrag` grabs a point and moves it, on a map as well.\n */\nexport class CosmosGraphLayer<PointDataT = unknown, LinkDataT = unknown> extends Layer<\n Required<CosmosGraphLayerOwnProps<PointDataT, LinkDataT>>\n> {\n public static layerName = 'CosmosGraphLayer'\n public static defaultProps = defaultProps\n\n declare public state: {\n graph?: Graph;\n /** The `graph` prop this state was built from; `null` when the layer created its own. */\n providedGraph: Graph | null;\n isReady: boolean;\n /** `points` changed before the graph was ready: load them once it is. */\n isIngestPending: boolean;\n pointCount: number;\n linkCount: number;\n /**\n * Load mode: what the graph holds, so a channel reloads only when its own input\n * changes and a restyle leaves the layout alone. `loadedPositions` is the\n * `initialPositions` array, `SEEDED`, or the points array; `loadedPairs` the pair\n * array sent last; `idToIndex` the id map of the loaded points; `keptLinks` the\n * array links the graph holds, in its order.\n */\n hasLoaded: boolean;\n loadedPositions?: unknown;\n loadedPairs?: Float32Array | null;\n idToIndex?: Map<string | number, number> | null;\n keptLinks: readonly LinkDataT[] | null;\n /** The view was found unsupported and said so; said once. */\n viewWarned?: boolean;\n linksWarned?: boolean;\n draggedPointIndex: number | null;\n /**\n * This layer's last auto-highlight write was a hover. Several layers may draw one\n * graph, and the hover lives on the graph: only the layer holding it clears it.\n */\n holdsHover: boolean;\n animationHandle?: number;\n }\n\n public get isLoaded (): boolean {\n return super.isLoaded && Boolean(this.state?.isReady)\n }\n\n public initializeState (): void {\n const { device, timeline } = this.context\n if (device.type !== 'webgl') {\n throw new Error(\n `@cosmos.gl/deck-layers requires a WebGL 2 device — cosmos.gl is WebGL-only, got '${device.type}'`\n )\n }\n\n this.state = {\n providedGraph: null,\n isReady: false,\n isIngestPending: false,\n hasLoaded: false,\n pointCount: 0,\n linkCount: 0,\n keptLinks: null,\n draggedPointIndex: null,\n holdsHover: false,\n // Step the simulation exactly once per animation frame, independent of\n // draw passes (draw runs per viewport)\n animationHandle: timeline.attachAnimation({ setTime: (time) => this._onTimelineTick(time) }),\n }\n this._attachGraph(this.props.graph ?? null)\n }\n\n public updateState (params: UpdateParameters<this>): void {\n super.updateState(params)\n const { props, oldProps, changeFlags } = params\n // Swapping graphs loads the current data into the new one, or follows it\n const providedGraph = props.graph ?? null\n const graphSwapped = providedGraph !== this.state.providedGraph\n if (graphSwapped) {\n this._releaseGraph()\n this._attachGraph(providedGraph)\n }\n const graph = this.state.graph\n if (!graph) return\n\n if (!providedGraph && !graphSwapped && !configEquals(props.config, oldProps.config)) {\n // Graph.setConfig starts from the defaults: a key left out goes back to its default\n graph.setConfig(this._graphConfig())\n }\n\n const triggers = typeof changeFlags.updateTriggersChanged === 'object'\n ? changeFlags.updateTriggersChanged as CosmosUpdateTriggers\n : undefined\n const triggered = (key: keyof CosmosUpdateTriggers): boolean => Boolean(triggers?.all || triggers?.[key])\n // Array links resolve against the id map and the position accessor at load,\n // so a change to either counts as a change of that channel\n const pointsChanged = graphSwapped || props.points !== oldProps.points || triggered('getPointPosition')\n const idsChanged = triggered('getPointId')\n const linksChanged = graphSwapped || props.links !== oldProps.links ||\n triggered('getLinkSource') || triggered('getLinkTarget') || idsChanged\n // Styles follow their accessors (a constant by value, a function by trigger) and\n // ride along with a new points or links object, which may carry new attributes\n const pointStyleChanged = pointsChanged || triggered('getPointColor') || triggered('getPointSize') ||\n accessorReplaced(props.getPointColor, oldProps.getPointColor) || accessorReplaced(props.getPointSize, oldProps.getPointSize)\n const linkStyleChanged = linksChanged || triggered('getLinkColor') || triggered('getLinkWidth') ||\n accessorReplaced(props.getLinkColor, oldProps.getLinkColor) || accessorReplaced(props.getLinkWidth, oldProps.getLinkWidth)\n if (!pointsChanged && !linksChanged && !pointStyleChanged && !linkStyleChanged) return\n\n // A channel the layer uploaded and the app no longer gives goes back to the config\n // default. Only the layer's own upload is cleared: it had data to load (`points`) on\n // this graph, so an array the application set itself is never touched\n const uploaded = Boolean(oldProps.points) && !graphSwapped\n const oldPoints = pointAttributesOf(oldProps.points)\n const newPoints = pointAttributesOf(props.points)\n const oldLinks = linkAttributesOf(oldProps.links)\n const newLinks = linkAttributesOf(props.links)\n const stopped = (before: boolean, now: boolean): boolean => uploaded && before && !now\n const unsetChannels = {\n pointColorUnset: stopped(isChannelSet(oldProps.getPointColor, oldPoints?.getPointColor), isChannelSet(props.getPointColor, newPoints?.getPointColor)),\n pointSizeUnset: stopped(isChannelSet(oldProps.getPointSize, oldPoints?.getPointSize), isChannelSet(props.getPointSize, newPoints?.getPointSize)),\n linkColorUnset: stopped(isChannelSet(oldProps.getLinkColor, oldLinks?.getLinkColor), isChannelSet(props.getLinkColor, newLinks?.getLinkColor)),\n linkWidthUnset: stopped(isChannelSet(oldProps.getLinkWidth, oldLinks?.getLinkWidth), isChannelSet(props.getLinkWidth, newLinks?.getLinkWidth)),\n }\n\n if (props.points) {\n // The layer's data goes into the graph — once the device check has passed\n if (this.state.isReady) this._load({ pointsChanged, linksChanged, idsChanged, pointStyleChanged, linkStyleChanged, ...unsetChannels })\n else this.state.isIngestPending = true\n } else {\n // No data of its own: the layer draws what the graph holds and writes nothing\n if (props.links && !this.state.linksWarned) {\n this.state.linksWarned = true\n console.warn('@cosmos.gl/deck-layers: `links` is ignored without `points` — load them into the graph instead')\n }\n this.state.isIngestPending = false\n this.state.hasLoaded = false\n }\n }\n\n public draw (opts: {\n shaderModuleProps?: { picking?: { isActive?: number | boolean } };\n parameters?: { blendColor?: number[] };\n }): void {\n const { graph, isReady } = this.state\n if (!graph || !isReady) return\n\n const { viewport } = this.context\n const view = this._viewTransform(graph, viewport)\n if (!view) return\n graph.setViewTransform(view, [viewport.width, viewport.height])\n if (opts.shaderModuleProps?.picking?.isActive) {\n // deck's pick pass: cosmos draws its picking colors with the alpha deck uses to tell\n // layers apart (the pass's blend constant), links offset past the points so one layer\n // carries both index spaces — getPickingInfo splits them again\n graph.drawToRenderPass(this.context.renderPass, {\n picking: {\n alpha: opts.parameters?.blendColor?.[3] ?? 1,\n linkIndexOffset: graph.graph.pointsNumber ?? 0,\n },\n })\n return\n }\n graph.drawToRenderPass(this.context.renderPass)\n }\n\n public getPickingInfo ({ info }: GetPickingInfoParams): CosmosGraphPickingInfo {\n const picked: CosmosGraphPickingInfo = info\n const graph = this.state.graph\n if (!graph || info.index < 0) return picked\n const pointCount = graph.graph.pointsNumber ?? 0\n const { points, links } = this.props\n if (info.index >= pointCount) {\n picked.elementType = 'link'\n picked.index = info.index - pointCount\n picked.object = Array.isArray(links) ? this.state.keptLinks?.[picked.index] : undefined\n } else {\n picked.elementType = 'point'\n picked.object = Array.isArray(points) ? points[info.index] : undefined\n }\n return picked\n }\n\n public onDragStart (info: PickingInfo, event: DragGestureEvent): boolean {\n const { graph } = this.state\n const { enablePointDrag, dragReheatAlpha } = this.props\n const picked = info as CosmosGraphPickingInfo\n if (!enablePointDrag || !graph || picked.elementType !== 'point' || info.index < 0) return false\n\n // A direct field write: per-gesture state must not re-run the layer's update\n this.state.draggedPointIndex = info.index\n graph.setPinnedPoint(info.index, true)\n if (dragReheatAlpha !== null) graph.start(dragReheatAlpha)\n // A grabbed point must not also pan the view\n event.stopImmediatePropagation?.()\n this.props.onPointDragStart?.(picked)\n return true\n }\n\n public onDrag (info: PickingInfo, event: DragGestureEvent): boolean {\n const { graph, draggedPointIndex } = this.state\n if (!graph || draggedPointIndex === null) return false\n\n const position = this._dragPosition(graph, info)\n if (position) graph.setPointPosition(draggedPointIndex, position[0], position[1])\n event.stopImmediatePropagation?.()\n // Repaint even when the simulation is settled and the ticker is idle\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n this.props.onPointDrag?.(info as CosmosGraphPickingInfo)\n return true\n }\n\n public onDragEnd (info: PickingInfo, event: DragGestureEvent): boolean {\n const { graph, draggedPointIndex } = this.state\n if (!graph || draggedPointIndex === null) return false\n\n if (this.props.unpinOnDragEnd) graph.setPinnedPoint(draggedPointIndex, false)\n this.state.draggedPointIndex = null\n event.stopImmediatePropagation?.()\n this.props.onPointDragEnd?.(info as CosmosGraphPickingInfo)\n return true\n }\n\n /** The whole simulation space, in space coordinates; lets deck's viewport helpers frame the graph. */\n public getBounds (): [number[], number[]] | null {\n const spaceSize = this._spaceSize()\n return [[0, 0, 0], [spaceSize, spaceSize, 0]]\n }\n\n public finalizeState (context: LayerContext): void {\n if (this.state?.animationHandle !== undefined) {\n this.context.timeline.detachAnimation(this.state.animationHandle)\n }\n if (this.state) this._releaseGraph()\n super.finalizeState(context)\n }\n\n /** No deck attributes: cosmos.gl holds every channel and draws them itself. */\n protected _getAttributeManager (): null {\n return null\n }\n\n /**\n * deck's auto-highlight, through cosmos.gl's own hover emphasis: the hovered point\n * gets the hover ring, the hovered link the hovered-link width and color. It is the\n * graph's host hover, so the graph's config — focus included — stays the\n * application's. deck's picking module has no model of ours to tint, so\n * `highlightColor` does not apply.\n */\n protected _updateAutoHighlight (info: PickingInfo): void {\n const { graph, isReady } = this.state\n if (!graph || !isReady) return\n const type = info.picked && info.index >= 0 ? (info as CosmosGraphPickingInfo).elementType : undefined\n const pointIndex = type === 'point' ? info.index : undefined\n const linkIndex = type === 'link' ? info.index : undefined\n graph.setHostHoveredPoint(pointIndex)\n graph.setHostHoveredLink(linkIndex)\n // A direct field write, as for a drag: hover state must not re-run the layer's update\n this.state.holdsHover = pointIndex !== undefined || linkIndex !== undefined\n this.setNeedsRedraw()\n }\n\n /**\n * The pointer in space coordinates, through the view of the viewport the pointer\n * is in — the same derivation `draw` hands cosmos, inverted — under a map as well\n * as an orthographic view. Not through the view cosmos holds: that is whichever\n * viewport drew the graph last, a thumbnail's as easily as the one being dragged\n * in. Pixels are relative to that viewport. Where the view cannot be derived the\n * point stays where it is.\n */\n private _dragPosition (graph: Graph, info: PickingInfo): [number, number] | null {\n const viewport = info.viewport ?? this.context.viewport\n const view = this._viewTransform(graph, viewport)\n if (!view) return null\n // Space is y up; the space origin's pixel and the scale are the whole affine map\n return [(info.x - viewport.x - view.originX) / view.k, (view.originY - (info.y - viewport.y)) / view.k]\n }\n\n /** Adopts the provided graph, or creates a headless one on deck's device when `provided` is `null`. */\n private _attachGraph (provided: Graph | null): void {\n const { device } = this.context\n const graph = provided ?? new Graph(null, this._graphConfig(), Promise.resolve(device))\n this.setState({\n graph,\n providedGraph: provided,\n isReady: false,\n hasLoaded: false,\n loadedPositions: undefined,\n loadedPairs: null,\n idToIndex: null,\n keptLinks: null,\n })\n\n if (!provided) this.props.onGraphCreated?.(graph)\n\n graph.ready.then(() => {\n // `this` may be a stale descriptor by now; state is the stable identity\n if (this.state?.graph !== graph) return\n const layer = (this.getCurrentLayer() ?? this) as CosmosGraphLayer<PointDataT, LinkDataT>\n // cosmos records its draws into deck's render pass: that needs deck's device\n if (graph.simulation.device !== layer.context.device) {\n console.error(\n '@cosmos.gl/deck-layers: the provided graph runs on a different device than deck — construct it with the device from deck\\'s onDeviceInitialized'\n )\n return\n }\n // Only now may the layer touch the graph's data\n if (layer.state.isIngestPending) {\n layer.state.isIngestPending = false\n layer._load({\n pointsChanged: true,\n linksChanged: true,\n idsChanged: true,\n pointStyleChanged: true,\n linkStyleChanged: true,\n pointColorUnset: false,\n pointSizeUnset: false,\n linkColorUnset: false,\n linkWidthUnset: false,\n })\n }\n layer.setState({ isReady: true })\n }).catch((error: Error) => {\n console.error('@cosmos.gl/deck-layers: the graph failed to initialize', error)\n })\n }\n\n /**\n * Destroys a layer-created graph; a provided one is left to the application, without\n * the hover this layer put on it. deck sends no leave to a layer it removes.\n */\n private _releaseGraph (): void {\n const { graph, providedGraph, holdsHover } = this.state\n if (graph && providedGraph) {\n if (holdsHover) {\n graph.setHostHoveredPoint(undefined)\n graph.setHostHoveredLink(undefined)\n }\n } else if (graph) graph.destroy()\n this.state.graph = undefined\n this.state.holdsHover = false\n }\n\n /** The graph's space size — authoritative for a provided graph too. */\n private _spaceSize (): number {\n return this.state?.graph?.config.spaceSize ?? this.props.config?.spaceSize ?? Graph.prototype.config?.spaceSize ?? 4096\n }\n\n /**\n * The config for a layer-created graph: the prop without the keys deck owns,\n * and the pixel ratio deck's canvas draws at, so cosmos sizes pixels alike.\n */\n private _graphConfig (): GraphConfig {\n const config: Partial<Record<keyof GraphConfig, unknown>> = { ...this.props.config }\n for (const key of DECK_OWNED_CONFIG_KEYS) delete config[key]\n config.pixelRatio = this._pixelRatio()\n return config as GraphConfig\n }\n\n /** deck's device pixels per CSS pixel, as its canvas context reports them. */\n private _pixelRatio (): number {\n const canvasContext = this.context.device.canvasContext as { cssToDeviceRatio?: () => number } | null\n const ratio = canvasContext?.cssToDeviceRatio?.()\n if (ratio && Number.isFinite(ratio)) return ratio\n return typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1\n }\n\n /**\n * cosmos's view for a deck viewport: a uniform scale `k` (pixels per space\n * unit) and a translation, per `setViewTransform`'s space → screen formula,\n * inverted. Three anchors through deck's projection — the space origin, its\n * x axis, its y axis — give the scale and tell whether the view is one cosmos\n * can draw: unrotated, unpitched, y up. The space origin's pixel is returned\n * too, for mapping the other way.\n */\n private _viewTransform (\n graph: Graph,\n viewport: Viewport\n ): { k: number; x: number; y: number; originX: number; originY: number } | null {\n const spaceSize = graph.config.spaceSize\n const modelMatrix = this.props.modelMatrix\n const toPixel = (sx: number, sy: number): [number, number] => {\n // Space → common (through modelMatrix, column-major, z = 0) → world → pixel.\n // On a map, common is Web Mercator and world is lng/lat; elsewhere both are\n // common, and unprojectPosition is the identity\n const cx = modelMatrix ? (modelMatrix[0] as number) * sx + (modelMatrix[4] as number) * sy + (modelMatrix[12] as number) : sx\n const cy = modelMatrix ? (modelMatrix[1] as number) * sx + (modelMatrix[5] as number) * sy + (modelMatrix[13] as number) : sy\n const world = viewport.unprojectPosition([cx, cy, 0])\n const pixel = viewport.project(world)\n return [pixel[0] as number, pixel[1] as number]\n }\n const [originX, originY] = toPixel(0, 0)\n const [eastX, eastY] = toPixel(spaceSize, 0)\n const [northX, northY] = toPixel(0, spaceSize)\n const k = (eastX - originX) / spaceSize\n const tolerance = 1e-3 * Math.max(1, Math.abs(eastX - originX))\n const rotated = Math.abs(eastY - originY) > tolerance || Math.abs(northX - originX) > tolerance\n const yDown = northY > originY\n if (rotated || yDown || !(k > 0)) {\n if (!this.state.viewWarned) {\n this.state.viewWarned = true\n console.warn(\n '@cosmos.gl/deck-layers: cosmos.gl draws under a flat, north-up, y-up view only — ' +\n 'use OrthographicView({ flipY: false }) or a map at pitch 0 and bearing 0. The graph is not drawn.'\n )\n }\n return null\n }\n this.state.viewWarned = false\n return {\n k,\n x: originX - (k * (viewport.width - spaceSize)) / 2,\n y: originY - k * (spaceSize + (viewport.height - spaceSize) / 2),\n originX,\n originY,\n }\n }\n\n private _onTimelineTick (time: number): void {\n const { graph, isReady } = this.state ?? {}\n if (!graph || !isReady || !graph.isSimulationRunning) return\n // One step per frame per graph, however many layers draw it\n if (steppedAt.get(graph) !== time) {\n steppedAt.set(graph, time)\n graph.step()\n }\n // Repaint the frame this step just computed; when the simulation settles,\n // the flag stops being set and deck goes idle on its own\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n }\n\n /**\n * Load mode: puts the layer's `points`, `links` and styles into the graph.\n * Each channel is sent only when its own input changed — a restyle leaves the\n * layout alone, a changed id map re-resolves array links without touching the\n * positions.\n */\n private _load (changes: {\n pointsChanged: boolean;\n linksChanged: boolean;\n idsChanged: boolean;\n pointStyleChanged: boolean;\n linkStyleChanged: boolean;\n pointColorUnset: boolean;\n pointSizeUnset: boolean;\n linkColorUnset: boolean;\n linkWidthUnset: boolean;\n }): void {\n const graph = this.state.graph\n if (!graph) return\n const { points, links, getPointId, getPointPosition } = this.props\n if (!points) return\n const firstLoad = !this.state.hasLoaded\n const spaceSize = this._spaceSize()\n\n // Unseeded points land in the middle half of the space, clear of the walls. They\n // are drawn from the graph's own RNG, so a `randomSeed` reproduces the layout\n const randomCoordinate = (): number => spaceSize * graph.simulation.store.getRandomFloat(0.25, 0.75)\n\n let pointCount: number\n let pointObjects: readonly PointDataT[] | null = null\n let pointAttributes: CosmosPointAttributes | undefined\n let positions: Float32Array | null = null // to load; null leaves the graph's\n let loadedPositions = this.state.loadedPositions\n let idToIndex = this.state.idToIndex ?? null\n\n if (Array.isArray(points)) {\n const pointArray = points as readonly PointDataT[]\n pointCount = pointArray.length\n pointObjects = pointArray\n // Object points carry positions and ids together: a change reloads both\n if (firstLoad || changes.pointsChanged) {\n positions = new Float32Array(pointCount * 2)\n idToIndex = getPointId ? new Map() : null\n for (let i = 0; i < pointCount; i += 1) {\n const point = pointArray[i] as PointDataT\n const info: AccessorContext<PointDataT> = { index: i, data: pointArray, target: [] }\n const position = getPointPosition ? resolveAccessor(getPointPosition, point, info) : null\n positions[i * 2] = position ? position[0] : randomCoordinate()\n positions[i * 2 + 1] = position ? position[1] : randomCoordinate()\n if (idToIndex && getPointId) idToIndex.set(resolveAccessor(getPointId, point, info), i)\n }\n loadedPositions = pointArray\n } else if (changes.idsChanged) {\n idToIndex = getPointId ? new Map() : null\n if (idToIndex && getPointId) {\n for (let i = 0; i < pointCount; i += 1) {\n const info: AccessorContext<PointDataT> = { index: i, data: pointArray, target: [] }\n idToIndex.set(resolveAccessor(getPointId, pointArray[i] as PointDataT, info), i)\n }\n }\n }\n } else {\n const binaryPoints = points as { length: number; initialPositions?: Float32Array; attributes?: CosmosPointAttributes }\n pointCount = binaryPoints.length\n pointAttributes = binaryPoints.attributes\n idToIndex = null\n // Positions reload when their input changed: another `initialPositions`\n // array, a seed the layer must draw again for a new count, or a first load\n const positionsInput: unknown = binaryPoints.initialPositions ?? SEEDED\n if (firstLoad || positionsInput !== this.state.loadedPositions || pointCount !== this.state.pointCount) {\n if (binaryPoints.initialPositions) {\n positions = binaryPoints.initialPositions\n } else {\n positions = new Float32Array(pointCount * 2)\n for (let i = 0; i < positions.length; i += 1) positions[i] = randomCoordinate()\n }\n loadedPositions = positionsInput\n }\n }\n\n let pairs: Float32Array | null = null // to load; null leaves the graph's\n let linkCount = this.state.linkCount\n let keptLinks: readonly LinkDataT[] | null = this.state.keptLinks\n let linkAttributes: CosmosLinkAttributes | undefined\n if (links instanceof Float32Array || (links && !Array.isArray(links) && 'pairs' in links)) {\n const pairArray = links instanceof Float32Array ? links : links.pairs\n linkAttributes = links instanceof Float32Array ? undefined : links.attributes\n keptLinks = null\n linkCount = pairArray.length / 2\n if (firstLoad || pairArray !== this.state.loadedPairs) pairs = pairArray\n } else if (Array.isArray(links)) {\n // Array links resolve against the loaded points, so they reload with them\n if (firstLoad || changes.linksChanged || positions) {\n const linkObjects = links as readonly LinkDataT[]\n const { getLinkSource, getLinkTarget } = this.props\n // An endpoint is a point index, or a point id when the id map exists;\n // anything that does not name a point drops the whole link\n const resolveEndpoint = (endpoint: string | number): number | undefined => {\n const index = idToIndex ? idToIndex.get(endpoint) : endpoint\n return typeof index === 'number' && Number.isInteger(index) && index >= 0 && index < pointCount\n ? index\n : undefined\n }\n const kept: LinkDataT[] = []\n const keptIndices: number[] = []\n for (let i = 0; i < linkObjects.length; i += 1) {\n const link = linkObjects[i] as LinkDataT\n const info: AccessorContext<LinkDataT> = { index: i, data: linkObjects, target: [] }\n const source = resolveEndpoint(resolveAccessor(getLinkSource, link, info))\n const target = resolveEndpoint(resolveAccessor(getLinkTarget, link, info))\n if (source === undefined || target === undefined) continue\n kept.push(link)\n keptIndices.push(source, target)\n }\n const dropped = linkObjects.length - kept.length\n if (dropped > 0) {\n const hint = idToIndex ? 'getLinkSource / getLinkTarget against getPointId' : 'getLinkSource / getLinkTarget'\n console.warn(\n `@cosmos.gl/deck-layers: dropped ${dropped} of ${linkObjects.length} links whose source or target is not a point — check ${hint}`\n )\n }\n pairs = Float32Array.from(keptIndices)\n keptLinks = kept\n linkCount = kept.length\n }\n } else {\n keptLinks = null\n linkCount = 0\n if (firstLoad || this.state.loadedPairs !== NO_LINKS) pairs = NO_LINKS\n }\n\n // Positions are space coordinates by contract: not rescaled unless the graph's config asks\n if (positions) graph.setPointPositions(positions, graph.config.rescalePositions === undefined ? true : undefined)\n if (pairs) graph.setLinks(pairs)\n // Styles: deck accessors and attributes, as cosmos's arrays. A channel the app gives\n // follows a reload (the count may have changed) and its own accessor; a channel it\n // does not give is left to the config default, and cleared when it just stopped\n const { getPointColor, getPointSize, getLinkColor, getLinkWidth } = this.props\n if (positions || changes.pointStyleChanged) {\n if (isChannelSet(getPointColor, pointAttributes?.getPointColor)) {\n graph.setPointColors(toColorArray(pointCount, getPointColor, pointObjects, pointAttributes?.getPointColor))\n } else if (changes.pointColorUnset) graph.setPointColors(NO_STYLE)\n if (isChannelSet(getPointSize, pointAttributes?.getPointSize)) {\n graph.setPointSizes(toValueArray(pointCount, getPointSize, pointObjects, pointAttributes?.getPointSize))\n } else if (changes.pointSizeUnset) graph.setPointSizes(NO_STYLE)\n }\n if (pairs || changes.linkStyleChanged) {\n if (isChannelSet(getLinkColor, linkAttributes?.getLinkColor)) {\n graph.setLinkColors(toColorArray(linkCount, getLinkColor, keptLinks, linkAttributes?.getLinkColor))\n } else if (changes.linkColorUnset) graph.setLinkColors(NO_STYLE)\n if (isChannelSet(getLinkWidth, linkAttributes?.getLinkWidth)) {\n graph.setLinkWidths(toValueArray(linkCount, getLinkWidth, keptLinks, linkAttributes?.getLinkWidth))\n } else if (changes.linkWidthUnset) graph.setLinkWidths(NO_STYLE)\n }\n // A headless graph applies at once: no transition, and the simulation keeps its alpha\n graph.render()\n\n // A new id map with nothing reloaded still changes how ids reach indices\n const idsRemapped = idToIndex !== this.state.idToIndex\n this.setState({\n hasLoaded: true,\n pointCount,\n linkCount,\n keptLinks,\n loadedPositions,\n loadedPairs: pairs ?? this.state.loadedPairs,\n idToIndex,\n })\n\n // After the graph holds the data, so what the callback sends lines up with it.\n // A throw is the app's error, not the layer's: it goes to deck's onError and leaves\n // the load, and the layer's readiness after a first load, intact.\n if (positions || pairs || idsRemapped) {\n try {\n this.props.onGraphDataLoaded?.({\n graph,\n pointsLoaded: Boolean(positions),\n linksLoaded: Boolean(pairs),\n pointIndexById: idToIndex,\n links: Array.isArray(links) ? keptLinks : null,\n })\n } catch (error) {\n this.raiseError(error as Error, 'onGraphDataLoaded')\n }\n }\n }\n}\n"],"names":["DECK_OWNED_CONFIG_KEYS","isStyleAccessor","constant","value","defaultProps","l","COORDINATE_SYSTEM","resolveAccessor","accessor","object","info","accessorReplaced","next","previous","configEquals","b","keys","key","x","y","v","i","toColorArray","count","objects","attribute","channel","colors","data","color","toValueArray","values","steppedAt","SEEDED","NO_LINKS","NO_STYLE","isChannelSet","pointAttributesOf","points","linkAttributesOf","links","_CosmosGraphLayer","Layer","_a","device","timeline","time","params","props","oldProps","changeFlags","providedGraph","graphSwapped","graph","triggers","triggered","pointsChanged","idsChanged","linksChanged","pointStyleChanged","linkStyleChanged","uploaded","oldPoints","newPoints","oldLinks","newLinks","stopped","before","now","unsetChannels","opts","isReady","viewport","view","_b","_d","_c","picked","pointCount","event","enablePointDrag","dragReheatAlpha","draggedPointIndex","position","spaceSize","context","type","pointIndex","linkIndex","provided","Graph","layer","error","holdsHover","config","canvasContext","ratio","modelMatrix","toPixel","sx","sy","cx","cy","world","pixel","originX","originY","eastX","eastY","northX","northY","k","tolerance","rotated","yDown","changes","getPointId","getPointPosition","firstLoad","randomCoordinate","pointObjects","pointAttributes","positions","loadedPositions","idToIndex","pointArray","point","binaryPoints","positionsInput","pairs","linkCount","keptLinks","linkAttributes","pairArray","linkObjects","getLinkSource","getLinkTarget","resolveEndpoint","endpoint","index","kept","keptIndices","link","source","target","dropped","hint","getPointColor","getPointSize","getLinkColor","getLinkWidth","idsRemapped","CosmosGraphLayer"],"mappings":";;AAuEO,MAAMA,KAAyB;AAAA,EACpC;AAAA,EAAoB;AAAA,EAAmB;AAAA,EAAc;AAAA,EAAkB;AAAA,EACvE;AAAA,EAAsB;AAAA,EACtB;AAAA,EAAoB;AAAA,EAAc;AAAA,EAA8B;AAAA,EAChE;AAAA,EAAiB;AAAA,EAAgB;AAAA,EAAkB;AAAA,EAAmB;AAAA,EAAyB;AAAA,EAC/F;AAAA,EAAgC;AAAA,EAChC;AAAA,EAAW;AAAA,EAAgB;AAAA,EAAe;AAAA,EAC1C;AAAA,EAAiB;AAAA,EAAsB;AAAA,EAAqB;AAAA,EAC5D;AAAA,EAAe;AAAA,EAAoB;AAAA,EAAmB;AAAA,EAAmB;AAAA,EACzE;AAAA,EAAe;AAAA,EAAU;AAAA,EAAa;AAAA,EAAe;AAAA,EAAU;AACjE,GA4LMC,IAAkB,CAACC,MAAiC,CAACC,MACzDA,KAAS,QAAQ,OAAOA,KAAU,eACjCD,MAAa,WAAW,OAAOC,KAAU,WAAW,MAAM,QAAQA,CAAK,KAAK,YAAY,OAAOA,CAAK,IAEjGC,KAAoD;AAAA,EACxD,QAAQ,EAAE,MAAM,UAAU,OAAO,MAAM,UAAU,GAAA;AAAA,EACjD,OAAO;AAAA,EACP,YAAY,EAAE,MAAM,YAAY,OAAO,KAAA;AAAA,EACvC,kBAAkB,EAAE,MAAM,YAAY,OAAO,KAAA;AAAA,EAC7C,cAAc,EAAE,MAAM,YAAY,OAAO,MAAM,UAAUH,EAAgB,QAAQ,EAAA;AAAA,EACjF,eAAe,EAAE,MAAM,YAAY,OAAO,MAAM,UAAUA,EAAgB,OAAO,EAAA;AAAA,EACjF,eAAe,EAAE,MAAM,YAAY,OAAO,CAACI,MAAgBA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-graph-layer.ts"],"sourcesContent":["import { COORDINATE_SYSTEM, Layer } from '@deck.gl/core'\nimport type {\n Accessor,\n AccessorContext,\n BinaryAttribute,\n Color,\n DefaultProps,\n GetPickingInfoParams,\n LayerContext,\n LayerProps,\n PickingInfo,\n UpdateParameters,\n Viewport,\n} from '@deck.gl/core'\nimport { Graph, defaultConfigValues } from '@cosmos.gl/graph'\nimport type { GraphConfig } from '@cosmos.gl/graph'\n\n/**\n * Binary styling channels for binary points, keyed by the accessor each one\n * replaces. Colors are RGBA per point, 4 values each: a `Uint8Array` in\n * 0..255 (deck's convention) is converted, a `Float32Array` is cosmos's own\n * 0..1 and is handed over as it is. Sizes are one value per point, handed\n * over as they are. Values are read tightly packed; `offset` and `stride` are\n * not honoured.\n */\nexport type CosmosPointAttributes = {\n getPointColor?: BinaryAttribute;\n getPointSize?: BinaryAttribute;\n}\n\n/**\n * Points input: an array to run accessors over, or the cosmos-native binary\n * form — a point count plus optional `[x0, y0, x1, y1, …]` initial positions\n * and binary styling channels. Points without given positions are seeded\n * randomly inside the simulation space.\n */\nexport type CosmosGraphPoints<PointDataT> = readonly PointDataT[] | {\n length: number;\n initialPositions?: Float32Array;\n attributes?: CosmosPointAttributes;\n}\n\n/**\n * Binary styling channels for binary links, keyed by the accessor each one\n * replaces, with the same conventions as `CosmosPointAttributes`: colors a\n * `Uint8Array` in 0..255 or a `Float32Array` in 0..1, widths one per link.\n */\nexport type CosmosLinkAttributes = {\n getLinkColor?: BinaryAttribute;\n getLinkWidth?: BinaryAttribute;\n}\n\n/**\n * Links input: an array to run accessors over, the cosmos-native\n * `[source0, target0, source1, target1, …]` array of point indices, or that\n * array as `pairs` with binary styling channels beside it. An array link whose\n * source or target does not resolve to a point is dropped, with one warning\n * per data change; a pair that names no point is skipped by the engine and\n * keeps its index.\n */\nexport type CosmosGraphLinks<LinkDataT> = readonly LinkDataT[] | Float32Array | {\n pairs: Float32Array;\n attributes?: CosmosLinkAttributes;\n}\n\n/**\n * The cosmos.gl config keys deck owns in this embedding — the canvas, the view\n * and its zoom, the frame loop, the pointer and its callbacks. The layer strips\n * them from `config`: deck's view state, controller, event callbacks and\n * `useDevicePixels` are the way to those things.\n */\nexport const DECK_OWNED_CONFIG_KEYS = [\n 'enableRenderLoop', 'backgroundColor', 'pixelRatio', 'showFPSMonitor', 'attribution',\n 'hoveredPointCursor', 'hoveredLinkCursor',\n 'initialZoomLevel', 'enableZoom', 'enableSimulationDuringZoom', 'enableDrag',\n 'fitViewOnInit', 'fitViewDelay', 'fitViewPadding', 'fitViewDuration', 'fitViewByPointsInRect', 'fitViewByPointIndices',\n 'simulationRepulsionFromMouse', 'enableRightClickRepulsion',\n 'onClick', 'onPointClick', 'onLinkClick', 'onBackgroundClick',\n 'onContextMenu', 'onPointContextMenu', 'onLinkContextMenu', 'onBackgroundContextMenu',\n 'onMouseMove', 'onPointMouseOver', 'onPointMouseOut', 'onLinkMouseOver', 'onLinkMouseOut',\n 'onZoomStart', 'onZoom', 'onZoomEnd', 'onDragStart', 'onDrag', 'onDragEnd',\n] as const satisfies readonly (keyof GraphConfig)[]\n\n/**\n * cosmos.gl's configuration as the layer takes it: every key of `GraphConfig`\n * except the ones deck owns (`DECK_OWNED_CONFIG_KEYS`). Rendering keys work as\n * in cosmos.gl, because cosmos.gl does the rendering. The transition keys have\n * no effect: a headless `Graph` applies data changes at once.\n */\nexport type CosmosGraphLayerConfig = Omit<GraphConfig, (typeof DECK_OWNED_CONFIG_KEYS)[number]>\n\n/**\n * What `onGraphDataLoaded` reports: the graph, what the load replaced, and how\n * your data maps to the graph's point and link indices. Per-point and per-link\n * arrays you hand the graph (`setLinkStrength`, `setPointShapes`,\n * `setPointClusters`, …) follow those indices. `links` and `pointIndexById`\n * are the layer's own state: read or copy them, never mutate them.\n */\nexport type CosmosGraphDataLoadedInfo<LinkDataT = unknown> = {\n /** The graph the data was loaded into: layer-created or provided. */\n graph: Graph;\n /**\n * The point positions were replaced, and with them possibly the point count.\n * Per-point arrays sent before this load may no longer line up.\n */\n pointsLoaded: boolean;\n /**\n * The links were replaced. Per-link arrays sent before this load may no longer\n * line up: the engine reuses the last one it was sent whenever its length\n * matches the new link count, in the old order.\n */\n linksLoaded: boolean;\n /**\n * Point `i` is always entry `i` of `points` (or pair `i` of `initialPositions`).\n * With array points and `getPointId`, this maps each id to its index; a repeated\n * id maps to its last point. Otherwise `null`.\n */\n pointIndexById: ReadonlyMap<string | number, number> | null;\n /**\n * Array links: the links the graph holds, in its order — link `i` is\n * `info.links[i]`. Links whose endpoints name no point are not among them, so\n * an index into your `links` array can differ. Binary links, or no `links`\n * prop: `null`, and link `i` is pair `i` of your pair array.\n */\n links: readonly LinkDataT[] | null;\n}\n\n/**\n * Picking info from a CosmosGraphLayer: which kind of element was hit, with `index`\n * counting within that kind (point `i` or link `i`), and `object` the original record\n * for array data.\n */\nexport type CosmosGraphPickingInfo = PickingInfo & {\n elementType?: 'point' | 'link';\n}\n\nexport type CosmosGraphLayerProps<PointDataT = unknown, LinkDataT = unknown> =\n CosmosGraphLayerOwnProps<PointDataT, LinkDataT> & LayerProps\n\ntype CosmosGraphLayerOwnProps<PointDataT, LinkDataT> = {\n /**\n * One entry per point — an array of your objects, or `{ length, initialPositions?, attributes? }`.\n * The layer loads them, with `links` and the styling accessors, into the graph. Omit it to\n * draw the data the graph already holds instead: the layer then writes nothing into the\n * graph, styling accessors included — the mode for an application-loaded `graph`.\n */\n points?: CosmosGraphPoints<PointDataT> | null;\n /** One entry per link — an array of your objects, or a flat point-index pair array. Ignored without `points`. */\n links?: CosmosGraphLinks<LinkDataT> | null;\n /**\n * Stable point id accessor. When provided (with array points), link\n * accessors may return ids instead of point indices.\n */\n getPointId?: Accessor<PointDataT, string | number> | null;\n /**\n * Initial `[x, y]` position accessor for array points, in cosmos space\n * coordinates; points it leaves undefined are seeded randomly.\n */\n getPointPosition?: Accessor<PointDataT, readonly [number, number] | null | undefined> | null;\n /**\n * Point size accessor, in cosmos.gl's units: pixels at zoom 1, scaled with the view\n * when `config.scalePointsOnZoom` is on, times `config.pointSizeScale`. `0` hides the point.\n * Unset, every point draws `config.pointDefaultSize`.\n * @default null\n */\n getPointSize?: Accessor<PointDataT, number> | null;\n /**\n * Point RGBA color accessor, channels in 0..255 (deck's convention; converted for cosmos).\n * Unset, every point draws `config.pointDefaultColor`.\n * @default null\n */\n getPointColor?: Accessor<PointDataT, Color> | null;\n /**\n * Source accessor for array links: a point index, or a point id when\n * `getPointId` is set.\n * @default l => l.source\n */\n getLinkSource?: Accessor<LinkDataT, string | number>;\n /**\n * Target accessor for array links: a point index, or a point id when\n * `getPointId` is set.\n * @default l => l.target\n */\n getLinkTarget?: Accessor<LinkDataT, string | number>;\n /**\n * Link RGBA color accessor, channels in 0..255. Unset, every link draws\n * `config.linkDefaultColor`.\n * @default null\n */\n getLinkColor?: Accessor<LinkDataT, Color> | null;\n /**\n * Link width accessor, in cosmos.gl's units (see `config.scaleLinksOnZoom`, `config.linkWidthScale`).\n * Unset, every link draws `config.linkDefaultWidth`.\n * @default null\n */\n getLinkWidth?: Accessor<LinkDataT, number> | null;\n /**\n * Lets pointer drags grab a point: pinned on drag start, moved with the pointer,\n * released per `unpinOnDragEnd`. View panning is suppressed while a point is\n * grabbed. Needs `pickable`.\n * @default false\n */\n enablePointDrag?: boolean;\n /**\n * Simulation alpha to restart with when a drag starts, so the graph responds\n * to the moving point; `null` leaves the simulation untouched.\n * @default 0.1\n */\n dragReheatAlpha?: number | null;\n /**\n * Release the point on drag end; `false` keeps it pinned where dropped.\n * @default true\n */\n unpinOnDragEnd?: boolean;\n /** Called when a point drag starts. */\n onPointDragStart?: ((info: CosmosGraphPickingInfo) => void) | null;\n /** Called for every pointer move while a point is dragged. */\n onPointDrag?: ((info: CosmosGraphPickingInfo) => void) | null;\n /** Called when a point drag ends. */\n onPointDragEnd?: ((info: CosmosGraphPickingInfo) => void) | null;\n /**\n * cosmos.gl's configuration — forces, space size, rendering options such as\n * `curvedLinks`, `pointDefaultShape`, `linkDefaultArrows`, the simulation\n * callbacks — passed to the layer-created `Graph`. A key left out goes back\n * to the engine default. Ignored when `graph` is provided.\n */\n config?: CosmosGraphLayerConfig;\n /**\n * An application-owned headless `Graph` to draw instead of creating one:\n * `new Graph(null, config, devicePromise)` with the device from deck's\n * `onDeviceInitialized`. The layer steps it while it runs (`pause()` it to\n * take over stepping, then `deck.redraw()` after each manual `step()`) and\n * draws it; it never configures or destroys it — `config` and\n * `onGraphCreated` apply only to a layer-created graph, and teardown is the\n * application's, before `deck.finalize()`.\n *\n * `points` decides who loads the data. Given, the layer loads `points`,\n * `links` and the styling accessors into the graph once the device check has\n * passed, over whatever it held. Omitted, the layer draws the graph's own\n * data and writes nothing. Several layers may draw one graph — it steps once\n * per frame however many draw it — as long as at most one of them loads data.\n */\n graph?: Graph | null;\n /**\n * Called once with the layer-created `Graph` — the whole cosmos.gl API for\n * what the props do not cover: pause, pin, reheat, shapes, clusters, trackers,\n * sparse position writes. Not called for a provided `graph`.\n */\n onGraphCreated?: ((graph: Graph) => void) | null;\n /**\n * Called after each load of `points` or `links` into the graph, once the\n * graph holds the new data — and, with both load flags `false`, when only the\n * id map changed. Use it to send what lines up with the graph's indices —\n * link strengths, shapes, arrows, clusters, pins — again after a reload:\n * `info.pointIndexById` and `info.links` map your data to those indices.\n * Not called when the layer draws a graph's own data (no `points`).\n *\n * The first call comes when the graph is ready (and again after a `graph`\n * swap), later ones during deck's layer update. Calls on `info.graph` are\n * fine in either; defer anything that changes layer props. A throw goes to\n * deck's `onError`, and the load stands.\n */\n onGraphDataLoaded?: ((info: CosmosGraphDataLoadedInfo<LinkDataT>) => void) | null;\n}\n\n/**\n * deck's accessor check takes a function, or a constant of the default's type. A style\n * accessor defaults to unset, so its check also takes the constant: a number or a color.\n */\nconst isStyleAccessor = (constant: 'number' | 'color') => (value: unknown): boolean =>\n value == null || typeof value === 'function' ||\n (constant === 'number' ? typeof value === 'number' : Array.isArray(value) || ArrayBuffer.isView(value))\n\nconst defaultProps: DefaultProps<CosmosGraphLayerProps> = {\n points: { type: 'object', value: null, optional: true },\n links: null,\n getPointId: { type: 'accessor', value: null },\n getPointPosition: { type: 'accessor', value: null },\n getPointSize: { type: 'accessor', value: null, validate: isStyleAccessor('number') },\n getPointColor: { type: 'accessor', value: null, validate: isStyleAccessor('color') },\n getLinkSource: { type: 'accessor', value: (l: unknown) => (l as { source: number }).source },\n getLinkTarget: { type: 'accessor', value: (l: unknown) => (l as { target: number }).target },\n getLinkColor: { type: 'accessor', value: null, validate: isStyleAccessor('color') },\n getLinkWidth: { type: 'accessor', value: null, validate: isStyleAccessor('number') },\n enablePointDrag: false,\n dragReheatAlpha: 0.1,\n unpinOnDragEnd: true,\n onPointDragStart: { type: 'function', value: null, optional: true },\n onPointDrag: { type: 'function', value: null, optional: true },\n onPointDragEnd: { type: 'function', value: null, optional: true },\n config: { type: 'object', value: {}, compare: 2 },\n graph: { type: 'object', value: null, optional: true },\n onGraphCreated: { type: 'function', value: null, optional: true },\n onGraphDataLoaded: { type: 'function', value: null, optional: true },\n // cosmos draws its space coordinates as world coordinates; `modelMatrix` places the space\n coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,\n}\n\n/** The slice of a deck gesture event the drag handlers need. */\ntype DragGestureEvent = {\n stopImmediatePropagation?: () => void;\n}\n\n/** The update-trigger keys the layer reads. */\ntype CosmosUpdateTriggers = {\n all?: unknown;\n getPointId?: unknown;\n getPointPosition?: unknown;\n getPointSize?: unknown;\n getPointColor?: unknown;\n getLinkSource?: unknown;\n getLinkTarget?: unknown;\n getLinkColor?: unknown;\n getLinkWidth?: unknown;\n}\n\n/** Resolves a deck accessor (function or constant) for one object. */\nconst resolveAccessor = <In, Out>(accessor: Accessor<In, Out>, object: In, info: AccessorContext<In>): Out =>\n typeof accessor === 'function' ? (accessor as (o: In, i: AccessorContext<In>) => Out)(object, info) : accessor\n\n/**\n * As deck compares its own accessors: replacing a function counts only through\n * the update trigger; replacing a constant, or switching to or from one, counts.\n */\nconst accessorReplaced = (next: unknown, previous: unknown): boolean =>\n next !== previous && !(typeof next === 'function' && typeof previous === 'function')\n\n/** deck's `compare: 2` for the config: keys shallow, arrays by element. */\nconst configEquals = (a: Record<string, unknown> | undefined, b: Record<string, unknown> | undefined): boolean => {\n if (a === b) return true\n if (!a || !b) return false\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false\n return keys.every((key) => {\n const x = a[key]\n const y = b[key]\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => v === y[i])\n return x === y\n })\n}\n\n/**\n * RGBA per element as cosmos takes it (0..1), from a binary attribute or an\n * accessor. A `Float32Array` attribute is cosmos's own form and passes through.\n */\nconst toColorArray = <In>(\n count: number,\n accessor: Accessor<In, Color> | null,\n objects: readonly In[] | null,\n attribute: BinaryAttribute | undefined\n): Float32Array => {\n if (attribute) {\n const { value } = attribute\n return value instanceof Float32Array ? value : Float32Array.from(value as ArrayLike<number>, (channel) => channel / 255)\n }\n const colors = new Float32Array(count * 4)\n const data = objects ?? { length: count }\n for (let i = 0; i < count; i += 1) {\n const color = resolveAccessor(accessor as Accessor<In, Color>, objects?.[i] as In, { index: i, data, target: [] })\n colors[i * 4] = (color[0] as number) / 255\n colors[i * 4 + 1] = (color[1] as number) / 255\n colors[i * 4 + 2] = (color[2] as number) / 255\n colors[i * 4 + 3] = (color[3] ?? 255) / 255\n }\n return colors\n}\n\n/** One value per element, from a binary attribute (passed through) or an accessor. */\nconst toValueArray = <In>(\n count: number,\n accessor: Accessor<In, number> | null,\n objects: readonly In[] | null,\n attribute: BinaryAttribute | undefined\n): Float32Array => {\n if (attribute) {\n const { value } = attribute\n return value instanceof Float32Array ? value : Float32Array.from(value as ArrayLike<number>)\n }\n const values = new Float32Array(count)\n const data = objects ?? { length: count }\n for (let i = 0; i < count; i += 1) {\n values[i] = resolveAccessor(accessor as Accessor<In, number>, objects?.[i] as In, { index: i, data, target: [] })\n }\n return values\n}\n\n/**\n * When each graph last stepped, by timeline time: layers drawing the same graph\n * share one step per frame instead of each taking their own.\n */\nconst steppedAt = new WeakMap<Graph, number>()\n\n/**\n * Bounds reads on their way per graph, from every layer drawing it: while one is, no layer\n * steps the graph, or the read would wait for the step (`getBounds`).\n */\nconst pendingBoundsReads = new WeakMap<Graph, number>()\n\n/**\n * Unseeded points are drawn in the middle half of the space, around the world origin\n * gravity pulls toward: these fractions of the engine's `spaceSize`. A default placement,\n * not a bound; `_load` draws inside it and `getBounds` reports it before anything settles.\n */\nconst UNSEEDED_PLACEMENT: readonly [number, number] = [0.25, 0.75]\n\n/**\n * The length `_viewTransform` projects to read deck's scale: any length long enough for the\n * projected pixels to resolve it does, so it is not tied to the engine.\n */\nconst VIEW_PROBE_LENGTH = 4096\n\n/**\n * A present point's coordinate as the engine stores it: rounded to float32, an infinity\n * (also one the rounding makes) on the matching edge — `0` or `infiniteEdge`, the engine's\n * `toFiniteCoordinate` in position-utils, which is not public. The edge is the space's\n * width today; a bad-input rule, not a bound.\n */\nconst toEngineCoordinate = (value: number, infiniteEdge: number): number => {\n const rounded = Math.fround(value)\n if (rounded === Infinity) return infiniteEdge\n if (rounded === -Infinity) return 0\n return rounded\n}\n\n/** A 2D bounding box grown one point at a time; non-finite points are left out. */\nclass BoundsBox {\n private minX = Infinity\n private minY = Infinity\n private maxX = -Infinity\n private maxY = -Infinity\n\n public add (x: number, y: number): void {\n if (!Number.isFinite(x) || !Number.isFinite(y)) return\n if (x < this.minX) this.minX = x\n if (x > this.maxX) this.maxX = x\n if (y < this.minY) this.minY = y\n if (y > this.maxY) this.maxY = y\n }\n\n /** Layer.getBounds' shape, z = 0; `null` when no point was added. */\n public bounds (): [number[], number[]] | null {\n if (this.minX > this.maxX) return null\n return [[this.minX, this.minY, 0], [this.maxX, this.maxY, 0]]\n }\n}\n\n/** What the layer loaded when binary points carried no `initialPositions`: a seed of its own. */\nconst SEEDED = Symbol('seeded')\nconst NO_LINKS = new Float32Array(0)\n/** An empty style array: the engine takes it as no data and draws the config default. */\nconst NO_STYLE = new Float32Array(0)\n\n/** A style channel is the app's per-element data when an accessor or a binary attribute gives it. */\nconst isChannelSet = (accessor: unknown, attribute: BinaryAttribute | undefined): boolean =>\n accessor != null || attribute != null\n\n/** The binary styling channels of a `points` prop, if it is in binary form. */\nconst pointAttributesOf = (points: unknown): CosmosPointAttributes | undefined =>\n points && !Array.isArray(points) ? (points as { attributes?: CosmosPointAttributes }).attributes : undefined\n\n/** The binary styling channels of a `links` prop, if it is `{ pairs, attributes }`. */\nconst linkAttributesOf = (links: unknown): CosmosLinkAttributes | undefined =>\n links && !Array.isArray(links) && !(links instanceof Float32Array)\n ? (links as { attributes?: CosmosLinkAttributes }).attributes\n : undefined\n\n/**\n * The cosmos.gl graph layer: give it points and links, and cosmos.gl lays them\n * out and draws them under deck's camera. The layer creates a headless `Graph`\n * on deck's device (or draws the application's, via `graph`), loads the data —\n * or, without `points`, leaves the graph's own data alone — advances the\n * simulation once per animation frame from deck's shared timeline while it runs\n * (deck goes idle when it settles), hands deck's view to cosmos.gl before each\n * draw and records cosmos.gl's own point and link draws into deck's render\n * pass. Everything cosmos.gl renders is available through `config` and the\n * `Graph` handle: shapes, arrows, dashes, curves, greyout, rings.\n *\n * The view: cosmos.gl's is a uniform scale plus a translation with y up, so\n * the layer draws under an `OrthographicView({ flipY: false })` or a map view\n * at pitch 0 and bearing 0, with `modelMatrix` placing the space in the world.\n * A rotated, pitched or y-down view is reported once and not drawn.\n *\n * Picking is deck's: in deck's pick pass cosmos.gl draws its picking colors\n * (an index per point and per link, hard-edged), so `pickable` gives hover and\n * click with `info.elementType`, `info.index` and, for array data, `info.object`.\n * `autoHighlight` lights the hovered point or link with cosmos.gl's own hover\n * ring and hovered-link width (`config.hoveredPointRingColor`,\n * `config.hoveredLinkWidthIncrease`, `config.hoveredLinkColor`) and leaves focus\n * to the application; `highlightColor` is not used.\n * `enablePointDrag` grabs a point and moves it, on a map as well.\n */\nexport class CosmosGraphLayer<PointDataT = unknown, LinkDataT = unknown> extends Layer<\n Required<CosmosGraphLayerOwnProps<PointDataT, LinkDataT>>\n> {\n public static layerName = 'CosmosGraphLayer'\n public static defaultProps = defaultProps\n\n declare public state: {\n graph?: Graph;\n /** The `graph` prop this state was built from; `null` when the layer created its own. */\n providedGraph: Graph | null;\n isReady: boolean;\n /** `points` changed before the graph was ready: load them once it is. */\n isIngestPending: boolean;\n pointCount: number;\n linkCount: number;\n /**\n * Load mode: what the graph holds, so a channel reloads only when its own input\n * changes and a restyle leaves the layout alone. `loadedPositions` is the\n * `initialPositions` array, `SEEDED`, or the points array; `loadedPairs` the pair\n * array sent last; `idToIndex` the id map of the loaded points; `keptLinks` the\n * array links the graph holds, in its order.\n */\n hasLoaded: boolean;\n loadedPositions?: unknown;\n loadedPairs?: Float32Array | null;\n idToIndex?: Map<string | number, number> | null;\n keptLinks: readonly LinkDataT[] | null;\n /**\n * `getBounds`' measured box: the last one read back (`null` when nothing finite was\n * there), the position texture version it was asked at, and whether a read is on its\n * way. Unset until the first read lands, and again when a new dataset is loaded. The\n * serial counts the datasets loaded: a read of the previous one that lands after the\n * next is dropped.\n */\n measuredBounds?: [number[], number[]] | null;\n measuredBoundsVersion?: number;\n isMeasuringBounds?: boolean;\n loadSerial?: number;\n /** The view was found unsupported and said so; said once. */\n viewWarned?: boolean;\n linksWarned?: boolean;\n draggedPointIndex: number | null;\n /**\n * This layer's last auto-highlight write was a hover. Several layers may draw one\n * graph, and the hover lives on the graph: only the layer holding it clears it.\n */\n holdsHover: boolean;\n animationHandle?: number;\n }\n\n public get isLoaded (): boolean {\n return super.isLoaded && Boolean(this.state?.isReady)\n }\n\n public initializeState (): void {\n const { device, timeline } = this.context\n if (device.type !== 'webgl') {\n throw new Error(\n `@cosmos.gl/deck-layers requires a WebGL 2 device — cosmos.gl is WebGL-only, got '${device.type}'`\n )\n }\n\n this.state = {\n providedGraph: null,\n isReady: false,\n isIngestPending: false,\n hasLoaded: false,\n pointCount: 0,\n linkCount: 0,\n keptLinks: null,\n draggedPointIndex: null,\n holdsHover: false,\n // Step the simulation exactly once per animation frame, independent of\n // draw passes (draw runs per viewport)\n animationHandle: timeline.attachAnimation({ setTime: (time) => this._onTimelineTick(time) }),\n }\n this._attachGraph(this.props.graph ?? null)\n }\n\n public updateState (params: UpdateParameters<this>): void {\n super.updateState(params)\n const { props, oldProps, changeFlags } = params\n // Swapping graphs loads the current data into the new one, or follows it\n const providedGraph = props.graph ?? null\n const graphSwapped = providedGraph !== this.state.providedGraph\n if (graphSwapped) {\n this._releaseGraph()\n this._attachGraph(providedGraph)\n }\n const graph = this.state.graph\n if (!graph) return\n\n if (!providedGraph && !graphSwapped && !configEquals(props.config, oldProps.config)) {\n // Graph.setConfig starts from the defaults: a key left out goes back to its default\n graph.setConfig(this._graphConfig())\n }\n\n const triggers = typeof changeFlags.updateTriggersChanged === 'object'\n ? changeFlags.updateTriggersChanged as CosmosUpdateTriggers\n : undefined\n const triggered = (key: keyof CosmosUpdateTriggers): boolean => Boolean(triggers?.all || triggers?.[key])\n // Array links resolve against the id map and the position accessor at load,\n // so a change to either counts as a change of that channel\n const pointsChanged = graphSwapped || props.points !== oldProps.points || triggered('getPointPosition')\n const idsChanged = triggered('getPointId')\n const linksChanged = graphSwapped || props.links !== oldProps.links ||\n triggered('getLinkSource') || triggered('getLinkTarget') || idsChanged\n // Styles follow their accessors (a constant by value, a function by trigger) and\n // ride along with a new points or links object, which may carry new attributes\n const pointStyleChanged = pointsChanged || triggered('getPointColor') || triggered('getPointSize') ||\n accessorReplaced(props.getPointColor, oldProps.getPointColor) || accessorReplaced(props.getPointSize, oldProps.getPointSize)\n const linkStyleChanged = linksChanged || triggered('getLinkColor') || triggered('getLinkWidth') ||\n accessorReplaced(props.getLinkColor, oldProps.getLinkColor) || accessorReplaced(props.getLinkWidth, oldProps.getLinkWidth)\n if (!pointsChanged && !linksChanged && !pointStyleChanged && !linkStyleChanged) return\n\n // A channel the layer uploaded and the app no longer gives goes back to the config\n // default. Only the layer's own upload is cleared: it had data to load (`points`) on\n // this graph, so an array the application set itself is never touched\n const uploaded = Boolean(oldProps.points) && !graphSwapped\n const oldPoints = pointAttributesOf(oldProps.points)\n const newPoints = pointAttributesOf(props.points)\n const oldLinks = linkAttributesOf(oldProps.links)\n const newLinks = linkAttributesOf(props.links)\n const stopped = (before: boolean, now: boolean): boolean => uploaded && before && !now\n const unsetChannels = {\n pointColorUnset: stopped(isChannelSet(oldProps.getPointColor, oldPoints?.getPointColor), isChannelSet(props.getPointColor, newPoints?.getPointColor)),\n pointSizeUnset: stopped(isChannelSet(oldProps.getPointSize, oldPoints?.getPointSize), isChannelSet(props.getPointSize, newPoints?.getPointSize)),\n linkColorUnset: stopped(isChannelSet(oldProps.getLinkColor, oldLinks?.getLinkColor), isChannelSet(props.getLinkColor, newLinks?.getLinkColor)),\n linkWidthUnset: stopped(isChannelSet(oldProps.getLinkWidth, oldLinks?.getLinkWidth), isChannelSet(props.getLinkWidth, newLinks?.getLinkWidth)),\n }\n\n if (props.points) {\n // The layer's data goes into the graph — once the device check has passed\n if (this.state.isReady) this._load({ pointsChanged, linksChanged, idsChanged, pointStyleChanged, linkStyleChanged, ...unsetChannels })\n else this.state.isIngestPending = true\n } else {\n // No data of its own: the layer draws what the graph holds and writes nothing\n if (props.links && !this.state.linksWarned) {\n this.state.linksWarned = true\n console.warn('@cosmos.gl/deck-layers: `links` is ignored without `points` — load them into the graph instead')\n }\n this.state.isIngestPending = false\n this.state.hasLoaded = false\n }\n }\n\n public draw (opts: {\n shaderModuleProps?: { picking?: { isActive?: number | boolean } };\n parameters?: { blendColor?: number[] };\n }): void {\n const { graph, isReady } = this.state\n if (!graph || !isReady) return\n\n const { viewport } = this.context\n const view = this._viewTransform(graph, viewport)\n if (!view) return\n graph.setViewTransform(view, [viewport.width, viewport.height])\n if (opts.shaderModuleProps?.picking?.isActive) {\n // deck's pick pass: cosmos draws its picking colors with the alpha deck uses to tell\n // layers apart (the pass's blend constant), links offset past the points so one layer\n // carries both index spaces — getPickingInfo splits them again\n graph.drawToRenderPass(this.context.renderPass, {\n picking: {\n alpha: opts.parameters?.blendColor?.[3] ?? 1,\n linkIndexOffset: graph.graph.pointsNumber ?? 0,\n },\n })\n return\n }\n graph.drawToRenderPass(this.context.renderPass)\n }\n\n public getPickingInfo ({ info }: GetPickingInfoParams): CosmosGraphPickingInfo {\n const picked: CosmosGraphPickingInfo = info\n const graph = this.state.graph\n if (!graph || info.index < 0) return picked\n const pointCount = graph.graph.pointsNumber ?? 0\n const { points, links } = this.props\n if (info.index >= pointCount) {\n picked.elementType = 'link'\n picked.index = info.index - pointCount\n picked.object = Array.isArray(links) ? this.state.keptLinks?.[picked.index] : undefined\n } else {\n picked.elementType = 'point'\n picked.object = Array.isArray(points) ? points[info.index] : undefined\n }\n return picked\n }\n\n public onDragStart (info: PickingInfo, event: DragGestureEvent): boolean {\n const { graph } = this.state\n const { enablePointDrag, dragReheatAlpha } = this.props\n const picked = info as CosmosGraphPickingInfo\n if (!enablePointDrag || !graph || picked.elementType !== 'point' || info.index < 0) return false\n\n // A direct field write: per-gesture state must not re-run the layer's update\n this.state.draggedPointIndex = info.index\n graph.setPinnedPoint(info.index, true)\n if (dragReheatAlpha !== null) graph.start(dragReheatAlpha)\n // A grabbed point must not also pan the view\n event.stopImmediatePropagation?.()\n this.props.onPointDragStart?.(picked)\n return true\n }\n\n public onDrag (info: PickingInfo, event: DragGestureEvent): boolean {\n const { graph, draggedPointIndex } = this.state\n if (!graph || draggedPointIndex === null) return false\n\n const position = this._dragPosition(graph, info)\n if (position) graph.setPointPosition(draggedPointIndex, position[0], position[1])\n event.stopImmediatePropagation?.()\n // Repaint even when the simulation is settled and the ticker is idle\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n this.props.onPointDrag?.(info as CosmosGraphPickingInfo)\n return true\n }\n\n public onDragEnd (info: PickingInfo, event: DragGestureEvent): boolean {\n const { graph, draggedPointIndex } = this.state\n if (!graph || draggedPointIndex === null) return false\n\n if (this.props.unpinOnDragEnd) graph.setPinnedPoint(draggedPointIndex, false)\n this.state.draggedPointIndex = null\n event.stopImmediatePropagation?.()\n this.props.onPointDragEnd?.(info as CosmosGraphPickingInfo)\n return true\n }\n\n /**\n * The box around the graph's points, `[[minX, minY, 0], [maxX, maxY, 0]]`, for an\n * application to frame the layer with. In space coordinates, before `modelMatrix`: map it\n * through `modelMatrix` (and, on a map, unproject it) before fitting a viewport to it.\n * deck.gl's core does not call it; its mask effect reads it from every mask layer and its\n * collision-filter effect from every layer carrying that extension, each on every frame.\n *\n * `spaceSize` bounds no position — a layout grows past its square as far as its forces\n * take it — so the box is measured from the live positions, read back from the GPU. The\n * read does not stall the frame: it is asynchronous, started by a call that finds the\n * positions changed since the box was measured, one at a time, and the box it returns is\n * the last one measured. While a read is on its way the layer holds the graph's step, as\n * the engine's own render loop holds its frame for a copy: the read that completes a copy\n * waits for every command queued before it, and a step queued behind the copy would be\n * that wait. (A graph the application steps itself is not held.) While points move the\n * box trails the drawn frame, by a frame or so, and a call made before the first read\n * lands — or before the first read of a newly loaded dataset — gets the input box below.\n * When a read lands the layer asks for a redraw, so a consumer reading the box every\n * frame has the new one on the next. A layer nobody asks reads nothing. Absent points\n * (NaN) are left out.\n *\n * Until the graph holds positions (its device is still initializing) or the first read\n * has landed, the box is that of the positions the layer is about to load or has loaded:\n * `initialPositions`, or `getPointPosition` over the point objects, plus the middle half\n * of the space where unseeded points are placed — where the points start, so a view can\n * be framed before the first frame.\n *\n * When there is nothing to measure — no points yet, every point absent, or positions the\n * graph rescales on load (`rescalePositions: true`), which it centres on the space — the\n * box is the space's square, `[[0, 0, 0], [spaceSize, spaceSize, 0]]`: where the graph\n * starts, and what this method returned before layouts could leave the square. It is\n * never `null`; the declared type keeps deck's `Layer.getBounds` contract, so a subclass\n * may still override it with deck's own signature.\n */\n public getBounds (): [number[], number[]] | null {\n const { state } = this\n const graph = state?.graph\n const positions = graph?.getPointPositionTexture()\n if (graph && positions && positions.pointCount > 0) {\n if (positions.version !== state.measuredBoundsVersion && !state.isMeasuringBounds) this._measureBounds(graph, positions.version)\n if (state.measuredBounds !== undefined) return state.measuredBounds ?? this._spaceSquare()\n }\n const box = new BoundsBox()\n this._addInputPositions(box)\n return box.bounds() ?? this._spaceSquare()\n }\n\n public finalizeState (context: LayerContext): void {\n if (this.state?.animationHandle !== undefined) {\n this.context.timeline.detachAnimation(this.state.animationHandle)\n }\n if (this.state) this._releaseGraph()\n super.finalizeState(context)\n }\n\n /** No deck attributes: cosmos.gl holds every channel and draws them itself. */\n protected _getAttributeManager (): null {\n return null\n }\n\n /**\n * deck's auto-highlight, through cosmos.gl's own hover emphasis: the hovered point\n * gets the hover ring, the hovered link the hovered-link width and color. It is the\n * graph's host hover, so the graph's config — focus included — stays the\n * application's. deck's picking module has no model of ours to tint, so\n * `highlightColor` does not apply.\n */\n protected _updateAutoHighlight (info: PickingInfo): void {\n const { graph, isReady } = this.state\n if (!graph || !isReady) return\n const type = info.picked && info.index >= 0 ? (info as CosmosGraphPickingInfo).elementType : undefined\n const pointIndex = type === 'point' ? info.index : undefined\n const linkIndex = type === 'link' ? info.index : undefined\n graph.setHostHoveredPoint(pointIndex)\n graph.setHostHoveredLink(linkIndex)\n // A direct field write, as for a drag: hover state must not re-run the layer's update\n this.state.holdsHover = pointIndex !== undefined || linkIndex !== undefined\n this.setNeedsRedraw()\n }\n\n /**\n * The pointer in space coordinates, through the view of the viewport the pointer\n * is in — the same derivation `draw` hands cosmos, inverted — under a map as well\n * as an orthographic view. Not through the view cosmos holds: that is whichever\n * viewport drew the graph last, a thumbnail's as easily as the one being dragged\n * in. Pixels are relative to that viewport. Where the view cannot be derived the\n * point stays where it is.\n */\n private _dragPosition (graph: Graph, info: PickingInfo): [number, number] | null {\n const viewport = info.viewport ?? this.context.viewport\n const view = this._viewTransform(graph, viewport)\n if (!view) return null\n // Space is y up; the space origin's pixel and the scale are the whole affine map\n return [(info.x - viewport.x - view.originX) / view.k, (view.originY - (info.y - viewport.y)) / view.k]\n }\n\n /** Adopts the provided graph, or creates a headless one on deck's device when `provided` is `null`. */\n private _attachGraph (provided: Graph | null): void {\n const { device } = this.context\n const graph = provided ?? new Graph(null, this._graphConfig(), Promise.resolve(device))\n this.setState({\n graph,\n providedGraph: provided,\n isReady: false,\n hasLoaded: false,\n loadedPositions: undefined,\n loadedPairs: null,\n idToIndex: null,\n keptLinks: null,\n })\n\n if (!provided) this.props.onGraphCreated?.(graph)\n\n graph.ready.then(() => {\n // `this` may be a stale descriptor by now; state is the stable identity\n if (this.state?.graph !== graph) return\n const layer = (this.getCurrentLayer() ?? this) as CosmosGraphLayer<PointDataT, LinkDataT>\n // cosmos records its draws into deck's render pass: that needs deck's device\n if (graph.simulation.device !== layer.context.device) {\n console.error(\n '@cosmos.gl/deck-layers: the provided graph runs on a different device than deck — construct it with the device from deck\\'s onDeviceInitialized'\n )\n return\n }\n // Only now may the layer touch the graph's data\n if (layer.state.isIngestPending) {\n layer.state.isIngestPending = false\n layer._load({\n pointsChanged: true,\n linksChanged: true,\n idsChanged: true,\n pointStyleChanged: true,\n linkStyleChanged: true,\n pointColorUnset: false,\n pointSizeUnset: false,\n linkColorUnset: false,\n linkWidthUnset: false,\n })\n }\n layer.setState({ isReady: true })\n }).catch((error: Error) => {\n console.error('@cosmos.gl/deck-layers: the graph failed to initialize', error)\n })\n }\n\n /**\n * Destroys a layer-created graph; a provided one is left to the application, without\n * the hover this layer put on it. deck sends no leave to a layer it removes.\n */\n private _releaseGraph (): void {\n const { graph, providedGraph, holdsHover } = this.state\n if (graph && providedGraph) {\n if (holdsHover) {\n graph.setHostHoveredPoint(undefined)\n graph.setHostHoveredLink(undefined)\n }\n } else if (graph) graph.destroy()\n this.state.graph = undefined\n this.state.holdsHover = false\n // Another graph's texture versions would not mean the same box\n this.state.measuredBounds = undefined\n this.state.measuredBoundsVersion = undefined\n this.state.isMeasuringBounds = false\n }\n\n /**\n * Starts one asynchronous read of the live positions and keeps its box for `getBounds`,\n * stamped with the texture version the read was asked at. A read that lands after the\n * layer let go of the graph is dropped; an empty result (nothing to read, or the point\n * count changed under the copy) leaves the box as it was, and the next call asks again.\n */\n private _measureBounds (graph: Graph, version: number): void {\n const { state } = this\n const serial = state.loadSerial\n state.isMeasuringBounds = true\n pendingBoundsReads.set(graph, (pendingBoundsReads.get(graph) ?? 0) + 1)\n const settled = (): void => { pendingBoundsReads.set(graph, Math.max(0, (pendingBoundsReads.get(graph) ?? 1) - 1)) }\n graph.getPointPositionsAsync().then((positions) => {\n settled()\n if (state.graph !== graph) return\n state.isMeasuringBounds = false\n // Another dataset has been loaded since: not its box. The next frame starts a read of\n // the dataset there now\n if (state.loadSerial !== serial) {\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n return\n }\n if (positions.length === 0) return\n const box = new BoundsBox()\n for (let i = 0; i < positions.length; i += 2) box.add(positions[i] as number, positions[i + 1] as number)\n state.measuredBounds = box.bounds()\n state.measuredBoundsVersion = version\n // A consumer that reads the box every frame has the new one on the next\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n }, () => {\n settled()\n if (state.graph !== graph) return\n state.isMeasuringBounds = false\n // Nothing was measured: the next frame asks again\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n })\n }\n\n /** The space's square, the stand-in extent when there is nothing to measure (see `getBounds`). */\n private _spaceSquare (): [number[], number[]] {\n const spaceSize = this._spaceSize()\n return [[0, 0, 0], [spaceSize, spaceSize, 0]]\n }\n\n /**\n * Adds the positions the layer would load to `box` (see `getBounds`): the given ones,\n * placed as the engine will place them, and the square unseeded points are drawn in.\n * Nothing when they are rescaled on load.\n */\n private _addInputPositions (box: BoundsBox): void {\n const { points, getPointPosition } = this.props\n if (!points) return\n // Loaded positions are space coordinates unless the graph's config asks to rescale them\n if ((this.state?.graph?.config ?? this.props.config)?.rescalePositions === true) return\n const spaceSize = this._spaceSize()\n // The engine stores float32 and puts an infinite coordinate of a present point on the\n // matching edge of the space (position-utils' toFiniteCoordinate); NaN marks it absent\n const add = (x: number, y: number): void => {\n if (Number.isNaN(x) || Number.isNaN(y)) return\n box.add(toEngineCoordinate(x, spaceSize), toEngineCoordinate(y, spaceSize))\n }\n let unseeded = false\n if (Array.isArray(points)) {\n const pointArray = points as readonly PointDataT[]\n for (let i = 0; i < pointArray.length; i += 1) {\n const info: AccessorContext<PointDataT> = { index: i, data: pointArray, target: [] }\n const position = getPointPosition ? resolveAccessor(getPointPosition, pointArray[i] as PointDataT, info) : null\n if (position) add(position[0], position[1])\n else unseeded = true\n }\n } else {\n const { length, initialPositions } = points as { length: number; initialPositions?: Float32Array }\n if (initialPositions) {\n for (let i = 0; i < length; i += 1) add(initialPositions[i * 2] as number, initialPositions[i * 2 + 1] as number)\n } else unseeded = length > 0\n }\n if (unseeded) {\n // _load's randomCoordinate draws inside this square\n box.add(spaceSize * UNSEEDED_PLACEMENT[0], spaceSize * UNSEEDED_PLACEMENT[0])\n box.add(spaceSize * UNSEEDED_PLACEMENT[1], spaceSize * UNSEEDED_PLACEMENT[1])\n }\n }\n\n /**\n * The length the engine's placement rules are fractions of: the infinite-input edge, the\n * unseeded square, and the stand-in extent. The graph's own, validated, length once\n * there is a graph — from its construction, so the default when its config's `spaceSize`\n * is not a usable size, and authoritative for a provided graph — the config's before.\n * It sizes nothing.\n */\n private _spaceSize (): number {\n const engine = this.state?.graph?.simulation.store.referenceLength\n if (engine !== undefined) return engine\n // Before a graph exists, the config's, resolved as the engine will resolve it: the\n // default unless it is a positive finite number, and at least 2\n const configured = this.props.config?.spaceSize\n if (configured === undefined || !Number.isFinite(configured) || configured <= 0) return defaultConfigValues.spaceSize\n return Math.max(configured, 2)\n }\n\n /**\n * The config for a layer-created graph: the prop without the keys deck owns,\n * and the pixel ratio deck's canvas draws at, so cosmos sizes pixels alike.\n */\n private _graphConfig (): GraphConfig {\n const config: Partial<Record<keyof GraphConfig, unknown>> = { ...this.props.config }\n for (const key of DECK_OWNED_CONFIG_KEYS) delete config[key]\n config.pixelRatio = this._pixelRatio()\n return config as GraphConfig\n }\n\n /** deck's device pixels per CSS pixel, as its canvas context reports them. */\n private _pixelRatio (): number {\n const canvasContext = this.context.device.canvasContext as { cssToDeviceRatio?: () => number } | null\n const ratio = canvasContext?.cssToDeviceRatio?.()\n if (ratio && Number.isFinite(ratio)) return ratio\n return typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1\n }\n\n /**\n * cosmos's view for a deck viewport: a uniform scale `k` (pixels per space\n * unit) and a translation, per `setViewTransform`'s space → screen formula,\n * inverted. Three anchors through deck's projection — the space origin, its\n * x axis, its y axis — give the scale and tell whether the view is one cosmos\n * can draw: unrotated, unpitched, y up. The translation then follows from where\n * the space origin lands and the world origin cosmos centres its screen on, read\n * from the engine (`spaceSize / 2` on both axes, after the engine's own space-size\n * adjustment). The space origin's pixel is returned too, for mapping the other way.\n */\n private _viewTransform (\n graph: Graph,\n viewport: Viewport\n ): { k: number; x: number; y: number; originX: number; originY: number } | null {\n // The engine's own origin, not the config's: it is what cosmos draws with, and it stays\n // valid when `config.spaceSize` is not (the engine falls back to a default)\n const { worldOrigin } = graph.simulation.store\n const probeLength = VIEW_PROBE_LENGTH\n const modelMatrix = this.props.modelMatrix\n const toPixel = (sx: number, sy: number): [number, number] => {\n // Space → common (through modelMatrix, column-major, z = 0) → world → pixel.\n // On a map, common is Web Mercator and world is lng/lat; elsewhere both are\n // common, and unprojectPosition is the identity\n const cx = modelMatrix ? (modelMatrix[0] as number) * sx + (modelMatrix[4] as number) * sy + (modelMatrix[12] as number) : sx\n const cy = modelMatrix ? (modelMatrix[1] as number) * sx + (modelMatrix[5] as number) * sy + (modelMatrix[13] as number) : sy\n const world = viewport.unprojectPosition([cx, cy, 0])\n const pixel = viewport.project(world)\n return [pixel[0] as number, pixel[1] as number]\n }\n const [originX, originY] = toPixel(0, 0)\n const [eastX, eastY] = toPixel(probeLength, 0)\n const [northX, northY] = toPixel(0, probeLength)\n const k = (eastX - originX) / probeLength\n const tolerance = 1e-3 * Math.max(1, Math.abs(eastX - originX))\n const rotated = Math.abs(eastY - originY) > tolerance || Math.abs(northX - originX) > tolerance\n const yDown = northY > originY\n if (rotated || yDown || !(k > 0)) {\n if (!this.state.viewWarned) {\n this.state.viewWarned = true\n console.warn(\n '@cosmos.gl/deck-layers: cosmos.gl draws under a flat, north-up, y-up view only — ' +\n 'use OrthographicView({ flipY: false }) or a map at pitch 0 and bearing 0. The graph is not drawn.'\n )\n }\n return null\n }\n this.state.viewWarned = false\n // setViewTransform's formula at the space origin (0, 0), solved for the translation:\n // originX = k * (w / 2 - ox) + x, originY = k * (oy + h / 2) + y, with (ox, oy) the\n // world origin cosmos centres the screen on\n const [worldOriginX, worldOriginY] = worldOrigin\n return {\n k,\n x: originX - k * (viewport.width / 2 - worldOriginX),\n y: originY - k * (worldOriginY + viewport.height / 2),\n originX,\n originY,\n }\n }\n\n private _onTimelineTick (time: number): void {\n const { graph, isReady } = this.state ?? {}\n if (!graph || !isReady || !graph.isSimulationRunning) return\n // One step per frame per graph, however many layers draw it — and none while a bounds\n // read of any of them is on its way, which would otherwise wait for the step (getBounds)\n if (steppedAt.get(graph) !== time && !pendingBoundsReads.get(graph)) {\n steppedAt.set(graph, time)\n graph.step()\n }\n // Repaint the frame this step just computed; when the simulation settles,\n // the flag stops being set and deck goes idle on its own\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n }\n\n /**\n * Load mode: puts the layer's `points`, `links` and styles into the graph.\n * Each channel is sent only when its own input changed — a restyle leaves the\n * layout alone, a changed id map re-resolves array links without touching the\n * positions.\n */\n private _load (changes: {\n pointsChanged: boolean;\n linksChanged: boolean;\n idsChanged: boolean;\n pointStyleChanged: boolean;\n linkStyleChanged: boolean;\n pointColorUnset: boolean;\n pointSizeUnset: boolean;\n linkColorUnset: boolean;\n linkWidthUnset: boolean;\n }): void {\n const graph = this.state.graph\n if (!graph) return\n const { points, links, getPointId, getPointPosition } = this.props\n if (!points) return\n const firstLoad = !this.state.hasLoaded\n const spaceSize = this._spaceSize()\n\n // Unseeded points land in UNSEEDED_PLACEMENT, around the world origin gravity pulls\n // toward. They are drawn from the graph's own RNG, so a `randomSeed` reproduces the\n // layout\n const randomCoordinate = (): number =>\n spaceSize * graph.simulation.store.getRandomFloat(UNSEEDED_PLACEMENT[0], UNSEEDED_PLACEMENT[1])\n\n let pointCount: number\n let pointObjects: readonly PointDataT[] | null = null\n let pointAttributes: CosmosPointAttributes | undefined\n let positions: Float32Array | null = null // to load; null leaves the graph's\n let loadedPositions = this.state.loadedPositions\n let idToIndex = this.state.idToIndex ?? null\n\n if (Array.isArray(points)) {\n const pointArray = points as readonly PointDataT[]\n pointCount = pointArray.length\n pointObjects = pointArray\n // Object points carry positions and ids together: a change reloads both\n if (firstLoad || changes.pointsChanged) {\n positions = new Float32Array(pointCount * 2)\n idToIndex = getPointId ? new Map() : null\n for (let i = 0; i < pointCount; i += 1) {\n const point = pointArray[i] as PointDataT\n const info: AccessorContext<PointDataT> = { index: i, data: pointArray, target: [] }\n const position = getPointPosition ? resolveAccessor(getPointPosition, point, info) : null\n positions[i * 2] = position ? position[0] : randomCoordinate()\n positions[i * 2 + 1] = position ? position[1] : randomCoordinate()\n if (idToIndex && getPointId) idToIndex.set(resolveAccessor(getPointId, point, info), i)\n }\n loadedPositions = pointArray\n } else if (changes.idsChanged) {\n idToIndex = getPointId ? new Map() : null\n if (idToIndex && getPointId) {\n for (let i = 0; i < pointCount; i += 1) {\n const info: AccessorContext<PointDataT> = { index: i, data: pointArray, target: [] }\n idToIndex.set(resolveAccessor(getPointId, pointArray[i] as PointDataT, info), i)\n }\n }\n }\n } else {\n const binaryPoints = points as { length: number; initialPositions?: Float32Array; attributes?: CosmosPointAttributes }\n pointCount = binaryPoints.length\n pointAttributes = binaryPoints.attributes\n idToIndex = null\n // Positions reload when their input changed: another `initialPositions`\n // array, a seed the layer must draw again for a new count, or a first load\n const positionsInput: unknown = binaryPoints.initialPositions ?? SEEDED\n if (firstLoad || positionsInput !== this.state.loadedPositions || pointCount !== this.state.pointCount) {\n if (binaryPoints.initialPositions) {\n positions = binaryPoints.initialPositions\n } else {\n positions = new Float32Array(pointCount * 2)\n for (let i = 0; i < positions.length; i += 1) positions[i] = randomCoordinate()\n }\n loadedPositions = positionsInput\n }\n }\n\n let pairs: Float32Array | null = null // to load; null leaves the graph's\n let linkCount = this.state.linkCount\n let keptLinks: readonly LinkDataT[] | null = this.state.keptLinks\n let linkAttributes: CosmosLinkAttributes | undefined\n if (links instanceof Float32Array || (links && !Array.isArray(links) && 'pairs' in links)) {\n const pairArray = links instanceof Float32Array ? links : links.pairs\n linkAttributes = links instanceof Float32Array ? undefined : links.attributes\n keptLinks = null\n linkCount = pairArray.length / 2\n if (firstLoad || pairArray !== this.state.loadedPairs) pairs = pairArray\n } else if (Array.isArray(links)) {\n // Array links resolve against the loaded points, so they reload with them\n if (firstLoad || changes.linksChanged || positions) {\n const linkObjects = links as readonly LinkDataT[]\n const { getLinkSource, getLinkTarget } = this.props\n // An endpoint is a point index, or a point id when the id map exists;\n // anything that does not name a point drops the whole link\n const resolveEndpoint = (endpoint: string | number): number | undefined => {\n const index = idToIndex ? idToIndex.get(endpoint) : endpoint\n return typeof index === 'number' && Number.isInteger(index) && index >= 0 && index < pointCount\n ? index\n : undefined\n }\n const kept: LinkDataT[] = []\n const keptIndices: number[] = []\n for (let i = 0; i < linkObjects.length; i += 1) {\n const link = linkObjects[i] as LinkDataT\n const info: AccessorContext<LinkDataT> = { index: i, data: linkObjects, target: [] }\n const source = resolveEndpoint(resolveAccessor(getLinkSource, link, info))\n const target = resolveEndpoint(resolveAccessor(getLinkTarget, link, info))\n if (source === undefined || target === undefined) continue\n kept.push(link)\n keptIndices.push(source, target)\n }\n const dropped = linkObjects.length - kept.length\n if (dropped > 0) {\n const hint = idToIndex ? 'getLinkSource / getLinkTarget against getPointId' : 'getLinkSource / getLinkTarget'\n console.warn(\n `@cosmos.gl/deck-layers: dropped ${dropped} of ${linkObjects.length} links whose source or target is not a point — check ${hint}`\n )\n }\n pairs = Float32Array.from(keptIndices)\n keptLinks = kept\n linkCount = kept.length\n }\n } else {\n keptLinks = null\n linkCount = 0\n if (firstLoad || this.state.loadedPairs !== NO_LINKS) pairs = NO_LINKS\n }\n\n // Positions are space coordinates by contract: not rescaled unless the graph's config asks\n if (positions) {\n graph.setPointPositions(positions, graph.config.rescalePositions === undefined ? true : undefined)\n // The box measured from the previous dataset is not this one's: until its first read\n // lands, getBounds serves the input box, and a read of the old positions is dropped\n this.state.measuredBounds = undefined\n this.state.measuredBoundsVersion = undefined\n this.state.loadSerial = (this.state.loadSerial ?? 0) + 1\n }\n if (pairs) graph.setLinks(pairs)\n // Styles: deck accessors and attributes, as cosmos's arrays. A channel the app gives\n // follows a reload (the count may have changed) and its own accessor; a channel it\n // does not give is left to the config default, and cleared when it just stopped\n const { getPointColor, getPointSize, getLinkColor, getLinkWidth } = this.props\n if (positions || changes.pointStyleChanged) {\n if (isChannelSet(getPointColor, pointAttributes?.getPointColor)) {\n graph.setPointColors(toColorArray(pointCount, getPointColor, pointObjects, pointAttributes?.getPointColor))\n } else if (changes.pointColorUnset) graph.setPointColors(NO_STYLE)\n if (isChannelSet(getPointSize, pointAttributes?.getPointSize)) {\n graph.setPointSizes(toValueArray(pointCount, getPointSize, pointObjects, pointAttributes?.getPointSize))\n } else if (changes.pointSizeUnset) graph.setPointSizes(NO_STYLE)\n }\n if (pairs || changes.linkStyleChanged) {\n if (isChannelSet(getLinkColor, linkAttributes?.getLinkColor)) {\n graph.setLinkColors(toColorArray(linkCount, getLinkColor, keptLinks, linkAttributes?.getLinkColor))\n } else if (changes.linkColorUnset) graph.setLinkColors(NO_STYLE)\n if (isChannelSet(getLinkWidth, linkAttributes?.getLinkWidth)) {\n graph.setLinkWidths(toValueArray(linkCount, getLinkWidth, keptLinks, linkAttributes?.getLinkWidth))\n } else if (changes.linkWidthUnset) graph.setLinkWidths(NO_STYLE)\n }\n // A headless graph applies at once: no transition, and the simulation keeps its alpha\n graph.render()\n\n // A new id map with nothing reloaded still changes how ids reach indices\n const idsRemapped = idToIndex !== this.state.idToIndex\n this.setState({\n hasLoaded: true,\n pointCount,\n linkCount,\n keptLinks,\n loadedPositions,\n loadedPairs: pairs ?? this.state.loadedPairs,\n idToIndex,\n })\n\n // After the graph holds the data, so what the callback sends lines up with it.\n // A throw is the app's error, not the layer's: it goes to deck's onError and leaves\n // the load, and the layer's readiness after a first load, intact.\n if (positions || pairs || idsRemapped) {\n try {\n this.props.onGraphDataLoaded?.({\n graph,\n pointsLoaded: Boolean(positions),\n linksLoaded: Boolean(pairs),\n pointIndexById: idToIndex,\n links: Array.isArray(links) ? keptLinks : null,\n })\n } catch (error) {\n this.raiseError(error as Error, 'onGraphDataLoaded')\n }\n }\n }\n}\n"],"names":["DECK_OWNED_CONFIG_KEYS","isStyleAccessor","constant","value","defaultProps","l","COORDINATE_SYSTEM","resolveAccessor","accessor","object","info","accessorReplaced","next","previous","configEquals","b","keys","key","x","y","v","i","toColorArray","count","objects","attribute","channel","colors","data","color","toValueArray","values","steppedAt","pendingBoundsReads","UNSEEDED_PLACEMENT","VIEW_PROBE_LENGTH","toEngineCoordinate","infiniteEdge","rounded","BoundsBox","SEEDED","NO_LINKS","NO_STYLE","isChannelSet","pointAttributesOf","points","linkAttributesOf","links","_CosmosGraphLayer","Layer","_a","device","timeline","time","params","props","oldProps","changeFlags","providedGraph","graphSwapped","graph","triggers","triggered","pointsChanged","idsChanged","linksChanged","pointStyleChanged","linkStyleChanged","uploaded","oldPoints","newPoints","oldLinks","newLinks","stopped","before","now","unsetChannels","opts","isReady","viewport","view","_b","_d","_c","picked","pointCount","event","enablePointDrag","dragReheatAlpha","draggedPointIndex","position","state","positions","box","context","type","pointIndex","linkIndex","provided","Graph","layer","error","holdsHover","version","serial","settled","spaceSize","getPointPosition","add","unseeded","pointArray","length","initialPositions","engine","configured","defaultConfigValues","config","canvasContext","ratio","worldOrigin","probeLength","modelMatrix","toPixel","sx","sy","cx","cy","world","pixel","originX","originY","eastX","eastY","northX","northY","k","tolerance","rotated","yDown","worldOriginX","worldOriginY","changes","getPointId","firstLoad","randomCoordinate","pointObjects","pointAttributes","loadedPositions","idToIndex","point","binaryPoints","positionsInput","pairs","linkCount","keptLinks","linkAttributes","pairArray","linkObjects","getLinkSource","getLinkTarget","resolveEndpoint","endpoint","index","kept","keptIndices","link","source","target","dropped","hint","getPointColor","getPointSize","getLinkColor","getLinkWidth","idsRemapped","CosmosGraphLayer"],"mappings":";;AAuEO,MAAMA,KAAyB;AAAA,EACpC;AAAA,EAAoB;AAAA,EAAmB;AAAA,EAAc;AAAA,EAAkB;AAAA,EACvE;AAAA,EAAsB;AAAA,EACtB;AAAA,EAAoB;AAAA,EAAc;AAAA,EAA8B;AAAA,EAChE;AAAA,EAAiB;AAAA,EAAgB;AAAA,EAAkB;AAAA,EAAmB;AAAA,EAAyB;AAAA,EAC/F;AAAA,EAAgC;AAAA,EAChC;AAAA,EAAW;AAAA,EAAgB;AAAA,EAAe;AAAA,EAC1C;AAAA,EAAiB;AAAA,EAAsB;AAAA,EAAqB;AAAA,EAC5D;AAAA,EAAe;AAAA,EAAoB;AAAA,EAAmB;AAAA,EAAmB;AAAA,EACzE;AAAA,EAAe;AAAA,EAAU;AAAA,EAAa;AAAA,EAAe;AAAA,EAAU;AACjE,GA4LMC,IAAkB,CAACC,MAAiC,CAACC,MACzDA,KAAS,QAAQ,OAAOA,KAAU,eACjCD,MAAa,WAAW,OAAOC,KAAU,WAAW,MAAM,QAAQA,CAAK,KAAK,YAAY,OAAOA,CAAK,IAEjGC,KAAoD;AAAA,EACxD,QAAQ,EAAE,MAAM,UAAU,OAAO,MAAM,UAAU,GAAA;AAAA,EACjD,OAAO;AAAA,EACP,YAAY,EAAE,MAAM,YAAY,OAAO,KAAA;AAAA,EACvC,kBAAkB,EAAE,MAAM,YAAY,OAAO,KAAA;AAAA,EAC7C,cAAc,EAAE,MAAM,YAAY,OAAO,MAAM,UAAUH,EAAgB,QAAQ,EAAA;AAAA,EACjF,eAAe,EAAE,MAAM,YAAY,OAA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K,MAAM;AAc7C,QAbA,KAAK,SAAS;AAAA,MACZ,WAAW;AAAA,MACX,YAAA/D;AAAA,MACA,WAAAoE;AAAA,MACA,WAAAC;AAAA,MACA,iBAAAP;AAAA,MACA,aAAaK,KAAS,KAAK,MAAM;AAAA,MACjC,WAAAJ;AAAA,IAAA,CACD,GAKGxD,KAAa4D,KAASsB;AACxB,UAAI;AACF,SAAA7F,KAAA/B,IAAA,KAAK,OAAM,sBAAX,QAAA+B,EAAA,KAAA/B,GAA+B;AAAA,UAC7B,OAAAU;AAAA,UACA,cAAc,EAAQgC;AAAA,UACtB,aAAa,EAAQ4D;AAAA,UACrB,gBAAgBJ;AAAA,UAChB,OAAO,MAAM,QAAQrG,CAAK,IAAI2G,IAAY;AAAA,QAAA;AAAA,MAE9C,SAASrD,GAAO;AACd,aAAK,WAAWA,GAAgB,mBAAmB;AAAA,MACrD;AAAA,EAEJ;AACF;AA3wBErD,EAAc,YAAY,oBAC1BA,EAAc,eAAe5C;AAJxB,IAAM2K,KAAN/H;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmos.gl/deck-layers",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "A deck.gl layer that runs and draws a cosmos.gl graph — cosmos.gl's own renderer under deck's camera, on a shared luma.gl device",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@luma.gl/core": "~9.3.0",
|
|
35
35
|
"@luma.gl/engine": "~9.3.0",
|
|
36
36
|
"@luma.gl/shadertools": "~9.3.0",
|
|
37
|
-
"@cosmos.gl/graph": "^3.
|
|
37
|
+
"@cosmos.gl/graph": "^3.6.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@deck.gl/core": "~9.3.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"vite": "^6.4.3",
|
|
48
48
|
"vite-plugin-dts": "^4.3.0",
|
|
49
|
-
"@cosmos.gl/graph": "^3.
|
|
49
|
+
"@cosmos.gl/graph": "^3.6.0"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "vite build",
|