@swiftplot/vue 0.5.1 → 0.5.2

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 CHANGED
@@ -98,11 +98,11 @@ Gzip size of the minified bundle of each entry in `site/scripts/size/`, built fr
98
98
  | entry | imports | KB |
99
99
  | ------------------ | ------------------------------------------------------- | ---: |
100
100
  | plot-line | `plot` and `line` from `swiftplot` | 14.4 |
101
- | plot-line-features | the same with `tooltip`, `legend`, `zoom` and `animate` | 19.0 |
102
- | line-chart | `lineChart` from `swiftplot/charts` | 37.5 |
101
+ | plot-line-features | the same with `tooltip`, `legend`, `zoom` and `animate` | 19.1 |
102
+ | line-chart | `lineChart` from `swiftplot/charts` | 37.6 |
103
103
  | all-charts | every chart of `swiftplot/charts` | 54.7 |
104
- | react-line-chart | `LineChart` from `@swiftplot/react`, React not counted | 56.2 |
105
- | vue-line-chart | `LineChart` from `@swiftplot/vue`, Vue not counted | 57.2 |
104
+ | react-line-chart | `LineChart` from `@swiftplot/react`, React not counted | 39.3 |
105
+ | vue-line-chart | `LineChart` from `@swiftplot/vue`, Vue not counted | 39.8 |
106
106
 
107
107
  On chart-bench's page, which bundles `plot`, `line`, `area`, `ticks`, `dots`, `tooltip` and `animate`, swiftplot 0.5.0 adds 19.3 KB and uPlot 23.9 KB (`results/bundle.json`: the arm's page less the same page with no chart). uPlot ships more in its size: it is one module that comes whole, with its legend, cursor, selection and series types whether a page uses them or not.
108
108
 
package/dist/bind.d.ts CHANGED
@@ -19,5 +19,5 @@ type Shown = {
19
19
  layout: Layout;
20
20
  hover: Hover | null;
21
21
  };
22
- export declare function bind<P extends Sized, T extends Declared<P> = Declared<P>>(chart: Mount<P>, declared: T & Record<Exclude<keyof T, keyof Declared<P>>, never>): Component;
22
+ export declare function bind<P extends Sized, T extends Declared<P> = Declared<P>>(chart: Mount<P>, declared: () => T & Record<Exclude<keyof T, keyof Declared<P>>, never>): Component;
23
23
  export {};
