@camstack/server 1.2.775 → 1.2.776
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/CHANGELOG.md +6 -0
- package/package.json +5 -13
- package/system/dist/addon-runner.js +17 -4
- package/system/dist/addon-runner.mjs +17 -4
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +3 -3
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +4 -4
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +4 -4
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +3 -3
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +9 -9
- package/system/dist/builtins/platform-probe/index.mjs +9 -9
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +19 -19
- package/system/dist/builtins/system-config/system-config.addon.mjs +282 -282
- package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
- package/system/dist/{custom-action-registry-oHl1xltx.mjs → custom-action-registry-BIJZBObd.mjs} +37 -37
- package/system/dist/index.js +17 -4
- package/system/dist/index.mjs +229 -216
- package/system/dist/kernel/moleculer/device-cap-proxy.d.ts +7 -1
- package/system/dist/{restore-archive-DYn0lsQl.mjs → restore-archive-BT_VMwFC.mjs} +149 -149
- package/system/package.json +1 -1
package/system/dist/index.mjs
CHANGED
|
@@ -36,12 +36,12 @@ import { a as MESH_CA_KEY_REF, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT
|
|
|
36
36
|
import { $ as caFingerprintCompact, A as getProcessNodeMeshTransport, B as MESH_NODE_CERTIFICATES_COLLECTION, C as MESH_TLS_PORT_HELLO_FIELD, Ct as readOriginSetting, D as setProcessMeshTlsEnabler, Dt as readCidrSetting, E as ServiceBroker, Et as parseCidrList, F as renewMeshCertificate, G as getProcessMeshCertificateRegistry, H as MeshCertificateRegistry, I as revokeMeshCertificate, J as processMeshCrl, K as setProcessMeshCertificateRegistry, L as getProcessMeshTlsListenerState, M as isProcessVerifiedMeshPeer, N as onProcessNodeRegistered, O as dropProcessPeer, P as setProcessMeshPeerTransportLookup, Q as caFingerprint, R as openMeshTlsWhenRevocationsLoaded, S as verifyMembershipAnswer, St as parseOriginList, SystemConfigAddon, T as Errors, Tt as normalizeIp, U as RENEWAL_ABANDONED, V as MESH_NODE_CERTIFICATES_COLUMNS, W as describeMeshLeaf, X as getProcessMeshCaState, Y as MeshCaKeeper, Z as requireProcessMeshCa, _ as signPairingProof, _t as verifyAgentUiUnlockTicket, a as hubHostFromMeshAddress, at as issueMeshLeafForNode, b as MembershipResponder, bt as isInsecureOrigin, c as PAIRING_MAX_SESSIONS, ct as AGENT_DASHBOARD_ORIGINS_FIELD, d as PAIRING_PROTOCOL, dt as AGENT_UI_UNLOCK_USE, et as createMeshCsrPem, f as PAIRING_TTL_MS, ft as AGENT_UI_UNLOCK_VERSION, g as keyFingerprintShort, gt as parseAgentDashboardOrigins, h as describeCsr, ht as mintAgentUiUnlockTicket, i as AgentPairing, it as isValidAgentNodeId, j as getProcessPeerLeaf, k as emitProcessNodeRegistered, l as PAIRING_PATHS, lt as AGENT_UI_UNLOCK_TTL_MS, m as computePairingSas, mt as isAllowedAgentDashboardReturnTo, n as HubPairing, nt as generateMeshCa, o as PAIRING_CODE_DIGITS, ot as issueMeshLeafFromCsr, p as computePairingCommitment, pt as UnlockTicketJtiStore, q as MeshCrl, r as PairingHttpError, rt as generateMeshKeyPair, s as PAIRING_MAX_CODE_ATTEMPTS, st as loadMeshCa, tt as exportMeshPrivateKeyPem, u as PAIRING_PIN_DIGITS, ut as AGENT_UI_UNLOCK_TYP, v as verifyPairingProof, vt as InvalidCorsOriginError, w as TlsTcpTransporter, wt as createCidrMatcher, x as signMembershipProof, xt as normalizeOrigin, y as MEMBERSHIP_PATHS, yt as OPAQUE_ORIGIN, z as setProcessMeshTlsListenerState } from "./builtins/system-config/system-config.addon.mjs";
|
|
37
37
|
import "./builtins/system-config/index.mjs";
|
|
38
38
|
import { WinstonDestination, WinstonLoggingAddon } from "./builtins/winston-logging/index.mjs";
|
|
39
|
-
import { C as isModelDownloaded, E as setHuggingFaceReachabilityObserver, T as revisionWeightUrl, _ as downloadFile, a as startEventLoopStallMonitor, b as fetchJson, c as createAuthenticatedFileServer, d as resolveFilePath, f as ModelDownloadService, g as deleteModelFromDisk, h as collectModelFiles, i as attributeStall, l as parseRangeHeader, m as adoptModelRevisions, n as STALL_REPORT_MS, o as createFileDataPlaneHandler, r as STALL_TICK_MS, s as contentTypeFor, t as CustomActionRegistry, u as parseTokenizedUrl, v as downloadModel, w as resolveFormatRevision, x as getModelFilePath, y as ensureModel } from "./custom-action-registry-
|
|
39
|
+
import { C as isModelDownloaded, E as setHuggingFaceReachabilityObserver, T as revisionWeightUrl, _ as downloadFile, a as startEventLoopStallMonitor, b as fetchJson, c as createAuthenticatedFileServer, d as resolveFilePath, f as ModelDownloadService, g as deleteModelFromDisk, h as collectModelFiles, i as attributeStall, l as parseRangeHeader, m as adoptModelRevisions, n as STALL_REPORT_MS, o as createFileDataPlaneHandler, r as STALL_TICK_MS, s as contentTypeFor, t as CustomActionRegistry, u as parseTokenizedUrl, v as downloadModel, w as resolveFormatRevision, x as getModelFilePath, y as ensureModel } from "./custom-action-registry-BIJZBObd.mjs";
|
|
40
40
|
import { A as retirePreviousLocalCa, C as checkUploadedCa, D as loadTlsCert, E as ensureTlsCert, F as closeLanHttp, I as readLanHttpState, L as registerLanHttpHandler, M as allFamiliesListenHost, N as applyLanHttp, O as reissueTlsLeaf, P as bindPendingLanHttp, S as chainsToPublicRoot, T as caReplacementMarkerFile, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, c as leafFingerprintOf, d as servedHttpsLeafFingerprint, f as prepareBootTls, g as readTlsEnabled, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, k as replaceUnconstrainedLocalCa, l as registerHttpsListener, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, p as UPLOADED_CA_FILE, r as regenerateCertificate, s as clearHttpsListener, t as createCiaoPublisher, u as reloadHttpsListener, v as splitPemCertificates, w as validateUploadedTls, x as writeTlsMode, y as writeExtraSans } from "./hub-mdns-ciao-vybj30s5.mjs";
|
|
41
41
|
import { n as getPlatformKeychainKey, r as setPlatformKeychainKey, t as clearPlatformKeychainKey } from "./platform-key-source-BWlq0jjn.mjs";
|
|
42
42
|
import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-Di9daRwI.mjs";
|
|
43
|
-
import { _ as backupRecordStoresOf, c as BackupDecryptError, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, h as readBackupEncryptionHeader, l as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, t as BackupKeyRequiredError, u as BackupKeyMismatchError } from "./restore-archive-
|
|
44
|
-
import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-
|
|
43
|
+
import { _ as backupRecordStoresOf, c as BackupDecryptError, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, h as readBackupEncryptionHeader, l as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, t as BackupKeyRequiredError, u as BackupKeyMismatchError } from "./restore-archive-BT_VMwFC.mjs";
|
|
44
|
+
import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-BW3OcrLD.mjs";
|
|
45
45
|
import { z } from "zod";
|
|
46
46
|
import * as crypto$1 from "node:crypto";
|
|
47
47
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -56,7 +56,7 @@ import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, DATAPLANE_SECRET
|
|
|
56
56
|
import * as os$1 from "node:os";
|
|
57
57
|
import { tmpdir } from "node:os";
|
|
58
58
|
import { pathToFileURL } from "node:url";
|
|
59
|
-
import * as fs
|
|
59
|
+
import * as fs from "node:fs";
|
|
60
60
|
import { accessSync, constants, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
|
|
61
61
|
import { execFile, spawn } from "node:child_process";
|
|
62
62
|
import { once } from "node:events";
|
|
@@ -5114,7 +5114,7 @@ var PythonEnvManager = class {
|
|
|
5114
5114
|
async ensure(options) {
|
|
5115
5115
|
const probe = await this.probe();
|
|
5116
5116
|
if (!probe.available || !probe.path) throw userError("system.python-required", void 0, "Python 3.10+ is required but not found on this system");
|
|
5117
|
-
if (!fs
|
|
5117
|
+
if (!fs.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
|
|
5118
5118
|
"-m",
|
|
5119
5119
|
"venv",
|
|
5120
5120
|
this.venvPath
|
|
@@ -5137,7 +5137,7 @@ var PythonEnvManager = class {
|
|
|
5137
5137
|
}
|
|
5138
5138
|
spawn(script, args) {
|
|
5139
5139
|
const venvPython = path$1.join(this.venvPath, "bin", "python");
|
|
5140
|
-
if (!fs
|
|
5140
|
+
if (!fs.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
|
|
5141
5141
|
return spawn(venvPython, [script, ...args]);
|
|
5142
5142
|
}
|
|
5143
5143
|
};
|
|
@@ -5489,20 +5489,20 @@ var StorageManager = class {
|
|
|
5489
5489
|
const basePath = this.locationManager.getBackend(mappedName).basePath;
|
|
5490
5490
|
location.files = {
|
|
5491
5491
|
async readFile(p) {
|
|
5492
|
-
return fs
|
|
5492
|
+
return fs.promises.readFile(path$1.join(basePath, p));
|
|
5493
5493
|
},
|
|
5494
5494
|
async writeFile(p, data) {
|
|
5495
5495
|
const full = path$1.join(basePath, p);
|
|
5496
|
-
await fs
|
|
5497
|
-
await fs
|
|
5496
|
+
await fs.promises.mkdir(path$1.dirname(full), { recursive: true });
|
|
5497
|
+
await fs.promises.writeFile(full, data);
|
|
5498
5498
|
},
|
|
5499
5499
|
async deleteFile(p) {
|
|
5500
|
-
await fs
|
|
5500
|
+
await fs.promises.rm(path$1.join(basePath, p), { force: true });
|
|
5501
5501
|
},
|
|
5502
5502
|
async listFiles(prefix) {
|
|
5503
5503
|
const dir = prefix ? path$1.join(basePath, prefix) : basePath;
|
|
5504
5504
|
try {
|
|
5505
|
-
return (await fs
|
|
5505
|
+
return (await fs.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
|
|
5506
5506
|
} catch {
|
|
5507
5507
|
return [];
|
|
5508
5508
|
}
|
|
@@ -5512,7 +5512,7 @@ var StorageManager = class {
|
|
|
5512
5512
|
},
|
|
5513
5513
|
async exists(p) {
|
|
5514
5514
|
try {
|
|
5515
|
-
await fs
|
|
5515
|
+
await fs.promises.access(path$1.join(basePath, p));
|
|
5516
5516
|
return true;
|
|
5517
5517
|
} catch {
|
|
5518
5518
|
return false;
|
|
@@ -6140,7 +6140,7 @@ var TRADITIONAL_NATIVE_PACKAGES = ["better-sqlite3"];
|
|
|
6140
6140
|
function hasDotNode(dir, maxDepth) {
|
|
6141
6141
|
let entries;
|
|
6142
6142
|
try {
|
|
6143
|
-
entries = fs
|
|
6143
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
6144
6144
|
} catch {
|
|
6145
6145
|
return false;
|
|
6146
6146
|
}
|
|
@@ -6151,7 +6151,7 @@ function hasDotNode(dir, maxDepth) {
|
|
|
6151
6151
|
}
|
|
6152
6152
|
/** Locate the bundled `prebuild-install` bin.js inside the staged closure. */
|
|
6153
6153
|
function resolvePrebuildInstallBin(closureDir, moduleDir) {
|
|
6154
|
-
return [path$1.join(moduleDir, "node_modules", "prebuild-install", "bin.js"), path$1.join(closureDir, "node_modules", "prebuild-install", "bin.js")].find((c) => fs
|
|
6154
|
+
return [path$1.join(moduleDir, "node_modules", "prebuild-install", "bin.js"), path$1.join(closureDir, "node_modules", "prebuild-install", "bin.js")].find((c) => fs.existsSync(c)) ?? null;
|
|
6155
6155
|
}
|
|
6156
6156
|
/**
|
|
6157
6157
|
* Default fetcher: run the closure's own `prebuild-install` under the CURRENT
|
|
@@ -6204,7 +6204,7 @@ async function ensureNativePrebuilds(closureDir, options) {
|
|
|
6204
6204
|
const fetched = [];
|
|
6205
6205
|
for (const pkg of packages) {
|
|
6206
6206
|
const moduleDir = path$1.join(nm, pkg);
|
|
6207
|
-
if (!fs
|
|
6207
|
+
if (!fs.existsSync(moduleDir)) continue;
|
|
6208
6208
|
if (hasDotNode(moduleDir, 4)) continue;
|
|
6209
6209
|
options.logger.warn("staged closure native prebuild missing — fetching for running ABI", { meta: {
|
|
6210
6210
|
pkg,
|
|
@@ -6267,12 +6267,12 @@ async function ensureNativePrebuilds(closureDir, options) {
|
|
|
6267
6267
|
function replantFromBundled(srcModuleDir, dstModuleDir, hasNative) {
|
|
6268
6268
|
if (!hasNative(srcModuleDir)) return false;
|
|
6269
6269
|
try {
|
|
6270
|
-
fs
|
|
6270
|
+
fs.rmSync(dstModuleDir, {
|
|
6271
6271
|
recursive: true,
|
|
6272
6272
|
force: true
|
|
6273
6273
|
});
|
|
6274
|
-
fs
|
|
6275
|
-
fs
|
|
6274
|
+
fs.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
|
|
6275
|
+
fs.cpSync(srcModuleDir, dstModuleDir, {
|
|
6276
6276
|
recursive: true,
|
|
6277
6277
|
dereference: true
|
|
6278
6278
|
});
|
|
@@ -6301,7 +6301,7 @@ async function ensureAddonNativePrebuilds(addonDir, options) {
|
|
|
6301
6301
|
const missing = [];
|
|
6302
6302
|
for (const pkg of packages) {
|
|
6303
6303
|
const moduleDir = path$1.join(nm, pkg);
|
|
6304
|
-
if (!fs
|
|
6304
|
+
if (!fs.existsSync(moduleDir)) continue;
|
|
6305
6305
|
if (hasNative(moduleDir)) {
|
|
6306
6306
|
results.push({
|
|
6307
6307
|
pkg,
|
|
@@ -6400,7 +6400,7 @@ async function defaultDownloadTarball(url, destTgz) {
|
|
|
6400
6400
|
const res = await fetch(url);
|
|
6401
6401
|
if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} downloading ${url}`);
|
|
6402
6402
|
const bytes = Buffer.from(await res.arrayBuffer());
|
|
6403
|
-
await fs
|
|
6403
|
+
await fs.promises.writeFile(destTgz, bytes);
|
|
6404
6404
|
}
|
|
6405
6405
|
async function defaultExtractTarball(tgzPath, destDir) {
|
|
6406
6406
|
await execFileAsync$5("tar", [
|
|
@@ -6486,7 +6486,7 @@ async function resolveUncached(options) {
|
|
|
6486
6486
|
argsPrefix: []
|
|
6487
6487
|
};
|
|
6488
6488
|
const cliPath = bootstrappedCliPath(options.cacheDir);
|
|
6489
|
-
if (fs
|
|
6489
|
+
if (fs.existsSync(cliPath)) {
|
|
6490
6490
|
options.logger.info("system npm unavailable — using bootstrapped npm", { meta: { cliPath } });
|
|
6491
6491
|
return {
|
|
6492
6492
|
command: process.execPath,
|
|
@@ -6498,12 +6498,12 @@ async function resolveUncached(options) {
|
|
|
6498
6498
|
const registry = (options.registry ?? DEFAULT_REGISTRY).replace(/\/+$/, "");
|
|
6499
6499
|
const tarballUrl = tarballUrlOf(await (options.fetchJson ?? defaultFetchJson)(`${registry}/npm/latest`));
|
|
6500
6500
|
if (!tarballUrl) throw new Error(`registry metadata for 'npm' carries no dist.tarball (${registry})`);
|
|
6501
|
-
await fs
|
|
6501
|
+
await fs.promises.mkdir(options.cacheDir, { recursive: true });
|
|
6502
6502
|
const tgzPath = path$1.join(options.cacheDir, "npm-bootstrap.tgz");
|
|
6503
6503
|
await (options.downloadTarball ?? defaultDownloadTarball)(tarballUrl, tgzPath);
|
|
6504
6504
|
await (options.extractTarball ?? defaultExtractTarball)(tgzPath, options.cacheDir);
|
|
6505
|
-
await fs
|
|
6506
|
-
if (!fs
|
|
6505
|
+
await fs.promises.rm(tgzPath, { force: true });
|
|
6506
|
+
if (!fs.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
|
|
6507
6507
|
options.logger.info("npm bootstrapped", { meta: { cliPath } });
|
|
6508
6508
|
return {
|
|
6509
6509
|
command: process.execPath,
|
|
@@ -6569,7 +6569,7 @@ function readOwningPackageVersion(entryPath) {
|
|
|
6569
6569
|
let dir = path$1.dirname(entryPath);
|
|
6570
6570
|
for (let hop = 0; hop < PACKAGE_JSON_LOOKUP_DEPTH; hop++) {
|
|
6571
6571
|
try {
|
|
6572
|
-
const version = asJsonObject$1(parseJsonUnknown(fs
|
|
6572
|
+
const version = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
|
|
6573
6573
|
if (typeof version === "string" && version.length > 0) return version;
|
|
6574
6574
|
} catch {}
|
|
6575
6575
|
const parent = path$1.dirname(dir);
|
|
@@ -6613,14 +6613,14 @@ function readOwningPackageVersion(entryPath) {
|
|
|
6613
6613
|
function addonModuleCacheKey(entryPath) {
|
|
6614
6614
|
let stat;
|
|
6615
6615
|
try {
|
|
6616
|
-
stat = fs
|
|
6616
|
+
stat = fs.statSync(entryPath);
|
|
6617
6617
|
} catch {
|
|
6618
6618
|
return null;
|
|
6619
6619
|
}
|
|
6620
6620
|
const version = readOwningPackageVersion(entryPath) ?? `m${stat.mtimeMs}`;
|
|
6621
6621
|
let content;
|
|
6622
6622
|
try {
|
|
6623
|
-
content = createHash("sha1").update(fs
|
|
6623
|
+
content = createHash("sha1").update(fs.readFileSync(entryPath)).digest("hex").slice(0, 16);
|
|
6624
6624
|
} catch {
|
|
6625
6625
|
content = `m${stat.mtimeMs}s${stat.size}`;
|
|
6626
6626
|
}
|
|
@@ -6724,14 +6724,14 @@ var AddonLoader = class {
|
|
|
6724
6724
|
* BUILTINS from the active closure, not the (now-inert) addons-dir copy, so
|
|
6725
6725
|
* the addons-dir `@camstack/server/system` must NOT be double-loaded here. */
|
|
6726
6726
|
async loadFromDirectory(addonsDir, skipPackages = []) {
|
|
6727
|
-
if (!fs
|
|
6727
|
+
if (!fs.existsSync(addonsDir)) return;
|
|
6728
6728
|
const skip = new Set(skipPackages);
|
|
6729
|
-
const entries = fs
|
|
6729
|
+
const entries = fs.readdirSync(addonsDir, { withFileTypes: true });
|
|
6730
6730
|
for (const entry of entries) {
|
|
6731
6731
|
if (!isDirectoryEntry(entry, addonsDir)) continue;
|
|
6732
6732
|
if (entry.name.startsWith("@")) {
|
|
6733
6733
|
const scopeDir = path$1.join(addonsDir, entry.name);
|
|
6734
|
-
const scopeEntries = fs
|
|
6734
|
+
const scopeEntries = fs.readdirSync(scopeDir, { withFileTypes: true });
|
|
6735
6735
|
for (const scopeEntry of scopeEntries) {
|
|
6736
6736
|
if (!isDirectoryEntry(scopeEntry, scopeDir)) continue;
|
|
6737
6737
|
if (skip.has(`${entry.name}/${scopeEntry.name}`)) continue;
|
|
@@ -6745,7 +6745,7 @@ var AddonLoader = class {
|
|
|
6745
6745
|
}
|
|
6746
6746
|
async tryLoadAddon(addonDir) {
|
|
6747
6747
|
const pkgJsonPath = path$1.join(addonDir, "package.json");
|
|
6748
|
-
if (!fs
|
|
6748
|
+
if (!fs.existsSync(pkgJsonPath)) return;
|
|
6749
6749
|
try {
|
|
6750
6750
|
await this.loadFromAddonDir(addonDir);
|
|
6751
6751
|
} catch (err) {
|
|
@@ -6763,7 +6763,7 @@ var AddonLoader = class {
|
|
|
6763
6763
|
/** Load addon from a specific directory (package.json + dist/) */
|
|
6764
6764
|
async loadFromAddonDir(addonDir) {
|
|
6765
6765
|
const pkgJsonPath = path$1.join(addonDir, "package.json");
|
|
6766
|
-
const pkgJson = asJsonObject$1(parseJsonUnknown(fs
|
|
6766
|
+
const pkgJson = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
|
|
6767
6767
|
const packageNameRaw = pkgJson["name"];
|
|
6768
6768
|
const packageName = typeof packageNameRaw === "string" ? packageNameRaw : "";
|
|
6769
6769
|
const packageVersionRaw = pkgJson["version"];
|
|
@@ -6811,7 +6811,7 @@ var AddonLoader = class {
|
|
|
6811
6811
|
}
|
|
6812
6812
|
const entryFile = declaration.entry.replace(/^\.\//, "").replace(/^src\//, "dist/").replace(/\.ts$/, ".js");
|
|
6813
6813
|
let entryPath = path$1.resolve(addonDir, entryFile);
|
|
6814
|
-
if (!fs
|
|
6814
|
+
if (!fs.existsSync(entryPath)) {
|
|
6815
6815
|
const base = entryPath.replace(/\.(js|cjs|mjs)$/, "");
|
|
6816
6816
|
entryPath = [
|
|
6817
6817
|
`${base}.cjs`,
|
|
@@ -6820,9 +6820,9 @@ var AddonLoader = class {
|
|
|
6820
6820
|
path$1.resolve(addonDir, "dist", "index.cjs"),
|
|
6821
6821
|
path$1.resolve(addonDir, "dist", "index.mjs"),
|
|
6822
6822
|
path$1.resolve(addonDir, declaration.entry)
|
|
6823
|
-
].find((p) => fs
|
|
6823
|
+
].find((p) => fs.existsSync(p)) ?? entryPath;
|
|
6824
6824
|
}
|
|
6825
|
-
if (!fs
|
|
6825
|
+
if (!fs.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
|
|
6826
6826
|
const modUnknown = await importAddonModuleFresh(entryPath);
|
|
6827
6827
|
const mod = isRecord$4(modUnknown) ? modUnknown : {};
|
|
6828
6828
|
const AddonClass = resolveAddonClass(mod);
|
|
@@ -6934,7 +6934,7 @@ function isDirectoryEntry(entry, parentDir) {
|
|
|
6934
6934
|
if (entry.name.startsWith(".")) return false;
|
|
6935
6935
|
if (entry.isDirectory()) return true;
|
|
6936
6936
|
if (entry.isSymbolicLink()) try {
|
|
6937
|
-
return fs
|
|
6937
|
+
return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
|
|
6938
6938
|
} catch {
|
|
6939
6939
|
return false;
|
|
6940
6940
|
}
|
|
@@ -7028,7 +7028,7 @@ var execFileAsync$4 = promisify(execFile);
|
|
|
7028
7028
|
* Single source of truth — replaces scattered mkdirSync calls.
|
|
7029
7029
|
*/
|
|
7030
7030
|
function ensureDir(dirPath) {
|
|
7031
|
-
fs
|
|
7031
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
7032
7032
|
}
|
|
7033
7033
|
/**
|
|
7034
7034
|
* Copy a directory recursively — ASYNC so it never blocks the event loop.
|
|
@@ -7041,7 +7041,7 @@ function ensureDir(dirPath) {
|
|
|
7041
7041
|
* `fs.promises.cp` keeps the I/O off the event loop. (Node ≥18 stable.)
|
|
7042
7042
|
*/
|
|
7043
7043
|
async function copyDirRecursive(src, dest) {
|
|
7044
|
-
await fs
|
|
7044
|
+
await fs.promises.cp(src, dest, {
|
|
7045
7045
|
recursive: true,
|
|
7046
7046
|
force: true
|
|
7047
7047
|
});
|
|
@@ -7146,13 +7146,13 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
|
|
|
7146
7146
|
if (typeof fileEntry !== "string") continue;
|
|
7147
7147
|
if (fileEntry === "dist" || fileEntry.includes("*")) continue;
|
|
7148
7148
|
const srcPath = path$1.join(sourceDir, fileEntry);
|
|
7149
|
-
if (!fs
|
|
7149
|
+
if (!fs.existsSync(srcPath)) continue;
|
|
7150
7150
|
const destPath = path$1.join(destDir, fileEntry);
|
|
7151
|
-
const stat = await fs
|
|
7151
|
+
const stat = await fs.promises.stat(srcPath);
|
|
7152
7152
|
if (stat.isDirectory()) await copyDirRecursive(srcPath, destPath);
|
|
7153
7153
|
else if (stat.isFile()) {
|
|
7154
7154
|
ensureDir(path$1.dirname(destPath));
|
|
7155
|
-
await fs
|
|
7155
|
+
await fs.promises.copyFile(srcPath, destPath);
|
|
7156
7156
|
}
|
|
7157
7157
|
}
|
|
7158
7158
|
}
|
|
@@ -7163,10 +7163,10 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
|
|
|
7163
7163
|
function isSourceNewer(packageDir) {
|
|
7164
7164
|
const srcDir = path$1.join(packageDir, "src");
|
|
7165
7165
|
const distDir = path$1.join(packageDir, "dist");
|
|
7166
|
-
if (!fs
|
|
7166
|
+
if (!fs.existsSync(srcDir) || !fs.existsSync(distDir)) return true;
|
|
7167
7167
|
try {
|
|
7168
|
-
const distMtime = fs
|
|
7169
|
-
const entries = fs
|
|
7168
|
+
const distMtime = fs.statSync(distDir).mtimeMs;
|
|
7169
|
+
const entries = fs.readdirSync(srcDir, {
|
|
7170
7170
|
withFileTypes: true,
|
|
7171
7171
|
recursive: true
|
|
7172
7172
|
});
|
|
@@ -7174,7 +7174,7 @@ function isSourceNewer(packageDir) {
|
|
|
7174
7174
|
if (!entry.isFile()) continue;
|
|
7175
7175
|
const parentDir = entry.parentPath ?? String(Reflect.get(entry, "path") ?? "");
|
|
7176
7176
|
const filePath = path$1.join(parentDir, entry.name);
|
|
7177
|
-
if (fs
|
|
7177
|
+
if (fs.statSync(filePath).mtimeMs > distMtime) return true;
|
|
7178
7178
|
}
|
|
7179
7179
|
return false;
|
|
7180
7180
|
} catch {
|
|
@@ -7191,7 +7191,7 @@ function isSourceNewer(packageDir) {
|
|
|
7191
7191
|
* `copyDirRecursive` for the wedge this prevents.
|
|
7192
7192
|
*/
|
|
7193
7193
|
async function installPackageFromNpm(packageName, targetDir) {
|
|
7194
|
-
const tmpDir = await fs
|
|
7194
|
+
const tmpDir = await fs.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
|
|
7195
7195
|
try {
|
|
7196
7196
|
const { stdout } = await execFileAsync$4("npm", [
|
|
7197
7197
|
"pack",
|
|
@@ -7214,21 +7214,21 @@ async function installPackageFromNpm(packageName, targetDir) {
|
|
|
7214
7214
|
extractDir
|
|
7215
7215
|
], { timeout: 3e4 });
|
|
7216
7216
|
const packageSubDir = path$1.join(extractDir, "package");
|
|
7217
|
-
const srcPkgJsonDir = fs
|
|
7218
|
-
await fs
|
|
7217
|
+
const srcPkgJsonDir = fs.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
|
|
7218
|
+
await fs.promises.rm(targetDir, {
|
|
7219
7219
|
recursive: true,
|
|
7220
7220
|
force: true
|
|
7221
7221
|
});
|
|
7222
7222
|
ensureDir(targetDir);
|
|
7223
|
-
await fs
|
|
7223
|
+
await fs.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
|
|
7224
7224
|
const distSrc = path$1.join(srcPkgJsonDir, "dist");
|
|
7225
|
-
if (fs
|
|
7225
|
+
if (fs.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
|
|
7226
7226
|
try {
|
|
7227
|
-
const npmPkg = asJsonObject$1(parseJsonUnknown(await fs
|
|
7227
|
+
const npmPkg = asJsonObject$1(parseJsonUnknown(await fs.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
|
|
7228
7228
|
if (npmPkg) await copyExtraFileDirs(npmPkg, srcPkgJsonDir, targetDir);
|
|
7229
7229
|
} catch {}
|
|
7230
7230
|
} finally {
|
|
7231
|
-
await fs
|
|
7231
|
+
await fs.promises.rm(tmpDir, {
|
|
7232
7232
|
recursive: true,
|
|
7233
7233
|
force: true
|
|
7234
7234
|
});
|
|
@@ -7253,7 +7253,7 @@ function packageDirName$1(declaredName) {
|
|
|
7253
7253
|
}
|
|
7254
7254
|
function isDirLike$1(p) {
|
|
7255
7255
|
try {
|
|
7256
|
-
return fs
|
|
7256
|
+
return fs.statSync(p).isDirectory();
|
|
7257
7257
|
} catch {
|
|
7258
7258
|
return false;
|
|
7259
7259
|
}
|
|
@@ -7271,12 +7271,12 @@ var AddonManifest = class {
|
|
|
7271
7271
|
*/
|
|
7272
7272
|
read() {
|
|
7273
7273
|
if (this.cache != null) return this.cache;
|
|
7274
|
-
if (!fs
|
|
7274
|
+
if (!fs.existsSync(this.manifestPath)) {
|
|
7275
7275
|
this.cache = this.empty();
|
|
7276
7276
|
return this.cache;
|
|
7277
7277
|
}
|
|
7278
7278
|
try {
|
|
7279
|
-
const raw = fs
|
|
7279
|
+
const raw = fs.readFileSync(this.manifestPath, "utf-8");
|
|
7280
7280
|
const parsed = JSON.parse(raw);
|
|
7281
7281
|
if (parsed.version !== MANIFEST_VERSION) {
|
|
7282
7282
|
process.stderr.write(`[AddonManifest] schema mismatch (file=${parsed.version} vs runtime=${MANIFEST_VERSION}); starting empty\n`);
|
|
@@ -7297,13 +7297,13 @@ var AddonManifest = class {
|
|
|
7297
7297
|
* a half-written file.
|
|
7298
7298
|
*/
|
|
7299
7299
|
write(manifest) {
|
|
7300
|
-
fs
|
|
7300
|
+
fs.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
|
|
7301
7301
|
const tmp = `${this.manifestPath}.tmp.${process.pid}.${Date.now()}`;
|
|
7302
|
-
fs
|
|
7302
|
+
fs.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
|
|
7303
7303
|
encoding: "utf-8",
|
|
7304
7304
|
mode: 384
|
|
7305
7305
|
});
|
|
7306
|
-
fs
|
|
7306
|
+
fs.renameSync(tmp, this.manifestPath);
|
|
7307
7307
|
this.cache = manifest;
|
|
7308
7308
|
}
|
|
7309
7309
|
/** Lookup a single addon's manifest entry, or `null` if not tracked. */
|
|
@@ -7378,22 +7378,22 @@ var AddonManifest = class {
|
|
|
7378
7378
|
* exactly what moved. Returns the total number of changes.
|
|
7379
7379
|
*/
|
|
7380
7380
|
reconcileFromDisk(addonsDir, onChange) {
|
|
7381
|
-
if (!fs
|
|
7381
|
+
if (!fs.existsSync(addonsDir)) return 0;
|
|
7382
7382
|
const m = this.read();
|
|
7383
7383
|
let changes = 0;
|
|
7384
7384
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7385
7385
|
/** Package name → version, for every ADDON package actually installed. */
|
|
7386
7386
|
const onDisk = /* @__PURE__ */ new Map();
|
|
7387
|
-
for (const scope of fs
|
|
7387
|
+
for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
|
|
7388
7388
|
if (!scope.name.startsWith("@") || !isDirLike$1(path$1.join(addonsDir, scope.name))) continue;
|
|
7389
7389
|
const scopeDir = path$1.join(addonsDir, scope.name);
|
|
7390
|
-
for (const pkg of fs
|
|
7390
|
+
for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
|
|
7391
7391
|
if (!isDirLike$1(path$1.join(scopeDir, pkg.name))) continue;
|
|
7392
7392
|
const pkgJsonPath = path$1.join(scopeDir, pkg.name, "package.json");
|
|
7393
|
-
if (!fs
|
|
7393
|
+
if (!fs.existsSync(pkgJsonPath)) continue;
|
|
7394
7394
|
let pkgJson;
|
|
7395
7395
|
try {
|
|
7396
|
-
const parsed = JSON.parse(fs
|
|
7396
|
+
const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
7397
7397
|
if (typeof parsed !== "object" || parsed == null) continue;
|
|
7398
7398
|
pkgJson = parsed;
|
|
7399
7399
|
} catch {
|
|
@@ -7464,28 +7464,28 @@ var AddonManifest = class {
|
|
|
7464
7464
|
migrateFromInstallSourceMarkers(addonsDir) {
|
|
7465
7465
|
const m = this.read();
|
|
7466
7466
|
if (Object.keys(m.addons).length > 0) return 0;
|
|
7467
|
-
if (!fs
|
|
7467
|
+
if (!fs.existsSync(addonsDir)) return 0;
|
|
7468
7468
|
let migrated = 0;
|
|
7469
7469
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7470
|
-
for (const scope of fs
|
|
7470
|
+
for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
|
|
7471
7471
|
if (!scope.isDirectory() || !scope.name.startsWith("@")) continue;
|
|
7472
7472
|
const scopeDir = path$1.join(addonsDir, scope.name);
|
|
7473
|
-
for (const pkg of fs
|
|
7473
|
+
for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
|
|
7474
7474
|
if (!pkg.isDirectory()) continue;
|
|
7475
7475
|
const pkgDir = path$1.join(scopeDir, pkg.name);
|
|
7476
7476
|
const markerPath = path$1.join(pkgDir, ".install-source");
|
|
7477
7477
|
const pkgJsonPath = path$1.join(pkgDir, "package.json");
|
|
7478
|
-
if (!fs
|
|
7478
|
+
if (!fs.existsSync(pkgJsonPath)) continue;
|
|
7479
7479
|
let pkgJson;
|
|
7480
7480
|
try {
|
|
7481
|
-
const parsed = JSON.parse(fs
|
|
7481
|
+
const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
7482
7482
|
if (typeof parsed !== "object" || parsed == null) continue;
|
|
7483
7483
|
pkgJson = parsed;
|
|
7484
7484
|
} catch {
|
|
7485
7485
|
continue;
|
|
7486
7486
|
}
|
|
7487
7487
|
if (!pkgJson.name || !pkgJson.version) continue;
|
|
7488
|
-
const source = fs
|
|
7488
|
+
const source = fs.existsSync(markerPath) ? fs.readFileSync(markerPath, "utf-8").trim() : "bundled";
|
|
7489
7489
|
m.addons[pkgJson.name] = {
|
|
7490
7490
|
name: pkgJson.name,
|
|
7491
7491
|
version: pkgJson.version,
|
|
@@ -7689,7 +7689,7 @@ function planClosureDedupe(input) {
|
|
|
7689
7689
|
function readTreeManifest(pkgJsonPath) {
|
|
7690
7690
|
let raw;
|
|
7691
7691
|
try {
|
|
7692
|
-
raw = asJsonObject$1(parseJsonUnknown(fs
|
|
7692
|
+
raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
|
|
7693
7693
|
} catch {
|
|
7694
7694
|
return null;
|
|
7695
7695
|
}
|
|
@@ -7714,7 +7714,7 @@ function readTreeManifest(pkgJsonPath) {
|
|
|
7714
7714
|
function listTopLevelEntries(nodeModulesDir) {
|
|
7715
7715
|
let entries;
|
|
7716
7716
|
try {
|
|
7717
|
-
entries = fs
|
|
7717
|
+
entries = fs.readdirSync(nodeModulesDir, { withFileTypes: true });
|
|
7718
7718
|
} catch {
|
|
7719
7719
|
return [];
|
|
7720
7720
|
}
|
|
@@ -7724,7 +7724,7 @@ function listTopLevelEntries(nodeModulesDir) {
|
|
|
7724
7724
|
if (entry.name.startsWith("@")) {
|
|
7725
7725
|
let inner;
|
|
7726
7726
|
try {
|
|
7727
|
-
inner = fs
|
|
7727
|
+
inner = fs.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
|
|
7728
7728
|
} catch {
|
|
7729
7729
|
continue;
|
|
7730
7730
|
}
|
|
@@ -7757,14 +7757,14 @@ function collectAddonTreeState(addonDir) {
|
|
|
7757
7757
|
const entryDir = path$1.join(nodeModulesDir, name);
|
|
7758
7758
|
let isLink = false;
|
|
7759
7759
|
try {
|
|
7760
|
-
isLink = fs
|
|
7760
|
+
isLink = fs.lstatSync(entryDir).isSymbolicLink();
|
|
7761
7761
|
} catch {
|
|
7762
7762
|
continue;
|
|
7763
7763
|
}
|
|
7764
7764
|
if (isLink) {
|
|
7765
7765
|
let target = "";
|
|
7766
7766
|
try {
|
|
7767
|
-
target = fs
|
|
7767
|
+
target = fs.readlinkSync(entryDir);
|
|
7768
7768
|
} catch {}
|
|
7769
7769
|
existingLinks.push({
|
|
7770
7770
|
name,
|
|
@@ -7778,7 +7778,7 @@ function collectAddonTreeState(addonDir) {
|
|
|
7778
7778
|
version: manifest.version
|
|
7779
7779
|
});
|
|
7780
7780
|
for (const [depName, range] of manifest.ranges) {
|
|
7781
|
-
if (fs
|
|
7781
|
+
if (fs.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
|
|
7782
7782
|
addRange(depName, range);
|
|
7783
7783
|
}
|
|
7784
7784
|
}
|
|
@@ -7808,7 +7808,7 @@ function resolveClosureNodeModulesDir(explicitDir) {
|
|
|
7808
7808
|
const frameworkDir = explicitDir ?? process.env["CAMSTACK_FRAMEWORK_DIR"];
|
|
7809
7809
|
if (frameworkDir === void 0 || frameworkDir.length === 0) return null;
|
|
7810
7810
|
const nodeModulesDir = explicitDir ?? path$1.join(frameworkDir, "node_modules");
|
|
7811
|
-
return fs
|
|
7811
|
+
return fs.existsSync(nodeModulesDir) ? nodeModulesDir : null;
|
|
7812
7812
|
}
|
|
7813
7813
|
function symlinkType() {
|
|
7814
7814
|
return process.platform === "win32" ? "junction" : "dir";
|
|
@@ -7827,10 +7827,10 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
|
|
|
7827
7827
|
const nodeModulesDir = path$1.join(addonDir, "node_modules");
|
|
7828
7828
|
const probePath = path$1.join(nodeModulesDir, ".closure-link-probe");
|
|
7829
7829
|
try {
|
|
7830
|
-
fs
|
|
7831
|
-
fs
|
|
7832
|
-
fs
|
|
7833
|
-
fs
|
|
7830
|
+
fs.mkdirSync(nodeModulesDir, { recursive: true });
|
|
7831
|
+
fs.rmSync(probePath, { force: true });
|
|
7832
|
+
fs.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
|
|
7833
|
+
fs.rmSync(probePath, { force: true });
|
|
7834
7834
|
} catch (err) {
|
|
7835
7835
|
logger.warn("closure dedupe skipped — symlinks unavailable on this volume", { meta: {
|
|
7836
7836
|
addonDir,
|
|
@@ -7852,12 +7852,12 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
|
|
|
7852
7852
|
}
|
|
7853
7853
|
const entryDir = path$1.join(nodeModulesDir, link.name);
|
|
7854
7854
|
try {
|
|
7855
|
-
fs
|
|
7855
|
+
fs.rmSync(entryDir, {
|
|
7856
7856
|
recursive: true,
|
|
7857
7857
|
force: true
|
|
7858
7858
|
});
|
|
7859
|
-
fs
|
|
7860
|
-
fs
|
|
7859
|
+
fs.mkdirSync(path$1.dirname(entryDir), { recursive: true });
|
|
7860
|
+
fs.symlinkSync(target, entryDir, symlinkType());
|
|
7861
7861
|
linked.push(link.name);
|
|
7862
7862
|
} catch (err) {
|
|
7863
7863
|
logger.warn("closure dedupe — link failed; entry removed copy may need reinstall", { meta: {
|
|
@@ -7933,7 +7933,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
|
|
|
7933
7933
|
count: Object.keys(native).length
|
|
7934
7934
|
} });
|
|
7935
7935
|
try {
|
|
7936
|
-
fs
|
|
7936
|
+
fs.writeFileSync(markerFile, markerHash);
|
|
7937
7937
|
} catch (err) {
|
|
7938
7938
|
logger.warn("Failed to write native deps marker", { meta: {
|
|
7939
7939
|
markerFile,
|
|
@@ -7971,7 +7971,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
|
|
|
7971
7971
|
}
|
|
7972
7972
|
await rebuildNativeDeps(addonDir, pending.map(([name]) => name), logger, npmCacheDir ?? defaultNpmCacheDir(), registry);
|
|
7973
7973
|
try {
|
|
7974
|
-
fs
|
|
7974
|
+
fs.writeFileSync(markerFile, markerHash);
|
|
7975
7975
|
} catch (err) {
|
|
7976
7976
|
logger.warn("Failed to write native deps marker", { meta: {
|
|
7977
7977
|
markerFile,
|
|
@@ -7993,12 +7993,12 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
|
|
|
7993
7993
|
if (source === target) continue;
|
|
7994
7994
|
if (!hasBuiltBinary(source)) continue;
|
|
7995
7995
|
try {
|
|
7996
|
-
fs
|
|
7996
|
+
fs.rmSync(target, {
|
|
7997
7997
|
recursive: true,
|
|
7998
7998
|
force: true
|
|
7999
7999
|
});
|
|
8000
|
-
fs
|
|
8001
|
-
fs
|
|
8000
|
+
fs.mkdirSync(path$1.dirname(target), { recursive: true });
|
|
8001
|
+
fs.cpSync(source, target, {
|
|
8002
8002
|
recursive: true,
|
|
8003
8003
|
dereference: true
|
|
8004
8004
|
});
|
|
@@ -8034,7 +8034,7 @@ var BUNDLED_NATIVE_SIBLING_SCOPES = {
|
|
|
8034
8034
|
function hasAnyDotNode(dir, maxDepth) {
|
|
8035
8035
|
let entries;
|
|
8036
8036
|
try {
|
|
8037
|
-
entries = fs
|
|
8037
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
8038
8038
|
} catch {
|
|
8039
8039
|
return false;
|
|
8040
8040
|
}
|
|
@@ -8048,12 +8048,12 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
|
|
|
8048
8048
|
if (!hasAnyDotNode(src, 5)) return;
|
|
8049
8049
|
if (hasAnyDotNode(dst, 5)) return;
|
|
8050
8050
|
try {
|
|
8051
|
-
fs
|
|
8051
|
+
fs.rmSync(dst, {
|
|
8052
8052
|
recursive: true,
|
|
8053
8053
|
force: true
|
|
8054
8054
|
});
|
|
8055
|
-
fs
|
|
8056
|
-
fs
|
|
8055
|
+
fs.mkdirSync(path$1.dirname(dst), { recursive: true });
|
|
8056
|
+
fs.cpSync(src, dst, {
|
|
8057
8057
|
recursive: true,
|
|
8058
8058
|
dereference: true
|
|
8059
8059
|
});
|
|
@@ -8088,7 +8088,7 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
|
|
|
8088
8088
|
*/
|
|
8089
8089
|
function copyBundledNativeModules(sourceDir, targetDir, logger) {
|
|
8090
8090
|
const srcNm = path$1.join(sourceDir, "node_modules");
|
|
8091
|
-
if (!fs
|
|
8091
|
+
if (!fs.existsSync(srcNm)) return;
|
|
8092
8092
|
const dstNm = path$1.join(targetDir, "node_modules");
|
|
8093
8093
|
for (const [name, scopes] of Object.entries(BUNDLED_NATIVE_SIBLING_SCOPES)) {
|
|
8094
8094
|
copyPrebuiltModuleDir(path$1.join(srcNm, name), path$1.join(dstNm, name), name, logger);
|
|
@@ -8096,7 +8096,7 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
|
|
|
8096
8096
|
const scopeSrc = path$1.join(srcNm, scope);
|
|
8097
8097
|
let siblings;
|
|
8098
8098
|
try {
|
|
8099
|
-
siblings = fs
|
|
8099
|
+
siblings = fs.readdirSync(scopeSrc);
|
|
8100
8100
|
} catch {
|
|
8101
8101
|
continue;
|
|
8102
8102
|
}
|
|
@@ -8106,12 +8106,12 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
|
|
|
8106
8106
|
}
|
|
8107
8107
|
/** A package dir is "built" when it carries a compiled `.node` or a prebuilds tree. */
|
|
8108
8108
|
function hasBuiltBinary(pkgDir) {
|
|
8109
|
-
if (!fs
|
|
8109
|
+
if (!fs.existsSync(path$1.join(pkgDir, "package.json"))) return false;
|
|
8110
8110
|
const releaseDir = path$1.join(pkgDir, "build", "Release");
|
|
8111
8111
|
try {
|
|
8112
|
-
if (fs
|
|
8112
|
+
if (fs.existsSync(releaseDir) && fs.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
|
|
8113
8113
|
} catch {}
|
|
8114
|
-
return fs
|
|
8114
|
+
return fs.existsSync(path$1.join(pkgDir, "prebuilds"));
|
|
8115
8115
|
}
|
|
8116
8116
|
/** Candidate hoisted locations for `<name>`: NODE_PATH entries + ancestors of `addonDir`. */
|
|
8117
8117
|
function candidateHoistedDirs(name, addonDir) {
|
|
@@ -8149,7 +8149,7 @@ function hashDeclaration(deps) {
|
|
|
8149
8149
|
}
|
|
8150
8150
|
function markerMatches(markerFile, expected) {
|
|
8151
8151
|
try {
|
|
8152
|
-
return fs
|
|
8152
|
+
return fs.readFileSync(markerFile, "utf-8").trim() === expected;
|
|
8153
8153
|
} catch {
|
|
8154
8154
|
return false;
|
|
8155
8155
|
}
|
|
@@ -8256,7 +8256,7 @@ function parseInstallSource(value) {
|
|
|
8256
8256
|
function readPackageJson(pkgJsonPath) {
|
|
8257
8257
|
let raw;
|
|
8258
8258
|
try {
|
|
8259
|
-
raw = asJsonObject$1(parseJsonUnknown(fs
|
|
8259
|
+
raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
|
|
8260
8260
|
} catch {
|
|
8261
8261
|
return null;
|
|
8262
8262
|
}
|
|
@@ -8298,7 +8298,7 @@ function shouldSkipClosureProvidedSeed(packageName, isResolvable) {
|
|
|
8298
8298
|
var REGISTRY_LATEST_TIMEOUT_MS = 15e3;
|
|
8299
8299
|
function readInstalledPackageVersion(addonDir) {
|
|
8300
8300
|
try {
|
|
8301
|
-
const raw = JSON.parse(fs
|
|
8301
|
+
const raw = JSON.parse(fs.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
|
|
8302
8302
|
if (raw === null || typeof raw !== "object") return null;
|
|
8303
8303
|
const version = Reflect.get(raw, "version");
|
|
8304
8304
|
return typeof version === "string" && version.length > 0 ? version : null;
|
|
@@ -8439,7 +8439,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8439
8439
|
} catch {
|
|
8440
8440
|
return Object.freeze([]);
|
|
8441
8441
|
}
|
|
8442
|
-
const raw = fs
|
|
8442
|
+
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
8443
8443
|
const parsed = JSON.parse(raw);
|
|
8444
8444
|
const deps = Object.keys(parsed.dependencies ?? {});
|
|
8445
8445
|
const agentOnly = new Set(parsed.camstack?.agentOnlyBootstrapAddons ?? []);
|
|
@@ -8484,7 +8484,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8484
8484
|
} catch {
|
|
8485
8485
|
return Object.freeze([]);
|
|
8486
8486
|
}
|
|
8487
|
-
const raw = fs
|
|
8487
|
+
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
8488
8488
|
const addons = JSON.parse(raw).camstack?.agentBootstrapAddons ?? [];
|
|
8489
8489
|
return Object.freeze(["@camstack/server", ...addons]);
|
|
8490
8490
|
}
|
|
@@ -8514,7 +8514,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8514
8514
|
this.logger.info(`Install source: ${isLocal ? `bundle (${this.bundledAddonsDir})` : "npm"}, ${pkgList.length} package(s)`);
|
|
8515
8515
|
for (const packageName of pkgList) {
|
|
8516
8516
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
8517
|
-
if (fs
|
|
8517
|
+
if (fs.existsSync(path$1.join(addonDir, "package.json"))) {
|
|
8518
8518
|
if (isLocal || shouldSkipClosureProvidedSeed(packageName, this.isResolvableFromClosure(packageName))) {
|
|
8519
8519
|
this.logger.debug(`${packageName} — already installed, skipping`);
|
|
8520
8520
|
continue;
|
|
@@ -8658,7 +8658,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8658
8658
|
const installedPackages = this.listInstalled();
|
|
8659
8659
|
for (const pkg of installedPackages) {
|
|
8660
8660
|
try {
|
|
8661
|
-
if (fs
|
|
8661
|
+
if (fs.lstatSync(pkg.dir).isSymbolicLink()) continue;
|
|
8662
8662
|
} catch {
|
|
8663
8663
|
continue;
|
|
8664
8664
|
}
|
|
@@ -8698,7 +8698,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8698
8698
|
if (closureNodeModules !== null) for (const link of state.existingLinks) {
|
|
8699
8699
|
if (!isClosureLinkTarget(link.target, closureNodeModules)) continue;
|
|
8700
8700
|
const linkDir = path$1.join(nodeModulesDir, link.name);
|
|
8701
|
-
const targetManifest = fs
|
|
8701
|
+
const targetManifest = fs.existsSync(path$1.join(linkDir, "package.json"));
|
|
8702
8702
|
const ranges = state.requirements.get(link.name) ?? [];
|
|
8703
8703
|
let holds = targetManifest;
|
|
8704
8704
|
if (holds && ranges.length > 0) {
|
|
@@ -8707,14 +8707,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8707
8707
|
}
|
|
8708
8708
|
if (!holds) {
|
|
8709
8709
|
this.logger.warn(`${packageName} — closure link for ${link.name} no longer holds; reinstalling this addon's deps`, { meta: { target: link.target } });
|
|
8710
|
-
fs
|
|
8710
|
+
fs.rmSync(linkDir, { force: true });
|
|
8711
8711
|
needsInstall = true;
|
|
8712
8712
|
}
|
|
8713
8713
|
}
|
|
8714
8714
|
const linked = [];
|
|
8715
8715
|
for (const [depName, range] of declaredEntries) {
|
|
8716
8716
|
if (typeof range !== "string") continue;
|
|
8717
|
-
if (fs
|
|
8717
|
+
if (fs.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
|
|
8718
8718
|
const closureVersion = closureNodeModules === null ? void 0 : readClosureVersions(closureNodeModules, [depName]).get(depName);
|
|
8719
8719
|
if (closureNodeModules !== null && closureVersion !== void 0 && closureSatisfiesRange(range, closureVersion)) {
|
|
8720
8720
|
if (executeClosureDedupe(addonDir, closureNodeModules, {
|
|
@@ -8747,7 +8747,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8747
8747
|
const closureNodeModules = resolveClosureNodeModulesDir(this.closureNodeModulesDir);
|
|
8748
8748
|
if (closureNodeModules !== null) {
|
|
8749
8749
|
const state = collectAddonTreeState(addonDir);
|
|
8750
|
-
for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs
|
|
8750
|
+
for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
|
|
8751
8751
|
}
|
|
8752
8752
|
this.logger.info(`${packageName} — reinstalling runtime dependencies`, { meta: { addonDir } });
|
|
8753
8753
|
await runNpm([
|
|
@@ -8792,7 +8792,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8792
8792
|
async realignFromClosure(packageName, closureDir) {
|
|
8793
8793
|
const targetDir = path$1.join(this.addonsDir, packageName);
|
|
8794
8794
|
const result = await this.installLocal(packageName, closureDir);
|
|
8795
|
-
await fs
|
|
8795
|
+
await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
|
|
8796
8796
|
this.manifest.upsert(result.name, {
|
|
8797
8797
|
version: result.version,
|
|
8798
8798
|
source: "closure"
|
|
@@ -8808,17 +8808,17 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8808
8808
|
async installCopy(packageName, sourceDir, pkgData, targetDir) {
|
|
8809
8809
|
await this.ensureBuilt(packageName, sourceDir, pkgData);
|
|
8810
8810
|
const distDir = path$1.join(sourceDir, "dist");
|
|
8811
|
-
if (!fs
|
|
8812
|
-
await fs
|
|
8811
|
+
if (!fs.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
|
|
8812
|
+
await fs.promises.rm(targetDir, {
|
|
8813
8813
|
recursive: true,
|
|
8814
8814
|
force: true
|
|
8815
8815
|
});
|
|
8816
8816
|
ensureDir(targetDir);
|
|
8817
|
-
await fs
|
|
8817
|
+
await fs.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
|
|
8818
8818
|
await copyDirRecursive(distDir, path$1.join(targetDir, "dist"));
|
|
8819
8819
|
await copyExtraFileDirs(pkgData, sourceDir, targetDir);
|
|
8820
8820
|
copyBundledNativeModules(sourceDir, targetDir, this.logger);
|
|
8821
|
-
await fs
|
|
8821
|
+
await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
|
|
8822
8822
|
const localPkgVersion = asString$1(pkgData.version, "0.0.0");
|
|
8823
8823
|
this.manifest.upsert(packageName, {
|
|
8824
8824
|
version: localPkgVersion,
|
|
@@ -8859,7 +8859,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8859
8859
|
* unusual auth, offline mode, etc).
|
|
8860
8860
|
*/
|
|
8861
8861
|
async installFromNpm(packageName, version) {
|
|
8862
|
-
const tmpDir = fs
|
|
8862
|
+
const tmpDir = fs.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
|
|
8863
8863
|
const packageSpec = version ? `${packageName}@${version}` : packageName;
|
|
8864
8864
|
this.logger.info(`${packageName} — installing from npm`);
|
|
8865
8865
|
try {
|
|
@@ -8873,19 +8873,19 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8873
8873
|
];
|
|
8874
8874
|
if (this.registry) args.push("--registry", this.registry);
|
|
8875
8875
|
const { stdout } = await runNpm(args, this.npmRunOptions(tmpDir, 12e4));
|
|
8876
|
-
const tgzFiles = fs
|
|
8876
|
+
const tgzFiles = fs.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
|
|
8877
8877
|
if (tgzFiles.length === 0) throw new Error(`npm pack produced no tgz. stdout: ${stdout.trim()}`);
|
|
8878
8878
|
return path$1.join(tmpDir, tgzFiles[0]);
|
|
8879
8879
|
});
|
|
8880
8880
|
const result = await this.installFromTgz(tgzPath);
|
|
8881
|
-
fs
|
|
8881
|
+
fs.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
|
|
8882
8882
|
this.manifest.upsert(result.name, {
|
|
8883
8883
|
version: result.version,
|
|
8884
8884
|
source: "npm"
|
|
8885
8885
|
});
|
|
8886
8886
|
return result;
|
|
8887
8887
|
} finally {
|
|
8888
|
-
fs
|
|
8888
|
+
fs.rmSync(tmpDir, {
|
|
8889
8889
|
recursive: true,
|
|
8890
8890
|
force: true
|
|
8891
8891
|
});
|
|
@@ -8923,7 +8923,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8923
8923
|
if (!tarRes.ok) throw new Error(`tarball GET ${tarballUrl} → ${tarRes.status}`);
|
|
8924
8924
|
const tgzPath = path$1.join(tmpDir, `${packageName.replace(/[/@]/g, "-").replace(/^-+/, "")}-${resolvedVersion}.tgz`);
|
|
8925
8925
|
const buf = Buffer.from(await tarRes.arrayBuffer());
|
|
8926
|
-
fs
|
|
8926
|
+
fs.writeFileSync(tgzPath, buf);
|
|
8927
8927
|
return tgzPath;
|
|
8928
8928
|
}
|
|
8929
8929
|
/**
|
|
@@ -8944,7 +8944,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8944
8944
|
* on the next deploy.
|
|
8945
8945
|
*/
|
|
8946
8946
|
async evictInstallDir(targetDir) {
|
|
8947
|
-
if (!fs
|
|
8947
|
+
if (!fs.existsSync(targetDir)) return;
|
|
8948
8948
|
const graveyard = path$1.join(this.addonsDir, ".evicting");
|
|
8949
8949
|
ensureDir(graveyard);
|
|
8950
8950
|
await this.sweepGraveyard(graveyard);
|
|
@@ -8952,10 +8952,10 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8952
8952
|
const flatName = path$1.relative(this.addonsDir, targetDir).replace(/[/\\]/g, "-");
|
|
8953
8953
|
const asideDir = path$1.join(graveyard, `${flatName}-${ts}`);
|
|
8954
8954
|
try {
|
|
8955
|
-
fs
|
|
8955
|
+
fs.renameSync(targetDir, asideDir);
|
|
8956
8956
|
} catch (renameErr) {
|
|
8957
8957
|
if (renameErr.code === "EXDEV") {
|
|
8958
|
-
await fs
|
|
8958
|
+
await fs.promises.rm(targetDir, {
|
|
8959
8959
|
recursive: true,
|
|
8960
8960
|
force: true
|
|
8961
8961
|
});
|
|
@@ -8963,7 +8963,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8963
8963
|
}
|
|
8964
8964
|
throw renameErr;
|
|
8965
8965
|
}
|
|
8966
|
-
await fs
|
|
8966
|
+
await fs.promises.rm(asideDir, {
|
|
8967
8967
|
recursive: true,
|
|
8968
8968
|
force: true
|
|
8969
8969
|
}).catch((cleanupErr) => {
|
|
@@ -8984,14 +8984,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8984
8984
|
async sweepStagingResidue(stagingRoot) {
|
|
8985
8985
|
let names;
|
|
8986
8986
|
try {
|
|
8987
|
-
names = fs
|
|
8987
|
+
names = fs.readdirSync(stagingRoot);
|
|
8988
8988
|
} catch {
|
|
8989
8989
|
return;
|
|
8990
8990
|
}
|
|
8991
8991
|
const now = Date.now();
|
|
8992
8992
|
const ages = [];
|
|
8993
8993
|
for (const name of names) try {
|
|
8994
|
-
const stat = fs
|
|
8994
|
+
const stat = fs.statSync(path$1.join(stagingRoot, name));
|
|
8995
8995
|
ages.push({
|
|
8996
8996
|
name,
|
|
8997
8997
|
ageMs: now - stat.mtimeMs
|
|
@@ -9002,7 +9002,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9002
9002
|
stagingRoot,
|
|
9003
9003
|
entries: sweepable
|
|
9004
9004
|
} });
|
|
9005
|
-
await Promise.all(sweepable.map((name) => fs
|
|
9005
|
+
await Promise.all(sweepable.map((name) => fs.promises.rm(path$1.join(stagingRoot, name), {
|
|
9006
9006
|
recursive: true,
|
|
9007
9007
|
force: true
|
|
9008
9008
|
}).catch(() => void 0)));
|
|
@@ -9011,11 +9011,11 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9011
9011
|
async sweepGraveyard(graveyard) {
|
|
9012
9012
|
let entries;
|
|
9013
9013
|
try {
|
|
9014
|
-
entries = fs
|
|
9014
|
+
entries = fs.readdirSync(graveyard);
|
|
9015
9015
|
} catch {
|
|
9016
9016
|
return;
|
|
9017
9017
|
}
|
|
9018
|
-
await Promise.all(entries.map((name) => fs
|
|
9018
|
+
await Promise.all(entries.map((name) => fs.promises.rm(path$1.join(graveyard, name), {
|
|
9019
9019
|
recursive: true,
|
|
9020
9020
|
force: true
|
|
9021
9021
|
}).catch(() => void 0)));
|
|
@@ -9066,7 +9066,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9066
9066
|
return;
|
|
9067
9067
|
}
|
|
9068
9068
|
const strippedManifest = stripBundledDeps(pkgView.raw);
|
|
9069
|
-
await fs
|
|
9069
|
+
await fs.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
|
|
9070
9070
|
const deps = asJsonObject$1(strippedManifest["dependencies"]);
|
|
9071
9071
|
const depNames = deps ? Object.keys(deps) : [];
|
|
9072
9072
|
if (depNames.length === 0) return;
|
|
@@ -9198,9 +9198,9 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9198
9198
|
"-C",
|
|
9199
9199
|
stagingDir
|
|
9200
9200
|
], { timeout: 12e4 });
|
|
9201
|
-
const pkgDir = fs
|
|
9201
|
+
const pkgDir = fs.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
|
|
9202
9202
|
const pkgJsonPath = path$1.join(pkgDir, "package.json");
|
|
9203
|
-
if (!fs
|
|
9203
|
+
if (!fs.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
|
|
9204
9204
|
const pkgView = readPackageJson(pkgJsonPath);
|
|
9205
9205
|
if (!pkgView) throw new Error(`Invalid package.json at ${pkgJsonPath}`);
|
|
9206
9206
|
if (!pkgView.camstackAddons) throw new Error(`Package ${pkgView.name} has no camstack.addons manifest`);
|
|
@@ -9210,7 +9210,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9210
9210
|
this.dedupeTreeAgainstClosure(pkgDir, pkgView.name);
|
|
9211
9211
|
await this.evictInstallDir(targetDir);
|
|
9212
9212
|
ensureDir(path$1.dirname(targetDir));
|
|
9213
|
-
await fs
|
|
9213
|
+
await fs.promises.rename(pkgDir, targetDir);
|
|
9214
9214
|
this.manifest.upsert(pkgView.name, {
|
|
9215
9215
|
version: pkgView.version,
|
|
9216
9216
|
source: "bundled"
|
|
@@ -9221,7 +9221,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9221
9221
|
};
|
|
9222
9222
|
} finally {
|
|
9223
9223
|
this.inFlightStaging.delete(stagingName);
|
|
9224
|
-
await fs
|
|
9224
|
+
await fs.promises.rm(stagingDir, {
|
|
9225
9225
|
recursive: true,
|
|
9226
9226
|
force: true
|
|
9227
9227
|
}).catch(() => void 0);
|
|
@@ -9251,24 +9251,24 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9251
9251
|
const current = this.manifest.get(packageName);
|
|
9252
9252
|
if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
|
|
9253
9253
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9254
|
-
if (!fs
|
|
9254
|
+
if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
|
|
9255
9255
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
9256
9256
|
const backupRoot = path$1.join(this.addonsDir, ".backups", packageName);
|
|
9257
9257
|
ensureDir(backupRoot);
|
|
9258
9258
|
const backupDir = path$1.join(backupRoot, ts);
|
|
9259
9259
|
this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
|
|
9260
|
-
fs
|
|
9260
|
+
fs.renameSync(addonDir, backupDir);
|
|
9261
9261
|
let result;
|
|
9262
9262
|
try {
|
|
9263
9263
|
result = await this.installFromNpm(packageName, version);
|
|
9264
9264
|
} catch (installErr) {
|
|
9265
9265
|
this.logger.error(`${packageName} — install failed, restoring backup`, { meta: { error: errMsg$1(installErr) } });
|
|
9266
9266
|
try {
|
|
9267
|
-
if (fs
|
|
9267
|
+
if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
|
|
9268
9268
|
recursive: true,
|
|
9269
9269
|
force: true
|
|
9270
9270
|
});
|
|
9271
|
-
fs
|
|
9271
|
+
fs.renameSync(backupDir, addonDir);
|
|
9272
9272
|
this.manifest.upsert(packageName, {
|
|
9273
9273
|
version: current.version,
|
|
9274
9274
|
source: current.source,
|
|
@@ -9329,7 +9329,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9329
9329
|
const current = this.manifest.get(packageName);
|
|
9330
9330
|
if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
|
|
9331
9331
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9332
|
-
if (!fs
|
|
9332
|
+
if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
|
|
9333
9333
|
await this.installRuntimeDependencies(stagedPath, packageName);
|
|
9334
9334
|
await this.installNativeDependencies(stagedPath, packageName);
|
|
9335
9335
|
this.dedupeTreeAgainstClosure(stagedPath, packageName);
|
|
@@ -9338,14 +9338,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9338
9338
|
ensureDir(backupRoot);
|
|
9339
9339
|
const backupDir = path$1.join(backupRoot, ts);
|
|
9340
9340
|
this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
|
|
9341
|
-
fs
|
|
9341
|
+
fs.renameSync(addonDir, backupDir);
|
|
9342
9342
|
try {
|
|
9343
9343
|
try {
|
|
9344
|
-
fs
|
|
9344
|
+
fs.renameSync(stagedPath, addonDir);
|
|
9345
9345
|
} catch (renameErr) {
|
|
9346
9346
|
if (renameErr.code === "EXDEV") {
|
|
9347
|
-
fs
|
|
9348
|
-
fs
|
|
9347
|
+
fs.cpSync(stagedPath, addonDir, { recursive: true });
|
|
9348
|
+
fs.rmSync(stagedPath, {
|
|
9349
9349
|
recursive: true,
|
|
9350
9350
|
force: true
|
|
9351
9351
|
});
|
|
@@ -9354,11 +9354,11 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9354
9354
|
} catch (swapErr) {
|
|
9355
9355
|
this.logger.error(`${packageName} — staged swap failed, restoring backup`, { meta: { error: errMsg$1(swapErr) } });
|
|
9356
9356
|
try {
|
|
9357
|
-
if (fs
|
|
9357
|
+
if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
|
|
9358
9358
|
recursive: true,
|
|
9359
9359
|
force: true
|
|
9360
9360
|
});
|
|
9361
|
-
fs
|
|
9361
|
+
fs.renameSync(backupDir, addonDir);
|
|
9362
9362
|
this.manifest.upsert(packageName, {
|
|
9363
9363
|
version: current.version,
|
|
9364
9364
|
source: current.source,
|
|
@@ -9397,20 +9397,20 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9397
9397
|
this.logger.warn(`${packageName} — no backup to rollback to`);
|
|
9398
9398
|
return null;
|
|
9399
9399
|
}
|
|
9400
|
-
if (!fs
|
|
9400
|
+
if (!fs.existsSync(entry.lastBackupDir)) {
|
|
9401
9401
|
this.logger.warn(`${packageName} — backup dir vanished: ${entry.lastBackupDir}`);
|
|
9402
9402
|
return null;
|
|
9403
9403
|
}
|
|
9404
9404
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9405
|
-
if (fs
|
|
9405
|
+
if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
|
|
9406
9406
|
recursive: true,
|
|
9407
9407
|
force: true
|
|
9408
9408
|
});
|
|
9409
|
-
fs
|
|
9409
|
+
fs.renameSync(entry.lastBackupDir, addonDir);
|
|
9410
9410
|
const pkgJsonPath = path$1.join(addonDir, "package.json");
|
|
9411
9411
|
let restoredVersion = entry.version;
|
|
9412
|
-
if (fs
|
|
9413
|
-
const parsed = JSON.parse(fs
|
|
9412
|
+
if (fs.existsSync(pkgJsonPath)) try {
|
|
9413
|
+
const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
9414
9414
|
if (typeof parsed === "object" && parsed != null) {
|
|
9415
9415
|
const v = parsed.version;
|
|
9416
9416
|
if (typeof v === "string" && v.length > 0) restoredVersion = v;
|
|
@@ -9458,7 +9458,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9458
9458
|
return false;
|
|
9459
9459
|
}
|
|
9460
9460
|
try {
|
|
9461
|
-
await fs
|
|
9461
|
+
await fs.promises.rm(target, {
|
|
9462
9462
|
recursive: true,
|
|
9463
9463
|
force: true
|
|
9464
9464
|
});
|
|
@@ -9476,7 +9476,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9476
9476
|
listBackupsFor(packageName) {
|
|
9477
9477
|
const dir = path$1.join(this.backupsRoot, packageName);
|
|
9478
9478
|
try {
|
|
9479
|
-
return fs
|
|
9479
|
+
return fs.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
|
|
9480
9480
|
} catch {
|
|
9481
9481
|
return [];
|
|
9482
9482
|
}
|
|
@@ -9508,7 +9508,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9508
9508
|
for (const dir of [pkgDir, path$1.dirname(pkgDir)]) {
|
|
9509
9509
|
if (!this.isInsideBackups(dir)) continue;
|
|
9510
9510
|
try {
|
|
9511
|
-
await fs
|
|
9511
|
+
await fs.promises.rmdir(dir);
|
|
9512
9512
|
} catch {
|
|
9513
9513
|
return;
|
|
9514
9514
|
}
|
|
@@ -9590,7 +9590,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9590
9590
|
*/
|
|
9591
9591
|
resolveBackupToKeep(packageName, backups) {
|
|
9592
9592
|
const liveDir = path$1.join(this.addonsDir, packageName);
|
|
9593
|
-
if (!fs
|
|
9593
|
+
if (!fs.existsSync(liveDir)) {
|
|
9594
9594
|
const newest = backups[backups.length - 1] ?? null;
|
|
9595
9595
|
if (newest != null) this.logger.warn(`${packageName} — live install dir missing; retaining its newest backup as the only surviving copy`, { meta: {
|
|
9596
9596
|
liveDir,
|
|
@@ -9607,7 +9607,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9607
9607
|
listBackedUpPackages() {
|
|
9608
9608
|
let entries;
|
|
9609
9609
|
try {
|
|
9610
|
-
entries = fs
|
|
9610
|
+
entries = fs.readdirSync(this.backupsRoot, { withFileTypes: true });
|
|
9611
9611
|
} catch {
|
|
9612
9612
|
return [];
|
|
9613
9613
|
}
|
|
@@ -9619,14 +9619,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9619
9619
|
continue;
|
|
9620
9620
|
}
|
|
9621
9621
|
const scopeDir = path$1.join(this.backupsRoot, entry.name);
|
|
9622
|
-
for (const inner of fs
|
|
9622
|
+
for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
|
|
9623
9623
|
}
|
|
9624
9624
|
return names;
|
|
9625
9625
|
}
|
|
9626
9626
|
async uninstall(packageName) {
|
|
9627
9627
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9628
|
-
if (fs
|
|
9629
|
-
fs
|
|
9628
|
+
if (fs.existsSync(addonDir)) {
|
|
9629
|
+
fs.rmSync(addonDir, {
|
|
9630
9630
|
recursive: true,
|
|
9631
9631
|
force: true
|
|
9632
9632
|
});
|
|
@@ -9634,8 +9634,8 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9634
9634
|
return;
|
|
9635
9635
|
}
|
|
9636
9636
|
const legacyDir = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""));
|
|
9637
|
-
if (fs
|
|
9638
|
-
fs
|
|
9637
|
+
if (fs.existsSync(legacyDir)) {
|
|
9638
|
+
fs.rmSync(legacyDir, {
|
|
9639
9639
|
recursive: true,
|
|
9640
9640
|
force: true
|
|
9641
9641
|
});
|
|
@@ -9643,22 +9643,22 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9643
9643
|
}
|
|
9644
9644
|
}
|
|
9645
9645
|
listInstalled() {
|
|
9646
|
-
if (!fs
|
|
9646
|
+
if (!fs.existsSync(this.addonsDir)) return [];
|
|
9647
9647
|
const packageDirs = [];
|
|
9648
|
-
for (const entry of fs
|
|
9648
|
+
for (const entry of fs.readdirSync(this.addonsDir, { withFileTypes: true })) {
|
|
9649
9649
|
if (!isDirEntry(entry, this.addonsDir)) continue;
|
|
9650
9650
|
if (entry.name.startsWith("@")) {
|
|
9651
9651
|
const scopeDir = path$1.join(this.addonsDir, entry.name);
|
|
9652
|
-
for (const inner of fs
|
|
9652
|
+
for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
|
|
9653
9653
|
} else packageDirs.push(path$1.join(this.addonsDir, entry.name));
|
|
9654
9654
|
}
|
|
9655
9655
|
return packageDirs.map((dir) => {
|
|
9656
9656
|
const pkgPath = path$1.join(dir, "package.json");
|
|
9657
|
-
if (!fs
|
|
9657
|
+
if (!fs.existsSync(pkgPath)) return null;
|
|
9658
9658
|
const pkg = readPackageJson(pkgPath);
|
|
9659
9659
|
if (!pkg || !pkg.camstackAddons) return null;
|
|
9660
9660
|
const sourceFile = path$1.join(dir, ".install-source");
|
|
9661
|
-
const installSource = fs
|
|
9661
|
+
const installSource = fs.existsSync(sourceFile) ? parseInstallSource(fs.readFileSync(sourceFile, "utf-8").trim()) : void 0;
|
|
9662
9662
|
return {
|
|
9663
9663
|
name: pkg.name,
|
|
9664
9664
|
version: pkg.version,
|
|
@@ -9668,13 +9668,13 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9668
9668
|
}).filter((item) => item !== null);
|
|
9669
9669
|
}
|
|
9670
9670
|
isInstalled(packageName) {
|
|
9671
|
-
if (fs
|
|
9672
|
-
return fs
|
|
9671
|
+
if (fs.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
|
|
9672
|
+
return fs.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
|
|
9673
9673
|
}
|
|
9674
9674
|
getInstalledPackage(packageName) {
|
|
9675
9675
|
let pkgPath = path$1.join(this.addonsDir, packageName, "package.json");
|
|
9676
|
-
if (!fs
|
|
9677
|
-
if (!fs
|
|
9676
|
+
if (!fs.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
|
|
9677
|
+
if (!fs.existsSync(pkgPath)) return null;
|
|
9678
9678
|
const pkg = readPackageJson(pkgPath);
|
|
9679
9679
|
if (!pkg) return null;
|
|
9680
9680
|
return {
|
|
@@ -9693,7 +9693,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9693
9693
|
]) {
|
|
9694
9694
|
const candidate = path$1.join(this.bundledAddonsDir, dirName);
|
|
9695
9695
|
try {
|
|
9696
|
-
const pkg = asJsonObject$1(parseJsonUnknown(fs
|
|
9696
|
+
const pkg = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
|
|
9697
9697
|
if (pkg && asString$1(pkg["name"]) === packageName) return candidate;
|
|
9698
9698
|
} catch {}
|
|
9699
9699
|
}
|
|
@@ -9702,7 +9702,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9702
9702
|
/** Ensure a package is built (dist/ exists and page bundles present) */
|
|
9703
9703
|
async ensureBuilt(packageName, sourceDir, pkgData) {
|
|
9704
9704
|
const distDir = path$1.join(sourceDir, "dist");
|
|
9705
|
-
if (!(!fs
|
|
9705
|
+
if (!(!fs.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
|
|
9706
9706
|
this.logger.info(`${packageName} — building (dist/ missing or incomplete)`);
|
|
9707
9707
|
try {
|
|
9708
9708
|
await runNpm(["run", "build"], this.npmRunOptions(sourceDir, 18e4));
|
|
@@ -9717,7 +9717,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9717
9717
|
if (!camstack?.addons) return false;
|
|
9718
9718
|
for (const addon of camstack.addons) {
|
|
9719
9719
|
if (!addon.pages) continue;
|
|
9720
|
-
for (const page of addon.pages) if (page.bundle && !fs
|
|
9720
|
+
for (const page of addon.pages) if (page.bundle && !fs.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
|
|
9721
9721
|
}
|
|
9722
9722
|
return false;
|
|
9723
9723
|
}
|
|
@@ -9726,7 +9726,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9726
9726
|
function isDirEntry(entry, parentDir) {
|
|
9727
9727
|
if (entry.isDirectory()) return true;
|
|
9728
9728
|
if (entry.isSymbolicLink()) try {
|
|
9729
|
-
return fs
|
|
9729
|
+
return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
|
|
9730
9730
|
} catch {
|
|
9731
9731
|
return false;
|
|
9732
9732
|
}
|
|
@@ -9825,7 +9825,7 @@ function selectAddonResidue(candidates) {
|
|
|
9825
9825
|
}
|
|
9826
9826
|
function readDeclaredName(dir) {
|
|
9827
9827
|
try {
|
|
9828
|
-
const parsed = JSON.parse(fs
|
|
9828
|
+
const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
9829
9829
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
9830
9830
|
const name = parsed.name;
|
|
9831
9831
|
return typeof name === "string" ? name : null;
|
|
@@ -9835,7 +9835,7 @@ function readDeclaredName(dir) {
|
|
|
9835
9835
|
}
|
|
9836
9836
|
function readDeclaredVersion(dir) {
|
|
9837
9837
|
try {
|
|
9838
|
-
const parsed = JSON.parse(fs
|
|
9838
|
+
const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
9839
9839
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
9840
9840
|
const version = parsed.version;
|
|
9841
9841
|
return typeof version === "string" ? version : null;
|
|
@@ -9845,7 +9845,7 @@ function readDeclaredVersion(dir) {
|
|
|
9845
9845
|
}
|
|
9846
9846
|
function isDirLike(p) {
|
|
9847
9847
|
try {
|
|
9848
|
-
return fs
|
|
9848
|
+
return fs.statSync(p).isDirectory();
|
|
9849
9849
|
} catch {
|
|
9850
9850
|
return false;
|
|
9851
9851
|
}
|
|
@@ -9855,7 +9855,7 @@ function freeQuarantineTarget(store, scope, dirName) {
|
|
|
9855
9855
|
const base = scope === null ? dirName : `${scope.replace("@", "")}__${dirName}`;
|
|
9856
9856
|
let candidate = path$1.join(store, base);
|
|
9857
9857
|
let n = 1;
|
|
9858
|
-
while (fs
|
|
9858
|
+
while (fs.existsSync(candidate)) {
|
|
9859
9859
|
candidate = path$1.join(store, `${base}-${n}`);
|
|
9860
9860
|
n += 1;
|
|
9861
9861
|
}
|
|
@@ -9872,7 +9872,7 @@ function freeQuarantineTarget(store, scope, dirName) {
|
|
|
9872
9872
|
function quarantineAddonResidue(addonsDir, log) {
|
|
9873
9873
|
const quarantined = [];
|
|
9874
9874
|
const failed = [];
|
|
9875
|
-
if (!fs
|
|
9875
|
+
if (!fs.existsSync(addonsDir)) return {
|
|
9876
9876
|
quarantined,
|
|
9877
9877
|
failed
|
|
9878
9878
|
};
|
|
@@ -9880,7 +9880,7 @@ function quarantineAddonResidue(addonsDir, log) {
|
|
|
9880
9880
|
const scan = (parent, scope) => {
|
|
9881
9881
|
let names;
|
|
9882
9882
|
try {
|
|
9883
|
-
names = fs
|
|
9883
|
+
names = fs.readdirSync(parent);
|
|
9884
9884
|
} catch {
|
|
9885
9885
|
return;
|
|
9886
9886
|
}
|
|
@@ -9899,8 +9899,8 @@ function quarantineAddonResidue(addonsDir, log) {
|
|
|
9899
9899
|
const version = readDeclaredVersion(full);
|
|
9900
9900
|
const to = freeQuarantineTarget(store, scope, dirName);
|
|
9901
9901
|
try {
|
|
9902
|
-
fs
|
|
9903
|
-
fs
|
|
9902
|
+
fs.mkdirSync(store, { recursive: true });
|
|
9903
|
+
fs.renameSync(full, to);
|
|
9904
9904
|
} catch (err) {
|
|
9905
9905
|
const error = err instanceof Error ? err.message : String(err);
|
|
9906
9906
|
failed.push({
|
|
@@ -9958,11 +9958,11 @@ function getRestartMarkerPath(dataDir) {
|
|
|
9958
9958
|
* intact or no marker at all (never a half-written file).
|
|
9959
9959
|
*/
|
|
9960
9960
|
function writePendingRestart(dataDir, marker) {
|
|
9961
|
-
fs
|
|
9961
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
9962
9962
|
const markerPath = getRestartMarkerPath(dataDir);
|
|
9963
9963
|
const tmpPath = `${markerPath}.tmp`;
|
|
9964
|
-
fs
|
|
9965
|
-
fs
|
|
9964
|
+
fs.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
|
|
9965
|
+
fs.renameSync(tmpPath, markerPath);
|
|
9966
9966
|
}
|
|
9967
9967
|
/**
|
|
9968
9968
|
* Read + consume the marker. Returns the parsed payload on success and
|
|
@@ -9987,10 +9987,10 @@ function writePendingRestart(dataDir, marker) {
|
|
|
9987
9987
|
*/
|
|
9988
9988
|
function readPendingRestart(dataDir) {
|
|
9989
9989
|
const markerPath = getRestartMarkerPath(dataDir);
|
|
9990
|
-
if (!fs
|
|
9990
|
+
if (!fs.existsSync(markerPath)) return null;
|
|
9991
9991
|
let raw;
|
|
9992
9992
|
try {
|
|
9993
|
-
raw = fs
|
|
9993
|
+
raw = fs.readFileSync(markerPath, "utf-8");
|
|
9994
9994
|
} catch (err) {
|
|
9995
9995
|
console.error("[restart-coordinator] Marker unreadable — leaving in place:", err);
|
|
9996
9996
|
return null;
|
|
@@ -10029,7 +10029,7 @@ function readPendingRestart(dataDir) {
|
|
|
10029
10029
|
/** Remove the marker if present. No-op if missing. */
|
|
10030
10030
|
function clearPendingRestart(dataDir) {
|
|
10031
10031
|
const markerPath = getRestartMarkerPath(dataDir);
|
|
10032
|
-
fs
|
|
10032
|
+
fs.rmSync(markerPath, { force: true });
|
|
10033
10033
|
}
|
|
10034
10034
|
function isRestartKind(value) {
|
|
10035
10035
|
return value === "framework-update" || value === "manual" || value === "system";
|
|
@@ -10041,7 +10041,7 @@ function scheduleSelfRestart(options = {}) {
|
|
|
10041
10041
|
const touchTarget = process.env["CAMSTACK_RESTART_TOUCH_FILE"];
|
|
10042
10042
|
if (touchTarget !== void 0 && touchTarget.length > 0) try {
|
|
10043
10043
|
const now = /* @__PURE__ */ new Date();
|
|
10044
|
-
fs
|
|
10044
|
+
fs.utimesSync(touchTarget, now, now);
|
|
10045
10045
|
return;
|
|
10046
10046
|
} catch (err) {
|
|
10047
10047
|
console.error("[restart-coordinator] dev touch-reload failed; falling through to process exit:", err);
|
|
@@ -14411,11 +14411,11 @@ function applyEnvOverrides(raw) {
|
|
|
14411
14411
|
return result;
|
|
14412
14412
|
}
|
|
14413
14413
|
function loadYaml(configPath) {
|
|
14414
|
-
if (!fs
|
|
14414
|
+
if (!fs.existsSync(configPath)) {
|
|
14415
14415
|
console.warn(`[ConfigManager] Config file not found at: ${configPath}\n → Using built-in defaults. Set CONFIG_PATH env var or create the file.\n → Example path from project root: ./server/backend/data/config.yaml`);
|
|
14416
14416
|
return {};
|
|
14417
14417
|
}
|
|
14418
|
-
const parsed = load(fs
|
|
14418
|
+
const parsed = load(fs.readFileSync(configPath, "utf-8")) ?? {};
|
|
14419
14419
|
console.log(`[ConfigManager] Loaded config from: ${configPath}`);
|
|
14420
14420
|
return parsed;
|
|
14421
14421
|
}
|
|
@@ -16268,7 +16268,13 @@ function buildNativeCapProxy(broker, addonId, capName, deviceId) {
|
|
|
16268
16268
|
function deviceHasStreamSources(device) {
|
|
16269
16269
|
return typeof Reflect.get(device, "getStreamSources") === "function";
|
|
16270
16270
|
}
|
|
16271
|
-
|
|
16271
|
+
/**
|
|
16272
|
+
* `afterRemove` is the worker's local teardown (registry entry, native caps,
|
|
16273
|
+
* children). The hub's `remove` reaches a forked worker ONLY through this
|
|
16274
|
+
* provider, so the lifecycle call alone would leave a zombie instance in the
|
|
16275
|
+
* worker (timers running, still listed as adopted). It is idempotent.
|
|
16276
|
+
*/
|
|
16277
|
+
function buildDeviceOpsProvider(device, afterRemove) {
|
|
16272
16278
|
const assertMatch = (incoming) => {
|
|
16273
16279
|
if (incoming !== device.id) throw new Error(`device-ops: deviceId mismatch — expected '${device.id}', got '${incoming}'`);
|
|
16274
16280
|
};
|
|
@@ -16296,6 +16302,7 @@ function buildDeviceOpsProvider(device) {
|
|
|
16296
16302
|
removeDevice: async (input) => {
|
|
16297
16303
|
assertMatch(input.deviceId);
|
|
16298
16304
|
await device.removeDevice();
|
|
16305
|
+
await afterRemove?.(device.id);
|
|
16299
16306
|
},
|
|
16300
16307
|
getSettingsSchema: async (input) => {
|
|
16301
16308
|
assertMatch(input.deviceId);
|
|
@@ -16526,6 +16533,10 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
16526
16533
|
}
|
|
16527
16534
|
};
|
|
16528
16535
|
};
|
|
16536
|
+
/** The integration a spawned child inherits: its parent's persisted one, if any. */
|
|
16537
|
+
const resolveParentIntegrationId = async (parentId) => {
|
|
16538
|
+
return (await callDeviceManager(api, "loadMeta", { deviceId: parentId }).catch(() => null))?.integrationId ?? void 0;
|
|
16539
|
+
};
|
|
16529
16540
|
/**
|
|
16530
16541
|
* Spawn one accessory child device declared by a parent's
|
|
16531
16542
|
* `getAccessoryChildren()`. Mirrors the standard `create()` flow
|
|
@@ -16543,13 +16554,15 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
16543
16554
|
const empty = {};
|
|
16544
16555
|
const existingMeta = await callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null);
|
|
16545
16556
|
const isFirstSpawn = !existingMeta || existingMeta.name === childStableId;
|
|
16557
|
+
const linkDeviceId = spec.meta.linkDeviceId ?? parent.id;
|
|
16558
|
+
const integrationId = spec.meta.integrationId ?? await resolveParentIntegrationId(parent.id);
|
|
16546
16559
|
await callDeviceManager(api, "applyInitialMeta", {
|
|
16547
16560
|
deviceId: id,
|
|
16548
|
-
linkDeviceId
|
|
16561
|
+
linkDeviceId,
|
|
16549
16562
|
...isFirstSpawn && spec.meta.name !== void 0 ? { name: spec.meta.name } : {},
|
|
16550
16563
|
...isFirstSpawn && spec.meta.location !== void 0 ? { location: spec.meta.location } : {},
|
|
16551
16564
|
...spec.meta.type !== void 0 ? { type: spec.meta.type } : {},
|
|
16552
|
-
...
|
|
16565
|
+
...integrationId !== void 0 ? { integrationId } : {},
|
|
16553
16566
|
...spec.meta.role !== void 0 ? { role: spec.meta.role } : {}
|
|
16554
16567
|
}).catch((err) => {
|
|
16555
16568
|
opts.logger.warn("spawnAccessoryChild: applyInitialMeta pre-seed failed", {
|
|
@@ -16810,7 +16823,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
16810
16823
|
},
|
|
16811
16824
|
register: async (device) => {
|
|
16812
16825
|
registry.register(addonId, device);
|
|
16813
|
-
buildContext(device.stableId, device.id, device.parentDeviceId).registerNativeCap(deviceOpsCapability, buildDeviceOpsProvider(device));
|
|
16826
|
+
buildContext(device.stableId, device.id, device.parentDeviceId).registerNativeCap(deviceOpsCapability, buildDeviceOpsProvider(device, (id) => teardownLocal(id, false)));
|
|
16814
16827
|
try {
|
|
16815
16828
|
await callDeviceManager(api, "registerDevice", {
|
|
16816
16829
|
addonId,
|
|
@@ -22576,7 +22589,7 @@ async function probeVaapiInit(renderNode) {
|
|
|
22576
22589
|
*/
|
|
22577
22590
|
function safeExistsSync(path) {
|
|
22578
22591
|
try {
|
|
22579
|
-
return fs
|
|
22592
|
+
return fs.existsSync(path);
|
|
22580
22593
|
} catch {
|
|
22581
22594
|
return false;
|
|
22582
22595
|
}
|
|
@@ -22595,11 +22608,11 @@ function probeLinuxGpus() {
|
|
|
22595
22608
|
if (safeExistsSync("/dev/nvidia0") || safeExistsSync("/proc/driver/nvidia/version")) signals.hasNvidiaGpu = true;
|
|
22596
22609
|
try {
|
|
22597
22610
|
const drmDir = "/sys/class/drm";
|
|
22598
|
-
if (fs
|
|
22611
|
+
if (fs.existsSync(drmDir)) for (const entry of fs.readdirSync(drmDir)) {
|
|
22599
22612
|
if (!entry.startsWith("card")) continue;
|
|
22600
22613
|
const vendorPath = `${drmDir}/${entry}/device/vendor`;
|
|
22601
22614
|
if (!safeExistsSync(vendorPath)) continue;
|
|
22602
|
-
const vendor = fs
|
|
22615
|
+
const vendor = fs.readFileSync(vendorPath, "utf8").trim().toLowerCase();
|
|
22603
22616
|
if (vendor === "0x10de") signals.hasNvidiaGpu = true;
|
|
22604
22617
|
else if (vendor === "0x1002") signals.hasAmdGpu = true;
|
|
22605
22618
|
else if (vendor === "0x8086") signals.hasIntelGpu = true;
|
|
@@ -22817,21 +22830,21 @@ function sleep$1(ms) {
|
|
|
22817
22830
|
* crashed holder) is stolen.
|
|
22818
22831
|
*/
|
|
22819
22832
|
async function withFileLock(lockPath, fn) {
|
|
22820
|
-
fs
|
|
22833
|
+
fs.mkdirSync(join(lockPath, ".."), { recursive: true });
|
|
22821
22834
|
for (;;) try {
|
|
22822
|
-
const fd = fs
|
|
22823
|
-
fs
|
|
22835
|
+
const fd = fs.openSync(lockPath, "wx");
|
|
22836
|
+
fs.closeSync(fd);
|
|
22824
22837
|
break;
|
|
22825
22838
|
} catch {
|
|
22826
22839
|
try {
|
|
22827
|
-
if (Date.now() - fs
|
|
22840
|
+
if (Date.now() - fs.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs.rmSync(lockPath, { force: true });
|
|
22828
22841
|
else await sleep$1(LOCK_POLL_MS);
|
|
22829
22842
|
} catch {}
|
|
22830
22843
|
}
|
|
22831
22844
|
try {
|
|
22832
22845
|
return await fn();
|
|
22833
22846
|
} finally {
|
|
22834
|
-
fs
|
|
22847
|
+
fs.rmSync(lockPath, { force: true });
|
|
22835
22848
|
}
|
|
22836
22849
|
}
|
|
22837
22850
|
/** Coalesce in-process + serialize cross-process for one binary id. */
|
|
@@ -22889,7 +22902,7 @@ var AddonDepsManager = class {
|
|
|
22889
22902
|
* failed or tampered download throws, and provisioning reports it.
|
|
22890
22903
|
*/
|
|
22891
22904
|
async stageNativeDepsDeclaredBy(requirementsFile) {
|
|
22892
|
-
if (!declaresEdgetpuDelegate(fs
|
|
22905
|
+
if (!declaresEdgetpuDelegate(fs.readFileSync(requirementsFile, "utf8"))) return;
|
|
22893
22906
|
await singleFlight(this.depsDir, "edgetpu-delegate", () => ensureEdgetpuDelegate(this.nodeRoot, this.logger));
|
|
22894
22907
|
}
|
|
22895
22908
|
getDepsDir() {
|
|
@@ -23920,7 +23933,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
23920
23933
|
const addonId = declaration.id;
|
|
23921
23934
|
const nodeDataDir = process.env["CAMSTACK_DATA"] ?? dataDir;
|
|
23922
23935
|
const addonDataDir = path$1.resolve(nodeDataDir, "addons-data", addonId);
|
|
23923
|
-
fs
|
|
23936
|
+
fs.mkdirSync(addonDataDir, { recursive: true });
|
|
23924
23937
|
if (runtime.mode === "broker") ensureBindingSubscription(runtime.broker);
|
|
23925
23938
|
const regs = getRegistries(nodeId);
|
|
23926
23939
|
const workerResolver = {
|
|
@@ -25726,7 +25739,7 @@ var FailedRunnerRetryLedger = class {
|
|
|
25726
25739
|
function readRunnerPackageVersions(addonDirs) {
|
|
25727
25740
|
const out = {};
|
|
25728
25741
|
for (const dir of addonDirs) try {
|
|
25729
|
-
const raw = JSON.parse(fs
|
|
25742
|
+
const raw = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
25730
25743
|
const version = typeof raw === "object" && raw !== null ? Reflect.get(raw, "version") : null;
|
|
25731
25744
|
out[dir] = typeof version === "string" && version.length > 0 ? version : null;
|
|
25732
25745
|
} catch {
|
|
@@ -25787,7 +25800,7 @@ function readAddonHeapDeclaration(spec) {
|
|
|
25787
25800
|
if (cached !== void 0) return cached;
|
|
25788
25801
|
let declaration = EMPTY_HEAP_DECLARATION;
|
|
25789
25802
|
for (const manifestPath of [path$1.join(spec.addonDir, "package.json"), path$1.join(path$1.dirname(spec.addonDir), "package.json")]) try {
|
|
25790
|
-
const raw = fs
|
|
25803
|
+
const raw = fs.readFileSync(manifestPath, "utf8");
|
|
25791
25804
|
const parsed = JSON.parse(raw);
|
|
25792
25805
|
const profile = extractHeapProfile(parsed, spec.addonId);
|
|
25793
25806
|
const maxOldSpaceMb = extractMaxOldSpaceMb(parsed, spec.addonId);
|
|
@@ -27009,17 +27022,17 @@ var JobJournal = class {
|
|
|
27009
27022
|
return path$1.join(this.jobsDir, `${id}.json`);
|
|
27010
27023
|
}
|
|
27011
27024
|
writeAtomic(filePath, data) {
|
|
27012
|
-
fs
|
|
27025
|
+
fs.mkdirSync(path$1.dirname(filePath), { recursive: true });
|
|
27013
27026
|
const tmp = `${filePath}.tmp.${process.pid}.${Date.now()}`;
|
|
27014
|
-
fs
|
|
27027
|
+
fs.writeFileSync(tmp, JSON.stringify(data, null, 2), {
|
|
27015
27028
|
encoding: "utf-8",
|
|
27016
27029
|
mode: 384
|
|
27017
27030
|
});
|
|
27018
|
-
fs
|
|
27031
|
+
fs.renameSync(tmp, filePath);
|
|
27019
27032
|
}
|
|
27020
27033
|
readIndex() {
|
|
27021
27034
|
try {
|
|
27022
|
-
const raw = JSON.parse(fs
|
|
27035
|
+
const raw = JSON.parse(fs.readFileSync(this.indexPath, "utf-8"));
|
|
27023
27036
|
if (raw && Array.isArray(raw.jobIds)) return {
|
|
27024
27037
|
version: 1,
|
|
27025
27038
|
jobIds: raw.jobIds
|
|
@@ -27044,7 +27057,7 @@ var JobJournal = class {
|
|
|
27044
27057
|
}
|
|
27045
27058
|
getJob(id) {
|
|
27046
27059
|
try {
|
|
27047
|
-
const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs
|
|
27060
|
+
const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs.readFileSync(this.jobPath(id), "utf-8")));
|
|
27048
27061
|
return parsed.success ? parsed.data : null;
|
|
27049
27062
|
} catch {
|
|
27050
27063
|
return null;
|
|
@@ -27109,14 +27122,14 @@ var StagingArea = class {
|
|
|
27109
27122
|
}
|
|
27110
27123
|
async fetchAndStage(input) {
|
|
27111
27124
|
const destDir = path$1.join(this.stagingDir, input.jobId, safeSegment(input.name));
|
|
27112
|
-
fs
|
|
27125
|
+
fs.rmSync(destDir, {
|
|
27113
27126
|
recursive: true,
|
|
27114
27127
|
force: true
|
|
27115
27128
|
});
|
|
27116
27129
|
const tgz = await this.deps.fetchTarball(input.name, input.version, input.signal);
|
|
27117
27130
|
if (input.signal.aborted) throw new Error("staging aborted after fetch");
|
|
27118
27131
|
await this.deps.extract(tgz, destDir);
|
|
27119
|
-
const raw = JSON.parse(fs
|
|
27132
|
+
const raw = JSON.parse(fs.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
|
|
27120
27133
|
if (typeof raw.version !== "string" || raw.version.length === 0) throw new Error(`staging validation failed: ${input.name} staged a package.json with no version`);
|
|
27121
27134
|
if (EXACT_SEMVER.test(input.version) && raw.version !== input.version) throw new Error(`staging validation failed: ${input.name} expected version ${input.version}, got ${raw.version}`);
|
|
27122
27135
|
return {
|
|
@@ -27125,7 +27138,7 @@ var StagingArea = class {
|
|
|
27125
27138
|
};
|
|
27126
27139
|
}
|
|
27127
27140
|
cleanup(jobId) {
|
|
27128
|
-
fs
|
|
27141
|
+
fs.rmSync(path$1.join(this.stagingDir, jobId), {
|
|
27129
27142
|
recursive: true,
|
|
27130
27143
|
force: true
|
|
27131
27144
|
});
|
|
@@ -27140,13 +27153,13 @@ var StagingArea = class {
|
|
|
27140
27153
|
sweepOrphans() {
|
|
27141
27154
|
let entries;
|
|
27142
27155
|
try {
|
|
27143
|
-
entries = fs
|
|
27156
|
+
entries = fs.readdirSync(this.stagingDir);
|
|
27144
27157
|
} catch {
|
|
27145
27158
|
return 0;
|
|
27146
27159
|
}
|
|
27147
27160
|
let removed = 0;
|
|
27148
27161
|
for (const name of entries) try {
|
|
27149
|
-
fs
|
|
27162
|
+
fs.rmSync(path$1.join(this.stagingDir, name), {
|
|
27150
27163
|
recursive: true,
|
|
27151
27164
|
force: true
|
|
27152
27165
|
});
|
|
@@ -27324,7 +27337,7 @@ var LifecycleJobEngine = class {
|
|
|
27324
27337
|
* on failure → `failed`.
|
|
27325
27338
|
*/
|
|
27326
27339
|
async reconcileJob(job) {
|
|
27327
|
-
const exists = this.deps.stagedPathExists ?? ((p) => fs
|
|
27340
|
+
const exists = this.deps.stagedPathExists ?? ((p) => fs.existsSync(p));
|
|
27328
27341
|
for (const task of job.tasks) {
|
|
27329
27342
|
if (task.target === "framework") {
|
|
27330
27343
|
if (!this.isTerminal(task.phase)) this.skipFrameworkTask(job, task);
|
|
@@ -27965,7 +27978,7 @@ var CatalogRegistry = class {
|
|
|
27965
27978
|
const file = path$1.join(packageDir, "i18n", `${lang}.json`);
|
|
27966
27979
|
let text;
|
|
27967
27980
|
try {
|
|
27968
|
-
text = fs
|
|
27981
|
+
text = fs.readFileSync(file, "utf8");
|
|
27969
27982
|
} catch {
|
|
27970
27983
|
continue;
|
|
27971
27984
|
}
|