@vixt/uni 0.2.1 → 0.3.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/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.mjs +40 -7
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -37,6 +37,17 @@ declare module '@vixt/core/client' {
|
|
|
37
37
|
}
|
|
38
38
|
declare const presetUni: _vixt_core.VixtModule<VixtOptions>;
|
|
39
39
|
|
|
40
|
+
declare module '@vixt/core' {
|
|
41
|
+
interface VixtOptions {
|
|
42
|
+
uniModules?: ModuleOptions;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
interface ModuleOptions {
|
|
46
|
+
include?: string[];
|
|
47
|
+
exclude?: string[];
|
|
48
|
+
}
|
|
49
|
+
declare const uniModules: _vixt_core.VixtModule<_vixt_core.ModuleOptions>;
|
|
50
|
+
|
|
40
51
|
/** 增加小程序中vueuse的运行所需 */
|
|
41
52
|
declare function vueusePolyfill(code: string, id: string): string;
|
|
42
53
|
/** 移除路径中的'../' */
|
|
@@ -47,4 +58,4 @@ declare function useImports(): ImportsMap;
|
|
|
47
58
|
|
|
48
59
|
declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
|
|
49
60
|
|
|
50
|
-
export { appUni, _default as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniPatch, useImports, vueusePolyfill };
|
|
61
|
+
export { type ModuleOptions, appUni, _default as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniModules, uniPatch, useImports, vueusePolyfill };
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,17 @@ declare module '@vixt/core/client' {
|
|
|
37
37
|
}
|
|
38
38
|
declare const presetUni: _vixt_core.VixtModule<VixtOptions>;
|
|
39
39
|
|
|
40
|
+
declare module '@vixt/core' {
|
|
41
|
+
interface VixtOptions {
|
|
42
|
+
uniModules?: ModuleOptions;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
interface ModuleOptions {
|
|
46
|
+
include?: string[];
|
|
47
|
+
exclude?: string[];
|
|
48
|
+
}
|
|
49
|
+
declare const uniModules: _vixt_core.VixtModule<_vixt_core.ModuleOptions>;
|
|
50
|
+
|
|
40
51
|
/** 增加小程序中vueuse的运行所需 */
|
|
41
52
|
declare function vueusePolyfill(code: string, id: string): string;
|
|
42
53
|
/** 移除路径中的'../' */
|
|
@@ -47,4 +58,4 @@ declare function useImports(): ImportsMap;
|
|
|
47
58
|
|
|
48
59
|
declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
|
|
49
60
|
|
|
50
|
-
export { appUni, _default as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniPatch, useImports, vueusePolyfill };
|
|
61
|
+
export { type ModuleOptions, appUni, _default as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniModules, uniPatch, useImports, vueusePolyfill };
|
package/dist/index.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import Pages from '@uni-helper/vite-plugin-uni-pages';
|
|
|
9
9
|
import defu from 'defu';
|
|
10
10
|
import UnoCSS from 'unocss/vite';
|
|
11
11
|
import AutoImport from 'unplugin-auto-import/vite';
|
|
12
|
+
import path$1 from 'node:path';
|
|
12
13
|
import { resolvePathSync } from 'mlly';
|
|
13
14
|
import { readFileSync } from 'node:fs';
|
|
14
15
|
import process from 'node:process';
|
|
@@ -59,7 +60,7 @@ export function createApp() {
|
|
|
59
60
|
fs.outputFileSync(path.resolve(buildDir, "main.ts"), code);
|
|
60
61
|
return code;
|
|
61
62
|
}
|
|
62
|
-
const name$
|
|
63
|
+
const name$2 = "vixt:app";
|
|
63
64
|
const defaults$1 = {
|
|
64
65
|
rootId: "app",
|
|
65
66
|
rootTag: "div",
|
|
@@ -73,14 +74,14 @@ const defaults$1 = {
|
|
|
73
74
|
}
|
|
74
75
|
};
|
|
75
76
|
const appUni = defineVixtModule({
|
|
76
|
-
meta: { name: name$
|
|
77
|
+
meta: { name: name$2, configKey: "app" },
|
|
77
78
|
defaults: defaults$1,
|
|
78
79
|
setup(options, vixt) {
|
|
79
80
|
let indexHtmlCode;
|
|
80
81
|
let mainTsCode;
|
|
81
82
|
const mainTsPath = path.resolve(vixt.options.srcDir, "main.ts");
|
|
82
83
|
return {
|
|
83
|
-
name: name$
|
|
84
|
+
name: name$2,
|
|
84
85
|
configResolved() {
|
|
85
86
|
indexHtmlCode = generateIndexHtml(options, vixt);
|
|
86
87
|
mainTsCode = generateMainTs(options, vixt);
|
|
@@ -103,9 +104,9 @@ const appUni = defineVixtModule({
|
|
|
103
104
|
}
|
|
104
105
|
});
|
|
105
106
|
|
|
106
|
-
const name = "vixt:preset-uni";
|
|
107
|
+
const name$1 = "vixt:preset-uni";
|
|
107
108
|
const presetUni = defineVixtModule({
|
|
108
|
-
meta: { name },
|
|
109
|
+
meta: { name: name$1 },
|
|
109
110
|
setup(_, vixt) {
|
|
110
111
|
const { components, composables = [], constants = [], utils = [], stores = [] } = resolveLayersDirs(vixt._layers);
|
|
111
112
|
const { buildTypesDir, buildImportsDir } = vixt.options;
|
|
@@ -142,6 +143,38 @@ const presetUni = defineVixtModule({
|
|
|
142
143
|
}
|
|
143
144
|
});
|
|
144
145
|
|
|
146
|
+
function copyUniModules(_, vixt) {
|
|
147
|
+
const { srcDir, uniModules: { include, exclude } = {} } = vixt.options;
|
|
148
|
+
const { uni_modules = [] } = resolveLayersDirs(vixt._layers);
|
|
149
|
+
const srcUniModulesPath = path$1.join(srcDir, "uni_modules");
|
|
150
|
+
uni_modules.forEach((uniModulesPath) => {
|
|
151
|
+
fs.readdirSync(uniModulesPath).filter((dir) => {
|
|
152
|
+
if (include?.length)
|
|
153
|
+
return include.includes(dir);
|
|
154
|
+
if (exclude?.length)
|
|
155
|
+
return !exclude.includes(dir);
|
|
156
|
+
return true;
|
|
157
|
+
}).forEach((dir) => {
|
|
158
|
+
const srcPath = path$1.join(uniModulesPath, dir);
|
|
159
|
+
const destPath = path$1.join(srcUniModulesPath, dir);
|
|
160
|
+
const srcPkgVersion = fs.readJSONSync(path$1.join(srcPath, "package.json"), { throws: false })?.version;
|
|
161
|
+
const destPkgVersion = fs.readJSONSync(path$1.join(destPath, "package.json"), { throws: false })?.version;
|
|
162
|
+
if (srcPath !== destPath && srcPkgVersion !== destPkgVersion) {
|
|
163
|
+
fs.removeSync(destPath);
|
|
164
|
+
fs.copySync(srcPath, destPath);
|
|
165
|
+
fs.writeFileSync(path$1.join(destPath, ".gitignore"), "*", "utf-8");
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const name = "vixt:uni-modules";
|
|
171
|
+
const uniModules = defineVixtModule({
|
|
172
|
+
meta: { name },
|
|
173
|
+
setup(_, vixt) {
|
|
174
|
+
copyUniModules(_, vixt);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
145
178
|
function vueusePolyfill(code, id) {
|
|
146
179
|
if (!id.endsWith("@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js"))
|
|
147
180
|
return code;
|
|
@@ -207,7 +240,7 @@ function useImports() {
|
|
|
207
240
|
}
|
|
208
241
|
|
|
209
242
|
const defaults = {
|
|
210
|
-
modules: [appUni, presetUni],
|
|
243
|
+
modules: [uniModules, appUni, presetUni],
|
|
211
244
|
typescript: {
|
|
212
245
|
tsConfig: {
|
|
213
246
|
compilerOptions: {
|
|
@@ -221,4 +254,4 @@ const defaults = {
|
|
|
221
254
|
};
|
|
222
255
|
const index = createVixtPlugin({ defaults });
|
|
223
256
|
|
|
224
|
-
export { appUni, index as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniPatch, useImports, vueusePolyfill };
|
|
257
|
+
export { appUni, index as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniModules, 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.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/SoulLyoko/vixt#readme",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@uni-helper/vite-plugin-uni-components": "^0.2.0",
|
|
26
26
|
"@uni-helper/vite-plugin-uni-layouts": "^0.1.10",
|
|
27
27
|
"@uni-helper/vite-plugin-uni-pages": "^0.2.28",
|
|
28
|
-
"unocss-applet": "^0.
|
|
29
|
-
"@vixt/core": "0.
|
|
30
|
-
"@vixt/vue": "0.
|
|
28
|
+
"unocss-applet": "^0.10.0",
|
|
29
|
+
"@vixt/core": "0.3.1",
|
|
30
|
+
"@vixt/vue": "0.3.1"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "unbuild"
|