package/dist/bind.js CHANGED
@@ -52,7 +52,8 @@ const hostStyle = (style) => Object.fromEntries(Object.entries(normalizeStyle([s
52
52
  const FALLBACK = 'data-swiftplot-fallback';
53
53
  const LAYER = 'data-swiftplot-fallback-layer';
54
54
  const styles = new WeakMap();
55
- let detached;
55
+ const detached = new WeakMap();
56
+ const windowOf = (el) => (el.ownerDocument?.defaultView ?? globalThis);
56
57
  /**
57
58
  * Lowest priority: with no height from the app, fill a parent that has one, else 300 px. A rule in the
58
59
  * first cascade layer of the host's document or shadow root rather than an inline height, so a height
@@ -60,19 +61,25 @@ let detached;
60
61
  * once it is laid out.
61
62
  */
62
63
  function fallback(el) {
64
+ const win = windowOf(el);
65
+ let observer = detached.get(win);
63
66
  if (!el.isConnected) {
64
- (detached ??= new ResizeObserver(entries => {
65
- for (const { target } of entries)
66
- if (target.isConnected)
67
- fallback(target);
68
- })).observe(el);
67
+ if (!observer) {
68
+ observer = new win.ResizeObserver(entries => {
69
+ for (const { target } of entries)
70
+ if (target.isConnected)
71
+ fallback(target);
72
+ });
73
+ detached.set(win, observer);
74
+ }
75
+ observer.observe(el);
69
76
  return;
70
77
  }
71
- detached?.unobserve(el);
78
+ observer?.unobserve(el);
72
79
  const contain = el.style.contain;
73
80
  el.removeAttribute(FALLBACK);
74
81
  el.style.contain = 'size';
75
- const cs = getComputedStyle(el);
82
+ const cs = win.getComputedStyle(el);
76
83
  for (const h of ['fill', 'fixed']) {
77
84
  if (el.clientHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom) > 0)
78
85
  break;
@@ -103,7 +110,7 @@ function sheet(el) {
103
110
  // A script that also keeps its node first would move it back forever, so a burst of moves ends the watch.
104
111
  let moves = 0;
105
112
  let since = 0;
106
- const first = new MutationObserver(() => {
113
+ const first = new (windowOf(el).MutationObserver)(() => {
107
114
  if (style.parentNode !== parent)
108
115
  return first.disconnect();
109
116
  const head = parent.firstChild;
@@ -140,7 +147,7 @@ export function bind(chart, declared) {
140
147
  return defineComponent({
141
148
  inheritAttrs: false,
142
149
  props: {
143
- ...declared,
150
+ ...declared(),
144
151
  onError: null,
145
152
  ...Object.fromEntries(Object.values(LISTENERS).map(e => [toHandlerKey(e), null])),
146
153
  },
@@ -271,7 +278,10 @@ export function bind(chart, declared) {
271
278
  sync();
272
279
  });
273
280
  onBeforeUnmount(() => {
274
- detached?.unobserve(host.value);
281
+ // A Suspense boundary unmounted while pending never set the ref.
282
+ if (!host.value)
283
+ return;
284
+ detached.get(windowOf(host.value))?.unobserve(host.value);
275
285
  bound?.destroy();
276
286
  bound = undefined;
277
287
  });
package/dist/index.js CHANGED
@@ -22,63 +22,63 @@ const base = {
22
22
  const axes = { xAxis: null, yAxis: null, zoom: flag, view: null };
23
23
  const overlays = { rules: null, zones: null, brush: flag };
24
24
  const xy = { ...base, ...axes, ...overlays, x: null, y: null, y2: null, series: null, y2Axis: null };
25
- export const LineChart = bind(lineChart, {
25
+ export const LineChart = /*#__PURE__*/ bind(lineChart, () => ({
26
26
  ...xy,
27
27
  curve: null,
28
28
  fill: flag,
29
29
  errorBars: null,
30
30
  join: bool,
31
- });
32
- export const AreaChart = bind(areaChart, {
31
+ }));
32
+ export const AreaChart = /*#__PURE__*/ bind(areaChart, () => ({
33
33
  ...xy,
34
34
  curve: null,
35
35
  join: bool,
36
36
  stack: bool,
37
- });
38
- export const BarChart = bind(barChart, {
37
+ }));
38
+ export const BarChart = /*#__PURE__*/ bind(barChart, () => ({
39
39
  ...xy,
40
40
  stack: bool,
41
41
  errorBars: null,
42
- });
43
- export const ScatterChart = bind(scatterChart, {
42
+ }));
43
+ export const ScatterChart = /*#__PURE__*/ bind(scatterChart, () => ({
44
44
  ...xy,
45
45
  r: null,
46
46
  alpha: null,
47
47
  ring: null,
48
48
  shape: null,
49
49
  errorBars: null,
50
- });
51
- export const PieChart = bind(pieChart, {
50
+ }));
51
+ export const PieChart = /*#__PURE__*/ bind(pieChart, () => ({
52
52
  ...base,
53
53
  label: null,
54
54
  value: null,
55
55
  inner: null,
56
56
  text: bool,
57
57
  sweep: null,
58
- });
59
- export const FunnelChart = bind(funnelChart, {
58
+ }));
59
+ export const FunnelChart = /*#__PURE__*/ bind(funnelChart, () => ({
60
60
  ...base,
61
61
  label: null,
62
62
  value: null,
63
63
  text: bool,
64
64
  fill: null,
65
- });
66
- export const RadialBarChart = bind(radialBarChart, {
65
+ }));
66
+ export const RadialBarChart = /*#__PURE__*/ bind(radialBarChart, () => ({
67
67
  ...base,
68
68
  label: null,
69
69
  value: null,
70
70
  max: null,
71
71
  sweep: null,
72
72
  inner: null,
73
- });
74
- export const RadarChart = bind(radarChart, {
73
+ }));
74
+ export const RadarChart = /*#__PURE__*/ bind(radarChart, () => ({
75
75
  ...base,
76
76
  x: null,
77
77
  y: null,
78
78
  max: null,
79
79
  fill: null,
80
- });
81
- export const HeatmapChart = bind(heatmapChart, {
80
+ }));
81
+ export const HeatmapChart = /*#__PURE__*/ bind(heatmapChart, () => ({
82
82
  ...base,
83
83
  x: null,
84
84
  y: null,
@@ -86,22 +86,22 @@ export const HeatmapChart = bind(heatmapChart, {
86
86
  color: null,
87
87
  xAxis: null,
88
88
  yAxis: null,
89
- });
90
- export const HistogramChart = bind(histogramChart, {
89
+ }));
90
+ export const HistogramChart = /*#__PURE__*/ bind(histogramChart, () => ({
91
91
  ...base,
92
92
  ...axes,
93
93
  x: null,
94
94
  bins: null,
95
- });
96
- export const BoxPlotChart = bind(boxPlotChart, {
95
+ }));
96
+ export const BoxPlotChart = /*#__PURE__*/ bind(boxPlotChart, () => ({
97
97
  ...base,
98
98
  x: null,
99
99
  y: null,
100
100
  fill: null,
101
101
  xAxis: null,
102
102
  yAxis: null,
103
- });
104
- export const CandlestickChart = bind(candlestickChart, {
103
+ }));
104
+ export const CandlestickChart = /*#__PURE__*/ bind(candlestickChart, () => ({
105
105
  ...base,
106
106
  ...axes,
107
107
  x: null,
@@ -111,8 +111,8 @@ export const CandlestickChart = bind(candlestickChart, {
111
111
  close: null,
112
112
  up: null,
113
113
  down: null,
114
- });
115
- export const ComboChart = bind(comboChart, {
114
+ }));
115
+ export const ComboChart = /*#__PURE__*/ bind(comboChart, () => ({
116
116
  ...base,
117
117
  ...axes,
118
118
  ...overlays,
@@ -123,26 +123,26 @@ export const ComboChart = bind(comboChart, {
123
123
  y2Lines: null,
124
124
  y2Bars: null,
125
125
  stack: bool,
126
- });
127
- export const SankeyChart = bind(sankeyChart, {
126
+ }));
127
+ export const SankeyChart = /*#__PURE__*/ bind(sankeyChart, () => ({
128
128
  ...base,
129
129
  source: null,
130
130
  target: null,
131
131
  value: null,
132
132
  blend: bool,
133
133
  text: bool,
134
- });
135
- export const TreemapChart = bind(treemapChart, {
134
+ }));
135
+ export const TreemapChart = /*#__PURE__*/ bind(treemapChart, () => ({
136
136
  ...base,
137
137
  text: bool,
138
138
  shade: null,
139
- });
140
- export const SunburstChart = bind(sunburstChart, {
139
+ }));
140
+ export const SunburstChart = /*#__PURE__*/ bind(sunburstChart, () => ({
141
141
  ...base,
142
142
  text: bool,
143
143
  shade: null,
144
- });
145
- export const Plot = bind(mount, {
144
+ }));
145
+ export const Plot = /*#__PURE__*/ bind(mount, () => ({
146
146
  width: null,
147
147
  height: null,
148
148
  margin: null,
@@ -159,4 +159,4 @@ export const Plot = bind(mount, {
159
159
  hidden: null,
160
160
  selected: null,
161
161
  pointer: null,
162
- });
162
+ }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftplot/vue",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Vue components for swiftplot charts",
5
5
  "keywords": [
6
6
  "chart",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "peerDependencies": {
36
36
  "vue": "^3.4",
37
- "swiftplot": "^0.5.1"
37
+ "swiftplot": "^0.5.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^24.19.2",
@@ -44,7 +44,7 @@
44
44
  "vitest": "^5.1.1",
45
45
  "vue": "^3.5.46",
46
46
  "vue-tsc": "^3.3.14",
47
- "swiftplot": "0.5.1"
47
+ "swiftplot": "0.5.2"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsc -p tsconfig.build.json",