@vueuse/nuxt 13.9.0 → 14.0.0-alpha.1
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/dist/index.d.ts +38 -0
- package/dist/index.js +112 -0
- package/package.json +10 -12
- package/index.d.mts +0 -39
- package/index.mjs +0 -112
- /package/{ssr-plugin.mjs → dist/ssr-plugin.mjs} +0 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as _nuxt_schema0 from "@nuxt/schema";
|
|
2
|
+
|
|
3
|
+
//#region index.d.ts
|
|
4
|
+
interface VueUseNuxtOptions {
|
|
5
|
+
/**
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
autoImports?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* @experimental
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
ssrHandlers?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Auto import for VueUse in Nuxt
|
|
17
|
+
* Usage:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* // nuxt.config.js
|
|
21
|
+
* export default {
|
|
22
|
+
* buildModules: [
|
|
23
|
+
* '@vueuse/nuxt'
|
|
24
|
+
* ]
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
declare const _default: _nuxt_schema0.NuxtModule<VueUseNuxtOptions, VueUseNuxtOptions, false>;
|
|
29
|
+
declare module '@nuxt/schema' {
|
|
30
|
+
interface NuxtConfig {
|
|
31
|
+
vueuse?: VueUseNuxtOptions;
|
|
32
|
+
}
|
|
33
|
+
interface NuxtOptions {
|
|
34
|
+
vueuse?: VueUseNuxtOptions;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { VueUseNuxtOptions, _default as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { defineNuxtModule } from "@nuxt/kit";
|
|
4
|
+
import { metadata } from "@vueuse/metadata";
|
|
5
|
+
import { isPackageExists } from "local-pkg";
|
|
6
|
+
|
|
7
|
+
//#region index.ts
|
|
8
|
+
const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const disabledFunctions = [
|
|
10
|
+
"toRefs",
|
|
11
|
+
"toRef",
|
|
12
|
+
"toValue",
|
|
13
|
+
"useFetch",
|
|
14
|
+
"useCookie",
|
|
15
|
+
"useHead",
|
|
16
|
+
"useStorage",
|
|
17
|
+
"useImage"
|
|
18
|
+
];
|
|
19
|
+
const packages = [
|
|
20
|
+
"core",
|
|
21
|
+
"shared",
|
|
22
|
+
"components",
|
|
23
|
+
"motion",
|
|
24
|
+
"firebase",
|
|
25
|
+
"rxjs",
|
|
26
|
+
"sound",
|
|
27
|
+
"math",
|
|
28
|
+
"router"
|
|
29
|
+
];
|
|
30
|
+
const fullPackages = packages.map((p) => `@vueuse/${p}`);
|
|
31
|
+
/**
|
|
32
|
+
* Auto import for VueUse in Nuxt
|
|
33
|
+
* Usage:
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* // nuxt.config.js
|
|
37
|
+
* export default {
|
|
38
|
+
* buildModules: [
|
|
39
|
+
* '@vueuse/nuxt'
|
|
40
|
+
* ]
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
var nuxt_default = defineNuxtModule({
|
|
45
|
+
meta: {
|
|
46
|
+
name: "vueuse",
|
|
47
|
+
configKey: "vueuse"
|
|
48
|
+
},
|
|
49
|
+
defaults: {
|
|
50
|
+
ssrHandlers: false,
|
|
51
|
+
autoImports: true
|
|
52
|
+
},
|
|
53
|
+
setup(options, nuxt) {
|
|
54
|
+
nuxt.hook("vite:extend", ({ config }) => {
|
|
55
|
+
config.optimizeDeps = config.optimizeDeps || {};
|
|
56
|
+
config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
|
|
57
|
+
for (const pkg of fullPackages) if (!config.optimizeDeps.exclude.includes(pkg)) config.optimizeDeps.exclude.push(pkg);
|
|
58
|
+
});
|
|
59
|
+
nuxt.options.build = nuxt.options.build || {};
|
|
60
|
+
nuxt.options.build.transpile = nuxt.options.build.transpile || [];
|
|
61
|
+
nuxt.options.build.transpile.push(...fullPackages);
|
|
62
|
+
if (options.ssrHandlers) {
|
|
63
|
+
const pluginPath = resolve(_dirname, "./ssr-plugin.mjs");
|
|
64
|
+
nuxt.options.plugins = nuxt.options.plugins || [];
|
|
65
|
+
nuxt.options.plugins.push(pluginPath);
|
|
66
|
+
nuxt.options.build.transpile.push(pluginPath);
|
|
67
|
+
}
|
|
68
|
+
nuxt.hook("devtools:customTabs", (iframeTabs) => {
|
|
69
|
+
iframeTabs.push({
|
|
70
|
+
name: "vueuse",
|
|
71
|
+
title: "VueUse",
|
|
72
|
+
icon: "i-logos-vueuse",
|
|
73
|
+
view: {
|
|
74
|
+
type: "iframe",
|
|
75
|
+
src: "https://vueuse.org/functions.html"
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
if (options.autoImports) nuxt.hook("imports:sources", (sources) => {
|
|
80
|
+
if (sources.find((i) => fullPackages.includes(i.from))) return;
|
|
81
|
+
metadata.functions.forEach((i) => {
|
|
82
|
+
if (i.package === "shared") i.package = "core";
|
|
83
|
+
});
|
|
84
|
+
for (const pkg of packages) {
|
|
85
|
+
if (pkg === "shared") continue;
|
|
86
|
+
if (pkg !== "core" && !isPackageExists(`@vueuse/${pkg}`, { paths: nuxt.options._layers.map((layer) => layer.config.rootDir) })) continue;
|
|
87
|
+
const imports = metadata.functions.filter((i) => i.package === pkg && !i.internal).flatMap((i) => {
|
|
88
|
+
const names = [i.name, ...i.alias || []];
|
|
89
|
+
return names.map((n) => ({
|
|
90
|
+
from: `@vueuse/${i.importPath || i.package}`,
|
|
91
|
+
name: n,
|
|
92
|
+
as: n,
|
|
93
|
+
priority: -1,
|
|
94
|
+
meta: {
|
|
95
|
+
description: i.description,
|
|
96
|
+
docsUrl: i.docs,
|
|
97
|
+
category: i.category
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
}).filter((i) => i.name.length >= 4 && !disabledFunctions.includes(i.name));
|
|
101
|
+
sources.push({
|
|
102
|
+
from: "@vueuse/core",
|
|
103
|
+
imports,
|
|
104
|
+
priority: -1
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
export { nuxt_default as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "14.0.0-alpha.1",
|
|
5
5
|
"description": "VueUse Nuxt Module",
|
|
6
6
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -24,16 +24,14 @@
|
|
|
24
24
|
],
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"exports": {
|
|
27
|
-
".": "./index.
|
|
28
|
-
"./*": "
|
|
27
|
+
".": "./dist/index.js",
|
|
28
|
+
"./*": "./dist/*"
|
|
29
29
|
},
|
|
30
|
-
"main": "./index.
|
|
31
|
-
"module": "./index.
|
|
32
|
-
"types": "./index.d.
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"module": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
33
|
"files": [
|
|
34
|
-
"
|
|
35
|
-
"*.js",
|
|
36
|
-
"*.mjs"
|
|
34
|
+
"dist"
|
|
37
35
|
],
|
|
38
36
|
"peerDependencies": {
|
|
39
37
|
"nuxt": "^3.0.0 || ^4.0.0-0",
|
|
@@ -42,8 +40,8 @@
|
|
|
42
40
|
"dependencies": {
|
|
43
41
|
"@nuxt/kit": "^3.18.1",
|
|
44
42
|
"local-pkg": "^1.1.2",
|
|
45
|
-
"@vueuse/core": "
|
|
46
|
-
"@vueuse/metadata": "
|
|
43
|
+
"@vueuse/core": "14.0.0-alpha.1",
|
|
44
|
+
"@vueuse/metadata": "14.0.0-alpha.1"
|
|
47
45
|
},
|
|
48
46
|
"devDependencies": {
|
|
49
47
|
"@nuxt/schema": "^3.18.1",
|
|
@@ -51,7 +49,7 @@
|
|
|
51
49
|
"unimport": "^5.2.0"
|
|
52
50
|
},
|
|
53
51
|
"scripts": {
|
|
54
|
-
"build": "
|
|
52
|
+
"build": "tsdown",
|
|
55
53
|
"test:attw": "attw --pack --config-path ../../.attw.json ."
|
|
56
54
|
}
|
|
57
55
|
}
|
package/index.d.mts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
|
|
3
|
-
interface VueUseNuxtOptions {
|
|
4
|
-
/**
|
|
5
|
-
* @default true
|
|
6
|
-
*/
|
|
7
|
-
autoImports?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* @experimental
|
|
10
|
-
* @default false
|
|
11
|
-
*/
|
|
12
|
-
ssrHandlers?: boolean;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Auto import for VueUse in Nuxt
|
|
16
|
-
* Usage:
|
|
17
|
-
*
|
|
18
|
-
* ```ts
|
|
19
|
-
* // nuxt.config.js
|
|
20
|
-
* export default {
|
|
21
|
-
* buildModules: [
|
|
22
|
-
* '@vueuse/nuxt'
|
|
23
|
-
* ]
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
declare const _default: _nuxt_schema.NuxtModule<VueUseNuxtOptions, VueUseNuxtOptions, false>;
|
|
28
|
-
|
|
29
|
-
declare module '@nuxt/schema' {
|
|
30
|
-
interface NuxtConfig {
|
|
31
|
-
vueuse?: VueUseNuxtOptions;
|
|
32
|
-
}
|
|
33
|
-
interface NuxtOptions {
|
|
34
|
-
vueuse?: VueUseNuxtOptions;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { _default as default };
|
|
39
|
-
export type { VueUseNuxtOptions };
|
package/index.mjs
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { dirname, resolve } from 'node:path';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { defineNuxtModule } from '@nuxt/kit';
|
|
4
|
-
import { metadata } from '@vueuse/metadata';
|
|
5
|
-
import { isPackageExists } from 'local-pkg';
|
|
6
|
-
|
|
7
|
-
const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const disabledFunctions = [
|
|
9
|
-
// Vue 3 built-in
|
|
10
|
-
"toRefs",
|
|
11
|
-
"toRef",
|
|
12
|
-
"toValue",
|
|
13
|
-
// Nuxt built-in
|
|
14
|
-
"useFetch",
|
|
15
|
-
"useCookie",
|
|
16
|
-
"useHead",
|
|
17
|
-
"useStorage",
|
|
18
|
-
"useImage"
|
|
19
|
-
];
|
|
20
|
-
const packages = [
|
|
21
|
-
"core",
|
|
22
|
-
"shared",
|
|
23
|
-
"components",
|
|
24
|
-
"motion",
|
|
25
|
-
"firebase",
|
|
26
|
-
"rxjs",
|
|
27
|
-
"sound",
|
|
28
|
-
"math",
|
|
29
|
-
"router"
|
|
30
|
-
];
|
|
31
|
-
const fullPackages = packages.map((p) => `@vueuse/${p}`);
|
|
32
|
-
var index = defineNuxtModule({
|
|
33
|
-
meta: {
|
|
34
|
-
name: "vueuse",
|
|
35
|
-
configKey: "vueuse"
|
|
36
|
-
},
|
|
37
|
-
defaults: {
|
|
38
|
-
ssrHandlers: false,
|
|
39
|
-
autoImports: true
|
|
40
|
-
},
|
|
41
|
-
setup(options, nuxt) {
|
|
42
|
-
nuxt.hook("vite:extend", ({ config }) => {
|
|
43
|
-
config.optimizeDeps = config.optimizeDeps || {};
|
|
44
|
-
config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
|
|
45
|
-
for (const pkg of fullPackages) {
|
|
46
|
-
if (!config.optimizeDeps.exclude.includes(pkg))
|
|
47
|
-
config.optimizeDeps.exclude.push(pkg);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
nuxt.options.build = nuxt.options.build || {};
|
|
51
|
-
nuxt.options.build.transpile = nuxt.options.build.transpile || [];
|
|
52
|
-
nuxt.options.build.transpile.push(...fullPackages);
|
|
53
|
-
if (options.ssrHandlers) {
|
|
54
|
-
const pluginPath = resolve(_dirname, "./ssr-plugin.mjs");
|
|
55
|
-
nuxt.options.plugins = nuxt.options.plugins || [];
|
|
56
|
-
nuxt.options.plugins.push(pluginPath);
|
|
57
|
-
nuxt.options.build.transpile.push(pluginPath);
|
|
58
|
-
}
|
|
59
|
-
nuxt.hook("devtools:customTabs", (iframeTabs) => {
|
|
60
|
-
iframeTabs.push({
|
|
61
|
-
name: "vueuse",
|
|
62
|
-
title: "VueUse",
|
|
63
|
-
icon: "i-logos-vueuse",
|
|
64
|
-
view: {
|
|
65
|
-
type: "iframe",
|
|
66
|
-
src: "https://vueuse.org/functions.html"
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
if (options.autoImports) {
|
|
71
|
-
nuxt.hook("imports:sources", (sources) => {
|
|
72
|
-
if (sources.find((i) => fullPackages.includes(i.from)))
|
|
73
|
-
return;
|
|
74
|
-
metadata.functions.forEach((i) => {
|
|
75
|
-
if (i.package === "shared")
|
|
76
|
-
i.package = "core";
|
|
77
|
-
});
|
|
78
|
-
for (const pkg of packages) {
|
|
79
|
-
if (pkg === "shared")
|
|
80
|
-
continue;
|
|
81
|
-
if (pkg !== "core" && !isPackageExists(
|
|
82
|
-
`@vueuse/${pkg}`,
|
|
83
|
-
{ paths: nuxt.options._layers.map((layer) => layer.config.rootDir) }
|
|
84
|
-
)) {
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
const imports = metadata.functions.filter((i) => i.package === pkg && !i.internal).flatMap((i) => {
|
|
88
|
-
const names = [i.name, ...i.alias || []];
|
|
89
|
-
return names.map((n) => ({
|
|
90
|
-
from: `@vueuse/${i.importPath || i.package}`,
|
|
91
|
-
name: n,
|
|
92
|
-
as: n,
|
|
93
|
-
priority: -1,
|
|
94
|
-
meta: {
|
|
95
|
-
description: i.description,
|
|
96
|
-
docsUrl: i.docs,
|
|
97
|
-
category: i.category
|
|
98
|
-
}
|
|
99
|
-
}));
|
|
100
|
-
}).filter((i) => i.name.length >= 4 && !disabledFunctions.includes(i.name));
|
|
101
|
-
sources.push({
|
|
102
|
-
from: "@vueuse/core",
|
|
103
|
-
imports,
|
|
104
|
-
priority: -1
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
export { index as default };
|
|
File without changes
|