@wevu/compiler 0.1.0 → 0.1.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 +148 -142
- package/dist/index.mjs +5216 -4525
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LRUCache } from "lru-cache";
|
|
2
|
-
import { SFCBlock, SFCDescriptor, SFCParseResult, SFCStyleBlock } from "vue/compiler-sfc";
|
|
3
1
|
import * as t from "@babel/types";
|
|
4
2
|
import { Expression } from "@babel/types";
|
|
3
|
+
import { LRUCache } from "lru-cache";
|
|
4
|
+
import { SFCBlock, SFCDescriptor, SFCParseResult, SFCStyleBlock } from "vue/compiler-sfc";
|
|
5
5
|
|
|
6
6
|
//#region src/auto-import-components/builtin.d.ts
|
|
7
7
|
/**
|
|
@@ -45,36 +45,57 @@ declare const WE_VU_RUNTIME_APIS: {
|
|
|
45
45
|
*/
|
|
46
46
|
type WevuRuntimeApiName = (typeof WE_VU_RUNTIME_APIS)[keyof typeof WE_VU_RUNTIME_APIS];
|
|
47
47
|
//#endregion
|
|
48
|
-
//#region src/
|
|
49
|
-
declare const mtimeCache: Map<string, {
|
|
50
|
-
mtimeMs: number;
|
|
51
|
-
size: number;
|
|
52
|
-
}>;
|
|
53
|
-
declare const loadCache: LRUCache<string, string, unknown>;
|
|
48
|
+
//#region src/types/json.d.ts
|
|
54
49
|
/**
|
|
55
|
-
*
|
|
56
|
-
* @param id 文件路径
|
|
57
|
-
* @returns {Promise<boolean>} 当文件需要重新读取时返回 true
|
|
50
|
+
* JSON 合并阶段枚举。
|
|
58
51
|
*/
|
|
59
|
-
|
|
60
|
-
declare function readFile(id: string, options?: {
|
|
61
|
-
checkMtime?: boolean;
|
|
62
|
-
encoding?: BufferEncoding;
|
|
63
|
-
}): Promise<string>;
|
|
52
|
+
type JsonMergeStage = 'defaults' | 'json-block' | 'auto-using-components' | 'component-generics' | 'macro' | 'emit' | 'merge-existing';
|
|
64
53
|
/**
|
|
65
|
-
*
|
|
54
|
+
* JSON 合并上下文。
|
|
66
55
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
interface JsonMergeContext {
|
|
57
|
+
filename?: string;
|
|
58
|
+
kind?: 'app' | 'page' | 'component' | 'unknown';
|
|
59
|
+
stage: JsonMergeStage;
|
|
60
|
+
}
|
|
70
61
|
/**
|
|
71
|
-
*
|
|
62
|
+
* JSON 合并函数。
|
|
72
63
|
*/
|
|
73
|
-
|
|
64
|
+
type JsonMergeFunction = (target: Record<string, any>, source: Record<string, any>, context: JsonMergeContext) => Record<string, any> | void;
|
|
74
65
|
/**
|
|
75
|
-
*
|
|
66
|
+
* JSON 合并策略。
|
|
76
67
|
*/
|
|
77
|
-
|
|
68
|
+
type JsonMergeStrategy = 'deep' | 'assign' | 'replace' | JsonMergeFunction;
|
|
69
|
+
/**
|
|
70
|
+
* JSON 产物配置。
|
|
71
|
+
*/
|
|
72
|
+
interface JsonConfig {
|
|
73
|
+
/**
|
|
74
|
+
* 产物 JSON 默认值(用于 app/page/component)
|
|
75
|
+
*/
|
|
76
|
+
defaults?: {
|
|
77
|
+
app?: Record<string, any>;
|
|
78
|
+
page?: Record<string, any>;
|
|
79
|
+
component?: Record<string, any>;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* JSON 合并策略
|
|
83
|
+
* - `deep`: 深合并(默认)
|
|
84
|
+
* - `assign`: 浅合并(Object.assign)
|
|
85
|
+
* - `replace`: 直接替换
|
|
86
|
+
* - `function`: 自定义合并函数
|
|
87
|
+
*/
|
|
88
|
+
mergeStrategy?: JsonMergeStrategy;
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/types/wevu.d.ts
|
|
92
|
+
/**
|
|
93
|
+
* wevu JSON 默认值配置(app/component)。
|
|
94
|
+
*/
|
|
95
|
+
interface WevuDefaults {
|
|
96
|
+
app?: Record<string, any>;
|
|
97
|
+
component?: Record<string, any>;
|
|
98
|
+
}
|
|
78
99
|
//#endregion
|
|
79
100
|
//#region src/plugins/utils/vueSfc.d.ts
|
|
80
101
|
/**
|
|
@@ -142,30 +163,6 @@ declare function getSfcCheckMtime(config?: {
|
|
|
142
163
|
isDev?: boolean;
|
|
143
164
|
}): boolean;
|
|
144
165
|
//#endregion
|
|
145
|
-
//#region src/plugins/vue/compiler/style.d.ts
|
|
146
|
-
/**
|
|
147
|
-
* 样式编译结果。
|
|
148
|
-
*/
|
|
149
|
-
interface StyleCompileResult {
|
|
150
|
-
code: string;
|
|
151
|
-
map?: string;
|
|
152
|
-
scopedId?: string;
|
|
153
|
-
modules?: Record<string, Record<string, string>>;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* 样式编译选项。
|
|
157
|
-
*/
|
|
158
|
-
interface StyleCompileOptions {
|
|
159
|
-
id: string;
|
|
160
|
-
scoped?: boolean;
|
|
161
|
-
modules?: boolean | string;
|
|
162
|
-
preprocessOptions?: Record<string, any>;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* 将 Vue SFC 的 style 块转换为 WXSS
|
|
166
|
-
*/
|
|
167
|
-
declare function compileVueStyleToWxss(styleBlock: SFCStyleBlock, options: StyleCompileOptions): StyleCompileResult;
|
|
168
|
-
//#endregion
|
|
169
166
|
//#region src/plugins/vue/compiler/template/platform.d.ts
|
|
170
167
|
/**
|
|
171
168
|
* 小程序模板平台适配器定义。
|
|
@@ -252,7 +249,7 @@ type ClassStyleRuntime = 'wxs' | 'js';
|
|
|
252
249
|
*/
|
|
253
250
|
interface ClassStyleBinding {
|
|
254
251
|
name: string;
|
|
255
|
-
type: 'class' | 'style';
|
|
252
|
+
type: 'class' | 'style' | 'bind';
|
|
256
253
|
exp: string;
|
|
257
254
|
expAst?: Expression;
|
|
258
255
|
forStack: ForParseResult[];
|
|
@@ -310,98 +307,6 @@ declare function getMiniProgramTemplatePlatform(platform?: MpPlatform): MiniProg
|
|
|
310
307
|
*/
|
|
311
308
|
declare function compileVueTemplateToWxml(template: string, filename: string, options?: TemplateCompileOptions): TemplateCompileResult;
|
|
312
309
|
//#endregion
|
|
313
|
-
//#region src/plugins/vue/compiler/template/classStyleRuntime.d.ts
|
|
314
|
-
/**
|
|
315
|
-
* class/style WXS 模块名。
|
|
316
|
-
*/
|
|
317
|
-
declare const CLASS_STYLE_WXS_MODULE = "__weapp_vite";
|
|
318
|
-
/**
|
|
319
|
-
* class/style WXS 文件名(不含扩展名)。
|
|
320
|
-
*/
|
|
321
|
-
declare const CLASS_STYLE_WXS_FILE = "__weapp_vite_class_style";
|
|
322
|
-
interface ClassStyleWxsSourceOptions {
|
|
323
|
-
extension?: string;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* 构建 class/style WXS 引用标签。
|
|
327
|
-
*/
|
|
328
|
-
declare function buildClassStyleWxsTag(extension: string, src?: string): string;
|
|
329
|
-
/**
|
|
330
|
-
* 解析 class/style WXS 文件位置与引用路径。
|
|
331
|
-
*/
|
|
332
|
-
declare function resolveClassStyleWxsLocation(options: {
|
|
333
|
-
relativeBase: string;
|
|
334
|
-
extension: string;
|
|
335
|
-
packageRoot?: string;
|
|
336
|
-
}): {
|
|
337
|
-
fileName: string;
|
|
338
|
-
src: string;
|
|
339
|
-
};
|
|
340
|
-
/**
|
|
341
|
-
* 获取内置 class/style WXS 运行时代码。
|
|
342
|
-
*/
|
|
343
|
-
declare function getClassStyleWxsSource(options?: ClassStyleWxsSourceOptions): string;
|
|
344
|
-
//#endregion
|
|
345
|
-
//#region src/plugins/vue/transform/classStyleComputed.d.ts
|
|
346
|
-
interface ClassStyleHelperNames {
|
|
347
|
-
normalizeClassName: string;
|
|
348
|
-
normalizeStyleName: string;
|
|
349
|
-
unrefName?: string;
|
|
350
|
-
}
|
|
351
|
-
declare function buildClassStyleComputedCode(bindings: ClassStyleBinding[], helpers: ClassStyleHelperNames): string | null;
|
|
352
|
-
//#endregion
|
|
353
|
-
//#region src/types/json.d.ts
|
|
354
|
-
/**
|
|
355
|
-
* JSON 合并阶段枚举。
|
|
356
|
-
*/
|
|
357
|
-
type JsonMergeStage = 'defaults' | 'json-block' | 'auto-using-components' | 'component-generics' | 'macro' | 'emit' | 'merge-existing';
|
|
358
|
-
/**
|
|
359
|
-
* JSON 合并上下文。
|
|
360
|
-
*/
|
|
361
|
-
interface JsonMergeContext {
|
|
362
|
-
filename?: string;
|
|
363
|
-
kind?: 'app' | 'page' | 'component' | 'unknown';
|
|
364
|
-
stage: JsonMergeStage;
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* JSON 合并函数。
|
|
368
|
-
*/
|
|
369
|
-
type JsonMergeFunction = (target: Record<string, any>, source: Record<string, any>, context: JsonMergeContext) => Record<string, any> | void;
|
|
370
|
-
/**
|
|
371
|
-
* JSON 合并策略。
|
|
372
|
-
*/
|
|
373
|
-
type JsonMergeStrategy = 'deep' | 'assign' | 'replace' | JsonMergeFunction;
|
|
374
|
-
/**
|
|
375
|
-
* JSON 产物配置。
|
|
376
|
-
*/
|
|
377
|
-
interface JsonConfig {
|
|
378
|
-
/**
|
|
379
|
-
* 产物 JSON 默认值(用于 app/page/component)
|
|
380
|
-
*/
|
|
381
|
-
defaults?: {
|
|
382
|
-
app?: Record<string, any>;
|
|
383
|
-
page?: Record<string, any>;
|
|
384
|
-
component?: Record<string, any>;
|
|
385
|
-
};
|
|
386
|
-
/**
|
|
387
|
-
* JSON 合并策略
|
|
388
|
-
* - `deep`: 深合并(默认)
|
|
389
|
-
* - `assign`: 浅合并(Object.assign)
|
|
390
|
-
* - `replace`: 直接替换
|
|
391
|
-
* - `function`: 自定义合并函数
|
|
392
|
-
*/
|
|
393
|
-
mergeStrategy?: JsonMergeStrategy;
|
|
394
|
-
}
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/types/wevu.d.ts
|
|
397
|
-
/**
|
|
398
|
-
* wevu JSON 默认值配置(app/component)。
|
|
399
|
-
*/
|
|
400
|
-
interface WevuDefaults {
|
|
401
|
-
app?: Record<string, any>;
|
|
402
|
-
component?: Record<string, any>;
|
|
403
|
-
}
|
|
404
|
-
//#endregion
|
|
405
310
|
//#region src/plugins/vue/transform/compileVueFile/types.d.ts
|
|
406
311
|
/**
|
|
407
312
|
* Vue 单文件组件转换结果。
|
|
@@ -465,6 +370,107 @@ interface CompileVueFileOptions {
|
|
|
465
370
|
wevuDefaults?: WevuDefaults;
|
|
466
371
|
}
|
|
467
372
|
//#endregion
|
|
373
|
+
//#region src/plugins/jsx/compileJsxFile.d.ts
|
|
374
|
+
/**
|
|
375
|
+
* 编译 JSX/TSX 文件,输出 wevu 脚本与 WXML 模板。
|
|
376
|
+
*/
|
|
377
|
+
declare function compileJsxFile(source: string, filename: string, options?: CompileVueFileOptions): Promise<VueTransformResult>;
|
|
378
|
+
//#endregion
|
|
379
|
+
//#region src/plugins/utils/cache.d.ts
|
|
380
|
+
declare const mtimeCache: Map<string, {
|
|
381
|
+
mtimeMs: number;
|
|
382
|
+
size: number;
|
|
383
|
+
}>;
|
|
384
|
+
declare const loadCache: LRUCache<string, string, unknown>;
|
|
385
|
+
/**
|
|
386
|
+
* 返回 true 的时候需要重新 fs 读取
|
|
387
|
+
* @param id 文件路径
|
|
388
|
+
* @returns {Promise<boolean>} 当文件需要重新读取时返回 true
|
|
389
|
+
*/
|
|
390
|
+
declare function isInvalidate(id: string): Promise<boolean>;
|
|
391
|
+
declare function readFile(id: string, options?: {
|
|
392
|
+
checkMtime?: boolean;
|
|
393
|
+
encoding?: BufferEncoding;
|
|
394
|
+
}): Promise<string>;
|
|
395
|
+
/**
|
|
396
|
+
* 判断文件或路径是否存在,可选缓存。
|
|
397
|
+
*/
|
|
398
|
+
declare function pathExists(id: string, options?: {
|
|
399
|
+
ttlMs?: number;
|
|
400
|
+
}): Promise<boolean>;
|
|
401
|
+
/**
|
|
402
|
+
* 清理指定文件相关的缓存。
|
|
403
|
+
*/
|
|
404
|
+
declare function invalidateFileCache(id: string): void;
|
|
405
|
+
/**
|
|
406
|
+
* 清空所有文件缓存。
|
|
407
|
+
*/
|
|
408
|
+
declare function clearFileCaches(): void;
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region src/plugins/vue/compiler/style.d.ts
|
|
411
|
+
/**
|
|
412
|
+
* 样式编译结果。
|
|
413
|
+
*/
|
|
414
|
+
interface StyleCompileResult {
|
|
415
|
+
code: string;
|
|
416
|
+
map?: string;
|
|
417
|
+
scopedId?: string;
|
|
418
|
+
modules?: Record<string, Record<string, string>>;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* 样式编译选项。
|
|
422
|
+
*/
|
|
423
|
+
interface StyleCompileOptions {
|
|
424
|
+
id: string;
|
|
425
|
+
scoped?: boolean;
|
|
426
|
+
modules?: boolean | string;
|
|
427
|
+
preprocessOptions?: Record<string, any>;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* 将 Vue SFC 的 style 块转换为 WXSS
|
|
431
|
+
*/
|
|
432
|
+
declare function compileVueStyleToWxss(styleBlock: SFCStyleBlock, options: StyleCompileOptions): StyleCompileResult;
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/plugins/vue/compiler/template/classStyleRuntime.d.ts
|
|
435
|
+
/**
|
|
436
|
+
* class/style WXS 模块名。
|
|
437
|
+
*/
|
|
438
|
+
declare const CLASS_STYLE_WXS_MODULE = "__weapp_vite";
|
|
439
|
+
/**
|
|
440
|
+
* class/style WXS 文件名(不含扩展名)。
|
|
441
|
+
*/
|
|
442
|
+
declare const CLASS_STYLE_WXS_FILE = "__weapp_vite_class_style";
|
|
443
|
+
interface ClassStyleWxsSourceOptions {
|
|
444
|
+
extension?: string;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* 构建 class/style WXS 引用标签。
|
|
448
|
+
*/
|
|
449
|
+
declare function buildClassStyleWxsTag(extension: string, src?: string): string;
|
|
450
|
+
/**
|
|
451
|
+
* 解析 class/style WXS 文件位置与引用路径。
|
|
452
|
+
*/
|
|
453
|
+
declare function resolveClassStyleWxsLocation(options: {
|
|
454
|
+
relativeBase: string;
|
|
455
|
+
extension: string;
|
|
456
|
+
packageRoot?: string;
|
|
457
|
+
}): {
|
|
458
|
+
fileName: string;
|
|
459
|
+
src: string;
|
|
460
|
+
};
|
|
461
|
+
/**
|
|
462
|
+
* 获取内置 class/style WXS 运行时代码。
|
|
463
|
+
*/
|
|
464
|
+
declare function getClassStyleWxsSource(options?: ClassStyleWxsSourceOptions): string;
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/plugins/vue/transform/classStyleComputed.d.ts
|
|
467
|
+
interface ClassStyleHelperNames {
|
|
468
|
+
normalizeClassName: string;
|
|
469
|
+
normalizeStyleName: string;
|
|
470
|
+
unrefName?: string;
|
|
471
|
+
}
|
|
472
|
+
declare function buildClassStyleComputedCode(bindings: ClassStyleBinding[], helpers: ClassStyleHelperNames): string | null;
|
|
473
|
+
//#endregion
|
|
468
474
|
//#region src/plugins/vue/transform/compileVueFile/index.d.ts
|
|
469
475
|
/**
|
|
470
476
|
* 编译 Vue 单文件组件,输出脚本、模板、样式与配置结果。
|
|
@@ -686,4 +692,4 @@ interface CollectVueTemplateTagsOptions {
|
|
|
686
692
|
*/
|
|
687
693
|
declare function collectVueTemplateTags(template: string, options: CollectVueTemplateTagsOptions): Set<string>;
|
|
688
694
|
//#endregion
|
|
689
|
-
export { type AutoImportTagsOptions, type AutoUsingComponentsOptions, CLASS_STYLE_WXS_FILE, CLASS_STYLE_WXS_MODULE, type ClassStyleBinding, type ClassStyleRuntime, type CollectVueTemplateTagsOptions, type CompileVueFileOptions, type ForParseResult, type InlineExpressionAsset, type JsLikeLang, type JsonConfig, type JsonMergeContext, type JsonMergeStage, type JsonMergeStrategy, type MiniProgramPlatform, type ModuleResolver, type MpPlatform, RESERVED_VUE_COMPONENT_TAGS, type ReadAndParseSfcOptions, type ResolveSfcBlockSrcOptions, type ScopedSlotComponentAsset, type StyleCompileOptions, type StyleCompileResult, type TemplateCompileOptions, type TemplateCompileResult, type TemplateRefBinding, type TransformResult, type TransformScriptOptions, VUE_COMPONENT_TAG_RE, type VueTransformResult, WE_VU_MODULE_ID, WE_VU_PAGE_HOOK_TO_FEATURE, WE_VU_RUNTIME_APIS, type WevuDefaults, type WevuPageFeatureFlag, type WevuPageHookName, WevuRuntimeApiName, alipayPlatform, buildClassStyleComputedCode, buildClassStyleWxsTag, builtinComponentsSet, clearFileCaches, collectVueTemplateTags, collectWevuPageFeatureFlags, compileConfigBlocks, compileVueFile as compileSfc, compileVueFile, compileVueStyleToWxss as compileStyle, compileVueStyleToWxss, compileVueTemplateToWxml as compileTemplate, compileVueTemplateToWxml, createJsonMerger, createPageEntryMatcher, evaluateJsLikeConfig, extractJsonMacroFromScriptSetup, generateScopedId, getClassStyleWxsSource, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeatureFlagsIntoOptionsObject, injectWevuPageFeaturesInJs, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, isInvalidate, isJsonLikeLang, loadCache, mergeJsonWithStrategy, mtimeCache, normalizeConfigLang, pathExists, preprocessScriptSetupSrc, preprocessScriptSrc, readAndParseSfc, readFile, resolveClassStyleWxsLocation, resolveJsLikeLang, resolveSfcBlockSrc, restoreScriptSetupSrc, restoreScriptSrc, stripJsonMacroCallsFromCode, swanPlatform, transformScript, transformScript as transformSfcScript, ttPlatform, wechatPlatform };
|
|
695
|
+
export { type AutoImportTagsOptions, type AutoUsingComponentsOptions, CLASS_STYLE_WXS_FILE, CLASS_STYLE_WXS_MODULE, type ClassStyleBinding, type ClassStyleRuntime, type CollectVueTemplateTagsOptions, type CompileVueFileOptions, type ForParseResult, type InlineExpressionAsset, type JsLikeLang, type JsonConfig, type JsonMergeContext, type JsonMergeStage, type JsonMergeStrategy, type MiniProgramPlatform, type ModuleResolver, type MpPlatform, RESERVED_VUE_COMPONENT_TAGS, type ReadAndParseSfcOptions, type ResolveSfcBlockSrcOptions, type ScopedSlotComponentAsset, type StyleCompileOptions, type StyleCompileResult, type TemplateCompileOptions, type TemplateCompileResult, type TemplateRefBinding, type TransformResult, type TransformScriptOptions, VUE_COMPONENT_TAG_RE, type VueTransformResult, WE_VU_MODULE_ID, WE_VU_PAGE_HOOK_TO_FEATURE, WE_VU_RUNTIME_APIS, type WevuDefaults, type WevuPageFeatureFlag, type WevuPageHookName, WevuRuntimeApiName, alipayPlatform, buildClassStyleComputedCode, buildClassStyleWxsTag, builtinComponentsSet, clearFileCaches, collectVueTemplateTags, collectWevuPageFeatureFlags, compileConfigBlocks, compileJsxFile, compileVueFile as compileSfc, compileVueFile, compileVueStyleToWxss as compileStyle, compileVueStyleToWxss, compileVueTemplateToWxml as compileTemplate, compileVueTemplateToWxml, createJsonMerger, createPageEntryMatcher, evaluateJsLikeConfig, extractJsonMacroFromScriptSetup, generateScopedId, getClassStyleWxsSource, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeatureFlagsIntoOptionsObject, injectWevuPageFeaturesInJs, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, isInvalidate, isJsonLikeLang, loadCache, mergeJsonWithStrategy, mtimeCache, normalizeConfigLang, pathExists, preprocessScriptSetupSrc, preprocessScriptSrc, readAndParseSfc, readFile, resolveClassStyleWxsLocation, resolveJsLikeLang, resolveSfcBlockSrc, restoreScriptSetupSrc, restoreScriptSrc, stripJsonMacroCallsFromCode, swanPlatform, transformScript, transformScript as transformSfcScript, ttPlatform, wechatPlatform };
|