@proteus-vue/component-ir 0.1.0 → 0.2.0-beta.1
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 +218 -0
- package/README.md +1 -1
- package/dist/audit.d.ts +22 -0
- package/dist/conformance.d.ts +12 -3
- package/dist/degradation.d.ts +115 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.js +1316 -85
- package/dist/map.d.ts +1 -1
- package/dist/mp-spec-coverage.d.ts +106 -0
- package/dist/primitives.d.ts +2 -2
- package/dist/schema.d.ts +43 -2
- package/package.json +5 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
Proteus(普罗透斯)Vue 跨端编译框架
|
|
2
|
+
Copyright (c) 2026 Proteus Contributors
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
|
|
16
|
+
═══════════════════════════════════════════════════════════════════════════════
|
|
17
|
+
|
|
18
|
+
Apache License
|
|
19
|
+
Version 2.0, January 2004
|
|
20
|
+
http://www.apache.org/licenses/
|
|
21
|
+
|
|
22
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
23
|
+
|
|
24
|
+
1. Definitions.
|
|
25
|
+
|
|
26
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
27
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
28
|
+
|
|
29
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
30
|
+
the copyright owner that is granting the License.
|
|
31
|
+
|
|
32
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
33
|
+
other entities that control, are controlled by, or are under common
|
|
34
|
+
control with that entity. For the purposes of this definition,
|
|
35
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
36
|
+
direction or management of such entity, whether by contract or
|
|
37
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
38
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
39
|
+
|
|
40
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
41
|
+
exercising permissions granted by this License.
|
|
42
|
+
|
|
43
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
44
|
+
including but not limited to software source code, documentation
|
|
45
|
+
source, and configuration files.
|
|
46
|
+
|
|
47
|
+
"Object" form shall mean any form resulting from mechanical
|
|
48
|
+
transformation or translation of a Source form, including but
|
|
49
|
+
not limited to compiled object code, generated documentation,
|
|
50
|
+
and conversions to other media types.
|
|
51
|
+
|
|
52
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
53
|
+
Object form, made available under the License, as indicated by a
|
|
54
|
+
copyright notice that is included in or attached to the work
|
|
55
|
+
(an example is provided in the Appendix below).
|
|
56
|
+
|
|
57
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
58
|
+
form, that is based on (or derived from) the Work and for which the
|
|
59
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
60
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
61
|
+
of this License, Derivative Works shall not include works that remain
|
|
62
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
63
|
+
the Work and Derivative Works thereof.
|
|
64
|
+
|
|
65
|
+
"Contribution" shall mean any work of authorship, including
|
|
66
|
+
the original version of the Work and any modifications or additions
|
|
67
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
68
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
69
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
70
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
71
|
+
means any form of electronic, verbal, or written communication sent
|
|
72
|
+
to the Licensor or its representatives, including but not limited to
|
|
73
|
+
communication on electronic mailing lists, source code control systems,
|
|
74
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
75
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
76
|
+
excluding communication that is conspicuously marked or otherwise
|
|
77
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
78
|
+
|
|
79
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
80
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
81
|
+
subsequently incorporated within the Work.
|
|
82
|
+
|
|
83
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
84
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
85
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
86
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
87
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
88
|
+
Work and such Derivative Works in Source or Object form.
|
|
89
|
+
|
|
90
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
91
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
92
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
93
|
+
(except as stated in this section) patent license to make, have made,
|
|
94
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
95
|
+
where such license applies only to those patent claims licensable
|
|
96
|
+
by such Contributor that are necessarily infringed by their
|
|
97
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
98
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
99
|
+
institute patent litigation against any entity (including a
|
|
100
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
101
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
102
|
+
or contributory patent infringement, then any patent licenses
|
|
103
|
+
granted to You under this License for that Work shall terminate
|
|
104
|
+
as of the date such litigation is filed.
|
|
105
|
+
|
|
106
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
107
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
108
|
+
modifications, and in Source or Object form, provided that You
|
|
109
|
+
meet the following conditions:
|
|
110
|
+
|
|
111
|
+
(a) You must give any other recipients of the Work or
|
|
112
|
+
Derivative Works a copy of this License; and
|
|
113
|
+
|
|
114
|
+
(b) You must cause any modified files to carry prominent notices
|
|
115
|
+
stating that You changed the files; and
|
|
116
|
+
|
|
117
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
118
|
+
that You distribute, all copyright, patent, trademark, and
|
|
119
|
+
attribution notices from the Source form of the Work,
|
|
120
|
+
excluding those notices that do not pertain to any part of
|
|
121
|
+
the Derivative Works; and
|
|
122
|
+
|
|
123
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
124
|
+
distribution, then any Derivative Works that You distribute must
|
|
125
|
+
include a readable copy of the attribution notices contained
|
|
126
|
+
within such NOTICE file, excluding those notices that do not
|
|
127
|
+
pertain to any part of the Derivative Works, in at least one
|
|
128
|
+
of the following places: within a NOTICE text file distributed
|
|
129
|
+
as part of the Derivative Works; within the Source form or
|
|
130
|
+
documentation, if provided along with the Derivative Works; or,
|
|
131
|
+
within a display generated by the Derivative Works, if and
|
|
132
|
+
wherever such third-party notices normally appear. The contents
|
|
133
|
+
of the NOTICE file are for informational purposes only and
|
|
134
|
+
do not modify the License. You may add Your own attribution
|
|
135
|
+
notices within Derivative Works that You distribute, alongside
|
|
136
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
137
|
+
that such additional attribution notices cannot be construed
|
|
138
|
+
as modifying the License.
|
|
139
|
+
|
|
140
|
+
You may add Your own copyright statement to Your modifications and
|
|
141
|
+
may provide additional or different license terms and conditions
|
|
142
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
143
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
144
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
145
|
+
the conditions stated in this License.
|
|
146
|
+
|
|
147
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
148
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
149
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
150
|
+
this License, without any additional terms or conditions.
|
|
151
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
152
|
+
the terms of any separate license agreement you may have executed
|
|
153
|
+
with Licensor regarding such Contributions.
|
|
154
|
+
|
|
155
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
156
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
157
|
+
except as required for reasonable and customary use in describing the
|
|
158
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
159
|
+
|
|
160
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
161
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
162
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
163
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
164
|
+
implied, including, without limitation, any warranties or conditions
|
|
165
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
166
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
167
|
+
appropriateness of using or redistributing the Work and assume any
|
|
168
|
+
risks associated with Your exercise of permissions under this License.
|
|
169
|
+
|
|
170
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
171
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
172
|
+
unless required by applicable law (such as deliberate and grossly
|
|
173
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
174
|
+
liable to You for damages, including any direct, indirect, special,
|
|
175
|
+
incidental, or consequential damages of any character arising as a
|
|
176
|
+
result of this License or out of the use or inability to use the
|
|
177
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
178
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
179
|
+
other commercial damages or losses), even if such Contributor
|
|
180
|
+
has been advised of the possibility of such damages.
|
|
181
|
+
|
|
182
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
183
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
184
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
185
|
+
or other liability obligations and/or rights consistent with this
|
|
186
|
+
License. However, in accepting such obligations, You may act only
|
|
187
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
188
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
189
|
+
defend, and hold each Contributor harmless for any liability
|
|
190
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
191
|
+
of your accepting any such warranty or additional liability.
|
|
192
|
+
|
|
193
|
+
END OF TERMS AND CONDITIONS
|
|
194
|
+
|
|
195
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
196
|
+
|
|
197
|
+
To apply the Apache License to your work, attach the following
|
|
198
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
199
|
+
replaced with your own identifying information. (Don't include
|
|
200
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
201
|
+
comment syntax for the file format. We also recommend that a
|
|
202
|
+
file or class name and description of purpose be included on the
|
|
203
|
+
same "printed page" as the copyright notice for easier
|
|
204
|
+
identification within third-party archives.
|
|
205
|
+
|
|
206
|
+
Copyright [yyyy] [name of copyright owner]
|
|
207
|
+
|
|
208
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
209
|
+
you may not use this file except in compliance with the License.
|
|
210
|
+
You may obtain a copy of the License at
|
|
211
|
+
|
|
212
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
213
|
+
|
|
214
|
+
Unless required by applicable law or agreed to in writing, software
|
|
215
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
216
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
217
|
+
See the License for the specific language governing permissions and
|
|
218
|
+
limitations under the License.
|
package/README.md
CHANGED
package/dist/audit.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export interface MpMatrixItem {
|
|
|
8
8
|
status: MpCoverageStatus;
|
|
9
9
|
/** 对照类别(component / api-*) */
|
|
10
10
|
group: 'component' | 'api';
|
|
11
|
+
/** ★诚实边界:proteus 引用的 p-* 为 L2 规划中(尚未实现)——引用门禁据此豁免(不豁免则视为幽灵) */
|
|
12
|
+
planned?: boolean;
|
|
11
13
|
}
|
|
12
14
|
/** 全量对照矩阵 */
|
|
13
15
|
export declare const MP_MAPPING_MATRIX: MpMatrixItem[];
|
|
@@ -17,6 +19,10 @@ export interface CoverageReport {
|
|
|
17
19
|
compat: number;
|
|
18
20
|
private: number;
|
|
19
21
|
missing: number;
|
|
22
|
+
/** ★诚实边界:`planned: true` 行——L2 规划中(尚未实现),计作已覆盖但**不是已落地** */
|
|
23
|
+
planned: number;
|
|
24
|
+
/** ★真·已落地 = total − private − missing − planned(有等价能力且现已可用)——区分「有等价」与「真缺」 */
|
|
25
|
+
landed: number;
|
|
20
26
|
/** 覆盖百分比(非 missing 占比) */
|
|
21
27
|
percent: number;
|
|
22
28
|
/** G-32.1:missing > 0 → 不达标(CI 红) */
|
|
@@ -26,8 +32,24 @@ export interface CoverageReport {
|
|
|
26
32
|
/**
|
|
27
33
|
* ★G-32.1 audit:coverage:小程序官方能力 100% 覆盖校验
|
|
28
34
|
* 缺失(❌)= 无 Proteus 原语且非平台私有 —— 出现即 CI 红
|
|
35
|
+
* ★非纯计数:额外区分 `landed`(现已可用)与 `planned`(L2 规划待落地),避免「100% = 全做完」的误读
|
|
29
36
|
*/
|
|
30
37
|
export declare function auditMiniprogramCoverage(matrix?: MpMatrixItem[]): CoverageReport;
|
|
38
|
+
export interface MatrixRefIssue {
|
|
39
|
+
mp: string;
|
|
40
|
+
ref: string;
|
|
41
|
+
kind: 'component' | 'semantic' | 'hook';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* ★矩阵引用一致性:proteus 列引用的 token 必须真实存在(组件标签 ∈ TAG_SEMANTIC_MAP / 语义 ∈ SEMANTIC_ENUM /
|
|
45
|
+
* Hook ∈ knownHooks)——否则「幽灵引用」(旧矩阵把未实现的 p-overlay/p-progress、不存在的 capability.fetch 等
|
|
46
|
+
* 标为 ok/compat,致「100% 覆盖」自证同义反复)。`planned: true` 行豁免「组件标签不存在」(诚实登记 L2 规划)。
|
|
47
|
+
* @param knownHooks 能力 Hook 名集合(来自 @proteus-vue/api SSOT——component-ir 不 import api,由调用方传入)
|
|
48
|
+
*/
|
|
49
|
+
export declare function auditMatrixReferences(matrix?: MpMatrixItem[], knownHooks?: ReadonlySet<string>): {
|
|
50
|
+
issues: MatrixRefIssue[];
|
|
51
|
+
plannedRefs: number;
|
|
52
|
+
};
|
|
31
53
|
export interface ConsistencyIssue {
|
|
32
54
|
rule: string;
|
|
33
55
|
detail: string;
|
package/dist/conformance.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/** ★#425 破 type-only 环:渲染快照的本地鸭子视图(只读 component-ir 所需字段——结构与 render-backend
|
|
2
|
+
* RenderNodeSnapshot 对齐,结构兼容即可传参;component-ir 零 import render-backend,build 序单向可排) */
|
|
3
|
+
export interface RenderNodeSnapshotView {
|
|
4
|
+
type: string;
|
|
5
|
+
semantic: string;
|
|
6
|
+
control: string;
|
|
7
|
+
children: RenderNodeSnapshotView[];
|
|
8
|
+
props?: Record<string, unknown>;
|
|
9
|
+
text?: string;
|
|
10
|
+
}
|
|
2
11
|
/** 控件映射偏差:error=与参考表不符(门禁阻断);unverified=参考表未声明该后端/语义,或 Layer 1 兼容层标签(不强制) */
|
|
3
12
|
export interface ControlMismatch {
|
|
4
13
|
path: string;
|
|
@@ -23,13 +32,13 @@ export interface SemanticTree {
|
|
|
23
32
|
children: SemanticTree[];
|
|
24
33
|
}
|
|
25
34
|
/** 提取语义树(忽略控件/属性——只比结构形状) */
|
|
26
|
-
export declare function extractSemanticTree(snap:
|
|
35
|
+
export declare function extractSemanticTree(snap: RenderNodeSnapshotView): SemanticTree;
|
|
27
36
|
/**
|
|
28
37
|
* 渲染快照 vs 规范参考表(SEMANTIC_BACKEND_MAP)
|
|
29
38
|
* - Layer 0 语义节点(semantic ≠ type):参考表命中 → 控件必须一致(error);参考表缺该语义/后端列 → unverified(不臆造门禁)
|
|
30
39
|
* - Layer 1 兼容层节点(无 semantic,semantic === type):各后端自定义 compat 映射 → 不设门禁(unverified)
|
|
31
40
|
*/
|
|
32
|
-
export declare function checkComponentSnapshot(backendId: string, snapshot:
|
|
41
|
+
export declare function checkComponentSnapshot(backendId: string, snapshot: RenderNodeSnapshotView): ComponentConformanceResult;
|
|
33
42
|
/** 参考表覆盖缺口(G-31.4:新组件进 L1 须 ≥3 端映射;不足 → 降级 L2,禁入 core)
|
|
34
43
|
* ★G-32 B1:仅对 catalog 中 status='implemented' 的原语设门禁——planned(L2 生态/待落地)不阻断
|
|
35
44
|
*/
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { PrimitiveDef } from './primitives';
|
|
2
|
+
/** 端轴:仅「真有 Backend 实现」的端(见文件头诚实边界) */
|
|
3
|
+
export type DegradationEnd = 'mp' | 'web';
|
|
4
|
+
/** 降级三态(§2) */
|
|
5
|
+
export type DegradationTier = 'supported' | 'fallback' | 'unsupported';
|
|
6
|
+
/** 单属性降级声明 */
|
|
7
|
+
export interface DegradationEntry {
|
|
8
|
+
mp: DegradationTier;
|
|
9
|
+
web: DegradationTier;
|
|
10
|
+
/** 降级行为(任一端非 supported 时必填——EA-5 §4 反黑盒) */
|
|
11
|
+
behavior?: string;
|
|
12
|
+
}
|
|
13
|
+
export type DegradationMap = Record<string, DegradationEntry>;
|
|
14
|
+
/**
|
|
15
|
+
* ★按 tag 限定的 mp: fallback(2026-09-19 新增机制):属性在 Web 有实现、MP 无平台对等。
|
|
16
|
+
*
|
|
17
|
+
* 与 STYLE_WEB_FALLBACK 等「按属性名全局」的表不同——这里**按 tag 限定**,因为本仓存在
|
|
18
|
+
* **跨组件同名属性**(实测:`loop` 是 `<video>/<audio>` 的官方属性、`snap` 是 `<draggable-sheet>`
|
|
19
|
+
* 的官方属性,而框架的 `p-stack` 另有自己的语义 `loop`/`snap`)——按属性名全局判 fallback 会误伤。
|
|
20
|
+
*
|
|
21
|
+
* 依据:`p-stack` 的 `snap`/`loop` 是「轮播」语义消灭形态(G-31 §2.2、rules.md 拒绝 `<p-swiper>`),
|
|
22
|
+
* 但 MP 端容器滚动本身不成立——**Skyline 的 view 不滚动(CSS overflow 无效)**,这是本仓已实测
|
|
23
|
+
* 的结论(skyline-pitfalls S14 + `p-scroll` 同款告警:「小程序 view 不滚动——请改用 p-scroll-view」)。
|
|
24
|
+
* 容器不滚动 ⇒ 吸附/回环无载体(CSS scroll-snap 亦然)。
|
|
25
|
+
* fallback 行为 = 普通排列 + `capabilityWarnOnce` 控制台提示(可观察,非静默失效)。
|
|
26
|
+
* ★MP 端如需真轮播:用 `p-scroll-view` 的 `paging-enabled`(官方 Skyline 翻页属性,原生支持)。
|
|
27
|
+
*/
|
|
28
|
+
declare const TAG_PROP_MP_FALLBACK: Record<string, Record<string, string>>;
|
|
29
|
+
/** ★导出供降级门禁做「显式登记的 tag 限定 fallback」豁免(区别于跨组件同名导致的误报) */
|
|
30
|
+
export declare const TAG_SCOPED_MP_FALLBACK: typeof TAG_PROP_MP_FALLBACK;
|
|
31
|
+
/** 规则表登记的全部「非缺省判定」属性名(供门禁做**陈旧规则**检测——规则指向不存在的属性即失效) */
|
|
32
|
+
export declare const RULE_REGISTERED_PROPS: string[];
|
|
33
|
+
/** 宿主组件族 tag(web:fallback 的来源) */
|
|
34
|
+
export declare const HOST_FALLBACK_TAGS: string[];
|
|
35
|
+
/** 对单个属性判定降级三元组(端轴可扩展) */
|
|
36
|
+
export declare function degradeProp(tag: string | undefined, prop: string): DegradationEntry;
|
|
37
|
+
/** 组件原语(有 tag 者)的属性降级表:tag → { prop → entry } */
|
|
38
|
+
export declare function degradationOf(prim: PrimitiveDef): DegradationMap;
|
|
39
|
+
/** 全量降级表(SSOT:PRIMITIVE_CATALOG 中所有带 tag 的原语) */
|
|
40
|
+
export declare const DEGRADATION_TABLE: Record<string, DegradationMap>;
|
|
41
|
+
/**
|
|
42
|
+
* ★性能预计算(2026-09-18):tag → { kebab 属性名 → true },**只收 `mp: unsupported` 的属性**。
|
|
43
|
+
*
|
|
44
|
+
* 编译器编译每个元素都要判「该属性在 mp 端是否 unsupported」。此前编译器在 `serializeElement`
|
|
45
|
+
* 里**逐元素**新建 Map 并对每个属性名跑 kebabCase → 实测 `compile-vue-sfc` 基准从 0.573ms
|
|
46
|
+
* 涨到 0.765ms(+33%,推过 1.2x 警告线)。改为模块加载时预计算一次:
|
|
47
|
+
* 每元素仅剩 **一次 kebabCase + 一次 Set.has**,零分配。
|
|
48
|
+
*
|
|
49
|
+
* 语义等价:诊断只关心 `mp === 'unsupported'`(`fallback` 有意降级、不报),故只需该子集。
|
|
50
|
+
*/
|
|
51
|
+
export declare const MP_UNSUPPORTED_PROPS: Record<string, Set<string>>;
|
|
52
|
+
export interface DegradationIssue {
|
|
53
|
+
tag: string;
|
|
54
|
+
prop: string;
|
|
55
|
+
/**
|
|
56
|
+
* missing = 空白格(保留以兼容既有消费方;表由规则构建后不再产生);
|
|
57
|
+
* behavior-gap = 非 supported 但无可观察行为;table-divergence = 表与规则判定不一致。
|
|
58
|
+
*/
|
|
59
|
+
kind: 'missing' | 'behavior-gap' | 'table-divergence';
|
|
60
|
+
detail: string;
|
|
61
|
+
}
|
|
62
|
+
export interface DegradationReport {
|
|
63
|
+
/** 组件原语数 */
|
|
64
|
+
components: number;
|
|
65
|
+
/** 已声明属性数 */
|
|
66
|
+
props: number;
|
|
67
|
+
/** 各端各态计数 */
|
|
68
|
+
counts: Record<DegradationEnd, Record<DegradationTier, number>>;
|
|
69
|
+
/** fallback 已声明可观察行为数 / 需要行为数(反黑盒) */
|
|
70
|
+
behaviorDeclared: number;
|
|
71
|
+
behaviorNeeded: number;
|
|
72
|
+
issues: DegradationIssue[];
|
|
73
|
+
ok: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 降级门禁(EA-5):
|
|
77
|
+
* ① 每个 props 里的属性都必须在降级表中有声明(缺格 = 违反 EA-5,对齐 03 §3「不允许空白格」);
|
|
78
|
+
* ② 任一端为 fallback/unsupported 时必须有 behavior(可观察降级行为,§4 反黑盒)——
|
|
79
|
+
* 「只有状态、无行为」视为不诚实降级,判 FAIL。
|
|
80
|
+
*
|
|
81
|
+
* ★作用域(诚实说明):默认审计 PRIMITIVE_CATALOG 的组件原语属性(62 组件)。
|
|
82
|
+
* 组件库实际有 73 个 p-* 组件(`packages/components/*`)——其中 11 个(p-button、p-view、
|
|
83
|
+
* p-scroll-view、p-nav-bar、p-list-view、p-safe、p-sidebar、p-location、p-pick-photo、
|
|
84
|
+
* p-scan-qr、p-svg-canvas)尚未登记进 catalog。传 `extraSpecs` 可把这批也纳入审计,
|
|
85
|
+
* 由 CLI 脚本(scripts/audit-degradation.mjs)从组件源码提供,从而与端对齐标尺同口径(全 73 组件)。
|
|
86
|
+
*/
|
|
87
|
+
export declare function auditDegradation(extraSpecs?: Array<{
|
|
88
|
+
tag: string;
|
|
89
|
+
props: string[];
|
|
90
|
+
}>): DegradationReport;
|
|
91
|
+
/** 人类可读报告 */
|
|
92
|
+
export declare function formatDegradationReport(r: DegradationReport): string;
|
|
93
|
+
/** 编译期诊断码(对齐 03-degradation-tiers.md §6) */
|
|
94
|
+
export declare const PROP_NO_DEGRADATION = "PROP_NO_DEGRADATION";
|
|
95
|
+
export interface PropDiagnostic {
|
|
96
|
+
code: typeof PROP_NO_DEGRADATION;
|
|
97
|
+
tag: string;
|
|
98
|
+
prop: string;
|
|
99
|
+
end: DegradationEnd;
|
|
100
|
+
message: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* ★M6 编译期门禁:目标端**无法实现**的属性被业务侧使用时产生 fail-closed 诊断。
|
|
104
|
+
* 依据 03-degradation-tiers.md §2「unsupported = 本端无法实现 → 编译期警告/报错(fail-closed)」与 §6。
|
|
105
|
+
*
|
|
106
|
+
* `fallback` **不**产生诊断——降级是有意的可观察行为(行为已在表中声明);
|
|
107
|
+
* 只有 `unsupported` 才是「无论如何都会静默失败」,必须由编译器拦住。
|
|
108
|
+
*
|
|
109
|
+
* @param table 可选降级表(缺省 = 模块级 DEGRADATION_TABLE)。注入用以便测试无 unsupported 现状下的诊断路径。
|
|
110
|
+
* @returns 命中 unsupported 时返回诊断;否则 null。
|
|
111
|
+
*/
|
|
112
|
+
export declare function checkPropDegradation(tag: string, prop: string, end: DegradationEnd, table?: Record<string, DegradationMap>): PropDiagnostic | null;
|
|
113
|
+
/** 扫描一个元素的全部属性,返回所有 unsupported 诊断(供编译器批量收集) */
|
|
114
|
+
export declare function collectPropDiagnostics(tag: string, props: string[], end: DegradationEnd, table?: Record<string, DegradationMap>): PropDiagnostic[];
|
|
115
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { COMPONENT_IR_SCHEMA, SEMANTIC_ENUM, TAG_SEMANTIC_MAP } from './schema';
|
|
2
|
-
export type { ComponentIR } from './schema';
|
|
1
|
+
export { COMPONENT_IR_SCHEMA, SEMANTIC_ENUM, TAG_SEMANTIC_MAP, FRAMEWORK_INTERNAL_TAGS, TAG_SEMANTIC_ALIASES } from './schema';
|
|
2
|
+
export type { ComponentIR, TagAliasDecl } from './schema';
|
|
3
3
|
export { validateComponentIR, validateGridConstraints, validateComponentTree, DEFAULT_DESIGN_WIDTH } from './validate';
|
|
4
4
|
export type { CIRDiagnostic } from './validate';
|
|
5
5
|
export { SEMANTIC_BACKEND_MAP, mapSemanticToBackend } from './map';
|
|
@@ -8,5 +8,10 @@ export { checkComponentSnapshot, extractSemanticTree, checkSemanticCoverage } fr
|
|
|
8
8
|
export type { ComponentConformanceResult, ControlMismatch, SemanticTree, CoverageGap } from './conformance';
|
|
9
9
|
export { PRIMITIVE_CATALOG, componentPrimitives, implementedPrimitives, primitiveById, primitiveBySemantic, primitiveByTag, checkPrimitiveCatalog } from './primitives';
|
|
10
10
|
export type { PrimitiveDef, PrimitiveKind, PrimitiveStatus } from './primitives';
|
|
11
|
-
export { MP_MAPPING_MATRIX, auditMiniprogramCoverage, auditCatalogConsistency, formatCoverageReport } from './audit';
|
|
11
|
+
export { MP_MAPPING_MATRIX, auditMiniprogramCoverage, auditMatrixReferences, auditCatalogConsistency, formatCoverageReport } from './audit';
|
|
12
|
+
export type { MatrixRefIssue } from './audit';
|
|
12
13
|
export type { CoverageReport, MpCoverageStatus, MpMatrixItem, ConsistencyIssue } from './audit';
|
|
14
|
+
export { classifySpecApi, classifySpecComponent, auditSpecCoverage, auditSpecOverrideRefs, GESTURE_HANDLER_EXPECTED, SPEC_COVERED, SPEC_PLANNED, SPEC_PRIVATE, SPEC_NA, SPEC_COMPONENT_OVERRIDE, SPEC_RATCHET } from './mp-spec-coverage';
|
|
15
|
+
export type { MpSpecStatus, MpSpecClass, MpOfficialSpec, SpecCoverageReport } from './mp-spec-coverage';
|
|
16
|
+
export { DEGRADATION_TABLE, MP_UNSUPPORTED_PROPS, degradeProp, degradationOf, auditDegradation, formatDegradationReport, checkPropDegradation, collectPropDiagnostics, RULE_REGISTERED_PROPS, HOST_FALLBACK_TAGS, PROP_NO_DEGRADATION, } from './degradation';
|
|
17
|
+
export type { DegradationEnd, DegradationTier, DegradationEntry, DegradationMap, DegradationIssue, DegradationReport, PropDiagnostic, } from './degradation';
|