@weapp-vite/language-service 0.0.0-stage → 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ice breaker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,62 @@
1
- # Temporary Holding Version
1
+ # @weapp-vite/language-service
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ CLI、编辑器、Oxlint 项目检查和 Oxfmt 适配层共用的小程序语言内核。模板分析和标签格式化使用 TypeScript;脚本分析复用仓库 AST 设施,脚本格式化通过调用方注入格式器。不会执行用户脚本或远程文档脚本。
4
+
5
+ ## 平台与范围
6
+
7
+ | 平台 | 模板 | 原生样式 | 脚本模块 |
8
+ | --- | --- | --- | --- |
9
+ | 微信 | `.wxml` | `.wxss` | `.wxs` |
10
+ | 支付宝 | `.axml` | `.acss` | `.sjs` |
11
+ | 百度 | `.swan` | `.css` | `.sjs`、`.filter.js` |
12
+ | 抖音 | `.ttml` | `.ttss` | `.sjs` |
13
+ | 京东 | `.jxml` | `.jxss` | `.wxs` |
14
+ | 小红书 | `.xhsml` | `.css` | `.wxs` |
15
+ | QQ | `.qml` | `.qss` | `.wxs` |
16
+ | 快手 | `.ksml` | `.css` | `.ks` |
17
+ | 涂鸦 | `.tyml` | `.tyss` | `.sjs` |
18
+
19
+ 实际后缀以 `languageProfiles` 为准。QQ、快手、涂鸦属于语言支持,不会扩展构建目标。脚本支持相应的 `.js`、`.ts` 编译源码后缀;百度 Filter 的编译源码是 `.filter.ts`。共享 `.sjs`、`.wxs` 和 `.css` 无法仅凭后缀确定平台,需要项目配置、文件覆盖规则或模板引用归属。
20
+
21
+ `getLanguageSupportMatrix()` 返回平台、后缀、组件快照状态及案例 ID;`languageSupportCases` 将 ID 映射到仓库内可执行测试文件与 suite。固定种子 `0x5eed2026` 在每个平台执行 128 组模板组合,断言受保护片段逐字保留、格式化幂等、无效输入拒绝修改。覆盖结论限定于登记的静态语言契约;宿主渲染和运行时结果由对应平台的集成测试证明。
22
+
23
+ ## 使用
24
+
25
+ ```ts
26
+ import {
27
+ analyzeDocument,
28
+ formatTemplateResult,
29
+ getLanguageFileAssociations,
30
+ } from '@weapp-vite/language-service'
31
+
32
+ const result = analyzeDocument({
33
+ fileName: 'pages/index.axml',
34
+ source: '<view a:if="{{visible}}"> 保留文本 </view>',
35
+ })
36
+
37
+ const formatted = formatTemplateResult('<view class="page"/>', 'page.wxml')
38
+ // edits 使用原始文档的 UTF-16 [start, end) 范围,按源码顺序排列。
39
+ // 无效输入返回原文、空 edits 和结构化 diagnostics。
40
+ const associations = getLanguageFileAssociations()
41
+ ```
42
+
43
+ `formatTemplate` 保留返回字符串、错误时抛出 `LanguageError` 的便捷接口。模板格式化只修改标签布局;文本、属性值、引号、属性顺序、重复属性、插值、注释、CDATA、声明与脚本正文均保留源码片段。未知组件和自定义属性不会因为缺少组件表条目而被拒绝。
44
+
45
+ 原生 WXS、各平台 SJS、快手 KS 和百度 Filter 使用各自已核实的脚本约束;显式 `lang="ts"`、`lang="js"` 由编译源码路径处理。`getTemplateScriptInput` 统一内联脚本的虚拟文件名、方言、语言与来源类型,避免分析器、编辑器和格式器各自推断。
46
+
47
+ 脚本分析的 `imports` 和 `externalUses` 提供静态 ESM default/named/namespace、CommonJS require 别名与解构、静态成员、转导出及原始 UTF-16 范围。分析尊重词法遮蔽,排除动态 require、动态属性、已重赋值绑定和纯类型引用。重命名元数据分别描述公共导入名与本地绑定,保留已有别名及 shorthand 的含义;编辑器直接消费这些事实,不再重新解析脚本。
48
+
49
+ `exportScope` / `targetScope` 区分 named、default 对象成员、CommonJS 和 default 本身,同名公开成员不会被合并。CommonJS 使用点通过 `targetPath` 保留完整静态属性路径。`getScriptTemplateExports` 将编译目标的公开路径关联到源码符号;尚未核实的宿主混合导出返回 `ambiguous`,保留源码并停止不确定的跨文件重命名。
50
+
51
+ ## 组件数据
52
+
53
+ 九个平台各自拥有离线组件快照,记录来源、快照日期和内容 SHA-256。微信、支付宝、抖音复用仓库已有平台专属目录;其原始抓取日期未知时明确保留 `upstreamRetrievedAt: null`。其他平台从各自官方文档同步,不回退为微信组件表。涂鸦使用官方 SchemaDoc JSON,京东使用当前公开文档客户端声明的接口;频道元数据只在同步进程内存中使用。
54
+
55
+ ```sh
56
+ pnpm --filter @weapp-vite/language-service generate:schema
57
+ pnpm --filter @weapp-vite/language-service sync:schema swan
58
+ pnpm --filter @weapp-vite/language-service sync:schema jd
59
+ pnpm --filter @weapp-vite/language-service sync:schema ks --cache-dir <临时目录>
60
+ ```
61
+
62
+ 网络失败会中止本轮资产写入;限流时可以显式使用临时缓存断点续行。网络需要代理的 Node.js 24 环境可以启用 `NODE_USE_ENV_PROXY=1`。共享配置、编辑器关联和项目引用归属统一由公开的 profiles 与 `./project` API 提供。
@@ -0,0 +1,414 @@
1
+ type LanguagePlatform = 'weapp' | 'alipay' | 'tt' | 'swan' | 'jd' | 'xhs' | 'qq' | 'ks' | 'ty';
2
+ interface SourceRange {
3
+ start: number;
4
+ end: number;
5
+ }
6
+ interface SourceEdit extends SourceRange {
7
+ newText: string;
8
+ }
9
+ interface Diagnostic extends SourceRange {
10
+ code: string;
11
+ message: string;
12
+ severity: 'error' | 'warning' | 'info';
13
+ }
14
+ interface LanguageOptions {
15
+ platform?: LanguagePlatform;
16
+ defaultPlatform?: LanguagePlatform;
17
+ overrides?: {
18
+ files: string[];
19
+ platform: LanguagePlatform;
20
+ }[];
21
+ }
22
+ interface DocumentInput {
23
+ source: string;
24
+ fileName: string;
25
+ platform?: LanguagePlatform;
26
+ options?: LanguageOptions;
27
+ sourceKind?: 'native' | 'compiled';
28
+ dialect?: 'wxs' | 'sjs' | 'ks' | 'javascript';
29
+ language?: 'javascript' | 'typescript';
30
+ }
31
+ /** 语言错误保留结构化诊断,调用方可安全地拒绝全部写入。 */
32
+ declare class LanguageError extends Error {
33
+ diagnostics: Diagnostic[];
34
+ constructor(fileName: string, diagnostics: Diagnostic[]);
35
+ }
36
+ type ScriptSourceKind = 'native' | 'compiled';
37
+ type ScriptDialect = 'wxs' | 'sjs' | 'ks' | 'javascript';
38
+ type ScriptExportScope = 'named' | 'default-member' | 'commonjs' | 'default';
39
+ interface ScriptOptions {
40
+ platform?: LanguagePlatform;
41
+ sourceKind?: ScriptSourceKind;
42
+ dialect?: ScriptDialect;
43
+ language?: 'javascript' | 'typescript';
44
+ }
45
+ interface ScriptInput extends DocumentInput {
46
+ sourceKind?: ScriptSourceKind;
47
+ dialect?: ScriptDialect;
48
+ language?: 'javascript' | 'typescript';
49
+ }
50
+ interface ScriptAnalysis {
51
+ diagnostics: Diagnostic[];
52
+ valid: boolean;
53
+ dialect: ScriptDialect;
54
+ sourceKind: ScriptSourceKind;
55
+ references: ScriptReference[];
56
+ symbols: ScriptSymbol[];
57
+ imports: ScriptImportBinding[];
58
+ externalUses: ScriptExternalUse[];
59
+ }
60
+ interface ScriptImportRename {
61
+ kind: 'import-shorthand' | 'property-shorthand' | 'name';
62
+ localName?: string;
63
+ }
64
+ interface ScriptImportBinding extends SourceRange {
65
+ source: string;
66
+ imported: string;
67
+ localName: string;
68
+ kind: 'default' | 'named' | 'namespace' | 'require';
69
+ targetScope: ScriptExportScope;
70
+ targetPath?: string[];
71
+ importedRange?: SourceRange;
72
+ rename?: ScriptImportRename;
73
+ }
74
+ interface ScriptExternalUse extends SourceRange {
75
+ source: string;
76
+ imported: string;
77
+ localName?: string;
78
+ declaration?: SourceRange;
79
+ kind: 'binding' | 'member' | 'reexport';
80
+ targetScope: ScriptExportScope;
81
+ targetPath?: string[];
82
+ rename?: ScriptImportRename;
83
+ }
84
+ interface ScriptReference extends SourceRange {
85
+ source: string;
86
+ kind: 'import' | 'require' | 'export';
87
+ }
88
+ interface ScriptSymbol extends SourceRange {
89
+ name: string;
90
+ kind: 'declaration' | 'reference' | 'export';
91
+ exportScope?: ScriptExportScope;
92
+ declaration?: SourceRange;
93
+ rename?: {
94
+ kind: 'property-shorthand' | 'export-shorthand' | 'import-shorthand' | 'binding' | 'name';
95
+ localName?: string;
96
+ };
97
+ }
98
+ interface ScriptFormatResult {
99
+ code: string;
100
+ diagnostics: Diagnostic[];
101
+ changed: boolean;
102
+ }
103
+ interface ScriptFormatterResult {
104
+ code: string;
105
+ errors?: ReadonlyArray<{
106
+ message: string;
107
+ }>;
108
+ }
109
+ interface ScriptFormatterOptions {
110
+ trailingComma?: 'none';
111
+ embeddedLanguageFormatting: 'off';
112
+ }
113
+ interface FormatScriptOptions extends ScriptOptions {
114
+ format: (fileName: string, source: string, options: ScriptFormatterOptions) => ScriptFormatterResult | Promise<ScriptFormatterResult>;
115
+ }
116
+ interface TemplateAttribute extends SourceRange {
117
+ name: string;
118
+ nameStart: number;
119
+ nameEnd: number;
120
+ value?: string;
121
+ valueStart?: number;
122
+ valueEnd?: number;
123
+ rawValue?: string;
124
+ }
125
+ interface TemplateTag extends SourceRange {
126
+ kind: 'tag';
127
+ name: string;
128
+ nameStart: number;
129
+ nameEnd: number;
130
+ closing: boolean;
131
+ selfClosing: boolean;
132
+ attributes: TemplateAttribute[];
133
+ matching?: number;
134
+ parent?: number;
135
+ }
136
+ interface TemplateRaw extends SourceRange {
137
+ kind: 'text' | 'comment' | 'cdata' | 'declaration' | 'script';
138
+ tagName?: string;
139
+ }
140
+ type TemplateToken = TemplateTag | TemplateRaw;
141
+ interface TemplateReference extends SourceRange {
142
+ kind: 'template-import' | 'template-include' | 'template-name' | 'template-use' | 'script-module' | 'script-import' | 'event';
143
+ name: string;
144
+ source?: string;
145
+ tagName?: string;
146
+ sourceKind?: 'native' | 'compiled';
147
+ language?: 'javascript' | 'typescript';
148
+ }
149
+ interface TemplateBinding extends SourceRange {
150
+ name: string;
151
+ kind: 'item' | 'index';
152
+ collection: SourceRange & {
153
+ source: string;
154
+ };
155
+ }
156
+ interface TemplateScope extends SourceRange {
157
+ bindings: TemplateBinding[];
158
+ }
159
+ interface TemplateScript extends SourceRange {
160
+ tagName: string;
161
+ source: string;
162
+ sourceKind: 'native' | 'compiled';
163
+ language?: 'javascript' | 'typescript';
164
+ moduleName?: string;
165
+ }
166
+ interface TemplateExpression extends SourceRange {
167
+ fullStart: number;
168
+ fullEnd: number;
169
+ source: string;
170
+ }
171
+ interface TemplateAnalysis {
172
+ platform?: LanguagePlatform;
173
+ valid: boolean;
174
+ diagnostics: Diagnostic[];
175
+ tokens: TemplateToken[];
176
+ elements: TemplateTag[];
177
+ scopes: TemplateScope[];
178
+ references: TemplateReference[];
179
+ scripts: TemplateScript[];
180
+ expressions: TemplateExpression[];
181
+ }
182
+ interface TemplateFormatOptions extends LanguageOptions {
183
+ indent?: string;
184
+ printWidth?: number;
185
+ wrapAttributes?: number;
186
+ tabWidth?: number;
187
+ useTabs?: boolean;
188
+ singleAttributePerLine?: boolean;
189
+ bracketSameLine?: boolean;
190
+ endOfLine?: 'lf' | 'crlf' | 'cr' | 'auto';
191
+ }
192
+ interface TemplateFormatResult {
193
+ code: string;
194
+ changed: boolean;
195
+ edits: SourceEdit[];
196
+ diagnostics: Diagnostic[];
197
+ }
198
+ /** 为编辑器提供词法准确的表达式区间;不完整文档只返回已安全读取的范围。 */
199
+ declare function getTemplateExpressions(source: string): TemplateExpression[];
200
+ /** 编辑范围引用原始文档 UTF-16 偏移;无效输入只返回原文及诊断,编辑列表为空。 */
201
+ declare function formatTemplateResult(source: string, fileName?: string, options?: TemplateFormatOptions): TemplateFormatResult;
202
+ /** 仅修改标签布局;文本、插值、属性值和内联脚本逐字保留,失败时不返回可写结果。 */
203
+ declare function formatTemplate(source: string, fileName?: string, options?: TemplateFormatOptions): string;
204
+ /** 分析器、格式器和编辑器共同使用内联脚本身份,避免普通脚本误套 SJS 方言。 */
205
+ declare function getTemplateScriptInput(fileName: string, script: TemplateScript, platform?: LanguagePlatform): DocumentInput;
206
+ /** 生成保留全部源码范围的模板词法结果;错误不自动恢复为可写结果。 */
207
+ declare function scanTemplate(source: string): {
208
+ tokens: TemplateToken[];
209
+ diagnostics: Diagnostic[];
210
+ };
211
+ /** 分析模板结构与平台作用域,不执行脚本、不加载项目配置。 */
212
+ declare function analyzeTemplate(input: DocumentInput): TemplateAnalysis;
213
+ interface TemplateDirectives {
214
+ if: string;
215
+ elif: string;
216
+ else: string;
217
+ for: string;
218
+ forItem: string;
219
+ forIndex: string;
220
+ key: string;
221
+ }
222
+ interface LanguageProfile {
223
+ platform: LanguagePlatform;
224
+ support: 'core' | 'language-only';
225
+ templateExtensions: readonly string[];
226
+ styleExtensions: readonly string[];
227
+ scriptExtensions: readonly string[];
228
+ scriptModule: {
229
+ tag: string;
230
+ sourceAttribute: string;
231
+ moduleAttribute: string;
232
+ };
233
+ directives: TemplateDirectives;
234
+ events: {
235
+ style: 'alipay' | 'bind';
236
+ };
237
+ rawTags: readonly string[];
238
+ documentation: {
239
+ url: string;
240
+ version: 'unversioned';
241
+ retrievedAt: string;
242
+ }[];
243
+ }
244
+ /** 语言能力登记不扩展构建平台;官方文档无统一版本号时明确标记未版本化。 */
245
+ declare const languageProfiles: readonly LanguageProfile[];
246
+ declare const TEMPLATE_EXTENSIONS: string[];
247
+ declare const STYLE_EXTENSIONS: string[];
248
+ declare const SCRIPT_EXTENSIONS: string[];
249
+ declare const FILTER_EXTENSIONS: string[];
250
+ /** 同时识别原生脚本模块及需要先编译的 TypeScript/JavaScript 模块源码。 */
251
+ declare function isScriptModuleFile(fileName: string): boolean;
252
+ /** 获取语言方言,不把语言专用项目扩展为编译目标。 */
253
+ declare function getLanguageProfile(platform: LanguagePlatform): LanguageProfile;
254
+ /** 使用后匹配 glob、显式平台、唯一后缀和项目默认平台依次解析方言。 */
255
+ declare function resolveLanguageProfile(fileName: string, options?: LanguageOptions): LanguageProfile | undefined;
256
+ /** 所有原生样式扩展共用 CSS 语法;预处理器后缀不会被强制改为 CSS。 */
257
+ declare function getNativeStyleExtensions(): string[];
258
+ /** 返回项目收集器和编辑器共同使用的模板后缀。 */
259
+ declare function getTemplateExtensions(): string[];
260
+ /** 返回编辑器与脚手架共用的关联;提供全新对象,避免调用方互相修改。 */
261
+ declare function getLanguageFileAssociations(): Record<string, string>;
262
+ /** 返回循环属性名称,供提示、作用域分析及跳转共同使用。 */
263
+ declare function getTemplateLoopAttributes(platform?: LanguagePlatform): {
264
+ for: string;
265
+ forItem: string;
266
+ forIndex: string;
267
+ key: string;
268
+ };
269
+ /** 按当前平台识别事件属性,保留支付宝事件名的大小写约定。 */
270
+ declare function isEventAttribute(name: string, profileOrPlatform?: LanguageProfile | LanguagePlatform): boolean;
271
+ interface ComponentAttribute {
272
+ name: string;
273
+ type?: {
274
+ name: string;
275
+ };
276
+ desc?: string[];
277
+ enum?: {
278
+ value: string;
279
+ desc?: string[];
280
+ }[];
281
+ defaultValue?: string;
282
+ since?: string;
283
+ subAttrs?: {
284
+ equal: string;
285
+ attrs?: ComponentAttribute[];
286
+ }[];
287
+ }
288
+ interface ComponentEntry {
289
+ name: string;
290
+ docLink: string;
291
+ desc?: string[];
292
+ attrs: ComponentAttribute[];
293
+ }
294
+ interface ComponentSchema {
295
+ platform: LanguagePlatform;
296
+ availability: 'snapshot' | 'unavailable';
297
+ version: string;
298
+ source: string;
299
+ snapshotDate: string;
300
+ upstreamRetrievedAt: string | null;
301
+ reason?: string;
302
+ components: ComponentEntry[];
303
+ }
304
+ /** 返回平台自己的离线组件数据;缺少来源时明确返回不可用,绝不回退为微信组件表。 */
305
+ declare function getComponentSchema(platform: LanguagePlatform): ComponentSchema;
306
+ /** 查询指定平台已登记的组件名,不把未知组件作为错误。 */
307
+ declare function getComponentNames(platform: LanguagePlatform): string[];
308
+ /** 查询组件属性与枚举,供离线补全及悬浮说明使用。 */
309
+ declare function getComponentAttributes(platform: LanguagePlatform, tagName: string): ComponentAttribute[];
310
+ declare function analyzeScript(input: ScriptInput): ScriptAnalysis;
311
+ declare function analyzeScript(source: string, fileName: string, options?: ScriptOptions): ScriptAnalysis;
312
+ /** 通过注入的格式化器处理脚本;校验失败时保留原文并返回可定位诊断。 */
313
+ declare function formatScript(source: string, fileName: string, options: FormatScriptOptions): Promise<ScriptFormatResult>;
314
+ /** 在脚本词法状态中查找真正的结束标签,跳过字符串、模板、正则和完整注释。 */
315
+ declare function findScriptClosingTag(source: string, start: number, tagName: string): SourceRange | undefined;
316
+ /** WXS 允许未带结束符的结尾块注释;仅在词法分析确认后交给解析兼容层。 */
317
+ declare function findTrailingScriptComment(source: string): number | undefined;
318
+ interface ScriptTemplateExport {
319
+ path: string[];
320
+ targetScope: ScriptExportScope;
321
+ symbol: ScriptSymbol;
322
+ }
323
+ interface ScriptTemplateExports {
324
+ exports: ScriptTemplateExport[];
325
+ ambiguous: boolean;
326
+ reason?: string;
327
+ }
328
+ /** 模板模块映射只采用已明确的导出契约;未知宿主的混合导出拒绝猜选同名符号。 */
329
+ declare function getScriptTemplateExports(analysis: ScriptAnalysis, options?: ScriptOptions): ScriptTemplateExports;
330
+ /** 案例 ID 指向可执行的回归入口;覆盖结论限定于这些语言契约。 */
331
+ declare const languageSupportCases: readonly [{
332
+ readonly id: "template-platform-contract";
333
+ readonly scenario: "平台指令、循环作用域、事件及无损幂等格式";
334
+ readonly test: "packages/language-service/src/template/index.test.ts";
335
+ readonly suite: "platform template contracts";
336
+ }, {
337
+ readonly id: "template-protected-source";
338
+ readonly scenario: "文本空白、插值、脚本、注释、CDATA、实体及换行保护";
339
+ readonly test: "packages/language-service/src/template/index.test.ts";
340
+ readonly suite: "lossless layout";
341
+ }, {
342
+ readonly id: "template-invalid-source";
343
+ readonly scenario: "词法、表达式、条件链、重复指令、绑定及原生模块诊断";
344
+ readonly test: "packages/language-service/src/template/index.test.ts";
345
+ readonly suite: "strict rejection";
346
+ }, {
347
+ readonly id: "template-seeded-combinations";
348
+ readonly scenario: "固定种子 0x5eed2026,每平台 128 组组合;逐字保护、幂等及无效输入拒写";
349
+ readonly test: "packages/language-service/src/template/combinations.test.ts";
350
+ readonly suite: "seeded lossless template combinations";
351
+ }, {
352
+ readonly id: "script-platform-contract";
353
+ readonly scenario: "平台脚本语法、运行时边界、引用及符号";
354
+ readonly test: "packages/language-service/src/script.test.ts";
355
+ readonly suite: "platform script diagnostics";
356
+ }, {
357
+ readonly id: "script-dialect-contract";
358
+ readonly scenario: "原生方言与编译源码边界及平台差异";
359
+ readonly test: "packages/language-service/src/scriptDialect.test.ts";
360
+ readonly suite: "native WXS and compiled source boundaries";
361
+ }, {
362
+ readonly id: "script-format-contract";
363
+ readonly scenario: "注入格式器、结构一致性及不安全修改拒绝";
364
+ readonly test: "packages/language-service/src/script.test.ts";
365
+ readonly suite: "injected script formatting";
366
+ }, {
367
+ readonly id: "script-cross-module-symbols";
368
+ readonly scenario: "ESM 与 require 静态绑定、遮蔽、成员及跨文件重命名范围";
369
+ readonly test: "packages/language-service/src/script/moduleFacts.test.ts";
370
+ readonly suite: "cross-module script symbol facts";
371
+ }, {
372
+ readonly id: "project-owner-contract";
373
+ readonly scenario: "项目配置、共享脚本归属、引用闭环及未保存文档";
374
+ readonly test: "packages/language-service/src/project/index.test.ts";
375
+ readonly suite: "project document ownership";
376
+ }, {
377
+ readonly id: "document-format-contract";
378
+ readonly scenario: "模板、脚本及原生样式集成和样式结构保护";
379
+ readonly test: "packages/oxfmt/src/languages/index.test.ts";
380
+ readonly suite: "shared multi-platform formatter";
381
+ }, {
382
+ readonly id: "offline-component-schema";
383
+ readonly scenario: "平台专属组件数据、属性与来源元数据";
384
+ readonly test: "packages/language-service/src/schema/index.test.ts";
385
+ readonly suite: "platform component snapshots";
386
+ }];
387
+ /** 此矩阵描述可审计的静态语言能力,不将其等同于所有宿主的渲染结果证明。 */
388
+ declare function getLanguageSupportMatrix(): {
389
+ platform: LanguagePlatform;
390
+ buildSupport: "core" | "language-only";
391
+ templateExtensions: string[];
392
+ styleExtensions: string[];
393
+ scriptExtensions: string[];
394
+ filterExtensions: string[];
395
+ compiledScriptSuffixes: string[];
396
+ cases: ("template-platform-contract" | "template-protected-source" | "template-invalid-source" | "template-seeded-combinations" | "script-platform-contract" | "script-dialect-contract" | "script-format-contract" | "script-cross-module-symbols" | "project-owner-contract" | "document-format-contract" | "offline-component-schema")[];
397
+ componentSchema: "snapshot" | "unavailable";
398
+ documentation: {
399
+ url: string;
400
+ version: "unversioned";
401
+ retrievedAt: string;
402
+ }[];
403
+ }[];
404
+ interface DocumentAnalysis {
405
+ kind: 'template' | 'script' | 'style' | 'unknown';
406
+ platform?: LanguagePlatform;
407
+ valid: boolean;
408
+ diagnostics: Diagnostic[];
409
+ template?: TemplateAnalysis;
410
+ script?: ScriptAnalysis;
411
+ }
412
+ /** 统一分析项目文件和内联脚本,所有诊断使用输入文档的 UTF-16 偏移。 */
413
+ declare function analyzeDocument(input: DocumentInput): DocumentAnalysis;
414
+ export { ScriptDialect as $, languageProfiles as A, TemplateAttribute as B, getLanguageProfile as C, isEventAttribute as D, getTemplateLoopAttributes as E, getTemplateScriptInput as F, TemplateRaw as G, TemplateExpression as H, formatTemplate as I, TemplateScript as J, TemplateReference as K, formatTemplateResult as L, TemplateDirectives as M, analyzeTemplate as N, isScriptModuleFile as O, scanTemplate as P, ScriptAnalysis as Q, getTemplateExpressions as R, getLanguageFileAssociations as S, getTemplateExtensions as T, TemplateFormatOptions as U, TemplateBinding as V, TemplateFormatResult as W, TemplateToken as X, TemplateTag as Y, FormatScriptOptions as Z, ComponentSchema as _, SourceEdit as _t, ScriptTemplateExport as a, ScriptImportBinding as at, STYLE_EXTENSIONS as b, findScriptClosingTag as c, ScriptOptions as ct, analyzeScript as d, ScriptSymbol as dt, ScriptExportScope as et, getComponentAttributes as f, Diagnostic as ft, ComponentEntry as g, LanguagePlatform as gt, ComponentAttribute as h, LanguageOptions as ht, languageSupportCases as i, ScriptFormatterResult as it, LanguageProfile as j, resolveLanguageProfile as k, findTrailingScriptComment as l, ScriptReference as lt, getComponentSchema as m, LanguageError as mt, analyzeDocument as n, ScriptFormatResult as nt, ScriptTemplateExports as o, ScriptImportRename as ot, getComponentNames as p, DocumentInput as pt, TemplateScope as q, getLanguageSupportMatrix as r, ScriptFormatterOptions as rt, getScriptTemplateExports as s, ScriptInput as st, DocumentAnalysis as t, ScriptExternalUse as tt, formatScript as u, ScriptSourceKind as ut, FILTER_EXTENSIONS as v, SourceRange as vt, getNativeStyleExtensions as w, TEMPLATE_EXTENSIONS as x, SCRIPT_EXTENSIONS as y, TemplateAnalysis as z };
@@ -0,0 +1,2 @@
1
+ import { $ as ScriptDialect, A as languageProfiles, B as TemplateAttribute, C as getLanguageProfile, D as isEventAttribute, E as getTemplateLoopAttributes, F as getTemplateScriptInput, G as TemplateRaw, H as TemplateExpression, I as formatTemplate, J as TemplateScript, K as TemplateReference, L as formatTemplateResult, M as TemplateDirectives, N as analyzeTemplate, O as isScriptModuleFile, P as scanTemplate, Q as ScriptAnalysis, R as getTemplateExpressions, S as getLanguageFileAssociations, T as getTemplateExtensions, U as TemplateFormatOptions, V as TemplateBinding, W as TemplateFormatResult, X as TemplateToken, Y as TemplateTag, Z as FormatScriptOptions, _ as ComponentSchema, _t as SourceEdit, a as ScriptTemplateExport, at as ScriptImportBinding, b as STYLE_EXTENSIONS, c as findScriptClosingTag, ct as ScriptOptions, d as analyzeScript, dt as ScriptSymbol, et as ScriptExportScope, f as getComponentAttributes, ft as Diagnostic, g as ComponentEntry, gt as LanguagePlatform, h as ComponentAttribute, ht as LanguageOptions, i as languageSupportCases, it as ScriptFormatterResult, j as LanguageProfile, k as resolveLanguageProfile, l as findTrailingScriptComment, lt as ScriptReference, m as getComponentSchema, mt as LanguageError, n as analyzeDocument, nt as ScriptFormatResult, o as ScriptTemplateExports, ot as ScriptImportRename, p as getComponentNames, pt as DocumentInput, q as TemplateScope, r as getLanguageSupportMatrix, rt as ScriptFormatterOptions, s as getScriptTemplateExports, st as ScriptInput, t as DocumentAnalysis, tt as ScriptExternalUse, u as formatScript, ut as ScriptSourceKind, v as FILTER_EXTENSIONS, vt as SourceRange, w as getNativeStyleExtensions, x as TEMPLATE_EXTENSIONS, y as SCRIPT_EXTENSIONS, z as TemplateAnalysis } from "./index-zymq0CcB.mjs";
2
+ export { type ComponentAttribute, type ComponentEntry, type ComponentSchema, Diagnostic, DocumentAnalysis, DocumentInput, FILTER_EXTENSIONS, type FormatScriptOptions, LanguageError, LanguageOptions, LanguagePlatform, type LanguageProfile, SCRIPT_EXTENSIONS, STYLE_EXTENSIONS, type ScriptAnalysis, type ScriptDialect, type ScriptExportScope, type ScriptExternalUse, type ScriptFormatResult, type ScriptFormatterOptions, type ScriptFormatterResult, type ScriptImportBinding, type ScriptImportRename, type ScriptInput, type ScriptOptions, type ScriptReference, type ScriptSourceKind, type ScriptSymbol, type ScriptTemplateExport, type ScriptTemplateExports, SourceEdit, SourceRange, TEMPLATE_EXTENSIONS, type TemplateAnalysis, type TemplateAttribute, type TemplateBinding, type TemplateDirectives, type TemplateExpression, type TemplateFormatOptions, type TemplateFormatResult, type TemplateRaw, type TemplateReference, type TemplateScope, type TemplateScript, type TemplateTag, type TemplateToken, analyzeDocument, analyzeScript, analyzeTemplate, findScriptClosingTag, findTrailingScriptComment, formatScript, formatTemplate, formatTemplateResult, getComponentAttributes, getComponentNames, getComponentSchema, getLanguageFileAssociations, getLanguageProfile, getLanguageSupportMatrix, getNativeStyleExtensions, getScriptTemplateExports, getTemplateExpressions, getTemplateExtensions, getTemplateLoopAttributes, getTemplateScriptInput, isEventAttribute, isScriptModuleFile, languageProfiles, languageSupportCases, resolveLanguageProfile, scanTemplate };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { y as FILTER_EXTENSIONS, d as LanguageError, b as SCRIPT_EXTENSIONS, x as STYLE_EXTENSIONS, S as TEMPLATE_EXTENSIONS, t as analyzeDocument, g as analyzeScript, s as analyzeTemplate, _ as findScriptClosingTag, v as findTrailingScriptComment, h as formatScript, l as formatTemplate, u as formatTemplateResult, i as getComponentAttributes, a as getComponentNames, o as getComponentSchema, C as getLanguageFileAssociations, w as getLanguageProfile, n as getLanguageSupportMatrix, T as getNativeStyleExtensions, m as getScriptTemplateExports, f as getTemplateExpressions, E as getTemplateExtensions, D as getTemplateLoopAttributes, c as getTemplateScriptInput, O as isEventAttribute, k as isScriptModuleFile, j as languageProfiles, r as languageSupportCases, A as resolveLanguageProfile, p as scanTemplate } from "./src-DeWCgmtC.mjs";
@@ -0,0 +1,39 @@
1
+ import { ft as Diagnostic, gt as LanguagePlatform, ht as LanguageOptions, pt as DocumentInput, t as DocumentAnalysis } from "../index-zymq0CcB.mjs";
2
+ import { OxfmtConfig } from "vite-plus/fmt";
3
+ import { OxlintConfig } from "vite-plus/lint";
4
+ export interface ProjectLanguageConfig {
5
+ root: string;
6
+ fmt?: OxfmtConfig;
7
+ lint?: OxlintConfig;
8
+ language: LanguageOptions;
9
+ }
10
+ interface ProjectConfigOptions {
11
+ configFile?: string;
12
+ configKind?: 'fmt' | 'lint';
13
+ workspaceFirst?: boolean;
14
+ }
15
+ /** 只在可信项目执行配置;工作区检查使用父配置,普通格式化使用最近配置。 */
16
+ export declare function loadProjectConfig(cwd: string, options?: ProjectConfigOptions): Promise<ProjectLanguageConfig>;
17
+ export interface ProjectDocument {
18
+ file: string;
19
+ fileName: string;
20
+ source: string;
21
+ platform?: LanguagePlatform;
22
+ input: DocumentInput;
23
+ analysis: DocumentAnalysis;
24
+ }
25
+ /** 从模板引用传播模块所属平台,不根据共享的 SJS 后缀猜测宿主。 */
26
+ export declare function analyzeProject(root: string, inputs?: string[], options?: LanguageOptions, ignores?: string[], sourceOverrides?: ReadonlyMap<string, string>): Promise<ProjectDocument[]>;
27
+ /** 编辑器传入未保存源码,沿用与 CLI 相同的项目引用归属和配置。 */
28
+ export declare function resolveProjectDocumentInput(project: ProjectLanguageConfig, fileName: string, source: string): Promise<DocumentInput>;
29
+ /** 编辑器和项目图共用静态路径解析,包含项目根路径及编译源替代。 */
30
+ export declare function resolveProjectReference(project: ProjectLanguageConfig, fileName: string, source: string): Promise<string | undefined>;
31
+ /** 诊断位置以 UTF-16 计算,输出使用稳定的相对路径与一基行列。 */
32
+ export declare function printDiagnostic(fileName: string, source: string, diagnostic: Diagnostic): string;
33
+ export declare const PROJECT_IGNORES: string[];
34
+ /** 原生模块及待编译模块都由语言适配层处理,不与普通 JS/TS 重复检查。 */
35
+ export declare function isScriptModule(file: string): boolean;
36
+ export declare function isNativeDocument(file: string): boolean;
37
+ /** 各工具共用忽略文件与路径归一化;不跟随符号链接,也不越过项目根。 */
38
+ export declare function collectProjectFiles(cwd: string, inputs?: string[], ignorePatterns?: string[]): Promise<string[]>;
39
+ export {};