@fjader/svelte 0.2.2 → 0.2.4

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 (148) hide show
  1. package/README.md +2 -0
  2. package/dist/components/axes/AxisBottom.svelte +23 -6
  3. package/dist/components/axes/AxisBottom.svelte.d.ts +10 -0
  4. package/dist/components/axes/AxisLeft.svelte +77 -8
  5. package/dist/components/axes/AxisLeft.svelte.d.ts +17 -0
  6. package/dist/components/axes/BandAxisTicks.svelte +64 -25
  7. package/dist/components/axes/BandAxisTicks.svelte.d.ts +5 -5
  8. package/dist/components/axes/axis-title.d.ts +30 -0
  9. package/dist/components/axes/axis-title.js +77 -0
  10. package/dist/components/charts/ChartCell.svelte +1 -1
  11. package/dist/components/charts/ChartContainer.svelte +12 -3
  12. package/dist/components/charts/ChartContainer.svelte.d.ts +7 -0
  13. package/dist/components/guides/legend/ContinuousColorLegend.svelte +9 -2
  14. package/dist/components/guides/legend/OrdinalColorLegend.svelte +96 -35
  15. package/dist/components/marks/AreaMarkX.svelte +21 -6
  16. package/dist/components/marks/AreaMarkY.svelte +21 -6
  17. package/dist/components/marks/BarMarkX.svelte +16 -1
  18. package/dist/components/marks/BarMarkY.svelte +16 -1
  19. package/dist/components/marks/DotsMark.svelte +5 -0
  20. package/dist/components/marks/LineMark.svelte +8 -1
  21. package/dist/components/marks/ParallelCoordinatesMark.svelte +10 -0
  22. package/dist/components/marks/ParallelCoordinatesMark.svelte.d.ts +5 -0
  23. package/dist/components/marks/RectMark.svelte +5 -0
  24. package/dist/components/marks/RectXMark.svelte +5 -0
  25. package/dist/components/marks/RectYMark.svelte +5 -0
  26. package/dist/components/marks/RuleMarkX.svelte +12 -2
  27. package/dist/components/marks/RuleMarkY.svelte +12 -2
  28. package/dist/components/marks/TextMark.svelte +76 -13
  29. package/dist/components/marks/lifecycle/MarkLifecycleV2.svelte.d.ts +21 -2
  30. package/dist/components/marks/lifecycle/MarkLifecycleV2.svelte.js +300 -42
  31. package/dist/components/marks/lifecycle/domain-queries.d.ts +3 -1
  32. package/dist/components/marks/lifecycle/domain-queries.js +22 -15
  33. package/dist/components/marks/lifecycle/domain-registration.js +2 -6
  34. package/dist/components/marks/lifecycle/other-rows.svelte.d.ts +104 -0
  35. package/dist/components/marks/lifecycle/other-rows.svelte.js +193 -0
  36. package/dist/components/marks/lifecycle/other-split.d.ts +80 -0
  37. package/dist/components/marks/lifecycle/other-split.js +112 -0
  38. package/dist/components/marks/lifecycle/query-builder.d.ts +26 -1
  39. package/dist/components/marks/lifecycle/query-builder.js +25 -5
  40. package/dist/components/marks/lifecycle/transform-scale-key.d.ts +16 -0
  41. package/dist/components/marks/lifecycle/transform-scale-key.js +27 -0
  42. package/dist/components/marks/utils/area-outline.d.ts +24 -0
  43. package/dist/components/marks/utils/area-outline.js +10 -0
  44. package/dist/components/marks/utils/reactive-config.d.ts +1 -1
  45. package/dist/components/marks/utils/reactive-config.js +9 -0
  46. package/dist/components/marks/utils/tooltip-helpers.d.ts +4 -1
  47. package/dist/components/marks/utils/tooltip-helpers.js +2 -1
  48. package/dist/components/rendering/Areas.svelte +30 -6
  49. package/dist/components/rendering/Areas.svelte.d.ts +2 -0
  50. package/dist/components/rendering/BaseGPURenderer.svelte.d.ts +3 -1
  51. package/dist/components/rendering/BaseGPURenderer.svelte.js +8 -3
  52. package/dist/components/rendering/Dots.svelte +24 -3
  53. package/dist/components/rendering/Dots.svelte.d.ts +2 -0
  54. package/dist/components/rendering/GridLine.svelte +2 -1
  55. package/dist/components/rendering/Lines.svelte +49 -7
  56. package/dist/components/rendering/Lines.svelte.d.ts +9 -0
  57. package/dist/components/rendering/ParallelLines.svelte +26 -7
  58. package/dist/components/rendering/ParallelLines.svelte.d.ts +2 -0
  59. package/dist/components/rendering/Rects.svelte +129 -20
  60. package/dist/components/rendering/Rects.svelte.d.ts +9 -0
  61. package/dist/components/rendering/RuleX.svelte +20 -5
  62. package/dist/components/rendering/RuleX.svelte.d.ts +2 -0
  63. package/dist/components/rendering/RuleY.svelte +20 -5
  64. package/dist/components/rendering/RuleY.svelte.d.ts +2 -0
  65. package/dist/components/rendering/activity-reads.d.ts +111 -0
  66. package/dist/components/rendering/activity-reads.js +154 -0
  67. package/dist/components/rendering/uniform-sizes.d.ts +26 -0
  68. package/dist/components/rendering/uniform-sizes.js +28 -0
  69. package/dist/config/ChartConfig.svelte.d.ts +5 -1
  70. package/dist/gpu/ColorScaleShaderLib.d.ts +13 -1
  71. package/dist/gpu/ColorScaleShaderLib.js +56 -5
  72. package/dist/gpu/GPUCoordinator.svelte.d.ts +8 -0
  73. package/dist/gpu/GPUCoordinator.svelte.js +68 -32
  74. package/dist/gpu/MorphedChannels.d.ts +6 -32
  75. package/dist/gpu/MorphedChannels.js +45 -3
  76. package/dist/gpu/ResolveShader.d.ts +2 -2
  77. package/dist/gpu/ResolveShader.js +2 -2
  78. package/dist/gpu/ScaleTemplateSystem.d.ts +19 -0
  79. package/dist/gpu/ScaleTemplateSystem.js +111 -11
  80. package/dist/gpu/SizeScaleShaderLib.d.ts +4 -4
  81. package/dist/gpu/SizeScaleShaderLib.js +4 -4
  82. package/dist/gpu/identity-slot-packing.d.ts +157 -40
  83. package/dist/gpu/identity-slot-packing.js +262 -62
  84. package/dist/gpu/tracked-scales.d.ts +14 -0
  85. package/dist/gpu/tracked-scales.js +18 -0
  86. package/dist/index.d.ts +2 -0
  87. package/dist/index.js +4 -0
  88. package/dist/interactors/BandLabelToggle.svelte +5 -9
  89. package/dist/interactors/BandLabelToggle.svelte.d.ts +3 -3
  90. package/dist/interactors/DerivedInterval1D.svelte +26 -54
  91. package/dist/interactors/Interval1D.svelte +8 -2
  92. package/dist/interactors/Interval2D.svelte +8 -2
  93. package/dist/interactors/ParallelAxisSource.svelte +14 -5
  94. package/dist/interactors/ParallelAxisSource.svelte.d.ts +2 -1
  95. package/dist/interactors/ParallelBrushes.svelte +8 -9
  96. package/dist/interactors/ParallelBrushes.svelte.d.ts +3 -3
  97. package/dist/interactors/Toggle.svelte +48 -38
  98. package/dist/interactors/Toggle.svelte.d.ts +4 -3
  99. package/dist/interactors/Tooltip.svelte +140 -42
  100. package/dist/interactors/TooltipManager.svelte.d.ts +20 -5
  101. package/dist/interactors/TooltipManager.svelte.js +40 -10
  102. package/dist/interactors/other-tooltip.d.ts +16 -0
  103. package/dist/interactors/other-tooltip.js +22 -0
  104. package/dist/interactors/relay-clauses.d.ts +23 -0
  105. package/dist/interactors/relay-clauses.js +60 -0
  106. package/dist/query-engine/CrossfilterSelection.svelte.d.ts +88 -15
  107. package/dist/query-engine/CrossfilterSelection.svelte.js +94 -20
  108. package/dist/query-engine/FieldActivity.svelte.d.ts +128 -0
  109. package/dist/query-engine/FieldActivity.svelte.js +378 -0
  110. package/dist/query-engine/FilterGroup.svelte.d.ts +76 -30
  111. package/dist/query-engine/FilterGroup.svelte.js +223 -124
  112. package/dist/query-engine/FilterGroupRegistry.svelte.d.ts +73 -3
  113. package/dist/query-engine/FilterGroupRegistry.svelte.js +161 -12
  114. package/dist/query-engine/MarkHandle.svelte.d.ts +9 -1
  115. package/dist/query-engine/MarkHandle.svelte.js +12 -2
  116. package/dist/query-engine/QueryEngine.d.ts +52 -16
  117. package/dist/query-engine/QueryEngine.js +116 -34
  118. package/dist/query-engine/categorical-identity.d.ts +114 -27
  119. package/dist/query-engine/categorical-identity.js +225 -51
  120. package/dist/query-engine/index.d.ts +2 -1
  121. package/dist/query-engine/index.js +1 -0
  122. package/dist/query-engine/preagg/Preagg.d.ts +1 -1
  123. package/dist/query-engine/preagg/Preagg.js +11 -9
  124. package/dist/query-engine/preagg/plan.d.ts +14 -5
  125. package/dist/query-engine/preagg/plan.js +44 -18
  126. package/dist/query-engine/toggle-predicate.d.ts +21 -0
  127. package/dist/query-engine/toggle-predicate.js +41 -2
  128. package/dist/scales/ActivityTable.d.ts +103 -0
  129. package/dist/scales/ActivityTable.js +220 -0
  130. package/dist/scales/BandScaleState.svelte.d.ts +41 -15
  131. package/dist/scales/BandScaleState.svelte.js +78 -36
  132. package/dist/scales/ChartScales.svelte.d.ts +2 -2
  133. package/dist/scales/ColorScaleState.svelte.d.ts +36 -8
  134. package/dist/scales/ColorScaleState.svelte.js +118 -24
  135. package/dist/scales/DomainResolver.d.ts +2 -0
  136. package/dist/scales/DomainResolver.js +15 -8
  137. package/dist/scales/ScaleRegistry.svelte.d.ts +9 -0
  138. package/dist/scales/ScaleRegistry.svelte.js +22 -1
  139. package/dist/scales/TimeScaleState.svelte.js +7 -1
  140. package/dist/spec/index.js +1 -0
  141. package/dist/spec/types.d.ts +4 -0
  142. package/dist/theme.css +5 -4
  143. package/dist/transforms/TransformCompiler.d.ts +37 -2
  144. package/dist/transforms/TransformCompiler.js +44 -1
  145. package/dist/transforms/index.d.ts +27 -0
  146. package/dist/transforms/index.js +127 -19
  147. package/dist/types.d.ts +71 -0
  148. package/package.json +3 -2
