@dimina-kit/compiler 0.0.2-dev.20260728065133 → 0.0.2-dev.20260728095034
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/compile-core.browser.js +14759 -16081
- package/dist/compile-core.node-chunks/chunk-2VRS523Z.js +8 -0
- package/dist/compile-core.node-chunks/chunk-LUD2P6RM.js +211 -0
- package/dist/compile-core.node-chunks/{chunk-M62ZDT7T.js → chunk-QJ34C5KK.js} +66 -542
- package/dist/compile-core.node-chunks/{logic-compiler-AEZPY2MO.js → logic-compiler-2SQFOFEO.js} +113 -37
- package/dist/compile-core.node-chunks/style-compiler-ZEJ3XLTS.js +277 -0
- package/dist/compile-core.node-chunks/{view-compiler-2SMUHAPD.js → view-compiler-WQNV7H5G.js} +161 -425
- package/dist/compile-core.node.js +6 -11
- package/dist/pool.node-chunks/{chunk-CKQISGZS.js → chunk-7FGOYOXU.js} +66 -542
- package/dist/pool.node-chunks/chunk-C7GEIDCP.js +211 -0
- package/dist/pool.node-chunks/chunk-KLXXOLDF.js +8 -0
- package/dist/pool.node-chunks/{chunk-WX4462A5.js → chunk-PDHO4Y56.js} +6 -11
- package/dist/pool.node-chunks/{logic-compiler-P4T4OMTG.js → logic-compiler-BODAINZQ.js} +113 -37
- package/dist/pool.node-chunks/style-compiler-TUNDVSR5.js +277 -0
- package/dist/pool.node-chunks/{view-compiler-2D7HPYIN.js → view-compiler-HOFFL63K.js} +161 -425
- package/dist/pool.node.js +2 -2
- package/dist/stage-worker.browser.js +1940 -3262
- package/dist/stage-worker.node.js +2 -2
- package/package.json +3 -3
- package/dist/compile-core.node-chunks/chunk-23PCGQQU.js +0 -141
- package/dist/compile-core.node-chunks/chunk-QYHGF3MS.js +0 -1601
- package/dist/compile-core.node-chunks/style-compiler-4PHMBQIC.js +0 -470
- package/dist/pool.node-chunks/chunk-LGB3AH5C.js +0 -1601
- package/dist/pool.node-chunks/chunk-VHWKAXDL.js +0 -141
- package/dist/pool.node-chunks/style-compiler-W7EA2Y7R.js +0 -470
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getViewScriptTags
|
|
3
|
+
} from "./chunk-QJ34C5KK.js";
|
|
4
|
+
|
|
5
|
+
// ../../dimina/fe/packages/compiler/src/common/compatibility.js
|
|
6
|
+
import { Parser } from "htmlparser2";
|
|
7
|
+
|
|
8
|
+
// ../../dimina/fe/packages/compiler/src/common/compatibility-reference.js
|
|
9
|
+
var supportedBuiltinComponents = [
|
|
10
|
+
"block",
|
|
11
|
+
"button",
|
|
12
|
+
"canvas",
|
|
13
|
+
"checkbox",
|
|
14
|
+
"checkbox-group",
|
|
15
|
+
"cover-image",
|
|
16
|
+
"cover-view",
|
|
17
|
+
"form",
|
|
18
|
+
"icon",
|
|
19
|
+
"image",
|
|
20
|
+
"input",
|
|
21
|
+
"label",
|
|
22
|
+
"movable-area",
|
|
23
|
+
"movable-view",
|
|
24
|
+
"navigation-bar",
|
|
25
|
+
"navigator",
|
|
26
|
+
"picker",
|
|
27
|
+
"picker-view",
|
|
28
|
+
"picker-view-column",
|
|
29
|
+
"progress",
|
|
30
|
+
"radio",
|
|
31
|
+
"radio-group",
|
|
32
|
+
"rich-text",
|
|
33
|
+
"scroll-view",
|
|
34
|
+
"slider",
|
|
35
|
+
"slot",
|
|
36
|
+
"swiper",
|
|
37
|
+
"swiper-item",
|
|
38
|
+
"switch",
|
|
39
|
+
"template",
|
|
40
|
+
"text",
|
|
41
|
+
"textarea",
|
|
42
|
+
"video",
|
|
43
|
+
"view",
|
|
44
|
+
"web-view",
|
|
45
|
+
"wxs",
|
|
46
|
+
"include",
|
|
47
|
+
"import"
|
|
48
|
+
];
|
|
49
|
+
var supportedWxApis = [
|
|
50
|
+
"env",
|
|
51
|
+
"canIUse",
|
|
52
|
+
"getUpdateManager",
|
|
53
|
+
"openSystemBluetoothSetting",
|
|
54
|
+
"getWindowInfo",
|
|
55
|
+
"getSystemSetting",
|
|
56
|
+
"getSystemInfoSync",
|
|
57
|
+
"getSystemInfoAsync",
|
|
58
|
+
"getSystemInfo",
|
|
59
|
+
"reLaunch",
|
|
60
|
+
"redirectTo",
|
|
61
|
+
"navigateTo",
|
|
62
|
+
"navigateBack",
|
|
63
|
+
"showToast",
|
|
64
|
+
"showModal",
|
|
65
|
+
"showLoading",
|
|
66
|
+
"showActionSheet",
|
|
67
|
+
"hideToast",
|
|
68
|
+
"hideLoading",
|
|
69
|
+
"setNavigationBarTitle",
|
|
70
|
+
"setNavigationBarColor",
|
|
71
|
+
"pageScrollTo",
|
|
72
|
+
"getMenuButtonBoundingClientRect",
|
|
73
|
+
"createAnimation",
|
|
74
|
+
"createCanvasContext",
|
|
75
|
+
"createOffscreenCanvas",
|
|
76
|
+
"canvasToTempFilePath",
|
|
77
|
+
"createSelectorQuery",
|
|
78
|
+
"createIntersectionObserver",
|
|
79
|
+
"request",
|
|
80
|
+
"downloadFile",
|
|
81
|
+
"uploadFile",
|
|
82
|
+
"setStorageSync",
|
|
83
|
+
"getStorageSync",
|
|
84
|
+
"removeStorageSync",
|
|
85
|
+
"clearStorageSync",
|
|
86
|
+
"setStorage",
|
|
87
|
+
"getStorage",
|
|
88
|
+
"removeStorage",
|
|
89
|
+
"clearStorage",
|
|
90
|
+
"getStorageInfoSync",
|
|
91
|
+
"getStorageInfo",
|
|
92
|
+
"saveImageToPhotosAlbum",
|
|
93
|
+
"previewImage",
|
|
94
|
+
"compressImage",
|
|
95
|
+
"chooseImage",
|
|
96
|
+
"chooseMedia",
|
|
97
|
+
"chooseContact",
|
|
98
|
+
"addPhoneContact",
|
|
99
|
+
"setClipboardData",
|
|
100
|
+
"getClipboardData",
|
|
101
|
+
"vibrateShort",
|
|
102
|
+
"vibrateLong",
|
|
103
|
+
"hideKeyboard",
|
|
104
|
+
"getNetworkType",
|
|
105
|
+
"makePhoneCall",
|
|
106
|
+
"extBridge",
|
|
107
|
+
"extOnBridge",
|
|
108
|
+
"extOffBridge"
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
// ../../dimina/fe/packages/compiler/src/common/compatibility.js
|
|
112
|
+
var cachedReference = null;
|
|
113
|
+
var warnedItems = /* @__PURE__ */ new Set();
|
|
114
|
+
function loadReference() {
|
|
115
|
+
if (cachedReference) {
|
|
116
|
+
return cachedReference;
|
|
117
|
+
}
|
|
118
|
+
cachedReference = {
|
|
119
|
+
supportedBuiltinComponents: new Set(supportedBuiltinComponents),
|
|
120
|
+
supportedWxApis: new Set(supportedWxApis)
|
|
121
|
+
};
|
|
122
|
+
return cachedReference;
|
|
123
|
+
}
|
|
124
|
+
function getWxMemberName(node) {
|
|
125
|
+
if (node?.type !== "MemberExpression") {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
if (node.object?.type !== "Identifier" || node.object.name !== "wx") {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
if (!node.computed && node.property?.type === "Identifier") {
|
|
132
|
+
return node.property.name;
|
|
133
|
+
}
|
|
134
|
+
if (node.computed && (node.property?.type === "StringLiteral" || node.property?.type === "Literal") && typeof node.property.value === "string") {
|
|
135
|
+
return node.property.value;
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
function warnUnsupportedWxApi(apiName, filePath, line) {
|
|
140
|
+
const { supportedWxApis: supportedWxApis2 } = loadReference();
|
|
141
|
+
if (!apiName || supportedWxApis2.has(apiName)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const location = formatLocation(filePath, line);
|
|
145
|
+
warnOnce("api", apiName, location, `[compat] Unsupported wx API: wx.${apiName}${location}`);
|
|
146
|
+
}
|
|
147
|
+
function warnUnsupportedComponent(tagName, filePath, line) {
|
|
148
|
+
const { supportedBuiltinComponents: supportedBuiltinComponents2 } = loadReference();
|
|
149
|
+
if (!tagName || supportedBuiltinComponents2.has(tagName) || getViewScriptTags().includes(tagName)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const location = formatLocation(filePath, line);
|
|
153
|
+
warnOnce("component", tagName, location, `[compat] Unsupported or undeclared component: <${tagName}>${location}`);
|
|
154
|
+
}
|
|
155
|
+
function checkTemplateCompatibility(content, filePath, components = {}) {
|
|
156
|
+
let parser;
|
|
157
|
+
parser = new Parser(
|
|
158
|
+
{
|
|
159
|
+
onopentag(tagName) {
|
|
160
|
+
if (components?.[tagName]) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const line = getLineByIndex(content, parser.startIndex);
|
|
164
|
+
warnUnsupportedComponent(tagName, filePath, line);
|
|
165
|
+
},
|
|
166
|
+
onerror(error) {
|
|
167
|
+
console.warn("[compat]", `Failed to parse template for compatibility diagnostics: ${filePath}`, error.message);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
xmlMode: true,
|
|
172
|
+
lowerCaseTags: false,
|
|
173
|
+
lowerCaseAttributeNames: false,
|
|
174
|
+
withStartIndices: true
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
parser.write(content);
|
|
178
|
+
parser.end();
|
|
179
|
+
}
|
|
180
|
+
function getLineByIndex(content, index) {
|
|
181
|
+
if (typeof index !== "number" || index < 0) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
let line = 1;
|
|
185
|
+
for (let i = 0; i < index; i++) {
|
|
186
|
+
if (content.charCodeAt(i) === 10) {
|
|
187
|
+
line++;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return line;
|
|
191
|
+
}
|
|
192
|
+
function formatLocation(filePath, line) {
|
|
193
|
+
if (!filePath) {
|
|
194
|
+
return "";
|
|
195
|
+
}
|
|
196
|
+
return line ? ` (${filePath}:${line})` : ` (${filePath})`;
|
|
197
|
+
}
|
|
198
|
+
function warnOnce(type, name, location, message) {
|
|
199
|
+
const key = `${type}:${name}:${location}`;
|
|
200
|
+
if (warnedItems.has(key)) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
warnedItems.add(key);
|
|
204
|
+
console.warn(message);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export {
|
|
208
|
+
getWxMemberName,
|
|
209
|
+
warnUnsupportedWxApi,
|
|
210
|
+
checkTemplateCompatibility
|
|
211
|
+
};
|