@bicharts/chart-host 0.6.21 → 0.6.23

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
@@ -2386,7 +2386,7 @@ function reconcileChartPick(pick, offered, autoLabel) {
2386
2386
  // src/duplicateGenerateGuard.ts
2387
2387
  var DUPLICATE_GENERATE_WINDOW_MS = 2500;
2388
2388
  function sameRequest(a2, b2) {
2389
- return a2.schemaHash === b2.schemaHash && a2.gennew === b2.gennew && a2.trycnt === b2.trycnt && a2.favorStyle === b2.favorStyle;
2389
+ return a2.schemaHash === b2.schemaHash && a2.gennew === b2.gennew && a2.trycnt === b2.trycnt && a2.favorStyle === b2.favorStyle && (a2.intent ?? "") === (b2.intent ?? "") && (a2.text ?? "") === (b2.text ?? "");
2390
2390
  }
2391
2391
  function isDuplicateGenerate(prev, next, now) {
2392
2392
  if (!prev) return false;
@@ -2400,6 +2400,14 @@ function armGenerateGuard(next, now) {
2400
2400
  return { ...next, startedAt: now, inFlight: true };
2401
2401
  }
2402
2402
 
2403
+ // src/lastChart.ts
2404
+ function canShowLastChart(cachedVersionPersisted, cachedCodePersisted) {
2405
+ return (cachedVersionPersisted ?? 0) > 0 && String(cachedCodePersisted ?? "").trim() !== "";
2406
+ }
2407
+ function shouldRestoreVersionAfterLicenseSave(currentVersionValue, cachedVersionPersisted, cachedCodePersisted) {
2408
+ return (currentVersionValue ?? 0) === 0 && canShowLastChart(cachedVersionPersisted, cachedCodePersisted);
2409
+ }
2410
+
2403
2411
  // src/clientIdentity.ts
2404
2412
  function stableFingerprintOptions() {
2405
2413
  return { exclude: ["fonts", "system.useragent", "system.browser.version"], logging: false };
@@ -2537,6 +2545,7 @@ export {
2537
2545
  buildRenderPayload,
2538
2546
  buildReviewWire,
2539
2547
  canConfirmLaunch,
2548
+ canShowLastChart,
2540
2549
  captureSvgSnapshot,
2541
2550
  cellSuppressesNormalize,
2542
2551
  censusColourSpread,
@@ -2652,6 +2661,7 @@ export {
2652
2661
  sessionViewStateProvider,
2653
2662
  shouldOpenChooserOnGenerate,
2654
2663
  shouldOpenInlineChooserOnGenerate,
2664
+ shouldRestoreVersionAfterLicenseSave,
2655
2665
  shouldReview,
2656
2666
  stableFingerprintOptions,
2657
2667
  stripEsmExports,
@@ -8,6 +8,17 @@ export interface GenerateGuardKey {
8
8
  favorStyle: string;
9
9
  /** The retry counter. Differs on every retry, so a retry is never suppressed. */
10
10
  trycnt: number;
11
+ /**
12
+ * Anything else the host's request asks for that makes it a different request - an adjustment's
13
+ * intent, a chosen projection. Absent and "" are the same. A host that keys only on the fields
14
+ * above passes none, and its guard behaves exactly as before.
15
+ */
16
+ intent?: string;
17
+ /**
18
+ * The reader's typed request text. A different text is a different request and always passes.
19
+ * Absent and "" are the same.
20
+ */
21
+ text?: string;
11
22
  }
12
23
  /** The last generate a host started, plus whether it is still running. */
13
24
  export interface GenerateGuardState extends GenerateGuardKey {
@@ -39,5 +39,6 @@ export { PENDING_RECOVERY_WINDOW_MS, PENDING_RECOVERY_POLL_MS, PENDING_RECOVERY_
39
39
  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
+ export { canShowLastChart, shouldRestoreVersionAfterLicenseSave } from "./lastChart";
42
43
  export { stableFingerprintOptions, fingerprintComponentDigest, type ClientIdSource } from "./clientIdentity";
43
44
  export type { HostServices, MarkerStore, PreferenceSource, HostTheme, ThemeSource, ThumbnailConsent, SnapshotTarget, WireSigner, WireTransport, WireResponse, CredentialTriple, CredentialSource, ViewportSource, Clock, DiagnosticEntry, DiagnosticsSink, RendererId, } from "./host/services";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Should the "show last chart" way back be offered?
3
+ *
4
+ * @param cachedVersionPersisted the PERSISTED cached version (not live render state)
5
+ * @param cachedCodePersisted the PERSISTED cached code (not live render state)
6
+ *
7
+ * True when a positive version is cached and its code is not blank.
8
+ */
9
+ export declare function canShowLastChart(cachedVersionPersisted: number | null | undefined, cachedCodePersisted: string | null | undefined): boolean;
10
+ /**
11
+ * After a licence is saved, should the host restore the cached version on its own?
12
+ *
13
+ * Only when the current version is 0 (missing reads as 0) - the reader was parked on the landing
14
+ * state - and there is a last chart to go back to (`canShowLastChart`).
15
+ */
16
+ export declare function shouldRestoreVersionAfterLicenseSave(currentVersionValue: number | null | undefined, cachedVersionPersisted: number | null | undefined, cachedCodePersisted: string | null | undefined): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.6.21",
3
+ "version": "0.6.23",
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",