@vixt/uni 0.0.8 → 0.0.9
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.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +41 -21
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,7 @@ import Layouts from '@uni-helper/vite-plugin-uni-layouts';
|
|
|
7
7
|
import Components from '@uni-helper/vite-plugin-uni-components';
|
|
8
8
|
import AutoImport from 'unplugin-auto-import/vite';
|
|
9
9
|
import UnoCSS from 'unocss/vite';
|
|
10
|
+
import { ImportsMap } from 'unplugin-auto-import/types';
|
|
10
11
|
|
|
11
12
|
declare const entryUni: _vixt_core.VixtModule<AppOptions>;
|
|
12
13
|
|
|
@@ -33,6 +34,8 @@ declare function vueusePolyfill(code: string, id: string): string;
|
|
|
33
34
|
declare function patchNormalizeNodeModules(): void;
|
|
34
35
|
declare const uniPatch: (options?: any) => vite.PluginOption;
|
|
35
36
|
|
|
37
|
+
declare const useImports: () => ImportsMap;
|
|
38
|
+
|
|
36
39
|
declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
|
|
37
40
|
|
|
38
|
-
export { _default as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, vueusePolyfill };
|
|
41
|
+
export { _default as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, useImports, vueusePolyfill };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import Layouts from '@uni-helper/vite-plugin-uni-layouts';
|
|
|
7
7
|
import Components from '@uni-helper/vite-plugin-uni-components';
|
|
8
8
|
import AutoImport from 'unplugin-auto-import/vite';
|
|
9
9
|
import UnoCSS from 'unocss/vite';
|
|
10
|
+
import { ImportsMap } from 'unplugin-auto-import/types';
|
|
10
11
|
|
|
11
12
|
declare const entryUni: _vixt_core.VixtModule<AppOptions>;
|
|
12
13
|
|
|
@@ -33,6 +34,8 @@ declare function vueusePolyfill(code: string, id: string): string;
|
|
|
33
34
|
declare function patchNormalizeNodeModules(): void;
|
|
34
35
|
declare const uniPatch: (options?: any) => vite.PluginOption;
|
|
35
36
|
|
|
37
|
+
declare const useImports: () => ImportsMap;
|
|
38
|
+
|
|
36
39
|
declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
|
|
37
40
|
|
|
38
|
-
export { _default as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, vueusePolyfill };
|
|
41
|
+
export { _default as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, useImports, vueusePolyfill };
|
package/dist/index.mjs
CHANGED
|
@@ -6,10 +6,13 @@ import Uni from '@dcloudio/vite-plugin-uni';
|
|
|
6
6
|
import Pages from '@uni-helper/vite-plugin-uni-pages';
|
|
7
7
|
import Layouts from '@uni-helper/vite-plugin-uni-layouts';
|
|
8
8
|
import Components from '@uni-helper/vite-plugin-uni-components';
|
|
9
|
-
import { uniuseAutoImports } from '@uni-helper/uni-use';
|
|
10
9
|
import AutoImport from 'unplugin-auto-import/vite';
|
|
11
10
|
import UnoCSS from 'unocss/vite';
|
|
12
11
|
import { resolvePathSync } from 'mlly';
|
|
12
|
+
import { readFileSync } from 'node:fs';
|
|
13
|
+
import process from 'node:process';
|
|
14
|
+
import { resolveModule } from 'local-pkg';
|
|
15
|
+
import { uniuseAutoImports } from '@uni-helper/uni-use';
|
|
13
16
|
|
|
14
17
|
function resolveLayersPlugins(layers, from) {
|
|
15
18
|
const { plugins = [] } = resolveLayersDirs(layers);
|
|
@@ -86,27 +89,10 @@ const presetUni = defineVixtModule({
|
|
|
86
89
|
dirs: components,
|
|
87
90
|
directoryAsNamespace: true,
|
|
88
91
|
collapseSamePrefixes: true,
|
|
89
|
-
allowOverrides: true
|
|
90
|
-
version: 2.7
|
|
92
|
+
allowOverrides: true
|
|
91
93
|
},
|
|
92
94
|
imports: {
|
|
93
|
-
imports: [
|
|
94
|
-
"vue",
|
|
95
|
-
"uni-app",
|
|
96
|
-
"pinia",
|
|
97
|
-
{
|
|
98
|
-
"@vueuse/core": [
|
|
99
|
-
// already imported by uni-use
|
|
100
|
-
["tryOnScopeDispose", ""],
|
|
101
|
-
["useNetwork", ""],
|
|
102
|
-
["useOnline", ""],
|
|
103
|
-
["usePreferredDark", ""],
|
|
104
|
-
["useStorage", ""],
|
|
105
|
-
["useStorageAsync", ""]
|
|
106
|
-
]
|
|
107
|
-
},
|
|
108
|
-
uniuseAutoImports()
|
|
109
|
-
],
|
|
95
|
+
imports: ["vue", "uni-app", "pinia", useImports()],
|
|
110
96
|
dts: `${typesDir}/auto-imports.d.ts`,
|
|
111
97
|
dirs: [...composables, ...constants, ...stores, ...utils],
|
|
112
98
|
vueTemplate: true
|
|
@@ -158,6 +144,40 @@ const uniPatch = defineVitePlugin(() => {
|
|
|
158
144
|
};
|
|
159
145
|
});
|
|
160
146
|
|
|
147
|
+
let _cache;
|
|
148
|
+
const useImports = () => {
|
|
149
|
+
const excluded = [
|
|
150
|
+
"toRefs",
|
|
151
|
+
"utils",
|
|
152
|
+
"toRef",
|
|
153
|
+
"toValue",
|
|
154
|
+
"tryOnScopeDispose",
|
|
155
|
+
"useNetwork",
|
|
156
|
+
"useOnline",
|
|
157
|
+
"usePreferredDark",
|
|
158
|
+
"useStorage",
|
|
159
|
+
"useStorageAsync"
|
|
160
|
+
];
|
|
161
|
+
if (!_cache) {
|
|
162
|
+
let indexesJson;
|
|
163
|
+
try {
|
|
164
|
+
const corePath = resolveModule("@vueuse/core") || process.cwd();
|
|
165
|
+
const path = resolveModule("@vueuse/core/indexes.json") || resolveModule("@vueuse/metadata/index.json") || resolveModule("@vueuse/metadata/index.json", { paths: [corePath] });
|
|
166
|
+
indexesJson = JSON.parse(readFileSync(path, "utf-8"));
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.error(error);
|
|
169
|
+
throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?");
|
|
170
|
+
}
|
|
171
|
+
if (indexesJson) {
|
|
172
|
+
_cache = {
|
|
173
|
+
"@vueuse/core": indexesJson.functions.filter((i) => ["core", "shared"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4 && !excluded.includes(i)),
|
|
174
|
+
...uniuseAutoImports()
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return _cache || {};
|
|
179
|
+
};
|
|
180
|
+
|
|
161
181
|
const defaults = {
|
|
162
182
|
modules: [entryUni, presetUni],
|
|
163
183
|
app: {
|
|
@@ -181,4 +201,4 @@ const defaults = {
|
|
|
181
201
|
};
|
|
182
202
|
const index = createVixtPlugin({ defaults });
|
|
183
203
|
|
|
184
|
-
export { index as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, vueusePolyfill };
|
|
204
|
+
export { index as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, useImports, vueusePolyfill };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixt/uni",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/SoulLyoko/vixt#readme",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"unocss": "^0.61.0",
|
|
33
33
|
"unplugin-auto-import": "^0.17.6",
|
|
34
34
|
"vue": "^3.4.31",
|
|
35
|
-
"@vixt/core": "0.0.
|
|
35
|
+
"@vixt/core": "0.0.9"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "unbuild"
|