@vixt/uni 0.0.7 → 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 CHANGED
@@ -3,9 +3,11 @@ import * as _vixt_core from '@vixt/core';
3
3
  import { AppOptions, PluginOptions, VixtOptions } from '@vixt/core';
4
4
  import Uni from '@dcloudio/vite-plugin-uni';
5
5
  import Pages from '@uni-helper/vite-plugin-uni-pages';
6
+ import Layouts from '@uni-helper/vite-plugin-uni-layouts';
6
7
  import Components from '@uni-helper/vite-plugin-uni-components';
7
8
  import AutoImport from 'unplugin-auto-import/vite';
8
9
  import UnoCSS from 'unocss/vite';
10
+ import { ImportsMap } from 'unplugin-auto-import/types';
9
11
 
10
12
  declare const entryUni: _vixt_core.VixtModule<AppOptions>;
11
13
 
@@ -15,7 +17,7 @@ declare module '@vixt/core' {
15
17
  /** https://github.com/uni-helper/vite-plugin-uni-pages */
16
18
  pages?: PluginOptions<typeof Pages>;
17
19
  /** https://github.com/uni-helper/vite-plugin-uni-layouts */
18
- layouts?: any;
20
+ uniLayouts?: PluginOptions<typeof Layouts>;
19
21
  /** https://github.com/uni-helper/vite-plugin-uni-components */
20
22
  components?: PluginOptions<typeof Components>;
21
23
  /** https://github.com/antfu/unplugin-auto-import */
@@ -32,6 +34,8 @@ declare function vueusePolyfill(code: string, id: string): string;
32
34
  declare function patchNormalizeNodeModules(): void;
33
35
  declare const uniPatch: (options?: any) => vite.PluginOption;
34
36
 
37
+ declare const useImports: () => ImportsMap;
38
+
35
39
  declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
36
40
 
37
- 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
@@ -3,9 +3,11 @@ import * as _vixt_core from '@vixt/core';
3
3
  import { AppOptions, PluginOptions, VixtOptions } from '@vixt/core';
4
4
  import Uni from '@dcloudio/vite-plugin-uni';
5
5
  import Pages from '@uni-helper/vite-plugin-uni-pages';
6
+ import Layouts from '@uni-helper/vite-plugin-uni-layouts';
6
7
  import Components from '@uni-helper/vite-plugin-uni-components';
7
8
  import AutoImport from 'unplugin-auto-import/vite';
8
9
  import UnoCSS from 'unocss/vite';
10
+ import { ImportsMap } from 'unplugin-auto-import/types';
9
11
 
10
12
  declare const entryUni: _vixt_core.VixtModule<AppOptions>;
11
13
 
@@ -15,7 +17,7 @@ declare module '@vixt/core' {
15
17
  /** https://github.com/uni-helper/vite-plugin-uni-pages */
16
18
  pages?: PluginOptions<typeof Pages>;
17
19
  /** https://github.com/uni-helper/vite-plugin-uni-layouts */
18
- layouts?: any;
20
+ uniLayouts?: PluginOptions<typeof Layouts>;
19
21
  /** https://github.com/uni-helper/vite-plugin-uni-components */
20
22
  components?: PluginOptions<typeof Components>;
21
23
  /** https://github.com/antfu/unplugin-auto-import */
@@ -32,6 +34,8 @@ declare function vueusePolyfill(code: string, id: string): string;
32
34
  declare function patchNormalizeNodeModules(): void;
33
35
  declare const uniPatch: (options?: any) => vite.PluginOption;
34
36
 
37
+ declare const useImports: () => ImportsMap;
38
+
35
39
  declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
36
40
 
37
- 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
@@ -9,6 +9,10 @@ import Components from '@uni-helper/vite-plugin-uni-components';
9
9
  import AutoImport from 'unplugin-auto-import/vite';
10
10
  import UnoCSS from 'unocss/vite';
11
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';
12
16
 
13
17
  function resolveLayersPlugins(layers, from) {
14
18
  const { plugins = [] } = resolveLayersDirs(layers);
@@ -79,7 +83,7 @@ const presetUni = defineVixtModule({
79
83
  const defaultOptions = {
80
84
  uni: {},
81
85
  pages: { dts: `${typesDir}/uni-pages.d.ts` },
82
- layouts: {},
86
+ uniLayouts: {},
83
87
  components: {
84
88
  dts: `${typesDir}/components.d.ts`,
85
89
  dirs: components,
@@ -88,7 +92,7 @@ const presetUni = defineVixtModule({
88
92
  allowOverrides: true
89
93
  },
90
94
  imports: {
91
- imports: ["vue", "@vueuse/core", "uni-app", "pinia"],
95
+ imports: ["vue", "uni-app", "pinia", useImports()],
92
96
  dts: `${typesDir}/auto-imports.d.ts`,
93
97
  dirs: [...composables, ...constants, ...stores, ...utils],
94
98
  vueTemplate: true
@@ -98,7 +102,7 @@ const presetUni = defineVixtModule({
98
102
  const options = defu(vixt.options, defaultOptions);
99
103
  const modules = [
100
104
  Pages(options.pages),
101
- Layouts(options.layouts),
105
+ Layouts(options.uniLayouts),
102
106
  Components(options.components),
103
107
  AutoImport(options.imports),
104
108
  UnoCSS(options.unocss),
@@ -140,6 +144,40 @@ const uniPatch = defineVitePlugin(() => {
140
144
  };
141
145
  });
142
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
+
143
181
  const defaults = {
144
182
  modules: [entryUni, presetUni],
145
183
  app: {
@@ -149,11 +187,18 @@ const defaults = {
149
187
  main: "src/main.ts"
150
188
  },
151
189
  typescript: {
152
- references: ["types/uni-pages.d.ts", "types/components.d.ts", "types/auto-imports.d.ts", "types/vite-env.d.ts"],
153
- tsConfig: { compilerOptions: { types: ["@dcloudio/types", "@uni-helper/vite-plugin-uni-pages/client"] } },
190
+ // references: ['types/uni-pages.d.ts', 'types/components.d.ts', 'types/auto-imports.d.ts'],
191
+ tsConfig: {
192
+ compilerOptions: {
193
+ types: ["@dcloudio/types", "@uni-helper/uni-app-types", "@uni-helper/vite-plugin-uni-pages/client"]
194
+ },
195
+ vueCompilerOptions: {
196
+ plugins: ["@uni-helper/uni-app-types/volar-plugin"]
197
+ }
198
+ },
154
199
  typeCheck: { vueTsc: true }
155
200
  }
156
201
  };
157
202
  const index = createVixtPlugin({ defaults });
158
203
 
159
- 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.7",
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",
@@ -21,6 +21,7 @@
21
21
  "@dcloudio/types": "^3.4.8",
22
22
  "@uni-helper/eslint-config": "^0.0.6",
23
23
  "@uni-helper/uni-app-types": "^0.5.13",
24
+ "@uni-helper/uni-use": "^0.19.12",
24
25
  "@uni-helper/unocss-preset-uni": "^0.2.9",
25
26
  "@uni-helper/vite-plugin-uni-components": "^0.0.9",
26
27
  "@uni-helper/vite-plugin-uni-layouts": "^0.1.10",
@@ -31,7 +32,7 @@
31
32
  "unocss": "^0.61.0",
32
33
  "unplugin-auto-import": "^0.17.6",
33
34
  "vue": "^3.4.31",
34
- "@vixt/core": "0.0.7"
35
+ "@vixt/core": "0.0.9"
35
36
  },
36
37
  "scripts": {
37
38
  "build": "unbuild"