@vueuse/nuxt 7.5.0 → 7.5.4
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/index.d.ts +25 -1
- package/index.mjs +57 -48
- package/indexes.json +610 -426
- package/package.json +7 -3
package/index.d.ts
CHANGED
|
@@ -1 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface VueUseNuxtOptions {
|
|
4
|
+
/**
|
|
5
|
+
* @default true
|
|
6
|
+
*/
|
|
7
|
+
autoImports?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* @expiremental
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
ssrHandlers?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: _nuxt_schema.NuxtModule<VueUseNuxtOptions>;
|
|
15
|
+
|
|
16
|
+
declare module '@nuxt/schema' {
|
|
17
|
+
interface NuxtConfig {
|
|
18
|
+
vueuse?: VueUseNuxtOptions;
|
|
19
|
+
}
|
|
20
|
+
interface NuxtOptions {
|
|
21
|
+
vueuse?: VueUseNuxtOptions;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { VueUseNuxtOptions, _default as default };
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
nuxt.options.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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 {
|
|
85
|
+
export { index as default };
|