@dimina-kit/compiler 0.0.2-dev.20260728080958 → 0.0.2-dev.20260728110120

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.
Files changed (25) hide show
  1. package/dist/compile-core.browser.js +14975 -16294
  2. package/dist/compile-core.node-chunks/chunk-2VRS523Z.js +8 -0
  3. package/dist/compile-core.node-chunks/chunk-LUD2P6RM.js +211 -0
  4. package/dist/compile-core.node-chunks/{chunk-M62ZDT7T.js → chunk-QJ34C5KK.js} +66 -542
  5. package/dist/compile-core.node-chunks/{logic-compiler-AEZPY2MO.js → logic-compiler-2SQFOFEO.js} +113 -37
  6. package/dist/compile-core.node-chunks/style-compiler-ZEJ3XLTS.js +277 -0
  7. package/dist/compile-core.node-chunks/{view-compiler-2SMUHAPD.js → view-compiler-WQNV7H5G.js} +161 -425
  8. package/dist/compile-core.node.js +6 -11
  9. package/dist/pool.node-chunks/{chunk-CKQISGZS.js → chunk-7FGOYOXU.js} +66 -542
  10. package/dist/pool.node-chunks/chunk-C7GEIDCP.js +211 -0
  11. package/dist/pool.node-chunks/chunk-KLXXOLDF.js +8 -0
  12. package/dist/pool.node-chunks/{chunk-WX4462A5.js → chunk-PDHO4Y56.js} +6 -11
  13. package/dist/pool.node-chunks/{logic-compiler-P4T4OMTG.js → logic-compiler-BODAINZQ.js} +113 -37
  14. package/dist/pool.node-chunks/style-compiler-TUNDVSR5.js +277 -0
  15. package/dist/pool.node-chunks/{view-compiler-2D7HPYIN.js → view-compiler-HOFFL63K.js} +161 -425
  16. package/dist/pool.node.js +2 -2
  17. package/dist/stage-worker.browser.js +2156 -3475
  18. package/dist/stage-worker.node.js +2 -2
  19. package/package.json +4 -4
  20. package/dist/compile-core.node-chunks/chunk-23PCGQQU.js +0 -141
  21. package/dist/compile-core.node-chunks/chunk-QYHGF3MS.js +0 -1601
  22. package/dist/compile-core.node-chunks/style-compiler-4PHMBQIC.js +0 -470
  23. package/dist/pool.node-chunks/chunk-LGB3AH5C.js +0 -1601
  24. package/dist/pool.node-chunks/chunk-VHWKAXDL.js +0 -141
  25. package/dist/pool.node-chunks/style-compiler-W7EA2Y7R.js +0 -470
