@kanzo-tech/graph 0.9.0 → 0.11.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.
Files changed (204) hide show
  1. package/README.md +60 -95
  2. package/dist/core/categories.d.ts +12 -0
  3. package/dist/core/categories.d.ts.map +1 -0
  4. package/dist/core/categories.js +14 -0
  5. package/dist/core/categories.js.map +1 -0
  6. package/dist/core/channels.d.ts +34 -0
  7. package/dist/core/channels.d.ts.map +1 -0
  8. package/dist/core/channels.js +19 -0
  9. package/dist/core/channels.js.map +1 -0
  10. package/dist/core/detail.d.ts +18 -0
  11. package/dist/core/detail.d.ts.map +1 -0
  12. package/dist/core/detail.js +20 -0
  13. package/dist/core/detail.js.map +1 -0
  14. package/dist/core/filter.d.ts +34 -0
  15. package/dist/core/filter.d.ts.map +1 -0
  16. package/dist/core/filter.js +99 -0
  17. package/dist/core/filter.js.map +1 -0
  18. package/dist/core/refine.d.ts +14 -0
  19. package/dist/core/refine.d.ts.map +1 -0
  20. package/dist/core/refine.js +20 -0
  21. package/dist/core/refine.js.map +1 -0
  22. package/dist/{resident.d.ts → core/resident.d.ts} +8 -8
  23. package/dist/core/resident.d.ts.map +1 -0
  24. package/dist/core/resident.js +44 -0
  25. package/dist/core/resident.js.map +1 -0
  26. package/dist/core/scheduler.d.ts +42 -0
  27. package/dist/core/scheduler.d.ts.map +1 -0
  28. package/dist/core/scheduler.js +77 -0
  29. package/dist/core/scheduler.js.map +1 -0
  30. package/dist/core/state.d.ts +132 -0
  31. package/dist/core/state.d.ts.map +1 -0
  32. package/dist/core/store.d.ts +6 -0
  33. package/dist/core/store.d.ts.map +1 -0
  34. package/dist/core/store.js +235 -0
  35. package/dist/core/store.js.map +1 -0
  36. package/dist/core/tile-matrix.d.ts +37 -0
  37. package/dist/core/tile-matrix.d.ts.map +1 -0
  38. package/dist/core/tile-matrix.js +49 -0
  39. package/dist/core/tile-matrix.js.map +1 -0
  40. package/dist/core/tile.d.ts +54 -0
  41. package/dist/core/tile.d.ts.map +1 -0
  42. package/dist/core/tile.js +76 -0
  43. package/dist/core/tile.js.map +1 -0
  44. package/dist/core/tileset.d.ts +59 -0
  45. package/dist/core/tileset.d.ts.map +1 -0
  46. package/dist/core/tileset.js +177 -0
  47. package/dist/core/tileset.js.map +1 -0
  48. package/dist/{types.d.ts → core/types.d.ts} +9 -0
  49. package/dist/core/types.d.ts.map +1 -0
  50. package/dist/index.d.ts +37 -70
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +32 -34
  53. package/dist/index.js.map +1 -1
  54. package/dist/{use-graph-selection.d.ts → parts/gesture.d.ts} +4 -4
  55. package/dist/parts/gesture.d.ts.map +1 -0
  56. package/dist/{use-graph-selection.js → parts/gesture.js} +17 -17
  57. package/dist/parts/gesture.js.map +1 -0
  58. package/dist/parts/graph-canvas.d.ts +17 -0
  59. package/dist/parts/graph-canvas.d.ts.map +1 -0
  60. package/dist/parts/graph-canvas.js +174 -0
  61. package/dist/parts/graph-canvas.js.map +1 -0
  62. package/dist/parts/graph-inspector.d.ts +18 -0
  63. package/dist/parts/graph-inspector.d.ts.map +1 -0
  64. package/dist/parts/graph-inspector.js +84 -0
  65. package/dist/parts/graph-inspector.js.map +1 -0
  66. package/dist/parts/graph-legend.d.ts +12 -0
  67. package/dist/parts/graph-legend.d.ts.map +1 -0
  68. package/dist/parts/graph-legend.js +61 -0
  69. package/dist/parts/graph-legend.js.map +1 -0
  70. package/dist/parts/graph-toolbar.d.ts +15 -0
  71. package/dist/parts/graph-toolbar.d.ts.map +1 -0
  72. package/dist/parts/graph-toolbar.js +94 -0
  73. package/dist/parts/graph-toolbar.js.map +1 -0
  74. package/dist/parts/overlays.d.ts +33 -0
  75. package/dist/parts/overlays.d.ts.map +1 -0
  76. package/dist/{use-graph-overlays.js → parts/overlays.js} +8 -8
  77. package/dist/parts/overlays.js.map +1 -0
  78. package/dist/{shape-glyph.d.ts → parts/shape-glyph.d.ts} +1 -1
  79. package/dist/parts/shape-glyph.d.ts.map +1 -0
  80. package/dist/{shape-glyph.js → parts/shape-glyph.js} +1 -1
  81. package/dist/parts/shape-glyph.js.map +1 -0
  82. package/dist/react/graph-root.d.ts +15 -0
  83. package/dist/react/graph-root.d.ts.map +1 -0
  84. package/dist/react/graph-root.js +23 -0
  85. package/dist/react/graph-root.js.map +1 -0
  86. package/dist/{use-graph-prefs.d.ts → react/use-graph-prefs.d.ts} +2 -2
  87. package/dist/react/use-graph-prefs.d.ts.map +1 -0
  88. package/dist/{use-graph-prefs.js → react/use-graph-prefs.js} +3 -3
  89. package/dist/react/use-graph-prefs.js.map +1 -0
  90. package/dist/react/use-graph-state.d.ts +11 -0
  91. package/dist/react/use-graph-state.d.ts.map +1 -0
  92. package/dist/react/use-graph-state.js +16 -0
  93. package/dist/react/use-graph-state.js.map +1 -0
  94. package/dist/react/use-graph.d.ts +38 -0
  95. package/dist/react/use-graph.d.ts.map +1 -0
  96. package/dist/react/use-graph.js +87 -0
  97. package/dist/react/use-graph.js.map +1 -0
  98. package/dist/{adaptive.d.ts → render/adaptive.d.ts} +1 -1
  99. package/dist/render/adaptive.d.ts.map +1 -0
  100. package/dist/render/adaptive.js.map +1 -0
  101. package/dist/render/compose.d.ts +51 -0
  102. package/dist/render/compose.d.ts.map +1 -0
  103. package/dist/render/compose.js +107 -0
  104. package/dist/render/compose.js.map +1 -0
  105. package/dist/render/css-color.d.ts.map +1 -0
  106. package/dist/render/css-color.js.map +1 -0
  107. package/dist/render/encode.d.ts +42 -0
  108. package/dist/render/encode.d.ts.map +1 -0
  109. package/dist/render/encode.js +68 -0
  110. package/dist/render/encode.js.map +1 -0
  111. package/dist/render/graph-looks.d.ts.map +1 -0
  112. package/dist/render/graph-looks.js.map +1 -0
  113. package/dist/render/graph-model.d.ts +44 -0
  114. package/dist/render/graph-model.d.ts.map +1 -0
  115. package/dist/render/graph-model.js +80 -0
  116. package/dist/render/graph-model.js.map +1 -0
  117. package/dist/{graph-sim.d.ts → render/graph-sim.d.ts} +2 -2
  118. package/dist/render/graph-sim.d.ts.map +1 -0
  119. package/dist/render/graph-sim.js.map +1 -0
  120. package/dist/{obligations.d.ts → render/obligations.d.ts} +1 -1
  121. package/dist/render/obligations.d.ts.map +1 -0
  122. package/dist/render/renderer.d.ts +38 -0
  123. package/dist/render/renderer.d.ts.map +1 -0
  124. package/dist/render/renderer.js +235 -0
  125. package/dist/render/renderer.js.map +1 -0
  126. package/dist/render/webgl.d.ts +14 -0
  127. package/dist/render/webgl.d.ts.map +1 -0
  128. package/dist/render/webgl.js +19 -0
  129. package/dist/render/webgl.js.map +1 -0
  130. package/dist/render/when-ready.d.ts.map +1 -0
  131. package/dist/render/when-ready.js.map +1 -0
  132. package/package.json +11 -21
  133. package/dist/adaptive.d.ts.map +0 -1
  134. package/dist/adaptive.js.map +0 -1
  135. package/dist/bounded.d.ts +0 -364
  136. package/dist/bounded.d.ts.map +0 -1
  137. package/dist/bounded.js +0 -18
  138. package/dist/bounded.js.map +0 -1
  139. package/dist/cluster-ring.d.ts +0 -25
  140. package/dist/cluster-ring.d.ts.map +0 -1
  141. package/dist/cluster-ring.js +0 -16
  142. package/dist/cluster-ring.js.map +0 -1
  143. package/dist/css-color.d.ts.map +0 -1
  144. package/dist/css-color.js.map +0 -1
  145. package/dist/duck-source.d.ts +0 -198
  146. package/dist/duck-source.d.ts.map +0 -1
  147. package/dist/duck-source.js +0 -320
  148. package/dist/duck-source.js.map +0 -1
  149. package/dist/graph-canvas.d.ts +0 -50
  150. package/dist/graph-canvas.d.ts.map +0 -1
  151. package/dist/graph-canvas.js +0 -35
  152. package/dist/graph-canvas.js.map +0 -1
  153. package/dist/graph-looks.d.ts.map +0 -1
  154. package/dist/graph-looks.js.map +0 -1
  155. package/dist/graph-model.d.ts +0 -130
  156. package/dist/graph-model.d.ts.map +0 -1
  157. package/dist/graph-model.js +0 -104
  158. package/dist/graph-model.js.map +0 -1
  159. package/dist/graph-sim.d.ts.map +0 -1
  160. package/dist/graph-sim.js.map +0 -1
  161. package/dist/obligations.d.ts.map +0 -1
  162. package/dist/resident.d.ts.map +0 -1
  163. package/dist/resident.js +0 -44
  164. package/dist/resident.js.map +0 -1
  165. package/dist/shape-glyph.d.ts.map +0 -1
  166. package/dist/shape-glyph.js.map +0 -1
  167. package/dist/slice-client.d.ts +0 -78
  168. package/dist/slice-client.d.ts.map +0 -1
  169. package/dist/slice-client.js +0 -98
  170. package/dist/slice-client.js.map +0 -1
  171. package/dist/types.d.ts.map +0 -1
  172. package/dist/use-graph-look.d.ts +0 -28
  173. package/dist/use-graph-look.d.ts.map +0 -1
  174. package/dist/use-graph-look.js +0 -28
  175. package/dist/use-graph-look.js.map +0 -1
  176. package/dist/use-graph-overlays.d.ts +0 -44
  177. package/dist/use-graph-overlays.d.ts.map +0 -1
  178. package/dist/use-graph-overlays.js.map +0 -1
  179. package/dist/use-graph-prefs.d.ts.map +0 -1
  180. package/dist/use-graph-prefs.js.map +0 -1
  181. package/dist/use-graph-selection.d.ts.map +0 -1
  182. package/dist/use-graph-selection.js.map +0 -1
  183. package/dist/use-graph.d.ts +0 -203
  184. package/dist/use-graph.d.ts.map +0 -1
  185. package/dist/use-graph.js +0 -102
  186. package/dist/use-graph.js.map +0 -1
  187. package/dist/use-query-loop.d.ts +0 -88
  188. package/dist/use-query-loop.d.ts.map +0 -1
  189. package/dist/use-query-loop.js +0 -148
  190. package/dist/use-query-loop.js.map +0 -1
  191. package/dist/use-renderer.d.ts +0 -86
  192. package/dist/use-renderer.d.ts.map +0 -1
  193. package/dist/use-renderer.js +0 -188
  194. package/dist/use-renderer.js.map +0 -1
  195. package/dist/when-ready.d.ts.map +0 -1
  196. package/dist/when-ready.js.map +0 -1
  197. /package/dist/{adaptive.js → render/adaptive.js} +0 -0
  198. /package/dist/{css-color.d.ts → render/css-color.d.ts} +0 -0
  199. /package/dist/{css-color.js → render/css-color.js} +0 -0
  200. /package/dist/{graph-looks.d.ts → render/graph-looks.d.ts} +0 -0
  201. /package/dist/{graph-looks.js → render/graph-looks.js} +0 -0
  202. /package/dist/{graph-sim.js → render/graph-sim.js} +0 -0
  203. /package/dist/{when-ready.d.ts → render/when-ready.d.ts} +0 -0
  204. /package/dist/{when-ready.js → render/when-ready.js} +0 -0
