@vixt/uni 0.0.8 → 0.0.10
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 -22
- 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);
|
|
@@ -85,28 +88,10 @@ const presetUni = defineVixtModule({
|
|
|
85
88
|
dts: `${typesDir}/components.d.ts`,
|
|
86
89
|
dirs: components,
|
|
87
90
|
directoryAsNamespace: true,
|
|
88
|
-
collapseSamePrefixes: true
|
|
89
|
-
allowOverrides: true,
|
|
90
|
-
version: 2.7
|
|
91
|
+
collapseSamePrefixes: true
|
|
91
92
|
},
|
|
92
93
|
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
|
-
],
|
|
94
|
+
imports: ["vue", "uni-app", "pinia", useImports()],
|
|
110
95
|
dts: `${typesDir}/auto-imports.d.ts`,
|
|
111
96
|
dirs: [...composables, ...constants, ...stores, ...utils],
|
|
112
97
|
vueTemplate: true
|
|
@@ -158,6 +143,40 @@ const uniPatch = defineVitePlugin(() => {
|
|
|
158
143
|
};
|
|
159
144
|
});
|
|
160
145
|
|
|
146
|
+
let _cache;
|
|
147
|
+
const useImports = () => {
|
|
148
|
+
const excluded = [
|
|
149
|
+
"toRefs",
|
|
150
|
+
"utils",
|
|
151
|
+
"toRef",
|
|
152
|
+
"toValue",
|
|
153
|
+
"tryOnScopeDispose",
|
|
154
|
+
"useNetwork",
|
|
155
|
+
"useOnline",
|
|
156
|
+
"usePreferredDark",
|
|
157
|
+
"useStorage",
|
|
158
|
+
"useStorageAsync"
|
|
159
|
+
];
|
|
160
|
+
if (!_cache) {
|
|
161
|
+
let indexesJson;
|
|
162
|
+
try {
|
|
163
|
+
const corePath = resolveModule("@vueuse/core") || process.cwd();
|
|
164
|
+
const path = resolveModule("@vueuse/core/indexes.json") || resolveModule("@vueuse/metadata/index.json") || resolveModule("@vueuse/metadata/index.json", { paths: [corePath] });
|
|
165
|
+
indexesJson = JSON.parse(readFileSync(path, "utf-8"));
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error(error);
|
|
168
|
+
throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?");
|
|
169
|
+
}
|
|
170
|
+
if (indexesJson) {
|
|
171
|
+
_cache = {
|
|
172
|
+
"@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)),
|
|
173
|
+
...uniuseAutoImports()
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return _cache || {};
|
|
178
|
+
};
|
|
179
|
+
|
|
161
180
|
const defaults = {
|
|
162
181
|
modules: [entryUni, presetUni],
|
|
163
182
|
app: {
|
|
@@ -181,4 +200,4 @@ const defaults = {
|
|
|
181
200
|
};
|
|
182
201
|
const index = createVixtPlugin({ defaults });
|
|
183
202
|
|
|
184
|
-
export { index as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, vueusePolyfill };
|
|
203
|
+
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.10",
|
|
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.10"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "unbuild"
|