@bicharts/chart-host 0.5.118 → 0.5.119

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
@@ -126,11 +126,12 @@ import {
126
126
  scrollFitFor,
127
127
  sessionViewStateProvider,
128
128
  stripEsmExports,
129
+ stripJsComments,
129
130
  svgInkReach,
130
131
  toRGBA,
131
132
  unpinScrolledAxis,
132
133
  valuePlacementFlag
133
- } from "./chunk-2UU3N4AG.mjs";
134
+ } from "./chunk-7ELYQSF5.mjs";
134
135
  import "./chunk-A2GMXZP7.mjs";
135
136
  import "./chunk-GHODWOAL.mjs";
136
137
 
@@ -2343,6 +2344,30 @@ function pendingRecoveryRemainingMs(m2, nowMs) {
2343
2344
  function transportFailureShouldRecover(headersReceived, genNew) {
2344
2345
  return headersReceived && genNew;
2345
2346
  }
2347
+ var TRANSPORT_LOST_CHECKING_MESSAGE = "The connection dropped while your chart was being generated - checking whether it finished on the server...";
2348
+ var GENERATION_CANCELLED_MESSAGE = "The connection dropped before the chart finished - nothing was charged. Generate again.";
2349
+ function recoveryAnswerIsCancelled(r2) {
2350
+ return !!r2 && r2.isGenerationCancelled === true;
2351
+ }
2352
+ function generationCancelledMessage(serverMessage) {
2353
+ const s2 = String(serverMessage ?? "").trim();
2354
+ return s2 !== "" ? s2 : GENERATION_CANCELLED_MESSAGE;
2355
+ }
2356
+
2357
+ // src/chartPick.ts
2358
+ function reconcileChartPick(pick, offered, autoLabel) {
2359
+ const want = String(pick ?? "").trim();
2360
+ if (!want) return { pick: "", dropped: false, message: "" };
2361
+ const names = (offered || []).map((n2) => String(n2 ?? "").trim()).filter((n2) => n2 !== "");
2362
+ if (names.length === 0) return { pick: want, dropped: false, message: "" };
2363
+ const key = want.toLowerCase();
2364
+ if (names.some((n2) => n2.toLowerCase() === key)) return { pick: want, dropped: false, message: "" };
2365
+ return {
2366
+ pick: "",
2367
+ dropped: true,
2368
+ message: `${want} no longer fits this selection, so the chart type is back to "${autoLabel}". Pick another from the list if you want to force one.`
2369
+ };
2370
+ }
2346
2371
 
2347
2372
  // src/index.ts
2348
2373
  function registerCityTable(packed) {
@@ -2387,6 +2412,7 @@ export {
2387
2412
  FILTER_ROW_PX,
2388
2413
  FIT_CONTENT_SELECTOR,
2389
2414
  FLIP_MODE_DEFAULT,
2415
+ GENERATION_CANCELLED_MESSAGE,
2390
2416
  GEO_POINT_PRECISIONS,
2391
2417
  GLYPH_SAMPLE_N,
2392
2418
  HOST_CONTAINER_CLASS,
@@ -2426,6 +2452,7 @@ export {
2426
2452
  SCROLL_SLACK_PX,
2427
2453
  SEASONAL_MARKERS_DEFAULT,
2428
2454
  SELECTION_ACTIVE_CLASS,
2455
+ TRANSPORT_LOST_CHECKING_MESSAGE,
2429
2456
  VALUE_AXIS_BASELINE_DEFAULT,
2430
2457
  VALUE_AXIS_MIN_FIT,
2431
2458
  WHITE_TEXT_BG_LUM,
@@ -2480,6 +2507,7 @@ export {
2480
2507
  fitRenderedChart,
2481
2508
  formatSourceDate,
2482
2509
  formatSourceDateFor,
2510
+ generationCancelledMessage,
2483
2511
  geoAssetFor,
2484
2512
  geoFromCache,
2485
2513
  glyphSampleGrid,
@@ -2537,6 +2565,8 @@ export {
2537
2565
  rasterizeSvgToPngDataUrl,
2538
2566
  readQualifyChartRow,
2539
2567
  readQualifyRefusalRow,
2568
+ reconcileChartPick,
2569
+ recoveryAnswerIsCancelled,
2540
2570
  recoveryOwnsTheSentence,
2541
2571
  recoveryPollRunning,
2542
2572
  refusalIsSelectable,
@@ -2555,6 +2585,7 @@ export {
2555
2585
  shouldOpenInlineChooserOnGenerate,
2556
2586
  shouldReview,
2557
2587
  stripEsmExports,
2588
+ stripJsComments,
2558
2589
  svgInkReach,
2559
2590
  svgNaturalSize,
2560
2591
  svgToDataUrl,
package/dist/react.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createChartHost,
5
5
  geoFromCache,
6
6
  loadGeo
7
- } from "./chunk-2UU3N4AG.mjs";
7
+ } from "./chunk-7ELYQSF5.mjs";
8
8
  import "./chunk-A2GMXZP7.mjs";
9
9
  import "./chunk-GHODWOAL.mjs";
10
10
 
@@ -0,0 +1,28 @@
1
+ /**
2
+ * A standing chart-type pick, checked against a FRESH qualify list.
3
+ *
4
+ * A reader's explicit pick can outlive the generate it was made for - a host that keeps it across a
5
+ * refusal that spent nothing, or one whose pick is a standing control by design. Either way the fields
6
+ * can change underneath it, and a pick the data no longer supports would otherwise cost a generate to
7
+ * discover: the substitution warning arrives after the credit, not before it.
8
+ *
9
+ * ONLY AGAINST A FRESH LIST, and only against the server's own answer. The list is what the qualify
10
+ * endpoint says fits the data as it is now; checking the pick against a client-side re-implementation of
11
+ * the shape gates would be a second opinion quietly disagreeing with the engine.
12
+ *
13
+ * AN EMPTY LIST IS NOT EVIDENCE THE PICK DIED. It is the shape qualifying for nothing, which has its own
14
+ * message and its own fix; dropping the pick there would add a second, misleading sentence.
15
+ *
16
+ * A DROP IS ALWAYS SAID. The message names the type and what the pick went back to, so a pick never
17
+ * disappears silently. `offered` is every name the host would let the reader pick right now - a host whose
18
+ * list also offers poor-fit types to pick anyway passes those too, because the pick is still choosable.
19
+ */
20
+ export interface ChartPickReconciliation {
21
+ /** The pick after reconciling: the original (trimmed) when still offered, else "" (no pick). */
22
+ pick: string;
23
+ /** True when a pick was dropped because the fresh list no longer offers it. */
24
+ dropped: boolean;
25
+ /** What to tell the reader when `dropped`; "" otherwise. */
26
+ message: string;
27
+ }
28
+ export declare function reconcileChartPick(pick: string | null | undefined, offered: readonly (string | null | undefined)[], autoLabel: string): ChartPickReconciliation;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Generated chart code with its JavaScript COMMENTS removed, and nothing else.
3
+ *
4
+ * WHY A HOST NEEDS THIS. A host decides from the code which optional libraries a chart needs before
5
+ * running it (see `requiredD3Plugins`), and a word in a comment is not a call. The helpers a generator
6
+ * prepends to every chart are documented in prose, and prose names things: one helper's comment listed the
7
+ * chart types it serves, "Basic Sankey" among them, so every chart carrying it - bar charts, cards,
8
+ * tables - read as needing the Sankey plugin, and a host fetched a library it would never call on every
9
+ * render.
10
+ *
11
+ * NOT THE NAIVE STRIP, ON PURPOSE. A regex that deletes from `//` to the end of the line also deletes from
12
+ * the `//` inside "https://..." to the end of that line - taking any real code after the string with it.
13
+ * For a check that can only ever REMOVE evidence, over-stripping is the dangerous direction: a plugin name
14
+ * lost that way is a chart failing several frames deep. So this walks the code once, tracking the three
15
+ * places a comment marker is not a comment - a string, a template literal (including code inside its
16
+ * `${...}`), and a regular-expression literal - and removes only what is genuinely a comment.
17
+ *
18
+ * THE ONE AMBIGUITY - is a `/` a division or the start of a regex? - is settled by the usual rule: what
19
+ * came before it. A division misread as a regex only keeps text (the comments after it, up to the next `/`
20
+ * on that line, stay in the output). The reverse - a regex literal that opens a statement right after `)`
21
+ * or `}` - is read as a division, and would lose text only if that regex itself contained `//` or `/*`.
22
+ * Generated chart code does not write that form; it is named here so nobody has to rediscover it.
23
+ *
24
+ * A removed comment is replaced by a single space, keeping any newlines a block comment spanned, so tokens
25
+ * either side never fuse and line numbers are preserved.
26
+ */
27
+ export declare function stripJsComments(code: string): string;
@@ -34,4 +34,6 @@ export { pinScrolledAxis, unpinScrolledAxis, type AxisPinReport } from "./fitDom
34
34
  export { MIN_DELTA_E, pickDistinctColorFromSeed, buildPalette, buildPaletteFromSeed, orderMostDistinct, LEGIBLE_LIGHTNESS, type PaletteResult, type SeedForSlot, type PaletteOptions, } from "./palette";
35
35
  export { deltaEHex } from "./deltaE";
36
36
  export { resolveAutoColorScale, autoRampMinStep, autoRampCanvas, AUTO_RAMP_CLASSES, AUTO_RAMP_DRAWN_OPACITY, AUTO_RAMP_MIN_STEP_DELTA_E, type AutoColorScale, type AutoColorScaleInput } from "./autoRamp";
37
- 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, type PendingGenerateMarker, type PendingRecoveryDecision, type LatePickupAction, } from "./pendingGenerate";
37
+ 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";
38
+ export { stripJsComments } from "./codeComments";
39
+ export { reconcileChartPick, type ChartPickReconciliation } from "./chartPick";
@@ -161,3 +161,31 @@ export declare function pendingRecoveryRemainingMs(m: PendingGenerateMarker, now
161
161
  * headers means the service never saw it, and retrying is the right move.
162
162
  */
163
163
  export declare function transportFailureShouldRecover(headersReceived: boolean, genNew: boolean): boolean;
164
+ /**
165
+ * WHAT A HOST SAYS THE MOMENT A GENERATE'S CONNECTION DROPS - before it knows anything else.
166
+ *
167
+ * It used to promise the chart ("it is still being built on the server ... will show it when it lands").
168
+ * That was never something the host had observed: the server takes a dropped connection as a cancel at its
169
+ * next safe boundary, charges nothing and hands the slot back, so the chart the reader was promised was
170
+ * frequently never going to arrive - and a poll then waited out its whole window for it. The honest sentence
171
+ * is the one that names only what is known: the connection dropped, and the host is checking.
172
+ */
173
+ export declare const TRANSPORT_LOST_CHECKING_MESSAGE = "The connection dropped while your chart was being generated - checking whether it finished on the server...";
174
+ /**
175
+ * The words for a recovery answer that says the generation was cancelled, when the server sent none of its
176
+ * own. The server's errorMessage is preferred - it is the one author of the sentence - and this is the same
177
+ * sentence, for a server that set the flag and left the message blank.
178
+ */
179
+ export declare const GENERATION_CANCELLED_MESSAGE = "The connection dropped before the chart finished - nothing was charged. Generate again.";
180
+ /**
181
+ * Is this recovery answer the server saying the generation was CANCELLED - so nothing will ever be ready?
182
+ *
183
+ * A terminal answer, not a "not yet": the poll stops, the reader is told, and Generate is theirs again. A
184
+ * server that predates the field sends only isVersionNotFound for the same row, which keeps a host polling
185
+ * until its window closes - the old behaviour, no worse. The field's presence is the capability.
186
+ */
187
+ export declare function recoveryAnswerIsCancelled(r: {
188
+ isGenerationCancelled?: boolean | null;
189
+ } | null | undefined): boolean;
190
+ /** The banner for a cancelled generation: the server's own sentence when it sent one, else the same words. */
191
+ export declare function generationCancelledMessage(serverMessage: string | null | undefined): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.5.118",
3
+ "version": "0.5.119",
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",