@vixt/uni 0.4.1 → 0.4.2
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +70 -70
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -70,9 +70,9 @@ declare function vueusePolyfill(code: string, id: string): string;
|
|
|
70
70
|
declare function patchNormalizeNodeModules(): void;
|
|
71
71
|
declare const uniPatch: (options?: any) => vite.PluginOption;
|
|
72
72
|
|
|
73
|
-
declare function
|
|
73
|
+
declare function uniVueUseResolver(): ImportsMap;
|
|
74
74
|
|
|
75
75
|
declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
|
|
76
76
|
|
|
77
|
-
export { appUni, _default as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniModules, uniPatch,
|
|
77
|
+
export { appUni, _default as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniModules, uniPatch, uniVueUseResolver, vueusePolyfill };
|
|
78
78
|
export type { ModuleOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -70,9 +70,9 @@ declare function vueusePolyfill(code: string, id: string): string;
|
|
|
70
70
|
declare function patchNormalizeNodeModules(): void;
|
|
71
71
|
declare const uniPatch: (options?: any) => vite.PluginOption;
|
|
72
72
|
|
|
73
|
-
declare function
|
|
73
|
+
declare function uniVueUseResolver(): ImportsMap;
|
|
74
74
|
|
|
75
75
|
declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
|
|
76
76
|
|
|
77
|
-
export { appUni, _default as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniModules, uniPatch,
|
|
77
|
+
export { appUni, _default as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniModules, uniPatch, uniVueUseResolver, vueusePolyfill };
|
|
78
78
|
export type { ModuleOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateClient, generateCss, generateAppConfig, generatePlugins, defineVixtModule, generateIndexHtml,
|
|
1
|
+
import { generateClient, generateCss, generateAppConfig, generatePlugins, defineVixtModule, generateIndexHtml, defineVitePlugin, resolveLayersDirs, createVixtPlugin } from '@vixt/core';
|
|
2
2
|
import path from 'pathe';
|
|
3
3
|
import { genarateAppComponent } from '@vixt/vue';
|
|
4
4
|
import fs from 'fs-extra';
|
|
@@ -106,11 +106,75 @@ const appUni = defineVixtModule({
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
+
function vueusePolyfill(code, id) {
|
|
110
|
+
if (!id.endsWith("@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js"))
|
|
111
|
+
return code;
|
|
112
|
+
code += `
|
|
113
|
+
export const render = () => {}
|
|
114
|
+
export const TransitionGroup = {}
|
|
115
|
+
`;
|
|
116
|
+
return code;
|
|
117
|
+
}
|
|
118
|
+
function patchNormalizeNodeModules() {
|
|
119
|
+
const matched = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules');`;
|
|
120
|
+
const replaced = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules').replace(/\\.\\.\\//g, '');`;
|
|
121
|
+
const codePath = resolvePathSync("@dcloudio/uni-cli-shared/dist/utils.js");
|
|
122
|
+
let code = fs.readFileSync(codePath, "utf8");
|
|
123
|
+
if (code.includes(matched)) {
|
|
124
|
+
code = code.replace(matched, replaced);
|
|
125
|
+
fs.writeFileSync(codePath, code);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const uniPatch = defineVitePlugin(() => {
|
|
129
|
+
patchNormalizeNodeModules();
|
|
130
|
+
return {
|
|
131
|
+
name: "vixt:uni-patch",
|
|
132
|
+
transform(code, id) {
|
|
133
|
+
code = vueusePolyfill(code, id);
|
|
134
|
+
return code;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
let _cache;
|
|
140
|
+
function uniVueUseResolver() {
|
|
141
|
+
const excluded = [
|
|
142
|
+
"toRefs",
|
|
143
|
+
"utils",
|
|
144
|
+
"toRef",
|
|
145
|
+
"toValue",
|
|
146
|
+
"tryOnScopeDispose",
|
|
147
|
+
"useNetwork",
|
|
148
|
+
"useOnline",
|
|
149
|
+
"usePreferredDark",
|
|
150
|
+
"useStorage",
|
|
151
|
+
"useStorageAsync"
|
|
152
|
+
];
|
|
153
|
+
if (!_cache) {
|
|
154
|
+
let indexesJson;
|
|
155
|
+
try {
|
|
156
|
+
const corePath = resolveModule("@vueuse/core") || process.cwd();
|
|
157
|
+
const path = resolveModule("@vueuse/core/indexes.json") || resolveModule("@vueuse/metadata/index.json") || resolveModule("@vueuse/metadata/index.json", { paths: [corePath] });
|
|
158
|
+
indexesJson = JSON.parse(readFileSync(path, "utf-8"));
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.error(error);
|
|
161
|
+
throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?");
|
|
162
|
+
}
|
|
163
|
+
if (indexesJson) {
|
|
164
|
+
_cache = {
|
|
165
|
+
"@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)),
|
|
166
|
+
...uniuseAutoImports()
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return _cache || {};
|
|
171
|
+
}
|
|
172
|
+
|
|
109
173
|
const name$1 = "vixt:preset-uni";
|
|
110
174
|
const presetUni = defineVixtModule({
|
|
111
175
|
meta: { name: name$1 },
|
|
112
176
|
setup(_, vixt) {
|
|
113
|
-
const { components, composables = [], constants = [], utils = [], stores = [] } = resolveLayersDirs(vixt._layers);
|
|
177
|
+
const { components = [], composables = [], constants = [], utils = [], stores = [] } = resolveLayersDirs([...vixt._layers].reverse());
|
|
114
178
|
const { buildTypesDir, buildImportsDir } = vixt.options;
|
|
115
179
|
const defaultOptions = {
|
|
116
180
|
uni: {},
|
|
@@ -118,14 +182,14 @@ const presetUni = defineVixtModule({
|
|
|
118
182
|
uniLayouts: {},
|
|
119
183
|
uniComponents: {
|
|
120
184
|
dts: `${buildTypesDir}/components.d.ts`,
|
|
121
|
-
dirs: components,
|
|
185
|
+
dirs: [...components].reverse(),
|
|
122
186
|
directoryAsNamespace: true,
|
|
123
187
|
collapseSamePrefixes: true
|
|
124
188
|
},
|
|
125
189
|
imports: {
|
|
126
|
-
imports: ["vue", "uni-app", "pinia",
|
|
190
|
+
imports: ["vue", "uni-app", "pinia", uniVueUseResolver()],
|
|
127
191
|
dts: `${buildTypesDir}/auto-imports.d.ts`,
|
|
128
|
-
dirs: [
|
|
192
|
+
dirs: [composables, constants, stores, utils, buildImportsDir].flat(),
|
|
129
193
|
vueTemplate: true
|
|
130
194
|
},
|
|
131
195
|
unocss: {}
|
|
@@ -192,70 +256,6 @@ const uniModules = defineVixtModule({
|
|
|
192
256
|
}
|
|
193
257
|
});
|
|
194
258
|
|
|
195
|
-
function vueusePolyfill(code, id) {
|
|
196
|
-
if (!id.endsWith("@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js"))
|
|
197
|
-
return code;
|
|
198
|
-
code += `
|
|
199
|
-
export const render = () => {}
|
|
200
|
-
export const TransitionGroup = {}
|
|
201
|
-
`;
|
|
202
|
-
return code;
|
|
203
|
-
}
|
|
204
|
-
function patchNormalizeNodeModules() {
|
|
205
|
-
const matched = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules');`;
|
|
206
|
-
const replaced = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules').replace(/\\.\\.\\//g, '');`;
|
|
207
|
-
const codePath = resolvePathSync("@dcloudio/uni-cli-shared/dist/utils.js");
|
|
208
|
-
let code = fs.readFileSync(codePath, "utf8");
|
|
209
|
-
if (code.includes(matched)) {
|
|
210
|
-
code = code.replace(matched, replaced);
|
|
211
|
-
fs.writeFileSync(codePath, code);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
const uniPatch = defineVitePlugin(() => {
|
|
215
|
-
patchNormalizeNodeModules();
|
|
216
|
-
return {
|
|
217
|
-
name: "vixt:uni-patch",
|
|
218
|
-
transform(code, id) {
|
|
219
|
-
code = vueusePolyfill(code, id);
|
|
220
|
-
return code;
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
let _cache;
|
|
226
|
-
function useImports() {
|
|
227
|
-
const excluded = [
|
|
228
|
-
"toRefs",
|
|
229
|
-
"utils",
|
|
230
|
-
"toRef",
|
|
231
|
-
"toValue",
|
|
232
|
-
"tryOnScopeDispose",
|
|
233
|
-
"useNetwork",
|
|
234
|
-
"useOnline",
|
|
235
|
-
"usePreferredDark",
|
|
236
|
-
"useStorage",
|
|
237
|
-
"useStorageAsync"
|
|
238
|
-
];
|
|
239
|
-
if (!_cache) {
|
|
240
|
-
let indexesJson;
|
|
241
|
-
try {
|
|
242
|
-
const corePath = resolveModule("@vueuse/core") || process.cwd();
|
|
243
|
-
const path = resolveModule("@vueuse/core/indexes.json") || resolveModule("@vueuse/metadata/index.json") || resolveModule("@vueuse/metadata/index.json", { paths: [corePath] });
|
|
244
|
-
indexesJson = JSON.parse(readFileSync(path, "utf-8"));
|
|
245
|
-
} catch (error) {
|
|
246
|
-
console.error(error);
|
|
247
|
-
throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?");
|
|
248
|
-
}
|
|
249
|
-
if (indexesJson) {
|
|
250
|
-
_cache = {
|
|
251
|
-
"@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)),
|
|
252
|
-
...uniuseAutoImports()
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return _cache || {};
|
|
257
|
-
}
|
|
258
|
-
|
|
259
259
|
const defaults = {
|
|
260
260
|
modules: [uniModules, appUni, presetUni],
|
|
261
261
|
typescript: {
|
|
@@ -271,4 +271,4 @@ const defaults = {
|
|
|
271
271
|
};
|
|
272
272
|
const index = createVixtPlugin({ defaults });
|
|
273
273
|
|
|
274
|
-
export { appUni, index as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniModules, uniPatch,
|
|
274
|
+
export { appUni, index as default, generateMainTs, patchNormalizeNodeModules, presetUni, uniModules, uniPatch, uniVueUseResolver, vueusePolyfill };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixt/uni",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.2",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/SoulLyoko/vixt#readme",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@uni-helper/vite-plugin-uni-layouts": "^0.1.10",
|
|
27
27
|
"@uni-helper/vite-plugin-uni-pages": "^0.2.28",
|
|
28
28
|
"unocss-applet": "^0.10.0",
|
|
29
|
-
"@vixt/core": "0.4.
|
|
30
|
-
"@vixt/vue": "0.4.
|
|
29
|
+
"@vixt/core": "0.4.2",
|
|
30
|
+
"@vixt/vue": "0.4.2"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "unbuild",
|