@vueuse/nuxt 7.2.1 → 7.4.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/index.cjs +1 -1
- package/index.mjs +38 -30
- package/indexes.json +62 -1
- package/package.json +8 -8
- package/ssr-plugin.mjs +48 -0
package/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// CommonJS proxy to bypass jiti transforms from nuxt 2 and using native ESM
|
|
2
2
|
module.exports = function(...args) {
|
|
3
|
-
return import('./index.
|
|
3
|
+
return import('./index.mjs').then(m => m.default.call(this, ...args))
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
module.exports.meta = require('./package.json')
|
package/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { dirname, resolve } from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { isPackageExists } from 'local-pkg';
|
|
5
5
|
|
|
6
|
-
const _dirname =
|
|
6
|
+
const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
7
|
const disabledFunctions = [
|
|
8
8
|
"useFetch",
|
|
9
9
|
"toRefs",
|
|
@@ -24,6 +24,7 @@ const packages = [
|
|
|
24
24
|
const fullPackages = packages.map((p) => `@vueuse/${p}`);
|
|
25
25
|
function VueUseModule() {
|
|
26
26
|
const { nuxt } = this;
|
|
27
|
+
const options = nuxt.options.vueuse || {};
|
|
27
28
|
nuxt.hook("vite:extend", ({ config }) => {
|
|
28
29
|
config.optimizeDeps = config.optimizeDeps || {};
|
|
29
30
|
config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
|
|
@@ -31,38 +32,45 @@ function VueUseModule() {
|
|
|
31
32
|
});
|
|
32
33
|
nuxt.options.build = nuxt.options.build || {};
|
|
33
34
|
nuxt.options.build.transpile = nuxt.options.build.transpile || [];
|
|
34
|
-
nuxt.options.build.transpile.push("@vueuse/nuxt");
|
|
35
|
+
nuxt.options.build.transpile.push("@vueuse/nuxt", "@vueuse/core", "@vueuse/shared");
|
|
35
36
|
let indexes;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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");
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
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
|
+
});
|
|
70
|
+
}
|
|
63
71
|
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
export { VueUseModule as default };
|
package/indexes.json
CHANGED
|
@@ -35,7 +35,10 @@
|
|
|
35
35
|
"external": [
|
|
36
36
|
"@vueuse/core",
|
|
37
37
|
"@vueuse/shared",
|
|
38
|
-
"local-pkg"
|
|
38
|
+
"local-pkg",
|
|
39
|
+
"fs",
|
|
40
|
+
"path",
|
|
41
|
+
"url"
|
|
39
42
|
],
|
|
40
43
|
"dir": "packages/nuxt",
|
|
41
44
|
"docs": "https://vueuse.org/nuxt/README.html"
|
|
@@ -629,6 +632,14 @@
|
|
|
629
632
|
"category": "Browser",
|
|
630
633
|
"description": "reactive [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API)"
|
|
631
634
|
},
|
|
635
|
+
{
|
|
636
|
+
"name": "useColorMode",
|
|
637
|
+
"package": "core",
|
|
638
|
+
"component": true,
|
|
639
|
+
"docs": "https://vueuse.org/core/useColorMode/",
|
|
640
|
+
"category": "Browser",
|
|
641
|
+
"description": "reactive color mode (dark / light / customs) with auto data persistence"
|
|
642
|
+
},
|
|
632
643
|
{
|
|
633
644
|
"name": "useConfirmDialog",
|
|
634
645
|
"package": "core",
|
|
@@ -643,6 +654,13 @@
|
|
|
643
654
|
"category": "Browser",
|
|
644
655
|
"description": "manipulate CSS variables"
|
|
645
656
|
},
|
|
657
|
+
{
|
|
658
|
+
"name": "useCycleList",
|
|
659
|
+
"package": "core",
|
|
660
|
+
"docs": "https://vueuse.org/core/useCycleList/",
|
|
661
|
+
"category": "Utilities",
|
|
662
|
+
"description": "cycle through a list of items"
|
|
663
|
+
},
|
|
646
664
|
{
|
|
647
665
|
"name": "useDark",
|
|
648
666
|
"package": "core",
|
|
@@ -721,6 +739,13 @@
|
|
|
721
739
|
"category": "Sensors",
|
|
722
740
|
"description": "reactive [bounding box](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) of an HTML element"
|
|
723
741
|
},
|
|
742
|
+
{
|
|
743
|
+
"name": "useElementByPoint",
|
|
744
|
+
"package": "core",
|
|
745
|
+
"docs": "https://vueuse.org/core/useElementByPoint/",
|
|
746
|
+
"category": "Sensors",
|
|
747
|
+
"description": "reactive element by point"
|
|
748
|
+
},
|
|
724
749
|
{
|
|
725
750
|
"name": "useElementHover",
|
|
726
751
|
"package": "core",
|
|
@@ -926,6 +951,13 @@
|
|
|
926
951
|
"category": "Sensors",
|
|
927
952
|
"description": "watch for changes being made to the DOM tree"
|
|
928
953
|
},
|
|
954
|
+
{
|
|
955
|
+
"name": "useNavigatorLanguage",
|
|
956
|
+
"package": "core",
|
|
957
|
+
"docs": "https://vueuse.org/core/useNavigatorLanguage/",
|
|
958
|
+
"category": "Sensors",
|
|
959
|
+
"description": "watch for changes being made to the navigator language preference by the user"
|
|
960
|
+
},
|
|
929
961
|
{
|
|
930
962
|
"name": "useNetwork",
|
|
931
963
|
"package": "core",
|
|
@@ -1032,6 +1064,14 @@
|
|
|
1032
1064
|
"category": "Sensors",
|
|
1033
1065
|
"description": "reports changes to the dimensions of an Element's content or the border-box"
|
|
1034
1066
|
},
|
|
1067
|
+
{
|
|
1068
|
+
"name": "useScreenSafeArea",
|
|
1069
|
+
"package": "core",
|
|
1070
|
+
"component": true,
|
|
1071
|
+
"docs": "https://vueuse.org/core/useScreenSafeArea/",
|
|
1072
|
+
"category": "Browser",
|
|
1073
|
+
"description": "reactive `env(safe-area-inset-*)`"
|
|
1074
|
+
},
|
|
1035
1075
|
{
|
|
1036
1076
|
"name": "useScriptTag",
|
|
1037
1077
|
"package": "core",
|
|
@@ -1088,6 +1128,13 @@
|
|
|
1088
1128
|
"category": "State",
|
|
1089
1129
|
"description": "reactive [LocalStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)/[SessionStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)"
|
|
1090
1130
|
},
|
|
1131
|
+
{
|
|
1132
|
+
"name": "useStorageAsync",
|
|
1133
|
+
"package": "core",
|
|
1134
|
+
"docs": "https://vueuse.org/core/useStorageAsync/",
|
|
1135
|
+
"category": "State",
|
|
1136
|
+
"description": "reactive Storage in with async support"
|
|
1137
|
+
},
|
|
1091
1138
|
{
|
|
1092
1139
|
"name": "useSwipe",
|
|
1093
1140
|
"package": "core",
|
|
@@ -1102,6 +1149,13 @@
|
|
|
1102
1149
|
"category": "Component",
|
|
1103
1150
|
"description": "shorthand for binding refs to template elements and components inside `v-for`"
|
|
1104
1151
|
},
|
|
1152
|
+
{
|
|
1153
|
+
"name": "useTextSelection",
|
|
1154
|
+
"package": "core",
|
|
1155
|
+
"docs": "https://vueuse.org/core/useTextSelection/",
|
|
1156
|
+
"category": "Sensors",
|
|
1157
|
+
"description": "reactively track user text selection based on [`Window.getSelection`](https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection)"
|
|
1158
|
+
},
|
|
1105
1159
|
{
|
|
1106
1160
|
"name": "useThrottledRefHistory",
|
|
1107
1161
|
"package": "core",
|
|
@@ -1318,6 +1372,13 @@
|
|
|
1318
1372
|
"category": "@RxJS",
|
|
1319
1373
|
"description": "use an Observable"
|
|
1320
1374
|
},
|
|
1375
|
+
{
|
|
1376
|
+
"name": "useSubject",
|
|
1377
|
+
"package": "rxjs",
|
|
1378
|
+
"docs": "https://vueuse.org/rxjs/useSubject/",
|
|
1379
|
+
"category": "@RxJS",
|
|
1380
|
+
"description": "bind Subject to ref and propagate value changes both ways"
|
|
1381
|
+
},
|
|
1321
1382
|
{
|
|
1322
1383
|
"name": "useSubscription",
|
|
1323
1384
|
"package": "rxjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/nuxt",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.1",
|
|
4
4
|
"description": "VueUse Nuxt Module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"nuxt3",
|
|
10
10
|
"nuxt-module"
|
|
11
11
|
],
|
|
12
|
+
"homepage": "https://github.com/vueuse/vueuse/tree/main/packages/nuxt#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/vueuse/vueuse/issues"
|
|
15
|
+
},
|
|
12
16
|
"license": "MIT",
|
|
13
17
|
"repository": {
|
|
14
18
|
"type": "git",
|
|
@@ -17,6 +21,7 @@
|
|
|
17
21
|
},
|
|
18
22
|
"funding": "https://github.com/sponsors/antfu",
|
|
19
23
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
24
|
+
"sideEffects": false,
|
|
20
25
|
"exports": {
|
|
21
26
|
".": {
|
|
22
27
|
"import": "./index.mjs",
|
|
@@ -26,15 +31,10 @@
|
|
|
26
31
|
"./*": "./*"
|
|
27
32
|
},
|
|
28
33
|
"main": "./index.cjs",
|
|
29
|
-
"types": "./index.d.ts",
|
|
30
34
|
"module": "./index.mjs",
|
|
31
|
-
"
|
|
32
|
-
"bugs": {
|
|
33
|
-
"url": "https://github.com/vueuse/vueuse/issues"
|
|
34
|
-
},
|
|
35
|
-
"homepage": "https://github.com/vueuse/vueuse/tree/main/packages/nuxt#readme",
|
|
35
|
+
"types": "./index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@vueuse/core": "7.
|
|
37
|
+
"@vueuse/core": "7.4.1",
|
|
38
38
|
"local-pkg": "^0.4.0",
|
|
39
39
|
"vue-demi": "*"
|
|
40
40
|
}
|
package/ssr-plugin.mjs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { setSSRHandler } from '@vueuse/core'
|
|
2
|
+
import { useMeta } from '#meta'
|
|
3
|
+
import { useCookie } from '#app'
|
|
4
|
+
|
|
5
|
+
setSSRHandler('getDefaultStorage', () => {
|
|
6
|
+
const cookieMap = new Map()
|
|
7
|
+
return {
|
|
8
|
+
getItem: (key) => {
|
|
9
|
+
if (!cookieMap.get(key))
|
|
10
|
+
cookieMap.set(key, useCookie(key))
|
|
11
|
+
return cookieMap.get(key).value
|
|
12
|
+
},
|
|
13
|
+
setItem: (key, value) => {
|
|
14
|
+
if (!cookieMap.get(key))
|
|
15
|
+
cookieMap.set(key, useCookie(key))
|
|
16
|
+
cookieMap.get(key).value = value
|
|
17
|
+
},
|
|
18
|
+
removeItem: (key) => {
|
|
19
|
+
if (!cookieMap.get(key))
|
|
20
|
+
cookieMap.set(key, useCookie(key))
|
|
21
|
+
cookieMap.get(key).value = undefined
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
if (process.server) {
|
|
27
|
+
setSSRHandler('updateHTMLAttrs', (selector, attr, value) => {
|
|
28
|
+
if (selector === 'html') {
|
|
29
|
+
useMeta({
|
|
30
|
+
htmlAttrs: {
|
|
31
|
+
[attr]: value,
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
else if (selector === 'body') {
|
|
36
|
+
useMeta({
|
|
37
|
+
bodyAttrs: {
|
|
38
|
+
[attr]: value,
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw new Error(`Unsupported meta selector "${selector}" in SSR`)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default () => {}
|