nuxt-echarts 0.1.0 → 0.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@ Nuxt Module for Apache ECharts™
11
11
 
12
12
  > [!IMPORTANT]
13
13
  >
14
- > Nuxt ECharts is currently in active development and based on [experimental `<NuxtIsland>`](https://nuxt.com/docs/api/components/nuxt-island). If you found any issue, design flaw, or have ideas to improve it, please open an [issue](https://github.com/kingyue737/nuxt-echarts/issues) or a [Discussion](https://github.com/kingyue737/nuxt-echarts/discussions).
14
+ > Nuxt ECharts SSR is based on [experimental `<NuxtIsland>`](https://nuxt.com/docs/api/components/nuxt-island). If you found any issue, design flaw, or have ideas to improve it, please open an [issue](https://github.com/kingyue737/nuxt-echarts/issues) or a [Discussion](https://github.com/kingyue737/nuxt-echarts/discussions).
15
15
 
16
16
  - [📖 &nbsp;Documentation](https://echarts.nuxt.dev)
17
17
 
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.2.0"
6
6
  },
7
- "version": "0.1.0",
7
+ "version": "0.2.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.1",
10
10
  "unbuild": "2.0.0"
@@ -163,73 +163,72 @@ declare const _default: import("vue").DefineComponent<{
163
163
  dispose: () => void;
164
164
  chart: import("vue").ShallowRef<import("echarts/core").ECharts | undefined>;
165
165
  root: import("vue").ShallowRef<EChartsElement | undefined>;
166
- inner: import("vue").ShallowRef<HTMLElement | undefined>;
167
166
  setOption: (option: Option, updateOptions?: UpdateOptions) => void;
168
167
  realAttrs: import("vue").ComputedRef<{
169
168
  [x: string]: any;
170
169
  }>;
171
- nativeListeners: import("vue").Ref<Record<string, unknown>>;
170
+ nativeListeners: import("vue").Ref<Record<string, unknown>, Record<string, unknown>>;
172
171
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
173
- click: (params: import("echarts/core").ECElementEvent) => boolean;
174
- dblclick: (params: import("echarts/core").ECElementEvent) => boolean;
175
- mouseout: (params: import("echarts/core").ECElementEvent) => boolean;
176
- mouseover: (params: import("echarts/core").ECElementEvent) => boolean;
177
- mouseup: (params: import("echarts/core").ECElementEvent) => boolean;
178
- mousedown: (params: import("echarts/core").ECElementEvent) => boolean;
179
- mousemove: (params: import("echarts/core").ECElementEvent) => boolean;
180
- contextmenu: (params: import("echarts/core").ECElementEvent) => boolean;
181
- globalout: (params: import("echarts/core").ECElementEvent) => boolean;
172
+ click: (params: import("echarts/core").ECElementEvent) => void;
173
+ dblclick: (params: import("echarts/core").ECElementEvent) => void;
174
+ mouseout: (params: import("echarts/core").ECElementEvent) => void;
175
+ mouseover: (params: import("echarts/core").ECElementEvent) => void;
176
+ mouseup: (params: import("echarts/core").ECElementEvent) => void;
177
+ mousedown: (params: import("echarts/core").ECElementEvent) => void;
178
+ mousemove: (params: import("echarts/core").ECElementEvent) => void;
179
+ contextmenu: (params: import("echarts/core").ECElementEvent) => void;
180
+ globalout: (params: import("echarts/core").ECElementEvent) => void;
182
181
  } & {
183
- highlight: null;
184
- downplay: null;
185
- selectchanged: null;
186
- legendselectchanged: null;
187
- legendselected: null;
188
- legendunselected: null;
189
- legendselectall: null;
190
- legendinverseselect: null;
191
- legendscroll: null;
192
- datazoom: null;
193
- datarangeselected: null;
194
- graphroam: null;
195
- georoam: null;
196
- treeroam: null;
197
- timelinechanged: null;
198
- timelineplaychanged: null;
199
- restore: null;
200
- dataviewchanged: null;
201
- magictypechanged: null;
202
- geoselectchanged: null;
203
- geoselected: null;
204
- geounselected: null;
205
- axisareaselected: null;
206
- brush: null;
207
- brushEnd: null;
208
- brushselected: null;
209
- globalcursortaken: null;
182
+ highlight: (params: any) => void;
183
+ downplay: (params: any) => void;
184
+ selectchanged: (params: any) => void;
185
+ legendselectchanged: (params: any) => void;
186
+ legendselected: (params: any) => void;
187
+ legendunselected: (params: any) => void;
188
+ legendselectall: (params: any) => void;
189
+ legendinverseselect: (params: any) => void;
190
+ legendscroll: (params: any) => void;
191
+ datazoom: (params: any) => void;
192
+ datarangeselected: (params: any) => void;
193
+ graphroam: (params: any) => void;
194
+ georoam: (params: any) => void;
195
+ treeroam: (params: any) => void;
196
+ timelinechanged: (params: any) => void;
197
+ timelineplaychanged: (params: any) => void;
198
+ restore: (params: any) => void;
199
+ dataviewchanged: (params: any) => void;
200
+ magictypechanged: (params: any) => void;
201
+ geoselectchanged: (params: any) => void;
202
+ geoselected: (params: any) => void;
203
+ geounselected: (params: any) => void;
204
+ axisareaselected: (params: any) => void;
205
+ brush: (params: any) => void;
206
+ brushEnd: (params: any) => void;
207
+ brushselected: (params: any) => void;
208
+ globalcursortaken: (params: any) => void;
210
209
  } & {
211
210
  rendered: (params: {
212
211
  elapsedTime: number;
213
- }) => boolean;
214
- finished: () => boolean;
212
+ }) => void;
213
+ finished: () => void;
215
214
  } & {
216
- "zr:mousewheel": (params: import("echarts/core").ElementEvent) => boolean;
217
- "zr:drag": (params: import("echarts/core").ElementEvent) => boolean;
218
- "zr:dragstart": (params: import("echarts/core").ElementEvent) => boolean;
219
- "zr:dragend": (params: import("echarts/core").ElementEvent) => boolean;
220
- "zr:dragenter": (params: import("echarts/core").ElementEvent) => boolean;
221
- "zr:dragleave": (params: import("echarts/core").ElementEvent) => boolean;
222
- "zr:dragover": (params: import("echarts/core").ElementEvent) => boolean;
223
- "zr:drop": (params: import("echarts/core").ElementEvent) => boolean;
224
- "zr:click": (params: import("echarts/core").ElementEvent) => boolean;
225
- "zr:dblclick": (params: import("echarts/core").ElementEvent) => boolean;
226
- "zr:mouseout": (params: import("echarts/core").ElementEvent) => boolean;
227
- "zr:mouseover": (params: import("echarts/core").ElementEvent) => boolean;
228
- "zr:mouseup": (params: import("echarts/core").ElementEvent) => boolean;
229
- "zr:mousedown": (params: import("echarts/core").ElementEvent) => boolean;
230
- "zr:mousemove": (params: import("echarts/core").ElementEvent) => boolean;
231
- "zr:contextmenu": (params: import("echarts/core").ElementEvent) => boolean;
232
- "zr:globalout": (params: import("echarts/core").ElementEvent) => boolean;
215
+ "zr:mousewheel": (params: import("echarts/core").ElementEvent) => void;
216
+ "zr:drag": (params: import("echarts/core").ElementEvent) => void;
217
+ "zr:dragstart": (params: import("echarts/core").ElementEvent) => void;
218
+ "zr:dragend": (params: import("echarts/core").ElementEvent) => void;
219
+ "zr:dragenter": (params: import("echarts/core").ElementEvent) => void;
220
+ "zr:dragleave": (params: import("echarts/core").ElementEvent) => void;
221
+ "zr:dragover": (params: import("echarts/core").ElementEvent) => void;
222
+ "zr:drop": (params: import("echarts/core").ElementEvent) => void;
223
+ "zr:click": (params: import("echarts/core").ElementEvent) => void;
224
+ "zr:dblclick": (params: import("echarts/core").ElementEvent) => void;
225
+ "zr:mouseout": (params: import("echarts/core").ElementEvent) => void;
226
+ "zr:mouseover": (params: import("echarts/core").ElementEvent) => void;
227
+ "zr:mouseup": (params: import("echarts/core").ElementEvent) => void;
228
+ "zr:mousedown": (params: import("echarts/core").ElementEvent) => void;
229
+ "zr:mousemove": (params: import("echarts/core").ElementEvent) => void;
230
+ "zr:contextmenu": (params: import("echarts/core").ElementEvent) => void;
231
+ "zr:globalout": (params: import("echarts/core").ElementEvent) => void;
233
232
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
234
233
  loading: BooleanConstructor;
235
234
  loadingOptions: PropType<import("../types").LoadingOptions>;
@@ -272,33 +271,33 @@ declare const _default: import("vue").DefineComponent<{
272
271
  "onZr:mousemove"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
273
272
  "onZr:contextmenu"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
274
273
  "onZr:globalout"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
275
- onHighlight?: ((...args: any[]) => any) | undefined;
276
- onDownplay?: ((...args: any[]) => any) | undefined;
277
- onSelectchanged?: ((...args: any[]) => any) | undefined;
278
- onLegendselectchanged?: ((...args: any[]) => any) | undefined;
279
- onLegendselected?: ((...args: any[]) => any) | undefined;
280
- onLegendunselected?: ((...args: any[]) => any) | undefined;
281
- onLegendselectall?: ((...args: any[]) => any) | undefined;
282
- onLegendinverseselect?: ((...args: any[]) => any) | undefined;
283
- onLegendscroll?: ((...args: any[]) => any) | undefined;
284
- onDatazoom?: ((...args: any[]) => any) | undefined;
285
- onDatarangeselected?: ((...args: any[]) => any) | undefined;
286
- onGraphroam?: ((...args: any[]) => any) | undefined;
287
- onGeoroam?: ((...args: any[]) => any) | undefined;
288
- onTreeroam?: ((...args: any[]) => any) | undefined;
289
- onTimelinechanged?: ((...args: any[]) => any) | undefined;
290
- onTimelineplaychanged?: ((...args: any[]) => any) | undefined;
291
- onRestore?: ((...args: any[]) => any) | undefined;
292
- onDataviewchanged?: ((...args: any[]) => any) | undefined;
293
- onMagictypechanged?: ((...args: any[]) => any) | undefined;
294
- onGeoselectchanged?: ((...args: any[]) => any) | undefined;
295
- onGeoselected?: ((...args: any[]) => any) | undefined;
296
- onGeounselected?: ((...args: any[]) => any) | undefined;
297
- onAxisareaselected?: ((...args: any[]) => any) | undefined;
298
- onBrush?: ((...args: any[]) => any) | undefined;
299
- onBrushEnd?: ((...args: any[]) => any) | undefined;
300
- onBrushselected?: ((...args: any[]) => any) | undefined;
301
- onGlobalcursortaken?: ((...args: any[]) => any) | undefined;
274
+ onHighlight?: ((params: any) => any) | undefined;
275
+ onDownplay?: ((params: any) => any) | undefined;
276
+ onSelectchanged?: ((params: any) => any) | undefined;
277
+ onLegendselectchanged?: ((params: any) => any) | undefined;
278
+ onLegendselected?: ((params: any) => any) | undefined;
279
+ onLegendunselected?: ((params: any) => any) | undefined;
280
+ onLegendselectall?: ((params: any) => any) | undefined;
281
+ onLegendinverseselect?: ((params: any) => any) | undefined;
282
+ onLegendscroll?: ((params: any) => any) | undefined;
283
+ onDatazoom?: ((params: any) => any) | undefined;
284
+ onDatarangeselected?: ((params: any) => any) | undefined;
285
+ onGraphroam?: ((params: any) => any) | undefined;
286
+ onGeoroam?: ((params: any) => any) | undefined;
287
+ onTreeroam?: ((params: any) => any) | undefined;
288
+ onTimelinechanged?: ((params: any) => any) | undefined;
289
+ onTimelineplaychanged?: ((params: any) => any) | undefined;
290
+ onRestore?: ((params: any) => any) | undefined;
291
+ onDataviewchanged?: ((params: any) => any) | undefined;
292
+ onMagictypechanged?: ((params: any) => any) | undefined;
293
+ onGeoselectchanged?: ((params: any) => any) | undefined;
294
+ onGeoselected?: ((params: any) => any) | undefined;
295
+ onGeounselected?: ((params: any) => any) | undefined;
296
+ onAxisareaselected?: ((params: any) => any) | undefined;
297
+ onBrush?: ((params: any) => any) | undefined;
298
+ onBrushEnd?: ((params: any) => any) | undefined;
299
+ onBrushselected?: ((params: any) => any) | undefined;
300
+ onGlobalcursortaken?: ((params: any) => any) | undefined;
302
301
  onRendered?: ((params: {
303
302
  elapsedTime: number;
304
303
  }) => any) | undefined;
@@ -47,7 +47,6 @@ export default defineComponent({
47
47
  inheritAttrs: false,
48
48
  setup(props, { attrs }) {
49
49
  const root = shallowRef();
50
- const inner = shallowRef();
51
50
  const chart = shallowRef();
52
51
  const manualOption = shallowRef();
53
52
  const defaultTheme = inject(THEME_KEY, null);
@@ -59,11 +58,9 @@ export default defineComponent({
59
58
  );
60
59
  const realTheme = computed(() => props.theme || unref(defaultTheme) || {});
61
60
  const realInitOptions = computed(
62
- // @ts-expect-error unknown computed type error
63
61
  () => props.initOptions || unref(defaultInitOptions) || {}
64
62
  );
65
63
  const realUpdateOptions = computed(
66
- // @ts-expect-error unknown computed type error
67
64
  () => props.updateOptions || unref(defaultUpdateOptions) || {}
68
65
  );
69
66
  const nativeListeners = ref({});
@@ -87,11 +84,11 @@ export default defineComponent({
87
84
  }
88
85
  realListeners[event] = attrs[key];
89
86
  });
90
- if (!inner.value) {
87
+ if (!root.value) {
91
88
  return;
92
89
  }
93
90
  const instance = chart.value = initChart(
94
- inner.value,
91
+ root.value,
95
92
  realTheme.value,
96
93
  realInitOptions.value
97
94
  );
@@ -210,7 +207,7 @@ export default defineComponent({
210
207
  });
211
208
  const publicApi = usePublicAPI(chart);
212
209
  useLoading(chart, loading, loadingOptions);
213
- useAutoresize(chart, autoresize, inner);
210
+ useAutoresize(chart, autoresize, root);
214
211
  onMounted(async () => {
215
212
  if (!root.value) await nextTick();
216
213
  init();
@@ -225,7 +222,6 @@ export default defineComponent({
225
222
  return {
226
223
  chart,
227
224
  root,
228
- inner,
229
225
  setOption,
230
226
  realAttrs,
231
227
  nativeListeners,
@@ -236,8 +232,6 @@ export default defineComponent({
236
232
  const attrs = this.realAttrs;
237
233
  attrs.ref = "root";
238
234
  attrs.class = attrs.class ? ["echarts"].concat(attrs.class) : "echarts";
239
- return h(TAG_NAME, attrs, [
240
- h("div", { ref: "inner", class: "vue-echarts-inner" })
241
- ]);
235
+ return h(TAG_NAME, attrs);
242
236
  }
243
237
  });
@@ -1,34 +1,34 @@
1
- <script setup lang="ts">
2
- import * as echarts from 'echarts'
3
- import { ref } from 'vue'
4
- import type { Option, InitOptions, Theme } from '../types'
5
-
6
- const props = defineProps<{
7
- option?: Option
8
- initOptions?: InitOptions
9
- theme?: Theme
10
- }>()
11
-
12
- const svgStr = ref('')
13
- const initOptions: InitOptions = echarts.util.merge(
14
- { renderer: 'svg', ssr: true } satisfies InitOptions,
15
- props.initOptions || {},
16
- )
17
- let chart = echarts.init(null, props.theme, initOptions)
18
- chart.setOption(props.option || {})
19
- svgStr.value = chart.renderToSVGString()
20
-
21
- chart.dispose()
22
-
23
- // @ts-expect-error release memory
24
- chart = null
25
-
26
- defineSlots<{ fallback: any }>()
27
- </script>
28
-
29
- <template>
30
- <div class="vue-echarts-container">
31
- <!--eslint-disable-next-line vue/no-v-html-->
32
- <div class="vue-echarts-inner" v-html="svgStr" />
33
- </div>
34
- </template>
1
+ <script setup lang="ts">
2
+ import * as echarts from 'echarts'
3
+ import { ref } from 'vue'
4
+ import type { Option, InitOptions, Theme } from '../types'
5
+
6
+ const props = defineProps<{
7
+ option?: Option
8
+ initOptions?: InitOptions
9
+ theme?: Theme
10
+ }>()
11
+
12
+ const svgStr = ref('')
13
+ const initOptions: InitOptions = echarts.util.merge(
14
+ { renderer: 'svg', ssr: true } satisfies InitOptions,
15
+ props.initOptions || {},
16
+ )
17
+ let chart = echarts.init(null, props.theme, initOptions)
18
+ chart.setOption(props.option || {})
19
+ svgStr.value = chart.renderToSVGString()
20
+
21
+ chart.dispose()
22
+
23
+ // @ts-expect-error release memory
24
+ chart = null
25
+
26
+ defineSlots<{ fallback: any }>()
27
+ </script>
28
+
29
+ <template>
30
+ <div class="vue-echarts-container">
31
+ <!--eslint-disable-next-line vue/no-v-html-->
32
+ <div class="vue-echarts-inner" v-html="svgStr" />
33
+ </div>
34
+ </template>
@@ -13,9 +13,93 @@ declare const _default: import("vue").DefineComponent<{
13
13
  $: import("vue").ComponentInternalInstance;
14
14
  $data: {};
15
15
  $props: Partial<{}> & Omit<{
16
- readonly option?: Option;
17
- readonly initOptions?: InitOptions;
18
- readonly theme?: Theme;
16
+ readonly option?: Option | undefined;
17
+ readonly initOptions?: InitOptions | undefined;
18
+ readonly theme?: Theme | undefined;
19
+ onError?: ((error: unknown) => any) | undefined;
20
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
21
+ option: {
22
+ type: PropType<import("echarts/core").EChartsCoreOption>;
23
+ };
24
+ theme: {
25
+ type: PropType<Theme>;
26
+ };
27
+ initOptions: {
28
+ type: PropType<import("echarts/core").EChartsInitOpts>;
29
+ };
30
+ }>> & {
31
+ onError?: ((error: unknown) => any) | undefined;
32
+ }, never>;
33
+ $attrs: {
34
+ [x: string]: unknown;
35
+ };
36
+ $refs: {
37
+ [x: string]: unknown;
38
+ };
39
+ $slots: Readonly<{
40
+ [name: string]: import("vue").Slot<any> | undefined;
41
+ }>;
42
+ $root: import("vue").ComponentPublicInstance | null;
43
+ $parent: import("vue").ComponentPublicInstance | null;
44
+ $emit: (event: "error", error: unknown) => void;
45
+ $el: any;
46
+ $options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
47
+ option: {
48
+ type: PropType<import("echarts/core").EChartsCoreOption>;
49
+ };
50
+ theme: {
51
+ type: PropType<Theme>;
52
+ };
53
+ initOptions: {
54
+ type: PropType<import("echarts/core").EChartsInitOpts>;
55
+ };
56
+ }>> & {
57
+ onError?: ((error: unknown) => any) | undefined;
58
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
59
+ error: (error: unknown) => void;
60
+ }, string, {}, {}, string, {}> & {
61
+ beforeCreate?: (() => void) | (() => void)[];
62
+ created?: (() => void) | (() => void)[];
63
+ beforeMount?: (() => void) | (() => void)[];
64
+ mounted?: (() => void) | (() => void)[];
65
+ beforeUpdate?: (() => void) | (() => void)[];
66
+ updated?: (() => void) | (() => void)[];
67
+ activated?: (() => void) | (() => void)[];
68
+ deactivated?: (() => void) | (() => void)[];
69
+ beforeDestroy?: (() => void) | (() => void)[];
70
+ beforeUnmount?: (() => void) | (() => void)[];
71
+ destroyed?: (() => void) | (() => void)[];
72
+ unmounted?: (() => void) | (() => void)[];
73
+ renderTracked?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[];
74
+ renderTriggered?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[];
75
+ errorCaptured?: ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void)[];
76
+ };
77
+ $forceUpdate: () => void;
78
+ $nextTick: typeof nextTick;
79
+ $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, (cleanupFn: () => void) => void]) => any : (...args: [any, any, (cleanupFn: () => void) => void]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
80
+ } & Omit<Readonly<import("vue").ExtractPropTypes<{
81
+ option: {
82
+ type: PropType<import("echarts/core").EChartsCoreOption>;
83
+ };
84
+ theme: {
85
+ type: PropType<Theme>;
86
+ };
87
+ initOptions: {
88
+ type: PropType<import("echarts/core").EChartsInitOpts>;
89
+ };
90
+ }>> & {
91
+ onError?: ((error: unknown) => any) | undefined;
92
+ }, never> & import("vue").ShallowUnwrapRef<{}> & {} & import("vue").ComponentCustomProperties & {} & {
93
+ $slots: {
94
+ fallback?(_: {}): any;
95
+ };
96
+ }) | null, ({
97
+ $: import("vue").ComponentInternalInstance;
98
+ $data: {};
99
+ $props: Partial<{}> & Omit<{
100
+ readonly option?: Option | undefined;
101
+ readonly initOptions?: InitOptions | undefined;
102
+ readonly theme?: Theme | undefined;
19
103
  onError?: ((error: unknown) => any) | undefined;
20
104
  } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
21
105
  option: {
@@ -1,49 +1,48 @@
1
- <script setup lang="ts">
2
- import { computed, unref, inject, ref } from 'vue'
3
- import type { InitOptions, Option, Theme } from '../types'
4
- import { THEME_KEY, INIT_OPTIONS_KEY } from '../utils/injection'
5
- import type { VChartIsland } from '#components'
6
-
7
- const defaultTheme = inject(THEME_KEY, null)
8
- const defaultInitOptions = inject(INIT_OPTIONS_KEY, null)
9
-
10
- const props = defineProps<{
11
- option?: Option
12
- theme?: Theme
13
- initOptions?: InitOptions
14
- }>()
15
- const emits = defineEmits<{ (event: 'error', error: unknown): void }>()
16
-
17
- const realTheme = computed(() => props.theme || unref(defaultTheme) || {})
18
- const realInitOptions = computed(
19
- // @ts-expect-error unknown computed type error
20
- () => props.initOptions || unref(defaultInitOptions) || {},
21
- )
22
- function onError(e: unknown) {
23
- // https://github.com/nuxt/nuxt/issues/27491
24
- if (
25
- e instanceof TypeError &&
26
- e.message === "Cannot read properties of undefined (reading 'link')"
27
- ) {
28
- root.value?.refresh()
29
- }
30
- emits('error', e)
31
- }
32
- const root = ref<InstanceType<typeof VChartIsland> | null>(null)
33
- </script>
34
-
35
- <template>
36
- <div class="vue-echarts-server">
37
- <VChartIsland
38
- ref="root"
39
- :theme="realTheme"
40
- :option="option"
41
- :init-options="realInitOptions"
42
- @error="onError"
43
- >
44
- <template #fallback>
45
- <slot name="fallback" />
46
- </template>
47
- </VChartIsland>
48
- </div>
49
- </template>
1
+ <script setup lang="ts">
2
+ import { computed, unref, inject, ref } from 'vue'
3
+ import type { InitOptions, Option, Theme } from '../types'
4
+ import { THEME_KEY, INIT_OPTIONS_KEY } from '../utils/injection'
5
+ import type { VChartIsland } from '#components'
6
+
7
+ const defaultTheme = inject(THEME_KEY, null)
8
+ const defaultInitOptions = inject(INIT_OPTIONS_KEY, null)
9
+
10
+ const props = defineProps<{
11
+ option?: Option
12
+ theme?: Theme
13
+ initOptions?: InitOptions
14
+ }>()
15
+ const emits = defineEmits<{ (event: 'error', error: unknown): void }>()
16
+
17
+ const realTheme = computed(() => props.theme || unref(defaultTheme) || {})
18
+ const realInitOptions = computed(
19
+ () => props.initOptions || unref(defaultInitOptions) || {},
20
+ )
21
+ function onError(e: unknown) {
22
+ // https://github.com/nuxt/nuxt/issues/27491
23
+ if (
24
+ e instanceof TypeError &&
25
+ e.message === "Cannot read properties of undefined (reading 'link')"
26
+ ) {
27
+ root.value?.refresh()
28
+ }
29
+ emits('error', e)
30
+ }
31
+ const root = ref<InstanceType<typeof VChartIsland> | null>(null)
32
+ </script>
33
+
34
+ <template>
35
+ <div class="vue-echarts-server">
36
+ <VChartIsland
37
+ ref="root"
38
+ :theme="realTheme"
39
+ :option="option"
40
+ :init-options="realInitOptions"
41
+ @error="onError"
42
+ >
43
+ <template #fallback>
44
+ <slot name="fallback" />
45
+ </template>
46
+ </VChartIsland>
47
+ </div>
48
+ </template>
@@ -1,5 +1,5 @@
1
1
  import { type Ref, type PropType } from 'vue';
2
- import { type EChartsType } from '../types.js';
2
+ import type { EChartsType } from '../types.js';
3
3
  type AutoresizeProp = boolean | {
4
4
  throttle?: number;
5
5
  onResize?: ResizeObserverCallback;
@@ -1 +1 @@
1
- .vue-echarts-container,x-vue-echarts{display:flex;flex-direction:column;height:100%;min-width:0;width:100%}.vue-echarts-inner{flex-grow:1;height:auto!important;min-width:0;width:auto!important}
1
+ .vue-echarts-container,x-vue-echarts{display:block;height:100%;min-width:0;width:100%}
@@ -1,8 +1,6 @@
1
1
  import type { init, SetOptionOpts, ECElementEvent, ElementEvent } from 'echarts/core';
2
- import type { Ref } from 'vue';
3
- export type Injection<T> = T | null | Ref<T | null> | {
4
- value: T | null;
5
- };
2
+ import type { MaybeRef } from 'vue';
3
+ export type Injection<T> = MaybeRef<T | null>;
6
4
  type InitType = typeof init;
7
5
  export type InitParameters = Parameters<InitType>;
8
6
  export type Theme = NonNullable<InitParameters[1]>;
@@ -35,18 +33,18 @@ type ElementEventName = MouseEventName | 'mousewheel' | 'drag' | 'dragstart' | '
35
33
  type ZRenderEventName = `zr:${ElementEventName}`;
36
34
  type OtherEventName = 'highlight' | 'downplay' | 'selectchanged' | 'legendselectchanged' | 'legendselected' | 'legendunselected' | 'legendselectall' | 'legendinverseselect' | 'legendscroll' | 'datazoom' | 'datarangeselected' | 'graphroam' | 'georoam' | 'treeroam' | 'timelinechanged' | 'timelineplaychanged' | 'restore' | 'dataviewchanged' | 'magictypechanged' | 'geoselectchanged' | 'geoselected' | 'geounselected' | 'axisareaselected' | 'brush' | 'brushEnd' | 'brushselected' | 'globalcursortaken';
37
35
  type MouseEmits = {
38
- [key in MouseEventName]: (params: ECElementEvent) => boolean;
36
+ [key in MouseEventName]: (params: ECElementEvent) => void;
39
37
  };
40
38
  type ZRenderEmits = {
41
- [key in ZRenderEventName]: (params: ElementEvent) => boolean;
39
+ [key in ZRenderEventName]: (params: ElementEvent) => void;
42
40
  };
43
41
  type OtherEmits = {
44
- [key in OtherEventName]: null;
42
+ [key in OtherEventName]: (params: any) => void;
45
43
  };
46
44
  export type Emits = MouseEmits & OtherEmits & {
47
45
  rendered: (params: {
48
46
  elapsedTime: number;
49
- }) => boolean;
50
- finished: () => boolean;
47
+ }) => void;
48
+ finished: () => void;
51
49
  } & ZRenderEmits;
52
50
  export {};
@@ -23,7 +23,7 @@ export function register() {
23
23
  if (customElements.get(TAG_NAME) == null) {
24
24
  customElements.define(TAG_NAME, EChartsElement);
25
25
  }
26
- } catch (e) {
26
+ } catch {
27
27
  return registered = false;
28
28
  }
29
29
  return registered = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-echarts",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Nuxt Module for Apache ECharts™",
5
5
  "keywords": [
6
6
  "vue",
@@ -14,7 +14,7 @@
14
14
  "repository": "kingyue737/nuxt-echarts",
15
15
  "license": "MIT",
16
16
  "type": "module",
17
- "packageManager": "pnpm@9.5.0",
17
+ "packageManager": "pnpm@9.6.0",
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./dist/types.d.ts",
@@ -41,38 +41,35 @@
41
41
  "format": "prettier . --write",
42
42
  "test": "vitest run",
43
43
  "test:watch": "vitest watch",
44
- "test:types": "nuxi typecheck && nuxi typecheck playground"
44
+ "test:types": "vue-tsc --noEmit && nuxi typecheck playground"
45
45
  },
46
46
  "dependencies": {
47
- "@nuxt/kit": "^3.12.3",
47
+ "@nuxt/kit": "^3.12.4",
48
48
  "echarts": "^5.5.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@nuxt/devtools": "^1.3.9",
52
- "@nuxt/eslint-config": "^0.3.13",
52
+ "@nuxt/eslint-config": "^0.5.0",
53
53
  "@nuxt/module-builder": "^0.8.1",
54
- "@nuxt/schema": "^3.12.3",
55
- "@nuxt/test-utils": "^3.13.1",
56
- "@types/node": "^20.14.10",
54
+ "@nuxt/schema": "^3.12.4",
55
+ "@nuxt/test-utils": "^3.14.0",
56
+ "@types/node": "^20.14.14",
57
57
  "changelogen": "^0.5.5",
58
- "eslint": "^9.6.0",
59
- "nuxt": "^3.12.3",
60
- "prettier": "^3.3.2",
58
+ "eslint": "^9.8.0",
59
+ "nuxt": "^3.12.4",
60
+ "prettier": "^3.3.3",
61
61
  "prettier-plugin-tailwindcss": "^0.6.5",
62
- "typescript": "^5.5.3",
63
- "vite": "^5.3.3",
64
- "vitest": "^1.6.0",
65
- "vue-tsc": "^2.0.26"
62
+ "typescript": "^5.5.4",
63
+ "vite": "^5.3.5",
64
+ "vitest": "^2.0.5",
65
+ "vue-tsc": "^2.0.29"
66
66
  },
67
67
  "peerDependencies": {
68
- "echarts": "^5.5.0"
68
+ "echarts": "^5.5.1"
69
69
  },
70
70
  "pnpm": {
71
71
  "peerDependencyRules": {
72
72
  "allowedVersions": {
73
- "@typescript-eslint/eslint-plugin>eslint": "^9.0.0",
74
- "@typescript-eslint/parser>eslint": "^9.0.0",
75
- "@typescript-eslint/type-utils>eslint": "^9.0.0",
76
73
  "@typescript-eslint/utils>eslint": "^9.0.0"
77
74
  },
78
75
  "ignoreMissing": [