@kanzo-tech/graph 0.14.0 → 0.15.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 +12 -15
- package/dist/core/categories.d.ts +18 -6
- package/dist/core/categories.d.ts.map +1 -1
- package/dist/core/categories.js +41 -10
- package/dist/core/categories.js.map +1 -1
- package/dist/core/channels.d.ts +10 -5
- package/dist/core/channels.d.ts.map +1 -1
- package/dist/core/channels.js +11 -13
- package/dist/core/channels.js.map +1 -1
- package/dist/core/detail.d.ts +14 -8
- package/dist/core/detail.d.ts.map +1 -1
- package/dist/core/detail.js +33 -15
- package/dist/core/detail.js.map +1 -1
- package/dist/core/filter.d.ts +3 -1
- package/dist/core/filter.d.ts.map +1 -1
- package/dist/core/filter.js +54 -50
- package/dist/core/filter.js.map +1 -1
- package/dist/core/load.d.ts +58 -0
- package/dist/core/load.d.ts.map +1 -0
- package/dist/core/load.js +115 -0
- package/dist/core/load.js.map +1 -0
- package/dist/core/state.d.ts +27 -55
- package/dist/core/state.d.ts.map +1 -1
- package/dist/core/store.d.ts +1 -3
- package/dist/core/store.d.ts.map +1 -1
- package/dist/core/store.js +160 -175
- package/dist/core/store.js.map +1 -1
- package/dist/core/types.d.ts +21 -17
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -25
- package/dist/index.js.map +1 -1
- package/dist/parts/gesture.d.ts +1 -10
- package/dist/parts/gesture.d.ts.map +1 -1
- package/dist/parts/gesture.js +28 -28
- package/dist/parts/gesture.js.map +1 -1
- package/dist/parts/graph-canvas.d.ts.map +1 -1
- package/dist/parts/graph-canvas.js +119 -108
- package/dist/parts/graph-canvas.js.map +1 -1
- package/dist/parts/graph-inspector.d.ts +4 -4
- package/dist/parts/graph-inspector.d.ts.map +1 -1
- package/dist/parts/graph-inspector.js +55 -57
- package/dist/parts/graph-inspector.js.map +1 -1
- package/dist/parts/graph-legend.d.ts +4 -4
- package/dist/parts/graph-legend.d.ts.map +1 -1
- package/dist/parts/graph-legend.js +21 -21
- package/dist/parts/graph-legend.js.map +1 -1
- package/dist/parts/overlays.d.ts +2 -4
- package/dist/parts/overlays.d.ts.map +1 -1
- package/dist/parts/overlays.js +45 -45
- package/dist/parts/overlays.js.map +1 -1
- package/dist/react/use-graph-state.d.ts +4 -2
- package/dist/react/use-graph-state.d.ts.map +1 -1
- package/dist/react/use-graph-state.js +10 -6
- package/dist/react/use-graph-state.js.map +1 -1
- package/dist/react/use-graph.d.ts +1 -4
- package/dist/react/use-graph.d.ts.map +1 -1
- package/dist/react/use-graph.js +38 -49
- package/dist/react/use-graph.js.map +1 -1
- package/dist/render/graph-looks.d.ts.map +1 -1
- package/dist/render/graph-looks.js.map +1 -1
- package/dist/render/graph-model.d.ts +6 -8
- package/dist/render/graph-model.d.ts.map +1 -1
- package/dist/render/graph-model.js +51 -57
- package/dist/render/graph-model.js.map +1 -1
- package/dist/render/graph-sim.d.ts +2 -3
- package/dist/render/graph-sim.d.ts.map +1 -1
- package/dist/render/graph-sim.js.map +1 -1
- package/dist/render/renderer.d.ts +6 -11
- package/dist/render/renderer.d.ts.map +1 -1
- package/dist/render/renderer.js +120 -173
- package/dist/render/renderer.js.map +1 -1
- package/dist/section.d.ts.map +1 -1
- package/dist/section.js +3 -7
- package/dist/section.js.map +1 -1
- package/package.json +11 -11
- package/dist/core/refine.d.ts +0 -14
- package/dist/core/refine.d.ts.map +0 -1
- package/dist/core/refine.js +0 -20
- package/dist/core/refine.js.map +0 -1
- package/dist/core/resident.d.ts +0 -79
- package/dist/core/resident.d.ts.map +0 -1
- package/dist/core/resident.js +0 -44
- package/dist/core/resident.js.map +0 -1
- package/dist/core/scheduler.d.ts +0 -42
- package/dist/core/scheduler.d.ts.map +0 -1
- package/dist/core/scheduler.js +0 -77
- package/dist/core/scheduler.js.map +0 -1
- package/dist/core/tile-matrix.d.ts +0 -37
- package/dist/core/tile-matrix.d.ts.map +0 -1
- package/dist/core/tile-matrix.js +0 -49
- package/dist/core/tile-matrix.js.map +0 -1
- package/dist/core/tile.d.ts +0 -54
- package/dist/core/tile.d.ts.map +0 -1
- package/dist/core/tile.js +0 -76
- package/dist/core/tile.js.map +0 -1
- package/dist/core/tileset.d.ts +0 -59
- package/dist/core/tileset.d.ts.map +0 -1
- package/dist/core/tileset.js +0 -177
- package/dist/core/tileset.js.map +0 -1
- package/dist/render/adaptive.d.ts +0 -27
- package/dist/render/adaptive.d.ts.map +0 -1
- package/dist/render/adaptive.js +0 -25
- package/dist/render/adaptive.js.map +0 -1
- package/dist/render/compose.d.ts +0 -51
- package/dist/render/compose.d.ts.map +0 -1
- package/dist/render/compose.js +0 -107
- package/dist/render/compose.js.map +0 -1
- package/dist/render/encode.d.ts +0 -42
- package/dist/render/encode.d.ts.map +0 -1
- package/dist/render/encode.js +0 -68
- package/dist/render/encode.js.map +0 -1
package/dist/render/compose.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { TileMatrixSet } from '@fossil-lang/corpus';
|
|
2
|
-
import { Binding } from '../core/channels';
|
|
3
|
-
import { Resident } from '../core/resident';
|
|
4
|
-
import { TileView } from '../core/store';
|
|
5
|
-
/** An edge shorter than this many screen pixels is a dot on its own ends, and is not composed. */
|
|
6
|
-
export declare const MIN_LINK_PIXELS = 3;
|
|
7
|
-
/** One buffer set for one cosmos.gl instance. */
|
|
8
|
-
export interface Composition {
|
|
9
|
-
/** `[x, y, …]`: vertices first, then cells, then far ends drawn only so an edge has one. */
|
|
10
|
-
readonly positions: Float32Array;
|
|
11
|
-
/** `[src, dst, …]` as indices into `positions`. */
|
|
12
|
-
readonly links: Float32Array;
|
|
13
|
-
/** How many edges each link stands for; `null` when every link is one edge. */
|
|
14
|
-
readonly weights: Float32Array | null;
|
|
15
|
-
/** Slots that are drawn — vertices and cells. Past it, far ends. */
|
|
16
|
-
readonly marks: number;
|
|
17
|
-
/** How many of the marks are vertices; cells follow them. */
|
|
18
|
-
readonly vertices: number;
|
|
19
|
-
readonly resident: Resident;
|
|
20
|
-
/** Per slot: the category's rank, or `0` when nothing is bound. */
|
|
21
|
-
readonly categories: Uint32Array;
|
|
22
|
-
/** Per slot: the ramp's raw value, or `null` when nothing is bound. */
|
|
23
|
-
readonly sizes: Float32Array | null;
|
|
24
|
-
/** Per vertex slot: its title, when `title` is bound. */
|
|
25
|
-
readonly titles: readonly string[] | null;
|
|
26
|
-
/** What each rank is, for a legend: the seed, then the other values seen, in rank order. */
|
|
27
|
-
readonly domain: readonly unknown[];
|
|
28
|
-
/** Per rank, the vertices the marks of that rank stand for. */
|
|
29
|
-
readonly tally: readonly number[];
|
|
30
|
-
/** Vertices the marks stand for — a cell counts its members. */
|
|
31
|
-
readonly represented: number;
|
|
32
|
-
}
|
|
33
|
-
export interface ComposeInput {
|
|
34
|
-
readonly matrix: TileMatrixSet;
|
|
35
|
-
readonly typeIndex: number;
|
|
36
|
-
readonly binding: Binding;
|
|
37
|
-
readonly modeColumn: string | null;
|
|
38
|
-
/** The categorical domain fixed before any tile: it ranks first, in its own order. */
|
|
39
|
-
readonly domain: readonly unknown[];
|
|
40
|
-
readonly visible: readonly TileView[];
|
|
41
|
-
readonly cached: readonly TileView[];
|
|
42
|
-
/** Graph units per screen pixel when composed, for the stub discard. */
|
|
43
|
-
readonly perPixel: number;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* **Visible tiles → one buffer set.** cosmos.gl replaces a whole buffer per setter, so what changed
|
|
47
|
-
* is decided at the granularity it offers: the set of tiles. The same visible set under the same
|
|
48
|
-
* binding composes to `null` — nothing new, and nothing to upload.
|
|
49
|
-
*/
|
|
50
|
-
export declare function createComposer(): (input: ComposeInput) => Composition | null;
|
|
51
|
-
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/render/compose.ts"],"names":[],"mappings":"AAAA,OA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AO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,sFAAsF;IACtF,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;IACrC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,CAAC,KAAK,EAAE,YAAY,KAAK,WAAW,GAAG,IAAI,CA+B5E"}
|
package/dist/render/compose.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { vertexId as X, residentOf as Z } from "../core/resident.js";
|
|
2
|
-
import { Dictionary as S, encode as q } from "./encode.js";
|
|
3
|
-
const G = 3;
|
|
4
|
-
function ee() {
|
|
5
|
-
let i = "", a = new S(), h = [], y = /* @__PURE__ */ new WeakMap(), m = "";
|
|
6
|
-
const w = (n, s) => {
|
|
7
|
-
let l = y.get(n.content);
|
|
8
|
-
return l || (l = q(n, s.binding, a, s.modeColumn), y.set(n.content, l)), l;
|
|
9
|
-
};
|
|
10
|
-
return (n) => {
|
|
11
|
-
const s = `${n.binding.category}|${n.binding.size}|${n.binding.title}|${n.modeColumn}`;
|
|
12
|
-
(s !== i || n.domain !== h) && (i = s, h = n.domain, a = new S(h), y = /* @__PURE__ */ new WeakMap(), m = "");
|
|
13
|
-
const l = n.visible.map((u) => J(u.content)).join(",");
|
|
14
|
-
if (l === m) return null;
|
|
15
|
-
m = l;
|
|
16
|
-
const p = n.visible.map((u) => ({ view: u, encoded: w(u, n) }));
|
|
17
|
-
return Q(n, p, a, w);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const U = /* @__PURE__ */ new WeakMap();
|
|
21
|
-
let H = 1;
|
|
22
|
-
function J(i) {
|
|
23
|
-
let a = U.get(i);
|
|
24
|
-
return a === void 0 && U.set(i, a = H++), a;
|
|
25
|
-
}
|
|
26
|
-
function Q(i, a, h, y) {
|
|
27
|
-
var B, P;
|
|
28
|
-
const m = [...a].sort((e, t) => Number(e.encoded.cells) - Number(t.encoded.cells));
|
|
29
|
-
let w = 0, n = 0;
|
|
30
|
-
for (const { encoded: e } of m)
|
|
31
|
-
w += e.n, e.cells || (n += e.n);
|
|
32
|
-
const s = [], l = [], p = [], u = [], x = [], A = new BigUint64Array(n), $ = /* @__PURE__ */ new Map(), I = (e) => {
|
|
33
|
-
let t = $.get(e);
|
|
34
|
-
return t || $.set(e, t = /* @__PURE__ */ new Map()), t;
|
|
35
|
-
}, z = (e, t, o) => {
|
|
36
|
-
var c, d;
|
|
37
|
-
const r = s.length / 2;
|
|
38
|
-
return s.push(t.positions[o * 2], t.positions[o * 2 + 1]), l.push(((c = t.codes) == null ? void 0 : c[o]) ?? 0), p.push(((d = t.sizes) == null ? void 0 : d[o]) ?? 0), I(e).set(t.keys[o], r), r;
|
|
39
|
-
};
|
|
40
|
-
let F = 0;
|
|
41
|
-
for (const { encoded: e, view: t } of m)
|
|
42
|
-
for (let o = 0; o < e.n; o++) {
|
|
43
|
-
const r = z(t.address.z, e, o), c = e.counts[o] ?? 0;
|
|
44
|
-
x[r] = c, F += c, e.cells || (A[r] = X(i.typeIndex, e.keys[o]), u.push(((B = e.titles) == null ? void 0 : B[o]) ?? ""));
|
|
45
|
-
}
|
|
46
|
-
const v = /* @__PURE__ */ new Map();
|
|
47
|
-
for (const e of i.cached) {
|
|
48
|
-
let t = v.get(e.address.z);
|
|
49
|
-
t || v.set(e.address.z, t = /* @__PURE__ */ new Map()), t.set(e.address.tile, e);
|
|
50
|
-
}
|
|
51
|
-
const N = (e, t) => {
|
|
52
|
-
var k, g;
|
|
53
|
-
const o = I(e).get(t);
|
|
54
|
-
if (o !== void 0) return o;
|
|
55
|
-
const r = ((k = i.matrix.tileMatrices[e]) == null ? void 0 : k.tileRows) ?? 1, c = (g = v.get(e)) == null ? void 0 : g.get(Math.floor(t / r));
|
|
56
|
-
if (!c) return;
|
|
57
|
-
const d = y(c, i);
|
|
58
|
-
for (let f = 0; f < d.n; f++) if (d.keys[f] === t) return z(e, d, f);
|
|
59
|
-
}, _ = G * i.perPixel, C = [], E = [], K = /* @__PURE__ */ new Set();
|
|
60
|
-
let L = !1;
|
|
61
|
-
for (const { encoded: e, view: t } of m) {
|
|
62
|
-
const { z: o } = t.address;
|
|
63
|
-
for (let r = 0; r < e.links.length / 2; r++) {
|
|
64
|
-
const c = e.links[r * 2], d = e.links[r * 2 + 1];
|
|
65
|
-
if (c === d) continue;
|
|
66
|
-
const k = `${o}:${c}:${d}`;
|
|
67
|
-
if (K.has(k)) continue;
|
|
68
|
-
const g = N(o, c), f = N(o, d);
|
|
69
|
-
if (g === void 0 || f === void 0) continue;
|
|
70
|
-
K.add(k);
|
|
71
|
-
const D = s[g * 2] - s[f * 2], R = s[g * 2 + 1] - s[f * 2 + 1];
|
|
72
|
-
if (Math.hypot(D, R) < _) continue;
|
|
73
|
-
C.push(g, f);
|
|
74
|
-
const T = ((P = e.weights) == null ? void 0 : P[r]) ?? 1;
|
|
75
|
-
e.weights && (L = !0), E.push(T);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const O = h.ranks(), W = Uint32Array.from(l, (e) => O[e] ?? 0), b = [];
|
|
79
|
-
O.forEach((e, t) => {
|
|
80
|
-
b[e] = h.values[t];
|
|
81
|
-
});
|
|
82
|
-
const M = b.map(() => 0);
|
|
83
|
-
for (let e = 0; e < w; e++) {
|
|
84
|
-
const t = W[e] ?? 0;
|
|
85
|
-
M[t] = (M[t] ?? 0) + (x[e] ?? 0);
|
|
86
|
-
}
|
|
87
|
-
const j = m.some(({ encoded: e }) => e.sizes !== null);
|
|
88
|
-
return {
|
|
89
|
-
positions: Float32Array.from(s),
|
|
90
|
-
links: Float32Array.from(C),
|
|
91
|
-
weights: L ? Float32Array.from(E) : null,
|
|
92
|
-
marks: w,
|
|
93
|
-
vertices: n,
|
|
94
|
-
resident: Z(A, n),
|
|
95
|
-
categories: W,
|
|
96
|
-
sizes: j ? Float32Array.from(p) : null,
|
|
97
|
-
titles: i.binding.title === void 0 ? null : u,
|
|
98
|
-
domain: b,
|
|
99
|
-
tally: M,
|
|
100
|
-
represented: F
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
export {
|
|
104
|
-
G as MIN_LINK_PIXELS,
|
|
105
|
-
ee as createComposer
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=compose.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sources":["../../src/render/compose.ts"],"sourcesContent":["import type { TileMatrixSet } from \"@fossil-lang/corpus\";\nimport type { Binding } from \"../core/channels\";\nimport { residentOf, vertexId, type Resident } from \"../core/resident\";\nimport type { TileContent } from \"../core/tile\";\nimport type { TileView } from \"../core/store\";\nimport { Dictionary, encode, type Encoded } from \"./encode\";\n\n/** An edge shorter than this many screen pixels is a dot on its own ends, and is not composed. */\nexport const MIN_LINK_PIXELS = 3;\n\n/** One buffer set for one cosmos.gl instance. */\nexport interface Composition {\n /** `[x, y, …]`: vertices first, then cells, then far ends drawn only so an edge has one. */\n readonly positions: Float32Array;\n /** `[src, dst, …]` as indices into `positions`. */\n readonly links: Float32Array;\n /** How many edges each link stands for; `null` when every link is one edge. */\n readonly weights: Float32Array | null;\n /** Slots that are drawn — vertices and cells. Past it, far ends. */\n readonly marks: number;\n /** How many of the marks are vertices; cells follow them. */\n readonly vertices: number;\n readonly resident: Resident;\n /** Per slot: the category's rank, or `0` when nothing is bound. */\n readonly categories: Uint32Array;\n /** Per slot: the ramp's raw value, or `null` when nothing is bound. */\n readonly sizes: Float32Array | null;\n /** Per vertex slot: its title, when `title` is bound. */\n readonly titles: readonly string[] | null;\n /** What each rank is, for a legend: the seed, then the other values seen, in rank order. */\n readonly domain: readonly unknown[];\n /** Per rank, the vertices the marks of that rank stand for. */\n readonly tally: readonly number[];\n /** Vertices the marks stand for — a cell counts its members. */\n readonly represented: number;\n}\n\nexport interface ComposeInput {\n readonly matrix: TileMatrixSet;\n readonly typeIndex: number;\n readonly binding: Binding;\n readonly modeColumn: string | null;\n /** The categorical domain fixed before any tile: it ranks first, in its own order. */\n readonly domain: readonly unknown[];\n readonly visible: readonly TileView[];\n readonly cached: readonly TileView[];\n /** Graph units per screen pixel when composed, for the stub discard. */\n readonly perPixel: number;\n}\n\n/**\n * **Visible tiles → one buffer set.** cosmos.gl replaces a whole buffer per setter, so what changed\n * is decided at the granularity it offers: the set of tiles. The same visible set under the same\n * binding composes to `null` — nothing new, and nothing to upload.\n */\nexport function createComposer(): (input: ComposeInput) => Composition | null {\n let bindingKey = \"\";\n let dictionary = new Dictionary();\n let seed: readonly unknown[] = [];\n let encoded = new WeakMap<TileContent, Encoded>();\n let setKey = \"\";\n\n const encodedOf = (view: TileView, input: ComposeInput): Encoded => {\n let found = encoded.get(view.content);\n if (!found) {\n found = encode(view, input.binding, dictionary, input.modeColumn);\n encoded.set(view.content, found);\n }\n return found;\n };\n\n return (input) => {\n const key = `${input.binding.category}|${input.binding.size}|${input.binding.title}|${input.modeColumn}`;\n if (key !== bindingKey || input.domain !== seed) {\n bindingKey = key;\n seed = input.domain;\n dictionary = new Dictionary(seed);\n encoded = new WeakMap();\n setKey = \"\";\n }\n const next = input.visible.map((view) => idOf(view.content)).join(\",\");\n if (next === setKey) return null;\n setKey = next;\n const tiles = input.visible.map((view) => ({ view, encoded: encodedOf(view, input) }));\n return assemble(input, tiles, dictionary, encodedOf);\n };\n}\n\nconst ids = new WeakMap<object, number>();\nlet nextId = 1;\nfunction idOf(content: object): number {\n let id = ids.get(content);\n if (id === undefined) ids.set(content, (id = nextId++));\n return id;\n}\n\nfunction assemble(\n input: ComposeInput,\n tiles: readonly { view: TileView; encoded: Encoded }[],\n dictionary: Dictionary,\n encodedOf: (view: TileView, input: ComposeInput) => Encoded,\n): Composition {\n const ordered = [...tiles].sort((a, b) => Number(a.encoded.cells) - Number(b.encoded.cells));\n let marks = 0;\n let vertexMarks = 0;\n for (const { encoded } of ordered) {\n marks += encoded.n;\n if (!encoded.cells) vertexMarks += encoded.n;\n }\n\n const xy: number[] = [];\n const codes: number[] = [];\n const ramp: number[] = [];\n const titles: string[] = [];\n const counts: number[] = [];\n const vertices = new BigUint64Array(vertexMarks);\n const slot = new Map<number, Map<number, number>>();\n const slotsAt = (z: number) => {\n let found = slot.get(z);\n if (!found) slot.set(z, (found = new Map()));\n return found;\n };\n const place = (z: number, encoded: Encoded, i: number) => {\n const at = xy.length / 2;\n xy.push(encoded.positions[i * 2] as number, encoded.positions[i * 2 + 1] as number);\n codes.push(encoded.codes?.[i] ?? 0);\n ramp.push(encoded.sizes?.[i] ?? 0);\n slotsAt(z).set(encoded.keys[i] as number, at);\n return at;\n };\n\n let represented = 0;\n for (const { encoded, view } of ordered) {\n for (let i = 0; i < encoded.n; i++) {\n const at = place(view.address.z, encoded, i);\n const count = encoded.counts[i] ?? 0;\n counts[at] = count;\n represented += count;\n if (!encoded.cells) {\n vertices[at] = vertexId(input.typeIndex, encoded.keys[i] as number);\n titles.push(encoded.titles?.[i] ?? \"\");\n }\n }\n }\n\n const cachedByZ = new Map<number, Map<number, TileView>>();\n for (const view of input.cached) {\n let byTile = cachedByZ.get(view.address.z);\n if (!byTile) cachedByZ.set(view.address.z, (byTile = new Map()));\n byTile.set(view.address.tile, view);\n }\n /** A far end: in the cache or not at all — never a read of its tile. */\n const farEnd = (z: number, key: number): number | undefined => {\n const known = slotsAt(z).get(key);\n if (known !== undefined) return known;\n const rows = input.matrix.tileMatrices[z]?.tileRows ?? 1;\n const view = cachedByZ.get(z)?.get(Math.floor(key / rows));\n if (!view) return undefined;\n const encoded = encodedOf(view, input);\n for (let i = 0; i < encoded.n; i++) if (encoded.keys[i] === key) return place(z, encoded, i);\n return undefined;\n };\n\n const minLength = MIN_LINK_PIXELS * input.perPixel;\n const links: number[] = [];\n const weights: number[] = [];\n const seen = new Set<string>();\n let weighted = false;\n for (const { encoded, view } of ordered) {\n const { z } = view.address;\n for (let e = 0; e < encoded.links.length / 2; e++) {\n const from = encoded.links[e * 2] as number;\n const to = encoded.links[e * 2 + 1] as number;\n if (from === to) continue;\n const pair = `${z}:${from}:${to}`;\n if (seen.has(pair)) continue;\n const a = farEnd(z, from);\n const b = farEnd(z, to);\n if (a === undefined || b === undefined) continue;\n seen.add(pair);\n const dx = (xy[a * 2] as number) - (xy[b * 2] as number);\n const dy = (xy[a * 2 + 1] as number) - (xy[b * 2 + 1] as number);\n if (Math.hypot(dx, dy) < minLength) continue;\n links.push(a, b);\n const weight = encoded.weights?.[e] ?? 1;\n if (encoded.weights) weighted = true;\n weights.push(weight);\n }\n }\n\n const ranks = dictionary.ranks();\n const categories = Uint32Array.from(codes, (code) => ranks[code] ?? 0);\n const domain: unknown[] = [];\n ranks.forEach((rank, code) => {\n domain[rank] = dictionary.values[code];\n });\n const tally = domain.map(() => 0);\n for (let i = 0; i < marks; i++) {\n const rank = categories[i] ?? 0;\n tally[rank] = (tally[rank] ?? 0) + (counts[i] ?? 0);\n }\n const bound = ordered.some(({ encoded }) => encoded.sizes !== null);\n\n return {\n positions: Float32Array.from(xy),\n links: Float32Array.from(links),\n weights: weighted ? Float32Array.from(weights) : null,\n marks,\n vertices: vertexMarks,\n resident: residentOf(vertices, vertexMarks),\n categories,\n sizes: bound ? Float32Array.from(ramp) : null,\n titles: input.binding.title === undefined ? null : titles,\n domain,\n tally,\n represented,\n };\n}\n"],"names":["MIN_LINK_PIXELS","createComposer","bindingKey","dictionary","Dictionary","seed","encoded","setKey","encodedOf","view","input","found","encode","key","next","idOf","tiles","assemble","ids","nextId","content","id","ordered","a","b","marks","vertexMarks","xy","codes","ramp","titles","counts","vertices","slot","slotsAt","z","place","i","at","_a","_b","represented","count","vertexId","cachedByZ","byTile","farEnd","known","rows","minLength","links","weights","seen","weighted","e","from","to","pair","dx","dy","weight","ranks","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CAAI,KAAKC,EAAMD,CAAI,KAAK,MAAMlC,EAAOM,CAAC,KAAK;AAAA,EACnD;AACA,QAAM8B,IAAQ7C,EAAQ,KAAK,CAAC,EAAE,SAAAhB,QAAcA,EAAQ,UAAU,IAAI;AAElE,SAAO;AAAA,IACL,WAAW,aAAa,KAAKqB,CAAE;AAAA,IAC/B,OAAO,aAAa,KAAKuB,CAAK;AAAA,IAC9B,SAASG,IAAW,aAAa,KAAKF,CAAO,IAAI;AAAA,IACjD,OAAA1B;AAAA,IACA,UAAUC;AAAA,IACV,UAAU0C,EAAWpC,GAAUN,CAAW;AAAA,IAC1C,YAAAoC;AAAA,IACA,OAAOK,IAAQ,aAAa,KAAKtC,CAAI,IAAI;AAAA,IACzC,QAAQnB,EAAM,QAAQ,UAAU,SAAY,OAAOoB;AAAA,IACnD,QAAAkC;AAAA,IACA,OAAAE;AAAA,IACA,aAAAzB;AAAA,EAAA;AAEJ;"}
|
package/dist/render/encode.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Binding } from '../core/channels';
|
|
2
|
-
import { TileView } from '../core/store';
|
|
3
|
-
/**
|
|
4
|
-
* Values to codes, in the order first seen — stable for the life of a binding. **The seed ranks
|
|
5
|
-
* first, in its own order**: the manifest's ordinals or the host's named values, so a colour is
|
|
6
|
-
* decided before a tile arrives. Only a value outside it is ranked by value, after the seed.
|
|
7
|
-
*/
|
|
8
|
-
export declare class Dictionary {
|
|
9
|
-
#private;
|
|
10
|
-
readonly values: unknown[];
|
|
11
|
-
constructor(seed?: readonly unknown[]);
|
|
12
|
-
code(value: unknown): number;
|
|
13
|
-
/** Each code's rank: the seed's own order, then every other value seen, numbers before strings. */
|
|
14
|
-
ranks(): Uint32Array;
|
|
15
|
-
}
|
|
16
|
-
/** One tile's rows and edges as the arrays a composition concatenates. */
|
|
17
|
-
export interface Encoded {
|
|
18
|
-
readonly n: number;
|
|
19
|
-
readonly cells: boolean;
|
|
20
|
-
/** `[x0, y0, x1, y1, …]`. */
|
|
21
|
-
readonly positions: Float32Array;
|
|
22
|
-
/** `dense_id` at the payload, `cell_id` on a rung — what an edge's ends name. */
|
|
23
|
-
readonly keys: Float64Array;
|
|
24
|
-
/** Dictionary codes of the categorical column, or `null` when nothing is bound. */
|
|
25
|
-
readonly codes: Uint32Array | null;
|
|
26
|
-
/** The ramp: `r`'s column at the payload, a cell's `count` on a rung. */
|
|
27
|
-
readonly sizes: Float32Array | null;
|
|
28
|
-
/** Vertices each row stands for: one at the payload, a cell's `count` on a rung. */
|
|
29
|
-
readonly counts: Float64Array;
|
|
30
|
-
readonly titles: readonly string[] | null;
|
|
31
|
-
/** `[src, dst, …]` in `keys`' space, every relation read from this tile, both directions. */
|
|
32
|
-
readonly links: Float64Array;
|
|
33
|
-
/** How many edges each link stands for: one at the payload, the quotient's `weight` on a rung. */
|
|
34
|
-
readonly weights: Float32Array | null;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* **A tile is encoded once per binding**: the arrays are made when it arrives, and a composition is a
|
|
38
|
-
* concatenation of arrays already made. A cell summarises one channel, so its colour is `mode` when
|
|
39
|
-
* `fill` binds the column the tree's mode is of, its size can only be `count`, and it has no title.
|
|
40
|
-
*/
|
|
41
|
-
export declare function encode(view: TileView, binding: Binding, dictionary: Dictionary, modeColumn: string | null): Encoded;
|
|
42
|
-
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/render/encode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAY9C;;;;GAIG;AACH,qBAAa,UAAU;;IACrB,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAM;gBAIpB,IAAI,GAAE,SAAS,OAAO,EAAO;IAKzC,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;IAW5B,mGAAmG;IACnG,KAAK,IAAI,WAAW;CAUrB;AASD,0EAA0E;AAC1E,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,6BAA6B;IAC7B,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,mFAAmF;IACnF,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1C,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,kGAAkG;IAClG,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;CACvC;AAQD;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,OAAO,CA2CT"}
|
package/dist/render/encode.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var q = Object.defineProperty;
|
|
2
|
-
var M = (e) => {
|
|
3
|
-
throw TypeError(e);
|
|
4
|
-
};
|
|
5
|
-
var x = (e, t, o) => t in e ? q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
6
|
-
var P = (e, t, o) => x(e, typeof t != "symbol" ? t + "" : t, o), T = (e, t, o) => t.has(e) || M("Cannot " + o);
|
|
7
|
-
var u = (e, t, o) => (T(e, t, "read from private field"), o ? o.call(e) : t.get(e)), C = (e, t, o) => t.has(e) ? M("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, o), U = (e, t, o, r) => (T(e, t, "write to private field"), r ? r.call(e, o) : t.set(e, o), o);
|
|
8
|
-
import { PAYLOAD_COORDINATES as B, PAYLOAD_ADDRESS as G } from "@fossil-lang/corpus";
|
|
9
|
-
const H = "cell_id", J = "count", Q = "mode", V = G[0], [W, Z] = B;
|
|
10
|
-
var f, l;
|
|
11
|
-
class ot {
|
|
12
|
-
constructor(t = []) {
|
|
13
|
-
P(this, "values", []);
|
|
14
|
-
C(this, f, /* @__PURE__ */ new Map());
|
|
15
|
-
C(this, l);
|
|
16
|
-
for (const o of t) this.code(o);
|
|
17
|
-
U(this, l, this.values.length);
|
|
18
|
-
}
|
|
19
|
-
code(t) {
|
|
20
|
-
const o = typeof t == "bigint" ? Number(t) : t;
|
|
21
|
-
let r = u(this, f).get(o);
|
|
22
|
-
return r === void 0 && (r = this.values.length, this.values.push(o), u(this, f).set(o, r)), r;
|
|
23
|
-
}
|
|
24
|
-
/** Each code's rank: the seed's own order, then every other value seen, numbers before strings. */
|
|
25
|
-
ranks() {
|
|
26
|
-
const t = new Uint32Array(this.values.length);
|
|
27
|
-
for (let r = 0; r < u(this, l); r++) t[r] = r;
|
|
28
|
-
const o = this.values.slice(u(this, l)).map((r, n) => ({ value: r, code: u(this, l) + n }));
|
|
29
|
-
return o.sort((r, n) => $(r.value, n.value)), o.forEach(({ code: r }, n) => {
|
|
30
|
-
t[r] = u(this, l) + n;
|
|
31
|
-
}), t;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
f = new WeakMap(), l = new WeakMap();
|
|
35
|
-
function $(e, t) {
|
|
36
|
-
return typeof e == "number" && typeof t == "number" ? e - t : typeof e == "number" ? -1 : typeof t == "number" ? 1 : String(e ?? "").localeCompare(String(t ?? ""));
|
|
37
|
-
}
|
|
38
|
-
const w = (e, t) => {
|
|
39
|
-
const o = new Float64Array(t);
|
|
40
|
-
if (e) for (let r = 0; r < t; r++) o[r] = Number(e[r] ?? Number.NaN);
|
|
41
|
-
return o;
|
|
42
|
-
};
|
|
43
|
-
function rt(e, t, o, r) {
|
|
44
|
-
var k, F, S, Y, O, z, R, K;
|
|
45
|
-
const { rows: n, edges: L } = e.content, i = e.kind === "cells", c = n.numRows, y = (k = n.getChild(W)) == null ? void 0 : k.toArray(), m = (F = n.getChild(Z)) == null ? void 0 : F.toArray(), g = new Float32Array(c * 2);
|
|
46
|
-
for (let s = 0; s < c; s++)
|
|
47
|
-
g[s * 2] = Number((y == null ? void 0 : y[s]) ?? Number.NaN), g[s * 2 + 1] = Number((m == null ? void 0 : m[s]) ?? Number.NaN);
|
|
48
|
-
const I = w((S = n.getChild(i ? H : V)) == null ? void 0 : S.toArray(), c), E = i ? t.category === r ? Q : void 0 : t.category, b = E === void 0 || (Y = n.getChild(E)) == null ? void 0 : Y.toArray();
|
|
49
|
-
let A = null;
|
|
50
|
-
if (b) {
|
|
51
|
-
A = new Uint32Array(c);
|
|
52
|
-
for (let s = 0; s < c; s++) A[s] = o.code(b[s] ?? null);
|
|
53
|
-
}
|
|
54
|
-
const D = i ? w((O = n.getChild(J)) == null ? void 0 : O.toArray(), c) : new Float64Array(c).fill(1), d = i ? t.size !== void 0 ? D : void 0 : t.size, X = d === void 0 ? null : Float32Array.from(typeof d == "string" ? w((z = n.getChild(d)) == null ? void 0 : z.toArray(), c) : d), _ = !i && t.title !== void 0 ? (R = n.getChild(t.title)) == null ? void 0 : R.toArray() : void 0, j = _ ? Array.from({ length: c }, (s, a) => String(_[a] ?? "")) : null;
|
|
55
|
-
let N = 0;
|
|
56
|
-
for (const s of L) N += s.src.length;
|
|
57
|
-
const p = new Float64Array(N * 2), v = i ? new Float32Array(N) : null;
|
|
58
|
-
let h = 0;
|
|
59
|
-
for (const s of L)
|
|
60
|
-
for (let a = 0; a < s.src.length; a++, h++)
|
|
61
|
-
p[h * 2] = Number(s.src[a]), p[h * 2 + 1] = Number(s.dst[a]), v && (v[h] = Number(((K = s.weight) == null ? void 0 : K[a]) ?? 1));
|
|
62
|
-
return { n: c, cells: i, positions: g, keys: I, codes: A, sizes: X, counts: D, titles: j, links: p, weights: v };
|
|
63
|
-
}
|
|
64
|
-
export {
|
|
65
|
-
ot as Dictionary,
|
|
66
|
-
rt as encode
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=encode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode.js","sources":["../../src/render/encode.ts"],"sourcesContent":["import { PAYLOAD_ADDRESS, PAYLOAD_COORDINATES } from \"@fossil-lang/corpus\";\nimport type { Binding } from \"../core/channels\";\nimport type { TileView } from \"../core/store\";\n\n/**\n * The cell columns a view reads. fossil's barrel publishes the payload's role table and not the\n * cells', so these two are spelled here; `/docs/design/graph` lists it as open on fossil's side.\n */\nconst CELL_KEY = \"cell_id\";\nconst CELL_TALLY = \"count\";\nconst CELL_MODE = \"mode\";\nconst KEY = PAYLOAD_ADDRESS[0] as string;\nconst [X, Y] = PAYLOAD_COORDINATES as [string, string];\n\n/**\n * Values to codes, in the order first seen — stable for the life of a binding. **The seed ranks\n * first, in its own order**: the manifest's ordinals or the host's named values, so a colour is\n * decided before a tile arrives. Only a value outside it is ranked by value, after the seed.\n */\nexport class Dictionary {\n readonly values: unknown[] = [];\n readonly #codes = new Map<unknown, number>();\n readonly #seeded: number;\n\n constructor(seed: readonly unknown[] = []) {\n for (const value of seed) this.code(value);\n this.#seeded = this.values.length;\n }\n\n code(value: unknown): number {\n const key = typeof value === \"bigint\" ? Number(value) : value;\n let code = this.#codes.get(key);\n if (code === undefined) {\n code = this.values.length;\n this.values.push(key);\n this.#codes.set(key, code);\n }\n return code;\n }\n\n /** Each code's rank: the seed's own order, then every other value seen, numbers before strings. */\n ranks(): Uint32Array {\n const ranks = new Uint32Array(this.values.length);\n for (let code = 0; code < this.#seeded; code++) ranks[code] = code;\n const rest = this.values.slice(this.#seeded).map((value, i) => ({ value, code: this.#seeded + i }));\n rest.sort((a, b) => compare(a.value, b.value));\n rest.forEach(({ code }, i) => {\n ranks[code] = this.#seeded + i;\n });\n return ranks;\n }\n}\n\nfunction compare(a: unknown, b: unknown): number {\n if (typeof a === \"number\" && typeof b === \"number\") return a - b;\n if (typeof a === \"number\") return -1;\n if (typeof b === \"number\") return 1;\n return String(a ?? \"\").localeCompare(String(b ?? \"\"));\n}\n\n/** One tile's rows and edges as the arrays a composition concatenates. */\nexport interface Encoded {\n readonly n: number;\n readonly cells: boolean;\n /** `[x0, y0, x1, y1, …]`. */\n readonly positions: Float32Array;\n /** `dense_id` at the payload, `cell_id` on a rung — what an edge's ends name. */\n readonly keys: Float64Array;\n /** Dictionary codes of the categorical column, or `null` when nothing is bound. */\n readonly codes: Uint32Array | null;\n /** The ramp: `r`'s column at the payload, a cell's `count` on a rung. */\n readonly sizes: Float32Array | null;\n /** Vertices each row stands for: one at the payload, a cell's `count` on a rung. */\n readonly counts: Float64Array;\n readonly titles: readonly string[] | null;\n /** `[src, dst, …]` in `keys`' space, every relation read from this tile, both directions. */\n readonly links: Float64Array;\n /** How many edges each link stands for: one at the payload, the quotient's `weight` on a rung. */\n readonly weights: Float32Array | null;\n}\n\nconst numbers = (values: ArrayLike<unknown> | undefined, n: number): Float64Array => {\n const out = new Float64Array(n);\n if (values) for (let i = 0; i < n; i++) out[i] = Number(values[i] ?? Number.NaN);\n return out;\n};\n\n/**\n * **A tile is encoded once per binding**: the arrays are made when it arrives, and a composition is a\n * concatenation of arrays already made. A cell summarises one channel, so its colour is `mode` when\n * `fill` binds the column the tree's mode is of, its size can only be `count`, and it has no title.\n */\nexport function encode(\n view: TileView,\n binding: Binding,\n dictionary: Dictionary,\n modeColumn: string | null,\n): Encoded {\n const { rows, edges } = view.content;\n const cells = view.kind === \"cells\";\n const n = rows.numRows;\n const xs = rows.getChild(X)?.toArray();\n const ys = rows.getChild(Y)?.toArray();\n const positions = new Float32Array(n * 2);\n for (let i = 0; i < n; i++) {\n positions[i * 2] = Number(xs?.[i] ?? Number.NaN);\n positions[i * 2 + 1] = Number(ys?.[i] ?? Number.NaN);\n }\n const keys = numbers(rows.getChild(cells ? CELL_KEY : KEY)?.toArray(), n);\n\n const categorical = cells ? (binding.category === modeColumn ? CELL_MODE : undefined) : binding.category;\n const category = categorical === undefined ? undefined : rows.getChild(categorical)?.toArray();\n let codes: Uint32Array | null = null;\n if (category) {\n codes = new Uint32Array(n);\n for (let i = 0; i < n; i++) codes[i] = dictionary.code(category[i] ?? null);\n }\n\n const counts = cells ? numbers(rows.getChild(CELL_TALLY)?.toArray(), n) : new Float64Array(n).fill(1);\n const ramp = cells ? (binding.size !== undefined ? counts : undefined) : binding.size;\n const sizes =\n ramp === undefined ? null : Float32Array.from(typeof ramp === \"string\" ? numbers(rows.getChild(ramp)?.toArray(), n) : ramp);\n\n const named = !cells && binding.title !== undefined ? rows.getChild(binding.title)?.toArray() : undefined;\n const titles = named ? Array.from({ length: n }, (_, i) => String(named[i] ?? \"\")) : null;\n\n let total = 0;\n for (const edge of edges) total += edge.src.length;\n const links = new Float64Array(total * 2);\n const weights = cells ? new Float32Array(total) : null;\n let at = 0;\n for (const edge of edges) {\n for (let e = 0; e < edge.src.length; e++, at++) {\n links[at * 2] = Number(edge.src[e]);\n links[at * 2 + 1] = Number(edge.dst[e]);\n if (weights) weights[at] = Number(edge.weight?.[e] ?? 1);\n }\n }\n\n return { n, cells, positions, keys, codes, sizes, counts, titles, links, weights };\n}\n"],"names":["CELL_KEY","CELL_TALLY","CELL_MODE","KEY","PAYLOAD_ADDRESS","X","Y","PAYLOAD_COORDINATES","Dictionary","seed","__publicField","__privateAdd","_codes","_seeded","value","__privateSet","key","code","__privateGet","ranks","rest","i","a","b","compare","numbers","values","n","out","encode","view","binding","dictionary","modeColumn","rows","edges","cells","xs","_a","ys","_b","positions","keys","_c","categorical","category","_d","codes","counts","_e","ramp","sizes","_f","named","_g","titles","_","total","edge","links","weights","at","e","_h"],"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