@@ -11,14 +11,16 @@
11
11
  * later tables APPEND unseen values with continuing ids. It never reorders and
12
12
  * never renumbers, so an id already baked into a vertex buffer stays valid and
13
13
  * no earlier mark has to requery. `value` carries the source column's own type
14
- * and `label` is NULL, except on a synthetic row (`reserveSynthetic`), where
15
- * that is inverted.
14
+ * and `label` is NULL, except on a synthetic row (`acquireSynthetic`), where
15
+ * that is inverted, and on the NULL category's row, where both are NULL.
16
16
  *
17
17
  * 2. A **per-table view**, `<table>_v_s<session>`, selecting `*` plus one
18
18
  * `__dplot_<field>_idx` column per requested field. Always LEFT JOIN with
19
19
  * COALESCE(-1): an inner join silently drops rows whose value is not in the
20
- * dim (NULLs, values added later), which is data loss presenting as a
21
- * rendering bug. -1 is the unmapped sentinel, unified in `1ac4fd4`.
20
+ * dim (a value a later append will add), which is data loss presenting as a
21
+ * rendering bug. -1 is the unmapped sentinel, unified in `1ac4fd4`. A NULL
22
+ * value is not unmapped: the dim has a row for it (value NULL, label NULL),
23
+ * joined with IS NOT DISTINCT FROM, so NULL is a category like any other.
22
24
  *
