@dimina/compiler 1.0.10 → 1.0.11
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/bin/index.cjs +1 -1
- package/dist/bin/index.js +1 -1
- package/dist/core/logic-compiler.cjs +1 -4
- package/dist/core/logic-compiler.js +1 -4
- package/dist/core/style-compiler.cjs +8 -1
- package/dist/core/style-compiler.js +8 -1
- package/dist/core/view-compiler.cjs +168 -4
- package/dist/core/view-compiler.js +168 -4
- package/dist/index.cjs +4 -4
- package/package.json +14 -14
package/dist/bin/index.cjs
CHANGED
package/dist/bin/index.js
CHANGED
|
@@ -50,7 +50,14 @@ if (!node_worker_threads.isMainThread) {
|
|
|
50
50
|
}
|
|
51
51
|
node_worker_threads.parentPort.postMessage({ success: true });
|
|
52
52
|
} catch (error) {
|
|
53
|
-
node_worker_threads.parentPort.postMessage({
|
|
53
|
+
node_worker_threads.parentPort.postMessage({
|
|
54
|
+
success: false,
|
|
55
|
+
error: {
|
|
56
|
+
message: error.message,
|
|
57
|
+
stack: error.stack,
|
|
58
|
+
name: error.name
|
|
59
|
+
}
|
|
60
|
+
});
|
|
54
61
|
}
|
|
55
62
|
});
|
|
56
63
|
}
|
|
@@ -31,7 +31,14 @@ if (!isMainThread) {
|
|
|
31
31
|
}
|
|
32
32
|
parentPort.postMessage({ success: true });
|
|
33
33
|
} catch (error) {
|
|
34
|
-
parentPort.postMessage({
|
|
34
|
+
parentPort.postMessage({
|
|
35
|
+
success: false,
|
|
36
|
+
error: {
|
|
37
|
+
message: error.message,
|
|
38
|
+
stack: error.stack,
|
|
39
|
+
name: error.name
|
|
40
|
+
}
|
|
41
|
+
});
|
|
35
42
|
}
|
|
36
43
|
});
|
|
37
44
|
}
|
|
@@ -29,6 +29,112 @@ function _interopNamespaceDefault(e) {
|
|
|
29
29
|
}
|
|
30
30
|
const cheerio__namespace = /* @__PURE__ */ _interopNamespaceDefault(cheerio);
|
|
31
31
|
const htmlparser2__namespace = /* @__PURE__ */ _interopNamespaceDefault(htmlparser2);
|
|
32
|
+
const traverse$1 = _traverse.default ? _traverse.default : _traverse;
|
|
33
|
+
const KEYWORDS = /* @__PURE__ */ new Set([
|
|
34
|
+
"true",
|
|
35
|
+
"false",
|
|
36
|
+
"null",
|
|
37
|
+
"undefined",
|
|
38
|
+
"NaN",
|
|
39
|
+
"Infinity",
|
|
40
|
+
"this",
|
|
41
|
+
"arguments",
|
|
42
|
+
"Array",
|
|
43
|
+
"Object",
|
|
44
|
+
"String",
|
|
45
|
+
"Number",
|
|
46
|
+
"Boolean",
|
|
47
|
+
"Math",
|
|
48
|
+
"Date",
|
|
49
|
+
"RegExp",
|
|
50
|
+
"Error",
|
|
51
|
+
"JSON",
|
|
52
|
+
"console",
|
|
53
|
+
"window",
|
|
54
|
+
"document",
|
|
55
|
+
"parseInt",
|
|
56
|
+
"parseFloat",
|
|
57
|
+
"isNaN",
|
|
58
|
+
"isFinite",
|
|
59
|
+
"encodeURI",
|
|
60
|
+
"encodeURIComponent",
|
|
61
|
+
"decodeURI",
|
|
62
|
+
"decodeURIComponent"
|
|
63
|
+
]);
|
|
64
|
+
function extractDependencies(expression) {
|
|
65
|
+
if (!expression || typeof expression !== "string") {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
69
|
+
try {
|
|
70
|
+
const code = `(${expression})`;
|
|
71
|
+
const ast = babel.parseSync(code, {
|
|
72
|
+
sourceType: "module",
|
|
73
|
+
plugins: []
|
|
74
|
+
});
|
|
75
|
+
traverse$1(ast, {
|
|
76
|
+
Identifier(path2) {
|
|
77
|
+
const name = path2.node.name;
|
|
78
|
+
if (KEYWORDS.has(name)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const parent = path2.parent;
|
|
82
|
+
if (parent.type === "MemberExpression" && parent.property === path2.node && !parent.computed) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (parent.type === "CallExpression" && parent.callee === path2.node) {
|
|
86
|
+
dependencies.add(name);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (parent.type === "ObjectProperty" && parent.key === path2.node && !parent.computed) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
dependencies.add(name);
|
|
93
|
+
},
|
|
94
|
+
// 处理成员表达式,确保只提取根对象
|
|
95
|
+
MemberExpression(path2) {
|
|
96
|
+
let root = path2.node.object;
|
|
97
|
+
while (root.type === "MemberExpression") {
|
|
98
|
+
root = root.object;
|
|
99
|
+
}
|
|
100
|
+
if (root.type === "Identifier" && !KEYWORDS.has(root.name)) {
|
|
101
|
+
dependencies.add(root.name);
|
|
102
|
+
}
|
|
103
|
+
path2.skip();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.warn("[expression-parser] AST 解析失败,表达式:", expression, "错误:", error.message);
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
return Array.from(dependencies);
|
|
111
|
+
}
|
|
112
|
+
function parseExpression(expression) {
|
|
113
|
+
if (!expression || typeof expression !== "string") {
|
|
114
|
+
return {
|
|
115
|
+
expression: "",
|
|
116
|
+
dependencies: [],
|
|
117
|
+
isSimple: true
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const dependencies = extractDependencies(expression);
|
|
121
|
+
const isSimple = dependencies.length === 1 && expression.trim() === dependencies[0];
|
|
122
|
+
return {
|
|
123
|
+
expression: expression.trim(),
|
|
124
|
+
dependencies,
|
|
125
|
+
isSimple
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function parseBindings(bindings) {
|
|
129
|
+
if (!bindings || typeof bindings !== "object") {
|
|
130
|
+
return {};
|
|
131
|
+
}
|
|
132
|
+
const parsed = {};
|
|
133
|
+
for (const [propName, expression] of Object.entries(bindings)) {
|
|
134
|
+
parsed[propName] = parseExpression(expression);
|
|
135
|
+
}
|
|
136
|
+
return parsed;
|
|
137
|
+
}
|
|
32
138
|
const traverse = _traverse.default ? _traverse.default : _traverse;
|
|
33
139
|
const fileType = [".wxml", ".ddml"];
|
|
34
140
|
const compileResCache = /* @__PURE__ */ new Map();
|
|
@@ -54,7 +160,14 @@ if (!node_worker_threads.isMainThread) {
|
|
|
54
160
|
}
|
|
55
161
|
node_worker_threads.parentPort.postMessage({ success: true });
|
|
56
162
|
} catch (error) {
|
|
57
|
-
node_worker_threads.parentPort.postMessage({
|
|
163
|
+
node_worker_threads.parentPort.postMessage({
|
|
164
|
+
success: false,
|
|
165
|
+
error: {
|
|
166
|
+
message: error.message,
|
|
167
|
+
stack: error.stack,
|
|
168
|
+
name: error.name
|
|
169
|
+
}
|
|
170
|
+
});
|
|
58
171
|
}
|
|
59
172
|
});
|
|
60
173
|
}
|
|
@@ -488,6 +601,31 @@ function compileModuleWithAllWxs(module2, scriptRes, allScriptModules) {
|
|
|
488
601
|
compileResCache.set(module2.path, cacheData);
|
|
489
602
|
scriptRes.set(module2.path, code);
|
|
490
603
|
}
|
|
604
|
+
function processIncludeConditionalAttrs($, elem, includeContent) {
|
|
605
|
+
const allAttrs = $(elem).attr();
|
|
606
|
+
const conditionAttrs = {};
|
|
607
|
+
let hasCondition = false;
|
|
608
|
+
for (const attrName in allAttrs) {
|
|
609
|
+
if (attrName.endsWith(":if") || attrName.endsWith(":elif") || attrName.endsWith(":else")) {
|
|
610
|
+
conditionAttrs[attrName] = allAttrs[attrName];
|
|
611
|
+
hasCondition = true;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
if (hasCondition) {
|
|
615
|
+
let blockAttrs = "";
|
|
616
|
+
for (const attrName in conditionAttrs) {
|
|
617
|
+
const attrValue = conditionAttrs[attrName];
|
|
618
|
+
if (attrValue !== void 0 && attrValue !== "") {
|
|
619
|
+
blockAttrs += ` ${attrName}="${attrValue}"`;
|
|
620
|
+
} else {
|
|
621
|
+
blockAttrs += ` ${attrName}`;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return `<block${blockAttrs}>${includeContent}</block>`;
|
|
625
|
+
} else {
|
|
626
|
+
return includeContent;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
491
629
|
function processIncludedFileWxsDependencies(content, includePath, scriptModule, components, processedPaths = /* @__PURE__ */ new Set()) {
|
|
492
630
|
if (processedPaths.has(includePath)) {
|
|
493
631
|
return;
|
|
@@ -581,7 +719,8 @@ function toCompileTemplate(isComponent, path2, components, componentPlaceholder,
|
|
|
581
719
|
$includeContent("template").remove();
|
|
582
720
|
$includeContent("wxs").remove();
|
|
583
721
|
$includeContent("dds").remove();
|
|
584
|
-
|
|
722
|
+
const processedContent = processIncludeConditionalAttrs($, elem, $includeContent.html());
|
|
723
|
+
$(elem).replaceWith(processedContent);
|
|
585
724
|
} else {
|
|
586
725
|
$(elem).remove();
|
|
587
726
|
}
|
|
@@ -698,7 +837,7 @@ function transTag(opts) {
|
|
|
698
837
|
res = `dd-${tag}`;
|
|
699
838
|
}
|
|
700
839
|
let tagRes;
|
|
701
|
-
const propsAry = isStart ? getProps(attrs, tag) : [];
|
|
840
|
+
const propsAry = isStart ? getProps(attrs, tag, components) : [];
|
|
702
841
|
const multipleSlots = attrs?.slot;
|
|
703
842
|
if (attrs?.slot) {
|
|
704
843
|
const isDynamicSlot = isWrappedByBraces(multipleSlots);
|
|
@@ -746,8 +885,9 @@ function generateSlotDirective(slotValue) {
|
|
|
746
885
|
return `#${slotValue}`;
|
|
747
886
|
}
|
|
748
887
|
}
|
|
749
|
-
function getProps(attrs, tag) {
|
|
888
|
+
function getProps(attrs, tag, components) {
|
|
750
889
|
const attrsList = [];
|
|
890
|
+
const propBindings = {};
|
|
751
891
|
Object.entries(attrs).forEach(([name, value]) => {
|
|
752
892
|
if (name.endsWith(":if")) {
|
|
753
893
|
attrsList.push({
|
|
@@ -846,6 +986,11 @@ function getProps(attrs, tag) {
|
|
|
846
986
|
if (tag === "template" && name === "data") {
|
|
847
987
|
pVal = `{${pVal}}`;
|
|
848
988
|
}
|
|
989
|
+
if (components && components[tag]) {
|
|
990
|
+
if (pVal && typeof pVal === "string") {
|
|
991
|
+
propBindings[name] = pVal;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
849
994
|
attrsList.push({
|
|
850
995
|
name: `:${name}`,
|
|
851
996
|
value: pVal
|
|
@@ -868,6 +1013,24 @@ function getProps(attrs, tag) {
|
|
|
868
1013
|
propsRes.push(`${name}="${escapeQuotes(value)}"`);
|
|
869
1014
|
}
|
|
870
1015
|
});
|
|
1016
|
+
if (components && components[tag] && Object.keys(propBindings).length > 0) {
|
|
1017
|
+
try {
|
|
1018
|
+
const validBindings = {};
|
|
1019
|
+
for (const [key, value] of Object.entries(propBindings)) {
|
|
1020
|
+
if (value !== void 0 && value !== null && typeof value === "string") {
|
|
1021
|
+
validBindings[key] = value;
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
if (Object.keys(validBindings).length > 0) {
|
|
1025
|
+
const parsedBindings = parseBindings(validBindings);
|
|
1026
|
+
const bindingsJson = JSON.stringify(parsedBindings);
|
|
1027
|
+
const escapedJson = bindingsJson.replace(/"/g, """);
|
|
1028
|
+
propsRes.push(`v-c-prop-bindings="${escapedJson}"`);
|
|
1029
|
+
}
|
|
1030
|
+
} catch (error) {
|
|
1031
|
+
console.warn("[compiler] 序列化 propBindings 失败:", error.message, "标签:", tag, "绑定数据:", propBindings);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
871
1034
|
return propsRes;
|
|
872
1035
|
}
|
|
873
1036
|
function generateVModelTemplate(expression) {
|
|
@@ -1192,5 +1355,6 @@ exports.generateVModelTemplate = generateVModelTemplate;
|
|
|
1192
1355
|
exports.parseBraceExp = parseBraceExp;
|
|
1193
1356
|
exports.parseClassRules = parseClassRules;
|
|
1194
1357
|
exports.parseKeyExpression = parseKeyExpression;
|
|
1358
|
+
exports.processIncludeConditionalAttrs = processIncludeConditionalAttrs;
|
|
1195
1359
|
exports.processWxsContent = processWxsContent;
|
|
1196
1360
|
exports.splitWithBraces = splitWithBraces;
|
|
@@ -9,6 +9,112 @@ import * as cheerio from "cheerio";
|
|
|
9
9
|
import { transform } from "esbuild";
|
|
10
10
|
import * as htmlparser2 from "htmlparser2";
|
|
11
11
|
import { r as resetStoreInfo, g as getTargetPath, a as getComponent, b as getContentByPath, c as getAbsolutePath, d as getWorkPath, e as collectAssets, f as getAppId, t as transformRpx, h as tagWhiteList } from "../env-Csj3AHY4.js";
|
|
12
|
+
const traverse$1 = _traverse.default ? _traverse.default : _traverse;
|
|
13
|
+
const KEYWORDS = /* @__PURE__ */ new Set([
|
|
14
|
+
"true",
|
|
15
|
+
"false",
|
|
16
|
+
"null",
|
|
17
|
+
"undefined",
|
|
18
|
+
"NaN",
|
|
19
|
+
"Infinity",
|
|
20
|
+
"this",
|
|
21
|
+
"arguments",
|
|
22
|
+
"Array",
|
|
23
|
+
"Object",
|
|
24
|
+
"String",
|
|
25
|
+
"Number",
|
|
26
|
+
"Boolean",
|
|
27
|
+
"Math",
|
|
28
|
+
"Date",
|
|
29
|
+
"RegExp",
|
|
30
|
+
"Error",
|
|
31
|
+
"JSON",
|
|
32
|
+
"console",
|
|
33
|
+
"window",
|
|
34
|
+
"document",
|
|
35
|
+
"parseInt",
|
|
36
|
+
"parseFloat",
|
|
37
|
+
"isNaN",
|
|
38
|
+
"isFinite",
|
|
39
|
+
"encodeURI",
|
|
40
|
+
"encodeURIComponent",
|
|
41
|
+
"decodeURI",
|
|
42
|
+
"decodeURIComponent"
|
|
43
|
+
]);
|
|
44
|
+
function extractDependencies(expression) {
|
|
45
|
+
if (!expression || typeof expression !== "string") {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
49
|
+
try {
|
|
50
|
+
const code = `(${expression})`;
|
|
51
|
+
const ast = babel.parseSync(code, {
|
|
52
|
+
sourceType: "module",
|
|
53
|
+
plugins: []
|
|
54
|
+
});
|
|
55
|
+
traverse$1(ast, {
|
|
56
|
+
Identifier(path2) {
|
|
57
|
+
const name = path2.node.name;
|
|
58
|
+
if (KEYWORDS.has(name)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const parent = path2.parent;
|
|
62
|
+
if (parent.type === "MemberExpression" && parent.property === path2.node && !parent.computed) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (parent.type === "CallExpression" && parent.callee === path2.node) {
|
|
66
|
+
dependencies.add(name);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (parent.type === "ObjectProperty" && parent.key === path2.node && !parent.computed) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
dependencies.add(name);
|
|
73
|
+
},
|
|
74
|
+
// 处理成员表达式,确保只提取根对象
|
|
75
|
+
MemberExpression(path2) {
|
|
76
|
+
let root = path2.node.object;
|
|
77
|
+
while (root.type === "MemberExpression") {
|
|
78
|
+
root = root.object;
|
|
79
|
+
}
|
|
80
|
+
if (root.type === "Identifier" && !KEYWORDS.has(root.name)) {
|
|
81
|
+
dependencies.add(root.name);
|
|
82
|
+
}
|
|
83
|
+
path2.skip();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.warn("[expression-parser] AST 解析失败,表达式:", expression, "错误:", error.message);
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
return Array.from(dependencies);
|
|
91
|
+
}
|
|
92
|
+
function parseExpression(expression) {
|
|
93
|
+
if (!expression || typeof expression !== "string") {
|
|
94
|
+
return {
|
|
95
|
+
expression: "",
|
|
96
|
+
dependencies: [],
|
|
97
|
+
isSimple: true
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const dependencies = extractDependencies(expression);
|
|
101
|
+
const isSimple = dependencies.length === 1 && expression.trim() === dependencies[0];
|
|
102
|
+
return {
|
|
103
|
+
expression: expression.trim(),
|
|
104
|
+
dependencies,
|
|
105
|
+
isSimple
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function parseBindings(bindings) {
|
|
109
|
+
if (!bindings || typeof bindings !== "object") {
|
|
110
|
+
return {};
|
|
111
|
+
}
|
|
112
|
+
const parsed = {};
|
|
113
|
+
for (const [propName, expression] of Object.entries(bindings)) {
|
|
114
|
+
parsed[propName] = parseExpression(expression);
|
|
115
|
+
}
|
|
116
|
+
return parsed;
|
|
117
|
+
}
|
|
12
118
|
const traverse = _traverse.default ? _traverse.default : _traverse;
|
|
13
119
|
const fileType = [".wxml", ".ddml"];
|
|
14
120
|
const compileResCache = /* @__PURE__ */ new Map();
|
|
@@ -34,7 +140,14 @@ if (!isMainThread) {
|
|
|
34
140
|
}
|
|
35
141
|
parentPort.postMessage({ success: true });
|
|
36
142
|
} catch (error) {
|
|
37
|
-
parentPort.postMessage({
|
|
143
|
+
parentPort.postMessage({
|
|
144
|
+
success: false,
|
|
145
|
+
error: {
|
|
146
|
+
message: error.message,
|
|
147
|
+
stack: error.stack,
|
|
148
|
+
name: error.name
|
|
149
|
+
}
|
|
150
|
+
});
|
|
38
151
|
}
|
|
39
152
|
});
|
|
40
153
|
}
|
|
@@ -468,6 +581,31 @@ function compileModuleWithAllWxs(module, scriptRes, allScriptModules) {
|
|
|
468
581
|
compileResCache.set(module.path, cacheData);
|
|
469
582
|
scriptRes.set(module.path, code);
|
|
470
583
|
}
|
|
584
|
+
function processIncludeConditionalAttrs($, elem, includeContent) {
|
|
585
|
+
const allAttrs = $(elem).attr();
|
|
586
|
+
const conditionAttrs = {};
|
|
587
|
+
let hasCondition = false;
|
|
588
|
+
for (const attrName in allAttrs) {
|
|
589
|
+
if (attrName.endsWith(":if") || attrName.endsWith(":elif") || attrName.endsWith(":else")) {
|
|
590
|
+
conditionAttrs[attrName] = allAttrs[attrName];
|
|
591
|
+
hasCondition = true;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (hasCondition) {
|
|
595
|
+
let blockAttrs = "";
|
|
596
|
+
for (const attrName in conditionAttrs) {
|
|
597
|
+
const attrValue = conditionAttrs[attrName];
|
|
598
|
+
if (attrValue !== void 0 && attrValue !== "") {
|
|
599
|
+
blockAttrs += ` ${attrName}="${attrValue}"`;
|
|
600
|
+
} else {
|
|
601
|
+
blockAttrs += ` ${attrName}`;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
return `<block${blockAttrs}>${includeContent}</block>`;
|
|
605
|
+
} else {
|
|
606
|
+
return includeContent;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
471
609
|
function processIncludedFileWxsDependencies(content, includePath, scriptModule, components, processedPaths = /* @__PURE__ */ new Set()) {
|
|
472
610
|
if (processedPaths.has(includePath)) {
|
|
473
611
|
return;
|
|
@@ -561,7 +699,8 @@ function toCompileTemplate(isComponent, path2, components, componentPlaceholder,
|
|
|
561
699
|
$includeContent("template").remove();
|
|
562
700
|
$includeContent("wxs").remove();
|
|
563
701
|
$includeContent("dds").remove();
|
|
564
|
-
|
|
702
|
+
const processedContent = processIncludeConditionalAttrs($, elem, $includeContent.html());
|
|
703
|
+
$(elem).replaceWith(processedContent);
|
|
565
704
|
} else {
|
|
566
705
|
$(elem).remove();
|
|
567
706
|
}
|
|
@@ -678,7 +817,7 @@ function transTag(opts) {
|
|
|
678
817
|
res = `dd-${tag}`;
|
|
679
818
|
}
|
|
680
819
|
let tagRes;
|
|
681
|
-
const propsAry = isStart ? getProps(attrs, tag) : [];
|
|
820
|
+
const propsAry = isStart ? getProps(attrs, tag, components) : [];
|
|
682
821
|
const multipleSlots = attrs?.slot;
|
|
683
822
|
if (attrs?.slot) {
|
|
684
823
|
const isDynamicSlot = isWrappedByBraces(multipleSlots);
|
|
@@ -726,8 +865,9 @@ function generateSlotDirective(slotValue) {
|
|
|
726
865
|
return `#${slotValue}`;
|
|
727
866
|
}
|
|
728
867
|
}
|
|
729
|
-
function getProps(attrs, tag) {
|
|
868
|
+
function getProps(attrs, tag, components) {
|
|
730
869
|
const attrsList = [];
|
|
870
|
+
const propBindings = {};
|
|
731
871
|
Object.entries(attrs).forEach(([name, value]) => {
|
|
732
872
|
if (name.endsWith(":if")) {
|
|
733
873
|
attrsList.push({
|
|
@@ -826,6 +966,11 @@ function getProps(attrs, tag) {
|
|
|
826
966
|
if (tag === "template" && name === "data") {
|
|
827
967
|
pVal = `{${pVal}}`;
|
|
828
968
|
}
|
|
969
|
+
if (components && components[tag]) {
|
|
970
|
+
if (pVal && typeof pVal === "string") {
|
|
971
|
+
propBindings[name] = pVal;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
829
974
|
attrsList.push({
|
|
830
975
|
name: `:${name}`,
|
|
831
976
|
value: pVal
|
|
@@ -848,6 +993,24 @@ function getProps(attrs, tag) {
|
|
|
848
993
|
propsRes.push(`${name}="${escapeQuotes(value)}"`);
|
|
849
994
|
}
|
|
850
995
|
});
|
|
996
|
+
if (components && components[tag] && Object.keys(propBindings).length > 0) {
|
|
997
|
+
try {
|
|
998
|
+
const validBindings = {};
|
|
999
|
+
for (const [key, value] of Object.entries(propBindings)) {
|
|
1000
|
+
if (value !== void 0 && value !== null && typeof value === "string") {
|
|
1001
|
+
validBindings[key] = value;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
if (Object.keys(validBindings).length > 0) {
|
|
1005
|
+
const parsedBindings = parseBindings(validBindings);
|
|
1006
|
+
const bindingsJson = JSON.stringify(parsedBindings);
|
|
1007
|
+
const escapedJson = bindingsJson.replace(/"/g, """);
|
|
1008
|
+
propsRes.push(`v-c-prop-bindings="${escapedJson}"`);
|
|
1009
|
+
}
|
|
1010
|
+
} catch (error) {
|
|
1011
|
+
console.warn("[compiler] 序列化 propBindings 失败:", error.message, "标签:", tag, "绑定数据:", propBindings);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
851
1014
|
return propsRes;
|
|
852
1015
|
}
|
|
853
1016
|
function generateVModelTemplate(expression) {
|
|
@@ -1173,6 +1336,7 @@ export {
|
|
|
1173
1336
|
parseBraceExp,
|
|
1174
1337
|
parseClassRules,
|
|
1175
1338
|
parseKeyExpression,
|
|
1339
|
+
processIncludeConditionalAttrs,
|
|
1176
1340
|
processWxsContent,
|
|
1177
1341
|
splitWithBraces
|
|
1178
1342
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@ const fs = require("node:fs");
|
|
|
8
8
|
const env = require("./env-Cmen1qwy.cjs");
|
|
9
9
|
const os = require("node:os");
|
|
10
10
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
11
|
-
const artCode = `
|
|
11
|
+
const artCode$1 = `
|
|
12
12
|
██████╗ ██╗███╗ ███╗██╗███╗ ██╗ █████╗
|
|
13
13
|
██╔══██╗██║████╗ ████║██║████╗ ██║██╔══██╗
|
|
14
14
|
██║ ██║██║██╔████╔██║██║██╔██╗ ██║███████║
|
|
@@ -16,8 +16,8 @@ const artCode = `
|
|
|
16
16
|
██████╔╝██║██║ ╚═╝ ██║██║██║ ╚████║██║ ██║
|
|
17
17
|
╚═════╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝
|
|
18
18
|
`;
|
|
19
|
-
function artCode
|
|
20
|
-
console.log(artCode);
|
|
19
|
+
function artCode() {
|
|
20
|
+
console.log(artCode$1);
|
|
21
21
|
}
|
|
22
22
|
function createDist() {
|
|
23
23
|
const distPath = env.getTargetPath();
|
|
@@ -317,7 +317,7 @@ function compileConfig() {
|
|
|
317
317
|
let isPrinted = false;
|
|
318
318
|
async function build(targetPath, workPath, useAppIdDir = true) {
|
|
319
319
|
if (!isPrinted) {
|
|
320
|
-
artCode
|
|
320
|
+
artCode();
|
|
321
321
|
isPrinted = true;
|
|
322
322
|
}
|
|
323
323
|
const tasks = new listr2.Listr(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimina/compiler",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "星河编译工具",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -45,24 +45,24 @@
|
|
|
45
45
|
"星河"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@babel/core": "^7.28.
|
|
48
|
+
"@babel/core": "^7.28.5",
|
|
49
49
|
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
|
|
50
|
-
"@babel/traverse": "^7.28.
|
|
51
|
-
"@babel/types": "^7.28.
|
|
52
|
-
"@vue/compiler-sfc": "^3.5.
|
|
53
|
-
"autoprefixer": "^10.4.
|
|
50
|
+
"@babel/traverse": "^7.28.5",
|
|
51
|
+
"@babel/types": "^7.28.5",
|
|
52
|
+
"@vue/compiler-sfc": "^3.5.25",
|
|
53
|
+
"autoprefixer": "^10.4.22",
|
|
54
54
|
"cheerio": "^1.1.2",
|
|
55
55
|
"chokidar": "^4.0.3",
|
|
56
|
-
"commander": "^14.0.
|
|
57
|
-
"cssnano": "^7.1.
|
|
58
|
-
"esbuild": "^0.25.
|
|
56
|
+
"commander": "^14.0.2",
|
|
57
|
+
"cssnano": "^7.1.2",
|
|
58
|
+
"esbuild": "^0.25.12",
|
|
59
59
|
"htmlparser2": "^10.0.0",
|
|
60
|
-
"less": "^4.4.
|
|
61
|
-
"listr2": "^9.0.
|
|
60
|
+
"less": "^4.4.2",
|
|
61
|
+
"listr2": "^9.0.5",
|
|
62
62
|
"postcss": "^8.5.6",
|
|
63
|
-
"postcss-selector-parser": "^7.1.
|
|
64
|
-
"sass": "^1.
|
|
65
|
-
"typescript": "^5.9.
|
|
63
|
+
"postcss-selector-parser": "^7.1.1",
|
|
64
|
+
"sass": "^1.95.1",
|
|
65
|
+
"typescript": "^5.9.3"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org/"
|