@@ -1,198 +0,0 @@
1
- import { Corpus, GapReason } from '@fossil-lang/corpus';
2
- import { Engine, Selection } from '@kanzo-tech/mosaic';
3
- import { BoundedSource } from './bounded';
4
- import { VertexId } from './resident';
5
- /**
6
- * The source: a corpus fossil wrote, read through DuckDB.
7
- *
8
- * On a subpath because Mosaic and fossil's reader are optional peers and this is the half that needs
9
- * them. The root barrel ships no source at all, which is the whole of what that split now means: a
10
- * host that installs neither gets the rendering surface and draws nothing.
11
- *
12
- * **There used to be two here and the second was neutral about storage.** `duckBoundedSource` took
13
- * two ordinary relations and the column names that made sense of them, and that neutrality earned
14
- * its keep once — it let bounded be measured against unbounded before anything committed to a layout
15
- * on disk. What it cost afterwards is the reason it is gone: a corpus already declares those names
16
- * in its manifest, so the second source was this side writing down what the other side owns, and the
17
- * two answered the same question in two dialects of the same SQL.
18
- *
19
- * **Every query in this file goes through a `SliceRead`, and there is no other path.** `onceQuery`
20
- * was the other one — a throwaway client per query, on this subpath, re-exported for the two
21
- * showcases that also read a relation directly. It is gone: a read the page's filters cannot reach
22
- * is a picture that disagrees with the page, and `slice-client.ts` carries what that cost.
23
- */
24
- /**
25
- * A DuckDB-backed source, and the one thing it can do that the render contract knows nothing about.
26
- *
27
- * `BoundedSource` says what a renderer needs: answer a bounded question. Publishing a selection is
28
- * the other direction of the same seam and it is Mosaic's, not the renderer's — so it lives on the
29
- * concrete type rather than on the contract, beside `watch`, which is on the contract because the
30
- * query loop is what has to act on it.
31
- */
32
- export interface DuckSource extends BoundedSource {
33
- /**
34
- * The reader's own selection, as a clause the rest of the page filters by. `null` retracts it.
35
- *
36
- * **The graph is exempt from its own clause, and that is the whole difference from the greyout it
37
- * replaces.** While the canvas *faded* excluded rows it could take its own clause too — the row was
38
- * still drawn and still selectable, and the fade was the brush. A canvas that now draws what
39
- * survives would answer a lasso by deleting everything the reader did not lasso, which is not a
40
- * selection, it is a filter nobody asked for.
41
- */
42
- publish(vertices: readonly VertexId[] | null): void;
43
- }
44
- /**
45
- * A corpus that fossil wrote, read by address — **and the addressing is fossil's.**
46
- *
47
- * **The five things a call site used to know, and now does not.** Drawing a corpus meant deriving
48
- * the chunk URLs from a `chunk_size` copied by hand, knowing how a tile is named, knowing what the
49
- * edge directory is called, knowing GraphAr's column names, and knowing that a glob cannot work over
50
- * a plain HTTP origin because there is no listing. Five conventions and about forty lines, none of
51
- * it the business of something that wants to draw a graph. `/docs/design/graph` carries the
52
- * argument; the copied `chunk_size` carries the evidence, because it went stale and read
53
- * a fraction of a corpus in silence for as long as it did.
54
- *
55
- * The consumer holds two things: **the corpus fossil opened, and the page's engine.**
56
- *
57
- * ```ts
58
- * const e = await engine();
59
- * const corpus = await open("/bench/1000000", { query: e.query });
60
- * const { source } = await openCorpus({ corpus, engine: e });
61
- * ```
62
- *
63
- * **And this side no longer knows the conventions either, which is the change.** It used to remove
64
- * that defect for its callers by committing it one level down — a YAML line-scanner, a
65
- * `chunk{k}.parquet` spelling, a `by_source/tile{k}.parquet` spelling and a `HEAD`-probing search
66
- * for a tile count — and by the time those were deleted all four were **wrong**: fossil writes
67
- * `container: rowgroups`, one `tiles.parquet` whose row groups are the tiles, and `vertex_count`
68
- * had been in the manifest the whole time the search was probing for it. Fossil's `open` is
69
- * `fossil_graph::plan` compiled to wasm32: the arithmetic the native reader runs, not a second
70
- * implementation of it that agrees until it does not.
71
- *
72
- * **Addressed, not queried.** The manifests and the per-tile boxes are read once and kept; after
73
- * that a camera move is arithmetic over boxes and a list of URLs. There is deliberately no request
74
- * on the path between the camera moving and a URL being computable — the moment there is one, this
75
- * has become the `viewport` verb fossil deleted.
76
- *
77
- * **What it is not.** It takes no column names and no type index. Those come from the manifest or
78
- * they do not come. There used to be a second source here for the case this is not — an arbitrary
79
- * relation with `x`/`y` that nobody wrote as a corpus — and taking `idField` here would have been
80
- * that one with extra steps. It is gone, so the rule is simpler than the guard against it: a column
81
- * name reaching this door is a name the manifest should have carried.
82
- */
83
- export interface OpenCorpusOptions {
84
- /**
85
- * The corpus, as fossil's `open` answered it — **opened by the host, and once.**
86
- *
87
- * This door used to open one itself from a `dest`, a `readText` and a `wasm`, which made it the
88
- * third open of the same corpus on a keasy discover visit: the host had already opened it to
89
- * query it, and opened it again only so that this could. Opening is the host's, because what it
90
- * takes is the host's — where the corpus is, and what signs it. Drawing takes the result.
91
- */
92
- corpus: Corpus;
93
- /**
94
- * The page's engine — `engine()` from `@kanzo-tech/mosaic`. The canvas reads its tiles and
95
- * publishes its clauses through the coordinator; the files are the ones the corpus already made
96
- * readable, by the names its addressing gives them.
97
- */
98
- engine: Pick<Engine, "coordinator">;
99
- /**
100
- * The crossfilter this graph draws inside — the same `Selection` the page's charts filter by.
101
- *
102
- * Given, the predicate rides in the slice query and the canvas draws what survives.
103
- */
104
- filterBy?: Selection;
105
- /**
106
- * Which vertex type to draw, when a corpus carries more than one.
107
- *
108
- * Defaults to the first the manifest names. A corpus of one type never passes it; a corpus of
109
- * several has to, because *which graph do you mean* is not a question a reader can answer.
110
- */
111
- vertexType?: string;
112
- /**
113
- * Read the identity column as well. **Off by default, and the same trade as everywhere else:**
114
- * `subject` costs about twice the drawing tile, so the drawing path carries addresses and a host
115
- * asks for names when something has to be *named* rather than painted.
116
- */
117
- subjects?: boolean;
118
- }
119
- /**
120
- * An opened corpus: the half that **draws** and the half that **answers**.
121
- *
122
- * A host needs both over the same bytes and they are not the same access. The canvas reads tiles by
123
- * address — a handful of files per camera move, chosen from the footer's boxes, with no query. A
124
- * chart, a crossfilter clause or a verb reads the *relation*: every row, by column name, in SQL.
125
- * Hiding the URLs behind `source` is right for the first and leaves the second with nothing to
126
- * query, so this hands on the names fossil's verbs already query the corpus by.
127
- */
128
- export interface OpenedCorpus {
129
- /**
130
- * For the canvas: `<GraphCanvas source={…}>`. Reads tiles, never the whole relation.
131
- *
132
- * A `DuckSource`, and `CorpusSource` is gone with the reason it existed: `extent()` was declared
133
- * there because a source over an unlaid-out relation has no answer to it, and *optional on the
134
- * base contract* says that better than a second interface — a relation with `x`/`y` has an extent
135
- * too, and it was the one host that could not frame its opening view.
136
- */
137
- source: DuckSource;
138
- /**
139
- * The vertex relation, as fossil registered it — qualified by the corpus's catalog.
140
- *
141
- * Every column the manifest declares, including the corpus' own properties — so a clause a chart
142
- * publishes over `kind` or `region` lands here with no translation, which is what makes one
143
- * crossfilter serve the canvas and the charts.
144
- */
145
- nodes: string;
146
- /**
147
- * The source-ordered edge relations this canvas draws, one fossil relation each.
148
- *
149
- * **A list, because a corpus declares a list.** This was one name, picked with `.find` over the
150
- * relations whose source is this type — so a corpus declaring two edge labels registered the
151
- * first and dropped the second with nothing raised, and a chart over `corpus_Person_edges` was a
152
- * chart over half the graph. `frame` on the other side takes every one of them
153
- * (`packages/corpus/src/corpus.ts`, `edges.filter((e) => e.srcType === address.type)`), and
154
- * fossil's own `verbs()` registers a view per relation under `{src}_{edge}_{dst}` rather than
155
- * unioning them — which is also what keeps two relations' differing property columns from having
156
- * to agree on one schema.
157
- *
158
- * Empty when the corpus declares no relation this source can draw; {@link OpenedCorpus.undrawn}
159
- * is then where the ones it declared went.
160
- */
161
- edges: readonly EdgeRelation[];
162
- /**
163
- * The relations incident to this type that the canvas does **not** read, and why.
164
- *
165
- * A single-type canvas can draw a relation only where *both* endpoints are numbered in its own
166
- * `dense_id` space. The rest are dropped from the read rather than mixed into it, and reported
167
- * here rather than dropped in silence.
168
- */
169
- undrawn: readonly UndrawnRelation[];
170
- }
171
- /** One edge relation of the drawn type, and the relation fossil registered its adjacency as. */
172
- export interface EdgeRelation {
173
- readonly edgeType: string;
174
- readonly srcType: string;
175
- readonly dstType: string;
176
- /** Fossil's relation, qualified by the corpus's catalog — its `CorpusRelation.sql`. */
177
- readonly view: string;
178
- }
179
- /**
180
- * One relation incident to the drawn type that this source cannot read, and why.
181
- *
182
- * **The reason is fossil's {@link GapReason} and not a second spelling of it** — `other-space` when
183
- * an endpoint is another vertex type, so the `dense_id` on that side numbers a different set of
184
- * vertices and this source holds no coordinates for any of them; `not-declared` when both endpoints
185
- * are this type and the corpus publishes no source-ordered adjacency to read. The two the drawing
186
- * read can produce; the third, `not-requested`, is `tilesFor`'s and never reaches here.
187
- *
188
- * What this adds to a `Gap` is the endpoint pair, which a `Gap` does not carry: it names a relation
189
- * by label and orientation, and a corpus may declare two relations under one label.
190
- */
191
- export interface UndrawnRelation {
192
- readonly edgeType: string;
193
- readonly srcType: string;
194
- readonly dstType: string;
195
- readonly reason: GapReason;
196
- }
197
- export declare function openCorpus(options: OpenCorpusOptions): Promise<OpenedCorpus>;
198
- //# sourceMappingURL=duck-source.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"duck-source.d.ts","sourceRoot":"","sources":["../src/duck-source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,MAAM,EAGN,SAAS,EAEV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAe,MAAM,EAAc,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAiC,MAAM,WAAW,CAAC;AAE9E,OAAO,EAA6B,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;CACrD;AAojBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAkBD;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;OAOG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;;;OAcG;IACH,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/B;;;;;;OAMG;IACH,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CACrC;AAED,gGAAgG;AAChG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uFAAuF;IACvF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CA8SlF"}
@@ -1,320 +0,0 @@
1
- "use client";
2
- import { PAYLOAD_COORDINATES as M, PAYLOAD_IDENTITY as te, PAYLOAD_ADDRESS as ne } from "@fossil-lang/corpus";
3
- import { numbers as b, clausePoints as se, fillColumn as x, column as oe } from "@kanzo-tech/mosaic";
4
- import { SliceRead as F } from "./slice-client.js";
5
- import { typeOf as ae, denseOf as G, vertexId as ie } from "./resident.js";
6
- const q = 0;
7
- function re(e, t) {
8
- return {
9
- points: new F(e, t),
10
- links: new F(e, t),
11
- meta: new F(e)
12
- };
13
- }
14
- function ce(e) {
15
- let t = Promise.resolve();
16
- return (n) => {
17
- const o = t.then(() => e.ask(() => n));
18
- return t = o.catch(() => {
19
- }), o;
20
- };
21
- }
22
- function z(e) {
23
- if (e == null) return "";
24
- const n = (Array.isArray(e) ? e : [e]).filter((o) => o != null).map((o) => String(o));
25
- return n.length > 0 ? n.map((o) => `(${o})`).join(" AND ") : "";
26
- }
27
- function P(e, t) {
28
- return e ? t ? `(${e}) AND (${t})` : e : t || "TRUE";
29
- }
30
- function le(e, t) {
31
- const o = [
32
- [e.x, t.xMin, ">="],
33
- [e.x, t.xMax, "<="],
34
- [e.y, t.yMin, ">="],
35
- [e.y, t.yMax, "<="]
36
- ].filter(([, i]) => Number.isFinite(i)).map(([i, c, r]) => `${i} ${r} ${c}`);
37
- return o.length > 0 ? o.join(" AND ") : "TRUE";
38
- }
39
- const ue = (e) => `greatest(1, CAST(ceil(matched / ${e}.0) AS BIGINT))`;
40
- function W(e, t, n, o, i = !0) {
41
- const c = t.size ? `, ${t.size} AS size` : "", r = t.subject ? `, ${t.subject} AS subject` : "", u = t.category ? "(dense_rank() OVER (ORDER BY cat) - 1)::INTEGER AS category" : "0::INTEGER AS category";
42
- return `WITH pool AS (
43
- SELECT ${t.id} AS id, ${t.x} AS x, ${t.y} AS y${c}${r}${t.category ? `, ${t.category} AS cat` : ""},
44
- count(*) OVER () AS matched
45
- FROM ${e}
46
- WHERE ${n}
47
- ), vis AS (
48
- SELECT id, x, y${t.size ? ", size" : ""}${t.subject ? ", subject" : ""}${i ? ", matched" : ""},
49
- ${u},
50
- (row_number() OVER (ORDER BY id) - 1)::INTEGER AS local
51
- FROM pool
52
- WHERE id % ${ue(o)} = 0
53
- LIMIT ${o}
54
- )`;
55
- }
56
- function de(e, t, n, o) {
57
- if (n === void 0 || !Number.isFinite(n) || n <= 0) return "";
58
- const i = o * n;
59
- return `(${e}.x - ${t}.x) * (${e}.x - ${t}.x) + (${e}.y - ${t}.y) * (${e}.y - ${t}.y) >= ${i * i}`;
60
- }
61
- function Ee(e, t, n, o, i, c, r) {
62
- const u = P(`NOT (${o})`, i), E = de("a", "b", c, r);
63
- return `, out AS (
64
- SELECT ${n.id} AS id, ${n.x} AS x, ${n.y} AS y FROM ${e} WHERE ${u}
65
- ), reach AS (
66
- SELECT id, x, y FROM vis UNION ALL SELECT id, x, y FROM out
67
- ), span AS (
68
- SELECT sv.local AS src, tv.local AS dst, a.id AS src_id, b.id AS dst_id
69
- FROM ${t} e
70
- JOIN reach a ON e.${n.source} = a.id
71
- JOIN reach b ON e.${n.target} = b.id
72
- LEFT JOIN vis sv ON sv.id = a.id
73
- LEFT JOIN vis tv ON tv.id = b.id
74
- WHERE (sv.id IS NOT NULL OR tv.id IS NOT NULL)${E ? ` AND ${E}` : ""}
75
- ), anchor AS (
76
- SELECT o.id, o.x, o.y,
77
- ((SELECT count(*) FROM vis) + row_number() OVER (ORDER BY o.id) - 1)::INTEGER AS local
78
- FROM out o
79
- WHERE o.id IN (SELECT src_id FROM span WHERE src IS NULL
80
- UNION SELECT dst_id FROM span WHERE dst IS NULL)
81
- )`;
82
- }
83
- function ye(e, t, n, o, i, c, r, u) {
84
- const E = le(n, o), S = (c ?? []).filter((l) => ae(l) === q).map(G), y = S.length > 0 ? ` OR ${n.id} IN (${S.join(",")})` : "", m = `(${E})${y}`, $ = (l) => P(m, z(l)), T = n.size ? ", size" : "", f = n.subject ? ", subject" : "", A = (l) => Ee(e, t, n, m, z(l), r, u);
85
- return {
86
- /**
87
- * The marks, then the anchors, in one answer — because they are one buffer.
88
- *
89
- * `ORDER BY local` is load-bearing rather than tidy: `local` runs `0..marks-1` over the sample
90
- * and continues past it over the anchors, so ordering by it puts every mark before every anchor
91
- * and makes `marks` a prefix length. `matched` is then still read off row zero.
92
- */
93
- points: (l) => `${W(e, n, $(l), i)}${A(l)}
94
- SELECT local, id, x, y, category, matched, TRUE AS mark${T}${f} FROM vis
95
- UNION ALL
96
- SELECT local, id, x, y, 0::INTEGER, NULL::BIGINT, FALSE AS mark${n.size ? ", CAST(NULL AS DOUBLE)" : ""}${n.subject ? ", CAST(NULL AS VARCHAR)" : ""} FROM anchor
97
- ORDER BY local`,
98
- /**
99
- * One end drawn and both ends positioned.
100
- *
101
- * There was a second form here — both ends drawn, edges leaving the window dropped — for a source
102
- * that fetched no bytes beyond the rectangle and therefore had no position to put a far end at.
103
- * It went with that source, and `longEnough` with it — the length predicate lives in `anchorCte`
104
- * now, on the same span, which is where it has to sit once the join runs over the held rows
105
- * rather than over the visible ones.
106
- */
107
- links: (l) => `${W(e, n, $(l), i, !1)}${A(l)}
108
- SELECT coalesce(sp.src, sa.local) AS src, coalesce(sp.dst, da.local) AS dst
109
- FROM span sp
110
- LEFT JOIN anchor sa ON sa.id = sp.src_id
111
- LEFT JOIN anchor da ON da.id = sp.dst_id`,
112
- assemble: (l, p) => ({
113
- /**
114
- * How many matched, separately from how many came back.
115
- *
116
- * Without it the view cannot tell a reader "there is more here than I am showing you", and a
117
- * truncated slice looks exactly like a complete one — which is the failure this whole branch
118
- * has been about. Read off the first row rather than asked for: `matched` is constant down the
119
- * column, and an empty answer has no row and no matches, which agree.
120
- */
121
- n: Number(b(l, "matched")[0] ?? 0),
122
- ...Ae(l, p, n.size ? "size" : void 0, n.subject !== void 0)
123
- })
124
- };
125
- }
126
- function pe(e) {
127
- let t = null, n = null;
128
- const o = /* @__PURE__ */ new Map(), i = (c) => (r) => {
129
- if (!t || !n || (o.set(c, r), o.size < 2)) return;
130
- const u = o.get("points"), E = o.get("links");
131
- o.clear(), n(t.assemble(u, E));
132
- };
133
- return {
134
- api: {
135
- /**
136
- * Say when the answer changes for a reason the camera cannot see.
137
- *
138
- * The reason it hands over a whole `Slice` rather than a nudge to ask again: the coordinator
139
- * has *already* re-run both reads with the new predicate by the time we hear about it. Asking
140
- * again would run the same two queries a second time to learn what is in hand.
141
- */
142
- watch(c) {
143
- return n = c, e.points.onAnswer = i("points"), e.links.onAnswer = i("links"), () => {
144
- n = null, o.clear(), t = null, e.points.release(), e.links.release(), e.meta.release();
145
- };
146
- }
147
- },
148
- async run(c) {
149
- t = c, o.clear();
150
- const [r, u] = await Promise.all([
151
- e.points.ask(c.points),
152
- e.links.ask(c.links)
153
- ]);
154
- return c.assemble(r, u);
155
- }
156
- };
157
- }
158
- function me(e, t, n, o) {
159
- t && t.update(
160
- se([n], o == null ? void 0 : o.map((i) => [G(i)]), {
161
- source: e.points,
162
- clients: /* @__PURE__ */ new Set([e.points, e.links])
163
- })
164
- );
165
- }
166
- function Ae(e, t, n, o = !1) {
167
- const i = Y(e, "x"), c = new Float32Array(i * 2), r = x(e, "x", c, 0, 2);
168
- x(e, "y", c, 1, 2);
169
- const u = new Int32Array(i);
170
- x(e, "mark", u);
171
- let E = 0;
172
- for (; E < r && u[E] !== 0; ) E++;
173
- const S = new Float64Array(r);
174
- x(e, "id", S);
175
- const y = new BigUint64Array(r);
176
- for (let p = 0; p < r; p++) y[p] = ie(q, S[p]);
177
- const m = new Uint16Array(r);
178
- x(e, "category", m);
179
- const $ = o ? oe(e, "subject") : void 0;
180
- let T;
181
- n && (T = new Float32Array(r), x(e, n, T));
182
- const f = Y(t, "src"), A = new Float32Array(f * 2), l = x(t, "src", A, 0, 2);
183
- return x(t, "dst", A, 1, 2), {
184
- marks: E,
185
- vertices: y,
186
- subjects: $,
187
- positions: c.subarray(0, r * 2),
188
- links: A.subarray(0, l * 2),
189
- categories: m,
190
- sizes: T
191
- };
192
- }
193
- function Y(e, t) {
194
- var i;
195
- const n = e == null ? void 0 : e.numRows;
196
- if (typeof n == "number") return n;
197
- const o = (i = e == null ? void 0 : e.getChild) == null ? void 0 : i.call(e, t);
198
- return o ? o.length : Array.from(e).length;
199
- }
200
- async function xe(e) {
201
- var D, j, H;
202
- const { corpus: t, engine: n, filterBy: o, subjects: i = !1, vertexType: c } = e, { addressing: r } = t, u = re(n.coordinator, o), E = ce(u.meta), S = pe(u), y = r.vertexType(c), m = r.drawing(y.type), $ = m.relations.map((s) => ({
203
- address: s,
204
- // Never null on a drawn relation: a declared source-ordered adjacency is what `drawing` admits
205
- // one for, and `not-declared` is why the others are in `undrawn` instead.
206
- adjacency: s.adjacency("src")
207
- })), T = $.map((s) => s.adjacency), f = r.incident(y.type).filter((s) => !m.relations.includes(s)).map((s, a) => ({
208
- edgeType: s.edgeType,
209
- srcType: s.srcType,
210
- dstType: s.dstType,
211
- reason: m.undrawn[a].reason
212
- }));
213
- let A = null;
214
- const l = y.files(), p = (s) => s.map((a) => `'${a.replace(/'/g, "''")}'`).join(", ");
215
- function w() {
216
- return A ?? (A = (async () => {
217
- const s = p(l), [a, d] = M, I = r.container === "rowgroups" ? "row_group_id" : `list_position([${s}], file_name) - 1`, _ = await E(
218
- `SELECT ${I} AS tile,
219
- min(CASE WHEN path_in_schema = '${a}' THEN coalesce(stats_min_value, stats_min)::DOUBLE END) AS x0,
220
- max(CASE WHEN path_in_schema = '${a}' THEN coalesce(stats_max_value, stats_max)::DOUBLE END) AS x1,
221
- min(CASE WHEN path_in_schema = '${d}' THEN coalesce(stats_min_value, stats_min)::DOUBLE END) AS y0,
222
- max(CASE WHEN path_in_schema = '${d}' THEN coalesce(stats_max_value, stats_max)::DOUBLE END) AS y1
223
- FROM parquet_metadata([${s}])
224
- WHERE path_in_schema IN ('${a}', '${d}') GROUP BY 1 ORDER BY 1`
225
- ), C = b(_, "tile"), [g, N, L, R] = ["x0", "x1", "y0", "y1"].map((h) => b(_, h));
226
- return C.map((h, O) => ({
227
- tile: h,
228
- x0: g == null ? void 0 : g[O],
229
- x1: N == null ? void 0 : N[O],
230
- y0: L == null ? void 0 : L[O],
231
- y1: R == null ? void 0 : R[O]
232
- }));
233
- })()), A;
234
- }
235
- function V(s, a) {
236
- return s.filter((d) => d.x1 >= a.xMin && d.x0 <= a.xMax && d.y1 >= a.yMin && d.y0 <= a.yMax).map((d) => d.tile);
237
- }
238
- const U = {
239
- id: ne[0],
240
- subject: i ? te[0] : void 0,
241
- x: M[0],
242
- y: M[1],
243
- source: ((D = T[0]) == null ? void 0 : D.column) ?? "src_dense",
244
- target: ((H = (j = $[0]) == null ? void 0 : j.address.adjacency("dst")) == null ? void 0 : H.column) ?? "dst_dense"
245
- }, J = await t.relations(), v = (s, a) => {
246
- const d = J.find(s);
247
- if (!d) throw new Error(`openCorpus: the corpus registers no relation for ${a}`);
248
- return d.sql;
249
- }, k = v((s) => s.kind === "vertex" && s.name === y.type, y.type);
250
- return {
251
- source: {
252
- ...S.api,
253
- publish(s) {
254
- me(u, o, U.id, s);
255
- },
256
- /**
257
- * How many vertices there are — **read, not probed.**
258
- *
259
- * The manifest declares `vertex_count`. What stood here was a note saying no manifest carries
260
- * it, and a doubling-then-bisecting `HEAD` search for the last chunk plus a
261
- * `parquet_file_metadata` read of its row count — about a dozen requests and a query, per
262
- * corpus, for a number already in hand.
263
- */
264
- async total() {
265
- if (y.count !== null) return Number(y.count);
266
- const s = await E(`SELECT count(*) AS n FROM ${k}`);
267
- return Number(b(s, "n")[0] ?? 0);
268
- },
269
- async extent() {
270
- const s = await w();
271
- return {
272
- xMin: Math.min(...s.map((a) => a.x0)),
273
- yMin: Math.min(...s.map((a) => a.y0)),
274
- xMax: Math.max(...s.map((a) => a.x1)),
275
- yMax: Math.max(...s.map((a) => a.y1))
276
- };
277
- },
278
- // Regions only, and it says so by being the only method there is. A neighbourhood needs
279
- // adjacency this source does not index; `ExploringSource` declared the second question here and
280
- // was deleted with it — `index.test.ts` carries why, and fossil's `expand` is what answers it.
281
- async slice(s) {
282
- const { fill: a, limit: d, minLinkPixels: I, perPixel: _, pinned: C, r: g, signal: N, view: L } = s, R = { ...U, category: a, size: g }, h = await w(), O = V(h, L);
283
- if (O.length === 0)
284
- return {
285
- n: 0,
286
- marks: 0,
287
- vertices: new BigUint64Array(0),
288
- positions: new Float32Array(0),
289
- links: new Float32Array(0),
290
- categories: new Uint16Array(0)
291
- };
292
- const X = r.tilesFor({
293
- type: y.type,
294
- tiles: O,
295
- directions: ["src"]
296
- }), B = [
297
- ...new Set(T.flatMap((Z) => O.map((ee) => Z.tileUrl(ee))))
298
- ];
299
- if (N != null && N.aborted) throw N.reason;
300
- const K = `read_parquet([${p(X.vertexUrls)}])`, Q = B.length > 0 ? `read_parquet([${p(B)}])` : `(SELECT NULL::BIGINT AS ${R.source}, NULL::BIGINT AS ${R.target} WHERE FALSE)`;
301
- return S.run(ye(K, Q, R, L, d, C, _, I));
302
- }
303
- },
304
- nodes: k,
305
- edges: $.map(({ address: s }) => ({
306
- edgeType: s.edgeType,
307
- srcType: s.srcType,
308
- dstType: s.dstType,
309
- view: v(
310
- (a) => a.kind === "edge" && a.edgeType === s.edgeType && a.srcType === s.srcType && a.dstType === s.dstType,
311
- `${s.srcType}_${s.edgeType}_${s.dstType}`
312
- )
313
- })),
314
- undrawn: f
315
- };
316
- }
317
- export {
318
- xe as openCorpus
319
- };
320
- //# sourceMappingURL=duck-source.js.map