@vixt/core 0.1.28 → 0.1.29
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/client/index.d.mts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +35 -42
- package/dist/shared/{core.b103189b.d.mts → core.CEkz_SNF.d.mts} +1 -9
- package/dist/shared/{core.b103189b.d.ts → core.CEkz_SNF.d.ts} +1 -9
- package/package.json +7 -7
package/dist/client/index.d.mts
CHANGED
package/dist/client/index.d.ts
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as VixtOptions, a as VixtConfigLayer, b as VixtConfigLayerMeta, M as ModuleOptions, c as ModuleDefinition, d as VixtModule, e as Vixt } from './shared/core.
|
|
2
|
-
export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig } from './shared/core.
|
|
1
|
+
import { V as VixtOptions, a as VixtConfigLayer, b as VixtConfigLayerMeta, M as ModuleOptions, c as ModuleDefinition, d as VixtModule, e as Vixt } from './shared/core.CEkz_SNF.mjs';
|
|
2
|
+
export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig } from './shared/core.CEkz_SNF.mjs';
|
|
3
3
|
import * as c12 from 'c12';
|
|
4
4
|
import { LoadConfigOptions } from 'c12';
|
|
5
5
|
import { RawVueCompilerOptions } from '@vue/language-core';
|
|
@@ -19,7 +19,7 @@ declare function applyLayers(layers: VixtConfigLayer[], config: VixtOptions): {
|
|
|
19
19
|
configFile?: string;
|
|
20
20
|
}[];
|
|
21
21
|
declare function isSamePath(a: string, b: string): boolean;
|
|
22
|
-
declare function resolveLayersDirs(layers
|
|
22
|
+
declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Load workspace and cwd env variables by default
|
|
@@ -33,7 +33,7 @@ declare function loadWorkspaceEnv(mode?: string, prefixes?: string | string[]):
|
|
|
33
33
|
declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) => PluginOption): (options?: Options) => PluginOption;
|
|
34
34
|
declare function defineVixtModule<T extends ModuleOptions>(definition: ModuleDefinition<T> | VixtModule<T>): VixtModule<T>;
|
|
35
35
|
declare function installModule(module: VixtModule, inlineOptions: any, vixt: Vixt): PluginOption;
|
|
36
|
-
declare function applyLayerModules(layers: VixtConfigLayer[]
|
|
36
|
+
declare function applyLayerModules(layers: VixtConfigLayer[]): Promise<VixtModule[]>;
|
|
37
37
|
|
|
38
38
|
declare const config: VixtModule<ModuleOptions>;
|
|
39
39
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as VixtOptions, a as VixtConfigLayer, b as VixtConfigLayerMeta, M as ModuleOptions, c as ModuleDefinition, d as VixtModule, e as Vixt } from './shared/core.
|
|
2
|
-
export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig } from './shared/core.
|
|
1
|
+
import { V as VixtOptions, a as VixtConfigLayer, b as VixtConfigLayerMeta, M as ModuleOptions, c as ModuleDefinition, d as VixtModule, e as Vixt } from './shared/core.CEkz_SNF.js';
|
|
2
|
+
export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig } from './shared/core.CEkz_SNF.js';
|
|
3
3
|
import * as c12 from 'c12';
|
|
4
4
|
import { LoadConfigOptions } from 'c12';
|
|
5
5
|
import { RawVueCompilerOptions } from '@vue/language-core';
|
|
@@ -19,7 +19,7 @@ declare function applyLayers(layers: VixtConfigLayer[], config: VixtOptions): {
|
|
|
19
19
|
configFile?: string;
|
|
20
20
|
}[];
|
|
21
21
|
declare function isSamePath(a: string, b: string): boolean;
|
|
22
|
-
declare function resolveLayersDirs(layers
|
|
22
|
+
declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Load workspace and cwd env variables by default
|
|
@@ -33,7 +33,7 @@ declare function loadWorkspaceEnv(mode?: string, prefixes?: string | string[]):
|
|
|
33
33
|
declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) => PluginOption): (options?: Options) => PluginOption;
|
|
34
34
|
declare function defineVixtModule<T extends ModuleOptions>(definition: ModuleDefinition<T> | VixtModule<T>): VixtModule<T>;
|
|
35
35
|
declare function installModule(module: VixtModule, inlineOptions: any, vixt: Vixt): PluginOption;
|
|
36
|
-
declare function applyLayerModules(layers: VixtConfigLayer[]
|
|
36
|
+
declare function applyLayerModules(layers: VixtConfigLayer[]): Promise<VixtModule[]>;
|
|
37
37
|
|
|
38
38
|
declare const config: VixtModule<ModuleOptions>;
|
|
39
39
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { cwd, env } from 'node:process';
|
|
2
1
|
import { loadConfig } from 'c12';
|
|
3
2
|
import fs from 'fs-extra';
|
|
4
|
-
import path from 'pathe';
|
|
3
|
+
import path, { resolve, normalize } from 'pathe';
|
|
4
|
+
import { env, cwd } from 'node:process';
|
|
5
5
|
import { cac } from 'cac';
|
|
6
6
|
import { findUpSync } from 'find-up';
|
|
7
7
|
import { loadEnv as loadEnv$1 } from 'vite';
|
|
@@ -14,67 +14,58 @@ function defineVixtConfig(input) {
|
|
|
14
14
|
return input;
|
|
15
15
|
}
|
|
16
16
|
async function loadVixtConfig(opts) {
|
|
17
|
-
const rootDir = path.resolve(cwd());
|
|
18
|
-
const buildDirName = ".vixt";
|
|
19
|
-
const buildDir = path.resolve(rootDir, buildDirName);
|
|
20
|
-
const buildTypesDir = path.resolve(buildDir, "types");
|
|
21
|
-
const buildLayersDir = path.resolve(buildDir, "layers");
|
|
22
|
-
const buildImportsDir = path.resolve(buildDir, "imports");
|
|
23
|
-
const srcDirName = "src";
|
|
24
|
-
const srcDir = path.resolve(rootDir, srcDirName);
|
|
25
17
|
const result = await loadConfig({
|
|
26
18
|
name: "vixt",
|
|
27
19
|
rcFile: false,
|
|
28
|
-
...opts
|
|
29
|
-
defaults: {
|
|
30
|
-
rootDir,
|
|
31
|
-
buildDirName,
|
|
32
|
-
buildDir,
|
|
33
|
-
buildTypesDir,
|
|
34
|
-
buildLayersDir,
|
|
35
|
-
buildImportsDir,
|
|
36
|
-
srcDirName,
|
|
37
|
-
srcDir,
|
|
38
|
-
...opts?.defaults
|
|
39
|
-
}
|
|
20
|
+
...opts
|
|
40
21
|
});
|
|
22
|
+
const { config, cwd } = result;
|
|
23
|
+
config.rootDir ??= cwd;
|
|
24
|
+
config.buildDir ??= resolve(config.rootDir, ".vixt");
|
|
25
|
+
config.buildTypesDir ??= resolve(config.buildDir, "types");
|
|
26
|
+
config.buildLayersDir ??= resolve(config.buildDir, "layers");
|
|
27
|
+
config.buildImportsDir ??= resolve(config.buildDir, "imports");
|
|
28
|
+
config.srcDir ??= resolve(config.rootDir, "src");
|
|
41
29
|
return result;
|
|
42
30
|
}
|
|
43
31
|
function applyLayers(layers, config) {
|
|
44
32
|
const { rootDir, buildLayersDir } = config;
|
|
45
|
-
return layers.map((layer) => {
|
|
33
|
+
return layers.filter((e) => e.cwd).map((layer) => {
|
|
46
34
|
const meta = layer.config?.meta ?? {};
|
|
47
35
|
const layerName = meta.name || layer.cwd.split("/").pop();
|
|
48
|
-
if (!isSamePath(layer.cwd,
|
|
36
|
+
if (!isSamePath(layer.cwd, resolve(rootDir))) {
|
|
49
37
|
meta.alias = `#/layers/${layerName}`;
|
|
38
|
+
}
|
|
50
39
|
if (layer.cwd?.includes("node_modules")) {
|
|
51
|
-
const newCwd =
|
|
40
|
+
const newCwd = resolve(buildLayersDir, layerName);
|
|
52
41
|
fs.copySync(layer.cwd, newCwd, {
|
|
53
42
|
filter: (src) => {
|
|
54
|
-
const nodeModulesPath =
|
|
55
|
-
const tsConfigPath =
|
|
43
|
+
const nodeModulesPath = resolve(layer.cwd, "node_modules");
|
|
44
|
+
const tsConfigPath = resolve(layer.cwd, "tsconfig.json");
|
|
56
45
|
return !isSamePath(src, nodeModulesPath) && !isSamePath(src, tsConfigPath);
|
|
57
46
|
}
|
|
58
47
|
});
|
|
59
48
|
layer.cwd = newCwd;
|
|
60
49
|
}
|
|
50
|
+
layer.config ??= {};
|
|
51
|
+
layer.config.rootDir ??= layer.cwd;
|
|
52
|
+
layer.config.srcDir ??= resolve(layer.config.rootDir, "src");
|
|
61
53
|
return { ...layer, meta };
|
|
62
54
|
});
|
|
63
55
|
}
|
|
64
56
|
function isSamePath(a, b) {
|
|
65
|
-
return
|
|
57
|
+
return normalize(a) === normalize(b);
|
|
66
58
|
}
|
|
67
|
-
function resolveLayersDirs(layers = []
|
|
68
|
-
const { srcDirName } = config;
|
|
59
|
+
function resolveLayersDirs(layers = []) {
|
|
69
60
|
const dirs = {};
|
|
70
61
|
for (const layer of layers) {
|
|
71
|
-
const srcPath =
|
|
62
|
+
const srcPath = layer.config.srcDir;
|
|
72
63
|
const isExist = fs.existsSync(srcPath);
|
|
73
64
|
const contents = isExist ? fs.readdirSync(srcPath) : [];
|
|
74
65
|
for (const content of contents) {
|
|
75
|
-
const fileOrDirPath =
|
|
66
|
+
const fileOrDirPath = resolve(srcPath, content);
|
|
76
67
|
if (fs.statSync(fileOrDirPath).isDirectory()) {
|
|
77
|
-
dirs[content]
|
|
68
|
+
dirs[content] ??= [];
|
|
78
69
|
dirs[content].push(fileOrDirPath);
|
|
79
70
|
}
|
|
80
71
|
}
|
|
@@ -107,15 +98,17 @@ function defineVixtModule(definition) {
|
|
|
107
98
|
const module = definition;
|
|
108
99
|
function getOptions(inlineOptions, vixt) {
|
|
109
100
|
const configKey = module.meta?.configKey || module.meta?.name;
|
|
101
|
+
const configOptions = configKey ? vixt.options[configKey] : {};
|
|
110
102
|
const defaultOptions = typeof module.defaults === "function" ? module.defaults(vixt) : module.defaults;
|
|
111
|
-
const resolvedOptions = defu(inlineOptions,
|
|
103
|
+
const resolvedOptions = defu(inlineOptions, configOptions, defaultOptions);
|
|
112
104
|
if (configKey) {
|
|
113
105
|
vixt.options[configKey] = resolvedOptions;
|
|
114
106
|
}
|
|
115
107
|
return resolvedOptions;
|
|
116
108
|
}
|
|
117
109
|
function normalizedModule(inlineOptions, vixt) {
|
|
118
|
-
|
|
110
|
+
const options = getOptions(inlineOptions, vixt);
|
|
111
|
+
return module.setup?.(options, vixt);
|
|
119
112
|
}
|
|
120
113
|
normalizedModule.getMeta = () => module.meta;
|
|
121
114
|
normalizedModule.getOptions = getOptions;
|
|
@@ -124,10 +117,10 @@ function defineVixtModule(definition) {
|
|
|
124
117
|
function installModule(module, inlineOptions, vixt) {
|
|
125
118
|
return module(inlineOptions, vixt);
|
|
126
119
|
}
|
|
127
|
-
async function applyLayerModules(layers
|
|
128
|
-
const { modules:
|
|
120
|
+
async function applyLayerModules(layers) {
|
|
121
|
+
const { modules: modulesDirs = [] } = resolveLayersDirs(layers);
|
|
129
122
|
const modules = [];
|
|
130
|
-
for (const m of
|
|
123
|
+
for (const m of modulesDirs) {
|
|
131
124
|
if (fs.existsSync(m)) {
|
|
132
125
|
const files = fs.readdirSync(m);
|
|
133
126
|
for (const f of files) {
|
|
@@ -184,8 +177,8 @@ const config = defineVixtModule({
|
|
|
184
177
|
configureServer(server) {
|
|
185
178
|
const mode = server.config.mode;
|
|
186
179
|
const watchFiles = [];
|
|
187
|
-
const configFiles = vixt._layers.map((layer) =>
|
|
188
|
-
const modulesDirs = vixt._layers.map((layer) => path.resolve(layer.
|
|
180
|
+
const configFiles = vixt._layers.map((layer) => layer.configFile);
|
|
181
|
+
const modulesDirs = vixt._layers.map((layer) => path.resolve(layer.config.srcDir, "modules"));
|
|
189
182
|
watchFiles.push(...configFiles, ...modulesDirs);
|
|
190
183
|
const workspaceManifestLocation = findUpSync(["pnpm-workspace.yaml", "pnpm-workspace.yml"]);
|
|
191
184
|
if (workspaceManifestLocation) {
|
|
@@ -326,8 +319,8 @@ async function loadVixt(opts) {
|
|
|
326
319
|
if (isForce) {
|
|
327
320
|
fs.removeSync(result.config.buildDir);
|
|
328
321
|
}
|
|
329
|
-
result.layers = applyLayers(result.layers
|
|
330
|
-
const layerModules = await applyLayerModules(result.layers ?? []
|
|
322
|
+
result.layers = applyLayers(result.layers ?? [], result.config);
|
|
323
|
+
const layerModules = await applyLayerModules(result.layers ?? []);
|
|
331
324
|
const vixt = {
|
|
332
325
|
options: result.config,
|
|
333
326
|
_layers: result.layers ?? [],
|
|
@@ -16,7 +16,7 @@ interface ModuleMeta extends Record<string, any> {
|
|
|
16
16
|
interface ModuleDefinition<T extends ModuleOptions = ModuleOptions> {
|
|
17
17
|
meta?: ModuleMeta;
|
|
18
18
|
defaults?: T | ((vixt: Vixt) => T);
|
|
19
|
-
setup?: (this: void, resolvedOptions: T, vixt: Vixt) => PluginOption;
|
|
19
|
+
setup?: (this: void, resolvedOptions: T, vixt: Vixt) => PluginOption | void;
|
|
20
20
|
}
|
|
21
21
|
interface VixtModule<T extends ModuleOptions = ModuleOptions> {
|
|
22
22
|
(this: void, inlineOptions: T, vixt: Vixt): PluginOption;
|
|
@@ -29,10 +29,6 @@ interface VixtOptions extends Record<string, any> {
|
|
|
29
29
|
* @default process.cwd()
|
|
30
30
|
*/
|
|
31
31
|
rootDir?: string;
|
|
32
|
-
/**
|
|
33
|
-
* @default '.vixt'
|
|
34
|
-
*/
|
|
35
|
-
buildDirName?: string;
|
|
36
32
|
/**
|
|
37
33
|
* @default '<rootDir>/.vixt'
|
|
38
34
|
*/
|
|
@@ -49,10 +45,6 @@ interface VixtOptions extends Record<string, any> {
|
|
|
49
45
|
* @default '<buildDir>/imports'
|
|
50
46
|
*/
|
|
51
47
|
buildImportsDir?: string;
|
|
52
|
-
/**
|
|
53
|
-
* @default 'src'
|
|
54
|
-
*/
|
|
55
|
-
srcDirName?: string;
|
|
56
48
|
/**
|
|
57
49
|
* @default '<rootDir>/src'
|
|
58
50
|
*/
|
|
@@ -16,7 +16,7 @@ interface ModuleMeta extends Record<string, any> {
|
|
|
16
16
|
interface ModuleDefinition<T extends ModuleOptions = ModuleOptions> {
|
|
17
17
|
meta?: ModuleMeta;
|
|
18
18
|
defaults?: T | ((vixt: Vixt) => T);
|
|
19
|
-
setup?: (this: void, resolvedOptions: T, vixt: Vixt) => PluginOption;
|
|
19
|
+
setup?: (this: void, resolvedOptions: T, vixt: Vixt) => PluginOption | void;
|
|
20
20
|
}
|
|
21
21
|
interface VixtModule<T extends ModuleOptions = ModuleOptions> {
|
|
22
22
|
(this: void, inlineOptions: T, vixt: Vixt): PluginOption;
|
|
@@ -29,10 +29,6 @@ interface VixtOptions extends Record<string, any> {
|
|
|
29
29
|
* @default process.cwd()
|
|
30
30
|
*/
|
|
31
31
|
rootDir?: string;
|
|
32
|
-
/**
|
|
33
|
-
* @default '.vixt'
|
|
34
|
-
*/
|
|
35
|
-
buildDirName?: string;
|
|
36
32
|
/**
|
|
37
33
|
* @default '<rootDir>/.vixt'
|
|
38
34
|
*/
|
|
@@ -49,10 +45,6 @@ interface VixtOptions extends Record<string, any> {
|
|
|
49
45
|
* @default '<buildDir>/imports'
|
|
50
46
|
*/
|
|
51
47
|
buildImportsDir?: string;
|
|
52
|
-
/**
|
|
53
|
-
* @default 'src'
|
|
54
|
-
*/
|
|
55
|
-
srcDirName?: string;
|
|
56
48
|
/**
|
|
57
49
|
* @default '<rootDir>/src'
|
|
58
50
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixt/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.29",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/SoulLyoko/vixt#readme",
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@types/fs-extra": "^11.0.4",
|
|
29
|
-
"@vue/tsconfig": "^0.
|
|
29
|
+
"@vue/tsconfig": "^0.7.0",
|
|
30
30
|
"c12": "^2.0.1",
|
|
31
31
|
"cac": "^6.7.14",
|
|
32
32
|
"defu": "^6.1.4",
|
|
33
33
|
"find-up": "^7.0.0",
|
|
34
34
|
"fs-extra": "^11.2.0",
|
|
35
|
-
"mlly": "^1.7.
|
|
36
|
-
"pathe": "^
|
|
37
|
-
"pkg-types": "^1.
|
|
35
|
+
"mlly": "^1.7.4",
|
|
36
|
+
"pathe": "^2.0.1",
|
|
37
|
+
"pkg-types": "^1.3.0",
|
|
38
38
|
"tsx": "^4.19.2",
|
|
39
|
-
"vite": "^
|
|
39
|
+
"vite": "^6.0.7",
|
|
40
40
|
"vite-plugin-checker": "^0.8.0",
|
|
41
|
-
"vue-tsc": "2.
|
|
41
|
+
"vue-tsc": "^2.2.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "unbuild"
|