nuxt-echarts 0.0.9 → 0.0.11

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2024 - present, Yue JIN
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 - present, Yue JIN
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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.9",
7
+ "version": "0.0.11",
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({
@@ -7,7 +7,7 @@ declare const _default: import("vue").DefineComponent<{
7
7
  loadingOptions: PropType<import("../types").LoadingOptions>;
8
8
  autoresize: PropType<boolean | {
9
9
  throttle?: number;
10
- onResize?: () => void;
10
+ onResize?: ResizeObserverCallback;
11
11
  }>;
12
12
  option: PropType<Option>;
13
13
  theme: {
@@ -165,10 +165,10 @@ declare const _default: import("vue").DefineComponent<{
165
165
  root: import("vue").ShallowRef<EChartsElement | undefined>;
166
166
  inner: import("vue").ShallowRef<HTMLElement | undefined>;
167
167
  setOption: (option: Option, updateOptions?: UpdateOptions) => void;
168
- nonEventAttrs: import("vue").ComputedRef<{
168
+ realAttrs: import("vue").ComputedRef<{
169
169
  [x: string]: any;
170
170
  }>;
171
- nativeListeners: Record<string, unknown>;
171
+ nativeListeners: import("vue").Ref<Record<string, unknown>>;
172
172
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
173
173
  click: (params: import("echarts/core").ECElementEvent) => boolean;
174
174
  dblclick: (params: import("echarts/core").ECElementEvent) => boolean;
@@ -235,7 +235,7 @@ declare const _default: import("vue").DefineComponent<{
235
235
  loadingOptions: PropType<import("../types").LoadingOptions>;
236
236
  autoresize: PropType<boolean | {
237
237
  throttle?: number;
238
- onResize?: () => void;
238
+ onResize?: ResizeObserverCallback;
239
239
  }>;
240
240
  option: PropType<Option>;
241
241
  theme: {
@@ -2,6 +2,7 @@ import {
2
2
  defineComponent,
3
3
  shallowRef,
4
4
  toRefs,
5
+ ref,
5
6
  unref,
6
7
  watch,
7
8
  computed,
@@ -66,24 +67,27 @@ export default defineComponent({
66
67
  // @ts-expect-error unknown computed type error
67
68
  () => props.updateOptions || unref(defaultUpdateOptions) || {}
68
69
  );
69
- const nonEventAttrs = computed(() => omitOn(attrs));
70
- const nativeListeners = {};
70
+ const nativeListeners = ref({});
71
+ const realAttrs = computed(() => ({
72
+ ...omitOn(attrs),
73
+ ...nativeListeners.value
74
+ }));
71
75
  const realListeners = {};
72
- Object.keys(attrs).filter((key) => isOn(key)).forEach((key) => {
73
- let event = key.charAt(2).toLowerCase() + key.slice(3);
74
- if (event.indexOf("native:") === 0) {
75
- const nativeKey = `on${event.charAt(7).toUpperCase()}${event.slice(
76
- 8
77
- )}`;
78
- nativeListeners[nativeKey] = attrs[key];
79
- return;
80
- }
81
- if (event.substring(event.length - 4) === "Once") {
82
- event = `~${event.substring(0, event.length - 4)}`;
83
- }
84
- realListeners[event] = attrs[key];
85
- });
86
76
  function init(option) {
77
+ Object.keys(attrs).filter((key) => isOn(key)).forEach((key) => {
78
+ let event = key.charAt(2).toLowerCase() + key.slice(3);
79
+ if (event.indexOf("native:") === 0) {
80
+ const nativeKey = `on${event.charAt(7).toUpperCase()}${event.slice(
81
+ 8
82
+ )}`;
83
+ nativeListeners.value[nativeKey] = attrs[key];
84
+ return;
85
+ }
86
+ if (event.substring(event.length - 4) === "Once") {
87
+ event = `~${event.substring(0, event.length - 4)}`;
88
+ }
89
+ realListeners[event] = attrs[key];
90
+ });
87
91
  if (!inner.value) {
88
92
  return;
89
93
  }
@@ -224,13 +228,13 @@ export default defineComponent({
224
228
  root,
225
229
  inner,
226
230
  setOption,
227
- nonEventAttrs,
231
+ realAttrs,
228
232
  nativeListeners,
229
233
  ...publicApi
230
234
  };
231
235
  },
232
236
  render() {
233
- const attrs = { ...this.nonEventAttrs, ...this.nativeListeners };
237
+ const attrs = this.realAttrs;
234
238
  attrs.ref = "root";
235
239
  attrs.class = attrs.class ? ["echarts"].concat(attrs.class) : "echarts";
236
240
  return h(TAG_NAME, attrs, [
@@ -1,5 +1,5 @@
1
- <script setup lang="ts"></script>
2
-
3
- <template>
4
- <VChartServer v-bind="$attrs" />
5
- </template>
1
+ <script setup lang="ts"></script>
2
+
3
+ <template>
4
+ <VChartServer v-bind="$attrs" />
5
+ </template>
@@ -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>
@@ -2,7 +2,7 @@ import { type Ref, type PropType } from 'vue';
2
2
  import { type EChartsType } from '../types.js';
3
3
  type AutoresizeProp = boolean | {
4
4
  throttle?: number;
5
- onResize?: () => void;
5
+ onResize?: ResizeObserverCallback;
6
6
  };
7
7
  export declare function useAutoresize(chart: Ref<EChartsType | undefined>, autoresize: Ref<AutoresizeProp | undefined>, root: Ref<HTMLElement | undefined>): void;
8
8
  export declare const autoresizeProps: {
@@ -1,25 +1,42 @@
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 = (entry, ob) => {
14
+ chart2.resize({ height: "auto", width: "auto" });
15
+ onResize?.(entry, ob);
16
+ };
17
+ const resizeCallback = wait ? (
18
+ // @ts-expect-error callback can accept params
19
+ throttle(callback, wait)
20
+ ) : callback;
21
+ ro = new ResizeObserver((entry, observer) => {
22
+ if (!initialResizeTriggered) {
23
+ initialResizeTriggered = true;
24
+ if (root2.offsetWidth === offsetWidth && root2.offsetHeight === offsetHeight) {
25
+ return;
26
+ }
27
+ }
28
+ resizeCallback(entry, observer);
29
+ });
30
+ ro.observe(root2);
20
31
  }
21
- });
22
- });
32
+ onCleanup(() => {
33
+ if (ro) {
34
+ ro.disconnect();
35
+ ro = null;
36
+ }
37
+ });
38
+ }
39
+ );
23
40
  }
24
41
  export const autoresizeProps = {
25
42
  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.9",
3
+ "version": "0.0.11",
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"