@blueprint-chart/lib 1.0.0 → 1.2.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,294 @@
1
+ const d = `
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
+ `, f = "blueprint-chart-resize", i = "blueprint-chart-error";
196
+ function m(e) {
197
+ return typeof e == "object" && e !== null && e.type === f && typeof e.height == "number" ? e.height : null;
198
+ }
199
+ function p(e) {
200
+ return typeof e == "object" && e !== null && e.type === i;
201
+ }
202
+ const u = g();
203
+ function g() {
204
+ var e;
205
+ try {
206
+ if (typeof globalThis < "u") {
207
+ const r = globalThis.BLUEPRINT_CHART_RUNTIME_URL;
208
+ if (typeof r == "string" && r)
209
+ return r;
210
+ }
211
+ return typeof document > "u" ? "" : ((e = document.currentScript) == null ? void 0 : e.src) ?? "";
212
+ } catch {
213
+ return "";
214
+ }
215
+ }
216
+ const b = /* @__PURE__ */ new Map();
217
+ let n = null;
218
+ function h() {
219
+ n || (n = (e) => {
220
+ for (const [r, t] of b)
221
+ if (e.source === r.contentWindow) {
222
+ t(e);
223
+ return;
224
+ }
225
+ }, window.addEventListener("message", n));
226
+ }
227
+ function k() {
228
+ h(), document.querySelectorAll(
229
+ 'script[type="application/blueprint-chart"]'
230
+ ).forEach(v);
231
+ }
232
+ function v(e) {
233
+ var c, s;
234
+ const r = (c = e.textContent) == null ? void 0 : c.trim();
235
+ if (!r)
236
+ return;
237
+ const t = document.createElement("iframe");
238
+ t.className = "blueprint-chart-iframe", t.style.cssText = "border: none; width: 100%; display: block;", t.setAttribute("sandbox", "allow-scripts"), t.setAttribute("title", "Blueprint Chart"), (s = e.parentNode) == null || s.insertBefore(t, e), t.srcdoc = y(r, u);
239
+ const o = (a) => {
240
+ const l = m(a.data);
241
+ if (l !== null) {
242
+ t.style.height = `${l}px`;
243
+ return;
244
+ }
245
+ p(a.data) && console.warn("Blueprint Chart: could not render embed.", a.data.message);
246
+ };
247
+ b.set(t, o);
248
+ }
249
+ function y(e, r) {
250
+ const t = r ? `<script src="${z(r)}"><\/script>` : "", o = r ? [
251
+ "try {",
252
+ ' window.BlueprintChart.renderBpc(document.getElementById("chart"), __BPC_SRC__);',
253
+ "}",
254
+ "catch (e) {",
255
+ ` parent.postMessage({ type: "${i}", message: String(e) }, "*");`,
256
+ "}"
257
+ ] : [
258
+ `parent.postMessage({ type: "${i}", message: "Blueprint Chart runtime URL unavailable" }, "*");`
259
+ ];
260
+ return [
261
+ "<!DOCTYPE html>",
262
+ "<html><head>",
263
+ `<style>${d}</style>`,
264
+ "</head><body>",
265
+ '<div id="chart" class="blueprint-chart-container"></div>',
266
+ t,
267
+ "<script>",
268
+ `var __BPC_SRC__ = ${x(e)};`,
269
+ "function notifySize() {",
270
+ " var h = document.documentElement.scrollHeight;",
271
+ ` parent.postMessage({ type: "${f}", height: h }, "*");`,
272
+ "}",
273
+ ...o,
274
+ "notifySize();",
275
+ "new ResizeObserver(notifySize).observe(document.body);",
276
+ "<\/script>",
277
+ "</body></html>"
278
+ ].filter(Boolean).join(`
279
+ `);
280
+ }
281
+ function x(e) {
282
+ return JSON.stringify(e).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
283
+ }
284
+ function z(e) {
285
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
286
+ }
287
+ export {
288
+ i as E,
289
+ f as R,
290
+ p as a,
291
+ y as b,
292
+ k as i,
293
+ m as r
294
+ };
@@ -0,0 +1,2 @@
1
+ export { buildSrcdoc } from './runtime/runtime';
2
+ 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-WUb0NtY5.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';