@kanzo-tech/graph 0.25.0 → 0.27.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/README.md +2 -2
- package/dist/core/categories.d.ts +1 -1
- package/dist/core/categories.d.ts.map +1 -1
- package/dist/core/categories.js.map +1 -1
- package/dist/core/channels.d.ts +12 -6
- package/dist/core/channels.d.ts.map +1 -1
- package/dist/core/channels.js +15 -12
- package/dist/core/channels.js.map +1 -1
- package/dist/core/client.d.ts +26 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +62 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/error.d.ts +3 -3
- package/dist/core/error.d.ts.map +1 -1
- package/dist/core/error.js.map +1 -1
- package/dist/core/load.d.ts +30 -39
- package/dist/core/load.d.ts.map +1 -1
- package/dist/core/load.js +63 -117
- package/dist/core/load.js.map +1 -1
- package/dist/core/source.d.ts +90 -0
- package/dist/core/source.d.ts.map +1 -0
- package/dist/core/source.js +105 -0
- package/dist/core/source.js.map +1 -0
- package/dist/core/state.d.ts +19 -20
- package/dist/core/state.d.ts.map +1 -1
- package/dist/core/store.d.ts.map +1 -1
- package/dist/core/store.js +138 -158
- package/dist/core/store.js.map +1 -1
- package/dist/core/types.d.ts +5 -3
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -18
- package/dist/index.js.map +1 -1
- package/dist/parts/graph-canvas.d.ts.map +1 -1
- package/dist/parts/graph-canvas.js +49 -48
- package/dist/parts/graph-canvas.js.map +1 -1
- package/dist/parts/graph-counts.js +4 -4
- package/dist/parts/graph-counts.js.map +1 -1
- package/dist/parts/graph-inspector.d.ts +3 -3
- package/dist/parts/graph-inspector.d.ts.map +1 -1
- package/dist/parts/graph-inspector.js +45 -43
- package/dist/parts/graph-inspector.js.map +1 -1
- package/dist/parts/graph-search.d.ts +7 -7
- package/dist/parts/graph-search.d.ts.map +1 -1
- package/dist/parts/graph-search.js +60 -69
- package/dist/parts/graph-search.js.map +1 -1
- package/dist/parts/graph-select.d.ts +27 -0
- package/dist/parts/graph-select.d.ts.map +1 -0
- package/dist/parts/graph-select.js +53 -0
- package/dist/parts/graph-select.js.map +1 -0
- package/dist/parts/graph-toolbar.js +1 -1
- package/dist/parts/graph-toolbar.js.map +1 -1
- package/dist/react/use-graph.js +31 -31
- package/dist/react/use-graph.js.map +1 -1
- package/dist/render/camera.d.ts +12 -1
- package/dist/render/camera.d.ts.map +1 -1
- package/dist/render/camera.js +33 -21
- package/dist/render/camera.js.map +1 -1
- package/dist/render/graph-sim.d.ts +1 -1
- package/dist/render/graph-sim.d.ts.map +1 -1
- package/dist/render/graph-sim.js.map +1 -1
- package/dist/render/motion.d.ts +33 -0
- package/dist/render/motion.d.ts.map +1 -0
- package/dist/render/motion.js +19 -0
- package/dist/render/motion.js.map +1 -0
- package/dist/render/placement.d.ts +2 -4
- package/dist/render/placement.d.ts.map +1 -1
- package/dist/render/placement.js +12 -16
- package/dist/render/placement.js.map +1 -1
- package/dist/render/renderer.d.ts +6 -5
- package/dist/render/renderer.d.ts.map +1 -1
- package/dist/render/renderer.js +130 -118
- package/dist/render/renderer.js.map +1 -1
- package/dist/section.js +1 -1
- package/dist/section.js.map +1 -1
- package/package.json +12 -14
- package/dist/core/detail.d.ts +0 -26
- package/dist/core/detail.d.ts.map +0 -1
- package/dist/core/detail.js +0 -63
- package/dist/core/detail.js.map +0 -1
- package/dist/core/filter.d.ts +0 -23
- package/dist/core/filter.d.ts.map +0 -1
- package/dist/core/filter.js +0 -95
- package/dist/core/filter.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera.js","sources":["../../src/render/camera.ts"],"sourcesContent":["import type { Graph } from \"@cosmos.gl/graph\";\n\nexport const FIT_DURATION = 420;\nconst FIT_PADDING = 0.18;\n/** How often a running layout re-frames the camera, and how long each re-frame glides. */\nconst FOLLOW_EVERY = 900;\nconst FOLLOW_DURATION = 700;\n\nexport interface Camera {\n /** A corpus was placed: frame these corners now, and again whenever the canvas changes size. */\n frame(corners: readonly number[]): void;\n /** The reader asked for the whole graph: frame it, and keep it framed through a resize. */\n fit(): void;\n /** A layout started moving the points: the corners are history, and the camera follows. */\n run(): void;\n tick(): void;\n settle(): void;\n destroy(): void;\n}\n\n/**\n * **Who holds the camera, and when it gives it back.** The camera frames the corpus once it is\n * placed and keeps it framed — through cosmos.gl's device coming up and every resize of the canvas,\n * since a host's split panel settles its width after mount and a frame taken at the old size opens\n * zoomed into a corner — and while a layout runs it follows the moving points and frames them when\n * they settle: Cosmograph's fit-on-settle, kept up. All of it stops the moment the reader zooms or\n * pans, and comes back with Fit or the next run.\n */\nexport function createCamera(graph: Graph
|
|
1
|
+
{"version":3,"file":"camera.js","sources":["../../src/render/camera.ts"],"sourcesContent":["import type { Graph } from \"@cosmos.gl/graph\";\nimport { GraphError } from \"../core/error\";\n\nexport const FIT_DURATION = 420;\nconst FIT_PADDING = 0.18;\n/** How often a running layout re-frames the camera, and how long each re-frame glides. */\nconst FOLLOW_EVERY = 900;\nconst FOLLOW_DURATION = 700;\n\nexport interface Camera {\n /** A corpus was placed: frame these corners now, and again whenever the canvas changes size. */\n frame(corners: readonly number[]): void;\n /** The reader asked for the whole graph: frame it, and keep it framed through a resize. */\n fit(): void;\n /** A layout started moving the points: the corners are history, and the camera follows. */\n run(): void;\n /** cosmos.gl's device came up: the frame is taken again, at the canvas's size. */\n ready(): void;\n /** cosmos.gl was handed positions and rendered them: from now on a fit may read them back. */\n drawn(): void;\n tick(): void;\n settle(): void;\n destroy(): void;\n}\n\n/**\n * **Who holds the camera, and when it gives it back.** The camera frames the corpus once it is\n * placed and keeps it framed — through cosmos.gl's device coming up and every resize of the canvas,\n * since a host's split panel settles its width after mount and a frame taken at the old size opens\n * zoomed into a corner — and while a layout runs it follows the moving points and frames them when\n * they settle: Cosmograph's fit-on-settle, kept up. All of it stops the moment the reader zooms or\n * pans, and comes back with Fit or the next run.\n *\n * **A fit without corners reads the points back from the GPU** (`fitView` → `getPointPositions` →\n * `readPixels` of cosmos.gl's position framebuffer), so it waits until there is one to read: the\n * device is up and a render has uploaded positions. If the read throws anyway, cosmos.gl holds no\n * positions: that is `graph/no-positions`, reported once through `fail`, and the camera reads no more\n * — rather than the same exception on every tick of a layout over a blank canvas.\n */\nexport function createCamera(\n graph: Graph,\n host: HTMLElement,\n fail: (error: GraphError) => void,\n): { camera: Camera; taken: (userDriven: boolean) => void } {\n let corners: readonly number[] | null = null;\n let framing = false;\n let following = false;\n let followed = 0;\n let pending = 0;\n let drawn = false;\n let broken = false;\n let gone = false;\n\n const fitPoints = (duration: number) => {\n if (!drawn || broken || !graph.isReady) return;\n try {\n graph.fitView(duration, FIT_PADDING);\n } catch (error) {\n broken = true;\n following = false;\n fail(new GraphError(\"graph/no-positions\", \"cosmos.gl holds no positions on the GPU to draw or frame.\", {}, { cause: error }));\n }\n };\n const fitNow = (duration: number) => {\n if (corners) graph.fitViewByPointPositions([...corners], duration, FIT_PADDING);\n else fitPoints(duration);\n };\n const reframe = () => {\n pending = 0;\n if (framing && !following) fitNow(0);\n };\n const later = () => {\n if (!pending && !gone) pending = requestAnimationFrame(reframe);\n };\n // After cosmos.gl's own observer has resized the canvas, so the frame is taken at the new size.\n const resizes = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(later);\n resizes?.observe(host);\n\n const camera: Camera = {\n frame(next) {\n corners = next;\n framing = true;\n fitNow(0);\n },\n fit() {\n framing = true;\n fitNow(FIT_DURATION);\n },\n run() {\n corners = null;\n following = true;\n followed = performance.now();\n },\n // A frame later: the commands cosmos.gl queued for its device run in the same turn as this.\n ready: later,\n drawn() {\n drawn = true;\n },\n tick() {\n const now = performance.now();\n if (!following || now - followed < FOLLOW_EVERY) return;\n followed = now;\n fitPoints(FOLLOW_DURATION);\n },\n settle() {\n if (following) fitPoints(FIT_DURATION);\n following = false;\n },\n destroy() {\n gone = true;\n resizes?.disconnect();\n if (pending) cancelAnimationFrame(pending);\n },\n };\n const taken = (userDriven: boolean) => {\n if (!userDriven) return;\n framing = false;\n following = false;\n };\n return { camera, taken };\n}\n"],"names":["FIT_DURATION","FIT_PADDING","FOLLOW_EVERY","FOLLOW_DURATION","createCamera","graph","host","fail","corners","framing","following","followed","pending","drawn","broken","gone","fitPoints","duration","error","GraphError","fitNow","reframe","later","resizes","next","now","userDriven"],"mappings":";AAGO,MAAMA,IAAe,KACtBC,IAAc,MAEdC,IAAe,KACfC,IAAkB;AAgCjB,SAASC,EACdC,GACAC,GACAC,GAC0D;AAC1D,MAAIC,IAAoC,MACpCC,IAAU,IACVC,IAAY,IACZC,IAAW,GACXC,IAAU,GACVC,IAAQ,IACRC,IAAS,IACTC,IAAO;AAEX,QAAMC,IAAY,CAACC,MAAqB;AACtC,QAAI,GAACJ,KAASC,KAAU,CAACT,EAAM;AAC/B,UAAI;AACF,QAAAA,EAAM,QAAQY,GAAUhB,CAAW;AAAA,MACrC,SAASiB,GAAO;AACd,QAAAJ,IAAS,IACTJ,IAAY,IACZH,EAAK,IAAIY,EAAW,sBAAsB,6DAA6D,CAAA,GAAI,EAAE,OAAOD,EAAA,CAAO,CAAC;AAAA,MAC9H;AAAA,EACF,GACME,IAAS,CAACH,MAAqB;AACnC,IAAIT,MAAe,wBAAwB,CAAC,GAAGA,CAAO,GAAGS,GAAUhB,CAAW,MAC/DgB,CAAQ;AAAA,EACzB,GACMI,IAAU,MAAM;AACpB,IAAAT,IAAU,GACNH,KAAW,CAACC,KAAWU,EAAO,CAAC;AAAA,EACrC,GACME,IAAQ,MAAM;AAClB,IAAI,CAACV,KAAW,CAACG,MAAMH,IAAU,sBAAsBS,CAAO;AAAA,EAChE,GAEME,IAAU,OAAO,iBAAmB,MAAc,OAAO,IAAI,eAAeD,CAAK;AACvF,SAAAC,KAAA,QAAAA,EAAS,QAAQjB,IA2CV,EAAE,QAzCc;AAAA,IACrB,MAAMkB,GAAM;AACV,MAAAhB,IAAUgB,GACVf,IAAU,IACVW,EAAO,CAAC;AAAA,IACV;AAAA,IACA,MAAM;AACJ,MAAAX,IAAU,IACVW,EAAOpB,CAAY;AAAA,IACrB;AAAA,IACA,MAAM;AACJ,MAAAQ,IAAU,MACVE,IAAY,IACZC,IAAW,YAAY,IAAA;AAAA,IACzB;AAAA;AAAA,IAEA,OAAOW;AAAA,IACP,QAAQ;AACN,MAAAT,IAAQ;AAAA,IACV;AAAA,IACA,OAAO;AACL,YAAMY,IAAM,YAAY,IAAA;AACxB,MAAI,CAACf,KAAae,IAAMd,IAAWT,MACnCS,IAAWc,GACXT,EAAUb,CAAe;AAAA,IAC3B;AAAA,IACA,SAAS;AACP,MAAIO,OAAqBV,CAAY,GACrCU,IAAY;AAAA,IACd;AAAA,IACA,UAAU;AACR,MAAAK,IAAO,IACPQ,KAAA,QAAAA,EAAS,cACLX,0BAA8BA,CAAO;AAAA,IAC3C;AAAA,EAAA,GAOe,OALH,CAACc,MAAwB;AACrC,IAAKA,MACLjB,IAAU,IACVC,IAAY;AAAA,EACd,EACiB;AACnB;"}
|
|
@@ -17,7 +17,7 @@ export interface Sim {
|
|
|
17
17
|
linkSpring: number;
|
|
18
18
|
linkDistance: number;
|
|
19
19
|
friction: number;
|
|
20
|
-
/** Pull toward the
|
|
20
|
+
/** Pull toward the centre of the vertex's cluster, when a column is bound to `cluster`. Zero lets the links decide alone. */
|
|
21
21
|
cluster: number;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-sim.d.ts","sourceRoot":"","sources":["../../src/render/graph-sim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iEAAiE;AACjE,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,
|
|
1
|
+
{"version":3,"file":"graph-sim.d.ts","sourceRoot":"","sources":["../../src/render/graph-sim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iEAAiE;AACjE,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,6HAA6H;IAC7H,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,MAAM,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAM,GAAG,GAAG,CAatF;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,GAAe,CAAC;AAE1C;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAGpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-sim.js","sources":["../../src/render/graph-sim.ts"],"sourcesContent":["/**\n * The force coefficients, and the one function that builds them from the axes a person chose.\n *\n * `graph-looks.ts`'s sibling, and deliberately its twin: a type the renderer consumes, one builder\n * that reads declared string values, and a default that is the builder called with nothing. What was\n * here before is what was there before — an interface, a `DEFAULT_SIM` table beside it, and a dock\n * that held six of them in React state and drew six sliders by hand.\n *\n * **A coefficient is not appearance, and it is still a preference.** `section.ts` says why it shares\n * the manifest: `tokens` are the colours a document may move, `prefs` are what the person on the\n * screen decides, and somebody tuning a layout until it settles is deciding.\n */\n\n/** Force coefficients, handed straight to the GPU simulation. */\nexport interface Sim {\n gravity: number;\n repulsion: number;\n linkSpring: number;\n linkDistance: number;\n friction: number;\n /** Pull toward the
|
|
1
|
+
{"version":3,"file":"graph-sim.js","sources":["../../src/render/graph-sim.ts"],"sourcesContent":["/**\n * The force coefficients, and the one function that builds them from the axes a person chose.\n *\n * `graph-looks.ts`'s sibling, and deliberately its twin: a type the renderer consumes, one builder\n * that reads declared string values, and a default that is the builder called with nothing. What was\n * here before is what was there before — an interface, a `DEFAULT_SIM` table beside it, and a dock\n * that held six of them in React state and drew six sliders by hand.\n *\n * **A coefficient is not appearance, and it is still a preference.** `section.ts` says why it shares\n * the manifest: `tokens` are the colours a document may move, `prefs` are what the person on the\n * screen decides, and somebody tuning a layout until it settles is deciding.\n */\n\n/** Force coefficients, handed straight to the GPU simulation. */\nexport interface Sim {\n gravity: number;\n repulsion: number;\n linkSpring: number;\n linkDistance: number;\n friction: number;\n /** Pull toward the centre of the vertex's cluster, when a column is bound to `cluster`. Zero lets the links decide alone. */\n cluster: number;\n}\n\n/**\n * Coefficients that settle a few-hundred-node graph into something readable.\n *\n * Chosen against a corpus of that size, and they are a starting point rather than a law: a graph\n * two orders of magnitude larger wants less repulsion and more friction, and the measurements in\n * `/docs/graph/benchmarks` say a live simulation is finished by around 200,000 points regardless. A\n * host that knows its corpus starts its users elsewhere through the tenant policy.\n *\n * The values are strings for the reason `lookFrom`'s are: a contributed preference is a string in\n * all three kinds, so an unrecognised namespace rides through a write untouched. A key that is\n * missing, or that carries a value the section never offered, takes the default below — which is\n * what a graph simulated before any of this existed.\n */\nexport function simFrom(values: Readonly<Record<string, string | undefined>> = {}): Sim {\n const num = (key: string, fallback: number) => {\n const value = Number.parseFloat(values[key] ?? \"\");\n return Number.isFinite(value) ? value : fallback;\n };\n return {\n gravity: num(\"gravity\", 0.14),\n repulsion: num(\"repulsion\", 1.1),\n linkSpring: num(\"link-spring\", 0.6),\n linkDistance: num(\"link-distance\", 18),\n friction: num(\"friction\", 0.86),\n cluster: num(\"cluster\", 0.1),\n };\n}\n\n/**\n * What a canvas simulates with when nobody has chosen anything.\n *\n * **Not on the barrel, and it used to be** — for the reason its twin was: it is `simFrom()`, a\n * second public name for a value already available on request, exported only because `sim` took a\n * whole `Sim` and a host changing `gravity` had to supply the other five.\n */\nexport const DEFAULT_SIM: Sim = simFrom();\n\n/**\n * The coefficients a caller wants different, over the ones this package chose.\n *\n * Flat, so a spread is the whole merge. `undefined` returns the shared constant rather than a copy:\n * the renderer re-heats when the forces change, so a fresh object\n * per render would put energy back into a settled layout on every render.\n */\nexport function resolveSim(patch?: Partial<Sim>): Sim {\n if (!patch) return DEFAULT_SIM;\n return { ...DEFAULT_SIM, ...patch };\n}\n"],"names":["simFrom","values","num","key","fallback","value","DEFAULT_SIM","resolveSim","patch"],"mappings":"AAqCO,SAASA,EAAQC,IAAuD,IAAS;AACtF,QAAMC,IAAM,CAACC,GAAaC,MAAqB;AAC7C,UAAMC,IAAQ,OAAO,WAAWJ,EAAOE,CAAG,KAAK,EAAE;AACjD,WAAO,OAAO,SAASE,CAAK,IAAIA,IAAQD;AAAA,EAC1C;AACA,SAAO;AAAA,IACL,SAASF,EAAI,WAAW,IAAI;AAAA,IAC5B,WAAWA,EAAI,aAAa,GAAG;AAAA,IAC/B,YAAYA,EAAI,eAAe,GAAG;AAAA,IAClC,cAAcA,EAAI,iBAAiB,EAAE;AAAA,IACrC,UAAUA,EAAI,YAAY,IAAI;AAAA,IAC9B,SAASA,EAAI,WAAW,GAAG;AAAA,EAAA;AAE/B;AASO,MAAMI,IAAmBN,EAAA;AASzB,SAASO,EAAWC,GAA2B;AACpD,SAAKA,IACE,EAAE,GAAGF,GAAa,GAAGE,EAAA,IADTF;AAErB;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Geometry } from '../core/load';
|
|
2
|
+
import { GraphOptions } from '../core/state';
|
|
3
|
+
/**
|
|
4
|
+
* **What the renderer decides from the data**, apart from cosmos.gl so it can be read and tested
|
|
5
|
+
* without a GPU: how long a layout cools, when it hides links, whether it runs, and what a filter
|
|
6
|
+
* or a pick leaves in full colour.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* How long a layout cools, in frames: cosmos.gl's alpha reaches its floor after exactly this many.
|
|
10
|
+
* Measured on the gate in `/docs/graph/layout`: the shape is done in one to three seconds at every
|
|
11
|
+
* size, so a layout that runs on is spending frames, not reaching a better picture — 600 settles
|
|
12
|
+
* 200,000 vertices in about ten seconds at sixty frames, and past that 240 does the same at half the
|
|
13
|
+
* frame rate.
|
|
14
|
+
*/
|
|
15
|
+
export declare const decayFor: (size: number) => number;
|
|
16
|
+
/**
|
|
17
|
+
* Past this many links a running layout does not draw them: drawing them is the cost, not the
|
|
18
|
+
* forces — at 800,000 links a layout ticked 14 times a second with them and 51 without (the gate).
|
|
19
|
+
* They come back when it settles.
|
|
20
|
+
*/
|
|
21
|
+
export declare const LINKS_WHILE_RUNNING = 250000;
|
|
22
|
+
/** Whether a layout should run: as `simulate` says, else exactly when the positions are not the data's. */
|
|
23
|
+
export declare const simulating: (options: GraphOptions, geometry: Geometry | null) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* **What is in full colour**, and everything else is greyed out: the vertices the page's filter keeps
|
|
26
|
+
* and — when the reader picked some — that they picked; and the links whose two ends are both. cosmos.gl
|
|
27
|
+
* greys links apart from points, so the links are said out loud.
|
|
28
|
+
*/
|
|
29
|
+
export declare function highlighted(geometry: Geometry, mask: Uint8Array | null, selection: readonly number[] | null): {
|
|
30
|
+
highlightedPointIndices: number[] | undefined;
|
|
31
|
+
highlightedLinkIndices: number[] | undefined;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/render/motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;;;GAIG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,MAAsC,CAAC;AAC/E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAE3C,2GAA2G;AAC3G,eAAO,MAAM,UAAU,GAAI,SAAS,YAAY,EAAE,UAAU,QAAQ,GAAG,IAAI,KAAG,OAClB,CAAC;AAE7D;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,UAAU,GAAG,IAAI,EACvB,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,GAClC;IAAE,uBAAuB,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAAC,sBAAsB,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,CAWjG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const e = (n) => n > 2e5 ? 240 : 600, u = 25e4, c = (n, l) => n.simulate ?? (l !== null && !l.bound);
|
|
2
|
+
function f(n, l, s) {
|
|
3
|
+
if (l === null && s === null) return { highlightedPointIndices: void 0, highlightedLinkIndices: void 0 };
|
|
4
|
+
const t = new Uint8Array(n.size);
|
|
5
|
+
if (s === null) t.set(l);
|
|
6
|
+
else for (const i of s) i < n.size && (l === null || l[i]) && (t[i] = 1);
|
|
7
|
+
const d = [];
|
|
8
|
+
for (let i = 0; i < n.size; i++) t[i] && d.push(i);
|
|
9
|
+
const o = [], { links: h } = n;
|
|
10
|
+
for (let i = 0; i < h.length / 2; i++) t[h[2 * i]] && t[h[2 * i + 1]] && o.push(i);
|
|
11
|
+
return { highlightedPointIndices: d, highlightedLinkIndices: o };
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
u as LINKS_WHILE_RUNNING,
|
|
15
|
+
e as decayFor,
|
|
16
|
+
f as highlighted,
|
|
17
|
+
c as simulating
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.js","sources":["../../src/render/motion.ts"],"sourcesContent":["import type { Geometry } from \"../core/load\";\nimport type { GraphOptions } from \"../core/state\";\n\n/**\n * **What the renderer decides from the data**, apart from cosmos.gl so it can be read and tested\n * without a GPU: how long a layout cools, when it hides links, whether it runs, and what a filter\n * or a pick leaves in full colour.\n */\n\n/**\n * How long a layout cools, in frames: cosmos.gl's alpha reaches its floor after exactly this many.\n * Measured on the gate in `/docs/graph/layout`: the shape is done in one to three seconds at every\n * size, so a layout that runs on is spending frames, not reaching a better picture — 600 settles\n * 200,000 vertices in about ten seconds at sixty frames, and past that 240 does the same at half the\n * frame rate.\n */\nexport const decayFor = (size: number): number => (size > 200_000 ? 240 : 600);\n/**\n * Past this many links a running layout does not draw them: drawing them is the cost, not the\n * forces — at 800,000 links a layout ticked 14 times a second with them and 51 without (the gate).\n * They come back when it settles.\n */\nexport const LINKS_WHILE_RUNNING = 250_000;\n\n/** Whether a layout should run: as `simulate` says, else exactly when the positions are not the data's. */\nexport const simulating = (options: GraphOptions, geometry: Geometry | null): boolean =>\n options.simulate ?? (geometry !== null && !geometry.bound);\n\n/**\n * **What is in full colour**, and everything else is greyed out: the vertices the page's filter keeps\n * and — when the reader picked some — that they picked; and the links whose two ends are both. cosmos.gl\n * greys links apart from points, so the links are said out loud.\n */\nexport function highlighted(\n geometry: Geometry,\n mask: Uint8Array | null,\n selection: readonly number[] | null,\n): { highlightedPointIndices: number[] | undefined; highlightedLinkIndices: number[] | undefined } {\n if (mask === null && selection === null) return { highlightedPointIndices: undefined, highlightedLinkIndices: undefined };\n const on = new Uint8Array(geometry.size);\n if (selection === null) on.set(mask as Uint8Array);\n else for (const id of selection) if (id < geometry.size && (mask === null || mask[id])) on[id] = 1;\n const points: number[] = [];\n for (let id = 0; id < geometry.size; id++) if (on[id]) points.push(id);\n const linkIds: number[] = [];\n const { links } = geometry;\n for (let e = 0; e < links.length / 2; e++) if (on[links[2 * e] as number] && on[links[2 * e + 1] as number]) linkIds.push(e);\n return { highlightedPointIndices: points, highlightedLinkIndices: linkIds };\n}\n"],"names":["decayFor","size","LINKS_WHILE_RUNNING","simulating","options","geometry","highlighted","mask","selection","on","id","points","linkIds","links","e"],"mappings":"AAgBO,MAAMA,IAAW,CAACC,MAA0BA,IAAO,MAAU,MAAM,KAM7DC,IAAsB,MAGtBC,IAAa,CAACC,GAAuBC,MAChDD,EAAQ,aAAaC,MAAa,QAAQ,CAACA,EAAS;AAO/C,SAASC,EACdD,GACAE,GACAC,GACiG;AACjG,MAAID,MAAS,QAAQC,MAAc,aAAa,EAAE,yBAAyB,QAAW,wBAAwB,OAAA;AAC9G,QAAMC,IAAK,IAAI,WAAWJ,EAAS,IAAI;AACvC,MAAIG,MAAc,KAAM,CAAAC,EAAG,IAAIF,CAAkB;AAAA,MAC5C,YAAWG,KAAMF,EAAW,CAAIE,IAAKL,EAAS,SAASE,MAAS,QAAQA,EAAKG,CAAE,OAAID,EAAGC,CAAE,IAAI;AACjG,QAAMC,IAAmB,CAAA;AACzB,WAASD,IAAK,GAAGA,IAAKL,EAAS,MAAMK,IAAM,CAAID,EAAGC,CAAE,KAAGC,EAAO,KAAKD,CAAE;AACrE,QAAME,IAAoB,CAAA,GACpB,EAAE,OAAAC,MAAUR;AAClB,WAASS,IAAI,GAAGA,IAAID,EAAM,SAAS,GAAGC,IAAK,CAAIL,EAAGI,EAAM,IAAIC,CAAC,CAAW,KAAKL,EAAGI,EAAM,IAAIC,IAAI,CAAC,CAAW,KAAGF,EAAQ,KAAKE,CAAC;AAC3H,SAAO,EAAE,yBAAyBH,GAAQ,wBAAwBC,EAAA;AACpE;"}
|
|
@@ -12,11 +12,9 @@ export interface Placement {
|
|
|
12
12
|
readonly dx: number;
|
|
13
13
|
readonly dy: number;
|
|
14
14
|
}
|
|
15
|
-
/** No extent — no row has a position — so nothing moves and nothing is drawn. */
|
|
16
|
-
export declare const UNPLACED: Placement;
|
|
17
15
|
export declare function placementOf(extent: Extent, box: number): Placement;
|
|
18
|
-
/**
|
|
19
|
-
export declare function placed(
|
|
16
|
+
/** Bound positions in the square. A vertex with no value stays `NaN`, which cosmos.gl does not draw. */
|
|
17
|
+
export declare function placed(positions: Float32Array, at: Placement): Float32Array;
|
|
20
18
|
/** The extent's corners in the square, for a camera that frames it. */
|
|
21
19
|
export declare function cornersOf(extent: Extent, at: Placement): number[];
|
|
22
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../src/render/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,
|
|
1
|
+
{"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../src/render/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAKlE;AAED,wGAAwG;AACxG,wBAAgB,MAAM,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,GAAG,YAAY,CAO3E;AAED,uEAAuE;AACvE,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,CAEjE"}
|
package/dist/render/placement.js
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return { side: c, k: n, dx: (c - d.w * n) / 2 - d.x * n, dy: (c - d.h * n) / 2 - d.y * n };
|
|
1
|
+
function l(r, c) {
|
|
2
|
+
const y = Math.max(r.w, r.h, 2), d = y > c ? c / y : 1, k = y * d;
|
|
3
|
+
return { side: k, k: d, dx: (k - r.w * d) / 2 - r.x * d, dy: (k - r.h * d) / 2 - r.y * d };
|
|
5
4
|
}
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
for (let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return c;
|
|
5
|
+
function u(r, c) {
|
|
6
|
+
const y = new Float32Array(r.length);
|
|
7
|
+
for (let d = 0; d < r.length; d += 2)
|
|
8
|
+
y[d] = r[d] * c.k + c.dx, y[d + 1] = r[d + 1] * c.k + c.dy;
|
|
9
|
+
return y;
|
|
13
10
|
}
|
|
14
|
-
function
|
|
15
|
-
return [
|
|
11
|
+
function f(r, c) {
|
|
12
|
+
return [r.x * c.k + c.dx, r.y * c.k + c.dy, (r.x + r.w) * c.k + c.dx, (r.y + r.h) * c.k + c.dy];
|
|
16
13
|
}
|
|
17
14
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
y as placed,
|
|
15
|
+
f as cornersOf,
|
|
16
|
+
u as placed,
|
|
21
17
|
l as placementOf
|
|
22
18
|
};
|
|
23
19
|
//# sourceMappingURL=placement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placement.js","sources":["../../src/render/placement.ts"],"sourcesContent":["import type { Geometry } from \"../core/load\";\n\ntype Extent = NonNullable<Geometry[\"extent\"]>;\n\n/**\n * **Where the corpus's extent sits in cosmos.gl's square** — centred, at its own scale, and scaled\n * down only past the box the device can simulate in. Drawing alone is translation-invariant, but the\n * layout is not: gravity pulls toward the square's centre and many-body bins points on a grid over\n * `[0, side]²`, so an extent left where it was contracts toward a corner and falls off the grid.\n */\nexport interface Placement {\n readonly side: number;\n readonly k: number;\n readonly dx: number;\n readonly dy: number;\n}\n\
|
|
1
|
+
{"version":3,"file":"placement.js","sources":["../../src/render/placement.ts"],"sourcesContent":["import type { Geometry } from \"../core/load\";\n\ntype Extent = NonNullable<Geometry[\"extent\"]>;\n\n/**\n * **Where the corpus's extent sits in cosmos.gl's square** — centred, at its own scale, and scaled\n * down only past the box the device can simulate in. Drawing alone is translation-invariant, but the\n * layout is not: gravity pulls toward the square's centre and many-body bins points on a grid over\n * `[0, side]²`, so an extent left where it was contracts toward a corner and falls off the grid.\n */\nexport interface Placement {\n readonly side: number;\n readonly k: number;\n readonly dx: number;\n readonly dy: number;\n}\n\nexport function placementOf(extent: Extent, box: number): Placement {\n const longest = Math.max(extent.w, extent.h, 2);\n const k = longest > box ? box / longest : 1;\n const side = longest * k;\n return { side, k, dx: (side - extent.w * k) / 2 - extent.x * k, dy: (side - extent.h * k) / 2 - extent.y * k };\n}\n\n/** Bound positions in the square. A vertex with no value stays `NaN`, which cosmos.gl does not draw. */\nexport function placed(positions: Float32Array, at: Placement): Float32Array {\n const out = new Float32Array(positions.length);\n for (let i = 0; i < positions.length; i += 2) {\n out[i] = (positions[i] as number) * at.k + at.dx;\n out[i + 1] = (positions[i + 1] as number) * at.k + at.dy;\n }\n return out;\n}\n\n/** The extent's corners in the square, for a camera that frames it. */\nexport function cornersOf(extent: Extent, at: Placement): number[] {\n return [extent.x * at.k + at.dx, extent.y * at.k + at.dy, (extent.x + extent.w) * at.k + at.dx, (extent.y + extent.h) * at.k + at.dy];\n}\n"],"names":["placementOf","extent","box","longest","k","side","placed","positions","at","out","i","cornersOf"],"mappings":"AAiBO,SAASA,EAAYC,GAAgBC,GAAwB;AAClE,QAAMC,IAAU,KAAK,IAAIF,EAAO,GAAGA,EAAO,GAAG,CAAC,GACxCG,IAAID,IAAUD,IAAMA,IAAMC,IAAU,GACpCE,IAAOF,IAAUC;AACvB,SAAO,EAAE,MAAAC,GAAM,GAAAD,GAAG,KAAKC,IAAOJ,EAAO,IAAIG,KAAK,IAAIH,EAAO,IAAIG,GAAG,KAAKC,IAAOJ,EAAO,IAAIG,KAAK,IAAIH,EAAO,IAAIG,EAAA;AAC7G;AAGO,SAASE,EAAOC,GAAyBC,GAA6B;AAC3E,QAAMC,IAAM,IAAI,aAAaF,EAAU,MAAM;AAC7C,WAASG,IAAI,GAAGA,IAAIH,EAAU,QAAQG,KAAK;AACzC,IAAAD,EAAIC,CAAC,IAAKH,EAAUG,CAAC,IAAeF,EAAG,IAAIA,EAAG,IAC9CC,EAAIC,IAAI,CAAC,IAAKH,EAAUG,IAAI,CAAC,IAAeF,EAAG,IAAIA,EAAG;AAExD,SAAOC;AACT;AAGO,SAASE,EAAUV,GAAgBO,GAAyB;AACjE,SAAO,CAACP,EAAO,IAAIO,EAAG,IAAIA,EAAG,IAAIP,EAAO,IAAIO,EAAG,IAAIA,EAAG,KAAKP,EAAO,IAAIA,EAAO,KAAKO,EAAG,IAAIA,EAAG,KAAKP,EAAO,IAAIA,EAAO,KAAKO,EAAG,IAAIA,EAAG,EAAE;AACtI;"}
|
|
@@ -23,15 +23,16 @@ export interface Renderer extends GraphCommands {
|
|
|
23
23
|
* **cosmos.gl's lifetime, and the frame that renders once.** Built once per element; it subscribes to
|
|
24
24
|
* the store and discharges what changed in one `requestAnimationFrame`:
|
|
25
25
|
*
|
|
26
|
-
* - a new graph uploads positions and links, once per corpus
|
|
27
|
-
* - a binding, a look or a theme change uploads colours, sizes and
|
|
28
|
-
* - a selection, a focus or a pin sets config and uploads nothing, and never calls
|
|
29
|
-
* `render()
|
|
26
|
+
* - a new graph uploads positions and links, once per corpus and per position binding;
|
|
27
|
+
* - a binding, a look or a theme change uploads colours, sizes, shapes and clusters and nothing else;
|
|
28
|
+
* - a filter, a selection, a focus or a pin sets config and uploads nothing, and never calls
|
|
29
|
+
* `render()`: a vertex the page's filter does not keep is greyed out, Cosmograph's way, so the
|
|
30
|
+
* points never move because a chart was brushed;
|
|
30
31
|
* - the camera reaches nothing: cosmos.gl moves it, and the overlays follow.
|
|
31
32
|
*
|
|
32
33
|
* A vertex's id is its index here, so nothing is resolved between the store and the buffers.
|
|
33
34
|
* `transitionDuration` is 0: the default animates every upload for 800 ms and keeps the loop awake.
|
|
34
|
-
* The
|
|
35
|
+
* The layout runs on its own when `x` and `y` are unbound, and from the current positions.
|
|
35
36
|
* Every callback reads the store's latest options, so a host's inline `onFailure` never rebuilds it.
|
|
36
37
|
* A failure to draw at all marks the store `failed` through `unrenderable`, never `onFailure` alone.
|
|
37
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/render/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/render/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,eAAe,CAAC;AASrE,MAAM,WAAW,cAAc;IAC7B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,+FAA+F;IAC/F,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;CACvD;AAED,MAAM,WAAW,QAAS,SAAQ,aAAa;IAC7C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,kFAAkF;IAClF,OAAO,IAAI,IAAI,CAAC;IAChB,uFAAuF;IACvF,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;KAAE,GAAG,MAAM,EAAE,CAAC;IACvG,OAAO,IAAI,IAAI,CAAC;CACjB;AAcD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,GAAE,cAAmB,GAAG,QAAQ,GAAG,IAAI,CAoVpH"}
|
package/dist/render/renderer.js
CHANGED
|
@@ -1,169 +1,181 @@
|
|
|
1
|
-
import { Graph as
|
|
2
|
-
import { GraphError as
|
|
3
|
-
import { resolveLook as
|
|
4
|
-
import { forces as z, appearance as
|
|
5
|
-
import { resolveSim as
|
|
6
|
-
import { createCamera as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { Graph as an } from "@cosmos.gl/graph";
|
|
2
|
+
import { GraphError as L } from "../core/error.js";
|
|
3
|
+
import { resolveLook as Y } from "./graph-looks.js";
|
|
4
|
+
import { forces as z, appearance as J, paint as ln } from "./graph-model.js";
|
|
5
|
+
import { resolveSim as Q } from "./graph-sim.js";
|
|
6
|
+
import { createCamera as sn, FIT_DURATION as un } from "./camera.js";
|
|
7
|
+
import { simulating as F, highlighted as cn, decayFor as fn, LINKS_WHILE_RUNNING as pn } from "./motion.js";
|
|
8
|
+
import { placementOf as dn, cornersOf as mn, placed as gn } from "./placement.js";
|
|
9
|
+
import { webglBox as hn, releaseContext as Sn } from "./webgl.js";
|
|
10
|
+
const T = 0.35, Pn = 1200, X = 20, $ = 1e4;
|
|
11
|
+
function xn(f, i, e = {}) {
|
|
12
|
+
let C = !1;
|
|
13
|
+
const h = (n) => {
|
|
14
|
+
C || i.unrenderable(n);
|
|
15
|
+
}, N = hn();
|
|
16
|
+
if (N === null)
|
|
17
|
+
return h(new L("graph/no-webgl", "This browser offers no WebGL context to draw with.")), null;
|
|
18
|
+
let b = Q(i.getOptions().sim), p = !1, E = !1, O = null, x = null, w = 0, A = -1;
|
|
19
|
+
const _ = (n) => {
|
|
20
|
+
const o = Math.round(n * X);
|
|
21
|
+
o !== A && (A = o, i.reportProgress(o / X));
|
|
21
22
|
};
|
|
22
|
-
let
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
const
|
|
23
|
+
let S = Y(i.getOptions().look), B = i.getOptions().look;
|
|
24
|
+
const a = { positions: !0, paint: !0, state: !0, pinned: !0 };
|
|
25
|
+
let P = 0, d = null, s = i.getSnapshot(), m = i.getOptions();
|
|
26
|
+
const G = () => {
|
|
26
27
|
var n;
|
|
27
|
-
return ((n =
|
|
28
|
+
return ((n = i.getSnapshot().geometry) == null ? void 0 : n.size) ?? 0;
|
|
28
29
|
};
|
|
29
|
-
let
|
|
30
|
+
let t;
|
|
30
31
|
try {
|
|
31
|
-
|
|
32
|
-
// No `spaceSize` here:
|
|
33
|
-
// `rescalePositions: false` because the placement below is ours
|
|
32
|
+
t = new an(f, {
|
|
33
|
+
// No `spaceSize` here: it is the geometry's, set when the graph has loaded.
|
|
34
|
+
// `rescalePositions: false` because the placement below is ours.
|
|
34
35
|
rescalePositions: !1,
|
|
36
|
+
fitViewOnInit: !1,
|
|
35
37
|
transitionDuration: 0,
|
|
36
|
-
enableSimulation:
|
|
37
|
-
...z(
|
|
38
|
-
// Frames to convergence: alpha reaches its floor after exactly this many rendered frames.
|
|
39
|
-
simulationDecay: 400,
|
|
38
|
+
enableSimulation: p,
|
|
39
|
+
...z(b),
|
|
40
40
|
randomSeed: "kanzo-discovery",
|
|
41
41
|
pixelRatio: window.devicePixelRatio || 1,
|
|
42
42
|
enableDrag: !0,
|
|
43
43
|
hoveredPointCursor: "pointer",
|
|
44
44
|
attribution: "",
|
|
45
|
-
onSimulationStart: () =>
|
|
45
|
+
onSimulationStart: () => i.report("running"),
|
|
46
46
|
onSimulationEnd: () => {
|
|
47
47
|
var n;
|
|
48
|
-
|
|
48
|
+
I("settled"), _(1), u.settle(), (n = e.onFrame) == null || n.call(e);
|
|
49
49
|
},
|
|
50
|
-
onSimulationPause: () =>
|
|
51
|
-
onSimulationUnpause: () =>
|
|
52
|
-
onSimulationTick: (n,
|
|
53
|
-
var
|
|
54
|
-
|
|
50
|
+
onSimulationPause: () => I("paused"),
|
|
51
|
+
onSimulationUnpause: () => I("running"),
|
|
52
|
+
onSimulationTick: (n, o, r) => {
|
|
53
|
+
var c, l;
|
|
54
|
+
_(t.progress), u.tick(), o !== void 0 && r && ((c = e.onHover) == null || c.call(e, r)), (l = e.onFrame) == null || l.call(e);
|
|
55
55
|
},
|
|
56
|
-
onZoomStart: (n,
|
|
56
|
+
onZoomStart: (n, o) => v(o),
|
|
57
57
|
onZoom: () => {
|
|
58
58
|
var n;
|
|
59
|
-
return (n =
|
|
59
|
+
return (n = e.onFrame) == null ? void 0 : n.call(e);
|
|
60
60
|
},
|
|
61
|
-
onPointMouseOver: (n,
|
|
62
|
-
var
|
|
63
|
-
|
|
61
|
+
onPointMouseOver: (n, o) => {
|
|
62
|
+
var r;
|
|
63
|
+
O = n, (r = e.onHover) == null || r.call(e, o), i.hover(n);
|
|
64
64
|
},
|
|
65
65
|
onPointMouseOut: () => {
|
|
66
66
|
var n;
|
|
67
|
-
|
|
67
|
+
O = null, (n = e.onHover) == null || n.call(e, null), i.hover(null);
|
|
68
68
|
},
|
|
69
69
|
onDragStart: () => {
|
|
70
|
-
|
|
70
|
+
x = O;
|
|
71
71
|
},
|
|
72
72
|
onDrag: (n) => {
|
|
73
|
-
var
|
|
74
|
-
(
|
|
73
|
+
var o, r;
|
|
74
|
+
(o = e.onHover) == null || o.call(e, t.screenToSpacePosition([n.x, n.y])), (r = e.onFrame) == null || r.call(e);
|
|
75
75
|
},
|
|
76
76
|
// d3-force's drag-to-fix, and only while a layout can move the point back: cosmos.gl moves a
|
|
77
77
|
// dragged point with the simulation off too, and a pin nothing pulls against means nothing.
|
|
78
78
|
onDragEnd: () => {
|
|
79
|
-
const n =
|
|
80
|
-
|
|
81
|
-
const { motion:
|
|
82
|
-
n !== null &&
|
|
79
|
+
const n = x;
|
|
80
|
+
x = null;
|
|
81
|
+
const { motion: o, pinned: r } = i.getSnapshot();
|
|
82
|
+
n !== null && o !== "settled" && !r.includes(n) && i.pin([...r, n]);
|
|
83
83
|
},
|
|
84
|
-
onPointClick: (n) =>
|
|
85
|
-
onBackgroundClick: () =>
|
|
84
|
+
onPointClick: (n) => Z(n),
|
|
85
|
+
onBackgroundClick: () => q()
|
|
86
86
|
});
|
|
87
87
|
} catch (n) {
|
|
88
|
-
return
|
|
88
|
+
return h(new L("graph/no-webgl", "The renderer failed to start.", {}, { cause: n })), null;
|
|
89
89
|
}
|
|
90
|
-
const { camera:
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
const { camera: u, taken: v } = sn(t, f, h), D = () => {
|
|
91
|
+
P || (P = requestAnimationFrame(() => {
|
|
92
|
+
P = 0, nn();
|
|
93
93
|
}));
|
|
94
94
|
};
|
|
95
|
-
function
|
|
96
|
-
var
|
|
97
|
-
const n =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
function nn() {
|
|
96
|
+
var j, K;
|
|
97
|
+
const n = i.getSnapshot(), { geometry: o, encoding: r } = n, c = i.getOptions(), l = a.positions && r ? o : null;
|
|
98
|
+
l && (a.positions = !1, t.setPointPositions(on(l), !0), l.links !== d && (d = l.links, t.setLinks(d), a.paint = a.state = a.pinned = !0));
|
|
99
|
+
const V = a.paint && o && r;
|
|
100
|
+
if (V) {
|
|
101
|
+
a.paint = !1;
|
|
102
|
+
const y = ln(o, r, S, f, c);
|
|
103
|
+
t.setPointColors(y.colors), t.setPointSizes(y.sizes), t.setPointShapes(y.shapes), t.setLinkColors(y.linkColors), t.setPointClusters(r.clusters ?? []), t.setConfigPartial({ ...J(S, f), renderLinks: H() });
|
|
103
104
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
focusedPointIndex: n.focus === null || n.focus >=
|
|
107
|
-
})),
|
|
105
|
+
a.state && o && (a.state = !1, t.setConfigPartial({
|
|
106
|
+
...cn(o, n.mask, ((j = n.selection) == null ? void 0 : j.vertices) ?? null),
|
|
107
|
+
focusedPointIndex: n.focus === null || n.focus >= o.size ? void 0 : n.focus
|
|
108
|
+
})), a.pinned && o && (a.pinned = !1, t.setPinnedPoints(n.pinned.length > 0 ? [...n.pinned] : null)), (V || l) && t.render(), l && tn(l, F(c, l)), o && r && !a.paint && i.reportDrawn(n), (K = e.onFrame) == null || K.call(e);
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
-
|
|
110
|
+
function on(n) {
|
|
111
|
+
const o = n.bound && n.extent ? dn(n.extent, N) : null;
|
|
112
|
+
return t.setConfigPartial({ spaceSize: (o == null ? void 0 : o.side) ?? n.space, simulationDecay: fn(n.size) }), !o || !n.extent ? n.positions : (u.frame(mn(n.extent, o)), gn(n.positions, o));
|
|
111
113
|
}
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
function tn(n, o) {
|
|
115
|
+
if (u.drawn(), o) return k(1);
|
|
116
|
+
p && t.pause(), n.bound || u.fit();
|
|
115
117
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
const H = () => S.link.render && !(E && ((d == null ? void 0 : d.length) ?? 0) / 2 > pn), U = () => t.setConfigPartial({ renderLinks: H() });
|
|
119
|
+
function I(n) {
|
|
120
|
+
E = n === "running", U(), i.report(n);
|
|
118
121
|
}
|
|
119
|
-
function
|
|
120
|
-
|
|
122
|
+
function en(n) {
|
|
123
|
+
const o = Q(n), r = Object.keys(o).some((c) => o[c] !== b[c]);
|
|
124
|
+
b = o, p && (t.setConfigPartial(z(o)), r && i.getSnapshot().motion !== "paused" && t.start(T));
|
|
121
125
|
}
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
e.select([n, ...t], "node", "Node"), e.focus(n);
|
|
126
|
+
function k(n) {
|
|
127
|
+
p || (p = !0, t.setConfigPartial({ enableSimulation: !0, ...z(b) })), u.run(), E = !0, t.start(n), U();
|
|
125
128
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
129
|
+
function g() {
|
|
130
|
+
clearTimeout(w), w = 0;
|
|
128
131
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
132
|
+
function Z(n) {
|
|
133
|
+
const o = t.getNeighboringPointIndices(n) ?? [];
|
|
134
|
+
i.select([n, ...o], "node", "Node"), i.focus(n);
|
|
135
|
+
}
|
|
136
|
+
function q() {
|
|
137
|
+
i.select(null), i.focus(null);
|
|
138
|
+
}
|
|
139
|
+
t.setConfigPartial(J(S, f)), t.render();
|
|
140
|
+
const M = (n) => {
|
|
141
|
+
n.preventDefault(), h(new L("graph/context-lost", "The browser took back the WebGL context; reload to get one."));
|
|
142
|
+
}, W = (n, o) => h(new L("graph/no-webgl", "No GPU device came up to draw with.", n, { cause: o })), R = setTimeout(() => W({ after: $ }), $);
|
|
143
|
+
t.ready.then(
|
|
134
144
|
() => {
|
|
135
145
|
var n;
|
|
136
|
-
clearTimeout(R),
|
|
146
|
+
clearTimeout(R), C || (n = f.querySelector("canvas")) == null || n.addEventListener("webglcontextlost", M), u.ready();
|
|
137
147
|
},
|
|
138
148
|
(n) => {
|
|
139
|
-
clearTimeout(R),
|
|
149
|
+
clearTimeout(R), W({}, n);
|
|
140
150
|
}
|
|
141
|
-
),
|
|
142
|
-
const
|
|
143
|
-
const n =
|
|
144
|
-
|
|
151
|
+
), i.report(p && t.isSimulationRunning ? "running" : "settled"), D();
|
|
152
|
+
const rn = i.subscribe(() => {
|
|
153
|
+
const n = i.getSnapshot(), o = i.getOptions();
|
|
154
|
+
n.geometry !== s.geometry && (a.positions = !0), n.encoding !== s.encoding && (a.paint = !0), o.look !== B && (B = o.look, S = Y(o.look), a.paint = !0), (o.fill !== m.fill || o.symbol !== m.symbol || o.stroke !== m.stroke) && (a.paint = !0), (n.selection !== s.selection || n.focus !== s.focus || n.mask !== s.mask) && (a.state = !0), n.pinned !== s.pinned && (a.pinned = !0), o.sim !== m.sim && en(o.sim);
|
|
155
|
+
const r = F(o, n.geometry);
|
|
156
|
+
n.geometry === s.geometry && r !== F(m, s.geometry) && (g(), r ? k(T) : t.pause()), s = n, m = o, (a.positions || a.paint || a.state || a.pinned) && D();
|
|
145
157
|
});
|
|
146
158
|
return {
|
|
147
|
-
graph:
|
|
159
|
+
graph: t,
|
|
148
160
|
repaint() {
|
|
149
|
-
|
|
161
|
+
a.paint = !0, D();
|
|
150
162
|
},
|
|
151
163
|
hit(n) {
|
|
152
|
-
const
|
|
153
|
-
return Array.from(
|
|
164
|
+
const o = "rect" in n ? t.findPointsInRect(n.rect) : t.findPointsInPolygon(n.polygon);
|
|
165
|
+
return Array.from(o);
|
|
154
166
|
},
|
|
155
167
|
zoomBy(n) {
|
|
156
|
-
|
|
168
|
+
t.setZoomLevel(t.getZoomLevel() * n, 220);
|
|
157
169
|
},
|
|
158
|
-
fit: () =>
|
|
170
|
+
fit: () => u.fit(),
|
|
159
171
|
pause() {
|
|
160
|
-
|
|
172
|
+
g(), t.pause();
|
|
161
173
|
},
|
|
162
174
|
resume() {
|
|
163
|
-
|
|
175
|
+
g(), i.getSnapshot().motion === "settled" || !p ? k(T) : t.unpause();
|
|
164
176
|
},
|
|
165
177
|
restart() {
|
|
166
|
-
|
|
178
|
+
g(), i.pin([]), k(1);
|
|
167
179
|
},
|
|
168
180
|
/**
|
|
169
181
|
* d3's release: unfix, then reheat, so the released points visibly flow back. A running layout
|
|
@@ -171,28 +183,28 @@ function kn(l, e, i = {}) {
|
|
|
171
183
|
* bounded burst and is paused again, because the reader paused it.
|
|
172
184
|
*/
|
|
173
185
|
unpin() {
|
|
174
|
-
const { motion: n, pinned:
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
},
|
|
186
|
+
const { motion: n, pinned: o } = i.getSnapshot();
|
|
187
|
+
o.length !== 0 && (g(), i.pin([]), k(T), n === "paused" && (w = window.setTimeout(() => {
|
|
188
|
+
w = 0, t.pause();
|
|
189
|
+
}, Pn)));
|
|
178
190
|
},
|
|
179
191
|
reveal(n) {
|
|
180
|
-
n >=
|
|
192
|
+
n >= G() || (Z(n), t.zoomToPointByIndex(n, 500, 5, !0));
|
|
181
193
|
},
|
|
182
194
|
frameSelection() {
|
|
183
|
-
var
|
|
184
|
-
const n = (((
|
|
185
|
-
n.length > 0 &&
|
|
195
|
+
var o;
|
|
196
|
+
const n = (((o = i.getSnapshot().selection) == null ? void 0 : o.vertices) ?? []).filter((r) => r < G());
|
|
197
|
+
n.length > 0 && t.fitViewByPointIndices(n, un, 0.25);
|
|
186
198
|
},
|
|
187
|
-
clear:
|
|
199
|
+
clear: q,
|
|
188
200
|
destroy() {
|
|
189
|
-
|
|
190
|
-
const n =
|
|
191
|
-
n == null || n.removeEventListener("webglcontextlost",
|
|
201
|
+
rn(), g(), P && cancelAnimationFrame(P), clearTimeout(R), u.destroy(), C = !0;
|
|
202
|
+
const n = f.querySelector("canvas");
|
|
203
|
+
n == null || n.removeEventListener("webglcontextlost", M), t.destroy(), Sn(n);
|
|
192
204
|
}
|
|
193
205
|
};
|
|
194
206
|
}
|
|
195
207
|
export {
|
|
196
|
-
|
|
208
|
+
xn as createRenderer
|
|
197
209
|
};
|
|
198
210
|
//# sourceMappingURL=renderer.js.map
|