@blueprint-chart/lib 1.1.0 → 1.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.
@@ -0,0 +1,315 @@
1
+ const f = `
2
+ /* Blueprint Chart — Runtime Embed Styles
3
+ CSS custom properties with baked-in defaults for standalone iframe usage. */
4
+
5
+ .bc-frame {
6
+ --bc-frame-font-family: system-ui, -apple-system, sans-serif;
7
+ --bc-frame-padding: 0;
8
+ --bc-frame-bg: #fff;
9
+ --bc-text-color: #333;
10
+ font-family: var(--bc-frame-font-family);
11
+ background: var(--bc-frame-bg);
12
+ }
13
+
14
+ /* Keeps the SVG's baked-in background rect (applyCanvasBackground) in sync
15
+ with the frame background; transparentBackground sets the var to
16
+ transparent at runtime. */
17
+ .bc-frame .bc-canvas-bg {
18
+ fill: var(--bc-frame-bg, #fff);
19
+ }
20
+
21
+ .bc-frame-header {
22
+ padding: var(--bc-frame-padding) var(--bc-frame-padding) 0;
23
+ background: var(--bc-frame-header-bg, transparent);
24
+ border-bottom: var(--bc-frame-header-border-bottom, none);
25
+ margin-bottom: var(--bc-frame-header-margin-bottom, 0);
26
+ }
27
+
28
+ .bc-frame-body {
29
+ padding: 0 var(--bc-frame-padding);
30
+ }
31
+
32
+ .bc-frame-title {
33
+ --bc-frame-title-color: var(--bc-text-color, #333);
34
+ --bc-frame-title-font-size: 1.25rem;
35
+ color: var(--bc-frame-title-color);
36
+ font-size: var(--bc-frame-title-font-size);
37
+ font-weight: bold;
38
+ margin: 0;
39
+ }
40
+
41
+ .bc-frame-description {
42
+ --bc-frame-description-color: var(--bc-text-color, #555);
43
+ --bc-frame-description-font-size: 0.875rem;
44
+ color: var(--bc-frame-description-color);
45
+ font-size: var(--bc-frame-description-font-size);
46
+ margin: 0.25rem 0 0;
47
+ }
48
+
49
+ .bc-frame-footer {
50
+ margin-top: 0.5rem;
51
+ gap: 0.25rem 1rem;
52
+ padding: var(--bc-frame-footer-padding-top, 0) var(--bc-frame-padding) var(--bc-frame-padding);
53
+ background: var(--bc-frame-footer-bg, transparent);
54
+ border-top: var(--bc-frame-footer-border-top, none);
55
+ }
56
+
57
+ .bc-frame-footer-left {
58
+ display: flex;
59
+ align-items: baseline;
60
+ flex-wrap: wrap;
61
+ gap: 0.25rem 0.75rem;
62
+ }
63
+
64
+ .bc-frame-footer-left > :not(:first-child)::before {
65
+ content: "\\00B7";
66
+ margin-right: 0.5rem;
67
+ color: var(--bc-text-color, #888);
68
+ }
69
+
70
+ .bc-frame-footer-right {
71
+ display: flex;
72
+ align-items: center;
73
+ }
74
+
75
+ .bc-frame-note {
76
+ --bc-frame-note-color: var(--bc-text-color, #888);
77
+ --bc-frame-note-font-size: 0.75rem;
78
+ font-style: italic;
79
+ color: var(--bc-frame-note-color);
80
+ font-size: var(--bc-frame-note-font-size);
81
+ margin: 0;
82
+ padding: 0 var(--bc-frame-padding);
83
+ }
84
+
85
+ .bc-frame-byline,
86
+ .bc-frame-source {
87
+ --bc-frame-meta-color: var(--bc-text-color, #888);
88
+ --bc-frame-meta-font-size: 0.75rem;
89
+ color: var(--bc-frame-meta-color);
90
+ font-size: var(--bc-frame-meta-font-size);
91
+ }
92
+
93
+ .bc-frame-credit {
94
+ --bc-frame-credit-color: var(--bc-text-color, #666);
95
+ --bc-frame-credit-font-size: 0.75rem;
96
+ color: var(--bc-frame-credit-color);
97
+ font-size: var(--bc-frame-credit-font-size);
98
+ font-weight: 600;
99
+ display: inline-flex;
100
+ align-items: center;
101
+ text-decoration: none;
102
+ }
103
+
104
+ .bc-frame-source-link {
105
+ color: inherit;
106
+ text-decoration: underline;
107
+ }
108
+
109
+ .bc-axis .domain {
110
+ stroke: var(--bc-axis-color, #333);
111
+ }
112
+
113
+ .bc-axis .tick text {
114
+ fill: var(--bc-axis-color, #333);
115
+ font-size: 10px;
116
+ }
117
+
118
+ .bc-axis .tick line {
119
+ stroke: var(--bc-axis-color, #333);
120
+ }
121
+
122
+ .bc-grid-line {
123
+ stroke: var(--bc-grid-color, #e0e0e0);
124
+ stroke-width: 1;
125
+ }
126
+
127
+ .bc-zero-baseline {
128
+ stroke: #666;
129
+ stroke-width: 1;
130
+ }
131
+
132
+ .bc-bar {
133
+ /* fill is set via D3 .attr() from data-bound colors — do not override */
134
+ }
135
+
136
+ .bc-line {
137
+ fill: none;
138
+ stroke-width: 2;
139
+ }
140
+
141
+ .bc-value-label {
142
+ font-size: 11px;
143
+ /* fill is set via D3 .attr() — do not override */
144
+ }
145
+
146
+ .bc-direct-label {
147
+ font-size: 12px;
148
+ font-weight: 600;
149
+ }
150
+
151
+ .bc-tooltip {
152
+ position: absolute;
153
+ pointer-events: none;
154
+ background: var(--bc-tooltip-bg, #fff);
155
+ color: var(--bc-tooltip-color, #212529);
156
+ border: 1px solid var(--bc-tooltip-border-color, #dee2e6);
157
+ border-radius: 4px;
158
+ padding: 6px 10px;
159
+ font-size: 13px;
160
+ box-shadow: 0 2px 8px rgba(0,0,0,0.12);
161
+ z-index: 9999;
162
+ display: none;
163
+ }
164
+
165
+ .bc-crosshair {
166
+ stroke: #999;
167
+ stroke-width: 1;
168
+ pointer-events: none;
169
+ }
170
+
171
+ .bc-arc-label-line {
172
+ fill: none;
173
+ stroke: #999;
174
+ stroke-width: 1;
175
+ }
176
+
177
+ .bc-theme-blueprint-framed {
178
+ --bc-frame-header-border-bottom: 1px solid #e0e0e0;
179
+ --bc-frame-header-margin-bottom: 0.5rem;
180
+ --bc-frame-footer-bg: #f8f8f8;
181
+ --bc-frame-footer-border-top: 1px solid #e0e0e0;
182
+ --bc-frame-footer-padding-top: 0.625rem;
183
+ }
184
+
185
+ .blueprint-chart-error {
186
+ color: red;
187
+ padding: 1em;
188
+ border: 1px solid red;
189
+ }
190
+
191
+ body {
192
+ margin: 0;
193
+ overflow: hidden;
194
+ }
195
+
196
+ /* Dark theme: activated by data-bs-theme="dark" on the document (matching the
197
+ editor's convention). The chart owns these colors; the dark frame background
198
+ also drives the renderer's resolveBackgroundColor, so data-mark colors and
199
+ contrast labels adapt at render time. Scoped to .bc-frame so these override
200
+ the frame's own light --bc-frame-bg / --bc-text-color declarations (which are
201
+ set on .bc-frame and would otherwise shadow a document-level override). */
202
+ [data-bs-theme="dark"] body {
203
+ /* color themes above-bar value labels (fill: currentColor). */
204
+ background: #1c1c1c;
205
+ color: rgba(255, 255, 255, 0.9);
206
+ }
207
+
208
+ [data-bs-theme="dark"] .bc-frame {
209
+ --bc-frame-bg: #1c1c1c;
210
+ --bc-text-color: rgba(255, 255, 255, 0.9);
211
+ --bc-axis-color: rgba(255, 255, 255, 0.6);
212
+ --bc-grid-color: #333;
213
+
214
+ color: rgba(255, 255, 255, 0.9);
215
+ }
216
+ `, b = "blueprint-chart-resize", s = "blueprint-chart-error";
217
+ function m(e) {
218
+ return typeof e == "object" && e !== null && e.type === b && typeof e.height == "number" ? e.height : null;
219
+ }
220
+ function p(e) {
221
+ return typeof e == "object" && e !== null && e.type === s;
222
+ }
223
+ const g = u();
224
+ function u() {
225
+ var e;
226
+ try {
227
+ if (typeof globalThis < "u") {
228
+ const r = globalThis.BLUEPRINT_CHART_RUNTIME_URL;
229
+ if (typeof r == "string" && r)
230
+ return r;
231
+ }
232
+ return typeof document > "u" ? "" : ((e = document.currentScript) == null ? void 0 : e.src) ?? "";
233
+ } catch {
234
+ return "";
235
+ }
236
+ }
237
+ const d = /* @__PURE__ */ new Map();
238
+ let i = null;
239
+ function h() {
240
+ i || (i = (e) => {
241
+ for (const [r, t] of d)
242
+ if (e.source === r.contentWindow) {
243
+ t(e);
244
+ return;
245
+ }
246
+ }, window.addEventListener("message", i));
247
+ }
248
+ function w() {
249
+ h(), document.querySelectorAll(
250
+ 'script[type="application/blueprint-chart"]'
251
+ ).forEach(v);
252
+ }
253
+ function v(e) {
254
+ var o, a;
255
+ const r = (o = e.textContent) == null ? void 0 : o.trim();
256
+ if (!r)
257
+ return;
258
+ const t = document.createElement("iframe");
259
+ t.className = "blueprint-chart-iframe", t.style.cssText = "border: none; width: 100%; display: block;", t.setAttribute("sandbox", "allow-scripts"), t.setAttribute("title", "Blueprint Chart"), (a = e.parentNode) == null || a.insertBefore(t, e), t.srcdoc = y(r, g);
260
+ const n = (c) => {
261
+ const l = m(c.data);
262
+ if (l !== null) {
263
+ t.style.height = `${l}px`;
264
+ return;
265
+ }
266
+ p(c.data) && console.warn("Blueprint Chart: could not render embed.", c.data.message);
267
+ };
268
+ d.set(t, n);
269
+ }
270
+ function y(e, r, t) {
271
+ const n = r ? `<script src="${k(r)}"><\/script>` : "", o = t === "dark" ? '<html data-bs-theme="dark">' : "<html>", a = r ? [
272
+ "try {",
273
+ ' window.BlueprintChart.renderBpc(document.getElementById("chart"), __BPC_SRC__);',
274
+ "}",
275
+ "catch (e) {",
276
+ ` parent.postMessage({ type: "${s}", message: String(e) }, "*");`,
277
+ "}"
278
+ ] : [
279
+ `parent.postMessage({ type: "${s}", message: "Blueprint Chart runtime URL unavailable" }, "*");`
280
+ ];
281
+ return [
282
+ "<!DOCTYPE html>",
283
+ `${o}<head>`,
284
+ `<style>${f}</style>`,
285
+ "</head><body>",
286
+ '<div id="chart" class="blueprint-chart-container"></div>',
287
+ n,
288
+ "<script>",
289
+ `var __BPC_SRC__ = ${x(e)};`,
290
+ "function notifySize() {",
291
+ " var h = document.documentElement.scrollHeight;",
292
+ ` parent.postMessage({ type: "${b}", height: h }, "*");`,
293
+ "}",
294
+ ...a,
295
+ "notifySize();",
296
+ "new ResizeObserver(notifySize).observe(document.body);",
297
+ "<\/script>",
298
+ "</body></html>"
299
+ ].filter(Boolean).join(`
300
+ `);
301
+ }
302
+ function x(e) {
303
+ return JSON.stringify(e).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
304
+ }
305
+ function k(e) {
306
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
307
+ }
308
+ export {
309
+ s as E,
310
+ b as R,
311
+ p as a,
312
+ y as b,
313
+ w as i,
314
+ m as r
315
+ };
@@ -0,0 +1,3 @@
1
+ export { buildSrcdoc } from './runtime/runtime';
2
+ export type { EmbedTheme } from './runtime/runtime';
3
+ export { readResizeHeight, isErrorMessage, RESIZE_MESSAGE, ERROR_MESSAGE } from './runtime/messages';
package/dist/embed.js ADDED
@@ -0,0 +1,8 @@
1
+ import { E as a, R as r, b as e, a as R, r as S } from "./embed-DxKuPk6P.js";
2
+ export {
3
+ a as ERROR_MESSAGE,
4
+ r as RESIZE_MESSAGE,
5
+ e as buildSrcdoc,
6
+ R as isErrorMessage,
7
+ S as readResizeHeight
8
+ };
package/dist/index.d.ts CHANGED
@@ -35,5 +35,6 @@ export type { ChartSample } from './samples';
35
35
  export { renderBpc, renderChart, astToDefinition, resolveScene, render } from './render';
36
36
  export type { ChartDefinition, RenderOptions, ResolvedChartState, ChartHandle, RenderApiOptions, OutputOptions } from './render';
37
37
  export { ChartParseError, PngBrowserUnsupportedError, MissingNodeRenderDepsError } from './render';
38
+ export { buildSrcdoc } from './runtime/runtime';
38
39
  export { SceneTransition, getSceneTransition, featureJoin, snapshotLiveAttrs, BC_TRANSITION_NAME, } from './transitions';
39
40
  export type { CommitOptions, TransitionMode, SceneTransitionState, FeatureRole, FeatureJoinConfig, AttrMap, AttrValue, } from './transitions';