@@ -1,141 +0,0 @@
1
- // src/shims/worker_threads.js
2
- var isMainThread = true;
3
- var parentPort = null;
4
-
5
- // ../../dimina/fe/packages/compiler/src/core/sourcemap.js
6
- import { SourceMapConsumer, SourceMapGenerator } from "source-map-js";
7
- function wrapModDefine(module) {
8
- const code = module.code.endsWith("\n") ? module.code : module.code + "\n";
9
- const extraLine = module.extraInfoCode || "";
10
- const header = `modDefine('${module.path}', function(require, module, exports) {
11
- ${extraLine}`;
12
- const footer = "});\n";
13
- return { header, code, footer };
14
- }
15
- function appendSourceMap(smg, map, lineOffset, columnOffset) {
16
- const mapObject = typeof map === "string" ? JSON.parse(map) : map;
17
- const consumer = new SourceMapConsumer(mapObject);
18
- consumer.eachMapping((mapping) => {
19
- if (mapping.source == null || mapping.originalLine == null || mapping.originalColumn == null) {
20
- return;
21
- }
22
- smg.addMapping({
23
- generated: {
24
- line: mapping.generatedLine + lineOffset,
25
- column: mapping.generatedColumn + (mapping.generatedLine === 1 ? columnOffset : 0)
26
- },
27
- original: {
28
- line: mapping.originalLine,
29
- column: mapping.originalColumn
30
- },
31
- source: mapping.source,
32
- name: mapping.name
33
- });
34
- });
35
- if (mapObject.sourcesContent) {
36
- mapObject.sources.forEach((source, index) => {
37
- smg.setSourceContent(source, mapObject.sourcesContent[index]);
38
- });
39
- }
40
- }
41
- function advanceGeneratedPosition(position, code) {
42
- const lines = code.split("\n");
43
- if (lines.length === 1) {
44
- position.column += code.length;
45
- return;
46
- }
47
- position.line += lines.length - 1;
48
- position.column = lines.at(-1).length;
49
- }
50
- function concatSourcemap(chunks, file = "") {
51
- const smg = new SourceMapGenerator({ file });
52
- const position = { line: 1, column: 0 };
53
- let code = "";
54
- for (const chunk of chunks) {
55
- const chunkCode = typeof chunk === "string" ? chunk : chunk.code;
56
- if (typeof chunk !== "string" && chunk.map) {
57
- appendSourceMap(smg, chunk.map, position.line - 1, position.column);
58
- }
59
- code += chunkCode;
60
- advanceGeneratedPosition(position, chunkCode);
61
- }
62
- return { code, sourcemap: smg.toString() };
63
- }
64
- function createLineSourcemap(generatedCode, source, sourceContent, startLine = 1) {
65
- const smg = new SourceMapGenerator({ file: source });
66
- const generatedLineCount = generatedCode.split("\n").length;
67
- const sourceLineCount = Math.max(1, sourceContent.split("\n").length);
68
- for (let line = 1; line <= generatedLineCount; line++) {
69
- smg.addMapping({
70
- generated: { line, column: 0 },
71
- original: {
72
- line: Math.min(sourceLineCount, startLine + line - 1),
73
- column: 0
74
- },
75
- source
76
- });
77
- }
78
- smg.setSourceContent(source, sourceContent);
79
- return JSON.parse(smg.toString());
80
- }
81
- function mergeSourcemap(compileRes, file = "logic.js") {
82
- const chunks = [];
83
- for (const module of compileRes) {
84
- const { header, code, footer } = wrapModDefine(module);
85
- chunks.push(header, { code, map: module.map }, footer);
86
- }
87
- const { code: bundleCode, sourcemap } = concatSourcemap(chunks, file);
88
- return { bundleCode, sourcemap };
89
- }
90
- function remapSourcemap(nextMap, prevMap) {
91
- if (!nextMap) {
92
- return prevMap;
93
- }
94
- if (!prevMap) {
95
- return nextMap;
96
- }
97
- const nextMapObj = typeof nextMap === "string" ? JSON.parse(nextMap) : nextMap;
98
- const prevMapObj = typeof prevMap === "string" ? JSON.parse(prevMap) : prevMap;
99
- const smg = new SourceMapGenerator({ file: nextMapObj.file || prevMapObj.file || "" });
100
- const prevSmc = new SourceMapConsumer(prevMapObj);
101
- const nextSmc = new SourceMapConsumer(nextMapObj);
102
- nextSmc.eachMapping((mapping) => {
103
- if (mapping.source == null || mapping.originalLine == null || mapping.originalColumn == null) {
104
- return;
105
- }
106
- const original = prevSmc.originalPositionFor({
107
- line: mapping.originalLine,
108
- column: mapping.originalColumn
109
- });
110
- if (original.source == null || original.line == null || original.column == null) {
111
- return;
112
- }
113
- smg.addMapping({
114
- generated: {
115
- line: mapping.generatedLine,
116
- column: mapping.generatedColumn
117
- },
118
- original: {
119
- line: original.line,
120
- column: original.column
121
- },
122
- source: original.source,
123
- name: original.name || mapping.name
124
- });
125
- });
126
- if (prevMapObj.sourcesContent) {
127
- prevMapObj.sources.forEach((src, i) => {
128
- smg.setSourceContent(src, prevMapObj.sourcesContent[i]);
129
- });
130
- }
131
- return smg.toString();
132
- }
133
-
134
- export {
135
- isMainThread,
136
- parentPort,
137
- concatSourcemap,
138
- createLineSourcemap,
139
- mergeSourcemap,
140
- remapSourcemap
141
- };
@@ -1,470 +0,0 @@
1
- import {
2
- concatSourcemap,
3
- createLineSourcemap,
4
- isMainThread,
5
- parentPort,
6
- remapSourcemap
7
- } from "./chunk-VHWKAXDL.js";
8
- import {
9
- collectAssets,
10
- getAppId,
11
- getComponent,
12
- getContentByPath,
13
- getDependencyGraph,
14
- getStyleExts,
15
- getTargetPath,
16
- getWorkPath,
17
- resetStoreInfo,
18
- resolveAssetSourcePath,
19
- tagWhiteList,
20
- transformRpx
21
- } from "./chunk-CKQISGZS.js";
22
-
23
- // ../../dimina/fe/packages/compiler/src/core/style-compiler.js
24
- import fs from "node:fs";
25
- import path from "node:path";
26
- import { fileURLToPath, pathToFileURL } from "node:url";
27
- import { compileStyle } from "@vue/compiler-sfc";
28
- import autoprefixer from "autoprefixer";
29
- import cssnano from "cssnano";
30
- import less from "less";
31
- import postcss from "postcss";
32
- import selectorParser from "postcss-selector-parser";
33
- import * as sass from "sass";
34
- var compileRes = /* @__PURE__ */ new Map();
35
- if (!isMainThread) {
36
- parentPort.on("message", async ({ pages, storeInfo, sourcemap }) => {
37
- try {
38
- resetStoreInfo(storeInfo);
39
- const progress = {
40
- _completedTasks: 0,
41
- get completedTasks() {
42
- return this._completedTasks;
43
- },
44
- set completedTasks(value) {
45
- this._completedTasks = value;
46
- parentPort.postMessage({ completedTasks: this._completedTasks });
47
- }
48
- };
49
- await compileSS(pages.mainPages, null, progress, { sourcemap });
50
- for (const [root, subPages] of Object.entries(pages.subPages)) {
51
- await compileSS(subPages.info, root, progress, { sourcemap });
52
- }
53
- compileRes.clear();
54
- parentPort.postMessage({
55
- success: true,
56
- dependencyGraph: getDependencyGraph().toJSON()
57
- });
58
- } catch (error) {
59
- compileRes.clear();
60
- parentPort.postMessage({
61
- success: false,
62
- error: {
63
- message: error.message,
64
- stack: error.stack,
65
- name: error.name,
66
- file: error.file,
67
- line: error.line,
68
- column: error.column,
69
- stage: error.stage
70
- }
71
- });
72
- }
73
- });
74
- }
75
- async function compileSS(pages, root, progress, options = {}) {
76
- for (const page of pages) {
77
- const result = await buildCompileCss(page, /* @__PURE__ */ new Set(), options);
78
- let code = result.code;
79
- const filename = `${page.path.replace(/\//g, "_")}`;
80
- const outputDir = root ? `${getTargetPath()}/${root}` : `${getTargetPath()}/main`;
81
- if (!fs.existsSync(outputDir)) {
82
- fs.mkdirSync(outputDir, { recursive: true });
83
- }
84
- if (options.sourcemap) {
85
- const mapFileName = `${filename}.css.map`;
86
- const map = JSON.parse(result.map);
87
- map.file = `${filename}.css`;
88
- code += `
89
- /*# sourceMappingURL=${mapFileName} */
90
- `;
91
- fs.writeFileSync(`${outputDir}/${mapFileName}`, JSON.stringify(map));
92
- }
93
- fs.writeFileSync(`${outputDir}/${filename}.css`, code);
94
- progress.completedTasks++;
95
- }
96
- }
97
- async function buildCompileCss(module, compiledPaths = /* @__PURE__ */ new Set(), options = {}) {
98
- const chunks = [];
99
- const pendingModules = [module];
100
- while (pendingModules.length > 0) {
101
- const currentModule = pendingModules.pop();
102
- const currentPath = currentModule.path || currentModule.absolutePath;
103
- if (compiledPaths.has(currentPath)) {
104
- continue;
105
- }
106
- compiledPaths.add(currentPath);
107
- const result = await enhanceCSS(currentModule, options);
108
- if (result.code) {
109
- chunks.push(result);
110
- }
111
- const graphDependencies = getDependencyGraph().getDirectDependencies(currentPath, "component");
112
- const componentPaths = graphDependencies.length > 0 ? graphDependencies : Object.values(currentModule.usingComponents || {});
113
- for (let index = componentPaths.length - 1; index >= 0; index--) {
114
- const componentModule = getComponent(componentPaths[index]);
115
- if (componentModule) {
116
- pendingModules.push(componentModule);
117
- }
118
- }
119
- }
120
- if (options.sourcemap) {
121
- const { code, sourcemap: map } = concatSourcemap(chunks);
122
- return { code, map };
123
- }
124
- return { code: chunks.map((chunk) => chunk.code).join(""), map: null };
125
- }
126
- function createExternalClassPlugin(moduleId) {
127
- const scopeAttribute = `data-v-${moduleId}`;
128
- const externalScopeAttribute = "data-dd-external-class-scope";
129
- const processedRules = /* @__PURE__ */ new WeakSet();
130
- return {
131
- postcssPlugin: "dimina-external-class",
132
- Rule(rule) {
133
- if (processedRules.has(rule) || !moduleId || !rule.selector.includes(`[${scopeAttribute}]`)) {
134
- return;
135
- }
136
- processedRules.add(rule);
137
- try {
138
- rule.selector = selectorParser((selectors) => {
139
- for (const selector of [...selectors.nodes]) {
140
- const boostedSelector = selector.clone();
141
- const scopeNodes = [];
142
- boostedSelector.walkAttributes((attribute) => {
143
- if (attribute.attribute === scopeAttribute) {
144
- scopeNodes.push(attribute);
145
- }
146
- });
147
- const targetScope = scopeNodes.at(-1);
148
- if (!targetScope) {
149
- continue;
150
- }
151
- targetScope.parent.insertAfter(targetScope, selectorParser.attribute({
152
- attribute: externalScopeAttribute,
153
- operator: "~=",
154
- quoteMark: '"',
155
- value: scopeAttribute
156
- }));
157
- selectors.append(boostedSelector);
158
- }
159
- }).processSync(rule.selector);
160
- } catch (error) {
161
- throw rule.error(error.message, { plugin: "dimina-external-class" });
162
- }
163
- }
164
- };
165
- }
166
- function boostExternalClassSelectors(cssCode, moduleId) {
167
- if (!moduleId || !cssCode) {
168
- return cssCode;
169
- }
170
- return postcss([createExternalClassPlugin(moduleId)]).process(cssCode, { from: void 0 }).css;
171
- }
172
- function getStyleSourcePath(absolutePath) {
173
- const workPath = getWorkPath();
174
- if (absolutePath === workPath || absolutePath.startsWith(`${workPath}${path.sep}`)) {
175
- return `/${path.relative(workPath, absolutePath).split(path.sep).join("/")}`;
176
- }
177
- return absolutePath.split(path.sep).join("/");
178
- }
179
- function createStyleCompileError(stage, absolutePath, cause) {
180
- if (cause?.name === "StyleCompileError") {
181
- return cause;
182
- }
183
- const line = cause?.line ?? (Number.isInteger(cause?.span?.start?.line) ? cause.span.start.line + 1 : void 0);
184
- const column = cause?.column ?? (Number.isInteger(cause?.span?.start?.column) ? cause.span.start.column + 1 : void 0);
185
- const file = getStyleSourcePath(absolutePath);
186
- const location = line == null ? file : `${file}:${line}${column == null ? "" : `:${column}`}`;
187
- const reason = cause?.reason || cause?.sassMessage || cause?.message || String(cause);
188
- const error = new Error(`[style:${stage}] ${location} ${reason}`, { cause });
189
- error.name = "StyleCompileError";
190
- error.file = file;
191
- error.line = line;
192
- error.column = column;
193
- error.stage = stage;
194
- return error;
195
- }
196
- function normalizePreprocessorMap(inputMap, absolutePath, inputCSS) {
197
- const map = typeof inputMap === "string" ? JSON.parse(inputMap) : structuredClone(inputMap);
198
- const sourcePaths = map.sources.map((source) => {
199
- let resolvedPath = source;
200
- if (source.startsWith("file:")) {
201
- resolvedPath = fileURLToPath(source);
202
- } else if (!path.isAbsolute(source)) {
203
- resolvedPath = path.resolve(path.dirname(absolutePath), source);
204
- }
205
- return resolvedPath;
206
- });
207
- map.sources = sourcePaths.map(getStyleSourcePath);
208
- map.sourcesContent = map.sources.map((_, index) => {
209
- if (sourcePaths[index] === absolutePath) {
210
- return inputCSS;
211
- }
212
- return map.sourcesContent?.[index] ?? null;
213
- });
214
- return map;
215
- }
216
- function getPostcssMapOptions(sourcemap, prev) {
217
- if (!sourcemap) {
218
- return false;
219
- }
220
- return {
221
- inline: false,
222
- annotation: false,
223
- sourcesContent: true,
224
- prev
225
- };
226
- }
227
- function createStyleTransformPlugin(module, absolutePath, importResults, options) {
228
- const processedRules = /* @__PURE__ */ new WeakSet();
229
- return {
230
- postcssPlugin: "dimina-style-transform",
231
- AtRule(node) {
232
- if (node.name !== "import") {
233
- return;
234
- }
235
- const importPath = node.params.replace(/^['"]|['"]$/g, "");
236
- const importFullPath = resolveStyleImportPath(absolutePath, importPath);
237
- node.remove();
238
- importResults.push(buildCompileCss({
239
- absolutePath: importFullPath,
240
- id: module.id,
241
- ownerPath: module.ownerPath || module.path
242
- }, /* @__PURE__ */ new Set(), options));
243
- },
244
- Rule(rule) {
245
- if (processedRules.has(rule)) {
246
- return;
247
- }
248
- processedRules.add(rule);
249
- if (rule.selector.includes("::v-deep")) {
250
- rule.selector = rule.selector.replace(/::v-deep\s+(\S[^{]*)/g, ":deep($1)");
251
- }
252
- if (rule.selector.includes(":host")) {
253
- rule.selector = processHostSelector(rule.selector, module.id);
254
- }
255
- try {
256
- rule.selector = selectorParser((selectors) => {
257
- selectors.walkTags((tag) => {
258
- if (tagWhiteList.includes(tag.value)) {
259
- tag.value = `.dd-${tag.value}`;
260
- }
261
- });
262
- }).processSync(rule.selector);
263
- } catch (error) {
264
- throw rule.error(error.message, { plugin: "dimina-style-transform" });
265
- }
266
- },
267
- Comment(comment) {
268
- comment.remove();
269
- },
270
- Declaration(declaration) {
271
- declaration.value = normalizeCssUrlValue(
272
- declaration.value,
273
- absolutePath,
274
- module.ownerPath || module.path
275
- );
276
- declaration.value = transformRpx(declaration.value);
277
- }
278
- };
279
- }
280
- async function enhanceCSS(module, options = {}) {
281
- const absolutePath = module.absolutePath ? module.absolutePath : getAbsolutePath(module.path);
282
- if (!absolutePath) {
283
- return { code: "", map: null };
284
- }
285
- const graphOwnerPath = module.ownerPath || module.path;
286
- if (graphOwnerPath) {
287
- getDependencyGraph().addFile(graphOwnerPath, absolutePath, "style");
288
- }
289
- const cacheKey = `${absolutePath}::${module.id || ""}::${options.sourcemap ? "map" : "plain"}`;
290
- const inputCSS = getContentByPath(absolutePath);
291
- if (!inputCSS) {
292
- return { code: "", map: null };
293
- }
294
- if (compileRes.has(cacheKey)) {
295
- return compileRes.get(cacheKey);
296
- }
297
- let processedCSS = normalizeRootStyleImports(inputCSS);
298
- let processedMap = options.sourcemap ? createLineSourcemap(processedCSS, getStyleSourcePath(absolutePath), inputCSS) : null;
299
- const ext = path.extname(absolutePath).toLowerCase();
300
- try {
301
- if (ext === ".less") {
302
- const result2 = await less.render(processedCSS, {
303
- filename: absolutePath,
304
- paths: [path.dirname(absolutePath), getWorkPath()],
305
- sourceMap: options.sourcemap ? {
306
- outputSourceFiles: true,
307
- disableSourcemapAnnotation: true
308
- } : void 0
309
- });
310
- processedCSS = result2.css;
311
- if (options.sourcemap) {
312
- processedMap = normalizePreprocessorMap(result2.map, absolutePath, inputCSS);
313
- }
314
- } else if (ext === ".scss" || ext === ".sass") {
315
- const result2 = sass.compileString(processedCSS, {
316
- loadPaths: [path.dirname(absolutePath), getWorkPath()],
317
- syntax: ext === ".sass" ? "indented" : "scss",
318
- url: options.sourcemap ? pathToFileURL(absolutePath) : void 0,
319
- sourceMap: !!options.sourcemap,
320
- sourceMapIncludeSources: !!options.sourcemap
321
- });
322
- processedCSS = result2.css;
323
- if (options.sourcemap) {
324
- processedMap = normalizePreprocessorMap(result2.sourceMap, absolutePath, inputCSS);
325
- }
326
- }
327
- } catch (error) {
328
- throw createStyleCompileError("preprocess", absolutePath, error);
329
- }
330
- const fixedCSS = ensureImportSemicolons(processedCSS);
331
- if (options.sourcemap && fixedCSS !== processedCSS) {
332
- const normalizeMap = createLineSourcemap(fixedCSS, absolutePath, processedCSS);
333
- processedMap = remapSourcemap(normalizeMap, processedMap);
334
- }
335
- const importResults = [];
336
- let transformedResult;
337
- try {
338
- transformedResult = await postcss([
339
- createStyleTransformPlugin(module, absolutePath, importResults, options)
340
- ]).process(fixedCSS, {
341
- from: void 0,
342
- map: getPostcssMapOptions(options.sourcemap, processedMap)
343
- });
344
- } catch (error) {
345
- throw createStyleCompileError("transform", absolutePath, error);
346
- }
347
- const moduleId = module.id;
348
- let scopedResult;
349
- try {
350
- scopedResult = compileStyle({
351
- source: transformedResult.css,
352
- filename: getStyleSourcePath(absolutePath),
353
- id: moduleId,
354
- scoped: !!moduleId,
355
- inMap: options.sourcemap ? transformedResult.map.toJSON() : void 0
356
- });
357
- if (scopedResult.errors.length > 0) {
358
- throw scopedResult.errors[0];
359
- }
360
- } catch (error) {
361
- throw createStyleCompileError("scope", absolutePath, error);
362
- }
363
- let externalResult;
364
- try {
365
- externalResult = await postcss([createExternalClassPlugin(moduleId)]).process(scopedResult.code, {
366
- from: void 0,
367
- map: getPostcssMapOptions(options.sourcemap, scopedResult.map)
368
- });
369
- } catch (error) {
370
- throw createStyleCompileError("external-class", absolutePath, error);
371
- }
372
- let finalResult;
373
- try {
374
- finalResult = await postcss([
375
- autoprefixer({ overrideBrowserslist: ["cover 99.5%"] }),
376
- cssnano()
377
- ]).process(externalResult.css, {
378
- from: void 0,
379
- map: getPostcssMapOptions(options.sourcemap, externalResult.map?.toJSON())
380
- });
381
- } catch (error) {
382
- throw createStyleCompileError("postprocess", absolutePath, error);
383
- }
384
- const importedChunks = (await Promise.all(importResults)).filter((result2) => result2.code);
385
- let result;
386
- if (options.sourcemap) {
387
- const { code, sourcemap: map } = concatSourcemap([
388
- ...importedChunks,
389
- { code: finalResult.css, map: finalResult.map.toString() }
390
- ]);
391
- result = { code, map };
392
- } else {
393
- result = {
394
- code: importedChunks.map((chunk) => chunk.code).join("") + finalResult.css,
395
- map: null
396
- };
397
- }
398
- compileRes.set(cacheKey, result);
399
- return result;
400
- }
401
- function normalizeCssUrlValue(value, absolutePath, graphOwnerPath) {
402
- return value.replace(/url\(([^)]+)\)/g, (fullMatch, rawUrl) => {
403
- const cleanedUrl = rawUrl.trim().replace(/^['"]|['"]$/g, "");
404
- if (!cleanedUrl || cleanedUrl.startsWith("data:image")) {
405
- return fullMatch;
406
- }
407
- if (cleanedUrl.startsWith("//")) {
408
- return `url(https:${cleanedUrl})`;
409
- }
410
- if (/^(https?:|blob:|data:)/.test(cleanedUrl)) {
411
- return fullMatch;
412
- }
413
- if (graphOwnerPath && /\.(?:png|jpe?g|gif|svg)(?:\?.*)?$/.test(cleanedUrl)) {
414
- getDependencyGraph().addFile(
415
- graphOwnerPath,
416
- resolveAssetSourcePath(getWorkPath(), absolutePath, cleanedUrl),
417
- "style"
418
- );
419
- }
420
- const realSrc = collectAssets(getWorkPath(), absolutePath, cleanedUrl, getTargetPath(), getAppId());
421
- return `url(${realSrc})`;
422
- });
423
- }
424
- function getAbsolutePath(modulePath) {
425
- const workPath = getWorkPath();
426
- const src = modulePath.startsWith("/") ? modulePath : `/${modulePath}`;
427
- for (const ssType of getStyleExts()) {
428
- const ssFullPath = `${workPath}${src}${ssType}`;
429
- if (fs.existsSync(ssFullPath)) {
430
- return ssFullPath;
431
- }
432
- const indexSsFullPath = `${workPath}${src}/index${ssType}`;
433
- if (fs.existsSync(indexSsFullPath)) {
434
- return indexSsFullPath;
435
- }
436
- }
437
- }
438
- function resolveStyleImportPath(absolutePath, importPath, workPath = getWorkPath()) {
439
- if (importPath.startsWith("/")) {
440
- return path.join(workPath, importPath);
441
- }
442
- return path.resolve(path.dirname(absolutePath), importPath);
443
- }
444
- function normalizeRootStyleImports(source, workPath = getWorkPath()) {
445
- return source.replace(/(@import\s+(?:\(.*?\)\s*)?(?:url\()?['"])(\/[^'")]+)(['"]\)?)/g, (_, prefix, importPath, suffix) => {
446
- return `${prefix}${path.join(workPath, importPath)}${suffix}`;
447
- });
448
- }
449
- function ensureImportSemicolons(css) {
450
- return css.replace(/@import[^;\n]*$/gm, (match) => {
451
- return match.endsWith(";") ? match : `${match};`;
452
- });
453
- }
454
- function processHostSelector(selector, moduleId) {
455
- const hostSelector = `[data-dd-style-host~="${moduleId}"]`;
456
- return selector.replace(/:host\(([^)]+)\)/g, `${hostSelector}$1`).replace(/:host(?![\w-])/g, hostSelector);
457
- }
458
- function __resetStyleState() {
459
- compileRes.clear();
460
- }
461
- export {
462
- __resetStyleState,
463
- boostExternalClassSelectors,
464
- compileSS,
465
- ensureImportSemicolons,
466
- normalizeCssUrlValue,
467
- normalizeRootStyleImports,
468
- processHostSelector,
469
- resolveStyleImportPath
470
- };