@vixt/uni 0.0.6 → 0.0.8

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
@@ -1,6 +1,38 @@
1
1
  import * as vite from 'vite';
2
2
  import * as _vixt_core from '@vixt/core';
3
+ import { AppOptions, PluginOptions, VixtOptions } from '@vixt/core';
4
+ import Uni from '@dcloudio/vite-plugin-uni';
5
+ import Pages from '@uni-helper/vite-plugin-uni-pages';
6
+ import Layouts from '@uni-helper/vite-plugin-uni-layouts';
7
+ import Components from '@uni-helper/vite-plugin-uni-components';
8
+ import AutoImport from 'unplugin-auto-import/vite';
9
+ import UnoCSS from 'unocss/vite';
10
+
11
+ declare const entryUni: _vixt_core.VixtModule<AppOptions>;
12
+
13
+ declare module '@vixt/core' {
14
+ interface VixtOptions {
15
+ uni?: PluginOptions<typeof Uni>;
16
+ /** https://github.com/uni-helper/vite-plugin-uni-pages */
17
+ pages?: PluginOptions<typeof Pages>;
18
+ /** https://github.com/uni-helper/vite-plugin-uni-layouts */
19
+ uniLayouts?: PluginOptions<typeof Layouts>;
20
+ /** https://github.com/uni-helper/vite-plugin-uni-components */
21
+ components?: PluginOptions<typeof Components>;
22
+ /** https://github.com/antfu/unplugin-auto-import */
23
+ imports?: PluginOptions<typeof AutoImport>;
24
+ /** https://github.com/antfu/unocss */
25
+ unocss?: PluginOptions<typeof UnoCSS>;
26
+ }
27
+ }
28
+ declare const presetUni: _vixt_core.VixtModule<VixtOptions>;
29
+
30
+ /** 增加小程序中vueuse的运行所需 */
31
+ declare function vueusePolyfill(code: string, id: string): string;
32
+ /** 移除路径中的'../' */
33
+ declare function patchNormalizeNodeModules(): void;
34
+ declare const uniPatch: (options?: any) => vite.PluginOption;
3
35
 
4
36
  declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
5
37
 
6
- export { _default as default };
38
+ export { _default as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, vueusePolyfill };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,38 @@
1
1
  import * as vite from 'vite';
2
2
  import * as _vixt_core from '@vixt/core';
3
+ import { AppOptions, PluginOptions, VixtOptions } from '@vixt/core';
4
+ import Uni from '@dcloudio/vite-plugin-uni';
5
+ import Pages from '@uni-helper/vite-plugin-uni-pages';
6
+ import Layouts from '@uni-helper/vite-plugin-uni-layouts';
7
+ import Components from '@uni-helper/vite-plugin-uni-components';
8
+ import AutoImport from 'unplugin-auto-import/vite';
9
+ import UnoCSS from 'unocss/vite';
10
+
11
+ declare const entryUni: _vixt_core.VixtModule<AppOptions>;
12
+
13
+ declare module '@vixt/core' {
14
+ interface VixtOptions {
15
+ uni?: PluginOptions<typeof Uni>;
16
+ /** https://github.com/uni-helper/vite-plugin-uni-pages */
17
+ pages?: PluginOptions<typeof Pages>;
18
+ /** https://github.com/uni-helper/vite-plugin-uni-layouts */
19
+ uniLayouts?: PluginOptions<typeof Layouts>;
20
+ /** https://github.com/uni-helper/vite-plugin-uni-components */
21
+ components?: PluginOptions<typeof Components>;
22
+ /** https://github.com/antfu/unplugin-auto-import */
23
+ imports?: PluginOptions<typeof AutoImport>;
24
+ /** https://github.com/antfu/unocss */
25
+ unocss?: PluginOptions<typeof UnoCSS>;
26
+ }
27
+ }
28
+ declare const presetUni: _vixt_core.VixtModule<VixtOptions>;
29
+
30
+ /** 增加小程序中vueuse的运行所需 */
31
+ declare function vueusePolyfill(code: string, id: string): string;
32
+ /** 移除路径中的'../' */
33
+ declare function patchNormalizeNodeModules(): void;
34
+ declare const uniPatch: (options?: any) => vite.PluginOption;
3
35
 
4
36
  declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
5
37
 
6
- export { _default as default };
38
+ export { _default as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, vueusePolyfill };
package/dist/index.mjs CHANGED
@@ -6,8 +6,10 @@ 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';
9
10
  import AutoImport from 'unplugin-auto-import/vite';
10
11
  import UnoCSS from 'unocss/vite';
12
+ import { resolvePathSync } from 'mlly';
11
13
 
