@dimina/compiler 1.0.17 → 1.1.0
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/README.md +2 -0
- package/dist/bin/index.cjs +10 -8
- package/dist/bin/index.js +6 -4
- package/dist/{compatibility-DnN63SVV.cjs → compatibility-CzIJUgPs.cjs} +94 -4
- package/dist/{compatibility-DbP7rQJN.js → compatibility-DdxfVhcK.js} +89 -5
- package/dist/core/logic-compiler.cjs +16 -18
- package/dist/core/logic-compiler.js +13 -16
- package/dist/core/style-compiler.cjs +61 -53
- package/dist/core/style-compiler.js +52 -45
- package/dist/core/view-compiler.cjs +202 -88
- package/dist/core/view-compiler.js +196 -84
- package/dist/{env-BWsUjuZE.cjs → env-B4U3zZUm.cjs} +182 -63
- package/dist/{env-iShlMOS1.js → env-OH3--qg8.js} +159 -26
- package/dist/index.cjs +113 -23
- package/dist/index.js +108 -19
- package/dist/rolldown-runtime-D6vf50IK.cjs +28 -0
- package/package.json +8 -4
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,70 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-D6vf50IK.cjs");
|
|
2
|
+
const require_env = require("./env-B4U3zZUm.cjs");
|
|
2
3
|
let node_path = require("node:path");
|
|
3
|
-
node_path =
|
|
4
|
+
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
5
|
+
let node_process = require("node:process");
|
|
6
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
4
7
|
let node_url = require("node:url");
|
|
5
8
|
let node_worker_threads = require("node:worker_threads");
|
|
6
9
|
let listr2 = require("listr2");
|
|
7
|
-
let node_process = require("node:process");
|
|
8
|
-
node_process = require_env.__toESM(node_process, 1);
|
|
9
10
|
let node_fs = require("node:fs");
|
|
10
|
-
node_fs =
|
|
11
|
+
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
11
12
|
let node_os = require("node:os");
|
|
12
|
-
node_os =
|
|
13
|
+
node_os = require_rolldown_runtime.__toESM(node_os, 1);
|
|
14
|
+
//#region src/common/compile-progress.js
|
|
15
|
+
var DEFAULT_TERMINAL_COLUMNS = 80;
|
|
16
|
+
var MIN_PROGRESS_WIDTH = 8;
|
|
17
|
+
var MAX_PROGRESS_WIDTH = 28;
|
|
18
|
+
var RENDERER_CHROME_WIDTH = 14;
|
|
19
|
+
var PROGRESS_BRACKETS_WIDTH = 2;
|
|
20
|
+
/**
|
|
21
|
+
* Format worker progress without assuming a fixed terminal width.
|
|
22
|
+
* The completed count remains the source of truth. Whole cells avoid the
|
|
23
|
+
* visible gap that partial block glyphs leave before the unfilled section.
|
|
24
|
+
*/
|
|
25
|
+
function formatCompileProgress(completed, total, options = {}) {
|
|
26
|
+
const unicode = options.unicode ?? (0, listr2.isUnicodeSupported)();
|
|
27
|
+
const columns = normalizePositiveInteger(options.columns) || node_process.default.stdout.columns || DEFAULT_TERMINAL_COLUMNS;
|
|
28
|
+
const safeTotal = normalizePositiveInteger(total);
|
|
29
|
+
const safeCompleted = Math.min(normalizePositiveInteger(completed), safeTotal);
|
|
30
|
+
const ratio = safeTotal === 0 ? 0 : safeCompleted / safeTotal;
|
|
31
|
+
const percentage = Math.round(ratio * 100);
|
|
32
|
+
const separator = unicode ? "·" : "|";
|
|
33
|
+
const metadata = `${String(safeCompleted).padStart(String(safeTotal).length)}/${safeTotal} ${separator} ${String(percentage).padStart(3)}%`;
|
|
34
|
+
const availableWidth = columns - metadata.length - RENDERER_CHROME_WIDTH - PROGRESS_BRACKETS_WIDTH;
|
|
35
|
+
if (availableWidth < MIN_PROGRESS_WIDTH) return metadata;
|
|
36
|
+
const width = Math.min(availableWidth, MAX_PROGRESS_WIDTH);
|
|
37
|
+
return `[${unicode ? createUnicodeBar(ratio, width) : createAsciiBar(ratio, width)}] ${metadata}`;
|
|
38
|
+
}
|
|
39
|
+
function createUnicodeBar(ratio, width) {
|
|
40
|
+
const completeWidth = Math.round(ratio * width);
|
|
41
|
+
const emptyWidth = width - completeWidth;
|
|
42
|
+
return `${"█".repeat(completeWidth)}${"░".repeat(emptyWidth)}`;
|
|
43
|
+
}
|
|
44
|
+
function createAsciiBar(ratio, width) {
|
|
45
|
+
const completeWidth = Math.floor(ratio * width);
|
|
46
|
+
const showHead = ratio > 0 && ratio < 1;
|
|
47
|
+
const bodyWidth = Math.max(0, completeWidth - (showHead ? 1 : 0));
|
|
48
|
+
const emptyWidth = width - bodyWidth - (showHead ? 1 : 0);
|
|
49
|
+
return `${"=".repeat(bodyWidth)}${showHead ? ">" : ""}${"-".repeat(emptyWidth)}`;
|
|
50
|
+
}
|
|
51
|
+
function normalizePositiveInteger(value) {
|
|
52
|
+
return Number.isFinite(value) ? Math.max(0, Math.trunc(value)) : 0;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/common/art.js
|
|
56
|
+
var artCode = `
|
|
57
|
+
██████╗ ██╗███╗ ███╗██╗███╗ ██╗ █████╗
|
|
58
|
+
██╔══██╗██║████╗ ████║██║████╗ ██║██╔══██╗
|
|
59
|
+
██║ ██║██║██╔████╔██║██║██╔██╗ ██║███████║
|
|
60
|
+
██║ ██║██║██║╚██╔╝██║██║██║╚██╗██║██╔══██║
|
|
61
|
+
██████╔╝██║██║ ╚═╝ ██║██║██║ ╚████║██║ ██║
|
|
62
|
+
╚═════╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝
|
|
63
|
+
`;
|
|
64
|
+
function art_default() {
|
|
65
|
+
console.log(artCode);
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
13
68
|
//#region src/common/publish.js
|
|
14
69
|
function createDist() {
|
|
15
70
|
const distPath = require_env.getTargetPath();
|
|
@@ -309,6 +364,7 @@ function compileConfig() {
|
|
|
309
364
|
//#endregion
|
|
310
365
|
//#region src/index.js
|
|
311
366
|
var isPrinted = false;
|
|
367
|
+
var previousCompatibilityWarnings = /* @__PURE__ */ new Map();
|
|
312
368
|
/**
|
|
313
369
|
* 构建命令入口
|
|
314
370
|
* @param {string} targetPath 编译产物目标路径
|
|
@@ -323,12 +379,12 @@ var isPrinted = false;
|
|
|
323
379
|
async function build(targetPath, workPath, useAppIdDir = true, options = {}) {
|
|
324
380
|
const { sourcemap = false, fileTypes } = options;
|
|
325
381
|
if (!isPrinted) {
|
|
326
|
-
|
|
382
|
+
art_default();
|
|
327
383
|
isPrinted = true;
|
|
328
384
|
}
|
|
329
385
|
const tasks = new listr2.Listr([
|
|
330
386
|
{
|
|
331
|
-
title: "
|
|
387
|
+
title: "初始化项目",
|
|
332
388
|
task: (_, task) => task.newListr([
|
|
333
389
|
{
|
|
334
390
|
title: "收集配置信息",
|
|
@@ -357,29 +413,42 @@ async function build(targetPath, workPath, useAppIdDir = true, options = {}) {
|
|
|
357
413
|
], { concurrent: false })
|
|
358
414
|
},
|
|
359
415
|
{
|
|
360
|
-
title:
|
|
416
|
+
title: `编译项目 · ${node_path.default.basename(node_path.default.resolve(workPath))}`,
|
|
361
417
|
task: (ctx, task) => {
|
|
362
418
|
const pages = require_env.getPages();
|
|
363
419
|
ctx.pages = pages;
|
|
420
|
+
ctx.compatibilityWarnings = /* @__PURE__ */ new Set();
|
|
364
421
|
return task.newListr([
|
|
365
422
|
{
|
|
366
|
-
title: "
|
|
423
|
+
title: "编译视图",
|
|
424
|
+
rendererOptions: {
|
|
425
|
+
outputBar: true,
|
|
426
|
+
persistentOutput: false
|
|
427
|
+
},
|
|
367
428
|
task: async (ctx, task) => {
|
|
368
429
|
return runCompileInWorker("view", ctx, task, { sourcemap });
|
|
369
430
|
}
|
|
370
431
|
},
|
|
371
432
|
{
|
|
372
|
-
title: "
|
|
433
|
+
title: "编译逻辑",
|
|
434
|
+
rendererOptions: {
|
|
435
|
+
outputBar: true,
|
|
436
|
+
persistentOutput: false
|
|
437
|
+
},
|
|
373
438
|
task: async (ctx, task) => {
|
|
374
439
|
return runCompileInWorker("logic", ctx, task, { sourcemap });
|
|
375
440
|
}
|
|
376
441
|
},
|
|
377
442
|
{
|
|
378
|
-
title: "
|
|
443
|
+
title: "编译样式",
|
|
444
|
+
rendererOptions: {
|
|
445
|
+
outputBar: true,
|
|
446
|
+
persistentOutput: false
|
|
447
|
+
},
|
|
379
448
|
task: async (ctx, task) => {
|
|
380
449
|
pages.mainPages.unshift({
|
|
381
450
|
path: "app",
|
|
382
|
-
id:
|
|
451
|
+
id: require_env.getAppStyleScopeId()
|
|
383
452
|
});
|
|
384
453
|
return runCompileInWorker("style", ctx, task, { sourcemap });
|
|
385
454
|
}
|
|
@@ -388,14 +457,23 @@ async function build(targetPath, workPath, useAppIdDir = true, options = {}) {
|
|
|
388
457
|
}
|
|
389
458
|
},
|
|
390
459
|
{
|
|
391
|
-
title: "
|
|
460
|
+
title: "写入编译产物",
|
|
392
461
|
task: () => {
|
|
393
462
|
publishToDist(targetPath, useAppIdDir);
|
|
394
463
|
}
|
|
395
464
|
}
|
|
396
|
-
], {
|
|
465
|
+
], {
|
|
466
|
+
concurrent: false,
|
|
467
|
+
rendererOptions: {
|
|
468
|
+
collapseSubtasks: true,
|
|
469
|
+
formatOutput: "truncate",
|
|
470
|
+
timer: listr2.PRESET_TIMER
|
|
471
|
+
},
|
|
472
|
+
fallbackRendererOptions: { timer: listr2.PRESET_TIMER }
|
|
473
|
+
});
|
|
397
474
|
try {
|
|
398
475
|
const context = await tasks.run();
|
|
476
|
+
printCompatibilityWarnings(workPath, context.compatibilityWarnings);
|
|
399
477
|
return {
|
|
400
478
|
appId: require_env.getAppId(),
|
|
401
479
|
name: require_env.getAppName(),
|
|
@@ -424,16 +502,12 @@ function runCompileInWorker(script, ctx, task, options = {}) {
|
|
|
424
502
|
});
|
|
425
503
|
worker.on("message", (message) => {
|
|
426
504
|
try {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
const percentage = progress * 100;
|
|
430
|
-
const barLength = 30;
|
|
431
|
-
const filledLength = Math.ceil(barLength * progress);
|
|
432
|
-
task.output = `[${"█".repeat(filledLength) + "░".repeat(barLength - filledLength)}] ${percentage.toFixed(2)}%`;
|
|
433
|
-
}
|
|
505
|
+
for (const warning of message.compatibilityWarnings || []) ctx.compatibilityWarnings.add(warning);
|
|
506
|
+
if (node_process.default.stdout.isTTY && message.completedTasks !== void 0) task.output = formatCompileProgress(message.completedTasks, totalTasks);
|
|
434
507
|
if (message.success) {
|
|
435
508
|
if (isResolved) return;
|
|
436
509
|
isResolved = true;
|
|
510
|
+
if (node_process.default.stdout.isTTY && totalTasks > 0) task.output = formatCompileProgress(totalTasks, totalTasks);
|
|
437
511
|
worker.terminate();
|
|
438
512
|
resolve();
|
|
439
513
|
} else if (message.error) {
|
|
@@ -452,9 +526,25 @@ function runCompileInWorker(script, ctx, task, options = {}) {
|
|
|
452
526
|
handleError(err);
|
|
453
527
|
});
|
|
454
528
|
worker.on("exit", (code) => {
|
|
455
|
-
if (code !== 0 && !isResolved)
|
|
529
|
+
if (code !== 0 && !isResolved) {
|
|
530
|
+
const error = workerError || /* @__PURE__ */ new Error(code === 1 ? "Worker terminated due to reaching memory limit: JS heap out of memory" : `Worker stopped with exit code ${code}`);
|
|
531
|
+
handleError(error);
|
|
532
|
+
}
|
|
456
533
|
});
|
|
457
534
|
}));
|
|
458
535
|
}
|
|
536
|
+
function printCompatibilityWarnings(workPath, warnings = /* @__PURE__ */ new Set()) {
|
|
537
|
+
const projectPath = node_path.default.resolve(workPath);
|
|
538
|
+
const hasPreviousResult = previousCompatibilityWarnings.has(projectPath);
|
|
539
|
+
const previousWarnings = previousCompatibilityWarnings.get(projectPath) || /* @__PURE__ */ new Set();
|
|
540
|
+
const currentWarnings = new Set(warnings);
|
|
541
|
+
const newWarnings = [...currentWarnings].filter((warning) => !previousWarnings.has(warning));
|
|
542
|
+
previousCompatibilityWarnings.set(projectPath, currentWarnings);
|
|
543
|
+
if (newWarnings.length === 0) return;
|
|
544
|
+
const qualifier = hasPreviousResult ? " new" : "";
|
|
545
|
+
const suffix = newWarnings.length === 1 ? "" : "s";
|
|
546
|
+
console.warn(`\n[compat] ${newWarnings.length}${qualifier} compatibility warning${suffix}`);
|
|
547
|
+
for (const warning of newWarnings) console.warn(` - ${warning.replace(/^\[compat\]\s*/, "")}`);
|
|
548
|
+
}
|
|
459
549
|
//#endregion
|
|
460
550
|
module.exports = build;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,65 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as getPageConfigInfo, d as getTargetPath, f as getTemplateExts, h as getWorkPath, i as getAppStyleScopeId, l as getPages, n as getAppId, p as getViewScriptExts, r as getAppName, t as getAppConfigInfo, u as getStyleExts, v as storeInfo, y as collectAssets } from "./env-OH3--qg8.js";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import { Worker } from "node:worker_threads";
|
|
5
|
-
import { Listr } from "listr2";
|
|
6
|
-
import process from "node:process";
|
|
6
|
+
import { Listr, PRESET_TIMER, isUnicodeSupported } from "listr2";
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import os from "node:os";
|
|
9
|
+
//#region src/common/compile-progress.js
|
|
10
|
+
var DEFAULT_TERMINAL_COLUMNS = 80;
|
|
11
|
+
var MIN_PROGRESS_WIDTH = 8;
|
|
12
|
+
var MAX_PROGRESS_WIDTH = 28;
|
|
13
|
+
var RENDERER_CHROME_WIDTH = 14;
|
|
14
|
+
var PROGRESS_BRACKETS_WIDTH = 2;
|
|
15
|
+
/**
|
|
16
|
+
* Format worker progress without assuming a fixed terminal width.
|
|
17
|
+
* The completed count remains the source of truth. Whole cells avoid the
|
|
18
|
+
* visible gap that partial block glyphs leave before the unfilled section.
|
|
19
|
+
*/
|
|
20
|
+
function formatCompileProgress(completed, total, options = {}) {
|
|
21
|
+
const unicode = options.unicode ?? isUnicodeSupported();
|
|
22
|
+
const columns = normalizePositiveInteger(options.columns) || process.stdout.columns || DEFAULT_TERMINAL_COLUMNS;
|
|
23
|
+
const safeTotal = normalizePositiveInteger(total);
|
|
24
|
+
const safeCompleted = Math.min(normalizePositiveInteger(completed), safeTotal);
|
|
25
|
+
const ratio = safeTotal === 0 ? 0 : safeCompleted / safeTotal;
|
|
26
|
+
const percentage = Math.round(ratio * 100);
|
|
27
|
+
const separator = unicode ? "·" : "|";
|
|
28
|
+
const metadata = `${String(safeCompleted).padStart(String(safeTotal).length)}/${safeTotal} ${separator} ${String(percentage).padStart(3)}%`;
|
|
29
|
+
const availableWidth = columns - metadata.length - RENDERER_CHROME_WIDTH - PROGRESS_BRACKETS_WIDTH;
|
|
30
|
+
if (availableWidth < MIN_PROGRESS_WIDTH) return metadata;
|
|
31
|
+
const width = Math.min(availableWidth, MAX_PROGRESS_WIDTH);
|
|
32
|
+
return `[${unicode ? createUnicodeBar(ratio, width) : createAsciiBar(ratio, width)}] ${metadata}`;
|
|
33
|
+
}
|
|
34
|
+
function createUnicodeBar(ratio, width) {
|
|
35
|
+
const completeWidth = Math.round(ratio * width);
|
|
36
|
+
const emptyWidth = width - completeWidth;
|
|
37
|
+
return `${"█".repeat(completeWidth)}${"░".repeat(emptyWidth)}`;
|
|
38
|
+
}
|
|
39
|
+
function createAsciiBar(ratio, width) {
|
|
40
|
+
const completeWidth = Math.floor(ratio * width);
|
|
41
|
+
const showHead = ratio > 0 && ratio < 1;
|
|
42
|
+
const bodyWidth = Math.max(0, completeWidth - (showHead ? 1 : 0));
|
|
43
|
+
const emptyWidth = width - bodyWidth - (showHead ? 1 : 0);
|
|
44
|
+
return `${"=".repeat(bodyWidth)}${showHead ? ">" : ""}${"-".repeat(emptyWidth)}`;
|
|
45
|
+
}
|
|
46
|
+
function normalizePositiveInteger(value) {
|
|
47
|
+
return Number.isFinite(value) ? Math.max(0, Math.trunc(value)) : 0;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/common/art.js
|
|
51
|
+
var artCode = `
|
|
52
|
+
██████╗ ██╗███╗ ███╗██╗███╗ ██╗ █████╗
|
|
53
|
+
██╔══██╗██║████╗ ████║██║████╗ ██║██╔══██╗
|
|
54
|
+
██║ ██║██║██╔████╔██║██║██╔██╗ ██║███████║
|
|
55
|
+
██║ ██║██║██║╚██╔╝██║██║██║╚██╗██║██╔══██║
|
|
56
|
+
██████╔╝██║██║ ╚═╝ ██║██║██║ ╚████║██║ ██║
|
|
57
|
+
╚═════╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝
|
|
58
|
+
`;
|
|
59
|
+
function art_default() {
|
|
60
|
+
console.log(artCode);
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
9
63
|
//#region src/common/publish.js
|
|
10
64
|
function createDist() {
|
|
11
65
|
const distPath = getTargetPath();
|
|
@@ -305,6 +359,7 @@ function compileConfig() {
|
|
|
305
359
|
//#endregion
|
|
306
360
|
//#region src/index.js
|
|
307
361
|
var isPrinted = false;
|
|
362
|
+
var previousCompatibilityWarnings = /* @__PURE__ */ new Map();
|
|
308
363
|
/**
|
|
309
364
|
* 构建命令入口
|
|
310
365
|
* @param {string} targetPath 编译产物目标路径
|
|
@@ -324,7 +379,7 @@ async function build(targetPath, workPath, useAppIdDir = true, options = {}) {
|
|
|
324
379
|
}
|
|
325
380
|
const tasks = new Listr([
|
|
326
381
|
{
|
|
327
|
-
title: "
|
|
382
|
+
title: "初始化项目",
|
|
328
383
|
task: (_, task) => task.newListr([
|
|
329
384
|
{
|
|
330
385
|
title: "收集配置信息",
|
|
@@ -353,29 +408,42 @@ async function build(targetPath, workPath, useAppIdDir = true, options = {}) {
|
|
|
353
408
|
], { concurrent: false })
|
|
354
409
|
},
|
|
355
410
|
{
|
|
356
|
-
title:
|
|
411
|
+
title: `编译项目 · ${path.basename(path.resolve(workPath))}`,
|
|
357
412
|
task: (ctx, task) => {
|
|
358
413
|
const pages = getPages();
|
|
359
414
|
ctx.pages = pages;
|
|
415
|
+
ctx.compatibilityWarnings = /* @__PURE__ */ new Set();
|
|
360
416
|
return task.newListr([
|
|
361
417
|
{
|
|
362
|
-
title: "
|
|
418
|
+
title: "编译视图",
|
|
419
|
+
rendererOptions: {
|
|
420
|
+
outputBar: true,
|
|
421
|
+
persistentOutput: false
|
|
422
|
+
},
|
|
363
423
|
task: async (ctx, task) => {
|
|
364
424
|
return runCompileInWorker("view", ctx, task, { sourcemap });
|
|
365
425
|
}
|
|
366
426
|
},
|
|
367
427
|
{
|
|
368
|
-
title: "
|
|
428
|
+
title: "编译逻辑",
|
|
429
|
+
rendererOptions: {
|
|
430
|
+
outputBar: true,
|
|
431
|
+
persistentOutput: false
|
|
432
|
+
},
|
|
369
433
|
task: async (ctx, task) => {
|
|
370
434
|
return runCompileInWorker("logic", ctx, task, { sourcemap });
|
|
371
435
|
}
|
|
372
436
|
},
|
|
373
437
|
{
|
|
374
|
-
title: "
|
|
438
|
+
title: "编译样式",
|
|
439
|
+
rendererOptions: {
|
|
440
|
+
outputBar: true,
|
|
441
|
+
persistentOutput: false
|
|
442
|
+
},
|
|
375
443
|
task: async (ctx, task) => {
|
|
376
444
|
pages.mainPages.unshift({
|
|
377
445
|
path: "app",
|
|
378
|
-
id:
|
|
446
|
+
id: getAppStyleScopeId()
|
|
379
447
|
});
|
|
380
448
|
return runCompileInWorker("style", ctx, task, { sourcemap });
|
|
381
449
|
}
|
|
@@ -384,14 +452,23 @@ async function build(targetPath, workPath, useAppIdDir = true, options = {}) {
|
|
|
384
452
|
}
|
|
385
453
|
},
|
|
386
454
|
{
|
|
387
|
-
title: "
|
|
455
|
+
title: "写入编译产物",
|
|
388
456
|
task: () => {
|
|
389
457
|
publishToDist(targetPath, useAppIdDir);
|
|
390
458
|
}
|
|
391
459
|
}
|
|
392
|
-
], {
|
|
460
|
+
], {
|
|
461
|
+
concurrent: false,
|
|
462
|
+
rendererOptions: {
|
|
463
|
+
collapseSubtasks: true,
|
|
464
|
+
formatOutput: "truncate",
|
|
465
|
+
timer: PRESET_TIMER
|
|
466
|
+
},
|
|
467
|
+
fallbackRendererOptions: { timer: PRESET_TIMER }
|
|
468
|
+
});
|
|
393
469
|
try {
|
|
394
470
|
const context = await tasks.run();
|
|
471
|
+
printCompatibilityWarnings(workPath, context.compatibilityWarnings);
|
|
395
472
|
return {
|
|
396
473
|
appId: getAppId(),
|
|
397
474
|
name: getAppName(),
|
|
@@ -420,16 +497,12 @@ function runCompileInWorker(script, ctx, task, options = {}) {
|
|
|
420
497
|
});
|
|
421
498
|
worker.on("message", (message) => {
|
|
422
499
|
try {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const percentage = progress * 100;
|
|
426
|
-
const barLength = 30;
|
|
427
|
-
const filledLength = Math.ceil(barLength * progress);
|
|
428
|
-
task.output = `[${"█".repeat(filledLength) + "░".repeat(barLength - filledLength)}] ${percentage.toFixed(2)}%`;
|
|
429
|
-
}
|
|
500
|
+
for (const warning of message.compatibilityWarnings || []) ctx.compatibilityWarnings.add(warning);
|
|
501
|
+
if (process.stdout.isTTY && message.completedTasks !== void 0) task.output = formatCompileProgress(message.completedTasks, totalTasks);
|
|
430
502
|
if (message.success) {
|
|
431
503
|
if (isResolved) return;
|
|
432
504
|
isResolved = true;
|
|
505
|
+
if (process.stdout.isTTY && totalTasks > 0) task.output = formatCompileProgress(totalTasks, totalTasks);
|
|
433
506
|
worker.terminate();
|
|
434
507
|
resolve();
|
|
435
508
|
} else if (message.error) {
|
|
@@ -448,9 +521,25 @@ function runCompileInWorker(script, ctx, task, options = {}) {
|
|
|
448
521
|
handleError(err);
|
|
449
522
|
});
|
|
450
523
|
worker.on("exit", (code) => {
|
|
451
|
-
if (code !== 0 && !isResolved)
|
|
524
|
+
if (code !== 0 && !isResolved) {
|
|
525
|
+
const error = workerError || /* @__PURE__ */ new Error(code === 1 ? "Worker terminated due to reaching memory limit: JS heap out of memory" : `Worker stopped with exit code ${code}`);
|
|
526
|
+
handleError(error);
|
|
527
|
+
}
|
|
452
528
|
});
|
|
453
529
|
}));
|
|
454
530
|
}
|
|
531
|
+
function printCompatibilityWarnings(workPath, warnings = /* @__PURE__ */ new Set()) {
|
|
532
|
+
const projectPath = path.resolve(workPath);
|
|
533
|
+
const hasPreviousResult = previousCompatibilityWarnings.has(projectPath);
|
|
534
|
+
const previousWarnings = previousCompatibilityWarnings.get(projectPath) || /* @__PURE__ */ new Set();
|
|
535
|
+
const currentWarnings = new Set(warnings);
|
|
536
|
+
const newWarnings = [...currentWarnings].filter((warning) => !previousWarnings.has(warning));
|
|
537
|
+
previousCompatibilityWarnings.set(projectPath, currentWarnings);
|
|
538
|
+
if (newWarnings.length === 0) return;
|
|
539
|
+
const qualifier = hasPreviousResult ? " new" : "";
|
|
540
|
+
const suffix = newWarnings.length === 1 ? "" : "s";
|
|
541
|
+
console.warn(`\n[compat] ${newWarnings.length}${qualifier} compatibility warning${suffix}`);
|
|
542
|
+
for (const warning of newWarnings) console.warn(` - ${warning.replace(/^\[compat\]\s*/, "")}`);
|
|
543
|
+
}
|
|
455
544
|
//#endregion
|
|
456
545
|
export { build as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
Object.defineProperty(exports, "__toESM", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return __toESM;
|
|
27
|
+
}
|
|
28
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimina/compiler",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "星河编译工具",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -43,6 +43,9 @@
|
|
|
43
43
|
},
|
|
44
44
|
"author": "doslin",
|
|
45
45
|
"license": "Apache-2.0",
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20"
|
|
48
|
+
},
|
|
46
49
|
"keywords": [
|
|
47
50
|
"dimina",
|
|
48
51
|
"compiler",
|
|
@@ -52,7 +55,8 @@
|
|
|
52
55
|
],
|
|
53
56
|
"dependencies": {
|
|
54
57
|
"@vue/compiler-sfc": "^3.5.39",
|
|
55
|
-
"
|
|
58
|
+
"@vue/shared": "^3.5.39",
|
|
59
|
+
"autoprefixer": "^10.5.3",
|
|
56
60
|
"cheerio": "^1.2.0",
|
|
57
61
|
"chokidar": "^4.0.3",
|
|
58
62
|
"commander": "^14.0.3",
|
|
@@ -62,9 +66,9 @@
|
|
|
62
66
|
"less": "^4.6.7",
|
|
63
67
|
"listr2": "^9.0.5",
|
|
64
68
|
"magic-string": "^0.30.21",
|
|
65
|
-
"oxc-parser": "^0.
|
|
69
|
+
"oxc-parser": "^0.139.0",
|
|
66
70
|
"oxc-walker": "^1.0.0",
|
|
67
|
-
"postcss": "^8.5.
|
|
71
|
+
"postcss": "^8.5.19",
|
|
68
72
|
"postcss-selector-parser": "^7.1.4",
|
|
69
73
|
"sass": "^1.101.0",
|
|
70
74
|
"source-map-js": "^1.2.1"
|