@vueuse/nuxt 7.5.1 → 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 +1 -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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueuse/nuxt",
3
- "version": "7.5.1",
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.5.1",
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
  }