@dimina-kit/compiler 0.0.2-dev.20260718085557 → 0.0.2-dev.20260718095333
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 +1655 -900
- package/dist/compile-core.node-chunks/chunk-6734LXNU.js +1530 -0
- package/dist/compile-core.node-chunks/{chunk-O5CWW2ZX.js → chunk-QVEZ34FP.js} +258 -43
- package/dist/compile-core.node-chunks/{logic-compiler-4BUMLGSW.js → logic-compiler-VJWEQMXZ.js} +14 -14
- package/dist/compile-core.node-chunks/{style-compiler-4F5PSTLH.js → style-compiler-YWVITCJW.js} +60 -49
- package/dist/compile-core.node-chunks/{view-compiler-HHZZFMFQ.js → view-compiler-3OUFRVZF.js} +219 -78
- package/dist/compile-core.node.js +4 -4
- package/dist/pool.node-chunks/{chunk-QLBB5HQB.js → chunk-7F3E2G42.js} +258 -43
- package/dist/pool.node-chunks/chunk-DQNLDQGT.js +1530 -0
- package/dist/pool.node-chunks/{chunk-LVUKEB4F.js → chunk-LKL7FBHG.js} +4 -4
- package/dist/pool.node-chunks/{logic-compiler-PK5DY6DB.js → logic-compiler-HMMTJJWY.js} +14 -14
- package/dist/pool.node-chunks/{style-compiler-X4EGM6MY.js → style-compiler-VGVCLQ7X.js} +60 -49
- package/dist/pool.node-chunks/{view-compiler-4GBP7IAT.js → view-compiler-2VZMJ65O.js} +219 -78
- package/dist/pool.node.js +2 -2
- package/dist/stage-worker.browser.js +1655 -900
- package/dist/stage-worker.node.js +2 -2
- package/package.json +7 -7
- package/dist/compile-core.node-chunks/chunk-3MOLMQLJ.js +0 -211
- package/dist/pool.node-chunks/chunk-S7VHZTMY.js +0 -211
package/dist/compile-core.node-chunks/{style-compiler-4F5PSTLH.js → style-compiler-YWVITCJW.js}
RENAMED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
resetStoreInfo,
|
|
15
15
|
tagWhiteList,
|
|
16
16
|
transformRpx
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-QVEZ34FP.js";
|
|
18
18
|
|
|
19
19
|
// ../../dimina/fe/packages/compiler/src/core/style-compiler.js
|
|
20
20
|
import path from "node:path";
|
|
@@ -61,7 +61,7 @@ if (!isMainThread) {
|
|
|
61
61
|
}
|
|
62
62
|
async function compileSS(pages, root, progress) {
|
|
63
63
|
for (const page of pages) {
|
|
64
|
-
const code = await buildCompileCss(page,
|
|
64
|
+
const code = await buildCompileCss(page, /* @__PURE__ */ new Set()) || "";
|
|
65
65
|
const filename = `${page.path.replace(/\//g, "_")}`;
|
|
66
66
|
if (root) {
|
|
67
67
|
const subDir = `${getTargetPath()}/${root}`;
|
|
@@ -79,33 +79,63 @@ async function compileSS(pages, root, progress) {
|
|
|
79
79
|
progress.completedTasks++;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
async function buildCompileCss(module,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (module.usingComponents) {
|
|
99
|
-
for (const componentInfo of Object.values(module.usingComponents)) {
|
|
100
|
-
const componentModule = getComponent(componentInfo);
|
|
101
|
-
if (!componentModule) {
|
|
102
|
-
continue;
|
|
82
|
+
async function buildCompileCss(module, compiledPaths = /* @__PURE__ */ new Set()) {
|
|
83
|
+
let result = "";
|
|
84
|
+
const pendingModules = [module];
|
|
85
|
+
while (pendingModules.length > 0) {
|
|
86
|
+
const currentModule = pendingModules.pop();
|
|
87
|
+
const currentPath = currentModule.path || currentModule.absolutePath;
|
|
88
|
+
if (compiledPaths.has(currentPath)) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
compiledPaths.add(currentPath);
|
|
92
|
+
result += await enhanceCSS(currentModule) || "";
|
|
93
|
+
const componentPaths = Object.values(currentModule.usingComponents || {});
|
|
94
|
+
for (let index = componentPaths.length - 1; index >= 0; index--) {
|
|
95
|
+
const componentModule = getComponent(componentPaths[index]);
|
|
96
|
+
if (componentModule) {
|
|
97
|
+
pendingModules.push(componentModule);
|
|
103
98
|
}
|
|
104
|
-
result += await buildCompileCss(componentModule, depthChain, compiledPaths) || "";
|
|
105
99
|
}
|
|
106
100
|
}
|
|
107
101
|
return result;
|
|
108
102
|
}
|
|
103
|
+
function boostExternalClassSelectors(cssCode, moduleId) {
|
|
104
|
+
if (!moduleId || !cssCode) {
|
|
105
|
+
return cssCode;
|
|
106
|
+
}
|
|
107
|
+
const scopeAttribute = `data-v-${moduleId}`;
|
|
108
|
+
const externalScopeAttribute = "data-dd-external-class-scope";
|
|
109
|
+
const ast = postcss.parse(cssCode);
|
|
110
|
+
ast.walkRules((rule) => {
|
|
111
|
+
if (!rule.selector.includes(`[${scopeAttribute}]`)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
rule.selector = selectorParser((selectors) => {
|
|
115
|
+
for (const selector of [...selectors.nodes]) {
|
|
116
|
+
const boostedSelector = selector.clone();
|
|
117
|
+
const scopeNodes = [];
|
|
118
|
+
boostedSelector.walkAttributes((attribute) => {
|
|
119
|
+
if (attribute.attribute === scopeAttribute) {
|
|
120
|
+
scopeNodes.push(attribute);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
const targetScope = scopeNodes.at(-1);
|
|
124
|
+
if (!targetScope) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
targetScope.parent.insertAfter(targetScope, selectorParser.attribute({
|
|
128
|
+
attribute: externalScopeAttribute,
|
|
129
|
+
operator: "~=",
|
|
130
|
+
quoteMark: '"',
|
|
131
|
+
value: scopeAttribute
|
|
132
|
+
}));
|
|
133
|
+
selectors.append(boostedSelector);
|
|
134
|
+
}
|
|
135
|
+
}).processSync(rule.selector);
|
|
136
|
+
});
|
|
137
|
+
return ast.toResult().css;
|
|
138
|
+
}
|
|
109
139
|
async function enhanceCSS(module) {
|
|
110
140
|
const absolutePath = module.absolutePath ? module.absolutePath : getAbsolutePath(module.path);
|
|
111
141
|
if (!absolutePath) {
|
|
@@ -153,7 +183,7 @@ async function enhanceCSS(module) {
|
|
|
153
183
|
const str = node.params.replace(/^['"]|['"]$/g, "");
|
|
154
184
|
const importFullPath = resolveStyleImportPath(absolutePath, str);
|
|
155
185
|
node.remove();
|
|
156
|
-
promises.push(buildCompileCss({ absolutePath: importFullPath, id: module.id },
|
|
186
|
+
promises.push(buildCompileCss({ absolutePath: importFullPath, id: module.id }, /* @__PURE__ */ new Set()));
|
|
157
187
|
} else if (node.type === "rule") {
|
|
158
188
|
if (node.selector.includes("::v-deep")) {
|
|
159
189
|
node.selector = node.selector.replace(/::v-deep\s+(\S[^{]*)/g, ":deep($1)");
|
|
@@ -183,11 +213,11 @@ async function enhanceCSS(module) {
|
|
|
183
213
|
id: moduleId,
|
|
184
214
|
scoped: !!moduleId
|
|
185
215
|
}).code;
|
|
186
|
-
const
|
|
216
|
+
const externalClassCode = boostExternalClassSelectors(scopedCode, moduleId);
|
|
187
217
|
const res = await postcss([
|
|
188
218
|
autoprefixer({ overrideBrowserslist: ["cover 99.5%"] }),
|
|
189
219
|
cssnano()
|
|
190
|
-
]).process(
|
|
220
|
+
]).process(externalClassCode, { from: void 0 });
|
|
191
221
|
const importCss = (await Promise.all(promises)).filter(Boolean).join("");
|
|
192
222
|
const result = importCss + res.css;
|
|
193
223
|
compileRes.set(cacheKey, result);
|
|
@@ -234,44 +264,25 @@ function normalizeRootStyleImports(source, workPath = getWorkPath()) {
|
|
|
234
264
|
return `${prefix}${path.join(workPath, importPath)}${suffix}`;
|
|
235
265
|
});
|
|
236
266
|
}
|
|
237
|
-
async function removeBaseComponentScope(css, moduleId) {
|
|
238
|
-
if (!moduleId) return css;
|
|
239
|
-
const ast = postcss.parse(css);
|
|
240
|
-
const scopeAttrName = `data-v-${moduleId}`;
|
|
241
|
-
ast.walkRules((rule) => {
|
|
242
|
-
const hasBaseComponent = tagWhiteList.some(
|
|
243
|
-
(tag) => rule.selector.includes(`.dd-${tag}`)
|
|
244
|
-
);
|
|
245
|
-
if (hasBaseComponent && rule.selector.includes(scopeAttrName)) {
|
|
246
|
-
rule.selector = selectorParser((selectors) => {
|
|
247
|
-
selectors.walkAttributes((attr) => {
|
|
248
|
-
if (attr.attribute === scopeAttrName) {
|
|
249
|
-
attr.remove();
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}).processSync(rule.selector);
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
return ast.toResult().css;
|
|
256
|
-
}
|
|
257
267
|
function ensureImportSemicolons(css) {
|
|
258
268
|
return css.replace(/@import[^;\n]*$/gm, (match) => {
|
|
259
269
|
return match.endsWith(";") ? match : `${match};`;
|
|
260
270
|
});
|
|
261
271
|
}
|
|
262
272
|
function processHostSelector(selector, moduleId) {
|
|
263
|
-
|
|
273
|
+
const hostSelector = `[data-dd-style-host~="${moduleId}"]`;
|
|
274
|
+
return selector.replace(/:host\(([^)]+)\)/g, `${hostSelector}$1`).replace(/:host(?![\w-])/g, hostSelector);
|
|
264
275
|
}
|
|
265
276
|
function __resetStyleState() {
|
|
266
277
|
compileRes.clear();
|
|
267
278
|
}
|
|
268
279
|
export {
|
|
269
280
|
__resetStyleState,
|
|
281
|
+
boostExternalClassSelectors,
|
|
270
282
|
compileSS,
|
|
271
283
|
ensureImportSemicolons,
|
|
272
284
|
normalizeCssUrlValue,
|
|
273
285
|
normalizeRootStyleImports,
|
|
274
286
|
processHostSelector,
|
|
275
|
-
removeBaseComponentScope,
|
|
276
287
|
resolveStyleImportPath
|
|
277
288
|
};
|