@bicharts/chart-host 0.6.23 → 0.6.24

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/dist/index.mjs CHANGED
@@ -2408,6 +2408,25 @@ function shouldRestoreVersionAfterLicenseSave(currentVersionValue, cachedVersion
2408
2408
  return (currentVersionValue ?? 0) === 0 && canShowLastChart(cachedVersionPersisted, cachedCodePersisted);
2409
2409
  }
2410
2410
 
2411
+ // src/filterNarrowing.ts
2412
+ function isNarrowedByFilter(s2) {
2413
+ if (s2.highWaterSchemaHash === null || s2.highWaterSchemaHash !== s2.currentSchemaHash) return false;
2414
+ if (!(s2.highWaterRows > 0)) return false;
2415
+ if (!(s2.currentRows > 0)) return false;
2416
+ return s2.currentRows < s2.highWaterRows;
2417
+ }
2418
+ function isEmptiedByFilter(s2) {
2419
+ if (s2.highWaterSchemaHash === null || s2.highWaterSchemaHash !== s2.currentSchemaHash) return false;
2420
+ if (!(s2.highWaterRows > 0)) return false;
2421
+ return s2.currentRows <= 0;
2422
+ }
2423
+ function updateRowHighWater(prevRows, prevSchemaHash, currentRows, currentSchemaHash) {
2424
+ if (prevSchemaHash !== currentSchemaHash) {
2425
+ return { rows: currentRows, schemaHash: currentSchemaHash };
2426
+ }
2427
+ return { rows: Math.max(prevRows, currentRows), schemaHash: currentSchemaHash };
2428
+ }
2429
+
2411
2430
  // src/clientIdentity.ts
2412
2431
  function stableFingerprintOptions() {
2413
2432
  return { exclude: ["fonts", "system.useragent", "system.browser.version"], logging: false };
@@ -2594,10 +2613,12 @@ export {
2594
2613
  isBlankRender,
2595
2614
  isBlindMarker,
2596
2615
  isDuplicateGenerate,
2616
+ isEmptiedByFilter,
2597
2617
  isExcelDateFormat,
2598
2618
  isHorizontalLabelRow,
2599
2619
  isInsideControl,
2600
2620
  isInvalidSentinelError,
2621
+ isNarrowedByFilter,
2601
2622
  isPhantomBox,
2602
2623
  isPillBackdropAlpha,
2603
2624
  labelBand,
@@ -2674,6 +2695,7 @@ export {
2674
2695
  toSourceRows,
2675
2696
  transportFailureShouldRecover,
2676
2697
  unpinScrolledAxis,
2698
+ updateRowHighWater,
2677
2699
  valuePlacementFlag,
2678
2700
  vegaSpecReadsDatesInLocalTime,
2679
2701
  withoutViewOnlyKeys
@@ -0,0 +1,38 @@
1
+ export interface NarrowingState {
2
+ /** Row count of the dataset just delivered. */
3
+ currentRows: number;
4
+ /** Most rows ever seen for highWaterSchemaHash (0 = nothing recorded yet). */
5
+ highWaterRows: number;
6
+ /** Schema the high water was recorded against (null = nothing recorded yet). */
7
+ highWaterSchemaHash: number | null;
8
+ /** Schema of the dataset just delivered. */
9
+ currentSchemaHash: number;
10
+ }
11
+ /**
12
+ * True when the current dataset is a strict, non-empty subset of the largest one this schema has
13
+ * produced - a slicer or cross-filter is narrowing the data right now, and the chart is drawable but
14
+ * thin. Zero rows is a different state with its own predicate, `isEmptiedByFilter`, so neither caller
15
+ * has to re-check a row count to learn which question it got an answer to.
16
+ */
17
+ export declare function isNarrowedByFilter(s: NarrowingState): boolean;
18
+ /**
19
+ * True when the dataset has been filtered away to NOTHING - same schema, a positive high water, and
20
+ * zero rows now.
21
+ *
22
+ * Filtered-to-nothing is legitimately empty, but it is not indistinguishable from an empty dataset,
23
+ * and treating it as one cost a reader the connection between their own click and the chart that
24
+ * then read a flat "no data". The evidence needed is the SAME high-water signal: at zero rows, on an
25
+ * unchanged schema, a positive high water means this schema HAS delivered rows before and does not
26
+ * now. Only a filter does that. A changed schema resets the high water, so field drift reads a high
27
+ * water of 0 here and keeps the plain no-data wording.
28
+ */
29
+ export declare function isEmptiedByFilter(s: NarrowingState): boolean;
30
+ /**
31
+ * Roll the high-water mark forward for a completed load. Resets (rather than maxing) when the schema
32
+ * changes, so a field swap cannot leave a stale baseline from the previous schema making every later
33
+ * load look narrowed.
34
+ */
35
+ export declare function updateRowHighWater(prevRows: number, prevSchemaHash: number | null, currentRows: number, currentSchemaHash: number): {
36
+ rows: number;
37
+ schemaHash: number;
38
+ };
@@ -40,5 +40,6 @@ export { stripJsComments } from "./codeComments";
40
40
  export { reconcileChartPick, type ChartPickReconciliation } from "./chartPick";
41
41
  export { isDuplicateGenerate, armGenerateGuard, DUPLICATE_GENERATE_WINDOW_MS, type GenerateGuardKey, type GenerateGuardState, } from "./duplicateGenerateGuard";
42
42
  export { canShowLastChart, shouldRestoreVersionAfterLicenseSave } from "./lastChart";
43
+ export { isNarrowedByFilter, isEmptiedByFilter, updateRowHighWater, type NarrowingState, } from "./filterNarrowing";
43
44
  export { stableFingerprintOptions, fingerprintComponentDigest, type ClientIdSource } from "./clientIdentity";
44
45
  export type { HostServices, MarkerStore, PreferenceSource, HostTheme, ThemeSource, ThumbnailConsent, SnapshotTarget, WireSigner, WireTransport, WireResponse, CredentialTriple, CredentialSource, ViewportSource, Clock, DiagnosticEntry, DiagnosticsSink, RendererId, } from "./host/services";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.6.23",
3
+ "version": "0.6.24",
4
4
  "description": "Run a BIC-generated D3 chart in any web host: compiles the generated render() function, applies the shared option defaults, resolves mark clicks (through tooltip overlays), owns the selection affordance, and translates row indices between cross-filtered charts. The same contract the BIC Power BI visual implements, minus Power BI. React bindings at @bicharts/chart-host/react.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",