23
25
  * 3. An **additive coalescer**, `ensureColumns()`. Concurrent callers union into
24
26
  * a pending set, one CREATE OR REPLACE VIEW runs with the full union, and a
@@ -41,6 +43,18 @@
41
43
  * the series scale all read the same columns from the same dim, and none of
42
44
  * them is special-cased here.
43
45
  */
46
+ /**
47
+ * A synthetic id handed out by `acquireSynthetic`: what to release it with.
48
+ * `generation` ties it to the dims it was acquired from, so a release after a
49
+ * reset does not offer a dropped row to the next acquire.
50
+ */
51
+ export interface SyntheticId {
52
+ readonly field: string;
53
+ readonly id: number;
54
+ /** The label it displays: the requested one, or `"<label> (rest)"` beside a real one. */
55
+ readonly label: string;
56
+ readonly generation: number;
57
+ }
44
58
  /** The subset of QueryEngine this module needs. Keeps it testable in isolation. */
45
59
  export interface IdentityExec {
46
60
  exec(sql: string | string[]): Promise<void>;
@@ -89,7 +103,15 @@ export interface IdentityField {
89
103
  * (SameValueZero, which covers bigint). That is why the round trip is correct
90
104
  * today; it is the declared types that were wrong.
91
105
  */
92
- export type DimValue = string | number | bigint;
106
+ export type DimValue = string | number | bigint | null;
107
+ /**
108
+ * How a category value is shown: as itself, except the NULL category, which has
109
+ * no text of its own. The one formatter for axis ticks, legend entries, facet
110
+ * labels and tooltips, so NULL reads the same everywhere. Selections keep the
111
+ * raw `null`: this is display only.
112
+ */
113
+ export declare const NULL_CATEGORY_LABEL = "(null)";
114
+ export declare function categoryLabel<T>(value: T): T | string;
93
115
  /**
94
116
  * A field's id <-> value bijection, both directions in one object.
95
117
  *
@@ -105,11 +127,32 @@ export type DimValue = string | number | bigint;
105
127
  * once and stay correct when a second table appends to the dim.
106
128
  */
107
129
  export declare class FieldIdentity {
108
- /** id -> source value. Dense and 0-based, so position is the id. */
130
+ /**
131
+ * id -> source value. Dense and 0-based, so position is the id. A synthetic
132
+ * id (an Other bucket) holds its display label here.
133
+ */
109
134
  readonly values: DimValue[];
110
- /** source value -> id. The exact inverse of `values`. */
135
+ /**
136
+ * source value -> id, for real values only: the inverse of `values` with the
137
+ * synthetic ids left out. A label is not a value, and several synthetic ids
138
+ * may share one, so nothing resolves a bucket by its label.
139
+ */
111
140
  readonly ids: Map<DimValue, number>;
112
- constructor(values?: readonly DimValue[]);
141
+ /** The synthetic ids (Other buckets): rows of the dim no source row joins to. */
142
+ readonly synthetic: Set<number>;
143
+ /**
144
+ * The NULL category's id, or null while the data has no NULL. An ordinary
145
+ * category: ranked, drawn, selectable; `values[nullId]` is `null`, and `ids`
146
+ * maps `null` to it, so value lookups need no special case.
147
+ */
148
+ nullId: number | null;
149
+ /**
150
+ * The identity key this is the bijection for, as `identityKeyFor` derives
151
+ * it: what a scale that adopted it is keyed by for selection activity.
152
+ * Empty for one built outside the engine, as tests do.
153
+ */
154
+ readonly key: string;
155
+ constructor(values?: readonly DimValue[], key?: string);
113
156
  /**
114
157
  * Bumped by `reset`, so a holder of this LIVE object can tell whether it
115
158
  * moved since it last looked. Appends, a same-length replacement and an
@@ -117,16 +160,21 @@ export declare class FieldIdentity {
117
160
  * comparing `values.length` is not.
118
161
  */
119
162
  version: number;
120
- /** Replace both directions. The only writer. */
121
- reset(values: readonly DimValue[]): void;
163
+ /**
164
+ * Replace both directions. The only writer. `synthetic` names the ids that
165
+ * are buckets rather than values: they keep their label in `values` and stay
166
+ * out of `ids`.
167
+ */
168
+ reset(values: readonly DimValue[], synthetic?: Iterable<number>): void;
122
169
  /** True once the dim has been built and holds at least one value. */
123
170
  get present(): boolean;
124
171
  }
125
172
  /**
126
- * Above this many distinct values a band axis is refused outright.
127
- * The shared slot buffer holds 16384 floats across every band and point scale,
128
- * so a single axis this large cannot render whatever else is on the page — the
129
- * limit is capacity, not taste.
173
+ * Above this many distinct values a band axis is refused outright. The shared
174
+ * slot buffer (IDENTITY_SLOT_CAPACITY floats) holds every band and point
175
+ * scale's slots and every selected field's activity, one run per filter group,
176
+ * so an axis this large would crowd out the rest of the page — the limit is
177
+ * capacity, not taste.
130
178
  */
131
179
  export declare const MAX_IDENTITY_CARDINALITY = 10000;
132
180
  /**
@@ -148,9 +196,9 @@ export declare class CategoricalIdentity {
148
196
  /** SQL producing `field`'s value, once a mark has registered it; undefined before. */
149
197
  sqlFor(field: string): string | undefined;
150
198
  /**
151
- * Whether `field`'s dim has folded in `table`, so every non-NULL value the
152
- * table holds has an id and `-1` can only mean NULL. A dim another table
153
- * built may lack this table's values; a refused dim covers nothing.
199
+ * Whether `field`'s dim has folded in `table`, so every value the table holds,
200
+ * NULL included, has an id and `-1` never appears. A dim another table built
201
+ * may lack this table's values; a refused dim covers nothing.
154
202
  */
155
203
  dimCovers(field: string, table: string): boolean;
156
204
  /** The field whose id column is `column`, or null if no dim has that column. */
@@ -159,6 +207,14 @@ export declare class CategoricalIdentity {
159
207
  viewHas(table: string, field: string): boolean;
160
208
  /** Name of the dim table for `field`. */
161
209
  dimTable(field: string): string;
210
+ /**
211
+ * The table of ids `table` holds for `field`, or null before that table has
212
+ * folded into the dim. What `dense()` pads from, so a chart never pads a
213
+ * category only another table has.
214
+ */
215
+ presentTable(field: string, table: string): string | null;
216
+ /** The ids `table` holds for `field`, or null before that table has folded in. */
217
+ presentIds(field: string, table: string): ReadonlySet<number> | null;
162
218
  /** Name of the view that carries id columns for `table`. */
163
219
  viewTable(table: string): string;
164
220
  /**
@@ -188,6 +244,12 @@ export declare class CategoricalIdentity {
188
244
  * it before the dim exists.
189
245
  */
190
246
  identity(field: string): FieldIdentity;
247
+ /**
248
+ * The field's current bijection, or null if nothing has asked for it since
249
+ * the last reset. Unlike `identity`, never creates one: for a holder checking
250
+ * whether the identity it applied is still the live one, on every frame.
251
+ */
252
+ peekIdentity(field: string): FieldIdentity | null;
191
253
  /** Fields the view for `table` currently exposes. Empty when there is no view. */
192
254
  columnsFor(table: string): string[];
193
255
  /**
@@ -200,24 +262,49 @@ export declare class CategoricalIdentity {
200
262
  categorical?: (string | IdentityField)[];
201
263
  }): Promise<void>;
202
264
  /**
203
- * Reserve an id for a value that exists in no table — the synthetic "Other"
204
- * bucket a `topN({ includeOthers })` produces.
265
+ * Acquire an id for a value that exists in no table — the synthetic "Other"
266
+ * bucket a `topN({ includeOthers })` produces — and return it with the label
267
+ * it displays.
268
+ *
269
+ * A released id with the same label is reused before a dim row is inserted,
270
+ * so remounting a chart does not grow the dim or the field's activity block.
271
+ * Keyed by label too, so a reused id never needs relabelling.
205
272
  *
206
- * Goes through the same writer as every other id, so `values(f)[otherId]` is
207
- * the label and no consumer has to know it was synthetic. Serialized on the
208
- * per-field chain, so it cannot interleave with an append.
273
+ * Goes through the same writer as every other id, so `values(f)[id]` is the
274
+ * label; `synthetic` records that it is a bucket, which keeps it out of the
275
+ * value -> id map. Serialized on the per-field chain, so it cannot interleave
276
+ * with an append.
209
277
  *
210
278
  * Non-negative by construction: `scaleBand` discards `value < 0.0` before the
211
279
  * slot lookup, so a negative sentinel could never render.
212
280
  *
213
- * **Reuses the id if a real category already carries this label**, rather
214
- * than inserting a duplicate value — see the fan-out note above. Callers get
215
- * an id that may already be in the data, which the transform has to fold
216
- * into rather than append beside.
281
+ * **A real category carrying the label stays a category.** The bucket takes
282
+ * `"<label> (rest)"` instead, so two bars never share a label and the real
283
+ * one stays selectable. The check runs at acquire; a reload re-acquires.
217
284
  *
218
285
  * Requires the dim to exist: call after `ensureColumns` has resolved.
219
286
  */
220
- reserveSynthetic(field: string, label: string): Promise<number>;
287
+ acquireSynthetic(field: string, label: string): Promise<SyntheticId>;
288
+ /**
289
+ * Give an acquired id back for the next acquire of the same label. One from
290
+ * before a reset names a row of a dropped dim, and is ignored.
291
+ */
292
+ releaseSynthetic(synthetic: SyntheticId): void;
293
+ /**
294
+ * Re-read the dim into the field's value array, mutating in place.
295
+ *
296
+ * Re-reading the whole dim rather than only the new rows: categorical
297
+ * cardinality is small, this runs once per (field, table) pair at setup, and
298
+ * a full read cannot drift out of sync with the ids the way an incremental
299
+ * one can if an append is ever missed.
300
+ */
301
+ /**
302
+ * Bumped whenever a dim's rows change: a table folding in, an Other bucket
303
+ * reserved, a reset. A query that reads a dim (dense padding, an id join)
304
+ * returns different rows afterwards under the same SQL text, so whatever
305
+ * caches results by that text must also key on this. Only ever increases.
306
+ */
307
+ get version(): number;
221
308
  /**
222
309
  * Drop every view and dim and forget all state. Called on data reload, where
223
310
  * the ids are stale by definition — the same values may not exist any more,