@vixt/uni 0.0.14 → 0.1.0
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 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.mjs +24 -68
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import * as _vixt_core from '@vixt/core';
|
|
3
|
-
import {
|
|
3
|
+
import { 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
6
|
import Layouts from '@uni-helper/vite-plugin-uni-layouts';
|
|
@@ -9,8 +9,6 @@ import AutoImport from 'unplugin-auto-import/vite';
|
|
|
9
9
|
import UnoCSS from 'unocss/vite';
|
|
10
10
|
import { ImportsMap } from 'unplugin-auto-import/types';
|
|
11
11
|
|
|
12
|
-
declare const entryUni: _vixt_core.VixtModule<AppOptions>;
|
|
13
|
-
|
|
14
12
|
declare module '@vixt/core' {
|
|
15
13
|
interface VixtOptions {
|
|
16
14
|
uni?: PluginOptions<typeof Uni>;
|
|
@@ -38,4 +36,4 @@ declare const useImports: () => ImportsMap;
|
|
|
38
36
|
|
|
39
37
|
declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
|
|
40
38
|
|
|
41
|
-
export { _default as default,
|
|
39
|
+
export { _default as default, patchNormalizeNodeModules, presetUni, uniPatch, useImports, vueusePolyfill };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import * as _vixt_core from '@vixt/core';
|
|
3
|
-
import {
|
|
3
|
+
import { 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
6
|
import Layouts from '@uni-helper/vite-plugin-uni-layouts';
|
|
@@ -9,8 +9,6 @@ import AutoImport from 'unplugin-auto-import/vite';
|
|
|
9
9
|
import UnoCSS from 'unocss/vite';
|
|
10
10
|
import { ImportsMap } from 'unplugin-auto-import/types';
|
|
11
11
|
|
|
12
|
-
declare const entryUni: _vixt_core.VixtModule<AppOptions>;
|
|
13
|
-
|
|
14
12
|
declare module '@vixt/core' {
|
|
15
13
|
interface VixtOptions {
|
|
16
14
|
uni?: PluginOptions<typeof Uni>;
|
|
@@ -38,4 +36,4 @@ declare const useImports: () => ImportsMap;
|
|
|
38
36
|
|
|
39
37
|
declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
|
|
40
38
|
|
|
41
|
-
export { _default as default,
|
|
39
|
+
export { _default as default, patchNormalizeNodeModules, presetUni, uniPatch, useImports, vueusePolyfill };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { defineVixtModule, resolveLayersDirs, defineVitePlugin, createVixtPlugin } from '@vixt/core';
|
|
2
|
-
import path from 'pathe';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
2
|
import defu from 'defu';
|
|
5
3
|
import Uni from '@dcloudio/vite-plugin-uni';
|
|
6
4
|
import Pages from '@uni-helper/vite-plugin-uni-pages';
|
|
@@ -9,74 +7,12 @@ import Components from '@uni-helper/vite-plugin-uni-components';
|
|
|
9
7
|
import AutoImport from 'unplugin-auto-import/vite';
|
|
10
8
|
import UnoCSS from 'unocss/vite';
|
|
11
9
|
import { resolvePathSync } from 'mlly';
|
|
10
|
+
import fs from 'fs-extra';
|
|
12
11
|
import { readFileSync } from 'node:fs';
|
|
13
12
|
import process from 'node:process';
|
|
14
13
|
import { resolveModule } from 'local-pkg';
|
|
15
14
|
import { uniuseAutoImports } from '@uni-helper/uni-use';
|
|
16
15
|
|
|
17
|
-
function resolveLayersPlugins(layers, from) {
|
|
18
|
-
const { plugins = [] } = resolveLayersDirs(layers);
|
|
19
|
-
return plugins.map((pluginPath) => {
|
|
20
|
-
let pluginsDir = path.relative(from, pluginPath);
|
|
21
|
-
if (!pluginPath.startsWith(".") && !pluginPath.startsWith("/")) {
|
|
22
|
-
pluginsDir = `./${pluginsDir}`;
|
|
23
|
-
}
|
|
24
|
-
return `${pluginsDir}/*.ts`;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
function generateMainTs(options, vixt) {
|
|
28
|
-
const { buildDir, rootDir } = vixt.options;
|
|
29
|
-
const layersPluginsPath = resolveLayersPlugins(vixt._layers, path.resolve(rootDir, "src"));
|
|
30
|
-
const cssTemplate = options?.css?.map((e) => `import '${e}'`).join("\n");
|
|
31
|
-
const code = `/** Generated by Vixt */
|
|
32
|
-
// @ts-nocheck
|
|
33
|
-
import { createSSRApp } from 'vue'
|
|
34
|
-
import * as Pinia from 'pinia'
|
|
35
|
-
import { createUnistorage } from 'pinia-plugin-unistorage'
|
|
36
|
-
import { pages } from 'virtual:uni-pages'
|
|
37
|
-
|
|
38
|
-
import App from '@/App.vue'
|
|
39
|
-
${cssTemplate}
|
|
40
|
-
|
|
41
|
-
export function createApp() {
|
|
42
|
-
const app = createSSRApp(App)
|
|
43
|
-
const pinia = Pinia.createPinia()
|
|
44
|
-
pinia.use(createUnistorage())
|
|
45
|
-
app.use(pinia)
|
|
46
|
-
|
|
47
|
-
// install all plugins under 'plugins/'
|
|
48
|
-
const plugins = import.meta.glob(${JSON.stringify(layersPluginsPath)}, { import: 'default', eager: true })
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
Object.values(plugins).forEach((plugin) => typeof plugin === 'function' && plugin({ app, routes: pages, pinia }))
|
|
51
|
-
return { app, Pinia }
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
fs.outputFileSync(path.resolve(rootDir, buildDir, "main.ts"), code);
|
|
55
|
-
return code;
|
|
56
|
-
}
|
|
57
|
-
const name$1 = "vixt:entry-uni";
|
|
58
|
-
const entryUni = defineVixtModule({
|
|
59
|
-
meta: { name: name$1, configKey: "app" },
|
|
60
|
-
defaults: {
|
|
61
|
-
css: ["virtual:uno.css"]
|
|
62
|
-
},
|
|
63
|
-
setup(options, vixt) {
|
|
64
|
-
generateMainTs(options, vixt);
|
|
65
|
-
return {
|
|
66
|
-
name: "vixt:entry-uni",
|
|
67
|
-
enforce: "pre",
|
|
68
|
-
transform(code, id) {
|
|
69
|
-
const { buildDir, rootDir } = vixt.options;
|
|
70
|
-
const mainPath = path.resolve(rootDir, options.main);
|
|
71
|
-
if (id !== mainPath)
|
|
72
|
-
return;
|
|
73
|
-
code = fs.readFileSync(path.resolve(rootDir, buildDir, "main.ts"), "utf-8");
|
|
74
|
-
return code;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
16
|
const name = "vixt:preset-uni";
|
|
81
17
|
const presetUni = defineVixtModule({
|
|
82
18
|
meta: { name },
|
|
@@ -181,12 +117,32 @@ const useImports = () => {
|
|
|
181
117
|
};
|
|
182
118
|
|
|
183
119
|
const defaults = {
|
|
184
|
-
modules: [
|
|
120
|
+
modules: [presetUni],
|
|
185
121
|
app: {
|
|
186
122
|
head: {
|
|
187
123
|
link: [{ rel: "icon", href: "/static/favicon.ico" }]
|
|
188
124
|
},
|
|
189
|
-
|
|
125
|
+
css: ["virtual:uno.css"],
|
|
126
|
+
transformMain(code) {
|
|
127
|
+
code += `
|
|
128
|
+
import { createSSRApp } from 'vue'
|
|
129
|
+
import * as Pinia from 'pinia'
|
|
130
|
+
import { createUnistorage } from 'pinia-plugin-unistorage'
|
|
131
|
+
import { pages as routes } from 'virtual:uni-pages'
|
|
132
|
+
|
|
133
|
+
export function createApp() {
|
|
134
|
+
const app = createSSRApp(App)
|
|
135
|
+
const pinia = Pinia.createPinia()
|
|
136
|
+
pinia.use(createUnistorage())
|
|
137
|
+
app.use(pinia)
|
|
138
|
+
|
|
139
|
+
Object.values(plugins).forEach((plugin) => typeof plugin === 'function' && plugin({ app, routes, pinia, appConfig }))
|
|
140
|
+
|
|
141
|
+
return { app, Pinia }
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
144
|
+
return code;
|
|
145
|
+
}
|
|
190
146
|
},
|
|
191
147
|
typescript: {
|
|
192
148
|
// references: ['types/uni-pages.d.ts', 'types/components.d.ts', 'types/auto-imports.d.ts'],
|
|
@@ -203,4 +159,4 @@ const defaults = {
|
|
|
203
159
|
};
|
|
204
160
|
const index = createVixtPlugin({ defaults });
|
|
205
161
|
|
|
206
|
-
export { index as default,
|
|
162
|
+
export { index as default, 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.1.0",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/SoulLyoko/vixt#readme",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@vueuse/core": "^10.11.0",
|
|
30
30
|
"pinia": "^2.1.7",
|
|
31
31
|
"pinia-plugin-unistorage": "^0.0.19",
|
|
32
|
-
"unocss": "^0.61.
|
|
32
|
+
"unocss": "^0.61.3",
|
|
33
33
|
"unplugin-auto-import": "^0.17.6",
|
|
34
34
|
"vue": "^3.4.31",
|
|
35
|
-
"@vixt/core": "0.0
|
|
35
|
+
"@vixt/core": "0.1.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "unbuild"
|