12
14
  function resolveLayersPlugins(layers, from) {
13
15
  const { plugins = [] } = resolveLayersDirs(layers);
@@ -23,11 +25,11 @@ function generateMainTs(options, vixt) {
23
25
  const code = `/** Generated by Vixt */
24
26
  // @ts-nocheck
25
27
  import { createSSRApp } from 'vue'
26
- import * as Pinia from 'pinia'
28
+ import * as Pinia from 'pinia'
27
29
  import { createUnistorage } from 'pinia-plugin-unistorage'
28
30
  import { pages } from 'virtual:uni-pages'
29
- import App from '@/App.vue'
30
31
 
32
+ import App from '@/App.vue'
31
33
  ${cssTemplate}
32
34
 
33
35
  export function createApp() {
@@ -46,8 +48,8 @@ export function createApp() {
46
48
  fs.outputFileSync(path.resolve(rootDir, buildDir, "main.ts"), code);
47
49
  return code;
48
50
  }
49
- const name$1 = "vixt:entry";
50
- const entry = defineVixtModule({
51
+ const name$1 = "vixt:entry-uni";
52
+ const entryUni = defineVixtModule({
51
53
  meta: { name: name$1, configKey: "app" },
52
54
  defaults: {
53
55
  css: ["virtual:uno.css"]
@@ -55,7 +57,7 @@ const entry = defineVixtModule({
55
57
  setup(options, vixt) {
56
58
  generateMainTs(options, vixt);
57
59
  return {
58
- name: "vixt:entry",
60
+ name: "vixt:entry-uni",
59
61
  enforce: "pre",
60
62
  transform(code, id) {
61
63
  const { buildDir, rootDir } = vixt.options;
@@ -78,16 +80,33 @@ const presetUni = defineVixtModule({
78
80
  const defaultOptions = {
79
81
  uni: {},
80
82
  pages: { dts: `${typesDir}/uni-pages.d.ts` },
81
- layouts: {},
83
+ uniLayouts: {},
82
84
  components: {
83
85
  dts: `${typesDir}/components.d.ts`,
84
86
  dirs: components,
85
87
  directoryAsNamespace: true,
86
88
  collapseSamePrefixes: true,
87
- allowOverrides: true
89
+ allowOverrides: true,
90
+ version: 2.7
88
91
  },
89
92
  imports: {
90
- imports: ["vue", "@vueuse/core", "uni-app", "pinia"],
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
+ ],
91
110
  dts: `${typesDir}/auto-imports.d.ts`,
92
111
  dirs: [...composables, ...constants, ...stores, ...utils],
93
112
  vueTemplate: true
@@ -97,7 +116,7 @@ const presetUni = defineVixtModule({
97
116
  const options = defu(vixt.options, defaultOptions);
98
117
  const modules = [
99
118
  Pages(options.pages),
100
- Layouts(options.layouts),
119
+ Layouts(options.uniLayouts),
101
120
  Components(options.components),
102
121
  AutoImport(options.imports),
103
122
  UnoCSS(options.unocss),
@@ -118,7 +137,18 @@ export const TransitionGroup = {}
118
137
  `;
119
138
  return code;
120
139
  }
140
+ const matched = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules');`;
141
+ const replaced = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules').replace(/\\.\\.\\//g, '');`;
142
+ function patchNormalizeNodeModules() {
143
+ const codePath = resolvePathSync("@dcloudio/uni-cli-shared/dist/utils.js");
144
+ let code = fs.readFileSync(codePath, "utf8");
145
+ if (code.includes(matched)) {
146
+ code = code.replace(matched, replaced);
147
+ fs.writeFileSync(codePath, code);
148
+ }
149
+ }
121
150
  const uniPatch = defineVitePlugin(() => {
151
+ patchNormalizeNodeModules();
122
152
  return {
123
153
  name: "vixt:uni-patch",
124
154
  transform(code, id) {
@@ -129,7 +159,7 @@ const uniPatch = defineVitePlugin(() => {
129
159
  });
130
160
 
131
161
  const defaults = {
132
- modules: [entry, presetUni],
162
+ modules: [entryUni, presetUni],
133
163
  app: {
134
164
  head: {
135
165
  link: [{ rel: "icon", href: "/static/favicon.ico" }]
@@ -137,11 +167,18 @@ const defaults = {
137
167
  main: "src/main.ts"
138
168
  },
139
169
  typescript: {
140
- references: ["types/uni-pages.d.ts", "types/components.d.ts", "types/auto-imports.d.ts", "types/vite-env.d.ts"],
141
- tsConfig: { compilerOptions: { types: ["@dcloudio/types", "@uni-helper/vite-plugin-uni-pages/client"] } },
170
+ // references: ['types/uni-pages.d.ts', 'types/components.d.ts', 'types/auto-imports.d.ts'],
171
+ tsConfig: {
172
+ compilerOptions: {
173
+ types: ["@dcloudio/types", "@uni-helper/uni-app-types", "@uni-helper/vite-plugin-uni-pages/client"]
174
+ },
175
+ vueCompilerOptions: {
176
+ plugins: ["@uni-helper/uni-app-types/volar-plugin"]
177
+ }
178
+ },
142
179
  typeCheck: { vueTsc: true }
143
180
  }
144
181
  };
145
182
  const index = createVixtPlugin({ defaults });
146
183
 
147
- export { index as default };
184
+ export { index as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, vueusePolyfill };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/uni",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
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.6"
35
+ "@vixt/core": "0.0.8"
35
36
  },
36
37
  "scripts": {
37
38
  "build": "unbuild"