@absolutejs/absolute 0.19.0-beta.1034 → 0.19.0-beta.1036
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var __require = import.meta.require;
|
|
3
3
|
|
|
4
|
-
// .angular-partial-tmp-
|
|
4
|
+
// .angular-partial-tmp-TIyEAN/src/core/streamingSlotRegistrar.ts
|
|
5
5
|
var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
6
6
|
var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
|
|
7
7
|
var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var __require = import.meta.require;
|
|
3
3
|
|
|
4
|
-
// .angular-partial-tmp-
|
|
4
|
+
// .angular-partial-tmp-TIyEAN/src/core/streamingSlotRegistrar.ts
|
|
5
5
|
var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
6
6
|
var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
|
|
7
7
|
var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
|
|
@@ -48,7 +48,7 @@ var warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
|
48
48
|
getWarningController()?.maybeWarn(primitiveName);
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
// .angular-partial-tmp-
|
|
51
|
+
// .angular-partial-tmp-TIyEAN/src/core/streamingSlotRegistry.ts
|
|
52
52
|
var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
|
|
53
53
|
var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
|
|
54
54
|
var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
package/dist/cli/index.js
CHANGED
|
@@ -817,6 +817,7 @@ var COMPOSE_PATH = "db/docker-compose.db.yml", DEFAULT_SERVER_ENTRY = "src/backe
|
|
|
817
817
|
console.log(` \x1B[36mp\x1B[0m / pause \u2014 Pause/resume ${title}`);
|
|
818
818
|
console.log(" \x1B[36mo\x1B[0m / open \u2014 Open in browser");
|
|
819
819
|
console.log(" \x1B[36mc\x1B[0m / clear \u2014 Clear terminal");
|
|
820
|
+
console.log(" \x1B[36mm\x1B[0m / heap \u2014 Write a heap snapshot");
|
|
820
821
|
console.log(" \x1B[36mq\x1B[0m / quit \u2014 Graceful shutdown");
|
|
821
822
|
console.log(" \x1B[36mh\x1B[0m / help \u2014 Show this help");
|
|
822
823
|
console.log(" \x1B[36m$\x1B[0m \u2014 Run a shell command");
|
|
@@ -169881,7 +169882,7 @@ var isRecord = (value) => typeof value === "object" && value !== null, getIsland
|
|
|
169881
169882
|
var init_islands = () => {};
|
|
169882
169883
|
|
|
169883
169884
|
// src/build/islandEntries.ts
|
|
169884
|
-
import { dirname as dirname3, extname, join as
|
|
169885
|
+
import { dirname as dirname3, extname, join as join8, relative, resolve as resolve6 } from "path";
|
|
169885
169886
|
var import_typescript, frameworks, isRecord2 = (value) => typeof value === "object" && value !== null, resolveRegistryExport = (mod) => {
|
|
169886
169887
|
if (isRecord2(mod.islandRegistry))
|
|
169887
169888
|
return mod.islandRegistry;
|
|
@@ -170281,7 +170282,7 @@ __export(exports_prerender, {
|
|
|
170281
170282
|
PRERENDER_BYPASS_HEADER: () => PRERENDER_BYPASS_HEADER
|
|
170282
170283
|
});
|
|
170283
170284
|
import { mkdirSync as mkdirSync5, readFileSync as readFileSync10 } from "fs";
|
|
170284
|
-
import { join as
|
|
170285
|
+
import { join as join9 } from "path";
|
|
170285
170286
|
var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_TIMEOUT_MS = 30000, PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (route) => route === "/" ? "index.html" : `${route.slice(1).replace(/\//g, "-")}.html`, writeTimestamp = async (htmlPath) => {
|
|
170286
170287
|
const metaPath = htmlPath.replace(/\.html$/, ".meta");
|
|
170287
170288
|
await Bun.write(metaPath, String(Date.now()));
|
|
@@ -170347,7 +170348,7 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
170347
170348
|
return false;
|
|
170348
170349
|
const html = await res.text();
|
|
170349
170350
|
const fileName = routeToFilename(route);
|
|
170350
|
-
const filePath =
|
|
170351
|
+
const filePath = join9(prerenderDir, fileName);
|
|
170351
170352
|
await Bun.write(filePath, html);
|
|
170352
170353
|
await writeTimestamp(filePath);
|
|
170353
170354
|
return true;
|
|
@@ -170373,13 +170374,13 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
170373
170374
|
}
|
|
170374
170375
|
const html = await res.text();
|
|
170375
170376
|
const fileName = routeToFilename(route);
|
|
170376
|
-
const filePath =
|
|
170377
|
+
const filePath = join9(prerenderDir, fileName);
|
|
170377
170378
|
await Bun.write(filePath, html);
|
|
170378
170379
|
await writeTimestamp(filePath);
|
|
170379
170380
|
result.routes.set(route, filePath);
|
|
170380
170381
|
log?.(` Pre-rendered ${route} \u2192 ${fileName} (${html.length} bytes)`);
|
|
170381
170382
|
}, prerender = async (port, outDir, staticConfig, log) => {
|
|
170382
|
-
const prerenderDir =
|
|
170383
|
+
const prerenderDir = join9(outDir, "_prerendered");
|
|
170383
170384
|
mkdirSync5(prerenderDir, { recursive: true });
|
|
170384
170385
|
const baseUrl = `http://localhost:${port}`;
|
|
170385
170386
|
let routes;
|
|
@@ -170536,7 +170537,7 @@ var init_nativeRewrite = __esm(() => {
|
|
|
170536
170537
|
|
|
170537
170538
|
// src/build/rewriteImportsPlugin.ts
|
|
170538
170539
|
import { readdir } from "fs/promises";
|
|
170539
|
-
import { join as
|
|
170540
|
+
import { join as join10 } from "path";
|
|
170540
170541
|
var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
|
|
170541
170542
|
let result = content;
|
|
170542
170543
|
for (const [specifier, webPath] of replacements) {
|
|
@@ -170614,7 +170615,7 @@ ${content}`;
|
|
|
170614
170615
|
const entries = await readdir(dir);
|
|
170615
170616
|
for (const entry of entries) {
|
|
170616
170617
|
if (entry.endsWith(".js"))
|
|
170617
|
-
allFiles.push(
|
|
170618
|
+
allFiles.push(join10(dir, entry));
|
|
170618
170619
|
}
|
|
170619
170620
|
} catch {}
|
|
170620
170621
|
}
|
|
@@ -170922,7 +170923,7 @@ __export(exports_ls, {
|
|
|
170922
170923
|
runLs: () => runLs
|
|
170923
170924
|
});
|
|
170924
170925
|
import { existsSync as existsSync11, readFileSync as readFileSync13, statSync } from "fs";
|
|
170925
|
-
import { basename as basename5, extname as extname2, join as
|
|
170926
|
+
import { basename as basename5, extname as extname2, join as join12, relative as relative2 } from "path";
|
|
170926
170927
|
var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELDS, readStringField = (source, key) => {
|
|
170927
170928
|
const value = Reflect.get(source, key);
|
|
170928
170929
|
return typeof value === "string" ? value : undefined;
|
|
@@ -170944,13 +170945,13 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
170944
170945
|
const dir = readStringField(source, framework.field);
|
|
170945
170946
|
return dir === undefined ? [] : [
|
|
170946
170947
|
{
|
|
170947
|
-
dir:
|
|
170948
|
+
dir: join12(baseDir, dir),
|
|
170948
170949
|
label: framework.label,
|
|
170949
170950
|
pattern: framework.pattern
|
|
170950
170951
|
}
|
|
170951
170952
|
];
|
|
170952
170953
|
}), scanFramework = async (spec) => {
|
|
170953
|
-
const { pageFiles } = await scanConventions(
|
|
170954
|
+
const { pageFiles } = await scanConventions(join12(spec.dir, "pages"), spec.pattern);
|
|
170954
170955
|
if (pageFiles.length === 0)
|
|
170955
170956
|
return null;
|
|
170956
170957
|
const pages = pageFiles.map((file) => ({
|
|
@@ -170974,10 +170975,10 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
170974
170975
|
}, resolveDiskPath = (buildDir, value) => {
|
|
170975
170976
|
if (existsSync11(value))
|
|
170976
170977
|
return value;
|
|
170977
|
-
const underBuild =
|
|
170978
|
+
const underBuild = join12(buildDir, value);
|
|
170978
170979
|
if (existsSync11(underBuild))
|
|
170979
170980
|
return underBuild;
|
|
170980
|
-
return
|
|
170981
|
+
return join12(process.cwd(), value);
|
|
170981
170982
|
}, fileSize = (diskPath) => {
|
|
170982
170983
|
try {
|
|
170983
170984
|
return statSync(diskPath).size;
|
|
@@ -170985,7 +170986,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
170985
170986
|
return 0;
|
|
170986
170987
|
}
|
|
170987
170988
|
}, readManifestSizes = (manifestDir) => {
|
|
170988
|
-
const manifest = JSON.parse(readFileSync13(
|
|
170989
|
+
const manifest = JSON.parse(readFileSync13(join12(manifestDir, "manifest.json"), "utf-8"));
|
|
170989
170990
|
const sizes = new Map;
|
|
170990
170991
|
Object.entries(manifest).forEach(([key, value]) => {
|
|
170991
170992
|
sizes.set(key, fileSize(resolveDiskPath(manifestDir, value)));
|
|
@@ -171004,7 +171005,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
171004
171005
|
}))
|
|
171005
171006
|
})), manifestAge = (manifestPath) => getDurationString(Date.now() - statSync(manifestPath).mtimeMs), firstBuildDir = (candidates) => candidates.map((candidate) => {
|
|
171006
171007
|
const dir = readStringField(candidate.source, "buildDirectory");
|
|
171007
|
-
return dir === undefined ? undefined :
|
|
171008
|
+
return dir === undefined ? undefined : join12(candidate.baseDir, dir);
|
|
171008
171009
|
}).find((dir) => dir !== undefined), resolveSizesDir = (args, candidates) => parseFlagValue(args, "--outdir") ?? firstBuildDir(candidates) ?? DEFAULT_BUILD_DIR, formatSize = (bytes) => {
|
|
171009
171010
|
if (bytes === null || bytes === 0)
|
|
171010
171011
|
return "-";
|
|
@@ -171083,7 +171084,7 @@ ${colors.dim}${frameworkCount} ${frameworkCount === 1 ? "framework" : "framework
|
|
|
171083
171084
|
return;
|
|
171084
171085
|
}
|
|
171085
171086
|
const sizesDir = resolveSizesDir(args, candidates);
|
|
171086
|
-
const manifestPath =
|
|
171087
|
+
const manifestPath = join12(sizesDir, "manifest.json");
|
|
171087
171088
|
if (!existsSync11(manifestPath)) {
|
|
171088
171089
|
printDim(`No build at ${relativeOrSelf(manifestPath)}. Run \`absolute build\` first, or pass \`--outdir <dir>\`.`);
|
|
171089
171090
|
return;
|
|
@@ -171127,7 +171128,10 @@ var formatBytes = (bytes) => {
|
|
|
171127
171128
|
const kilobytes = bytes / BYTES_PER_KILOBYTE;
|
|
171128
171129
|
if (kilobytes < BYTES_PER_KILOBYTE)
|
|
171129
171130
|
return `${Math.round(kilobytes)} KB`;
|
|
171130
|
-
|
|
171131
|
+
const megabytes = kilobytes / BYTES_PER_KILOBYTE;
|
|
171132
|
+
if (megabytes < BYTES_PER_KILOBYTE)
|
|
171133
|
+
return `${megabytes.toFixed(1)} MB`;
|
|
171134
|
+
return `${(megabytes / BYTES_PER_KILOBYTE).toFixed(1)} GB`;
|
|
171131
171135
|
};
|
|
171132
171136
|
var init_formatBytes = __esm(() => {
|
|
171133
171137
|
init_constants();
|
|
@@ -171261,7 +171265,7 @@ __export(exports_psTui, {
|
|
|
171261
171265
|
});
|
|
171262
171266
|
import { spawn } from "child_process";
|
|
171263
171267
|
import { closeSync, fstatSync, openSync as openSync3, readSync } from "fs";
|
|
171264
|
-
var TUI_HEADERS, STATUS_INDEX =
|
|
171268
|
+
var TUI_HEADERS, STATUS_INDEX = 8, URL_INDEX = 9, MEM_HISTORY_MAX = 12, SPARK_CHARS = "\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588", helpLines2, statusLevelColor = (level) => {
|
|
171265
171269
|
if (level === "error")
|
|
171266
171270
|
return colors.red;
|
|
171267
171271
|
if (level === "warn")
|
|
@@ -171275,16 +171279,17 @@ var TUI_HEADERS, STATUS_INDEX = 6, URL_INDEX = 7, helpLines2, statusLevelColor =
|
|
|
171275
171279
|
if (status2 === "starting")
|
|
171276
171280
|
return colors.yellow;
|
|
171277
171281
|
return colors.dim;
|
|
171278
|
-
},
|
|
171279
|
-
|
|
171280
|
-
|
|
171281
|
-
|
|
171282
|
-
|
|
171283
|
-
|
|
171284
|
-
|
|
171285
|
-
|
|
171286
|
-
|
|
171287
|
-
|
|
171282
|
+
}, sparkline = (samples) => {
|
|
171283
|
+
if (samples.length === 0)
|
|
171284
|
+
return "";
|
|
171285
|
+
const max = Math.max(...samples);
|
|
171286
|
+
const min = Math.min(...samples);
|
|
171287
|
+
const range = max - min;
|
|
171288
|
+
return samples.map((value) => {
|
|
171289
|
+
const level = range === 0 ? 0 : Math.round((value - min) / range * (SPARK_CHARS.length - 1));
|
|
171290
|
+
return SPARK_CHARS[level] ?? SPARK_CHARS[0];
|
|
171291
|
+
}).join("");
|
|
171292
|
+
}, columnWidths2 = (allCells) => TUI_HEADERS.map((header, index) => Math.max(visibleLength(header), ...allCells.map((cells) => visibleLength(cells[index] ?? "")))), layoutWidths = (allCells, width) => {
|
|
171288
171293
|
const natural = columnWidths2(allCells);
|
|
171289
171294
|
const gaps = (TUI_HEADERS.length - 1) * LIST_TUI_COLUMN_GAP;
|
|
171290
171295
|
const available = width - LIST_TUI_MARKER_WIDTH - gaps;
|
|
@@ -171317,6 +171322,7 @@ var TUI_HEADERS, STATUS_INDEX = 6, URL_INDEX = 7, helpLines2, statusLevelColor =
|
|
|
171317
171322
|
}, driveListTui = async (terminal) => {
|
|
171318
171323
|
const { promise, resolve: resolveExit } = Promise.withResolvers();
|
|
171319
171324
|
let instances = [];
|
|
171325
|
+
const memoryHistory = new Map;
|
|
171320
171326
|
let selectedIndex = 0;
|
|
171321
171327
|
let mode = "list";
|
|
171322
171328
|
let helpVisible = false;
|
|
@@ -171350,9 +171356,24 @@ var TUI_HEADERS, STATUS_INDEX = 6, URL_INDEX = 7, helpLines2, statusLevelColor =
|
|
|
171350
171356
|
}, LIST_TUI_STATUS_MESSAGE_TIMEOUT_MS);
|
|
171351
171357
|
scheduleRender();
|
|
171352
171358
|
};
|
|
171359
|
+
const recordMemory = () => {
|
|
171360
|
+
const livePids = new Set(instances.map((entry) => entry.pid));
|
|
171361
|
+
instances.forEach((entry) => {
|
|
171362
|
+
const samples = memoryHistory.get(entry.pid) ?? [];
|
|
171363
|
+
samples.push(entry.memoryBytes ?? 0);
|
|
171364
|
+
if (samples.length > MEM_HISTORY_MAX)
|
|
171365
|
+
samples.shift();
|
|
171366
|
+
memoryHistory.set(entry.pid, samples);
|
|
171367
|
+
});
|
|
171368
|
+
[...memoryHistory.keys()].forEach((pid) => {
|
|
171369
|
+
if (!livePids.has(pid))
|
|
171370
|
+
memoryHistory.delete(pid);
|
|
171371
|
+
});
|
|
171372
|
+
};
|
|
171353
171373
|
const refresh = async () => {
|
|
171354
171374
|
const previousPid = selectedInstance()?.pid;
|
|
171355
171375
|
instances = await enrichInstances(await discoverInstances());
|
|
171376
|
+
recordMemory();
|
|
171356
171377
|
const foundIndex = previousPid === undefined ? 0 : instances.findIndex((instance) => instance.pid === previousPid);
|
|
171357
171378
|
selectedIndex = foundIndex >= 0 ? foundIndex : Math.min(selectedIndex, Math.max(0, instances.length - 1));
|
|
171358
171379
|
scheduleRender();
|
|
@@ -171649,17 +171670,33 @@ var TUI_HEADERS, STATUS_INDEX = 6, URL_INDEX = 7, helpLines2, statusLevelColor =
|
|
|
171649
171670
|
}
|
|
171650
171671
|
return padded;
|
|
171651
171672
|
};
|
|
171673
|
+
const cellsFor = (instance) => {
|
|
171674
|
+
const history = memoryHistory.get(instance.pid) ?? [];
|
|
171675
|
+
const peak = history.length > 0 ? Math.max(...history) : instance.memoryBytes ?? 0;
|
|
171676
|
+
return [
|
|
171677
|
+
instance.name,
|
|
171678
|
+
instance.source,
|
|
171679
|
+
instance.port === null ? "-" : String(instance.port),
|
|
171680
|
+
String(instance.pid),
|
|
171681
|
+
getDurationString(instance.uptimeMs),
|
|
171682
|
+
formatBytes(instance.memoryBytes),
|
|
171683
|
+
formatBytes(peak),
|
|
171684
|
+
sparkline(history),
|
|
171685
|
+
instance.status,
|
|
171686
|
+
instance.url ?? "-"
|
|
171687
|
+
];
|
|
171688
|
+
};
|
|
171652
171689
|
const renderInstanceRow = (instance, widths, isSelected) => {
|
|
171653
|
-
const body =
|
|
171690
|
+
const body = cellsFor(instance).map((cell, index) => colorizeCell(cell, index, instance.status, isSelected, widths)).join(" ".repeat(LIST_TUI_COLUMN_GAP));
|
|
171654
171691
|
const marker = isSelected ? `${colors.cyan}\u276F${colors.reset}` : " ";
|
|
171655
171692
|
return `${marker} ${body}`;
|
|
171656
171693
|
};
|
|
171657
171694
|
const pushInstanceRows = (rows, width) => {
|
|
171658
171695
|
if (instances.length === 0) {
|
|
171659
|
-
rows.push(padLine(`${colors.dim}No servers
|
|
171696
|
+
rows.push(padLine(`${colors.dim}No running servers found. Start one with \`absolute dev\`, \`start\`, or \`workspace dev\`.${colors.reset}`, width));
|
|
171660
171697
|
return;
|
|
171661
171698
|
}
|
|
171662
|
-
const allCells = instances.map(
|
|
171699
|
+
const allCells = instances.map(cellsFor);
|
|
171663
171700
|
const widths = layoutWidths(allCells, width);
|
|
171664
171701
|
const header = TUI_HEADERS.map((label, index) => padLine(label, widths[index] ?? 0)).join(" ".repeat(LIST_TUI_COLUMN_GAP));
|
|
171665
171702
|
rows.push(padLine(` ${colors.dim}${header}${colors.reset}`, width));
|
|
@@ -171769,6 +171806,8 @@ var init_psTui = __esm(() => {
|
|
|
171769
171806
|
"PID",
|
|
171770
171807
|
"UPTIME",
|
|
171771
171808
|
"MEM",
|
|
171809
|
+
"PEAK",
|
|
171810
|
+
"TREND",
|
|
171772
171811
|
"STATUS",
|
|
171773
171812
|
"URL"
|
|
171774
171813
|
];
|
|
@@ -171815,7 +171854,7 @@ var killPid = (pid) => {
|
|
|
171815
171854
|
instance.url ?? "-"
|
|
171816
171855
|
], columnWidths3 = (rows) => TABLE_HEADERS.map((header, index) => Math.max(visibleLength(header), ...rows.map((cells) => visibleLength(cells[index] ?? "")))), renderRow = (cells, widths) => cells.map((cell, index) => padLine(cell, widths[index] ?? 0)).join(" ".repeat(LIST_TUI_COLUMN_GAP)), printInstanceTable = (instances) => {
|
|
171817
171856
|
if (instances.length === 0) {
|
|
171818
|
-
process.stdout.write(`${colors.dim}No
|
|
171857
|
+
process.stdout.write(`${colors.dim}No running servers found. Start one with \`absolute dev\`, \`start\`, or \`workspace dev\`.${colors.reset}
|
|
171819
171858
|
`);
|
|
171820
171859
|
return;
|
|
171821
171860
|
}
|
|
@@ -171882,9 +171921,74 @@ var init_ps = __esm(() => {
|
|
|
171882
171921
|
];
|
|
171883
171922
|
});
|
|
171884
171923
|
|
|
171924
|
+
// src/cli/scripts/mem.ts
|
|
171925
|
+
var exports_mem = {};
|
|
171926
|
+
__export(exports_mem, {
|
|
171927
|
+
runMem: () => runMem
|
|
171928
|
+
});
|
|
171929
|
+
import { freemem, totalmem as totalmem2 } from "os";
|
|
171930
|
+
var BAR_WIDTH = 12, PERCENT = 100, HEADERS, sumMemory = (instances) => instances.reduce((total, instance) => total + (instance.memoryBytes ?? 0), 0), memBar = (fraction) => {
|
|
171931
|
+
const filled = Math.max(0, Math.min(BAR_WIDTH, Math.round(fraction * BAR_WIDTH)));
|
|
171932
|
+
return `${"\u2588".repeat(filled)}${colors.dim}${"\u2591".repeat(BAR_WIDTH - filled)}${colors.reset}`;
|
|
171933
|
+
}, instanceCells2 = (instance, systemTotal) => {
|
|
171934
|
+
const rss = instance.memoryBytes ?? 0;
|
|
171935
|
+
const fraction = systemTotal > 0 ? rss / systemTotal : 0;
|
|
171936
|
+
return [
|
|
171937
|
+
instance.name,
|
|
171938
|
+
instance.source,
|
|
171939
|
+
instance.port === null ? "-" : String(instance.port),
|
|
171940
|
+
formatBytes(instance.memoryBytes),
|
|
171941
|
+
`${memBar(fraction)} ${(fraction * PERCENT).toFixed(1)}%`
|
|
171942
|
+
];
|
|
171943
|
+
}, columnWidths4 = (rows) => HEADERS.map((header, index) => Math.max(visibleLength(header), ...rows.map((cells) => visibleLength(cells[index] ?? "")))), renderRow2 = (cells, widths) => cells.map((cell, index) => padLine(cell, widths[index] ?? 0)).join(" ".repeat(LIST_TUI_COLUMN_GAP)), printReport = (instances) => {
|
|
171944
|
+
const systemTotal = totalmem2();
|
|
171945
|
+
const used = systemTotal - freemem();
|
|
171946
|
+
const rows = instances.map((instance) => instanceCells2(instance, systemTotal));
|
|
171947
|
+
const widths = columnWidths4(rows);
|
|
171948
|
+
const count = instances.length;
|
|
171949
|
+
const lines = [
|
|
171950
|
+
`${colors.dim}${renderRow2(HEADERS, widths)}${colors.reset}`,
|
|
171951
|
+
...rows.map((cells) => renderRow2(cells, widths)),
|
|
171952
|
+
"",
|
|
171953
|
+
`${colors.dim}${count} server${count === 1 ? "" : "s"} \xB7 ${formatBytes(sumMemory(instances))} resident total${colors.reset}`,
|
|
171954
|
+
`${colors.dim}system ${formatBytes(used)} / ${formatBytes(systemTotal)} used \xB7 ${formatBytes(freemem())} free${colors.reset}`
|
|
171955
|
+
];
|
|
171956
|
+
process.stdout.write(`${lines.join(`
|
|
171957
|
+
`)}
|
|
171958
|
+
`);
|
|
171959
|
+
}, runMem = async (args) => {
|
|
171960
|
+
const instances = (await enrichInstances(await discoverInstances())).sort((left, right) => (right.memoryBytes ?? 0) - (left.memoryBytes ?? 0));
|
|
171961
|
+
if (args.includes("--json")) {
|
|
171962
|
+
process.stdout.write(`${JSON.stringify({
|
|
171963
|
+
instances,
|
|
171964
|
+
system: {
|
|
171965
|
+
freeBytes: freemem(),
|
|
171966
|
+
totalBytes: totalmem2(),
|
|
171967
|
+
usedBytes: totalmem2() - freemem()
|
|
171968
|
+
}
|
|
171969
|
+
}, null, 2)}
|
|
171970
|
+
`);
|
|
171971
|
+
return;
|
|
171972
|
+
}
|
|
171973
|
+
if (instances.length === 0) {
|
|
171974
|
+
process.stdout.write(`${colors.dim}No running servers found.${colors.reset}
|
|
171975
|
+
`);
|
|
171976
|
+
return;
|
|
171977
|
+
}
|
|
171978
|
+
printReport(instances);
|
|
171979
|
+
};
|
|
171980
|
+
var init_mem = __esm(() => {
|
|
171981
|
+
init_constants();
|
|
171982
|
+
init_formatBytes();
|
|
171983
|
+
init_discoverInstances();
|
|
171984
|
+
init_instanceStatus();
|
|
171985
|
+
init_tuiPrimitives();
|
|
171986
|
+
HEADERS = ["NAME", "SOURCE", "PORT", "RSS", "% SYS"];
|
|
171987
|
+
});
|
|
171988
|
+
|
|
171885
171989
|
// src/build/externalAssetPlugin.ts
|
|
171886
171990
|
import { copyFileSync as copyFileSync2, existsSync as existsSync12, mkdirSync as mkdirSync7, statSync as statSync2 } from "fs";
|
|
171887
|
-
import { basename as basename6, dirname as dirname4, join as
|
|
171991
|
+
import { basename as basename6, dirname as dirname4, join as join13, resolve as resolve11 } from "path";
|
|
171888
171992
|
var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
171889
171993
|
name: "absolute-external-asset",
|
|
171890
171994
|
setup(bld) {
|
|
@@ -171909,7 +172013,7 @@ var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
|
171909
172013
|
continue;
|
|
171910
172014
|
if (!statSync2(assetPath).isFile())
|
|
171911
172015
|
continue;
|
|
171912
|
-
const targetPath =
|
|
172016
|
+
const targetPath = join13(outDir, basename6(assetPath));
|
|
171913
172017
|
if (existsSync12(targetPath))
|
|
171914
172018
|
continue;
|
|
171915
172019
|
mkdirSync7(dirname4(targetPath), { recursive: true });
|
|
@@ -171934,12 +172038,12 @@ import {
|
|
|
171934
172038
|
mkdirSync as mkdirSync8,
|
|
171935
172039
|
readdirSync as readdirSync3,
|
|
171936
172040
|
readFileSync as readFileSync14,
|
|
171937
|
-
rmSync as
|
|
172041
|
+
rmSync as rmSync5,
|
|
171938
172042
|
statSync as statSync3,
|
|
171939
172043
|
unlinkSync as unlinkSync4,
|
|
171940
|
-
writeFileSync as
|
|
172044
|
+
writeFileSync as writeFileSync6
|
|
171941
172045
|
} from "fs";
|
|
171942
|
-
import { basename as basename7, dirname as dirname5, join as
|
|
172046
|
+
import { basename as basename7, dirname as dirname5, join as join14, relative as relative3, resolve as resolve12 } from "path";
|
|
171943
172047
|
var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
|
|
171944
172048
|
const resolvedVersion = version2 || "unknown";
|
|
171945
172049
|
console.log("");
|
|
@@ -171952,7 +172056,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
171952
172056
|
const entry = pending.pop();
|
|
171953
172057
|
if (!entry)
|
|
171954
172058
|
continue;
|
|
171955
|
-
const fullPath =
|
|
172059
|
+
const fullPath = join14(entry.parentPath, entry.name);
|
|
171956
172060
|
if (entry.isDirectory())
|
|
171957
172061
|
pending = pending.concat(readdirSync3(fullPath, { withFileTypes: true }));
|
|
171958
172062
|
else
|
|
@@ -171972,7 +172076,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
171972
172076
|
const entry = pending.pop();
|
|
171973
172077
|
if (!entry)
|
|
171974
172078
|
continue;
|
|
171975
|
-
const fullPath =
|
|
172079
|
+
const fullPath = join14(entry.parentPath, entry.name);
|
|
171976
172080
|
if (entry.isDirectory()) {
|
|
171977
172081
|
if (SERVER_RUNTIME_SCAN_SKIP_DIRS.has(entry.name))
|
|
171978
172082
|
continue;
|
|
@@ -172087,7 +172191,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
172087
172191
|
return true;
|
|
172088
172192
|
}, tryReadNodePackageJson = (packageDir) => {
|
|
172089
172193
|
try {
|
|
172090
|
-
return JSON.parse(readFileSync14(
|
|
172194
|
+
return JSON.parse(readFileSync14(join14(packageDir, "package.json"), "utf-8"));
|
|
172091
172195
|
} catch {
|
|
172092
172196
|
return null;
|
|
172093
172197
|
}
|
|
@@ -172099,8 +172203,8 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
172099
172203
|
if (!pkg)
|
|
172100
172204
|
return;
|
|
172101
172205
|
seen.add(specifier);
|
|
172102
|
-
const destDir =
|
|
172103
|
-
|
|
172206
|
+
const destDir = join14(outdir, "node_modules", ...specifier.split("/"));
|
|
172207
|
+
rmSync5(destDir, { force: true, recursive: true });
|
|
172104
172208
|
cpSync(srcDir, destDir, {
|
|
172105
172209
|
force: true,
|
|
172106
172210
|
recursive: true,
|
|
@@ -172139,7 +172243,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
172139
172243
|
}
|
|
172140
172244
|
copyAngularRuntimePackages(buildConfig, outdir);
|
|
172141
172245
|
}, collectRuntimePackageSpecifiers = (distDir) => {
|
|
172142
|
-
const nodeModulesDir =
|
|
172246
|
+
const nodeModulesDir = join14(distDir, "node_modules");
|
|
172143
172247
|
if (!existsSync13(nodeModulesDir))
|
|
172144
172248
|
return [];
|
|
172145
172249
|
const specifiers = [];
|
|
@@ -172147,7 +172251,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
172147
172251
|
if (!entry.isDirectory())
|
|
172148
172252
|
continue;
|
|
172149
172253
|
if (entry.name.startsWith("@")) {
|
|
172150
|
-
const scopeDir =
|
|
172254
|
+
const scopeDir = join14(nodeModulesDir, entry.name);
|
|
172151
172255
|
for (const scopedEntry of readdirSync3(scopeDir, {
|
|
172152
172256
|
withFileTypes: true
|
|
172153
172257
|
})) {
|
|
@@ -172179,18 +172283,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
172179
172283
|
const packageSpecifier = packageSpecifiers.find((root) => specifier === root || specifier.startsWith(`${root}/`));
|
|
172180
172284
|
if (!packageSpecifier)
|
|
172181
172285
|
return null;
|
|
172182
|
-
const packageDir =
|
|
172286
|
+
const packageDir = join14(distDir, "node_modules", ...packageSpecifier.split("/"));
|
|
172183
172287
|
const subpath = specifier.slice(packageSpecifier.length);
|
|
172184
|
-
const subPackageDir = subpath ?
|
|
172185
|
-
const resolvedPackageDir = subPackageDir && existsSync13(
|
|
172186
|
-
const packageJsonPath =
|
|
172288
|
+
const subPackageDir = subpath ? join14(packageDir, ...subpath.slice(1).split("/")) : null;
|
|
172289
|
+
const resolvedPackageDir = subPackageDir && existsSync13(join14(subPackageDir, "package.json")) ? subPackageDir : packageDir;
|
|
172290
|
+
const packageJsonPath = join14(resolvedPackageDir, "package.json");
|
|
172187
172291
|
if (!existsSync13(packageJsonPath))
|
|
172188
172292
|
return null;
|
|
172189
172293
|
const pkg = JSON.parse(readFileSync14(packageJsonPath, "utf-8"));
|
|
172190
172294
|
const exportKey = resolvedPackageDir !== subPackageDir && subpath ? `.${subpath}` : ".";
|
|
172191
172295
|
const rootExport = pkg.exports?.[exportKey];
|
|
172192
172296
|
const entry = pickExportEntry(rootExport) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
|
|
172193
|
-
return
|
|
172297
|
+
return join14(resolvedPackageDir, entry);
|
|
172194
172298
|
}, RUNTIME_JS_EXTENSIONS, MODULE_SPECIFIER_RE, isRuntimeJsFile = (filePath) => RUNTIME_JS_EXTENSIONS.some((extension) => filePath.endsWith(extension)), isNodeModulesPath = (filePath) => filePath.split(/[\\/]/).includes("node_modules"), isFile = (filePath) => {
|
|
172195
172299
|
try {
|
|
172196
172300
|
return statSync3(filePath).isFile();
|
|
@@ -172203,13 +172307,13 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
172203
172307
|
const candidates = [
|
|
172204
172308
|
candidate,
|
|
172205
172309
|
...RUNTIME_JS_EXTENSIONS.map((extension) => `${candidate}${extension}`),
|
|
172206
|
-
...RUNTIME_JS_EXTENSIONS.map((extension) =>
|
|
172310
|
+
...RUNTIME_JS_EXTENSIONS.map((extension) => join14(candidate, `index${extension}`))
|
|
172207
172311
|
];
|
|
172208
172312
|
return candidates.find((filePath) => isRuntimeJsFile(filePath) && isFile(filePath)) ?? null;
|
|
172209
172313
|
}, findContainingRuntimePackageDir = (filePath) => {
|
|
172210
172314
|
let dir = dirname5(filePath);
|
|
172211
172315
|
while (dir !== dirname5(dir)) {
|
|
172212
|
-
if (isNodeModulesPath(dir) && existsSync13(
|
|
172316
|
+
if (isNodeModulesPath(dir) && existsSync13(join14(dir, "package.json"))) {
|
|
172213
172317
|
return dir;
|
|
172214
172318
|
}
|
|
172215
172319
|
dir = dirname5(dir);
|
|
@@ -172225,7 +172329,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
172225
172329
|
const entry = pickExportEntry(pkg?.imports?.[specifier]);
|
|
172226
172330
|
if (!entry)
|
|
172227
172331
|
return null;
|
|
172228
|
-
return
|
|
172332
|
+
return join14(packageDir, entry);
|
|
172229
172333
|
}, collectRuntimeRewriteRoots = (distDir) => collectFiles2(distDir).filter((filePath) => isRuntimeJsFile(filePath) && !isNodeModulesPath(filePath)), rewriteRuntimeModuleSpecifiers = (distDir) => {
|
|
172230
172334
|
const packageSpecifiers = collectRuntimePackageSpecifiers(distDir);
|
|
172231
172335
|
if (packageSpecifiers.length === 0)
|
|
@@ -172262,7 +172366,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
172262
172366
|
return `${prefix}${quote}${ensureRelativeModuleSpecifier(filePath, target)}${quote}`;
|
|
172263
172367
|
});
|
|
172264
172368
|
if (rewritten !== source) {
|
|
172265
|
-
|
|
172369
|
+
writeFileSync6(filePath, rewritten);
|
|
172266
172370
|
}
|
|
172267
172371
|
}
|
|
172268
172372
|
}, generateEntrypoint = (distDir, serverEntry, prerenderMap, version2, buildConfig) => {
|
|
@@ -172808,7 +172912,7 @@ console.log(\`
|
|
|
172808
172912
|
copyServerRuntimeAssetReferences(resolvedOutdir);
|
|
172809
172913
|
const prerenderStart = performance.now();
|
|
172810
172914
|
process.stdout.write(cliTag4("\x1B[36m", "Pre-rendering pages"));
|
|
172811
|
-
|
|
172915
|
+
rmSync5(join14(resolvedOutdir, "_prerendered"), {
|
|
172812
172916
|
force: true,
|
|
172813
172917
|
recursive: true
|
|
172814
172918
|
});
|
|
@@ -172827,7 +172931,7 @@ console.log(\`
|
|
|
172827
172931
|
const compileStart = performance.now();
|
|
172828
172932
|
process.stdout.write(cliTag4("\x1B[36m", "Compiling standalone executable"));
|
|
172829
172933
|
const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion, buildConfig);
|
|
172830
|
-
const entrypointPath =
|
|
172934
|
+
const entrypointPath = join14(resolvedOutdir, "_compile_entrypoint.ts");
|
|
172831
172935
|
await Bun.write(entrypointPath, entrypointCode);
|
|
172832
172936
|
mkdirSync8(dirname5(resolvedOutfile), { recursive: true });
|
|
172833
172937
|
const result = await Bun.build({
|
|
@@ -172923,7 +173027,7 @@ var exports_typecheck = {};
|
|
|
172923
173027
|
__export(exports_typecheck, {
|
|
172924
173028
|
typecheck: () => typecheck
|
|
172925
173029
|
});
|
|
172926
|
-
import { resolve as resolve13, join as
|
|
173030
|
+
import { resolve as resolve13, join as join15 } from "path";
|
|
172927
173031
|
import { existsSync as existsSync14, readFileSync as readFileSync15 } from "fs";
|
|
172928
173032
|
import { mkdir as mkdir2, writeFile } from "fs/promises";
|
|
172929
173033
|
var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), resolveConfigPath = (configPath2) => resolve13(configPath2 ?? process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts"), getTypecheckTargets = async (configPath2) => {
|
|
@@ -173031,7 +173135,7 @@ Found ${errorCount} error${suffix}.`;
|
|
|
173031
173135
|
console.error("\x1B[31m\u2717\x1B[0m vue-tsc is required for Vue type checking. Install it: bun add -d vue-tsc");
|
|
173032
173136
|
process.exit(1);
|
|
173033
173137
|
}
|
|
173034
|
-
const vueTsconfigPath =
|
|
173138
|
+
const vueTsconfigPath = join15(cacheDir, "tsconfig.vue-check.json");
|
|
173035
173139
|
return writeFile(vueTsconfigPath, JSON.stringify({
|
|
173036
173140
|
compilerOptions: {
|
|
173037
173141
|
rootDir: ".."
|
|
@@ -173046,7 +173150,7 @@ Found ${errorCount} error${suffix}.`;
|
|
|
173046
173150
|
resolve13(vueTsconfigPath),
|
|
173047
173151
|
"--incremental",
|
|
173048
173152
|
"--tsBuildInfoFile",
|
|
173049
|
-
|
|
173153
|
+
join15(cacheDir, "vue-tsc.tsbuildinfo"),
|
|
173050
173154
|
"--pretty"
|
|
173051
173155
|
]));
|
|
173052
173156
|
}, buildAngularCheck = async (cacheDir, angularDir) => {
|
|
@@ -173055,7 +173159,7 @@ Found ${errorCount} error${suffix}.`;
|
|
|
173055
173159
|
console.error("\x1B[31m\u2717\x1B[0m @angular/compiler-cli is required for Angular type checking. Install it: bun add -d @angular/compiler-cli");
|
|
173056
173160
|
process.exit(1);
|
|
173057
173161
|
}
|
|
173058
|
-
const angularTsconfigPath =
|
|
173162
|
+
const angularTsconfigPath = join15(cacheDir, "tsconfig.angular-check.json");
|
|
173059
173163
|
await writeFile(angularTsconfigPath, JSON.stringify({
|
|
173060
173164
|
angularCompilerOptions: {
|
|
173061
173165
|
strictTemplates: true
|
|
@@ -173075,7 +173179,7 @@ Found ${errorCount} error${suffix}.`;
|
|
|
173075
173179
|
console.error("\x1B[31m\u2717\x1B[0m typescript is required for type checking. Install it: bun add -d typescript");
|
|
173076
173180
|
process.exit(1);
|
|
173077
173181
|
}
|
|
173078
|
-
const tscConfigPath =
|
|
173182
|
+
const tscConfigPath = join15(cacheDir, "tsconfig.typecheck.json");
|
|
173079
173183
|
return writeFile(tscConfigPath, JSON.stringify({
|
|
173080
173184
|
compilerOptions: {
|
|
173081
173185
|
rootDir: ".."
|
|
@@ -173090,7 +173194,7 @@ Found ${errorCount} error${suffix}.`;
|
|
|
173090
173194
|
resolve13(tscConfigPath),
|
|
173091
173195
|
"--incremental",
|
|
173092
173196
|
"--tsBuildInfoFile",
|
|
173093
|
-
|
|
173197
|
+
join15(cacheDir, "tsc.tsbuildinfo"),
|
|
173094
173198
|
"--pretty"
|
|
173095
173199
|
]));
|
|
173096
173200
|
}, buildSvelteCheck = async (cacheDir, svelteDir) => {
|
|
@@ -173099,7 +173203,7 @@ Found ${errorCount} error${suffix}.`;
|
|
|
173099
173203
|
console.error("\x1B[31m\u2717\x1B[0m svelte-check is required for Svelte type checking. Install it: bun add -d svelte-check");
|
|
173100
173204
|
process.exit(1);
|
|
173101
173205
|
}
|
|
173102
|
-
const svelteTsconfigPath =
|
|
173206
|
+
const svelteTsconfigPath = join15(cacheDir, "tsconfig.svelte-check.json");
|
|
173103
173207
|
await writeFile(svelteTsconfigPath, JSON.stringify({
|
|
173104
173208
|
extends: resolve13("tsconfig.json"),
|
|
173105
173209
|
files: ABSOLUTE_TYPECHECK_FILES,
|
|
@@ -173343,8 +173447,15 @@ var init_tunnelRelay = __esm(() => {
|
|
|
173343
173447
|
init_constants();
|
|
173344
173448
|
var {$: $3, env } = globalThis.Bun;
|
|
173345
173449
|
import { spawn as nodeSpawn } from "child_process";
|
|
173346
|
-
import {
|
|
173347
|
-
|
|
173450
|
+
import {
|
|
173451
|
+
createWriteStream,
|
|
173452
|
+
existsSync as existsSync5,
|
|
173453
|
+
readFileSync as readFileSync7,
|
|
173454
|
+
rmSync as rmSync2,
|
|
173455
|
+
writeFileSync as writeFileSync4
|
|
173456
|
+
} from "fs";
|
|
173457
|
+
import { tmpdir } from "os";
|
|
173458
|
+
import { join as join6, resolve as resolve3 } from "path";
|
|
173348
173459
|
|
|
173349
173460
|
// src/dev/tunnel/client.ts
|
|
173350
173461
|
var RECONNECT_DELAY_MS = 2000;
|
|
@@ -173509,6 +173620,7 @@ import { ReadStream } from "tty";
|
|
|
173509
173620
|
var SHORTCUTS = {
|
|
173510
173621
|
c: "clear",
|
|
173511
173622
|
h: "help",
|
|
173623
|
+
m: "heapSnapshot",
|
|
173512
173624
|
o: "open",
|
|
173513
173625
|
p: "pause",
|
|
173514
173626
|
q: "quit",
|
|
@@ -173516,12 +173628,14 @@ var SHORTCUTS = {
|
|
|
173516
173628
|
};
|
|
173517
173629
|
var WORD_COMMANDS = {
|
|
173518
173630
|
clear: "clear",
|
|
173631
|
+
heap: "heapSnapshot",
|
|
173519
173632
|
help: "help",
|
|
173520
173633
|
open: "open",
|
|
173521
173634
|
pause: "pause",
|
|
173522
173635
|
quit: "quit",
|
|
173523
173636
|
restart: "restart",
|
|
173524
|
-
resume: "pause"
|
|
173637
|
+
resume: "pause",
|
|
173638
|
+
snapshot: "heapSnapshot"
|
|
173525
173639
|
};
|
|
173526
173640
|
var trySetRawMode = () => {
|
|
173527
173641
|
if (typeof process.stdin.setRawMode !== "function") {
|
|
@@ -173816,6 +173930,16 @@ var resolveDevPort = async (requestedPort, options = {}) => {
|
|
|
173816
173930
|
init_utils();
|
|
173817
173931
|
var cliTag = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`;
|
|
173818
173932
|
var DEFAULT_PORT_RANGE = 10;
|
|
173933
|
+
var HEAP_SNAPSHOT_PRELOAD = `process.on('SIGUSR2', () => {
|
|
173934
|
+
try {
|
|
173935
|
+
const file = 'heap-' + process.pid + '-' + Date.now() + '.heapsnapshot';
|
|
173936
|
+
Bun.write(file, Bun.generateHeapSnapshot('v8'));
|
|
173937
|
+
console.log('[absolute] heap snapshot written: ' + file + ' (open in DevTools Memory tab)');
|
|
173938
|
+
} catch (error) {
|
|
173939
|
+
console.error('[absolute] heap snapshot failed:', error);
|
|
173940
|
+
}
|
|
173941
|
+
});
|
|
173942
|
+
`;
|
|
173819
173943
|
var ANSI_LOG_REGEX = new RegExp(`${String.fromCharCode(ANSI_ESCAPE_CODE)}\\[[0-?]*[ -/]*[@-~]`, "g");
|
|
173820
173944
|
var confirmPrompt = (message, defaultYes = true) => {
|
|
173821
173945
|
const { promise, resolve: resolvePrompt } = Promise.withResolvers();
|
|
@@ -174078,9 +174202,29 @@ var dev = async (serverEntry, configPath2) => {
|
|
|
174078
174202
|
}
|
|
174079
174203
|
return merged;
|
|
174080
174204
|
};
|
|
174205
|
+
const heapPreloadPath = join6(tmpdir(), `absolute-heap-${process.pid}.ts`);
|
|
174206
|
+
let heapSnapshotEnabled = false;
|
|
174207
|
+
try {
|
|
174208
|
+
writeFileSync4(heapPreloadPath, HEAP_SNAPSHOT_PRELOAD);
|
|
174209
|
+
heapSnapshotEnabled = true;
|
|
174210
|
+
} catch {
|
|
174211
|
+
heapSnapshotEnabled = false;
|
|
174212
|
+
}
|
|
174213
|
+
const removeHeapPreload = () => {
|
|
174214
|
+
if (!heapSnapshotEnabled)
|
|
174215
|
+
return;
|
|
174216
|
+
try {
|
|
174217
|
+
rmSync2(heapPreloadPath, { force: true });
|
|
174218
|
+
} catch {}
|
|
174219
|
+
};
|
|
174081
174220
|
const spawnServer = async () => {
|
|
174082
174221
|
await refreshDevConfigForSpawn();
|
|
174083
|
-
const proc = nodeSpawn("bun", [
|
|
174222
|
+
const proc = nodeSpawn("bun", [
|
|
174223
|
+
"--hot",
|
|
174224
|
+
"--no-clear-screen",
|
|
174225
|
+
...heapSnapshotEnabled ? ["--preload", heapPreloadPath] : [],
|
|
174226
|
+
serverEntry
|
|
174227
|
+
], {
|
|
174084
174228
|
cwd: process.cwd(),
|
|
174085
174229
|
detached: true,
|
|
174086
174230
|
env: {
|
|
@@ -174129,7 +174273,7 @@ var dev = async (serverEntry, configPath2) => {
|
|
|
174129
174273
|
};
|
|
174130
174274
|
try {
|
|
174131
174275
|
const { watch } = await import("fs");
|
|
174132
|
-
const { dirname: dirname3, join:
|
|
174276
|
+
const { dirname: dirname3, join: join7 } = await import("path");
|
|
174133
174277
|
const absServerEntry = resolve3(serverEntry);
|
|
174134
174278
|
const serverEntryDir = dirname3(absServerEntry);
|
|
174135
174279
|
const ROOT_RESTART_DENY = new Set([
|
|
@@ -174162,7 +174306,7 @@ var dev = async (serverEntry, configPath2) => {
|
|
|
174162
174306
|
if (now - last < 100)
|
|
174163
174307
|
return;
|
|
174164
174308
|
recentlyHandled.set(filename, now);
|
|
174165
|
-
scheduleServerRestart(
|
|
174309
|
+
scheduleServerRestart(join7(serverEntryDir, filename));
|
|
174166
174310
|
};
|
|
174167
174311
|
const recoveryScan = async () => {
|
|
174168
174312
|
let entries;
|
|
@@ -174181,7 +174325,7 @@ var dev = async (serverEntry, configPath2) => {
|
|
|
174181
174325
|
continue;
|
|
174182
174326
|
let st;
|
|
174183
174327
|
try {
|
|
174184
|
-
st = statSync(
|
|
174328
|
+
st = statSync(join7(serverEntryDir, entry.name));
|
|
174185
174329
|
} catch {
|
|
174186
174330
|
continue;
|
|
174187
174331
|
}
|
|
@@ -174268,6 +174412,7 @@ var dev = async (serverEntry, configPath2) => {
|
|
|
174268
174412
|
instanceLog.end();
|
|
174269
174413
|
} catch {}
|
|
174270
174414
|
deregisterInstance(instancePid);
|
|
174415
|
+
removeHeapPreload();
|
|
174271
174416
|
process.exit(exitCode);
|
|
174272
174417
|
};
|
|
174273
174418
|
const restartServer = async () => {
|
|
@@ -174352,11 +174497,29 @@ var dev = async (serverEntry, configPath2) => {
|
|
|
174352
174497
|
console.log(cliTag("\x1B[33m", `Could not open browser. Visit ${url}`));
|
|
174353
174498
|
}
|
|
174354
174499
|
};
|
|
174500
|
+
const triggerHeapSnapshot = () => {
|
|
174501
|
+
if (!heapSnapshotEnabled) {
|
|
174502
|
+
console.log(cliTag("\x1B[33m", "Heap snapshot unavailable (no preload)."));
|
|
174503
|
+
return;
|
|
174504
|
+
}
|
|
174505
|
+
const childPid = serverProcess.pid;
|
|
174506
|
+
if (childPid === undefined)
|
|
174507
|
+
return;
|
|
174508
|
+
try {
|
|
174509
|
+
process.kill(childPid, "SIGUSR2");
|
|
174510
|
+
console.log(cliTag("\x1B[36m", "Capturing heap snapshot..."));
|
|
174511
|
+
} catch {
|
|
174512
|
+
console.log(cliTag("\x1B[33m", "Could not signal the server for a snapshot."));
|
|
174513
|
+
}
|
|
174514
|
+
};
|
|
174355
174515
|
interactive = createInteractiveHandler({
|
|
174356
174516
|
shell: runShellCommand2,
|
|
174357
174517
|
clear: () => {
|
|
174358
174518
|
process.stdout.write("\x1Bc");
|
|
174359
174519
|
},
|
|
174520
|
+
heapSnapshot: () => {
|
|
174521
|
+
triggerHeapSnapshot();
|
|
174522
|
+
},
|
|
174360
174523
|
help: () => {
|
|
174361
174524
|
printHelp();
|
|
174362
174525
|
},
|
|
@@ -174446,7 +174609,7 @@ var dev = async (serverEntry, configPath2) => {
|
|
|
174446
174609
|
};
|
|
174447
174610
|
|
|
174448
174611
|
// src/cli/scripts/eslint.ts
|
|
174449
|
-
import { existsSync as existsSync6, readFileSync as readFileSync8, rmSync as
|
|
174612
|
+
import { existsSync as existsSync6, readFileSync as readFileSync8, rmSync as rmSync3 } from "fs";
|
|
174450
174613
|
import { resolve as resolve4 } from "path";
|
|
174451
174614
|
var DEFAULT_CACHE_LOCATION = ".absolutejs/eslint-cache";
|
|
174452
174615
|
var getCacheLocation = () => process.env.ABSOLUTE_ESLINT_CACHE?.trim() || DEFAULT_CACHE_LOCATION;
|
|
@@ -174644,7 +174807,7 @@ var formatDuration = (ms) => {
|
|
|
174644
174807
|
};
|
|
174645
174808
|
var handleClearCache = (cacheLocation) => {
|
|
174646
174809
|
try {
|
|
174647
|
-
|
|
174810
|
+
rmSync3(cacheLocation, { force: true });
|
|
174648
174811
|
console.log(`\x1B[32m\u2713\x1B[0m Cleared cache: ${cacheLocation}`);
|
|
174649
174812
|
} catch (err) {
|
|
174650
174813
|
console.error(`\x1B[31m\u2717\x1B[0m Failed to clear cache at ${cacheLocation}:`, err);
|
|
@@ -174838,7 +175001,7 @@ var info = () => {
|
|
|
174838
175001
|
// src/cli/cache.ts
|
|
174839
175002
|
init_constants();
|
|
174840
175003
|
import { mkdir } from "fs/promises";
|
|
174841
|
-
import { join as
|
|
175004
|
+
import { join as join7 } from "path";
|
|
174842
175005
|
var {Glob } = globalThis.Bun;
|
|
174843
175006
|
var CACHE_DIR = ".absolutejs";
|
|
174844
175007
|
var MAX_FILES_PER_BATCH = 200;
|
|
@@ -174890,7 +175053,7 @@ var hashFiles = async (paths) => {
|
|
|
174890
175053
|
};
|
|
174891
175054
|
var loadCache = async (tool) => {
|
|
174892
175055
|
try {
|
|
174893
|
-
const path =
|
|
175056
|
+
const path = join7(CACHE_DIR, `${tool}.cache.json`);
|
|
174894
175057
|
const data = await Bun.file(path).json();
|
|
174895
175058
|
const result = data;
|
|
174896
175059
|
return result;
|
|
@@ -174937,7 +175100,7 @@ var runTool = async (adapter, args) => {
|
|
|
174937
175100
|
};
|
|
174938
175101
|
var saveCache = async (tool, data) => {
|
|
174939
175102
|
await mkdir(CACHE_DIR, { recursive: true });
|
|
174940
|
-
const path =
|
|
175103
|
+
const path = join7(CACHE_DIR, `${tool}.cache.json`);
|
|
174941
175104
|
await Bun.write(path, JSON.stringify(data, null, "\t"));
|
|
174942
175105
|
};
|
|
174943
175106
|
|
|
@@ -174982,8 +175145,8 @@ init_startupBanner();
|
|
|
174982
175145
|
init_telemetryEvent();
|
|
174983
175146
|
init_utils();
|
|
174984
175147
|
var {env: env2 } = globalThis.Bun;
|
|
174985
|
-
import { existsSync as existsSync8, readFileSync as readFileSync11, rmSync as
|
|
174986
|
-
import { basename as basename3, join as
|
|
175148
|
+
import { existsSync as existsSync8, readFileSync as readFileSync11, rmSync as rmSync4 } from "fs";
|
|
175149
|
+
import { basename as basename3, join as join11, resolve as resolve8 } from "path";
|
|
174987
175150
|
var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`;
|
|
174988
175151
|
var resolvePackageVersion = (candidates) => {
|
|
174989
175152
|
for (const candidate of candidates) {
|
|
@@ -175103,7 +175266,7 @@ var start = async (serverEntry, outdir, configPath2) => {
|
|
|
175103
175266
|
if (!build)
|
|
175104
175267
|
throw new Error("Could not locate build module");
|
|
175105
175268
|
await build(buildConfig);
|
|
175106
|
-
|
|
175269
|
+
rmSync4(join11(resolvedOutdir, "_prerendered"), {
|
|
175107
175270
|
force: true,
|
|
175108
175271
|
recursive: true
|
|
175109
175272
|
});
|
|
@@ -175346,7 +175509,7 @@ import {
|
|
|
175346
175509
|
readdirSync as readdirSync2,
|
|
175347
175510
|
readFileSync as readFileSync12,
|
|
175348
175511
|
unlinkSync as unlinkSync3,
|
|
175349
|
-
writeFileSync as
|
|
175512
|
+
writeFileSync as writeFileSync5
|
|
175350
175513
|
} from "fs";
|
|
175351
175514
|
import { createConnection } from "net";
|
|
175352
175515
|
import { resolve as resolve9 } from "path";
|
|
@@ -175913,8 +176076,8 @@ var createWorkspaceLogSink = (appendLog) => {
|
|
|
175913
176076
|
const logDirectory = resolve9(".absolutejs", "workspace", "logs");
|
|
175914
176077
|
mkdirSync6(logDirectory, { recursive: true });
|
|
175915
176078
|
readdirSync2(logDirectory).filter((file) => file.endsWith(".log")).forEach((file) => unlinkSync3(resolve9(logDirectory, file)));
|
|
175916
|
-
|
|
175917
|
-
|
|
176079
|
+
writeFileSync5(resolve9(logDirectory, "all.log"), "");
|
|
176080
|
+
writeFileSync5(resolve9(logDirectory, "workspace.log"), "");
|
|
175918
176081
|
const initializedSources = new Set(["workspace"]);
|
|
175919
176082
|
const writeLog = (source, message, level) => {
|
|
175920
176083
|
const cleanMessage = stripAnsi2(message).trimEnd();
|
|
@@ -175926,7 +176089,7 @@ var createWorkspaceLogSink = (appendLog) => {
|
|
|
175926
176089
|
`;
|
|
175927
176090
|
const sourceFile = resolve9(logDirectory, `${sanitizeLogFileName(source)}.log`);
|
|
175928
176091
|
if (!initializedSources.has(source)) {
|
|
175929
|
-
|
|
176092
|
+
writeFileSync5(sourceFile, "");
|
|
175930
176093
|
initializedSources.add(source);
|
|
175931
176094
|
}
|
|
175932
176095
|
appendFileSync(sourceFile, line);
|
|
@@ -176743,6 +176906,10 @@ if (command === "dev") {
|
|
|
176743
176906
|
sendTelemetryEvent("cli:command", { command: "ps" });
|
|
176744
176907
|
const { runPs: runPs2 } = await Promise.resolve().then(() => (init_ps(), exports_ps));
|
|
176745
176908
|
await runPs2(args);
|
|
176909
|
+
} else if (command === "mem") {
|
|
176910
|
+
sendTelemetryEvent("cli:command", { command: "mem" });
|
|
176911
|
+
const { runMem: runMem2 } = await Promise.resolve().then(() => (init_mem(), exports_mem));
|
|
176912
|
+
await runMem2(args);
|
|
176746
176913
|
} else if (command === "info") {
|
|
176747
176914
|
sendTelemetryEvent("cli:command", { command });
|
|
176748
176915
|
info();
|
|
@@ -176784,7 +176951,8 @@ if (command === "dev") {
|
|
|
176784
176951
|
console.error(" config [--port n] Open the unified config UI (ESLint, tsconfig, Prettier)");
|
|
176785
176952
|
console.error(" eslint Run ESLint (cached)");
|
|
176786
176953
|
console.error(" info Print system info for bug reports");
|
|
176787
|
-
console.error(" ls [--
|
|
176954
|
+
console.error(" ls [--sizes] [--json] List the project's pages by framework (from source)");
|
|
176955
|
+
console.error(" mem [--json] Memory report (RSS) for running servers, plus system usage");
|
|
176788
176956
|
console.error(" ps [--watch] [--json] [--kill <pid|port>] [--kill-all] List/manage running servers");
|
|
176789
176957
|
console.error(" prettier Run Prettier check (cached)");
|
|
176790
176958
|
console.error(" typecheck Run type checkers for all frameworks");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runMem: (args: string[]) => Promise<void>;
|
package/dist/types/cli.d.ts
CHANGED