@vueuse/nuxt 7.4.2 → 7.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.
Files changed (3) hide show
  1. package/index.mjs +57 -48
  2. package/indexes.json +29 -0
  3. package/package.json +7 -3
package/index.mjs CHANGED
@@ -2,6 +2,7 @@ import fs from 'fs';
2
2
  import { dirname, resolve } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { isPackageExists } from 'local-pkg';
5
+ import { defineNuxtModule } from '@nuxt/kit';
5
6
 
6
7
  const _dirname = dirname(fileURLToPath(import.meta.url));
7
8
  const disabledFunctions = [
@@ -22,55 +23,63 @@ const packages = [
22
23
  "head"
23
24
  ];
24
25
  const fullPackages = packages.map((p) => `@vueuse/${p}`);
25
- function VueUseModule() {
26
- const { nuxt } = this;
27
- const options = nuxt.options.vueuse || {};
28
- nuxt.hook("vite:extend", ({ config }) => {
29
- config.optimizeDeps = config.optimizeDeps || {};
30
- config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
31
- config.optimizeDeps.exclude.push(...fullPackages);
32
- });
33
- nuxt.options.build = nuxt.options.build || {};
34
- nuxt.options.build.transpile = nuxt.options.build.transpile || [];
35
- nuxt.options.build.transpile.push("@vueuse/nuxt", "@vueuse/core", "@vueuse/shared");
36
- let indexes;
37
- if (options.ssrHandlers) {
38
- const pluginPath = resolve(_dirname, "./ssr-plugin.mjs");
39
- nuxt.options.plugins = nuxt.options.plugins || [];
40
- nuxt.options.plugins.push(pluginPath);
41
- }
42
- if (options.autoImports !== false) {
43
- nuxt.hook("autoImports:sources", (sources) => {
44
- if (sources.find((i) => fullPackages.includes(i.from)))
45
- return;
46
- if (!indexes) {
47
- try {
48
- indexes = JSON.parse(fs.readFileSync(resolve(_dirname, "./indexes.json"), "utf-8"));
49
- indexes == null ? void 0 : indexes.functions.forEach((i) => {
50
- if (i.package === "shared")
51
- i.package = "core";
52
- });
53
- } catch (e) {
54
- throw new Error("[@vueuse/nuxt] Failed to load indexes.json");
26
+ var index = defineNuxtModule({
27
+ meta: {
28
+ name: "vueuse",
29
+ configKey: "vueuse"
30
+ },
31
+ defaults: {
32
+ ssrHandlers: false,
33
+ autoImports: true
34
+ },
35
+ setup(options, nuxt) {
36
+ nuxt.hook("vite:extend", ({ config }) => {
37
+ config.optimizeDeps = config.optimizeDeps || {};
38
+ config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
39
+ config.optimizeDeps.exclude.push(...fullPackages);
40
+ });
41
+ nuxt.options.build = nuxt.options.build || {};
42
+ nuxt.options.build.transpile = nuxt.options.build.transpile || [];
43
+ nuxt.options.build.transpile.push(...fullPackages);
44
+ let indexes;
45
+ if (options.ssrHandlers) {
46
+ const pluginPath = resolve(_dirname, "./ssr-plugin.mjs");
47
+ nuxt.options.plugins = nuxt.options.plugins || [];
48
+ nuxt.options.plugins.push(pluginPath);
49
+ }
50
+ if (options.autoImports) {
51
+ nuxt.hook("autoImports:sources", (sources) => {
52
+ if (sources.find((i) => fullPackages.includes(i.from)))
53
+ return;
54
+ if (!indexes) {
55
+ try {
56
+ indexes = JSON.parse(fs.readFileSync(resolve(_dirname, "./indexes.json"), "utf-8"));
57
+ indexes == null ? void 0 : indexes.functions.forEach((i) => {
58
+ if (i.package === "shared")
59
+ i.package = "core";
60
+ });
61
+ } catch (e) {
62
+ throw new Error("[@vueuse/nuxt] Failed to load indexes.json");
63
+ }
55
64
  }
56
- }
57
- if (!indexes)
58
- return;
59
- for (const pkg of packages) {
60
- if (pkg === "shared")
61
- continue;
62
- if (!isPackageExists(`@vueuse/${pkg}`))
63
- continue;
64
- const functions = indexes.functions.filter((i) => (i.package === "core" || i.package === "shared") && !i.internal);
65
- if (functions.length) {
66
- sources.push({
67
- from: `@vueuse/${pkg}`,
68
- names: indexes.functions.filter((i) => i.package === pkg && !i.internal).map((i) => i.name).filter((i) => i.length >= 4 && !disabledFunctions.includes(i))
69
- });
65
+ if (!indexes)
66
+ return;
67
+ for (const pkg of packages) {
68
+ if (pkg === "shared")
69
+ continue;
70
+ if (!isPackageExists(`@vueuse/${pkg}`))
71
+ continue;
72
+ const functions = indexes.functions.filter((i) => (i.package === "core" || i.package === "shared") && !i.internal);
73
+ if (functions.length) {
74
+ sources.push({
75
+ from: `@vueuse/${pkg}`,
76
+ names: indexes.functions.filter((i) => i.package === pkg && !i.internal).map((i) => i.name).filter((i) => i.length >= 4 && !disabledFunctions.includes(i))
77
+ });
78
+ }
70
79
  }
71
- }
72
- });
80
+ });
81
+ }
73
82
  }
74
- }
83
+ });
75
84
 
76
- export { VueUseModule as default };
85
+ export { index as default };
package/indexes.json CHANGED
@@ -35,6 +35,7 @@
35
35
  "external": [
36
36
  "@vueuse/core",
37
37
  "@vueuse/shared",
38
+ "@nuxt/kit",
38
39
  "local-pkg",
39
40
  "fs",
40
41
  "path",
@@ -610,6 +611,13 @@
610
611
  "category": "Browser",
611
612
  "description": "reactive viewport breakpoints"
612
613
  },
614
+ {
615
+ "name": "useBroadcastChannel",
616
+ "package": "core",
617
+ "docs": "https://vueuse.org/core/useBroadcastChannel/",
618
+ "category": "Browser",
619
+ "description": "reactive [BroadcastChannel API](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel)"
620
+ },
613
621
  {
614
622
  "name": "useBrowserLocation",
615
623
  "package": "core",
@@ -906,6 +914,13 @@
906
914
  "category": "Browser",
907
915
  "description": "reactive [Media Query](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Testing_media_queries)"
908
916
  },
917
+ {
918
+ "name": "useMemoize",
919
+ "package": "core",
920
+ "docs": "https://vueuse.org/core/useMemoize/",
921
+ "category": "Utilities",
922
+ "description": "cache results of functions depending on arguments and keep it reactive"
923
+ },
909
924
  {
910
925
  "name": "useMemory",
911
926
  "package": "core",
@@ -1221,6 +1236,13 @@
1221
1236
  "category": "Component",
1222
1237
  "description": "shorthand for props v-model binding"
1223
1238
  },
1239
+ {
1240
+ "name": "useVibrate",
1241
+ "package": "core",
1242
+ "docs": "https://vueuse.org/core/useVibrate/",
1243
+ "category": "Browser",
1244
+ "description": "reactive vibration web API"
1245
+ },
1224
1246
  {
1225
1247
  "name": "useVirtualList",
1226
1248
  "package": "core",
@@ -1236,6 +1258,13 @@
1236
1258
  "category": "Browser",
1237
1259
  "description": "reactive [Screen Wake Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API) provides a way to prevent devices from dimming or locking the screen when an application needs to keep running"
1238
1260
  },
1261
+ {
1262
+ "name": "useWebNotification",
1263
+ "package": "core",
1264
+ "docs": "https://vueuse.org/core/useWebNotification/",
1265
+ "category": "Browser",
1266
+ "description": "reactive [Notification](https://developer.mozilla.org/en-US/docs/Web/API/notification)"
1267
+ },
1239
1268
  {
1240
1269
  "name": "useWebSocket",
1241
1270
  "package": "core",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueuse/nuxt",
3
- "version": "7.4.2",
3
+ "version": "7.5.2",
4
4
  "description": "VueUse Nuxt Module",
5
5
  "keywords": [
6
6
  "vue",
@@ -34,8 +34,12 @@
34
34
  "module": "./index.mjs",
35
35
  "types": "./index.d.ts",
36
36
  "dependencies": {
37
- "@vueuse/core": "7.4.2",
38
- "local-pkg": "^0.4.0",
37
+ "@nuxt/kit": "npm:@nuxt/kit-edge@latest",
38
+ "@vueuse/core": "7.5.2",
39
+ "local-pkg": "^0.4.1",
39
40
  "vue-demi": "*"
41
+ },
42
+ "devDependencies": {
43
+ "@nuxt/schema": "npm:@nuxt/schema-edge@latest"
40
44
  }
41
45
  }