@bicharts/chart-host 0.2.0 → 0.3.0
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/README.md +13 -0
- package/dist/{chunk-ARQZJCD4.mjs → chunk-4DULDBNH.mjs} +10 -0
- package/dist/index.mjs +5 -1
- package/dist/react.mjs +1 -1
- package/dist/types/host.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -120,6 +120,19 @@ The integration contract returned by `generate_chart` names exactly which ones *
|
|
|
120
120
|
needs. If one is missing, the host throws a message naming the package instead of a bare
|
|
121
121
|
`d3.sankey is not a function`.
|
|
122
122
|
|
|
123
|
+
You can also ask the code itself, *before* rendering it — which is what you want when the chart
|
|
124
|
+
arrives at run time and a blank frame is not an acceptable answer:
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
import { requiredD3Plugins } from "@bicharts/chart-host";
|
|
128
|
+
|
|
129
|
+
requiredD3Plugins(code); // -> ["d3-sankey"] (sorted, deduped, [] for core-only d3)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
It is a static scan, not a trial render: synchronous, side-effect free, and safe to run on
|
|
133
|
+
generated code you have not executed yet. It errs toward naming a plugin the chart may not
|
|
134
|
+
reach — a needless install is cheaper than a blank chart.
|
|
135
|
+
|
|
123
136
|
## Selection styling
|
|
124
137
|
|
|
125
138
|
Generated code emits marks and `data-row-idx`; it never styles "selected", because only the host
|
|
@@ -742,6 +742,14 @@ var D3_PLUGIN_PACKAGES = {
|
|
|
742
742
|
voronoiMap: "d3-voronoi-map",
|
|
743
743
|
weightedVoronoi: "d3-weighted-voronoi"
|
|
744
744
|
};
|
|
745
|
+
function requiredD3Plugins(code) {
|
|
746
|
+
const out = /* @__PURE__ */ new Set();
|
|
747
|
+
for (const m3 of String(code || "").matchAll(/\bd3\s*\.\s*(\w+)\s*\(/g)) {
|
|
748
|
+
const pkg = D3_PLUGIN_PACKAGES[m3[1]];
|
|
749
|
+
if (pkg) out.add(pkg);
|
|
750
|
+
}
|
|
751
|
+
return [...out].sort();
|
|
752
|
+
}
|
|
745
753
|
function explainRenderFailure(err, d3) {
|
|
746
754
|
const msg = String(err?.message ?? err ?? "");
|
|
747
755
|
if (!d3) {
|
|
@@ -1013,6 +1021,8 @@ export {
|
|
|
1013
1021
|
clearGeoCache,
|
|
1014
1022
|
buildRenderPayload,
|
|
1015
1023
|
createMarkResolver,
|
|
1024
|
+
requiredD3Plugins,
|
|
1025
|
+
explainRenderFailure,
|
|
1016
1026
|
compileRenderFn,
|
|
1017
1027
|
createChartHost
|
|
1018
1028
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -29,13 +29,15 @@ import {
|
|
|
29
29
|
compileRenderFn,
|
|
30
30
|
createChartHost,
|
|
31
31
|
createMarkResolver,
|
|
32
|
+
explainRenderFailure,
|
|
32
33
|
geoAssetFor,
|
|
33
34
|
geoFromCache,
|
|
34
35
|
loadGeo,
|
|
35
36
|
registerGeo,
|
|
36
37
|
registerGeoAsset,
|
|
38
|
+
requiredD3Plugins,
|
|
37
39
|
resolveOptions
|
|
38
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-4DULDBNH.mjs";
|
|
39
41
|
import "./chunk-A2GMXZP7.mjs";
|
|
40
42
|
export {
|
|
41
43
|
ANIM_MAX_IDEAL_FRAMES_DEFAULT,
|
|
@@ -67,10 +69,12 @@ export {
|
|
|
67
69
|
compileRenderFn,
|
|
68
70
|
createChartHost,
|
|
69
71
|
createMarkResolver,
|
|
72
|
+
explainRenderFailure,
|
|
70
73
|
geoAssetFor,
|
|
71
74
|
geoFromCache,
|
|
72
75
|
loadGeo,
|
|
73
76
|
registerGeo,
|
|
74
77
|
registerGeoAsset,
|
|
78
|
+
requiredD3Plugins,
|
|
75
79
|
resolveOptions
|
|
76
80
|
};
|
package/dist/react.mjs
CHANGED
package/dist/types/host.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export interface ChartHost {
|
|
|
56
56
|
initialMark(): Element | null;
|
|
57
57
|
destroy(): void;
|
|
58
58
|
}
|
|
59
|
+
export declare function requiredD3Plugins(code: string): string[];
|
|
59
60
|
export declare function explainRenderFailure(err: unknown, d3: any): unknown;
|
|
60
61
|
export declare function compileRenderFn(code: string, win: any, doc: any, d3: any): RenderFn;
|
|
61
62
|
export declare function createChartHost(container: HTMLElement, config: ChartHostConfig): ChartHost;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export * from "./contract";
|
|
|
2
2
|
export { resolveOptions, type ResolveOptionsInput } from "./defaults";
|
|
3
3
|
export { loadGeo, geoFromCache, registerGeo, registerGeoAsset, geoAssetFor, clearGeoCache, type GeoAssetName, } from "./geoLazy";
|
|
4
4
|
export { buildRenderPayload, type RenderPayload, type GeoPointBinding } from "./payload";
|
|
5
|
-
export { createChartHost, compileRenderFn, type ChartHost, type ChartHostConfig, type RenderFn } from "./host";
|
|
5
|
+
export { createChartHost, compileRenderFn, requiredD3Plugins, explainRenderFailure, type ChartHost, type ChartHostConfig, type RenderFn } from "./host";
|
|
6
6
|
export { createMarkResolver, type MarkResolver, type MarkResolverEnv } from "./selection";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/chart-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|