@vueuse/nuxt 7.7.1 → 8.0.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
@@ -12,11 +12,10 @@ npm i <b>@vueuse/nuxt</b>
12
12
 
13
13
  ```ts
14
14
  // nuxt.config
15
-
16
- export function defineNuxtConfig({
17
- buildModules: [
18
- '@vueuse/nuxt'
19
- ]
15
+ export default defineNuxtConfig({
16
+ modules: [
17
+ '@vueuse/nuxt',
18
+ ],
20
19
  })
21
20
  ```
22
21
 
package/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import fs from 'fs';
2
1
  import { dirname, resolve } from 'path';
3
2
  import { fileURLToPath } from 'url';
4
3
  import { isPackageExists } from 'local-pkg';
5
4
  import { defineNuxtModule } from '@nuxt/kit';
5
+ import { metadata } from '@vueuse/metadata';
6
6
 
7
7
  const _dirname = dirname(fileURLToPath(import.meta.url));
8
8
  const disabledFunctions = [
@@ -41,7 +41,6 @@ var index = defineNuxtModule({
41
41
  nuxt.options.build = nuxt.options.build || {};
42
42
  nuxt.options.build.transpile = nuxt.options.build.transpile || [];
43
43
  nuxt.options.build.transpile.push(...fullPackages);
44
- let indexes;
45
44
  if (options.ssrHandlers) {
46
45
  const pluginPath = resolve(_dirname, "./ssr-plugin.mjs");
47
46
  nuxt.options.plugins = nuxt.options.plugins || [];
@@ -51,29 +50,22 @@ var index = defineNuxtModule({
51
50
  nuxt.hook("autoImports:sources", (sources) => {
52
51
  if (sources.find((i) => fullPackages.includes(i.from)))
53
52
  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
- }
64
- }
65
- if (!indexes)
66
- return;
53
+ metadata.functions.forEach((i) => {
54
+ if (i.package === "shared")
55
+ i.package = "core";
56
+ });
67
57
  for (const pkg of packages) {
68
58
  if (pkg === "shared")
69
59
  continue;
70
60
  if (!isPackageExists(`@vueuse/${pkg}`))
71
61
  continue;
72
- const functions = indexes.functions.filter((i) => (i.package === "core" || i.package === "shared") && !i.internal);
62
+ const functions = metadata.functions.filter((i) => (i.package === "core" || i.package === "shared") && !i.internal);
73
63
  if (functions.length) {
64
+ const imports = metadata.functions.filter((i) => i.package === pkg && !i.internal).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i.length >= 4 && !disabledFunctions.includes(i));
74
65
  sources.push({
75
66
  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))
67
+ names: imports,
68
+ imports
77
69
  });
78
70
  }
79
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueuse/nuxt",
3
- "version": "7.7.1",
3
+ "version": "8.0.0",
4
4
  "description": "VueUse Nuxt Module",
5
5
  "keywords": [
6
6
  "vue",
@@ -14,14 +14,16 @@
14
14
  "url": "https://github.com/vueuse/vueuse/issues"
15
15
  },
16
16
  "license": "MIT",
17
+ "author": "Anthony Fu <https://github.com/antfu>",
17
18
  "repository": {
18
19
  "type": "git",
19
20
  "url": "git+https://github.com/vueuse/vueuse.git",
20
21
  "directory": "packages/nuxt"
21
22
  },
22
23
  "funding": "https://github.com/sponsors/antfu",
23
- "author": "Anthony Fu <https://github.com/antfu>",
24
- "sideEffects": false,
24
+ "main": "./index.cjs",
25
+ "module": "./index.mjs",
26
+ "types": "./index.d.ts",
25
27
  "exports": {
26
28
  ".": {
27
29
  "import": "./index.mjs",
@@ -30,12 +32,11 @@
30
32
  },
31
33
  "./*": "./*"
32
34
  },
33
- "main": "./index.cjs",
34
- "module": "./index.mjs",
35
- "types": "./index.d.ts",
35
+ "sideEffects": false,
36
36
  "dependencies": {
37
37
  "@nuxt/kit": "npm:@nuxt/kit-edge@latest",
38
- "@vueuse/core": "7.7.1",
38
+ "@vueuse/core": "8.0.0",
39
+ "@vueuse/metadata": "8.0.0",
39
40
  "local-pkg": "^0.4.1",
40
41
  "vue-demi": "*"
41
42
  },
package/ssr-plugin.mjs CHANGED
@@ -10,9 +10,9 @@ setSSRHandler('getDefaultStorage', () => {
10
10
  return cookieMap.get(key)
11
11
  }
12
12
  return {
13
- getItem: (key) => get(key).value,
13
+ getItem: key => get(key).value,
14
14
  setItem: (key, value) => get(key).value = value,
15
- removeItem: (key) => get(key).value = undefined
15
+ removeItem: key => get(key).value = undefined,
16
16
  }
17
17
  })
18
18