@kanzo-tech/graph 0.13.0 → 0.14.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.
@@ -1,35 +0,0 @@
1
- import { Graph } from '@cosmos.gl/graph';
2
- /**
3
- * **Every write into cosmos.gl goes through here, because a non-null instance is not a usable one.**
4
- *
5
- * cosmos.gl 3.x builds its device asynchronously. The constructor returns immediately and
6
- * `graphRef.current` is set, but for tens of milliseconds — longer when several graphs mount on one
7
- * page — the instance has no points, no links and no config to change. What happens then is not one
8
- * failure mode but two, and the quiet one is worse:
9
- *
10
- * - `setPointPositions` **throws** `Cannot set properties of undefined (setting 'shouldSkipRescale')`.
11
- * React swallows it into the effect boundary, so it reaches the console and nothing else.
12
- * - `setPointColors`, `setPointSizes`, `setConfigPartial` and `fitViewByPointPositions` **do not**.
13
- * They raise a dirty flag on something that is not there and return, so the picture is simply
14
- * never uploaded: a blank canvas beside a badge reporting a full slice, with `onFailure` silent
15
- * and nothing in the console at all.
16
- *
17
- * Measured on `/docs/graph`, where three graphs mount together and none of them drew a single point.
18
- * Upstream states the contract in its own `.d.ts` for `findPointsInRect` and `findPointsInPolygon`
19
- * — *must only be called when the graph is ready* — and it holds for every setter too.
20
- *
21
- * **The rule is a helper rather than five `await`s** because it was broken at five call sites in
22
- * four modules, which is what `CONVENTIONS.md` means by a rule that has to become a test.
23
- * `when-ready.test.ts` is that test, and it reads the source rather than the behaviour.
24
- *
25
- * **`ready` has no failure path.** When the device cannot be made, cosmos.gl does not reject — the
26
- * promise simply never settles, so `apply` never runs and the canvas stays empty. That is the state
27
- * `hasWebGL()` in `use-renderer.ts` probes for before any of this, and it is why this returns a
28
- * cancel rather than being awaited: nothing here may hold a caller open.
29
- *
30
- * @returns a cancel. Call it from an effect's cleanup — during a pan the slices arrive faster than
31
- * a frame, and every one but the last is superseded before it could have been drawn.
32
- */
33
- export declare function whenReady(graph: Graph, apply: (graph: Graph) => void): () => void;
34
- export declare function isReady(graph: Graph): boolean;
35
- //# sourceMappingURL=when-ready.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when-ready.d.ts","sourceRoot":"","sources":["../../src/render/when-ready.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,MAAM,IAAI,CAQjF;AAeD,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAI7C"}
@@ -1,17 +0,0 @@
1
- function d(e, r) {
2
- let t = !0;
3
- return e.ready.then(() => {
4
- t && r(e);
5
- }), () => {
6
- t = !1;
7
- };
8
- }
9
- const n = /* @__PURE__ */ new WeakSet();
10
- function i(e) {
11
- return n.has(e) ? !0 : (e.ready.then(() => n.add(e)), !1);
12
- }
13
- export {
14
- i as isReady,
15
- d as whenReady
16
- };
17
- //# sourceMappingURL=when-ready.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"when-ready.js","sources":["../../src/render/when-ready.ts"],"sourcesContent":["import type { Graph } from \"@cosmos.gl/graph\";\n\n/**\n * **Every write into cosmos.gl goes through here, because a non-null instance is not a usable one.**\n *\n * cosmos.gl 3.x builds its device asynchronously. The constructor returns immediately and\n * `graphRef.current` is set, but for tens of milliseconds — longer when several graphs mount on one\n * page — the instance has no points, no links and no config to change. What happens then is not one\n * failure mode but two, and the quiet one is worse:\n *\n * - `setPointPositions` **throws** `Cannot set properties of undefined (setting 'shouldSkipRescale')`.\n * React swallows it into the effect boundary, so it reaches the console and nothing else.\n * - `setPointColors`, `setPointSizes`, `setConfigPartial` and `fitViewByPointPositions` **do not**.\n * They raise a dirty flag on something that is not there and return, so the picture is simply\n * never uploaded: a blank canvas beside a badge reporting a full slice, with `onFailure` silent\n * and nothing in the console at all.\n *\n * Measured on `/docs/graph`, where three graphs mount together and none of them drew a single point.\n * Upstream states the contract in its own `.d.ts` for `findPointsInRect` and `findPointsInPolygon`\n * — *must only be called when the graph is ready* — and it holds for every setter too.\n *\n * **The rule is a helper rather than five `await`s** because it was broken at five call sites in\n * four modules, which is what `CONVENTIONS.md` means by a rule that has to become a test.\n * `when-ready.test.ts` is that test, and it reads the source rather than the behaviour.\n *\n * **`ready` has no failure path.** When the device cannot be made, cosmos.gl does not reject — the\n * promise simply never settles, so `apply` never runs and the canvas stays empty. That is the state\n * `hasWebGL()` in `use-renderer.ts` probes for before any of this, and it is why this returns a\n * cancel rather than being awaited: nothing here may hold a caller open.\n *\n * @returns a cancel. Call it from an effect's cleanup — during a pan the slices arrive faster than\n * a frame, and every one but the last is superseded before it could have been drawn.\n */\nexport function whenReady(graph: Graph, apply: (graph: Graph) => void): () => void {\n let live = true;\n void graph.ready.then(() => {\n if (live) apply(graph);\n });\n return () => {\n live = false;\n };\n}\n\n/**\n * Whether this instance's device has arrived, answered **synchronously**.\n *\n * For the two call sites that cannot wait: `findPointsInRect` and `findPointsInPolygon` run inside a\n * pointer handler and have to return a number, and upstream marks exactly those two — and nothing\n * else in its `.d.ts` — *must only be called when the graph is ready*.\n *\n * The flag is kept beside the instance rather than on it, in a `WeakSet`, because the promise is the\n * only thing cosmos.gl exposes and a promise cannot be asked whether it has settled. A graph that is\n * never asked about is never added, which costs one `false` and one hit test that selects nothing.\n */\nconst arrived = new WeakSet<Graph>();\n\nexport function isReady(graph: Graph): boolean {\n if (arrived.has(graph)) return true;\n void graph.ready.then(() => arrived.add(graph));\n return false;\n}\n"],"names":["whenReady","graph","apply","live","arrived","isReady"],"mappings":"AAiCO,SAASA,EAAUC,GAAcC,GAA2C;AACjF,MAAIC,IAAO;AACX,SAAKF,EAAM,MAAM,KAAK,MAAM;AAC1B,IAAIE,OAAYF,CAAK;AAAA,EACvB,CAAC,GACM,MAAM;AACX,IAAAE,IAAO;AAAA,EACT;AACF;AAaA,MAAMC,wBAAc,QAAA;AAEb,SAASC,EAAQJ,GAAuB;AAC7C,SAAIG,EAAQ,IAAIH,CAAK,IAAU,MAC1BA,EAAM,MAAM,KAAK,MAAMG,EAAQ,IAAIH,CAAK,CAAC,GACvC;AACT;"}