@bicharts/chart-host 0.6.15 → 0.6.16

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
@@ -2383,6 +2383,23 @@ function reconcileChartPick(pick, offered, autoLabel) {
2383
2383
  };
2384
2384
  }
2385
2385
 
2386
+ // src/duplicateGenerateGuard.ts
2387
+ var DUPLICATE_GENERATE_WINDOW_MS = 2500;
2388
+ function sameRequest(a2, b2) {
2389
+ return a2.schemaHash === b2.schemaHash && a2.gennew === b2.gennew && a2.trycnt === b2.trycnt && a2.favorStyle === b2.favorStyle;
2390
+ }
2391
+ function isDuplicateGenerate(prev, next, now) {
2392
+ if (!prev) return false;
2393
+ if (!sameRequest(prev, next)) return false;
2394
+ if (prev.inFlight) return true;
2395
+ const elapsed = now - prev.startedAt;
2396
+ if (elapsed < 0) return false;
2397
+ return elapsed < DUPLICATE_GENERATE_WINDOW_MS;
2398
+ }
2399
+ function armGenerateGuard(next, now) {
2400
+ return { ...next, startedAt: now, inFlight: true };
2401
+ }
2402
+
2386
2403
  // src/clientIdentity.ts
2387
2404
  function stableFingerprintOptions() {
2388
2405
  return { exclude: ["fonts", "system.useragent", "system.browser.version"], logging: false };
@@ -2450,6 +2467,7 @@ export {
2450
2467
  DARK_TEXT,
2451
2468
  DIM_OPACITY_DEFAULT,
2452
2469
  DIM_OPACITY_VAR,
2470
+ DUPLICATE_GENERATE_WINDOW_MS,
2453
2471
  FILTER_MIN_HEIGHT_PX,
2454
2472
  FILTER_MIN_TERM_CHARS,
2455
2473
  FILTER_MIN_WIDTH_PX,
@@ -2504,6 +2522,7 @@ export {
2504
2522
  XFILTER_REFRESH_EVENT,
2505
2523
  actionFor,
2506
2524
  applyLabelContrast,
2525
+ armGenerateGuard,
2507
2526
  askApplyImprovements,
2508
2527
  assembleD3,
2509
2528
  autoRampCanvas,
@@ -2565,6 +2584,7 @@ export {
2565
2584
  invalidSentinelReason,
2566
2585
  isBlankRender,
2567
2586
  isBlindMarker,
2587
+ isDuplicateGenerate,
2568
2588
  isExcelDateFormat,
2569
2589
  isHorizontalLabelRow,
2570
2590
  isInsideControl,
@@ -0,0 +1,33 @@
1
+ /** What identifies one generate request for suppression purposes. */
2
+ export interface GenerateGuardKey {
3
+ /** Field/column fingerprint. A field change moves this, and must not be suppressed. */
4
+ schemaHash: number;
5
+ /** A fresh generation vs a fetch/regeneration - different intents. */
6
+ gennew: boolean;
7
+ /** The explicit chart-type pick ("" when the picker is free to choose). */
8
+ favorStyle: string;
9
+ /** The retry counter. Differs on every retry, so a retry is never suppressed. */
10
+ trycnt: number;
11
+ }
12
+ /** The last generate a host started, plus whether it is still running. */
13
+ export interface GenerateGuardState extends GenerateGuardKey {
14
+ /** The host's clock (performance.now()) when the call STARTED. */
15
+ startedAt: number;
16
+ /** True from the start of the generate until it settles. */
17
+ inFlight: boolean;
18
+ }
19
+ /** Two calls this close together, with everything else equal, are one user action. */
20
+ export declare const DUPLICATE_GENERATE_WINDOW_MS = 2500;
21
+ /**
22
+ * Should this generate be suppressed as a duplicate of the one before it?
23
+ *
24
+ * Suppress when the request is identical AND either the previous call is still running, or it
25
+ * started within the window. Anything else proceeds.
26
+ *
27
+ * @param prev what the host last started, or null on its first generate
28
+ * @param next the request about to be made
29
+ * @param now the host's clock (performance.now()) at the moment of the call
30
+ */
31
+ export declare function isDuplicateGenerate(prev: GenerateGuardState | null | undefined, next: GenerateGuardKey, now: number): boolean;
32
+ /** The state to record when a generate is allowed to proceed. */
33
+ export declare function armGenerateGuard(next: GenerateGuardKey, now: number): GenerateGuardState;
@@ -38,5 +38,6 @@ export { resolveAutoColorScale, autoRampMinStep, autoRampCanvas, AUTO_RAMP_CLASS
38
38
  export { PENDING_RECOVERY_WINDOW_MS, PENDING_RECOVERY_POLL_MS, PENDING_RECOVERY_FIRST_POLL_MS, PENDING_RECOVERY_FAST_PHASE_MS, PENDING_RECOVERY_MID_POLL_MS, PENDING_RECOVERY_SLOW_PHASE_MS, PENDING_RECOVERY_SLOW_POLL_MS, pendingRecoveryNextDelayMs, encodePendingGenerate, parsePendingGenerate, markerArmedBlind, isBlindMarker, servedCorrelationProves, sameMarker, decidePendingRecovery, recoveryPollRunning, recoveryOwnsTheSentence, latePickupAction, latePickupKeepsMarker, pollGiveUpKeepsMarker, pendingRecoveryRemainingMs, transportFailureShouldRecover, TRANSPORT_LOST_CHECKING_MESSAGE, GENERATION_CANCELLED_MESSAGE, recoveryAnswerIsCancelled, generationCancelledMessage, type PendingGenerateMarker, type PendingRecoveryDecision, type LatePickupAction, } from "./pendingGenerate";
39
39
  export { stripJsComments } from "./codeComments";
40
40
  export { reconcileChartPick, type ChartPickReconciliation } from "./chartPick";
41
+ export { isDuplicateGenerate, armGenerateGuard, DUPLICATE_GENERATE_WINDOW_MS, type GenerateGuardKey, type GenerateGuardState, } from "./duplicateGenerateGuard";
41
42
  export { stableFingerprintOptions, fingerprintComponentDigest, type ClientIdSource } from "./clientIdentity";
42
43
  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.15",
3
+ "version": "0.6.16",
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",