nuxt-echarts 0.0.8 → 0.0.10

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
@@ -33,7 +33,7 @@ Nuxt Module for Apache ECharts™
33
33
  Install the module to your Nuxt application with one command:
34
34
 
35
35
  ```bash
36
- npx nuxi module add nuxt-echarts
36
+ npx nuxi module add echarts
37
37
  ```
38
38
 
39
39
  That's it! You can now use Nuxt ECharts in your Nuxt app ✨
package/dist/module.json CHANGED
@@ -4,9 +4,9 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.2.0"
6
6
  },
7
- "version": "0.0.8",
7
+ "version": "0.0.10",
8
8
  "builder": {
9
- "@nuxt/module-builder": "0.8.0",
9
+ "@nuxt/module-builder": "0.8.1",
10
10
  "unbuild": "2.0.0"
11
11
  }
12
12
  }
package/dist/module.mjs CHANGED
@@ -14,6 +14,9 @@ const module = defineNuxtModule({
14
14
  renderer: "canvas"
15
15
  },
16
16
  setup(options, nuxt) {
17
+ if (nuxt.options.ssr === false) {
18
+ nuxt.options.experimental.componentIslands = true;
19
+ }
17
20
  const { resolve } = createResolver(import.meta.url);
18
21
  addPlugin(resolve("./runtime/plugin"));
19
22
  addComponentsDir({
@@ -1,61 +1,63 @@
1
1
  <script>
2
- import { defineComponent } from "vue";
2
+ import {
3
+ hydrate
4
+ } from "echarts/ssr/client/index";
5
+ import {
6
+ useAttrs,
7
+ nextTick,
8
+ ref,
9
+ onMounted,
10
+ defineComponent
11
+ } from "vue";
3
12
  export default defineComponent({
4
13
  inheritAttrs: false,
5
- emits: {}
14
+ props: {
15
+ option: Object,
16
+ theme: {
17
+ type: [Object, String]
18
+ },
19
+ initOptions: Object
20
+ },
21
+ emits: {},
22
+ setup() {
23
+ const root = ref(null);
24
+ const attrs = useAttrs();
25
+ let container;
26
+ function hydrateChart() {
27
+ container = root.value?.$el;
28
+ if (container) {
29
+ hydrate(container, {
30
+ on: {
31
+ click: attrs.onClick,
32
+ mouseout: attrs.onMouseout,
33
+ mouseover: attrs.onMouseover
34
+ }
35
+ });
36
+ }
37
+ }
38
+ let observer;
39
+ onMounted(async () => {
40
+ await nextTick();
41
+ hydrateChart();
42
+ observer = new MutationObserver(async () => {
43
+ hydrateChart();
44
+ });
45
+ observer.observe(root.value.$el, {
46
+ characterData: false,
47
+ childList: true,
48
+ attributes: false
49
+ });
50
+ });
51
+ return { root };
52
+ }
6
53
  });
7
- </script>
8
-
9
- <script setup lang="ts">
10
- defineProps<{
11
- option?: Option
12
- theme?: Theme
13
- initOptions?: InitOptions
14
- }>()
15
-
16
- type ECSSRHandler = (params: ECSSRClientEventParams) => string | undefined
17
- type ECSSREventOn = `on${Capitalize<ECSSREvent>}`
18
-
19
- const root = ref<InstanceType<typeof VChartServer> | null>(null)
20
- const attrs = useAttrs() as Partial<Record<ECSSREventOn, ECSSRHandler>>
21
- let container: HTMLElement
22
- function hydrateChart() {
23
- container = root.value?.$el
24
- if (container) {
25
- // Use the lightweight runtime to give the chart interactive capabilities
26
- hydrate(container, {
27
- on: {
28
- click: attrs.onClick,
29
- mouseout: attrs.onMouseout,
30
- mouseover: attrs.onMouseover,
31
- },
32
- })
33
- }
34
- }
35
-
36
- let observer: MutationObserver
37
- onMounted(async () => {
38
- await nextTick()
39
- hydrateChart()
40
- observer = new MutationObserver(async () => {
41
- hydrateChart()
42
- })
43
-
44
- // call 'observe' on that MutationObserver instance,
45
- // passing it the element to observe, and the options object
46
- observer.observe(root.value!.$el, {
47
- characterData: false,
48
- childList: true,
49
- attributes: false,
50
- })
51
- })
52
- </script>
53
-
54
- <template>
55
- <VChartServer
56
- ref="root"
57
- :option="option"
58
- :init-options="initOptions"
59
- :theme="theme"
60
- />
61
- </template>
54
+ </script>
55
+
56
+ <template>
57
+ <VChartServer
58
+ ref="root"
59
+ :option="option"
60
+ :init-options="initOptions"
61
+ :theme="theme"
62
+ />
63
+ </template>
@@ -1,26 +1,108 @@
1
1
  import { type ECSSRClientEventParams, type ECSSREvent } from 'echarts/ssr/client/index';
2
2
  import type { InitOptions, Option, Theme } from '../types.js';
3
- declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
4
- option?: Option;
5
- theme?: Theme;
6
- initOptions?: InitOptions;
7
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<ECSSREvent, (params: ECSSRClientEventParams) => string | undefined>, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<{
8
- option?: Option;
9
- theme?: Theme;
10
- initOptions?: InitOptions;
11
- }>>> & {
3
+ import { nextTick, type PropType } from 'vue';
4
+ type ECSSRHandler = (params: ECSSRClientEventParams) => string | undefined;
5
+ declare const _default: import("vue").DefineComponent<{
6
+ option: PropType<Option>;
7
+ theme: {
8
+ type: PropType<Theme>;
9
+ };
10
+ initOptions: PropType<InitOptions>;
11
+ }, {
12
+ root: import("vue").Ref<({
13
+ $: import("vue").ComponentInternalInstance;
14
+ $data: {};
15
+ $props: Partial<{}> & Omit<{
16
+ readonly option?: Option;
17
+ readonly theme?: Theme;
18
+ readonly initOptions?: InitOptions;
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
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<ECSSREvent, ECSSRHandler>, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
98
+ option: PropType<Option>;
99
+ theme: {
100
+ type: PropType<Theme>;
101
+ };
102
+ initOptions: PropType<InitOptions>;
103
+ }>> & {
12
104
  onClick?: ((params: ECSSRClientEventParams) => any) | undefined;
13
105
  onMouseout?: ((params: ECSSRClientEventParams) => any) | undefined;
14
106
  onMouseover?: ((params: ECSSRClientEventParams) => any) | undefined;
15
107
  }, {}, {}>;
16
108
  export default _default;
17
-
18
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
19
- type __VLS_TypePropsToOption<T> = {
20
- [K in keyof T]-?: {} extends Pick<T, K> ? {
21
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
22
- } : {
23
- type: import('vue').PropType<T[K]>;
24
- required: true;
25
- };
26
- };
@@ -1,50 +1,50 @@
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 './VChartLight.vue'
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
- // @ts-expect-error https://github.com/nuxt/nuxt/issues/27730
29
- root.value.refresh()
30
- }
31
- emits('error', e)
32
- }
33
- const root = ref<InstanceType<typeof VChartIsland> | null>(null)
34
- </script>
35
-
36
- <template>
37
- <div class="vue-echarts-server">
38
- <VChartIsland
39
- ref="root"
40
- :theme="realTheme"
41
- :option="option"
42
- :init-options="realInitOptions"
43
- @error="onError"
44
- >
45
- <template #fallback>
46
- <slot name="fallback" />
47
- </template>
48
- </VChartIsland>
49
- </div>
50
- </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 './VChartLight.vue'
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
+ // @ts-expect-error https://github.com/nuxt/nuxt/issues/27730
29
+ root.value.refresh()
30
+ }
31
+ emits('error', e)
32
+ }
33
+ const root = ref<InstanceType<typeof VChartIsland> | null>(null)
34
+ </script>
35
+
36
+ <template>
37
+ <div class="vue-echarts-server">
38
+ <VChartIsland
39
+ ref="root"
40
+ :theme="realTheme"
41
+ :option="option"
42
+ :init-options="realInitOptions"
43
+ @error="onError"
44
+ >
45
+ <template #fallback>
46
+ <slot name="fallback" />
47
+ </template>
48
+ </VChartIsland>
49
+ </div>
50
+ </template>
@@ -1,25 +1,39 @@
1
1
  import { watch } from "vue";
2
2
  import { throttle } from "echarts/core";
3
3
  export function useAutoresize(chart, autoresize, root) {
4
- let observer;
5
- watch([root, chart, autoresize], ([root2, chart2, autoresize2], _, cleanup) => {
6
- if (root2 && chart2 && autoresize2) {
7
- const autoresizeOptions = autoresize2 === true ? {} : autoresize2;
8
- const { throttle: wait = 100, onResize } = autoresizeOptions;
9
- const callback = () => {
10
- chart2.resize({ width: "auto", height: "auto" });
11
- onResize?.();
12
- };
13
- observer = new ResizeObserver(wait ? throttle(callback, wait) : callback);
14
- observer.observe(root2);
15
- }
16
- cleanup(() => {
17
- if (root2 && observer) {
18
- observer.disconnect();
19
- observer = void 0;
4
+ watch(
5
+ [root, chart, autoresize],
6
+ ([root2, chart2, autoresize2], _, onCleanup) => {
7
+ let ro = null;
8
+ if (root2 && chart2 && autoresize2) {
9
+ const { offsetWidth, offsetHeight } = root2;
10
+ const autoresizeOptions = autoresize2 === true ? {} : autoresize2;
11
+ const { throttle: wait = 100, onResize } = autoresizeOptions;
12
+ let initialResizeTriggered = false;
13
+ const callback = () => {
14
+ chart2.resize({ height: "auto", width: "auto" });
15
+ onResize?.();
16
+ };
17
+ const resizeCallback = wait ? throttle(callback, wait) : callback;
18
+ ro = new ResizeObserver(() => {
19
+ if (!initialResizeTriggered) {
20
+ initialResizeTriggered = true;
21
+ if (root2.offsetWidth === offsetWidth && root2.offsetHeight === offsetHeight) {
22
+ return;
23
+ }
24
+ }
25
+ resizeCallback();
26
+ });
27
+ ro.observe(root2);
20
28
  }
21
- });
22
- });
29
+ onCleanup(() => {
30
+ if (ro) {
31
+ ro.disconnect();
32
+ ro = null;
33
+ }
34
+ });
35
+ }
36
+ );
23
37
  }
24
38
  export const autoresizeProps = {
25
39
  autoresize: [Boolean, Object]
@@ -1,2 +1,2 @@
1
- declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
1
+ declare const _default: any;
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-echarts",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Nuxt Module for Apache ECharts™",
5
5
  "keywords": [
6
6
  "vue",
@@ -44,23 +44,27 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@nuxt/kit": "^3.12.2",
47
- "echarts": "^5.5.0"
47
+ "echarts": "^5.5.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@nuxt/devtools": "^1.3.6",
50
+ "@nuxt/devtools": "^1.3.7",
51
51
  "@nuxt/eslint-config": "^0.3.13",
52
- "@nuxt/module-builder": "^0.8.0",
52
+ "@nuxt/module-builder": "^0.8.1",
53
53
  "@nuxt/schema": "^3.12.2",
54
54
  "@nuxt/test-utils": "^3.13.1",
55
- "@types/node": "^20.14.8",
55
+ "@types/node": "^20.14.9",
56
56
  "changelogen": "^0.5.5",
57
- "eslint": "^9.5.0",
57
+ "eslint": "^9.6.0",
58
58
  "nuxt": "^3.12.2",
59
59
  "prettier": "^3.3.2",
60
+ "prettier-plugin-tailwindcss": "^0.6.5",
60
61
  "typescript": "^5.5.2",
61
- "vite": "^5.3.1",
62
+ "vite": "^5.3.2",
62
63
  "vitest": "^1.6.0",
63
- "vue-tsc": "^2.0.22"
64
+ "vue-tsc": "^2.0.24"
65
+ },
66
+ "peerDependencies": {
67
+ "echarts": "^5.5.0"
64
68
  },
65
69
  "pnpm": {
66
70
  "peerDependencyRules": {
@@ -68,8 +72,7 @@
68
72
  "@typescript-eslint/eslint-plugin>eslint": "^9.0.0",
69
73
  "@typescript-eslint/parser>eslint": "^9.0.0",
70
74
  "@typescript-eslint/type-utils>eslint": "^9.0.0",
71
- "@typescript-eslint/utils>eslint": "^9.0.0",
72
- "@opentelemetry/api": "^1.9.0"
75
+ "@typescript-eslint/utils>eslint": "^9.0.0"
73
76
  },
74
77
  "ignoreMissing": [
75
78
  "webpack"