@varlet/cli 2.0.5 → 2.1.0-alpha.1666877950844
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/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/babel.config.cjs +29 -0
- package/cjs/babel.sfc.transform.cjs +18 -0
- package/cjs/jest.config.cjs +33 -0
- package/cjs/jest.media.mock.cjs +1 -0
- package/cjs/jest.style.mock.cjs +1 -0
- package/client.d.ts +1 -0
- package/client.js +1 -0
- package/lib/client/appType.d.ts +4 -0
- package/lib/client/appType.js +7 -0
- package/lib/client/index.d.ts +17 -0
- package/lib/client/index.js +106 -0
- package/lib/{bin.d.ts → node/bin.d.ts} +2 -2
- package/lib/node/bin.js +122 -0
- package/lib/{commands → node/commands}/build.d.ts +1 -1
- package/lib/node/commands/build.js +15 -0
- package/lib/{commands → node/commands}/changelog.d.ts +6 -6
- package/lib/node/commands/changelog.js +20 -0
- package/lib/{commands → node/commands}/commitLint.d.ts +1 -1
- package/lib/node/commands/commitLint.js +45 -0
- package/lib/{commands → node/commands}/compile.d.ts +7 -7
- package/lib/node/commands/compile.js +35 -0
- package/lib/{commands → node/commands}/create.d.ts +8 -8
- package/lib/node/commands/create.js +91 -0
- package/lib/{commands → node/commands}/dev.d.ts +5 -5
- package/lib/node/commands/dev.js +38 -0
- package/lib/{commands → node/commands}/gen.d.ts +8 -8
- package/lib/node/commands/gen.js +75 -0
- package/lib/{commands → node/commands}/jest.d.ts +8 -8
- package/lib/node/commands/jest.js +27 -0
- package/lib/{commands → node/commands}/lint.d.ts +1 -1
- package/lib/node/commands/lint.js +41 -0
- package/lib/{commands → node/commands}/preview.d.ts +1 -1
- package/lib/node/commands/preview.js +18 -0
- package/lib/{commands → node/commands}/release.d.ts +5 -5
- package/lib/node/commands/release.js +146 -0
- package/lib/{commands → node/commands}/vite.d.ts +3 -3
- package/lib/node/commands/vite.js +13 -0
- package/lib/{compiler → node/compiler}/compileModule.d.ts +5 -5
- package/lib/node/compiler/compileModule.js +74 -0
- package/lib/{compiler → node/compiler}/compileSFC.d.ts +2 -2
- package/lib/node/compiler/compileSFC.js +79 -0
- package/lib/{compiler → node/compiler}/compileScript.d.ts +17 -17
- package/lib/node/compiler/compileScript.js +141 -0
- package/lib/{compiler → node/compiler}/compileSiteEntry.d.ts +13 -13
- package/lib/node/compiler/compileSiteEntry.js +128 -0
- package/lib/{compiler → node/compiler}/compileStyle.d.ts +11 -11
- package/lib/node/compiler/compileStyle.js +39 -0
- package/lib/{compiler → node/compiler}/compileTemplateHighlight.d.ts +10 -10
- package/lib/node/compiler/compileTemplateHighlight.js +133 -0
- package/lib/{compiler → node/compiler}/compileTypes.d.ts +2 -2
- package/lib/node/compiler/compileTypes.js +45 -0
- package/lib/{config → node/config}/varlet.config.d.ts +45 -44
- package/lib/node/config/varlet.config.js +27 -0
- package/lib/node/config/varlet.default.config.d.ts +2 -0
- package/lib/node/config/varlet.default.config.js +264 -0
- package/lib/node/config/vite.config.d.ts +6 -0
- package/lib/node/config/vite.config.js +144 -0
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/{shared → node/shared}/constant.d.ts +42 -43
- package/lib/node/shared/constant.js +47 -0
- package/lib/{shared → node/shared}/fsUtils.d.ts +13 -12
- package/lib/node/shared/fsUtils.js +48 -0
- package/lib/{shared → node/shared}/logger.d.ts +8 -8
- package/lib/node/shared/logger.js +18 -0
- package/package.json +22 -19
- package/{preset.js → preset.cjs} +1 -1
- package/site/components/button/index.ts +10 -10
- package/site/components/cell/index.ts +10 -10
- package/site/components/code-example/CodeExample.vue +2 -1
- package/site/components/code-example/codeExample.less +41 -41
- package/site/components/code-example/index.ts +10 -10
- package/site/components/context/zIndex.ts +20 -20
- package/site/components/icon/icon.less +26 -26
- package/site/components/icon/index.ts +10 -10
- package/site/components/icon/props.ts +24 -24
- package/site/components/loading/index.ts +10 -10
- package/site/components/progress/index.ts +10 -10
- package/site/components/snackbar/snackbar.less +135 -135
- package/site/components/styles/common.less +64 -64
- package/site/components/styles/elevation.less +126 -126
- package/site/components/styles/var.less +27 -27
- package/site/components/utils/components.ts +1 -4
- package/site/components/utils/elements.ts +1 -1
- package/site/index.html +49 -49
- package/site/mobile/App.vue +27 -26
- package/site/mobile/components/AppHome.vue +2 -1
- package/site/mobile/components/app-bar/index.ts +10 -10
- package/site/mobile/components/app-bar/props.ts +25 -25
- package/site/mobile.html +41 -41
- package/site/module.d.ts +5 -5
- package/site/pc/App.vue +2 -1
- package/site/pc/Layout.vue +2 -1
- package/site/pc/components/AppHeader.vue +4 -2
- package/site/pc/pages/index/index.vue +8 -4
- package/site/tsconfig.json +11 -11
- package/site/useProgress.ts +2 -1
- package/site/utils.ts +6 -137
- package/template/generators/config/default/base/{varlet.config.js → varlet.config.mjs} +2 -2
- package/template/generators/config/i18n/base/{varlet.config.js → varlet.config.mjs} +2 -2
- package/tsconfig.json +2 -9
- package/lib/bin.js +0 -102
- package/lib/commands/build.js +0 -67
- package/lib/commands/changelog.js +0 -27
- package/lib/commands/commitLint.js +0 -21
- package/lib/commands/compile.js +0 -119
- package/lib/commands/create.js +0 -166
- package/lib/commands/dev.js +0 -123
- package/lib/commands/gen.js +0 -138
- package/lib/commands/jest.js +0 -85
- package/lib/commands/lint.js +0 -123
- package/lib/commands/preview.js +0 -74
- package/lib/commands/release.js +0 -270
- package/lib/commands/vite.js +0 -69
- package/lib/compiler/compileModule.js +0 -190
- package/lib/compiler/compileSFC.js +0 -135
- package/lib/compiler/compileScript.js +0 -194
- package/lib/compiler/compileSiteEntry.js +0 -237
- package/lib/compiler/compileStyle.js +0 -91
- package/lib/compiler/compileTemplateHighlight.js +0 -193
- package/lib/compiler/compileTypes.js +0 -85
- package/lib/config/babel.config.d.ts +0 -2
- package/lib/config/babel.config.js +0 -31
- package/lib/config/babel.sfc.transform.d.ts +0 -1
- package/lib/config/babel.sfc.transform.js +0 -18
- package/lib/config/jest.config.d.ts +0 -1
- package/lib/config/jest.config.js +0 -37
- package/lib/config/jest.media.mock.d.ts +0 -0
- package/lib/config/jest.media.mock.js +0 -2
- package/lib/config/jest.style.mock.d.ts +0 -0
- package/lib/config/jest.style.mock.js +0 -2
- package/lib/config/varlet.config.js +0 -35
- package/lib/config/vite.config.d.ts +0 -5
- package/lib/config/vite.config.js +0 -162
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -5
- package/lib/shared/constant.js +0 -50
- package/lib/shared/fsUtils.js +0 -108
- package/lib/shared/logger.js +0 -23
- package/site/mobile/components/AppType.vue +0 -22
- package/varlet.default.config.js +0 -267
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import { transformAsync } from '@babel/core';
|
|
3
|
+
import { bigCamelize } from '@varlet/shared';
|
|
4
|
+
import { replaceExt } from '../shared/fsUtils.js';
|
|
5
|
+
import { extractStyleDependencies, IMPORT_CSS_RE, IMPORT_LESS_RE, REQUIRE_CSS_RE, REQUIRE_LESS_RE, } from './compileStyle.js';
|
|
6
|
+
import { resolve } from 'path';
|
|
7
|
+
import { get } from 'lodash-es';
|
|
8
|
+
import { getVarletConfig } from '../config/varlet.config.js';
|
|
9
|
+
const { writeFileSync, readFileSync, removeSync, writeFile } = fse;
|
|
10
|
+
export const IMPORT_VUE_PATH_RE = /((?<!['"`])import\s+.+from\s+['"]\s*\.{1,2}\/.+)\.vue(\s*['"`]);?(?!\s*['"`])/g;
|
|
11
|
+
export const IMPORT_TS_PATH_RE = /((?<!['"`])import\s+.+from\s+['"]\s*\.{1,2}\/.+)\.ts(\s*['"`]);?(?!\s*['"`])/g;
|
|
12
|
+
export const IMPORT_JSX_PATH_RE = /((?<!['"`])import\s+.+from\s+['"]\s*\.{1,2}\/.+)\.jsx(\s*['"`]);?(?!\s*['"`])/g;
|
|
13
|
+
export const IMPORT_TSX_PATH_RE = /((?<!['"`])import\s+.+from\s+['"]\s*\.{1,2}\/.+)\.tsx(\s*['"`]);?(?!\s*['"`])/g;
|
|
14
|
+
export const REQUIRE_VUE_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.vue(\s*['"`]\))(?!\s*['"`])/g;
|
|
15
|
+
export const REQUIRE_TS_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.ts(\s*['"`]\))(?!\s*['"`])/g;
|
|
16
|
+
export const REQUIRE_JSX_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.jsx(\s*['"`]\))(?!\s*['"`])/g;
|
|
17
|
+
export const REQUIRE_TSX_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.tsx(\s*['"`]\))(?!\s*['"`])/g;
|
|
18
|
+
const scriptReplacer = (_, p1, p2) => `${p1}.js${p2}`;
|
|
19
|
+
export const replaceVueExt = (script) => script.replace(IMPORT_VUE_PATH_RE, scriptReplacer).replace(REQUIRE_VUE_PATH_RE, scriptReplacer);
|
|
20
|
+
export const replaceTSExt = (script) => script.replace(IMPORT_TS_PATH_RE, scriptReplacer).replace(REQUIRE_TS_PATH_RE, scriptReplacer);
|
|
21
|
+
export const replaceJSXExt = (script) => script.replace(IMPORT_JSX_PATH_RE, scriptReplacer).replace(REQUIRE_JSX_PATH_RE, scriptReplacer);
|
|
22
|
+
export const replaceTSXExt = (script) => script.replace(IMPORT_TSX_PATH_RE, scriptReplacer).replace(REQUIRE_TSX_PATH_RE, scriptReplacer);
|
|
23
|
+
export const moduleCompatible = async (script) => {
|
|
24
|
+
const moduleCompatible = get(await getVarletConfig(), 'moduleCompatible', {});
|
|
25
|
+
Object.keys(moduleCompatible).forEach((esm) => {
|
|
26
|
+
const commonjs = moduleCompatible[esm];
|
|
27
|
+
script = script.replace(esm, commonjs);
|
|
28
|
+
});
|
|
29
|
+
return script;
|
|
30
|
+
};
|
|
31
|
+
export async function compileScript(script, file) {
|
|
32
|
+
const modules = process.env.BABEL_MODULE;
|
|
33
|
+
if (modules === 'commonjs') {
|
|
34
|
+
script = await moduleCompatible(script);
|
|
35
|
+
}
|
|
36
|
+
let { code } = (await transformAsync(script, {
|
|
37
|
+
filename: file,
|
|
38
|
+
}));
|
|
39
|
+
code = extractStyleDependencies(file, code, modules === 'commonjs' ? REQUIRE_CSS_RE : IMPORT_CSS_RE);
|
|
40
|
+
code = extractStyleDependencies(file, code, modules === 'commonjs' ? REQUIRE_LESS_RE : IMPORT_LESS_RE);
|
|
41
|
+
code = replaceVueExt(code);
|
|
42
|
+
code = replaceTSXExt(code);
|
|
43
|
+
code = replaceJSXExt(code);
|
|
44
|
+
code = replaceTSExt(code);
|
|
45
|
+
removeSync(file);
|
|
46
|
+
writeFileSync(replaceExt(file, '.js'), code, 'utf8');
|
|
47
|
+
}
|
|
48
|
+
export async function compileScriptFile(file) {
|
|
49
|
+
const sources = readFileSync(file, 'utf-8');
|
|
50
|
+
await compileScript(sources, file);
|
|
51
|
+
}
|
|
52
|
+
export async function compileESEntry(dir, publicDirs) {
|
|
53
|
+
const imports = [];
|
|
54
|
+
const plugins = [];
|
|
55
|
+
const constInternalComponents = [];
|
|
56
|
+
const cssImports = [];
|
|
57
|
+
const publicComponents = [];
|
|
58
|
+
publicDirs.forEach((dirname) => {
|
|
59
|
+
const publicComponent = bigCamelize(dirname);
|
|
60
|
+
publicComponents.push(publicComponent);
|
|
61
|
+
imports.push(`import ${publicComponent}, * as ${publicComponent}Module from './${dirname}'`);
|
|
62
|
+
constInternalComponents.push(`export const _${publicComponent}Component = ${publicComponent}Module._${publicComponent}Component || {}`);
|
|
63
|
+
plugins.push(`${publicComponent}.install && app.use(${publicComponent})`);
|
|
64
|
+
cssImports.push(`import './${dirname}/style'`);
|
|
65
|
+
});
|
|
66
|
+
const install = `
|
|
67
|
+
function install(app) {
|
|
68
|
+
${plugins.join('\n ')}
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
const indexTemplate = `\
|
|
72
|
+
${imports.join('\n')}\n
|
|
73
|
+
${constInternalComponents.join('\n')}\n
|
|
74
|
+
${install}
|
|
75
|
+
export {
|
|
76
|
+
install,
|
|
77
|
+
${publicComponents.join(',\n ')}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
install,
|
|
82
|
+
${publicComponents.join(',\n ')}
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
const styleTemplate = `\
|
|
86
|
+
${cssImports.join('\n')}
|
|
87
|
+
`;
|
|
88
|
+
const umdTemplate = `\
|
|
89
|
+
${imports.join('\n')}\n
|
|
90
|
+
${cssImports.join('\n')}\n
|
|
91
|
+
${install}
|
|
92
|
+
export {
|
|
93
|
+
install,
|
|
94
|
+
${publicComponents.join(',\n ')}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default {
|
|
98
|
+
install,
|
|
99
|
+
${publicComponents.join(',\n ')}
|
|
100
|
+
}
|
|
101
|
+
`;
|
|
102
|
+
await Promise.all([
|
|
103
|
+
writeFile(resolve(dir, 'index.js'), indexTemplate, 'utf-8'),
|
|
104
|
+
writeFile(resolve(dir, 'umdIndex.js'), umdTemplate, 'utf-8'),
|
|
105
|
+
writeFile(resolve(dir, 'style.js'), styleTemplate, 'utf-8'),
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
export async function compileCommonJSEntry(dir, publicDirs) {
|
|
109
|
+
const requires = [];
|
|
110
|
+
const plugins = [];
|
|
111
|
+
const cssRequires = [];
|
|
112
|
+
const publicComponents = [];
|
|
113
|
+
publicDirs.forEach((dirname) => {
|
|
114
|
+
const publicComponent = bigCamelize(dirname);
|
|
115
|
+
publicComponents.push(publicComponent);
|
|
116
|
+
requires.push(`var ${publicComponent} = require('./${dirname}')['default']`);
|
|
117
|
+
plugins.push(`${publicComponent}.install && app.use(${publicComponent})`);
|
|
118
|
+
cssRequires.push(`require('./${dirname}/style')`);
|
|
119
|
+
});
|
|
120
|
+
const install = `
|
|
121
|
+
function install(app) {
|
|
122
|
+
${plugins.join('\n ')}
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
const indexTemplate = `\
|
|
126
|
+
${requires.join('\n')}\n
|
|
127
|
+
${install}
|
|
128
|
+
|
|
129
|
+
module.exports = {
|
|
130
|
+
install,
|
|
131
|
+
${publicComponents.join(',\n ')}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
const styleTemplate = `\
|
|
135
|
+
${cssRequires.join('\n')}
|
|
136
|
+
`;
|
|
137
|
+
await Promise.all([
|
|
138
|
+
writeFile(resolve(dir, 'index.js'), indexTemplate, 'utf-8'),
|
|
139
|
+
writeFile(resolve(dir, 'style.js'), styleTemplate, 'utf-8'),
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export declare function getExampleRoutePath(examplePath: string): string;
|
|
2
|
-
export declare function getComponentDocRoutePath(componentDocsPath: string): string;
|
|
3
|
-
export declare function getRootDocRoutePath(rootDocsPath: string): string;
|
|
4
|
-
export declare function getRootRoutePath(rootLocalePath: string): string;
|
|
5
|
-
export declare function getRootFilePath(rootLocalePath: string): string;
|
|
6
|
-
export declare function findExamples(): Promise<string[]>;
|
|
7
|
-
export declare function findComponentDocs(): Promise<string[]>;
|
|
8
|
-
export declare function findRootDocs(): Promise<string[]>;
|
|
9
|
-
export declare function findRootLocales(): Promise<string[]>;
|
|
10
|
-
export declare function buildMobileSiteRoutes(): Promise<void>;
|
|
11
|
-
export declare function buildPcSiteRoutes(): Promise<void>;
|
|
12
|
-
export declare function buildSiteSource(): Promise<void>;
|
|
13
|
-
export declare function buildSiteEntry(): Promise<void>;
|
|
1
|
+
export declare function getExampleRoutePath(examplePath: string): string;
|
|
2
|
+
export declare function getComponentDocRoutePath(componentDocsPath: string): string;
|
|
3
|
+
export declare function getRootDocRoutePath(rootDocsPath: string): string;
|
|
4
|
+
export declare function getRootRoutePath(rootLocalePath: string): string;
|
|
5
|
+
export declare function getRootFilePath(rootLocalePath: string): string;
|
|
6
|
+
export declare function findExamples(): Promise<string[]>;
|
|
7
|
+
export declare function findComponentDocs(): Promise<string[]>;
|
|
8
|
+
export declare function findRootDocs(): Promise<string[]>;
|
|
9
|
+
export declare function findRootLocales(): Promise<string[]>;
|
|
10
|
+
export declare function buildMobileSiteRoutes(): Promise<void>;
|
|
11
|
+
export declare function buildPcSiteRoutes(): Promise<void>;
|
|
12
|
+
export declare function buildSiteSource(): Promise<void>;
|
|
13
|
+
export declare function buildSiteEntry(): Promise<void>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import slash from 'slash';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import { DOCS_DIR_NAME, DIR_INDEX, EXAMPLE_DIR_NAME, LOCALE_DIR_NAME, ROOT_DOCS_DIR, ROOT_PAGES_DIR, SITE, SITE_DIR, SITE_MOBILE_ROUTES, SITE_PC_DIR, SITE_PC_ROUTES, SRC_DIR, } from '../shared/constant.js';
|
|
4
|
+
import { glob, isDir, outputFileSyncOnChange } from '../shared/fsUtils.js';
|
|
5
|
+
import { getVarletConfig } from '../config/varlet.config.js';
|
|
6
|
+
import { get } from 'lodash-es';
|
|
7
|
+
const { copy } = fse;
|
|
8
|
+
const EXAMPLE_COMPONENT_NAME_RE = /\/([-\w]+)\/example\/index.vue/;
|
|
9
|
+
const COMPONENT_DOCS_RE = /\/([-\w]+)\/docs\/([-\w]+)\.md/;
|
|
10
|
+
const ROOT_DOCS_RE = /\/docs\/([-\w]+)\.([-\w]+)\.md/;
|
|
11
|
+
const ROOT_LOCALE_RE = /\/pages\/([-\w]+)\/locale\/([-\w]+)\.ts/;
|
|
12
|
+
export function getExampleRoutePath(examplePath) {
|
|
13
|
+
var _a;
|
|
14
|
+
return '/' + ((_a = examplePath.match(EXAMPLE_COMPONENT_NAME_RE)) === null || _a === void 0 ? void 0 : _a[1]);
|
|
15
|
+
}
|
|
16
|
+
export function getComponentDocRoutePath(componentDocsPath) {
|
|
17
|
+
var _a;
|
|
18
|
+
const [, routePath, language] = (_a = componentDocsPath.match(COMPONENT_DOCS_RE)) !== null && _a !== void 0 ? _a : [];
|
|
19
|
+
return `/${language}/${routePath}`;
|
|
20
|
+
}
|
|
21
|
+
export function getRootDocRoutePath(rootDocsPath) {
|
|
22
|
+
var _a;
|
|
23
|
+
const [, routePath, language] = (_a = rootDocsPath.match(ROOT_DOCS_RE)) !== null && _a !== void 0 ? _a : [];
|
|
24
|
+
return `/${language}/${routePath}`;
|
|
25
|
+
}
|
|
26
|
+
export function getRootRoutePath(rootLocalePath) {
|
|
27
|
+
var _a;
|
|
28
|
+
const [, routePath, language] = (_a = rootLocalePath.match(ROOT_LOCALE_RE)) !== null && _a !== void 0 ? _a : [];
|
|
29
|
+
return `/${language}/${routePath}`;
|
|
30
|
+
}
|
|
31
|
+
export function getRootFilePath(rootLocalePath) {
|
|
32
|
+
return rootLocalePath.replace(/locale\/.+/, DIR_INDEX);
|
|
33
|
+
}
|
|
34
|
+
export function findExamples() {
|
|
35
|
+
return glob(`${SRC_DIR}/**/${EXAMPLE_DIR_NAME}/${DIR_INDEX}`);
|
|
36
|
+
}
|
|
37
|
+
export function findComponentDocs() {
|
|
38
|
+
return glob(`${SRC_DIR}/**/${DOCS_DIR_NAME}/*.md`);
|
|
39
|
+
}
|
|
40
|
+
export function findRootDocs() {
|
|
41
|
+
return glob(`${ROOT_DOCS_DIR}/*.md`);
|
|
42
|
+
}
|
|
43
|
+
export async function findRootLocales() {
|
|
44
|
+
const defaultLanguage = get(await getVarletConfig(), 'defaultLanguage');
|
|
45
|
+
const userPages = await glob(`${ROOT_PAGES_DIR}/*`);
|
|
46
|
+
const baseLocales = await glob(`${SITE}/pc/pages/**/${LOCALE_DIR_NAME}/*.ts`);
|
|
47
|
+
const userLocales = await userPages.reduce(async (userLocales, page) => {
|
|
48
|
+
if (isDir(page)) {
|
|
49
|
+
const locales = await glob(`${page}/${LOCALE_DIR_NAME}/*.ts`);
|
|
50
|
+
if (!locales.length)
|
|
51
|
+
locales.push(`${page}/${LOCALE_DIR_NAME}/${defaultLanguage}.ts`);
|
|
52
|
+
(await userLocales).push(...locales);
|
|
53
|
+
}
|
|
54
|
+
return userLocales;
|
|
55
|
+
}, Promise.resolve([]));
|
|
56
|
+
// filter
|
|
57
|
+
const filterMap = new Map();
|
|
58
|
+
baseLocales.forEach((locale) => {
|
|
59
|
+
var _a;
|
|
60
|
+
const [, routePath, language] = (_a = locale.match(ROOT_LOCALE_RE)) !== null && _a !== void 0 ? _a : [];
|
|
61
|
+
filterMap.set(routePath + language, slash(`${SITE_PC_DIR}/pages/${routePath}/locale/${language}.ts`));
|
|
62
|
+
});
|
|
63
|
+
userLocales.forEach((locale) => {
|
|
64
|
+
var _a;
|
|
65
|
+
const [, routePath, language] = (_a = locale.match(ROOT_LOCALE_RE)) !== null && _a !== void 0 ? _a : [];
|
|
66
|
+
filterMap.set(routePath + language, locale);
|
|
67
|
+
});
|
|
68
|
+
return Promise.resolve(Array.from(filterMap.values()));
|
|
69
|
+
}
|
|
70
|
+
export async function buildMobileSiteRoutes() {
|
|
71
|
+
const examples = await findExamples();
|
|
72
|
+
const routes = examples.map((example) => `
|
|
73
|
+
{
|
|
74
|
+
path: '${getExampleRoutePath(example)}',
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
component: () => import('${example}')
|
|
77
|
+
}`);
|
|
78
|
+
const source = `export default [\
|
|
79
|
+
${routes.join(',')}
|
|
80
|
+
]`;
|
|
81
|
+
await outputFileSyncOnChange(SITE_MOBILE_ROUTES, source);
|
|
82
|
+
}
|
|
83
|
+
export async function buildPcSiteRoutes() {
|
|
84
|
+
const [componentDocs, rootDocs, rootLocales] = await Promise.all([
|
|
85
|
+
findComponentDocs(),
|
|
86
|
+
findRootDocs(),
|
|
87
|
+
findRootLocales(),
|
|
88
|
+
]);
|
|
89
|
+
const rootPagesRoutes = rootLocales.map((rootLocale) => `
|
|
90
|
+
{
|
|
91
|
+
path: '${getRootRoutePath(rootLocale)}',
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
component: () => import('${getRootFilePath(rootLocale)}')
|
|
94
|
+
}\
|
|
95
|
+
`);
|
|
96
|
+
const componentDocsRoutes = componentDocs.map((componentDoc) => `
|
|
97
|
+
{
|
|
98
|
+
path: '${getComponentDocRoutePath(componentDoc)}',
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
component: () => import('${componentDoc}')
|
|
101
|
+
}`);
|
|
102
|
+
const rootDocsRoutes = rootDocs.map((rootDoc) => `
|
|
103
|
+
{
|
|
104
|
+
path: '${getRootDocRoutePath(rootDoc)}',
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
component: () => import('${rootDoc}')
|
|
107
|
+
}`);
|
|
108
|
+
const layoutRoutes = `{
|
|
109
|
+
path: '/layout',
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
component:()=> import('${slash(SITE_PC_DIR)}/Layout.vue'),
|
|
112
|
+
children: [
|
|
113
|
+
${[...componentDocsRoutes, rootDocsRoutes].join(',')},
|
|
114
|
+
]
|
|
115
|
+
}`;
|
|
116
|
+
const source = `export default [\
|
|
117
|
+
${rootPagesRoutes.join(',')},
|
|
118
|
+
${layoutRoutes}
|
|
119
|
+
]`;
|
|
120
|
+
outputFileSyncOnChange(SITE_PC_ROUTES, source);
|
|
121
|
+
}
|
|
122
|
+
export async function buildSiteSource() {
|
|
123
|
+
return copy(SITE, SITE_DIR);
|
|
124
|
+
}
|
|
125
|
+
export async function buildSiteEntry() {
|
|
126
|
+
await getVarletConfig(true);
|
|
127
|
+
await Promise.all([buildMobileSiteRoutes(), buildPcSiteRoutes(), buildSiteSource()]);
|
|
128
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export declare const EMPTY_SPACE_RE: RegExp;
|
|
2
|
-
export declare const EMPTY_LINE_RE: RegExp;
|
|
3
|
-
export declare const IMPORT_CSS_RE: RegExp;
|
|
4
|
-
export declare const IMPORT_LESS_RE: RegExp;
|
|
5
|
-
export declare const REQUIRE_CSS_RE: RegExp;
|
|
6
|
-
export declare const REQUIRE_LESS_RE: RegExp;
|
|
7
|
-
export declare const STYLE_IMPORT_RE: RegExp;
|
|
8
|
-
export declare const clearEmptyLine: (s: string) => string;
|
|
9
|
-
export declare function normalizeStyleDependency(styleImport: string, reg: RegExp): string;
|
|
10
|
-
export declare function extractStyleDependencies(file: string, code: string, styleReg: RegExp): string;
|
|
11
|
-
export declare function compileLess(file: string): Promise<void>;
|
|
1
|
+
export declare const EMPTY_SPACE_RE: RegExp;
|
|
2
|
+
export declare const EMPTY_LINE_RE: RegExp;
|
|
3
|
+
export declare const IMPORT_CSS_RE: RegExp;
|
|
4
|
+
export declare const IMPORT_LESS_RE: RegExp;
|
|
5
|
+
export declare const REQUIRE_CSS_RE: RegExp;
|
|
6
|
+
export declare const REQUIRE_LESS_RE: RegExp;
|
|
7
|
+
export declare const STYLE_IMPORT_RE: RegExp;
|
|
8
|
+
export declare const clearEmptyLine: (s: string) => string;
|
|
9
|
+
export declare function normalizeStyleDependency(styleImport: string, reg: RegExp): string;
|
|
10
|
+
export declare function extractStyleDependencies(file: string, code: string, styleReg: RegExp): string;
|
|
11
|
+
export declare function compileLess(file: string): Promise<void>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import less from 'less';
|
|
3
|
+
import { replaceExt, smartAppendFileSync } from '../shared/fsUtils.js';
|
|
4
|
+
import { parse, resolve } from 'path';
|
|
5
|
+
const { render } = less;
|
|
6
|
+
const { readFileSync, removeSync, writeFileSync } = fse;
|
|
7
|
+
export const EMPTY_SPACE_RE = /[\s]+/g;
|
|
8
|
+
export const EMPTY_LINE_RE = /[\n\r]*/g;
|
|
9
|
+
export const IMPORT_CSS_RE = /(?<!['"`])import\s+['"](\.{1,2}\/.+\.css)['"]\s*;?(?!\s*['"`])/g;
|
|
10
|
+
export const IMPORT_LESS_RE = /(?<!['"`])import\s+['"](\.{1,2}\/.+\.less)['"]\s*;?(?!\s*['"`])/g;
|
|
11
|
+
export const REQUIRE_CSS_RE = /(?<!['"`])require\(\s*['"](\.{1,2}\/.+\.css)['"]\s*\);?(?!\s*['"`])/g;
|
|
12
|
+
export const REQUIRE_LESS_RE = /(?<!['"`])require\(\s*['"](\.{1,2}\/.+\.less)['"]\s*\);?(?!\s*['"`])/g;
|
|
13
|
+
export const STYLE_IMPORT_RE = /@import\s+['"](.+)['"]\s*;/g;
|
|
14
|
+
export const clearEmptyLine = (s) => s.replace(EMPTY_LINE_RE, '').replace(EMPTY_SPACE_RE, ' ');
|
|
15
|
+
export function normalizeStyleDependency(styleImport, reg) {
|
|
16
|
+
let relativePath = styleImport.replace(reg, '$1');
|
|
17
|
+
relativePath = relativePath.replace(/(\.less)|(\.css)/, '');
|
|
18
|
+
if (relativePath.startsWith('./')) {
|
|
19
|
+
return '.' + relativePath;
|
|
20
|
+
}
|
|
21
|
+
return '../' + relativePath;
|
|
22
|
+
}
|
|
23
|
+
export function extractStyleDependencies(file, code, styleReg) {
|
|
24
|
+
var _a;
|
|
25
|
+
const styleImports = (_a = code.match(styleReg)) !== null && _a !== void 0 ? _a : [];
|
|
26
|
+
const cssFile = resolve(parse(file).dir, './style/index.js');
|
|
27
|
+
const modules = process.env.BABEL_MODULE;
|
|
28
|
+
styleImports.forEach((styleImport) => {
|
|
29
|
+
const normalizedPath = normalizeStyleDependency(styleImport, styleReg);
|
|
30
|
+
smartAppendFileSync(cssFile, modules === 'commonjs' ? `require('${normalizedPath}.css')\n` : `import '${normalizedPath}.css'\n`);
|
|
31
|
+
});
|
|
32
|
+
return code.replace(styleReg, '');
|
|
33
|
+
}
|
|
34
|
+
export async function compileLess(file) {
|
|
35
|
+
const source = readFileSync(file, 'utf-8');
|
|
36
|
+
const { css } = await render(source, { filename: file });
|
|
37
|
+
removeSync(file);
|
|
38
|
+
writeFileSync(replaceExt(file, '.css'), clearEmptyLine(css), 'utf-8');
|
|
39
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const replaceDot: (s: string) => string;
|
|
2
|
-
export declare const replaceUnderline: (s: string) => string;
|
|
3
|
-
export declare function parseTable(table: string): string[][];
|
|
4
|
-
export declare function compileTable(md: string, titleRe: RegExp): string;
|
|
5
|
-
export declare function compileTags(table: Record<string, any>, tags: Record<string, any>, componentName: string, varletConfig: Record<string, any>): void;
|
|
6
|
-
export declare function compileAttributes(table: Record<string, any>, attributes: Record<string, any>, componentName: string, varletConfig: Record<string, any>): void;
|
|
7
|
-
export declare function compileWebTypes(table: Record<string, any>, webTypes: Record<string, any>, componentName: string, varletConfig: Record<string, any>): void;
|
|
8
|
-
export declare function compileMD(path: string, tags: Record<string, any>, attributes: Record<string, any>, webTypes: Record<string, any>, varletConfig: Record<string, any>): void;
|
|
9
|
-
export declare function compileDir(path: string, tags: Record<string, any>, attributes: Record<string, any>, webTypes: Record<string, any>, varletConfig: Record<string, any>): void;
|
|
10
|
-
export declare function compileTemplateHighlight(): Promise<void>;
|
|
1
|
+
export declare const replaceDot: (s: string) => string;
|
|
2
|
+
export declare const replaceUnderline: (s: string) => string;
|
|
3
|
+
export declare function parseTable(table: string): string[][];
|
|
4
|
+
export declare function compileTable(md: string, titleRe: RegExp): string;
|
|
5
|
+
export declare function compileTags(table: Record<string, any>, tags: Record<string, any>, componentName: string, varletConfig: Record<string, any>): void;
|
|
6
|
+
export declare function compileAttributes(table: Record<string, any>, attributes: Record<string, any>, componentName: string, varletConfig: Record<string, any>): void;
|
|
7
|
+
export declare function compileWebTypes(table: Record<string, any>, webTypes: Record<string, any>, componentName: string, varletConfig: Record<string, any>): void;
|
|
8
|
+
export declare function compileMD(path: string, tags: Record<string, any>, attributes: Record<string, any>, webTypes: Record<string, any>, varletConfig: Record<string, any>): void;
|
|
9
|
+
export declare function compileDir(path: string, tags: Record<string, any>, attributes: Record<string, any>, webTypes: Record<string, any>, varletConfig: Record<string, any>): void;
|
|
10
|
+
export declare function compileTemplateHighlight(): Promise<void>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import { SRC_DIR, HL_MD, HL_API_RE, HL_COMPONENT_NAME_RE, HL_TITLE_ATTRIBUTES_RE, HL_TITLE_EVENTS_RE, HL_TITLE_SLOTS_RE, HL_WEB_TYPES_JSON, HL_DIR, HL_TAGS_JSON, HL_ATTRIBUTES_JSON, CLI_PACKAGE_JSON, } from '../shared/constant.js';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
import { isDir, isMD } from '../shared/fsUtils.js';
|
|
5
|
+
import { get } from 'lodash-es';
|
|
6
|
+
import { getVarletConfig } from '../config/varlet.config.js';
|
|
7
|
+
const { ensureDir, readdirSync, readFileSync, readJSONSync, writeFile } = fse;
|
|
8
|
+
const TABLE_HEAD_RE = /\s*\|.*\|\s*\n\s*\|.*---+\s*\|\s*\n+/;
|
|
9
|
+
const TABLE_FOOT_RE = /(\|\s*$)|(\|\s*\n(?!\s*\|))/;
|
|
10
|
+
export const replaceDot = (s) => s.replace(/`/g, '');
|
|
11
|
+
export const replaceUnderline = (s) => s.replace(/_/g, '');
|
|
12
|
+
export function parseTable(table) {
|
|
13
|
+
const rows = table.split('\n').filter(Boolean);
|
|
14
|
+
return rows.map((row) => {
|
|
15
|
+
const cols = row.split('|');
|
|
16
|
+
cols.shift();
|
|
17
|
+
cols.pop();
|
|
18
|
+
return cols.map((col) => col.replace(/__varlet_axis__/g, '|').trim());
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function compileTable(md, titleRe) {
|
|
22
|
+
const apiMatched = md.match(HL_API_RE);
|
|
23
|
+
if (!apiMatched) {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
md = md.slice(apiMatched.index + apiMatched[0].length);
|
|
27
|
+
const titleMatched = md.match(titleRe);
|
|
28
|
+
if (!titleMatched) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
md = md.slice(titleMatched.index + titleMatched[0].length);
|
|
32
|
+
const tableHeadMatched = md.match(TABLE_HEAD_RE);
|
|
33
|
+
if (!tableHeadMatched) {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
md = md.slice(tableHeadMatched.index + tableHeadMatched[0].length);
|
|
37
|
+
const tableFootMatched = md.match(TABLE_FOOT_RE);
|
|
38
|
+
if (!tableFootMatched) {
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
md = md.slice(0, tableFootMatched.index + tableFootMatched[0].length);
|
|
42
|
+
return md.replace(/\\\|/g, '__varlet_axis__').trim();
|
|
43
|
+
}
|
|
44
|
+
export function compileTags(table, tags, componentName, varletConfig) {
|
|
45
|
+
tags[`${get(varletConfig, 'namespace')}-${componentName}`] = {
|
|
46
|
+
attributes: table.attributesTable.map((row) => replaceDot(row[0])),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function compileAttributes(table, attributes, componentName, varletConfig) {
|
|
50
|
+
table.attributesTable.forEach((row) => {
|
|
51
|
+
const attrNamespace = `${get(varletConfig, 'namespace')}-${componentName}/${replaceDot(row[0])}`;
|
|
52
|
+
attributes[attrNamespace] = {
|
|
53
|
+
type: replaceUnderline(row[2]),
|
|
54
|
+
description: `${row[1]} 默认值:${replaceDot(row[3])}`,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export function compileWebTypes(table, webTypes, componentName, varletConfig) {
|
|
59
|
+
const { attributesTable, eventsTable, slotsTable } = table;
|
|
60
|
+
const attributes = attributesTable.map((row) => ({
|
|
61
|
+
name: replaceDot(row[0]),
|
|
62
|
+
description: row[1],
|
|
63
|
+
default: replaceDot(row[3]),
|
|
64
|
+
value: {
|
|
65
|
+
type: replaceUnderline(row[2]),
|
|
66
|
+
kind: 'expression',
|
|
67
|
+
},
|
|
68
|
+
}));
|
|
69
|
+
const events = eventsTable.map((row) => ({
|
|
70
|
+
name: replaceDot(row[0]),
|
|
71
|
+
description: row[1],
|
|
72
|
+
}));
|
|
73
|
+
const slots = slotsTable.map((row) => ({
|
|
74
|
+
name: replaceDot(row[0]),
|
|
75
|
+
description: row[1],
|
|
76
|
+
}));
|
|
77
|
+
webTypes.contributions.html.tags.push({
|
|
78
|
+
name: `${get(varletConfig, 'namespace')}-${componentName}`,
|
|
79
|
+
attributes,
|
|
80
|
+
events,
|
|
81
|
+
slots,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
export function compileMD(path, tags, attributes, webTypes, varletConfig) {
|
|
85
|
+
if (!path.endsWith(HL_MD)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const md = readFileSync(path, 'utf-8');
|
|
89
|
+
const componentName = path.match(HL_COMPONENT_NAME_RE)[2];
|
|
90
|
+
const attributesTable = parseTable(compileTable(md, HL_TITLE_ATTRIBUTES_RE));
|
|
91
|
+
const eventsTable = parseTable(compileTable(md, HL_TITLE_EVENTS_RE));
|
|
92
|
+
const slotsTable = parseTable(compileTable(md, HL_TITLE_SLOTS_RE));
|
|
93
|
+
const table = {
|
|
94
|
+
attributesTable,
|
|
95
|
+
eventsTable,
|
|
96
|
+
slotsTable,
|
|
97
|
+
};
|
|
98
|
+
compileWebTypes(table, webTypes, componentName, varletConfig);
|
|
99
|
+
compileTags(table, tags, componentName, varletConfig);
|
|
100
|
+
compileAttributes(table, attributes, componentName, varletConfig);
|
|
101
|
+
}
|
|
102
|
+
export function compileDir(path, tags, attributes, webTypes, varletConfig) {
|
|
103
|
+
const dir = readdirSync(path);
|
|
104
|
+
dir.forEach((filename) => {
|
|
105
|
+
const filePath = resolve(path, filename);
|
|
106
|
+
isDir(filePath) && compileDir(filePath, tags, attributes, webTypes, varletConfig);
|
|
107
|
+
isMD(filePath) && compileMD(filePath, tags, attributes, webTypes, varletConfig);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
export async function compileTemplateHighlight() {
|
|
111
|
+
await ensureDir(HL_DIR);
|
|
112
|
+
const varletConfig = await getVarletConfig();
|
|
113
|
+
const tags = {};
|
|
114
|
+
const attributes = {};
|
|
115
|
+
const webTypes = {
|
|
116
|
+
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
|
|
117
|
+
framework: 'vue',
|
|
118
|
+
version: readJSONSync(CLI_PACKAGE_JSON).version,
|
|
119
|
+
name: get(varletConfig, 'title'),
|
|
120
|
+
contributions: {
|
|
121
|
+
html: {
|
|
122
|
+
tags: [],
|
|
123
|
+
'types-syntax': 'typescript',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
compileDir(SRC_DIR, tags, attributes, webTypes, varletConfig);
|
|
128
|
+
await Promise.all([
|
|
129
|
+
writeFile(HL_WEB_TYPES_JSON, JSON.stringify(webTypes, null, 2)),
|
|
130
|
+
writeFile(HL_TAGS_JSON, JSON.stringify(tags, null, 2)),
|
|
131
|
+
writeFile(HL_ATTRIBUTES_JSON, JSON.stringify(attributes, null, 2)),
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function generateReference(moduleDir: string): void;
|
|
2
|
-
export declare function compileTypes(): Promise<void>;
|
|
1
|
+
export declare function generateReference(moduleDir: string): void;
|
|
2
|
+
export declare function compileTypes(): Promise<void>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import { TYPES_DIR, UI_PACKAGE_JSON } from '../shared/constant.js';
|
|
3
|
+
import { bigCamelize } from '@varlet/shared';
|
|
4
|
+
import { resolve, relative } from 'path';
|
|
5
|
+
import { getVarletConfig } from '../config/varlet.config.js';
|
|
6
|
+
import { get } from 'lodash-es';
|
|
7
|
+
const { ensureDir, writeFileSync, readdir, writeFile, readJSONSync } = fse;
|
|
8
|
+
export function generateReference(moduleDir) {
|
|
9
|
+
writeFileSync(resolve(moduleDir, 'index.d.ts'), `\
|
|
10
|
+
export * from '${relative(moduleDir, TYPES_DIR)}'
|
|
11
|
+
`);
|
|
12
|
+
}
|
|
13
|
+
export async function compileTypes() {
|
|
14
|
+
const varletConfig = await getVarletConfig();
|
|
15
|
+
const namespace = get(varletConfig, 'namespace');
|
|
16
|
+
const { name } = readJSONSync(UI_PACKAGE_JSON);
|
|
17
|
+
await ensureDir(TYPES_DIR);
|
|
18
|
+
const dir = await readdir(TYPES_DIR);
|
|
19
|
+
const ignoreEntryDir = dir.filter((filename) => filename !== 'index.d.ts' && filename !== 'global.d.ts');
|
|
20
|
+
const exports = [];
|
|
21
|
+
const declares = [];
|
|
22
|
+
ignoreEntryDir.forEach((filename) => {
|
|
23
|
+
const componentName = filename.slice(0, filename.indexOf('.d.ts'));
|
|
24
|
+
exports.push(`export * from './${componentName}'`);
|
|
25
|
+
if (!componentName.startsWith(namespace)) {
|
|
26
|
+
declares.push(`${bigCamelize(namespace)}${bigCamelize(componentName)}: typeof import('${name}')['_${bigCamelize(componentName)}Component']`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const globalDeclares = `\
|
|
30
|
+
declare module 'vue' {
|
|
31
|
+
export interface GlobalComponents {
|
|
32
|
+
${declares.join('\n ')}
|
|
33
|
+
}
|
|
34
|
+
}`;
|
|
35
|
+
const template = `\
|
|
36
|
+
import type { App } from 'vue'
|
|
37
|
+
|
|
38
|
+
export const install: (app: App) => void
|
|
39
|
+
|
|
40
|
+
${exports.join('\n')}
|
|
41
|
+
|
|
42
|
+
${globalDeclares}
|
|
43
|
+
`;
|
|
44
|
+
await Promise.all([writeFile(resolve(TYPES_DIR, 'index.d.ts'), template)]);
|
|
45
|
+
}
|
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
interface VarletConfig {
|
|
2
|
-
/**
|
|
3
|
-
* @default `Varlet`
|
|
4
|
-
* UI library name.
|
|
5
|
-
*/
|
|
6
|
-
name?: string;
|
|
7
|
-
/**
|
|
8
|
-
* @default `var`
|
|
9
|
-
* Component name prefix
|
|
10
|
-
*/
|
|
11
|
-
namespace?: string;
|
|
12
|
-
/**
|
|
13
|
-
* @default `localhost`
|
|
14
|
-
* Local dev server host
|
|
15
|
-
*/
|
|
16
|
-
host?: string;
|
|
17
|
-
/**
|
|
18
|
-
* @default `8080`
|
|
19
|
-
* Local dev server port
|
|
20
|
-
*/
|
|
21
|
-
port?: number;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export declare function
|
|
44
|
-
export
|
|
1
|
+
export interface VarletConfig {
|
|
2
|
+
/**
|
|
3
|
+
* @default `Varlet`
|
|
4
|
+
* UI library name.
|
|
5
|
+
*/
|
|
6
|
+
name?: string;
|
|
7
|
+
/**
|
|
8
|
+
* @default `var`
|
|
9
|
+
* Component name prefix
|
|
10
|
+
*/
|
|
11
|
+
namespace?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @default `localhost`
|
|
14
|
+
* Local dev server host
|
|
15
|
+
*/
|
|
16
|
+
host?: string;
|
|
17
|
+
/**
|
|
18
|
+
* @default `8080`
|
|
19
|
+
* Local dev server port
|
|
20
|
+
*/
|
|
21
|
+
port?: number;
|
|
22
|
+
title?: string;
|
|
23
|
+
logo?: string;
|
|
24
|
+
themeKey?: string;
|
|
25
|
+
defaultLanguage?: 'zh-CN' | 'en-US';
|
|
26
|
+
/**
|
|
27
|
+
* @default `false`
|
|
28
|
+
* Show mobile component on the right.
|
|
29
|
+
*/
|
|
30
|
+
useMobile?: boolean;
|
|
31
|
+
lightTheme?: Record<string, string>;
|
|
32
|
+
darkTheme?: Record<string, string>;
|
|
33
|
+
highlight?: {
|
|
34
|
+
style: string;
|
|
35
|
+
};
|
|
36
|
+
analysis?: {
|
|
37
|
+
baidu: string;
|
|
38
|
+
};
|
|
39
|
+
pc?: Record<string, any>;
|
|
40
|
+
mobile?: Record<string, any>;
|
|
41
|
+
moduleCompatible?: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
export declare function defineConfig(config: VarletConfig): VarletConfig;
|
|
44
|
+
export declare function mergeStrategy(value: any, srcValue: any, key: string): any[] | undefined;
|
|
45
|
+
export declare function getVarletConfig(emit?: boolean): Promise<Required<VarletConfig>>;
|