@compelem/compiler 0.30.0-beta.4 → 0.30.0-beta.6
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.ts +75 -1
- package/dist/index.js +2 -2
- package/dist/{vite-CY_6E-Ut.js → vite-C95uwtJI.js} +459 -134
- package/dist/vite-C95uwtJI.js.map +1 -0
- package/dist/vite.js +1 -1
- package/package.json +1 -1
- package/dist/vite-CY_6E-Ut.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -113,6 +113,13 @@ interface StaticLiteralCodes {
|
|
|
113
113
|
states?: string;
|
|
114
114
|
/** `__ce_static__.computedGetters` 字面量值(@computed 前移,原 getter 体外提) */
|
|
115
115
|
computedGetters?: string;
|
|
116
|
+
/**
|
|
117
|
+
* `__ce_static__.resources` 字面量值(@resource 前移)。
|
|
118
|
+
*
|
|
119
|
+
* 只放纯数据选项(timeout/immediate/track + source 的布尔标记);
|
|
120
|
+
* loader 与 source 函数搬成类上的 `__rl_<name>` / `__rs_<name>` 私有方法。
|
|
121
|
+
*/
|
|
122
|
+
resources?: string;
|
|
116
123
|
/** 类体访问器源码(prop/state/computed 的 get/set + `@tag` 类的 observedAttributes),
|
|
117
124
|
* 接在 static 字面量之后注入。无 `@tag` 的类不带 observedAttributes —— 它们永不被
|
|
118
125
|
* `customElements.define`,浏览器不会读它们的表。 */
|
|
@@ -273,6 +280,73 @@ interface VarMapEntry {
|
|
|
273
280
|
declare function defaultInclude(id: string, code: string): boolean;
|
|
274
281
|
/** 编译单个文件。解析失败时原样返回;静态分析/模板 codegen 失败会抛 StaticAnalysisError。 */
|
|
275
282
|
declare function compileFile(code: string, id: string, options?: CompilerOptions): CompileResult;
|
|
283
|
+
/**
|
|
284
|
+
* 编译**已确定要编译**的源码,跳过 `include` 判定。
|
|
285
|
+
*
|
|
286
|
+
* 与 {@link compileFile} 的分工:
|
|
287
|
+
* - `compileFile` 面向「磁盘上可能是组件、也可能不是」的输入,先按扩展名 +
|
|
288
|
+
* 特征做 include 判定;
|
|
289
|
+
* - `compileSource` 面向「调用方已经决定要编译」的输入 —— 典型是 SFC 插件把
|
|
290
|
+
* `.ce` 分段拼成的虚拟 TypeScript 模块。虚拟模块的 id 仍是 `.ce`(为了
|
|
291
|
+
* sourcemap 指向真实文件),天然过不了 `defaultInclude` 的扩展名检查,
|
|
292
|
+
* 以前只能传 `include: () => true` 绕过整个判定(连 node_modules 排除也一起绕过)。
|
|
293
|
+
*
|
|
294
|
+
* `options.include` 在这里被忽略。
|
|
295
|
+
*/
|
|
296
|
+
declare function compileSource(code: string, id: string, options?: CompilerOptions): CompileResult;
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/diagnostics.d.ts
|
|
299
|
+
/** 约定违规的处理力度:error 阻断构建 / warn 控制台提示 / silent 忽略。 */
|
|
300
|
+
type ConventionMode = 'error' | 'warn' | 'silent';
|
|
301
|
+
/** 已格式化为 `文件:行:列 [类名] 消息` 的两组诊断文本。 */
|
|
302
|
+
interface CollectedDiagnostics {
|
|
303
|
+
errs: string[];
|
|
304
|
+
warns: string[];
|
|
305
|
+
}
|
|
306
|
+
/** 惰性构建换行偏移索引(升序;仅在有诊断时付费一次)。 */
|
|
307
|
+
declare function newlineIndex(code: string): Int32Array;
|
|
308
|
+
/** 把源码偏移换算成 `行:列`(1 起算);带换行索引时走二分(O(log n))。 */
|
|
309
|
+
declare function offsetToLineCol(code: string, offset: number, nl?: Int32Array): string;
|
|
310
|
+
/** 相对 root 的展示路径(统一正斜杠,便于点击跳转)。 */
|
|
311
|
+
declare function relativeToRoot(id: string, root: string): string;
|
|
312
|
+
/**
|
|
313
|
+
* 从 diagnostics 收集**约定诊断**为可上报文本,按 severity 分为 errs(E-*)与 warns(W-*)。
|
|
314
|
+
*
|
|
315
|
+
* `root` 只用于把绝对路径压成相对路径,不影响判定。
|
|
316
|
+
*/
|
|
317
|
+
declare function collectDiagnostics(res: CompileResult, code: string, id: string, root: string): CollectedDiagnostics;
|
|
318
|
+
/**
|
|
319
|
+
* 按 mode 上报违规:error 走插件上下文的 `this.error`(阻断构建),warn 走控制台。
|
|
320
|
+
*
|
|
321
|
+
* `thisArg` 是 Rollup/Vite 的插件上下文;纯 API 调用时传 undefined 也能工作
|
|
322
|
+
* (退化为 `throw`)。
|
|
323
|
+
*/
|
|
324
|
+
declare function reportDiagnostics(msgs: string[], mode: ConventionMode, head: string, thisArg: any): void;
|
|
325
|
+
/**
|
|
326
|
+
* 一站式上报:W 码恒为控制台提示(不随档位阻断),E 码按 mode 处理。
|
|
327
|
+
*
|
|
328
|
+
* 返回是否发生了阻断(仅用于调用方决定是否继续)。
|
|
329
|
+
*/
|
|
330
|
+
declare function reportConventionDiagnostics(collected: CollectedDiagnostics, mode: ConventionMode, thisArg: any, tag?: string): void;
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region src/tag-registry.d.ts
|
|
333
|
+
/** `@tag('x-foo')` / `@tag(\`x-foo\`)`;一次扫描内复用,调用方负责重置 lastIndex。 */
|
|
334
|
+
declare const TAG_RE: RegExp;
|
|
335
|
+
/** 默认只把 `.ts` / `.tsx` 当作组件来源。 */
|
|
336
|
+
declare const DEFAULT_TAG_EXT: RegExp;
|
|
337
|
+
interface ScanKnownTagsOptions {
|
|
338
|
+
/** 参与扫描的文件扩展名正则,默认 {@link DEFAULT_TAG_EXT}。 */
|
|
339
|
+
extensions?: RegExp;
|
|
340
|
+
/** 目录递归深度上限,默认 20。 */
|
|
341
|
+
maxDepth?: number;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* 递归收集 root 下匹配 `extensions` 的文件里的 `@tag` 名,写入 `out`。
|
|
345
|
+
*
|
|
346
|
+
* 读失败的文件直接跳过:注册表是 best-effort 的,它只会**放宽**校验,
|
|
347
|
+
* 不该让一次权限错误打断构建。`node_modules` 等目录不参与扫描。
|
|
348
|
+
*/
|
|
349
|
+
declare function scanKnownTags(root: string, out: Set<string>, options?: ScanKnownTagsOptions): void;
|
|
276
350
|
//#endregion
|
|
277
|
-
export { type CompileResult, type CompiledStatic, type CompilerOptions, type ComponentAnalysis, DEBUG_DIV, type DepSummary, type ReactiveField, type ReactiveKind, type RenderAnalysis, StaticAnalysisError, type VitePluginOptions, analyzeFile, analyzeRender, assertStaticAnalysis, buildStaticLiteral, collectCompelemImports, compelemCompiler, compileFile, defaultInclude, injectInto, inlineTemplateMethods, isCompelemSource, parse };
|
|
351
|
+
export { type CollectedDiagnostics, type CompileResult, type CompiledStatic, type CompilerOptions, type ComponentAnalysis, type ConventionMode, DEBUG_DIV, DEFAULT_TAG_EXT, type DepSummary, type ReactiveField, type ReactiveKind, type RenderAnalysis, type ScanKnownTagsOptions, StaticAnalysisError, TAG_RE, type VitePluginOptions, analyzeFile, analyzeRender, assertStaticAnalysis, buildStaticLiteral, collectCompelemImports, collectDiagnostics, compelemCompiler, compileFile, compileSource, defaultInclude, injectInto, inlineTemplateMethods, isCompelemSource, newlineIndex, offsetToLineCol, parse, relativeToRoot, reportConventionDiagnostics, reportDiagnostics, scanKnownTags };
|
|
278
352
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { C as collectCompelemImports, S as analyzeFile, T as parse, _ as DEBUG_DIV, a as scanKnownTags, b as inlineTemplateMethods, c as offsetToLineCol, d as reportDiagnostics, f as compileFile, g as injectInto, h as buildStaticLiteral, i as TAG_RE, l as relativeToRoot, m as defaultInclude, o as collectDiagnostics, p as compileSource, r as DEFAULT_TAG_EXT, s as newlineIndex, t as compelemCompiler, u as reportConventionDiagnostics, v as StaticAnalysisError, w as isCompelemSource, x as analyzeRender, y as assertStaticAnalysis } from "./vite-C95uwtJI.js";
|
|
2
2
|
|
|
3
|
-
export { DEBUG_DIV, StaticAnalysisError, analyzeFile, analyzeRender, assertStaticAnalysis, buildStaticLiteral, collectCompelemImports, compelemCompiler, compileFile, defaultInclude, injectInto, inlineTemplateMethods, isCompelemSource, parse };
|
|
3
|
+
export { DEBUG_DIV, DEFAULT_TAG_EXT, StaticAnalysisError, TAG_RE, analyzeFile, analyzeRender, assertStaticAnalysis, buildStaticLiteral, collectCompelemImports, collectDiagnostics, compelemCompiler, compileFile, compileSource, defaultInclude, injectInto, inlineTemplateMethods, isCompelemSource, newlineIndex, offsetToLineCol, parse, relativeToRoot, reportConventionDiagnostics, reportDiagnostics, scanKnownTags };
|