@camstack/system 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19,7 +19,8 @@ const require_builtins_local_auth_local_auth_addon = require("./builtins/local-a
19
19
  require("./builtins/local-auth/index.js");
20
20
  const require_builtins_device_manager_device_manager_addon = require("./builtins/device-manager/device-manager.addon.js");
21
21
  require("./builtins/device-manager/index.js");
22
- const require_manifest_python_deps = require("./manifest-python-deps-D1DbAQEv.js");
22
+ const require_manifest_python_deps = require("./manifest-python-deps-B4BmMoGT.js");
23
+ const require_graceful_fs$1 = require("./graceful-fs-lg19SZNz.js");
23
24
  let _camstack_types_node = require("@camstack/types/node");
24
25
  let node_http = require("node:http");
25
26
  let node_fs = require("node:fs");
@@ -29,7 +30,6 @@ let node_path = require("node:path");
29
30
  node_path = require_chunk.__toESM(node_path, 1);
30
31
  let _camstack_types = require("@camstack/types");
31
32
  let node_crypto = require("node:crypto");
32
- node_crypto = require_chunk.__toESM(node_crypto);
33
33
  let node_child_process = require("node:child_process");
34
34
  let node_util = require("node:util");
35
35
  node_util = require_chunk.__toESM(node_util);
@@ -841,7 +841,7 @@ var ModelDownloadService = class {
841
841
  };
842
842
  //#endregion
843
843
  //#region src/python/python-env-manager.ts
844
- var execFileAsync$3 = (0, node_util.promisify)(node_child_process.execFile);
844
+ var execFileAsync$2 = (0, node_util.promisify)(node_child_process.execFile);
845
845
  var PythonEnvManager = class {
846
846
  venvPath;
847
847
  cachedProbe = null;
@@ -851,12 +851,12 @@ var PythonEnvManager = class {
851
851
  async probe() {
852
852
  if (this.cachedProbe) return this.cachedProbe;
853
853
  for (const cmd of ["python3", "python"]) try {
854
- const { stdout } = await execFileAsync$3(cmd, ["--version"]);
854
+ const { stdout } = await execFileAsync$2(cmd, ["--version"]);
855
855
  const version = stdout.trim().replace("Python ", "");
856
856
  const major = parseInt(version.split(".")[0] ?? "0", 10);
857
857
  const minor = parseInt(version.split(".")[1] ?? "0", 10);
858
858
  if (major < 3 || major === 3 && minor < 10) continue;
859
- const { stdout: pathOut } = await execFileAsync$3(cmd, ["-c", "import sys; print(sys.executable)"]);
859
+ const { stdout: pathOut } = await execFileAsync$2(cmd, ["-c", "import sys; print(sys.executable)"]);
860
860
  this.cachedProbe = {
861
861
  available: true,
862
862
  version,
@@ -872,13 +872,13 @@ var PythonEnvManager = class {
872
872
  async ensure(options) {
873
873
  const probe = await this.probe();
874
874
  if (!probe.available || !probe.path) throw new Error("Python 3.10+ is required but not found on this system");
875
- if (!node_fs.existsSync(node_path.join(this.venvPath, "bin", "python"))) await execFileAsync$3(probe.path, [
875
+ if (!node_fs.existsSync(node_path.join(this.venvPath, "bin", "python"))) await execFileAsync$2(probe.path, [
876
876
  "-m",
877
877
  "venv",
878
878
  this.venvPath
879
879
  ]);
880
880
  const venvPython = node_path.join(this.venvPath, "bin", "python");
881
- if (options.packages.length > 0) await execFileAsync$3(venvPython, [
881
+ if (options.packages.length > 0) await execFileAsync$2(venvPython, [
882
882
  "-m",
883
883
  "pip",
884
884
  "install",
@@ -2358,7 +2358,7 @@ function matchPath(pattern, path) {
2358
2358
  }
2359
2359
  //#endregion
2360
2360
  //#region src/tls/cert-manager.ts
2361
- var execFileAsync$2 = (0, node_util.promisify)(node_child_process.execFile);
2361
+ var execFileAsync$1 = (0, node_util.promisify)(node_child_process.execFile);
2362
2362
  /**
2363
2363
  * Ensure a self-signed TLS certificate exists in the given directory.
2364
2364
  * Generates one if missing. Returns paths to cert and key files.
@@ -2395,7 +2395,7 @@ async function ensureTlsCert(dataDir, options) {
2395
2395
  for (const dns of sanDns) sanParts.push(`DNS:${dns}`);
2396
2396
  for (const ip of sanIps) sanParts.push(`IP:${ip}`);
2397
2397
  const sanString = sanParts.join(",");
2398
- await execFileAsync$2("openssl", [
2398
+ await execFileAsync$1("openssl", [
2399
2399
  "req",
2400
2400
  "-x509",
2401
2401
  "-newkey",
@@ -3473,6 +3473,66 @@ var AddonManifest = class {
3473
3473
  this.cache = null;
3474
3474
  }
3475
3475
  /**
3476
+ * Reconcile the manifest with what is actually present on disk.
3477
+ *
3478
+ * For every `@scope/<pkg>` directory under `addonsDir` that has a
3479
+ * readable `package.json` but NO manifest entry yet, add one with
3480
+ * source `'seed'`. Existing entries are left untouched (their source,
3481
+ * version and timestamps are authoritative — a later install/update
3482
+ * overwrites them through `upsert`).
3483
+ *
3484
+ * Why this exists: addons baked into the Docker/Electron image are
3485
+ * copied straight into `addonsDir` by the container entrypoint (the
3486
+ * launcher's `ensureRequiredPackages` then sees `package.json` already
3487
+ * present and skips, never calling `upsert`). Without this reconcile
3488
+ * those seeded addons stay absent from the manifest, so `applyUpdate`
3489
+ * rejects them with "not currently tracked in manifest" — which is
3490
+ * exactly what broke "Update all" on a fresh image. Idempotent and
3491
+ * safe to run on every boot.
3492
+ *
3493
+ * Returns the number of entries added.
3494
+ */
3495
+ reconcileFromDisk(addonsDir) {
3496
+ if (!node_fs.existsSync(addonsDir)) return 0;
3497
+ const m = this.read();
3498
+ let added = 0;
3499
+ const now = (/* @__PURE__ */ new Date()).toISOString();
3500
+ for (const scope of node_fs.readdirSync(addonsDir, { withFileTypes: true })) {
3501
+ if (!scope.isDirectory() || !scope.name.startsWith("@")) continue;
3502
+ const scopeDir = node_path.join(addonsDir, scope.name);
3503
+ for (const pkg of node_fs.readdirSync(scopeDir, { withFileTypes: true })) {
3504
+ if (!pkg.isDirectory()) continue;
3505
+ const pkgJsonPath = node_path.join(scopeDir, pkg.name, "package.json");
3506
+ if (!node_fs.existsSync(pkgJsonPath)) continue;
3507
+ let pkgJson;
3508
+ try {
3509
+ const parsed = JSON.parse(node_fs.readFileSync(pkgJsonPath, "utf-8"));
3510
+ if (typeof parsed !== "object" || parsed == null) continue;
3511
+ pkgJson = parsed;
3512
+ } catch {
3513
+ continue;
3514
+ }
3515
+ if (!pkgJson.name || !pkgJson.version) continue;
3516
+ const addons = pkgJson.camstack?.addons;
3517
+ if (!Array.isArray(addons) || addons.length === 0) continue;
3518
+ if (m.addons[pkgJson.name] != null) continue;
3519
+ m.addons[pkgJson.name] = {
3520
+ name: pkgJson.name,
3521
+ version: pkgJson.version,
3522
+ source: "seed",
3523
+ installedAt: now,
3524
+ updatedAt: now
3525
+ };
3526
+ added++;
3527
+ }
3528
+ }
3529
+ if (added > 0) {
3530
+ m.updatedAt = now;
3531
+ this.write(m);
3532
+ }
3533
+ return added;
3534
+ }
3535
+ /**
3476
3536
  * Migration helper: if the manifest is empty but the addons directory
3477
3537
  * has packages with `.install-source` markers (the legacy per-addon
3478
3538
  * tracking), seed the manifest from those markers. Runs once at boot.
@@ -3528,175 +3588,6 @@ var AddonManifest = class {
3528
3588
  }
3529
3589
  };
3530
3590
  //#endregion
3531
- //#region src/kernel/deps/manifest-native-deps.ts
3532
- var execFileAsync$1 = (0, node_util.promisify)(node_child_process.execFile);
3533
- /**
3534
- * Native node modules an addon needs at runtime but cannot be bundled
3535
- * (`.node` binary files require ABI-matched compilation). Mirror of the
3536
- * Python `requirements.txt` pattern in `manifest-python-deps.ts` —
3537
- * declared in the addon's `package.json` under `camstack.nativeDependencies`,
3538
- * installed per-addon at install time so the host's regular `npm install`
3539
- * doesn't pull in the union of every camera driver's native deps.
3540
- *
3541
- * Phase E of the bundles + builder modernization spec
3542
- * (`docs/superpowers/specs/2026-05-09-bundles-and-builder-modernization-design.md`).
3543
- *
3544
- * Idempotent: hashes the `nativeDependencies` map and writes a marker
3545
- * to `<addonDir>/.camstack-native-deps-installed`. Re-installing only
3546
- * happens when the declared set changes.
3547
- *
3548
- * Failure modes:
3549
- * - manifest doesn't declare `nativeDependencies` (or declares empty) → no-op
3550
- * - `npm install` fails → throws (caller decides whether to abort install)
3551
- * - rebuild step fails → logs warning + continues (install may still
3552
- * work if prebuilt binaries shipped in the package cover the host
3553
- * ABI; surface a clear error at first `import` of the native module
3554
- * otherwise).
3555
- */
3556
- async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry) {
3557
- const native = readNativeDeps(pkgRaw);
3558
- if (native == null || Object.keys(native).length === 0) return;
3559
- const markerFile = node_path.join(addonDir, ".camstack-native-deps-installed");
3560
- const markerHash = hashDeclaration(native);
3561
- if (markerMatches(markerFile, markerHash)) {
3562
- logger.debug("Native deps already installed (marker matches)", { meta: {
3563
- addonDir,
3564
- count: Object.keys(native).length
3565
- } });
3566
- return;
3567
- }
3568
- const specs = Object.entries(native).map(([name, range]) => `${name}@${range}`);
3569
- logger.info("Installing native dependencies", { meta: {
3570
- addonDir,
3571
- specs
3572
- } });
3573
- const args = [
3574
- "install",
3575
- "--no-save",
3576
- "--no-package-lock",
3577
- "--no-audit",
3578
- "--no-fund",
3579
- "--omit=dev",
3580
- "--omit=peer",
3581
- ...registry ? ["--registry", registry] : [],
3582
- ...specs
3583
- ];
3584
- try {
3585
- await execFileAsync$1("npm", args, {
3586
- cwd: addonDir,
3587
- timeout: 3e5
3588
- });
3589
- } catch (err) {
3590
- throw new Error(`npm install of native deps failed for ${addonDir}: ${(0, _camstack_types.errMsg)(err)}`, { cause: err });
3591
- }
3592
- await rebuildNativeDeps(addonDir, Object.keys(native), logger);
3593
- try {
3594
- node_fs.writeFileSync(markerFile, markerHash);
3595
- } catch (err) {
3596
- logger.warn("Failed to write native deps marker", { meta: {
3597
- markerFile,
3598
- error: (0, _camstack_types.errMsg)(err)
3599
- } });
3600
- }
3601
- }
3602
- /** Read & validate `camstack.nativeDependencies`. Returns null when absent. */
3603
- function readNativeDeps(pkgRaw) {
3604
- const camstack = (0, _camstack_types.asJsonObject)(pkgRaw["camstack"]);
3605
- if (!camstack) return null;
3606
- const native = (0, _camstack_types.asJsonObject)(camstack["nativeDependencies"]);
3607
- if (!native) return null;
3608
- const out = {};
3609
- for (const [k, v] of Object.entries(native)) {
3610
- const range = (0, _camstack_types.asString)(v);
3611
- if (range) out[k] = range;
3612
- }
3613
- return Object.keys(out).length > 0 ? out : null;
3614
- }
3615
- /** SHA-256 of the canonical-keyed declaration — drives marker idempotency. */
3616
- function hashDeclaration(deps) {
3617
- const canonical = Object.keys(deps).toSorted().map((k) => `${k}@${deps[k]}`).join("\n");
3618
- return node_crypto.createHash("sha256").update(canonical).digest("hex");
3619
- }
3620
- function markerMatches(markerFile, expected) {
3621
- try {
3622
- return node_fs.readFileSync(markerFile, "utf-8").trim() === expected;
3623
- } catch {
3624
- return false;
3625
- }
3626
- }
3627
- /**
3628
- * Rebuild native modules against the host's runtime ABI.
3629
- *
3630
- * Detection: `process.versions.electron` is set when running inside
3631
- * Electron's main/renderer process (set even when `ELECTRON_RUN_AS_NODE`
3632
- * isn't), giving us a reliable signal. Plain Node leaves it undefined.
3633
- *
3634
- * Electron path: tries `@electron/rebuild` programmatically, falling
3635
- * back to `npx electron-rebuild` if the package isn't directly available.
3636
- * Node path: `npm rebuild --prefix <addonDir>` re-runs the install
3637
- * scripts of every package under that directory.
3638
- *
3639
- * Failures here are non-fatal: many native packages ship prebuilt
3640
- * binaries that cover both ABIs, so the rebuild may be unnecessary.
3641
- * The first `import` of an actually-mismatched binary throws a clear
3642
- * error that points the operator at this rebuild step.
3643
- */
3644
- async function rebuildNativeDeps(addonDir, packageNames, logger) {
3645
- if (typeof process.versions.electron === "string") {
3646
- const electronVersion = process.versions.electron;
3647
- logger.info("Rebuilding native deps for Electron", { meta: {
3648
- addonDir,
3649
- electronVersion,
3650
- packages: packageNames
3651
- } });
3652
- try {
3653
- const rebuildModule = await Promise.resolve().then(() => /* @__PURE__ */ require_chunk.__toESM(require("./main-DNnMW7Z2.js").default)).catch(() => null);
3654
- if (rebuildModule?.rebuild) {
3655
- await rebuildModule.rebuild({
3656
- buildPath: addonDir,
3657
- electronVersion,
3658
- onlyModules: packageNames
3659
- });
3660
- return;
3661
- }
3662
- logger.warn("@electron/rebuild not available — falling back to npx", { meta: { addonDir } });
3663
- await execFileAsync$1("npx", [
3664
- "--yes",
3665
- "electron-rebuild",
3666
- "-m",
3667
- addonDir,
3668
- "-v",
3669
- electronVersion
3670
- ], {
3671
- cwd: addonDir,
3672
- timeout: 6e5
3673
- });
3674
- } catch (err) {
3675
- logger.warn("Electron rebuild failed (continuing — prebuilt binary may be present)", { meta: {
3676
- addonDir,
3677
- error: (0, _camstack_types.errMsg)(err)
3678
- } });
3679
- }
3680
- return;
3681
- }
3682
- logger.info("Rebuilding native deps for Node", { meta: {
3683
- addonDir,
3684
- nodeAbi: process.versions.modules,
3685
- packages: packageNames
3686
- } });
3687
- try {
3688
- await execFileAsync$1("npm", ["rebuild", ...packageNames], {
3689
- cwd: addonDir,
3690
- timeout: 6e5
3691
- });
3692
- } catch (err) {
3693
- logger.warn("npm rebuild failed (continuing — prebuilt binary may be present)", { meta: {
3694
- addonDir,
3695
- error: (0, _camstack_types.errMsg)(err)
3696
- } });
3697
- }
3698
- }
3699
- //#endregion
3700
3591
  //#region src/kernel/addon-installer.ts
3701
3592
  var execFileAsync = (0, node_util.promisify)(node_child_process.execFile);
3702
3593
  function parseInstallSource(value) {
@@ -3846,6 +3737,21 @@ var AddonInstaller = class AddonInstaller {
3846
3737
  }
3847
3738
  }
3848
3739
  /**
3740
+ * Reconcile the install manifest with the addons actually present on
3741
+ * disk. Seeded addons (baked into the image and copied verbatim by the
3742
+ * container entrypoint) never pass through an `install*` codepath, so
3743
+ * they are missing from `manifest.json` and `applyUpdate` would reject
3744
+ * them with "not currently tracked in manifest". Call this once after
3745
+ * `ensureRequiredPackages` so every on-disk addon is updatable.
3746
+ *
3747
+ * Returns the number of manifest entries added.
3748
+ */
3749
+ reconcileManifest() {
3750
+ const added = this.manifest.reconcileFromDisk(this.addonsDir);
3751
+ if (added > 0) this.logger.info(`Manifest reconciled — ${added} seeded addon(s) registered`);
3752
+ return added;
3753
+ }
3754
+ /**
3849
3755
  * Install a single addon — on-demand installer used by AddonPackageService
3850
3756
  * (admin UI "Install addon" / "Reinstall" buttons).
3851
3757
  *
@@ -3944,7 +3850,7 @@ var AddonInstaller = class AddonInstaller {
3944
3850
  });
3945
3851
  } catch {}
3946
3852
  try {
3947
- await installManifestNativeDeps(targetDir, pkgData, this.logger, this.registry);
3853
+ await require_manifest_python_deps.installManifestNativeDeps(targetDir, pkgData, this.logger, this.registry);
3948
3854
  } catch (err) {
3949
3855
  this.logger.warn(`${packageName} — native deps install failed (continuing)`, { meta: { error: (0, _camstack_types.errMsg)(err) } });
3950
3856
  }
@@ -4078,7 +3984,7 @@ var AddonInstaller = class AddonInstaller {
4078
3984
  }
4079
3985
  }
4080
3986
  try {
4081
- await installManifestNativeDeps(targetDir, pkgView.raw, this.logger, this.registry);
3987
+ await require_manifest_python_deps.installManifestNativeDeps(targetDir, pkgView.raw, this.logger, this.registry);
4082
3988
  } catch (nativeErr) {
4083
3989
  node_fs.rmSync(targetDir, {
4084
3990
  recursive: true,
@@ -4172,6 +4078,76 @@ var AddonInstaller = class AddonInstaller {
4172
4078
  };
4173
4079
  }
4174
4080
  /**
4081
+ * Apply an update from a pre-validated staged directory — the fast
4082
+ * swap-from-staged path that skips npm entirely.
4083
+ *
4084
+ * Mirrors `applyUpdate` exactly for backup/restore/manifest, but
4085
+ * replaces step 2 ("install new version") with an atomic directory
4086
+ * move of `stagedPath` into `addonDir`.
4087
+ *
4088
+ * On cross-device move (EXDEV) falls back to a recursive copy followed
4089
+ * by removal of the staged directory. On any swap failure the backup is
4090
+ * restored and the error is rethrown — identical recovery to `applyUpdate`.
4091
+ *
4092
+ * Throws if the package is not tracked in the manifest or if `addonDir`
4093
+ * is missing (same preconditions as `applyUpdate`).
4094
+ */
4095
+ async applyUpdateFromStaged(packageName, version, stagedPath) {
4096
+ const current = this.manifest.get(packageName);
4097
+ if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
4098
+ const addonDir = node_path.join(this.addonsDir, packageName);
4099
+ if (!node_fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
4100
+ const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
4101
+ const backupRoot = node_path.join(this.addonsDir, ".backups", packageName);
4102
+ ensureDir(backupRoot);
4103
+ const backupDir = node_path.join(backupRoot, ts);
4104
+ this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
4105
+ node_fs.renameSync(addonDir, backupDir);
4106
+ try {
4107
+ try {
4108
+ node_fs.renameSync(stagedPath, addonDir);
4109
+ } catch (renameErr) {
4110
+ if (renameErr.code === "EXDEV") {
4111
+ node_fs.cpSync(stagedPath, addonDir, { recursive: true });
4112
+ node_fs.rmSync(stagedPath, {
4113
+ recursive: true,
4114
+ force: true
4115
+ });
4116
+ } else throw renameErr;
4117
+ }
4118
+ } catch (swapErr) {
4119
+ this.logger.error(`${packageName} — staged swap failed, restoring backup`, { meta: { error: (0, _camstack_types.errMsg)(swapErr) } });
4120
+ try {
4121
+ if (node_fs.existsSync(addonDir)) node_fs.rmSync(addonDir, {
4122
+ recursive: true,
4123
+ force: true
4124
+ });
4125
+ node_fs.renameSync(backupDir, addonDir);
4126
+ this.manifest.upsert(packageName, {
4127
+ version: current.version,
4128
+ source: current.source,
4129
+ lastBackupDir: void 0
4130
+ });
4131
+ } catch (restoreErr) {
4132
+ this.logger.error(`${packageName} — backup restore ALSO failed; manual recovery needed`, { meta: {
4133
+ backupDir,
4134
+ error: (0, _camstack_types.errMsg)(restoreErr)
4135
+ } });
4136
+ }
4137
+ throw swapErr;
4138
+ }
4139
+ this.manifest.upsert(packageName, {
4140
+ version,
4141
+ source: this.manifest.get(packageName)?.source ?? "npm",
4142
+ lastBackupDir: backupDir
4143
+ });
4144
+ return {
4145
+ name: packageName,
4146
+ version,
4147
+ backupDir
4148
+ };
4149
+ }
4150
+ /**
4175
4151
  * Roll back an addon to its most recent backup. Used after an update
4176
4152
  * passes installation but fails its post-restart health check.
4177
4153
  *
@@ -4367,12 +4343,12 @@ function detectWorkspacePackagesDir(startDir) {
4367
4343
  //#endregion
4368
4344
  //#region ../../node_modules/electron/index.js
4369
4345
  var require_electron = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
4370
- var fs$19 = require("fs");
4346
+ var fs$18 = require("fs");
4371
4347
  var path$40 = require("path");
4372
4348
  var pathFile = path$40.join(__dirname, "path.txt");
4373
4349
  function getElectronPath() {
4374
4350
  let executablePath;
4375
- if (fs$19.existsSync(pathFile)) executablePath = fs$19.readFileSync(pathFile, "utf-8");
4351
+ if (fs$18.existsSync(pathFile)) executablePath = fs$18.readFileSync(pathFile, "utf-8");
4376
4352
  if (process.env.ELECTRON_OVERRIDE_DIST_PATH) return path$40.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || "electron");
4377
4353
  if (executablePath) return path$40.join(__dirname, "dist", executablePath);
4378
4354
  else throw new Error("Electron failed to install correctly, please delete node_modules/electron and try installing again");
@@ -5604,7 +5580,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
5604
5580
  value: mod,
5605
5581
  enumerable: true
5606
5582
  }) : target, mod));
5607
- var require_common$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5583
+ var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5608
5584
  function isNothing(subject) {
5609
5585
  return typeof subject === "undefined" || subject === null;
5610
5586
  }
@@ -5668,7 +5644,7 @@ var require_exception = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5668
5644
  module.exports = YAMLException;
5669
5645
  }));
5670
5646
  var require_snippet = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5671
- var common = require_common$2();
5647
+ var common = require_common$1();
5672
5648
  function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
5673
5649
  let head = "";
5674
5650
  let tail = "";
@@ -5948,7 +5924,7 @@ var require_bool = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5948
5924
  });
5949
5925
  }));
5950
5926
  var require_int = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5951
- var common = require_common$2();
5927
+ var common = require_common$1();
5952
5928
  var Type = require_type();
5953
5929
  function isHexCode(c) {
5954
5930
  return c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102;
@@ -6055,7 +6031,7 @@ var require_int = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6055
6031
  });
6056
6032
  }));
6057
6033
  var require_float = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6058
- var common = require_common$2();
6034
+ var common = require_common$1();
6059
6035
  var Type = require_type();
6060
6036
  var YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
6061
6037
  var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
@@ -6356,7 +6332,7 @@ var require_default$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6356
6332
  });
6357
6333
  }));
6358
6334
  var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6359
- var common = require_common$2();
6335
+ var common = require_common$1();
6360
6336
  var YAMLException = require_exception();
6361
6337
  var makeSnippet = require_snippet();
6362
6338
  var DEFAULT_SCHEMA = require_default$1();
@@ -7379,7 +7355,7 @@ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7379
7355
  module.exports.load = load;
7380
7356
  }));
7381
7357
  var require_dumper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7382
- var common = require_common$2();
7358
+ var common = require_common$1();
7383
7359
  var YAMLException = require_exception();
7384
7360
  var DEFAULT_SCHEMA = require_default$1();
7385
7361
  var _toString = Object.prototype.toString;
@@ -28517,9 +28493,9 @@ var require_kleur = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
28517
28493
  //#region ../../node_modules/moleculer/src/utils.js
28518
28494
  var require_utils$3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
28519
28495
  var kleur = require_kleur();
28520
- var os$19 = require("os");
28496
+ var os$18 = require("os");
28521
28497
  var path$39 = require("path");
28522
- var fs$18 = require("fs");
28498
+ var fs$17 = require("fs");
28523
28499
  var { TimeoutError } = require_errors$2();
28524
28500
  var lut = [];
28525
28501
  for (let i = 0; i < 256; i++) lut[i] = (i < 16 ? "0" : "") + i.toString(16);
@@ -28616,7 +28592,7 @@ var require_utils$3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
28616
28592
  * @returns
28617
28593
  */
28618
28594
  getNodeID() {
28619
- return os$19.hostname().toLowerCase() + "-" + process.pid;
28595
+ return os$18.hostname().toLowerCase() + "-" + process.pid;
28620
28596
  },
28621
28597
  /**
28622
28598
  * Get list of local IPs
@@ -28626,7 +28602,7 @@ var require_utils$3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
28626
28602
  getIpList() {
28627
28603
  const list = [];
28628
28604
  const ilist = [];
28629
- const interfaces = os$19.networkInterfaces();
28605
+ const interfaces = os$18.networkInterfaces();
28630
28606
  for (let iface in interfaces) for (let i in interfaces[iface]) {
28631
28607
  const f = interfaces[iface]?.[i];
28632
28608
  if (f.family === "IPv4") if (f.internal) {
@@ -28812,7 +28788,7 @@ var require_utils$3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
28812
28788
  makeDirs(p) {
28813
28789
  p.split(path$39.sep).reduce((prevPath, folder) => {
28814
28790
  const currentPath = path$39.join(prevPath, folder, path$39.sep);
28815
- if (!fs$18.existsSync(currentPath)) fs$18.mkdirSync(currentPath);
28791
+ if (!fs$17.existsSync(currentPath)) fs$17.mkdirSync(currentPath);
28816
28792
  return currentPath;
28817
28793
  }, "");
28818
28794
  },
@@ -30038,7 +30014,7 @@ var require_csv = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module)
30038
30014
  var { makeDirs } = require_utils$3();
30039
30015
  var _ = require_lodash();
30040
30016
  var path$38 = require("path");
30041
- var fs$17 = require("fs");
30017
+ var fs$16 = require("fs");
30042
30018
  var METRIC = require_constants$6();
30043
30019
  var MODE_METRIC = "metric";
30044
30020
  var MODE_LABEL = "label";
@@ -30197,8 +30173,8 @@ var require_csv = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module)
30197
30173
  */
30198
30174
  writeRow(filename, headers, fields) {
30199
30175
  try {
30200
- if (!fs$17.existsSync(filename)) fs$17.writeFileSync(filename, headers.join(this.opts.delimiter) + this.opts.rowDelimiter);
30201
- fs$17.appendFileSync(filename, fields.join(this.opts.delimiter) + this.opts.rowDelimiter);
30176
+ if (!fs$16.existsSync(filename)) fs$16.writeFileSync(filename, headers.join(this.opts.delimiter) + this.opts.rowDelimiter);
30177
+ fs$16.appendFileSync(filename, fields.join(this.opts.delimiter) + this.opts.rowDelimiter);
30202
30178
  } catch (err) {
30203
30179
  /* istanbul ignore next */
30204
30180
  this.logger.error(`Unable to write metrics values to the '${filename}' file. Error: ${err.message}`, fields, err);
@@ -30312,7 +30288,7 @@ var require_event$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
30312
30288
  var require_datadog$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
30313
30289
  var BaseReporter = require_base$8();
30314
30290
  var _ = require_lodash();
30315
- var os$18 = require("os");
30291
+ var os$17 = require("os");
30316
30292
  var { MoleculerError } = require_errors$2();
30317
30293
  var METRIC = require_constants$6();
30318
30294
  var { isFunction } = require_utils$3();
@@ -30345,7 +30321,7 @@ var require_datadog$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
30345
30321
  super(opts);
30346
30322
  /** @type {DatadogReporterOptions} */
30347
30323
  this.opts = _.defaultsDeep(this.opts, {
30348
- host: os$18.hostname(),
30324
+ host: os$17.hostname(),
30349
30325
  baseUrl: BASE_URL,
30350
30326
  apiVersion: "v1",
30351
30327
  path: "/series",
@@ -31021,18 +30997,18 @@ var require_cpu_usage$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
31021
30997
  *
31022
30998
  * Based on: https://github.com/icebob/cpu
31023
30999
  */
31024
- var os$17 = require("os");
31000
+ var os$16 = require("os");
31025
31001
  /* istanbul ignore next */
31026
31002
  module.exports = function getCpuUsage(sampleTime = 100) {
31027
31003
  return new Promise((resolve, reject) => {
31028
31004
  try {
31029
- const first = os$17.cpus().map((cpu) => cpu.times);
31005
+ const first = os$16.cpus().map((cpu) => cpu.times);
31030
31006
  setTimeout(() => {
31031
31007
  try {
31032
- const second = os$17.cpus().map((cpu) => cpu.times);
31008
+ const second = os$16.cpus().map((cpu) => cpu.times);
31033
31009
  setTimeout(() => {
31034
31010
  try {
31035
- const third = os$17.cpus().map((cpu) => cpu.times);
31011
+ const third = os$16.cpus().map((cpu) => cpu.times);
31036
31012
  const usages = [];
31037
31013
  for (let i = 0; i < first.length; i++) {
31038
31014
  const first_idle = first[i].idle;
@@ -31065,7 +31041,7 @@ var require_cpu_usage$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
31065
31041
  //#endregion
31066
31042
  //#region ../../node_modules/moleculer/src/metrics/commons.js
31067
31043
  var require_commons = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
31068
- var os$16 = require("os");
31044
+ var os$15 = require("os");
31069
31045
  var METRIC = require_constants$6();
31070
31046
  var cpuUsage = require_cpu_usage$1();
31071
31047
  var v8;
@@ -31244,27 +31220,27 @@ var require_commons = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
31244
31220
  name: METRIC.OS_TYPE,
31245
31221
  type: METRIC.TYPE_INFO,
31246
31222
  description: "OS type"
31247
- }).set(os$16.type());
31223
+ }).set(os$15.type());
31248
31224
  this.register({
31249
31225
  name: METRIC.OS_RELEASE,
31250
31226
  type: METRIC.TYPE_INFO,
31251
31227
  description: "OS release"
31252
- }).set(os$16.release());
31228
+ }).set(os$15.release());
31253
31229
  this.register({
31254
31230
  name: METRIC.OS_HOSTNAME,
31255
31231
  type: METRIC.TYPE_INFO,
31256
31232
  description: "Hostname"
31257
- }).set(os$16.hostname());
31233
+ }).set(os$15.hostname());
31258
31234
  this.register({
31259
31235
  name: METRIC.OS_ARCH,
31260
31236
  type: METRIC.TYPE_INFO,
31261
31237
  description: "OS architecture"
31262
- }).set(os$16.arch());
31238
+ }).set(os$15.arch());
31263
31239
  this.register({
31264
31240
  name: METRIC.OS_PLATFORM,
31265
31241
  type: METRIC.TYPE_INFO,
31266
31242
  description: "OS platform"
31267
- }).set(os$16.platform());
31243
+ }).set(os$15.platform());
31268
31244
  const userInfo = getUserInfo();
31269
31245
  this.register({
31270
31246
  name: METRIC.OS_USER_UID,
@@ -31415,22 +31391,22 @@ var require_commons = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
31415
31391
  }
31416
31392
  this.set(METRIC.PROCESS_UPTIME, process.uptime());
31417
31393
  this.set(METRIC.PROCESS_INTERNAL_ACTIVE_HANDLES, process.getActiveResourcesInfo().length);
31418
- const freeMem = os$16.freemem();
31419
- const totalMem = os$16.totalmem();
31394
+ const freeMem = os$15.freemem();
31395
+ const totalMem = os$15.totalmem();
31420
31396
  const usedMem = totalMem - freeMem;
31421
31397
  this.set(METRIC.OS_MEMORY_FREE, freeMem);
31422
31398
  this.set(METRIC.OS_MEMORY_USED, usedMem);
31423
31399
  this.set(METRIC.OS_MEMORY_TOTAL, totalMem);
31424
- this.set(METRIC.OS_UPTIME, os$16.uptime());
31425
- this.set(METRIC.OS_TYPE, os$16.type());
31426
- this.set(METRIC.OS_RELEASE, os$16.release());
31427
- this.set(METRIC.OS_HOSTNAME, os$16.hostname());
31428
- this.set(METRIC.OS_ARCH, os$16.arch());
31429
- this.set(METRIC.OS_PLATFORM, os$16.platform());
31400
+ this.set(METRIC.OS_UPTIME, os$15.uptime());
31401
+ this.set(METRIC.OS_TYPE, os$15.type());
31402
+ this.set(METRIC.OS_RELEASE, os$15.release());
31403
+ this.set(METRIC.OS_HOSTNAME, os$15.hostname());
31404
+ this.set(METRIC.OS_ARCH, os$15.arch());
31405
+ this.set(METRIC.OS_PLATFORM, os$15.platform());
31430
31406
  const getNetworkInterfaces = () => {
31431
31407
  const list = [];
31432
31408
  const ilist = [];
31433
- const interfaces = os$16.networkInterfaces();
31409
+ const interfaces = os$15.networkInterfaces();
31434
31410
  for (let iface in interfaces) for (let i in interfaces[iface]) {
31435
31411
  const f = interfaces[iface][i];
31436
31412
  if (f.internal) ilist.push({
@@ -31460,7 +31436,7 @@ var require_commons = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
31460
31436
  this.set(METRIC.OS_DATETIME_ISO, d.toISOString());
31461
31437
  this.set(METRIC.OS_DATETIME_UTC, d.toUTCString());
31462
31438
  this.set(METRIC.OS_DATETIME_TZ_OFFSET, d.getTimezoneOffset());
31463
- const load = os$16.loadavg();
31439
+ const load = os$15.loadavg();
31464
31440
  this.set(METRIC.OS_CPU_LOAD_1, load[0]);
31465
31441
  this.set(METRIC.OS_CPU_LOAD_5, load[1]);
31466
31442
  this.set(METRIC.OS_CPU_LOAD_15, load[2]);
@@ -31468,7 +31444,7 @@ var require_commons = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
31468
31444
  return this.broker.Promise.resolve().then(() => cpuUsage().then((res) => {
31469
31445
  this.set(METRIC.OS_CPU_UTILIZATION, res.avg);
31470
31446
  try {
31471
- const cpus = os$16.cpus();
31447
+ const cpus = os$15.cpus();
31472
31448
  this.set(METRIC.OS_CPU_TOTAL, cpus.length);
31473
31449
  this.set(METRIC.OS_CPU_USER, cpus.reduce((a, b) => a + b.times.user, 0));
31474
31450
  this.set(METRIC.OS_CPU_SYSTEM, cpus.reduce((a, b) => a + b.times.sys, 0));
@@ -31490,7 +31466,7 @@ var require_commons = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
31490
31466
  */
31491
31467
  function getUserInfo() {
31492
31468
  try {
31493
- return os$16.userInfo();
31469
+ return os$15.userInfo();
31494
31470
  } catch {
31495
31471
  /* istanbul ignore next */
31496
31472
  return {};
@@ -35189,10 +35165,10 @@ var require_inherits_browser = /* @__PURE__ */ require_chunk.__commonJSMin(((exp
35189
35165
  //#region ../../node_modules/inherits/inherits.js
35190
35166
  var require_inherits = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
35191
35167
  try {
35192
- var util$10 = require("util");
35168
+ var util$8 = require("util");
35193
35169
  /* istanbul ignore next */
35194
- if (typeof util$10.inherits !== "function") throw "";
35195
- module.exports = util$10.inherits;
35170
+ if (typeof util$8.inherits !== "function") throw "";
35171
+ module.exports = util$8.inherits;
35196
35172
  } catch (e) {
35197
35173
  /* istanbul ignore next */
35198
35174
  module.exports = require_inherits_browser();
@@ -35200,7 +35176,7 @@ var require_inherits = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
35200
35176
  }));
35201
35177
  //#endregion
35202
35178
  //#region ../../node_modules/util-deprecate/node.js
35203
- var require_node$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
35179
+ var require_node$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
35204
35180
  /**
35205
35181
  * For Node.js, simply re-export the core `util.deprecate` function.
35206
35182
  */
@@ -35220,7 +35196,7 @@ var require__stream_writable = /* @__PURE__ */ require_chunk.__commonJSMin(((exp
35220
35196
  }
35221
35197
  var Duplex;
35222
35198
  Writable.WritableState = WritableState;
35223
- var internalUtil = { deprecate: require_node$2() };
35199
+ var internalUtil = { deprecate: require_node$1() };
35224
35200
  var Stream = require_stream$1();
35225
35201
  var Buffer$13 = require("buffer").Buffer;
35226
35202
  var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {};
@@ -37101,14 +37077,14 @@ var require_pipeline$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
37101
37077
  //#endregion
37102
37078
  //#region ../../node_modules/msgpack5/node_modules/readable-stream/readable.js
37103
37079
  var require_readable$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
37104
- var Stream$3 = require("stream");
37105
- if (process.env.READABLE_STREAM === "disable" && Stream$3) {
37106
- module.exports = Stream$3.Readable;
37107
- Object.assign(module.exports, Stream$3);
37108
- module.exports.Stream = Stream$3;
37080
+ var Stream$2 = require("stream");
37081
+ if (process.env.READABLE_STREAM === "disable" && Stream$2) {
37082
+ module.exports = Stream$2.Readable;
37083
+ Object.assign(module.exports, Stream$2);
37084
+ module.exports.Stream = Stream$2;
37109
37085
  } else {
37110
37086
  exports = module.exports = require__stream_readable();
37111
- exports.Stream = Stream$3 || exports;
37087
+ exports.Stream = Stream$2 || exports;
37112
37088
  exports.Readable = exports;
37113
37089
  exports.Writable = require__stream_writable();
37114
37090
  exports.Duplex = require__stream_duplex();
@@ -37454,7 +37430,7 @@ var require_streams = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
37454
37430
  //#endregion
37455
37431
  //#region ../../node_modules/msgpack5/lib/helpers.js
37456
37432
  var require_helpers$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
37457
- var util$9 = require("util");
37433
+ var util$7 = require("util");
37458
37434
  exports.IncompleteBufferError = IncompleteBufferError;
37459
37435
  function IncompleteBufferError(message) {
37460
37436
  Error.call(this);
@@ -37462,7 +37438,7 @@ var require_helpers$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =
37462
37438
  this.name = this.constructor.name;
37463
37439
  this.message = message || "unable to decode";
37464
37440
  }
37465
- util$9.inherits(IncompleteBufferError, Error);
37441
+ util$7.inherits(IncompleteBufferError, Error);
37466
37442
  exports.isFloat = function isFloat(n) {
37467
37443
  return n % 1 !== 0;
37468
37444
  };
@@ -39000,7 +38976,7 @@ var require_discoverers = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
39000
38976
  }));
39001
38977
  //#endregion
39002
38978
  //#region ../../node_modules/moleculer/src/registry/node.js
39003
- var require_node$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
38979
+ var require_node = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
39004
38980
  /**
39005
38981
  * Import types
39006
38982
  *
@@ -39115,8 +39091,8 @@ var require_node$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
39115
39091
  //#region ../../node_modules/moleculer/src/registry/node-catalog.js
39116
39092
  var require_node_catalog = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
39117
39093
  var _ = require_lodash();
39118
- var os$15 = require("os");
39119
- var Node = require_node$1();
39094
+ var os$14 = require("os");
39095
+ var Node = require_node();
39120
39096
  var { getIpList } = require_utils$3();
39121
39097
  /**
39122
39098
  * Import types
@@ -39161,7 +39137,7 @@ var require_node_catalog = /* @__PURE__ */ require_chunk.__commonJSMin(((exports
39161
39137
  node.local = true;
39162
39138
  node.ipList = getIpList();
39163
39139
  node.instanceID = this.broker.instanceID;
39164
- node.hostname = os$15.hostname();
39140
+ node.hostname = os$14.hostname();
39165
39141
  node.client = {
39166
39142
  type: "nodejs",
39167
39143
  version: this.broker.MOLECULER_VERSION,
@@ -40919,7 +40895,7 @@ var require_formatted = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
40919
40895
  var BaseLogger = require_base$4();
40920
40896
  var _ = require_lodash();
40921
40897
  var kleur = require_kleur();
40922
- var util$8 = require("util");
40898
+ var util$6 = require("util");
40923
40899
  var { isObject, isFunction } = require_utils$3();
40924
40900
  /**
40925
40901
  * Import types
@@ -40967,7 +40943,7 @@ var require_formatted = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
40967
40943
  init(loggerFactory) {
40968
40944
  super.init(loggerFactory);
40969
40945
  if (!this.opts.colors) kleur.enabled = false;
40970
- this.objectPrinter = this.opts.objectPrinter ? this.opts.objectPrinter : (o) => util$8.inspect(o, {
40946
+ this.objectPrinter = this.opts.objectPrinter ? this.opts.objectPrinter : (o) => util$6.inspect(o, {
40971
40947
  showHidden: false,
40972
40948
  depth: 2,
40973
40949
  colors: kleur.enabled,
@@ -41235,9 +41211,9 @@ var require_console$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
41235
41211
  var require_datadog$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
41236
41212
  var BaseLogger = require_base$4();
41237
41213
  var _ = require_lodash();
41238
- var os$14 = require("os");
41214
+ var os$13 = require("os");
41239
41215
  var { MoleculerError } = require_errors$2();
41240
- var util$7 = require("util");
41216
+ var util$5 = require("util");
41241
41217
  var { isObject } = require_utils$3();
41242
41218
  /**
41243
41219
  * Import types
@@ -41268,7 +41244,7 @@ var require_datadog$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
41268
41244
  apiKey: process.env.DATADOG_API_KEY,
41269
41245
  ddSource: "moleculer",
41270
41246
  env: void 0,
41271
- hostname: os$14.hostname(),
41247
+ hostname: os$13.hostname(),
41272
41248
  objectPrinter: null,
41273
41249
  interval: 10 * 1e3
41274
41250
  });
@@ -41283,7 +41259,7 @@ var require_datadog$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
41283
41259
  */
41284
41260
  init(loggerFactory) {
41285
41261
  super.init(loggerFactory);
41286
- this.objectPrinter = this.opts.objectPrinter ? this.opts.objectPrinter : (o) => util$7.inspect(o, {
41262
+ this.objectPrinter = this.opts.objectPrinter ? this.opts.objectPrinter : (o) => util$5.inspect(o, {
41287
41263
  showHidden: false,
41288
41264
  depth: 2,
41289
41265
  colors: false,
@@ -41392,712 +41368,6 @@ var require_datadog$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
41392
41368
  module.exports = DatadogLogger;
41393
41369
  }));
41394
41370
  //#endregion
41395
- //#region ../../node_modules/debug/src/common.js
41396
- var require_common$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
41397
- /**
41398
- * This is the common logic for both the Node.js and web browser
41399
- * implementations of `debug()`.
41400
- */
41401
- function setup(env) {
41402
- createDebug.debug = createDebug;
41403
- createDebug.default = createDebug;
41404
- createDebug.coerce = coerce;
41405
- createDebug.disable = disable;
41406
- createDebug.enable = enable;
41407
- createDebug.enabled = enabled;
41408
- createDebug.humanize = require_builtins_local_auth_local_auth_addon.require_ms();
41409
- createDebug.destroy = destroy;
41410
- Object.keys(env).forEach((key) => {
41411
- createDebug[key] = env[key];
41412
- });
41413
- /**
41414
- * The currently active debug mode names, and names to skip.
41415
- */
41416
- createDebug.names = [];
41417
- createDebug.skips = [];
41418
- /**
41419
- * Map of special "%n" handling functions, for the debug "format" argument.
41420
- *
41421
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
41422
- */
41423
- createDebug.formatters = {};
41424
- /**
41425
- * Selects a color for a debug namespace
41426
- * @param {String} namespace The namespace string for the debug instance to be colored
41427
- * @return {Number|String} An ANSI color code for the given namespace
41428
- * @api private
41429
- */
41430
- function selectColor(namespace) {
41431
- let hash = 0;
41432
- for (let i = 0; i < namespace.length; i++) {
41433
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
41434
- hash |= 0;
41435
- }
41436
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
41437
- }
41438
- createDebug.selectColor = selectColor;
41439
- /**
41440
- * Create a debugger with the given `namespace`.
41441
- *
41442
- * @param {String} namespace
41443
- * @return {Function}
41444
- * @api public
41445
- */
41446
- function createDebug(namespace) {
41447
- let prevTime;
41448
- let enableOverride = null;
41449
- let namespacesCache;
41450
- let enabledCache;
41451
- function debug(...args) {
41452
- if (!debug.enabled) return;
41453
- const self = debug;
41454
- const curr = Number(/* @__PURE__ */ new Date());
41455
- self.diff = curr - (prevTime || curr);
41456
- self.prev = prevTime;
41457
- self.curr = curr;
41458
- prevTime = curr;
41459
- args[0] = createDebug.coerce(args[0]);
41460
- if (typeof args[0] !== "string") args.unshift("%O");
41461
- let index = 0;
41462
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
41463
- if (match === "%%") return "%";
41464
- index++;
41465
- const formatter = createDebug.formatters[format];
41466
- if (typeof formatter === "function") {
41467
- const val = args[index];
41468
- match = formatter.call(self, val);
41469
- args.splice(index, 1);
41470
- index--;
41471
- }
41472
- return match;
41473
- });
41474
- createDebug.formatArgs.call(self, args);
41475
- (self.log || createDebug.log).apply(self, args);
41476
- }
41477
- debug.namespace = namespace;
41478
- debug.useColors = createDebug.useColors();
41479
- debug.color = createDebug.selectColor(namespace);
41480
- debug.extend = extend;
41481
- debug.destroy = createDebug.destroy;
41482
- Object.defineProperty(debug, "enabled", {
41483
- enumerable: true,
41484
- configurable: false,
41485
- get: () => {
41486
- if (enableOverride !== null) return enableOverride;
41487
- if (namespacesCache !== createDebug.namespaces) {
41488
- namespacesCache = createDebug.namespaces;
41489
- enabledCache = createDebug.enabled(namespace);
41490
- }
41491
- return enabledCache;
41492
- },
41493
- set: (v) => {
41494
- enableOverride = v;
41495
- }
41496
- });
41497
- if (typeof createDebug.init === "function") createDebug.init(debug);
41498
- return debug;
41499
- }
41500
- function extend(namespace, delimiter) {
41501
- const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
41502
- newDebug.log = this.log;
41503
- return newDebug;
41504
- }
41505
- /**
41506
- * Enables a debug mode by namespaces. This can include modes
41507
- * separated by a colon and wildcards.
41508
- *
41509
- * @param {String} namespaces
41510
- * @api public
41511
- */
41512
- function enable(namespaces) {
41513
- createDebug.save(namespaces);
41514
- createDebug.namespaces = namespaces;
41515
- createDebug.names = [];
41516
- createDebug.skips = [];
41517
- const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
41518
- for (const ns of split) if (ns[0] === "-") createDebug.skips.push(ns.slice(1));
41519
- else createDebug.names.push(ns);
41520
- }
41521
- /**
41522
- * Checks if the given string matches a namespace template, honoring
41523
- * asterisks as wildcards.
41524
- *
41525
- * @param {String} search
41526
- * @param {String} template
41527
- * @return {Boolean}
41528
- */
41529
- function matchesTemplate(search, template) {
41530
- let searchIndex = 0;
41531
- let templateIndex = 0;
41532
- let starIndex = -1;
41533
- let matchIndex = 0;
41534
- while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") {
41535
- starIndex = templateIndex;
41536
- matchIndex = searchIndex;
41537
- templateIndex++;
41538
- } else {
41539
- searchIndex++;
41540
- templateIndex++;
41541
- }
41542
- else if (starIndex !== -1) {
41543
- templateIndex = starIndex + 1;
41544
- matchIndex++;
41545
- searchIndex = matchIndex;
41546
- } else return false;
41547
- while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++;
41548
- return templateIndex === template.length;
41549
- }
41550
- /**
41551
- * Disable debug output.
41552
- *
41553
- * @return {String} namespaces
41554
- * @api public
41555
- */
41556
- function disable() {
41557
- const namespaces = [...createDebug.names, ...createDebug.skips.map((namespace) => "-" + namespace)].join(",");
41558
- createDebug.enable("");
41559
- return namespaces;
41560
- }
41561
- /**
41562
- * Returns true if the given mode name is enabled, false otherwise.
41563
- *
41564
- * @param {String} name
41565
- * @return {Boolean}
41566
- * @api public
41567
- */
41568
- function enabled(name) {
41569
- for (const skip of createDebug.skips) if (matchesTemplate(name, skip)) return false;
41570
- for (const ns of createDebug.names) if (matchesTemplate(name, ns)) return true;
41571
- return false;
41572
- }
41573
- /**
41574
- * Coerce `val`.
41575
- *
41576
- * @param {Mixed} val
41577
- * @return {Mixed}
41578
- * @api private
41579
- */
41580
- function coerce(val) {
41581
- if (val instanceof Error) return val.stack || val.message;
41582
- return val;
41583
- }
41584
- /**
41585
- * XXX DO NOT USE. This is a temporary stub function.
41586
- * XXX It WILL be removed in the next major release.
41587
- */
41588
- function destroy() {
41589
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
41590
- }
41591
- createDebug.enable(createDebug.load());
41592
- return createDebug;
41593
- }
41594
- module.exports = setup;
41595
- }));
41596
- //#endregion
41597
- //#region ../../node_modules/debug/src/browser.js
41598
- var require_browser = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
41599
- /**
41600
- * This is the web browser implementation of `debug()`.
41601
- */
41602
- exports.formatArgs = formatArgs;
41603
- exports.save = save;
41604
- exports.load = load;
41605
- exports.useColors = useColors;
41606
- exports.storage = localstorage();
41607
- exports.destroy = (() => {
41608
- let warned = false;
41609
- return () => {
41610
- if (!warned) {
41611
- warned = true;
41612
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
41613
- }
41614
- };
41615
- })();
41616
- /**
41617
- * Colors.
41618
- */
41619
- exports.colors = [
41620
- "#0000CC",
41621
- "#0000FF",
41622
- "#0033CC",
41623
- "#0033FF",
41624
- "#0066CC",
41625
- "#0066FF",
41626
- "#0099CC",
41627
- "#0099FF",
41628
- "#00CC00",
41629
- "#00CC33",
41630
- "#00CC66",
41631
- "#00CC99",
41632
- "#00CCCC",
41633
- "#00CCFF",
41634
- "#3300CC",
41635
- "#3300FF",
41636
- "#3333CC",
41637
- "#3333FF",
41638
- "#3366CC",
41639
- "#3366FF",
41640
- "#3399CC",
41641
- "#3399FF",
41642
- "#33CC00",
41643
- "#33CC33",
41644
- "#33CC66",
41645
- "#33CC99",
41646
- "#33CCCC",
41647
- "#33CCFF",
41648
- "#6600CC",
41649
- "#6600FF",
41650
- "#6633CC",
41651
- "#6633FF",
41652
- "#66CC00",
41653
- "#66CC33",
41654
- "#9900CC",
41655
- "#9900FF",
41656
- "#9933CC",
41657
- "#9933FF",
41658
- "#99CC00",
41659
- "#99CC33",
41660
- "#CC0000",
41661
- "#CC0033",
41662
- "#CC0066",
41663
- "#CC0099",
41664
- "#CC00CC",
41665
- "#CC00FF",
41666
- "#CC3300",
41667
- "#CC3333",
41668
- "#CC3366",
41669
- "#CC3399",
41670
- "#CC33CC",
41671
- "#CC33FF",
41672
- "#CC6600",
41673
- "#CC6633",
41674
- "#CC9900",
41675
- "#CC9933",
41676
- "#CCCC00",
41677
- "#CCCC33",
41678
- "#FF0000",
41679
- "#FF0033",
41680
- "#FF0066",
41681
- "#FF0099",
41682
- "#FF00CC",
41683
- "#FF00FF",
41684
- "#FF3300",
41685
- "#FF3333",
41686
- "#FF3366",
41687
- "#FF3399",
41688
- "#FF33CC",
41689
- "#FF33FF",
41690
- "#FF6600",
41691
- "#FF6633",
41692
- "#FF9900",
41693
- "#FF9933",
41694
- "#FFCC00",
41695
- "#FFCC33"
41696
- ];
41697
- /**
41698
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
41699
- * and the Firebug extension (any Firefox version) are known
41700
- * to support "%c" CSS customizations.
41701
- *
41702
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
41703
- */
41704
- function useColors() {
41705
- if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return true;
41706
- if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return false;
41707
- let m;
41708
- return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
41709
- }
41710
- /**
41711
- * Colorize log arguments if enabled.
41712
- *
41713
- * @api public
41714
- */
41715
- function formatArgs(args) {
41716
- args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
41717
- if (!this.useColors) return;
41718
- const c = "color: " + this.color;
41719
- args.splice(1, 0, c, "color: inherit");
41720
- let index = 0;
41721
- let lastC = 0;
41722
- args[0].replace(/%[a-zA-Z%]/g, (match) => {
41723
- if (match === "%%") return;
41724
- index++;
41725
- if (match === "%c") lastC = index;
41726
- });
41727
- args.splice(lastC, 0, c);
41728
- }
41729
- /**
41730
- * Invokes `console.debug()` when available.
41731
- * No-op when `console.debug` is not a "function".
41732
- * If `console.debug` is not available, falls back
41733
- * to `console.log`.
41734
- *
41735
- * @api public
41736
- */
41737
- exports.log = console.debug || console.log || (() => {});
41738
- /**
41739
- * Save `namespaces`.
41740
- *
41741
- * @param {String} namespaces
41742
- * @api private
41743
- */
41744
- function save(namespaces) {
41745
- try {
41746
- if (namespaces) exports.storage.setItem("debug", namespaces);
41747
- else exports.storage.removeItem("debug");
41748
- } catch (error) {}
41749
- }
41750
- /**
41751
- * Load `namespaces`.
41752
- *
41753
- * @return {String} returns the previously persisted debug modes
41754
- * @api private
41755
- */
41756
- function load() {
41757
- let r;
41758
- try {
41759
- r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
41760
- } catch (error) {}
41761
- if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
41762
- return r;
41763
- }
41764
- /**
41765
- * Localstorage attempts to return the localstorage.
41766
- *
41767
- * This is necessary because safari throws
41768
- * when a user disables cookies/localstorage
41769
- * and you attempt to access it.
41770
- *
41771
- * @return {LocalStorage}
41772
- * @api private
41773
- */
41774
- function localstorage() {
41775
- try {
41776
- return localStorage;
41777
- } catch (error) {}
41778
- }
41779
- module.exports = require_common$1()(exports);
41780
- var { formatters } = module.exports;
41781
- /**
41782
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
41783
- */
41784
- formatters.j = function(v) {
41785
- try {
41786
- return JSON.stringify(v);
41787
- } catch (error) {
41788
- return "[UnexpectedJSONParseError]: " + error.message;
41789
- }
41790
- };
41791
- }));
41792
- //#endregion
41793
- //#region ../../node_modules/has-flag/index.js
41794
- var require_has_flag$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
41795
- module.exports = (flag, argv = process.argv) => {
41796
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
41797
- const position = argv.indexOf(prefix + flag);
41798
- const terminatorPosition = argv.indexOf("--");
41799
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
41800
- };
41801
- }));
41802
- //#endregion
41803
- //#region ../../node_modules/supports-color/index.js
41804
- var require_supports_color$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
41805
- var os$13 = require("os");
41806
- var tty$1 = require("tty");
41807
- var hasFlag = require_has_flag$1();
41808
- var { env } = process;
41809
- var flagForceColor;
41810
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) flagForceColor = 0;
41811
- else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) flagForceColor = 1;
41812
- function envForceColor() {
41813
- if ("FORCE_COLOR" in env) {
41814
- if (env.FORCE_COLOR === "true") return 1;
41815
- if (env.FORCE_COLOR === "false") return 0;
41816
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
41817
- }
41818
- }
41819
- function translateLevel(level) {
41820
- if (level === 0) return false;
41821
- return {
41822
- level,
41823
- hasBasic: true,
41824
- has256: level >= 2,
41825
- has16m: level >= 3
41826
- };
41827
- }
41828
- function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
41829
- const noFlagForceColor = envForceColor();
41830
- if (noFlagForceColor !== void 0) flagForceColor = noFlagForceColor;
41831
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
41832
- if (forceColor === 0) return 0;
41833
- if (sniffFlags) {
41834
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) return 3;
41835
- if (hasFlag("color=256")) return 2;
41836
- }
41837
- if (haveStream && !streamIsTTY && forceColor === void 0) return 0;
41838
- const min = forceColor || 0;
41839
- if (env.TERM === "dumb") return min;
41840
- if (process.platform === "win32") {
41841
- const osRelease = os$13.release().split(".");
41842
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
41843
- return 1;
41844
- }
41845
- if ("CI" in env) {
41846
- if ([
41847
- "TRAVIS",
41848
- "CIRCLECI",
41849
- "APPVEYOR",
41850
- "GITLAB_CI",
41851
- "GITHUB_ACTIONS",
41852
- "BUILDKITE",
41853
- "DRONE"
41854
- ].some((sign) => sign in env) || env.CI_NAME === "codeship") return 1;
41855
- return min;
41856
- }
41857
- if ("TEAMCITY_VERSION" in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
41858
- if (env.COLORTERM === "truecolor") return 3;
41859
- if ("TERM_PROGRAM" in env) {
41860
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
41861
- switch (env.TERM_PROGRAM) {
41862
- case "iTerm.app": return version >= 3 ? 3 : 2;
41863
- case "Apple_Terminal": return 2;
41864
- }
41865
- }
41866
- if (/-256(color)?$/i.test(env.TERM)) return 2;
41867
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
41868
- if ("COLORTERM" in env) return 1;
41869
- return min;
41870
- }
41871
- function getSupportLevel(stream, options = {}) {
41872
- return translateLevel(supportsColor(stream, {
41873
- streamIsTTY: stream && stream.isTTY,
41874
- ...options
41875
- }));
41876
- }
41877
- module.exports = {
41878
- supportsColor: getSupportLevel,
41879
- stdout: getSupportLevel({ isTTY: tty$1.isatty(1) }),
41880
- stderr: getSupportLevel({ isTTY: tty$1.isatty(2) })
41881
- };
41882
- }));
41883
- //#endregion
41884
- //#region ../../node_modules/debug/src/node.js
41885
- var require_node = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
41886
- /**
41887
- * Module dependencies.
41888
- */
41889
- var tty = require("tty");
41890
- var util$6 = require("util");
41891
- /**
41892
- * This is the Node.js implementation of `debug()`.
41893
- */
41894
- exports.init = init;
41895
- exports.log = log;
41896
- exports.formatArgs = formatArgs;
41897
- exports.save = save;
41898
- exports.load = load;
41899
- exports.useColors = useColors;
41900
- exports.destroy = util$6.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
41901
- /**
41902
- * Colors.
41903
- */
41904
- exports.colors = [
41905
- 6,
41906
- 2,
41907
- 3,
41908
- 4,
41909
- 5,
41910
- 1
41911
- ];
41912
- try {
41913
- const supportsColor = require_supports_color$1();
41914
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) exports.colors = [
41915
- 20,
41916
- 21,
41917
- 26,
41918
- 27,
41919
- 32,
41920
- 33,
41921
- 38,
41922
- 39,
41923
- 40,
41924
- 41,
41925
- 42,
41926
- 43,
41927
- 44,
41928
- 45,
41929
- 56,
41930
- 57,
41931
- 62,
41932
- 63,
41933
- 68,
41934
- 69,
41935
- 74,
41936
- 75,
41937
- 76,
41938
- 77,
41939
- 78,
41940
- 79,
41941
- 80,
41942
- 81,
41943
- 92,
41944
- 93,
41945
- 98,
41946
- 99,
41947
- 112,
41948
- 113,
41949
- 128,
41950
- 129,
41951
- 134,
41952
- 135,
41953
- 148,
41954
- 149,
41955
- 160,
41956
- 161,
41957
- 162,
41958
- 163,
41959
- 164,
41960
- 165,
41961
- 166,
41962
- 167,
41963
- 168,
41964
- 169,
41965
- 170,
41966
- 171,
41967
- 172,
41968
- 173,
41969
- 178,
41970
- 179,
41971
- 184,
41972
- 185,
41973
- 196,
41974
- 197,
41975
- 198,
41976
- 199,
41977
- 200,
41978
- 201,
41979
- 202,
41980
- 203,
41981
- 204,
41982
- 205,
41983
- 206,
41984
- 207,
41985
- 208,
41986
- 209,
41987
- 214,
41988
- 215,
41989
- 220,
41990
- 221
41991
- ];
41992
- } catch (error) {}
41993
- /**
41994
- * Build up the default `inspectOpts` object from the environment variables.
41995
- *
41996
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
41997
- */
41998
- exports.inspectOpts = Object.keys(process.env).filter((key) => {
41999
- return /^debug_/i.test(key);
42000
- }).reduce((obj, key) => {
42001
- const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
42002
- return k.toUpperCase();
42003
- });
42004
- let val = process.env[key];
42005
- if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
42006
- else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
42007
- else if (val === "null") val = null;
42008
- else val = Number(val);
42009
- obj[prop] = val;
42010
- return obj;
42011
- }, {});
42012
- /**
42013
- * Is stdout a TTY? Colored output is enabled when `true`.
42014
- */
42015
- function useColors() {
42016
- return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
42017
- }
42018
- /**
42019
- * Adds ANSI color escape codes if enabled.
42020
- *
42021
- * @api public
42022
- */
42023
- function formatArgs(args) {
42024
- const { namespace: name, useColors } = this;
42025
- if (useColors) {
42026
- const c = this.color;
42027
- const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
42028
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
42029
- args[0] = prefix + args[0].split("\n").join("\n" + prefix);
42030
- args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
42031
- } else args[0] = getDate() + name + " " + args[0];
42032
- }
42033
- function getDate() {
42034
- if (exports.inspectOpts.hideDate) return "";
42035
- return (/* @__PURE__ */ new Date()).toISOString() + " ";
42036
- }
42037
- /**
42038
- * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
42039
- */
42040
- function log(...args) {
42041
- return process.stderr.write(util$6.formatWithOptions(exports.inspectOpts, ...args) + "\n");
42042
- }
42043
- /**
42044
- * Save `namespaces`.
42045
- *
42046
- * @param {String} namespaces
42047
- * @api private
42048
- */
42049
- function save(namespaces) {
42050
- if (namespaces) process.env.DEBUG = namespaces;
42051
- else delete process.env.DEBUG;
42052
- }
42053
- /**
42054
- * Load `namespaces`.
42055
- *
42056
- * @return {String} returns the previously persisted debug modes
42057
- * @api private
42058
- */
42059
- function load() {
42060
- return process.env.DEBUG;
42061
- }
42062
- /**
42063
- * Init logic for `debug` instances.
42064
- *
42065
- * Create a new `inspectOpts` object in case `useColors` is set
42066
- * differently for a particular `debug` instance.
42067
- */
42068
- function init(debug) {
42069
- debug.inspectOpts = {};
42070
- const keys = Object.keys(exports.inspectOpts);
42071
- for (let i = 0; i < keys.length; i++) debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
42072
- }
42073
- module.exports = require_common$1()(exports);
42074
- var { formatters } = module.exports;
42075
- /**
42076
- * Map %o to `util.inspect()`, all on a single line.
42077
- */
42078
- formatters.o = function(v) {
42079
- this.inspectOpts.colors = this.useColors;
42080
- return util$6.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
42081
- };
42082
- /**
42083
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
42084
- */
42085
- formatters.O = function(v) {
42086
- this.inspectOpts.colors = this.useColors;
42087
- return util$6.inspect(v, this.inspectOpts);
42088
- };
42089
- }));
42090
- //#endregion
42091
- //#region ../../node_modules/debug/src/index.js
42092
- var require_src = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
42093
- /**
42094
- * Detect Electron renderer / nwjs process, which is node, but we should
42095
- * treat as a browser.
42096
- */
42097
- if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) module.exports = require_browser();
42098
- else module.exports = require_node();
42099
- }));
42100
- //#endregion
42101
41371
  //#region ../../node_modules/moleculer/src/loggers/debug.js
42102
41372
  var require_debug = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
42103
41373
  var BaseLogger = require_base$4();
@@ -42139,7 +41409,7 @@ var require_debug = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
42139
41409
  init(loggerFactory) {
42140
41410
  super.init(loggerFactory);
42141
41411
  try {
42142
- this.debug = require_src()("moleculer");
41412
+ this.debug = require_graceful_fs$1.require_src()("moleculer");
42143
41413
  } catch (err) {
42144
41414
  /* istanbul ignore next */
42145
41415
  this.broker.fatal("The 'debug' package is missing! Please install it with 'npm install debug --save' command!", err, true);
@@ -42168,7 +41438,7 @@ var require_debug = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
42168
41438
  var require_file$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
42169
41439
  var FormattedLogger = require_formatted();
42170
41440
  var _ = require_lodash();
42171
- var fs$16 = require("fs/promises");
41441
+ var fs$15 = require("fs/promises");
42172
41442
  var path$37 = require("path");
42173
41443
  var os$12 = require("os");
42174
41444
  var { makeDirs } = require_utils$3();
@@ -42272,7 +41542,7 @@ var require_file$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
42272
41542
  const rows = Array.from(this.queue);
42273
41543
  this.queue.length = 0;
42274
41544
  const buf = rows.join(this.opts.eol) + this.opts.eol;
42275
- return fs$16.appendFile(filename, buf).catch((err) => {
41545
+ return fs$15.appendFile(filename, buf).catch((err) => {
42276
41546
  /* istanbul ignore next */
42277
41547
  console.debug("Unable to write log file:", filename, err);
42278
41548
  });
@@ -42420,8 +41690,8 @@ var require_rfdc = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module
42420
41690
  //#endregion
42421
41691
  //#region ../../node_modules/log4js/lib/configuration.js
42422
41692
  var require_configuration = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
42423
- var util$5 = require("util");
42424
- var debug = require_src()("log4js:configuration");
41693
+ var util$4 = require("util");
41694
+ var debug = require_graceful_fs$1.require_src()("log4js:configuration");
42425
41695
  var preProcessingListeners = [];
42426
41696
  var listeners = [];
42427
41697
  var not = (thing) => !thing;
@@ -42438,7 +41708,7 @@ var require_configuration = /* @__PURE__ */ require_chunk.__commonJSMin(((export
42438
41708
  };
42439
41709
  var throwExceptionIf = (config, checks, message) => {
42440
41710
  (Array.isArray(checks) ? checks : [checks]).forEach((test) => {
42441
- if (test) throw new Error(`Problem with log4js configuration: (${util$5.inspect(config, { depth: 5 })}) - ${message}`);
41711
+ if (test) throw new Error(`Problem with log4js configuration: (${util$4.inspect(config, { depth: 5 })}) - ${message}`);
42442
41712
  });
42443
41713
  };
42444
41714
  var configure = (candidate) => {
@@ -42620,7 +41890,7 @@ var require_lib$5 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
42620
41890
  var require_layouts = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
42621
41891
  var dateFormat = require_lib$5();
42622
41892
  var os$11 = require("os");
42623
- var util$4 = require("util");
41893
+ var util$3 = require("util");
42624
41894
  var path$36 = require("path");
42625
41895
  var styles = {
42626
41896
  bold: [1, 22],
@@ -42650,7 +41920,7 @@ var require_layouts = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
42650
41920
  return colorizeStart(style) + str + colorizeEnd(style);
42651
41921
  }
42652
41922
  function timestampLevelAndCategory(loggingEvent, colour) {
42653
- return colorize(util$4.format("[%s] [%s] %s - ", dateFormat.asString(loggingEvent.startTime), loggingEvent.level.toString(), loggingEvent.categoryName), colour);
41923
+ return colorize(util$3.format("[%s] [%s] %s - ", dateFormat.asString(loggingEvent.startTime), loggingEvent.level.toString(), loggingEvent.categoryName), colour);
42654
41924
  }
42655
41925
  /**
42656
41926
  * BasicLayout is a simple layout for storing the logs. The logs are stored
@@ -42662,17 +41932,17 @@ var require_layouts = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
42662
41932
  * @author Stephan Strittmatter
42663
41933
  */
42664
41934
  function basicLayout(loggingEvent) {
42665
- return timestampLevelAndCategory(loggingEvent) + util$4.format(...loggingEvent.data);
41935
+ return timestampLevelAndCategory(loggingEvent) + util$3.format(...loggingEvent.data);
42666
41936
  }
42667
41937
  /**
42668
41938
  * colouredLayout - taken from masylum's fork.
42669
41939
  * same as basicLayout, but with colours.
42670
41940
  */
42671
41941
  function colouredLayout(loggingEvent) {
42672
- return timestampLevelAndCategory(loggingEvent, loggingEvent.level.colour) + util$4.format(...loggingEvent.data);
41942
+ return timestampLevelAndCategory(loggingEvent, loggingEvent.level.colour) + util$3.format(...loggingEvent.data);
42673
41943
  }
42674
41944
  function messagePassThroughLayout(loggingEvent) {
42675
- return util$4.format(...loggingEvent.data);
41945
+ return util$3.format(...loggingEvent.data);
42676
41946
  }
42677
41947
  function dummyLayout(loggingEvent) {
42678
41948
  return loggingEvent.data[0];
@@ -42748,7 +42018,7 @@ var require_layouts = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mod
42748
42018
  return os$11.hostname().toString();
42749
42019
  }
42750
42020
  function formatMessage(loggingEvent) {
42751
- return util$4.format(...loggingEvent.data);
42021
+ return util$3.format(...loggingEvent.data);
42752
42022
  }
42753
42023
  function endOfLine() {
42754
42024
  return os$11.EOL;
@@ -43183,7 +42453,7 @@ var require_LoggingEvent = /* @__PURE__ */ require_chunk.__commonJSMin(((exports
43183
42453
  //#endregion
43184
42454
  //#region ../../node_modules/log4js/lib/clustering.js
43185
42455
  var require_clustering = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
43186
- var debug = require_src()("log4js:clustering");
42456
+ var debug = require_graceful_fs$1.require_src()("log4js:clustering");
43187
42457
  var LoggingEvent = require_LoggingEvent();
43188
42458
  var configuration = require_configuration();
43189
42459
  var disabled = false;
@@ -43351,7 +42621,7 @@ var require_logLevelFilter = /* @__PURE__ */ require_chunk.__commonJSMin(((expor
43351
42621
  //#endregion
43352
42622
  //#region ../../node_modules/log4js/lib/appenders/categoryFilter.js
43353
42623
  var require_categoryFilter = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
43354
- var debug = require_src()("log4js:categoryFilter");
42624
+ var debug = require_graceful_fs$1.require_src()("log4js:categoryFilter");
43355
42625
  function categoryFilter(excludes, appender) {
43356
42626
  if (typeof excludes === "string") excludes = [excludes];
43357
42627
  return (logEvent) => {
@@ -43371,7 +42641,7 @@ var require_categoryFilter = /* @__PURE__ */ require_chunk.__commonJSMin(((expor
43371
42641
  //#endregion
43372
42642
  //#region ../../node_modules/log4js/lib/appenders/noLogFilter.js
43373
42643
  var require_noLogFilter = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
43374
- var debug = require_src()("log4js:noLogFilter");
42644
+ var debug = require_graceful_fs$1.require_src()("log4js:noLogFilter");
43375
42645
  /**
43376
42646
  * The function removes empty or null regexp from the array
43377
42647
  * @param {string[]} regexp
@@ -43430,724 +42700,10 @@ var require_universalify = /* @__PURE__ */ require_chunk.__commonJSMin(((exports
43430
42700
  };
43431
42701
  }));
43432
42702
  //#endregion
43433
- //#region ../../node_modules/graceful-fs/polyfills.js
43434
- var require_polyfills = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
43435
- var constants = require("constants");
43436
- var origCwd = process.cwd;
43437
- var cwd = null;
43438
- var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
43439
- process.cwd = function() {
43440
- if (!cwd) cwd = origCwd.call(process);
43441
- return cwd;
43442
- };
43443
- try {
43444
- process.cwd();
43445
- } catch (er) {}
43446
- if (typeof process.chdir === "function") {
43447
- var chdir = process.chdir;
43448
- process.chdir = function(d) {
43449
- cwd = null;
43450
- chdir.call(process, d);
43451
- };
43452
- if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
43453
- }
43454
- module.exports = patch;
43455
- function patch(fs) {
43456
- if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) patchLchmod(fs);
43457
- if (!fs.lutimes) patchLutimes(fs);
43458
- fs.chown = chownFix(fs.chown);
43459
- fs.fchown = chownFix(fs.fchown);
43460
- fs.lchown = chownFix(fs.lchown);
43461
- fs.chmod = chmodFix(fs.chmod);
43462
- fs.fchmod = chmodFix(fs.fchmod);
43463
- fs.lchmod = chmodFix(fs.lchmod);
43464
- fs.chownSync = chownFixSync(fs.chownSync);
43465
- fs.fchownSync = chownFixSync(fs.fchownSync);
43466
- fs.lchownSync = chownFixSync(fs.lchownSync);
43467
- fs.chmodSync = chmodFixSync(fs.chmodSync);
43468
- fs.fchmodSync = chmodFixSync(fs.fchmodSync);
43469
- fs.lchmodSync = chmodFixSync(fs.lchmodSync);
43470
- fs.stat = statFix(fs.stat);
43471
- fs.fstat = statFix(fs.fstat);
43472
- fs.lstat = statFix(fs.lstat);
43473
- fs.statSync = statFixSync(fs.statSync);
43474
- fs.fstatSync = statFixSync(fs.fstatSync);
43475
- fs.lstatSync = statFixSync(fs.lstatSync);
43476
- if (fs.chmod && !fs.lchmod) {
43477
- fs.lchmod = function(path, mode, cb) {
43478
- if (cb) process.nextTick(cb);
43479
- };
43480
- fs.lchmodSync = function() {};
43481
- }
43482
- if (fs.chown && !fs.lchown) {
43483
- fs.lchown = function(path, uid, gid, cb) {
43484
- if (cb) process.nextTick(cb);
43485
- };
43486
- fs.lchownSync = function() {};
43487
- }
43488
- if (platform === "win32") fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
43489
- function rename(from, to, cb) {
43490
- var start = Date.now();
43491
- var backoff = 0;
43492
- fs$rename(from, to, function CB(er) {
43493
- if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
43494
- setTimeout(function() {
43495
- fs.stat(to, function(stater, st) {
43496
- if (stater && stater.code === "ENOENT") fs$rename(from, to, CB);
43497
- else cb(er);
43498
- });
43499
- }, backoff);
43500
- if (backoff < 100) backoff += 10;
43501
- return;
43502
- }
43503
- if (cb) cb(er);
43504
- });
43505
- }
43506
- if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
43507
- return rename;
43508
- })(fs.rename);
43509
- fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
43510
- function read(fd, buffer, offset, length, position, callback_) {
43511
- var callback;
43512
- if (callback_ && typeof callback_ === "function") {
43513
- var eagCounter = 0;
43514
- callback = function(er, _, __) {
43515
- if (er && er.code === "EAGAIN" && eagCounter < 10) {
43516
- eagCounter++;
43517
- return fs$read.call(fs, fd, buffer, offset, length, position, callback);
43518
- }
43519
- callback_.apply(this, arguments);
43520
- };
43521
- }
43522
- return fs$read.call(fs, fd, buffer, offset, length, position, callback);
43523
- }
43524
- if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
43525
- return read;
43526
- })(fs.read);
43527
- fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : (function(fs$readSync) {
43528
- return function(fd, buffer, offset, length, position) {
43529
- var eagCounter = 0;
43530
- while (true) try {
43531
- return fs$readSync.call(fs, fd, buffer, offset, length, position);
43532
- } catch (er) {
43533
- if (er.code === "EAGAIN" && eagCounter < 10) {
43534
- eagCounter++;
43535
- continue;
43536
- }
43537
- throw er;
43538
- }
43539
- };
43540
- })(fs.readSync);
43541
- function patchLchmod(fs) {
43542
- fs.lchmod = function(path, mode, callback) {
43543
- fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
43544
- if (err) {
43545
- if (callback) callback(err);
43546
- return;
43547
- }
43548
- fs.fchmod(fd, mode, function(err) {
43549
- fs.close(fd, function(err2) {
43550
- if (callback) callback(err || err2);
43551
- });
43552
- });
43553
- });
43554
- };
43555
- fs.lchmodSync = function(path, mode) {
43556
- var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
43557
- var threw = true;
43558
- var ret;
43559
- try {
43560
- ret = fs.fchmodSync(fd, mode);
43561
- threw = false;
43562
- } finally {
43563
- if (threw) try {
43564
- fs.closeSync(fd);
43565
- } catch (er) {}
43566
- else fs.closeSync(fd);
43567
- }
43568
- return ret;
43569
- };
43570
- }
43571
- function patchLutimes(fs) {
43572
- if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
43573
- fs.lutimes = function(path, at, mt, cb) {
43574
- fs.open(path, constants.O_SYMLINK, function(er, fd) {
43575
- if (er) {
43576
- if (cb) cb(er);
43577
- return;
43578
- }
43579
- fs.futimes(fd, at, mt, function(er) {
43580
- fs.close(fd, function(er2) {
43581
- if (cb) cb(er || er2);
43582
- });
43583
- });
43584
- });
43585
- };
43586
- fs.lutimesSync = function(path, at, mt) {
43587
- var fd = fs.openSync(path, constants.O_SYMLINK);
43588
- var ret;
43589
- var threw = true;
43590
- try {
43591
- ret = fs.futimesSync(fd, at, mt);
43592
- threw = false;
43593
- } finally {
43594
- if (threw) try {
43595
- fs.closeSync(fd);
43596
- } catch (er) {}
43597
- else fs.closeSync(fd);
43598
- }
43599
- return ret;
43600
- };
43601
- } else if (fs.futimes) {
43602
- fs.lutimes = function(_a, _b, _c, cb) {
43603
- if (cb) process.nextTick(cb);
43604
- };
43605
- fs.lutimesSync = function() {};
43606
- }
43607
- }
43608
- function chmodFix(orig) {
43609
- if (!orig) return orig;
43610
- return function(target, mode, cb) {
43611
- return orig.call(fs, target, mode, function(er) {
43612
- if (chownErOk(er)) er = null;
43613
- if (cb) cb.apply(this, arguments);
43614
- });
43615
- };
43616
- }
43617
- function chmodFixSync(orig) {
43618
- if (!orig) return orig;
43619
- return function(target, mode) {
43620
- try {
43621
- return orig.call(fs, target, mode);
43622
- } catch (er) {
43623
- if (!chownErOk(er)) throw er;
43624
- }
43625
- };
43626
- }
43627
- function chownFix(orig) {
43628
- if (!orig) return orig;
43629
- return function(target, uid, gid, cb) {
43630
- return orig.call(fs, target, uid, gid, function(er) {
43631
- if (chownErOk(er)) er = null;
43632
- if (cb) cb.apply(this, arguments);
43633
- });
43634
- };
43635
- }
43636
- function chownFixSync(orig) {
43637
- if (!orig) return orig;
43638
- return function(target, uid, gid) {
43639
- try {
43640
- return orig.call(fs, target, uid, gid);
43641
- } catch (er) {
43642
- if (!chownErOk(er)) throw er;
43643
- }
43644
- };
43645
- }
43646
- function statFix(orig) {
43647
- if (!orig) return orig;
43648
- return function(target, options, cb) {
43649
- if (typeof options === "function") {
43650
- cb = options;
43651
- options = null;
43652
- }
43653
- function callback(er, stats) {
43654
- if (stats) {
43655
- if (stats.uid < 0) stats.uid += 4294967296;
43656
- if (stats.gid < 0) stats.gid += 4294967296;
43657
- }
43658
- if (cb) cb.apply(this, arguments);
43659
- }
43660
- return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
43661
- };
43662
- }
43663
- function statFixSync(orig) {
43664
- if (!orig) return orig;
43665
- return function(target, options) {
43666
- var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
43667
- if (stats) {
43668
- if (stats.uid < 0) stats.uid += 4294967296;
43669
- if (stats.gid < 0) stats.gid += 4294967296;
43670
- }
43671
- return stats;
43672
- };
43673
- }
43674
- function chownErOk(er) {
43675
- if (!er) return true;
43676
- if (er.code === "ENOSYS") return true;
43677
- if (!process.getuid || process.getuid() !== 0) {
43678
- if (er.code === "EINVAL" || er.code === "EPERM") return true;
43679
- }
43680
- return false;
43681
- }
43682
- }
43683
- }));
43684
- //#endregion
43685
- //#region ../../node_modules/graceful-fs/legacy-streams.js
43686
- var require_legacy_streams = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
43687
- var Stream$2 = require("stream").Stream;
43688
- module.exports = legacy;
43689
- function legacy(fs) {
43690
- return {
43691
- ReadStream,
43692
- WriteStream
43693
- };
43694
- function ReadStream(path, options) {
43695
- if (!(this instanceof ReadStream)) return new ReadStream(path, options);
43696
- Stream$2.call(this);
43697
- var self = this;
43698
- this.path = path;
43699
- this.fd = null;
43700
- this.readable = true;
43701
- this.paused = false;
43702
- this.flags = "r";
43703
- this.mode = 438;
43704
- this.bufferSize = 64 * 1024;
43705
- options = options || {};
43706
- var keys = Object.keys(options);
43707
- for (var index = 0, length = keys.length; index < length; index++) {
43708
- var key = keys[index];
43709
- this[key] = options[key];
43710
- }
43711
- if (this.encoding) this.setEncoding(this.encoding);
43712
- if (this.start !== void 0) {
43713
- if ("number" !== typeof this.start) throw TypeError("start must be a Number");
43714
- if (this.end === void 0) this.end = Infinity;
43715
- else if ("number" !== typeof this.end) throw TypeError("end must be a Number");
43716
- if (this.start > this.end) throw new Error("start must be <= end");
43717
- this.pos = this.start;
43718
- }
43719
- if (this.fd !== null) {
43720
- process.nextTick(function() {
43721
- self._read();
43722
- });
43723
- return;
43724
- }
43725
- fs.open(this.path, this.flags, this.mode, function(err, fd) {
43726
- if (err) {
43727
- self.emit("error", err);
43728
- self.readable = false;
43729
- return;
43730
- }
43731
- self.fd = fd;
43732
- self.emit("open", fd);
43733
- self._read();
43734
- });
43735
- }
43736
- function WriteStream(path, options) {
43737
- if (!(this instanceof WriteStream)) return new WriteStream(path, options);
43738
- Stream$2.call(this);
43739
- this.path = path;
43740
- this.fd = null;
43741
- this.writable = true;
43742
- this.flags = "w";
43743
- this.encoding = "binary";
43744
- this.mode = 438;
43745
- this.bytesWritten = 0;
43746
- options = options || {};
43747
- var keys = Object.keys(options);
43748
- for (var index = 0, length = keys.length; index < length; index++) {
43749
- var key = keys[index];
43750
- this[key] = options[key];
43751
- }
43752
- if (this.start !== void 0) {
43753
- if ("number" !== typeof this.start) throw TypeError("start must be a Number");
43754
- if (this.start < 0) throw new Error("start must be >= zero");
43755
- this.pos = this.start;
43756
- }
43757
- this.busy = false;
43758
- this._queue = [];
43759
- if (this.fd === null) {
43760
- this._open = fs.open;
43761
- this._queue.push([
43762
- this._open,
43763
- this.path,
43764
- this.flags,
43765
- this.mode,
43766
- void 0
43767
- ]);
43768
- this.flush();
43769
- }
43770
- }
43771
- }
43772
- }));
43773
- //#endregion
43774
- //#region ../../node_modules/graceful-fs/clone.js
43775
- var require_clone = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
43776
- module.exports = clone;
43777
- var getPrototypeOf = Object.getPrototypeOf || function(obj) {
43778
- return obj.__proto__;
43779
- };
43780
- function clone(obj) {
43781
- if (obj === null || typeof obj !== "object") return obj;
43782
- if (obj instanceof Object) var copy = { __proto__: getPrototypeOf(obj) };
43783
- else var copy = Object.create(null);
43784
- Object.getOwnPropertyNames(obj).forEach(function(key) {
43785
- Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
43786
- });
43787
- return copy;
43788
- }
43789
- }));
43790
- //#endregion
43791
- //#region ../../node_modules/graceful-fs/graceful-fs.js
43792
- var require_graceful_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
43793
- var fs$15 = require("fs");
43794
- var polyfills = require_polyfills();
43795
- var legacy = require_legacy_streams();
43796
- var clone = require_clone();
43797
- var util$3 = require("util");
43798
- /* istanbul ignore next - node 0.x polyfill */
43799
- var gracefulQueue;
43800
- var previousSymbol;
43801
- /* istanbul ignore else - node 0.x polyfill */
43802
- if (typeof Symbol === "function" && typeof Symbol.for === "function") {
43803
- gracefulQueue = Symbol.for("graceful-fs.queue");
43804
- previousSymbol = Symbol.for("graceful-fs.previous");
43805
- } else {
43806
- gracefulQueue = "___graceful-fs.queue";
43807
- previousSymbol = "___graceful-fs.previous";
43808
- }
43809
- function noop() {}
43810
- function publishQueue(context, queue) {
43811
- Object.defineProperty(context, gracefulQueue, { get: function() {
43812
- return queue;
43813
- } });
43814
- }
43815
- var debug = noop;
43816
- if (util$3.debuglog) debug = util$3.debuglog("gfs4");
43817
- else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) debug = function() {
43818
- var m = util$3.format.apply(util$3, arguments);
43819
- m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
43820
- console.error(m);
43821
- };
43822
- if (!fs$15[gracefulQueue]) {
43823
- publishQueue(fs$15, global[gracefulQueue] || []);
43824
- fs$15.close = (function(fs$close) {
43825
- function close(fd, cb) {
43826
- return fs$close.call(fs$15, fd, function(err) {
43827
- if (!err) resetQueue();
43828
- if (typeof cb === "function") cb.apply(this, arguments);
43829
- });
43830
- }
43831
- Object.defineProperty(close, previousSymbol, { value: fs$close });
43832
- return close;
43833
- })(fs$15.close);
43834
- fs$15.closeSync = (function(fs$closeSync) {
43835
- function closeSync(fd) {
43836
- fs$closeSync.apply(fs$15, arguments);
43837
- resetQueue();
43838
- }
43839
- Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync });
43840
- return closeSync;
43841
- })(fs$15.closeSync);
43842
- if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) process.on("exit", function() {
43843
- debug(fs$15[gracefulQueue]);
43844
- require("assert").equal(fs$15[gracefulQueue].length, 0);
43845
- });
43846
- }
43847
- if (!global[gracefulQueue]) publishQueue(global, fs$15[gracefulQueue]);
43848
- module.exports = patch(clone(fs$15));
43849
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$15.__patched) {
43850
- module.exports = patch(fs$15);
43851
- fs$15.__patched = true;
43852
- }
43853
- function patch(fs$26) {
43854
- polyfills(fs$26);
43855
- fs$26.gracefulify = patch;
43856
- fs$26.createReadStream = createReadStream;
43857
- fs$26.createWriteStream = createWriteStream;
43858
- var fs$readFile = fs$26.readFile;
43859
- fs$26.readFile = readFile;
43860
- function readFile(path, options, cb) {
43861
- if (typeof options === "function") cb = options, options = null;
43862
- return go$readFile(path, options, cb);
43863
- function go$readFile(path, options, cb, startTime) {
43864
- return fs$readFile(path, options, function(err) {
43865
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
43866
- go$readFile,
43867
- [
43868
- path,
43869
- options,
43870
- cb
43871
- ],
43872
- err,
43873
- startTime || Date.now(),
43874
- Date.now()
43875
- ]);
43876
- else if (typeof cb === "function") cb.apply(this, arguments);
43877
- });
43878
- }
43879
- }
43880
- var fs$writeFile = fs$26.writeFile;
43881
- fs$26.writeFile = writeFile;
43882
- function writeFile(path, data, options, cb) {
43883
- if (typeof options === "function") cb = options, options = null;
43884
- return go$writeFile(path, data, options, cb);
43885
- function go$writeFile(path, data, options, cb, startTime) {
43886
- return fs$writeFile(path, data, options, function(err) {
43887
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
43888
- go$writeFile,
43889
- [
43890
- path,
43891
- data,
43892
- options,
43893
- cb
43894
- ],
43895
- err,
43896
- startTime || Date.now(),
43897
- Date.now()
43898
- ]);
43899
- else if (typeof cb === "function") cb.apply(this, arguments);
43900
- });
43901
- }
43902
- }
43903
- var fs$appendFile = fs$26.appendFile;
43904
- if (fs$appendFile) fs$26.appendFile = appendFile;
43905
- function appendFile(path, data, options, cb) {
43906
- if (typeof options === "function") cb = options, options = null;
43907
- return go$appendFile(path, data, options, cb);
43908
- function go$appendFile(path, data, options, cb, startTime) {
43909
- return fs$appendFile(path, data, options, function(err) {
43910
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
43911
- go$appendFile,
43912
- [
43913
- path,
43914
- data,
43915
- options,
43916
- cb
43917
- ],
43918
- err,
43919
- startTime || Date.now(),
43920
- Date.now()
43921
- ]);
43922
- else if (typeof cb === "function") cb.apply(this, arguments);
43923
- });
43924
- }
43925
- }
43926
- var fs$copyFile = fs$26.copyFile;
43927
- if (fs$copyFile) fs$26.copyFile = copyFile;
43928
- function copyFile(src, dest, flags, cb) {
43929
- if (typeof flags === "function") {
43930
- cb = flags;
43931
- flags = 0;
43932
- }
43933
- return go$copyFile(src, dest, flags, cb);
43934
- function go$copyFile(src, dest, flags, cb, startTime) {
43935
- return fs$copyFile(src, dest, flags, function(err) {
43936
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
43937
- go$copyFile,
43938
- [
43939
- src,
43940
- dest,
43941
- flags,
43942
- cb
43943
- ],
43944
- err,
43945
- startTime || Date.now(),
43946
- Date.now()
43947
- ]);
43948
- else if (typeof cb === "function") cb.apply(this, arguments);
43949
- });
43950
- }
43951
- }
43952
- var fs$readdir = fs$26.readdir;
43953
- fs$26.readdir = readdir;
43954
- var noReaddirOptionVersions = /^v[0-5]\./;
43955
- function readdir(path, options, cb) {
43956
- if (typeof options === "function") cb = options, options = null;
43957
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path, options, cb, startTime) {
43958
- return fs$readdir(path, fs$readdirCallback(path, options, cb, startTime));
43959
- } : function go$readdir(path, options, cb, startTime) {
43960
- return fs$readdir(path, options, fs$readdirCallback(path, options, cb, startTime));
43961
- };
43962
- return go$readdir(path, options, cb);
43963
- function fs$readdirCallback(path, options, cb, startTime) {
43964
- return function(err, files) {
43965
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
43966
- go$readdir,
43967
- [
43968
- path,
43969
- options,
43970
- cb
43971
- ],
43972
- err,
43973
- startTime || Date.now(),
43974
- Date.now()
43975
- ]);
43976
- else {
43977
- if (files && files.sort) files.sort();
43978
- if (typeof cb === "function") cb.call(this, err, files);
43979
- }
43980
- };
43981
- }
43982
- }
43983
- if (process.version.substr(0, 4) === "v0.8") {
43984
- var legStreams = legacy(fs$26);
43985
- ReadStream = legStreams.ReadStream;
43986
- WriteStream = legStreams.WriteStream;
43987
- }
43988
- var fs$ReadStream = fs$26.ReadStream;
43989
- if (fs$ReadStream) {
43990
- ReadStream.prototype = Object.create(fs$ReadStream.prototype);
43991
- ReadStream.prototype.open = ReadStream$open;
43992
- }
43993
- var fs$WriteStream = fs$26.WriteStream;
43994
- if (fs$WriteStream) {
43995
- WriteStream.prototype = Object.create(fs$WriteStream.prototype);
43996
- WriteStream.prototype.open = WriteStream$open;
43997
- }
43998
- Object.defineProperty(fs$26, "ReadStream", {
43999
- get: function() {
44000
- return ReadStream;
44001
- },
44002
- set: function(val) {
44003
- ReadStream = val;
44004
- },
44005
- enumerable: true,
44006
- configurable: true
44007
- });
44008
- Object.defineProperty(fs$26, "WriteStream", {
44009
- get: function() {
44010
- return WriteStream;
44011
- },
44012
- set: function(val) {
44013
- WriteStream = val;
44014
- },
44015
- enumerable: true,
44016
- configurable: true
44017
- });
44018
- var FileReadStream = ReadStream;
44019
- Object.defineProperty(fs$26, "FileReadStream", {
44020
- get: function() {
44021
- return FileReadStream;
44022
- },
44023
- set: function(val) {
44024
- FileReadStream = val;
44025
- },
44026
- enumerable: true,
44027
- configurable: true
44028
- });
44029
- var FileWriteStream = WriteStream;
44030
- Object.defineProperty(fs$26, "FileWriteStream", {
44031
- get: function() {
44032
- return FileWriteStream;
44033
- },
44034
- set: function(val) {
44035
- FileWriteStream = val;
44036
- },
44037
- enumerable: true,
44038
- configurable: true
44039
- });
44040
- function ReadStream(path, options) {
44041
- if (this instanceof ReadStream) return fs$ReadStream.apply(this, arguments), this;
44042
- else return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
44043
- }
44044
- function ReadStream$open() {
44045
- var that = this;
44046
- open(that.path, that.flags, that.mode, function(err, fd) {
44047
- if (err) {
44048
- if (that.autoClose) that.destroy();
44049
- that.emit("error", err);
44050
- } else {
44051
- that.fd = fd;
44052
- that.emit("open", fd);
44053
- that.read();
44054
- }
44055
- });
44056
- }
44057
- function WriteStream(path, options) {
44058
- if (this instanceof WriteStream) return fs$WriteStream.apply(this, arguments), this;
44059
- else return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
44060
- }
44061
- function WriteStream$open() {
44062
- var that = this;
44063
- open(that.path, that.flags, that.mode, function(err, fd) {
44064
- if (err) {
44065
- that.destroy();
44066
- that.emit("error", err);
44067
- } else {
44068
- that.fd = fd;
44069
- that.emit("open", fd);
44070
- }
44071
- });
44072
- }
44073
- function createReadStream(path, options) {
44074
- return new fs$26.ReadStream(path, options);
44075
- }
44076
- function createWriteStream(path, options) {
44077
- return new fs$26.WriteStream(path, options);
44078
- }
44079
- var fs$open = fs$26.open;
44080
- fs$26.open = open;
44081
- function open(path, flags, mode, cb) {
44082
- if (typeof mode === "function") cb = mode, mode = null;
44083
- return go$open(path, flags, mode, cb);
44084
- function go$open(path, flags, mode, cb, startTime) {
44085
- return fs$open(path, flags, mode, function(err, fd) {
44086
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
44087
- go$open,
44088
- [
44089
- path,
44090
- flags,
44091
- mode,
44092
- cb
44093
- ],
44094
- err,
44095
- startTime || Date.now(),
44096
- Date.now()
44097
- ]);
44098
- else if (typeof cb === "function") cb.apply(this, arguments);
44099
- });
44100
- }
44101
- }
44102
- return fs$26;
44103
- }
44104
- function enqueue(elem) {
44105
- debug("ENQUEUE", elem[0].name, elem[1]);
44106
- fs$15[gracefulQueue].push(elem);
44107
- retry();
44108
- }
44109
- var retryTimer;
44110
- function resetQueue() {
44111
- var now = Date.now();
44112
- for (var i = 0; i < fs$15[gracefulQueue].length; ++i) if (fs$15[gracefulQueue][i].length > 2) {
44113
- fs$15[gracefulQueue][i][3] = now;
44114
- fs$15[gracefulQueue][i][4] = now;
44115
- }
44116
- retry();
44117
- }
44118
- function retry() {
44119
- clearTimeout(retryTimer);
44120
- retryTimer = void 0;
44121
- if (fs$15[gracefulQueue].length === 0) return;
44122
- var elem = fs$15[gracefulQueue].shift();
44123
- var fn = elem[0];
44124
- var args = elem[1];
44125
- var err = elem[2];
44126
- var startTime = elem[3];
44127
- var lastTime = elem[4];
44128
- if (startTime === void 0) {
44129
- debug("RETRY", fn.name, args);
44130
- fn.apply(null, args);
44131
- } else if (Date.now() - startTime >= 6e4) {
44132
- debug("TIMEOUT", fn.name, args);
44133
- var cb = args.pop();
44134
- if (typeof cb === "function") cb.call(null, err);
44135
- } else {
44136
- var sinceAttempt = Date.now() - lastTime;
44137
- var sinceStart = Math.max(lastTime - startTime, 1);
44138
- if (sinceAttempt >= Math.min(sinceStart * 1.2, 100)) {
44139
- debug("RETRY", fn.name, args);
44140
- fn.apply(null, args.concat([startTime]));
44141
- } else fs$15[gracefulQueue].push(elem);
44142
- }
44143
- if (retryTimer === void 0) retryTimer = setTimeout(retry, 0);
44144
- }
44145
- }));
44146
- //#endregion
44147
42703
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/fs/index.js
44148
42704
  var require_fs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
44149
42705
  var u = require_universalify().fromCallback;
44150
- var fs = require_graceful_fs();
42706
+ var fs = require_graceful_fs$1.require_graceful_fs();
44151
42707
  var api = [
44152
42708
  "access",
44153
42709
  "appendFile",
@@ -44246,7 +42802,7 @@ var require_win32 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
44246
42802
  //#endregion
44247
42803
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/mkdirs/mkdirs.js
44248
42804
  var require_mkdirs$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
44249
- var fs = require_graceful_fs();
42805
+ var fs = require_graceful_fs$1.require_graceful_fs();
44250
42806
  var path$34 = require("path");
44251
42807
  var invalidWin32Path = require_win32().invalidWin32Path;
44252
42808
  var o777 = parseInt("0777", 8);
@@ -44293,7 +42849,7 @@ var require_mkdirs$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
44293
42849
  //#endregion
44294
42850
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js
44295
42851
  var require_mkdirs_sync = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
44296
- var fs = require_graceful_fs();
42852
+ var fs = require_graceful_fs$1.require_graceful_fs();
44297
42853
  var path$33 = require("path");
44298
42854
  var invalidWin32Path = require_win32().invalidWin32Path;
44299
42855
  var o777 = parseInt("0777", 8);
@@ -44349,7 +42905,7 @@ var require_mkdirs = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
44349
42905
  //#endregion
44350
42906
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/util/utimes.js
44351
42907
  var require_utimes = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
44352
- var fs = require_graceful_fs();
42908
+ var fs = require_graceful_fs$1.require_graceful_fs();
44353
42909
  var os$10 = require("os");
44354
42910
  var path$32 = require("path");
44355
42911
  function hasMillisResSync() {
@@ -44414,7 +42970,7 @@ var require_utimes = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
44414
42970
  //#endregion
44415
42971
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/util/stat.js
44416
42972
  var require_stat = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
44417
- var fs = require_graceful_fs();
42973
+ var fs = require_graceful_fs$1.require_graceful_fs();
44418
42974
  var path$31 = require("path");
44419
42975
  var NODE_VERSION_MAJOR_WITH_BIGINT = 10;
44420
42976
  var NODE_VERSION_MINOR_WITH_BIGINT = 5;
@@ -44574,7 +43130,7 @@ var require_buffer = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
44574
43130
  //#endregion
44575
43131
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/copy-sync/copy-sync.js
44576
43132
  var require_copy_sync$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
44577
- var fs = require_graceful_fs();
43133
+ var fs = require_graceful_fs$1.require_graceful_fs();
44578
43134
  var path$30 = require("path");
44579
43135
  var mkdirpSync = require_mkdirs().mkdirsSync;
44580
43136
  var utimesSync = require_utimes().utimesMillisSync;
@@ -44704,7 +43260,7 @@ var require_path_exists = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
44704
43260
  //#endregion
44705
43261
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/copy/copy.js
44706
43262
  var require_copy$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
44707
- var fs = require_graceful_fs();
43263
+ var fs = require_graceful_fs$1.require_graceful_fs();
44708
43264
  var path$29 = require("path");
44709
43265
  var mkdirp = require_mkdirs().mkdirs;
44710
43266
  var pathExists = require_path_exists().pathExists;
@@ -44864,7 +43420,7 @@ var require_copy = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module
44864
43420
  //#endregion
44865
43421
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/remove/rimraf.js
44866
43422
  var require_rimraf = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
44867
- var fs = require_graceful_fs();
43423
+ var fs = require_graceful_fs$1.require_graceful_fs();
44868
43424
  var path$28 = require("path");
44869
43425
  var assert$2 = require("assert");
44870
43426
  var isWindows = process.platform === "win32";
@@ -45054,7 +43610,7 @@ var require_remove = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
45054
43610
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/empty/index.js
45055
43611
  var require_empty = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45056
43612
  var u = require_universalify().fromCallback;
45057
- var fs = require_graceful_fs();
43613
+ var fs = require_graceful_fs$1.require_graceful_fs();
45058
43614
  var path$27 = require("path");
45059
43615
  var mkdir = require_mkdirs();
45060
43616
  var remove = require_remove();
@@ -45098,7 +43654,7 @@ var require_empty = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
45098
43654
  var require_file$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45099
43655
  var u = require_universalify().fromCallback;
45100
43656
  var path$26 = require("path");
45101
- var fs = require_graceful_fs();
43657
+ var fs = require_graceful_fs$1.require_graceful_fs();
45102
43658
  var mkdir = require_mkdirs();
45103
43659
  var pathExists = require_path_exists().pathExists;
45104
43660
  function createFile(file, callback) {
@@ -45141,7 +43697,7 @@ var require_file$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
45141
43697
  var require_link = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45142
43698
  var u = require_universalify().fromCallback;
45143
43699
  var path$25 = require("path");
45144
- var fs = require_graceful_fs();
43700
+ var fs = require_graceful_fs$1.require_graceful_fs();
45145
43701
  var mkdir = require_mkdirs();
45146
43702
  var pathExists = require_path_exists().pathExists;
45147
43703
  function createLink(srcpath, dstpath, callback) {
@@ -45193,7 +43749,7 @@ var require_link = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module
45193
43749
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/ensure/symlink-paths.js
45194
43750
  var require_symlink_paths = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45195
43751
  var path$24 = require("path");
45196
- var fs = require_graceful_fs();
43752
+ var fs = require_graceful_fs$1.require_graceful_fs();
45197
43753
  var pathExists = require_path_exists().pathExists;
45198
43754
  /**
45199
43755
  * Function that returns two types of paths, one relative to symlink, and one
@@ -45284,7 +43840,7 @@ var require_symlink_paths = /* @__PURE__ */ require_chunk.__commonJSMin(((export
45284
43840
  //#endregion
45285
43841
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/ensure/symlink-type.js
45286
43842
  var require_symlink_type = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45287
- var fs = require_graceful_fs();
43843
+ var fs = require_graceful_fs$1.require_graceful_fs();
45288
43844
  function symlinkType(srcpath, type, callback) {
45289
43845
  callback = typeof type === "function" ? type : callback;
45290
43846
  type = typeof type === "function" ? false : type;
@@ -45315,7 +43871,7 @@ var require_symlink_type = /* @__PURE__ */ require_chunk.__commonJSMin(((exports
45315
43871
  var require_symlink = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45316
43872
  var u = require_universalify().fromCallback;
45317
43873
  var path$23 = require("path");
45318
- var fs = require_graceful_fs();
43874
+ var fs = require_graceful_fs$1.require_graceful_fs();
45319
43875
  var _mkdirs = require_mkdirs();
45320
43876
  var mkdirs = _mkdirs.mkdirs;
45321
43877
  var mkdirsSync = _mkdirs.mkdirsSync;
@@ -45391,7 +43947,7 @@ var require_ensure = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modu
45391
43947
  var require_jsonfile$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45392
43948
  var _fs;
45393
43949
  try {
45394
- _fs = require_graceful_fs();
43950
+ _fs = require_graceful_fs$1.require_graceful_fs();
45395
43951
  } catch (_) {
45396
43952
  _fs = require("fs");
45397
43953
  }
@@ -45402,10 +43958,10 @@ var require_jsonfile$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
45402
43958
  }
45403
43959
  if (typeof options === "string") options = { encoding: options };
45404
43960
  options = options || {};
45405
- var fs$22 = options.fs || _fs;
43961
+ var fs$21 = options.fs || _fs;
45406
43962
  var shouldThrow = true;
45407
43963
  if ("throws" in options) shouldThrow = options.throws;
45408
- fs$22.readFile(file, options, function(err, data) {
43964
+ fs$21.readFile(file, options, function(err, data) {
45409
43965
  if (err) return callback(err);
45410
43966
  data = stripBom(data);
45411
43967
  var obj;
@@ -45423,11 +43979,11 @@ var require_jsonfile$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
45423
43979
  function readFileSync(file, options) {
45424
43980
  options = options || {};
45425
43981
  if (typeof options === "string") options = { encoding: options };
45426
- var fs$23 = options.fs || _fs;
43982
+ var fs$22 = options.fs || _fs;
45427
43983
  var shouldThrow = true;
45428
43984
  if ("throws" in options) shouldThrow = options.throws;
45429
43985
  try {
45430
- var content = fs$23.readFileSync(file, options);
43986
+ var content = fs$22.readFileSync(file, options);
45431
43987
  content = stripBom(content);
45432
43988
  return JSON.parse(content, options.reviver);
45433
43989
  } catch (err) {
@@ -45452,7 +44008,7 @@ var require_jsonfile$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
45452
44008
  options = {};
45453
44009
  }
45454
44010
  options = options || {};
45455
- var fs$24 = options.fs || _fs;
44011
+ var fs$23 = options.fs || _fs;
45456
44012
  var str = "";
45457
44013
  try {
45458
44014
  str = stringify(obj, options);
@@ -45460,13 +44016,13 @@ var require_jsonfile$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
45460
44016
  if (callback) callback(err, null);
45461
44017
  return;
45462
44018
  }
45463
- fs$24.writeFile(file, str, options, callback);
44019
+ fs$23.writeFile(file, str, options, callback);
45464
44020
  }
45465
44021
  function writeFileSync(file, obj, options) {
45466
44022
  options = options || {};
45467
- var fs$25 = options.fs || _fs;
44023
+ var fs$24 = options.fs || _fs;
45468
44024
  var str = stringify(obj, options);
45469
- return fs$25.writeFileSync(file, str, options);
44025
+ return fs$24.writeFileSync(file, str, options);
45470
44026
  }
45471
44027
  function stripBom(content) {
45472
44028
  if (Buffer.isBuffer(content)) content = content.toString("utf8");
@@ -45519,7 +44075,7 @@ var require_output_json = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
45519
44075
  //#endregion
45520
44076
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/json/output-json-sync.js
45521
44077
  var require_output_json_sync = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45522
- var fs = require_graceful_fs();
44078
+ var fs = require_graceful_fs$1.require_graceful_fs();
45523
44079
  var path$21 = require("path");
45524
44080
  var mkdir = require_mkdirs();
45525
44081
  var jsonFile = require_jsonfile();
@@ -45548,7 +44104,7 @@ var require_json = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module
45548
44104
  //#endregion
45549
44105
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/move-sync/move-sync.js
45550
44106
  var require_move_sync$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45551
- var fs = require_graceful_fs();
44107
+ var fs = require_graceful_fs$1.require_graceful_fs();
45552
44108
  var path$20 = require("path");
45553
44109
  var copySync = require_copy_sync().copySync;
45554
44110
  var removeSync = require_remove().removeSync;
@@ -45595,7 +44151,7 @@ var require_move_sync = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
45595
44151
  //#endregion
45596
44152
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/move/move.js
45597
44153
  var require_move$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45598
- var fs = require_graceful_fs();
44154
+ var fs = require_graceful_fs$1.require_graceful_fs();
45599
44155
  var path$19 = require("path");
45600
44156
  var copy = require_copy().copy;
45601
44157
  var remove = require_remove().remove;
@@ -45659,7 +44215,7 @@ var require_move = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module
45659
44215
  //#region ../../node_modules/streamroller/node_modules/fs-extra/lib/output/index.js
45660
44216
  var require_output = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45661
44217
  var u = require_universalify().fromCallback;
45662
- var fs = require_graceful_fs();
44218
+ var fs = require_graceful_fs$1.require_graceful_fs();
45663
44219
  var path$18 = require("path");
45664
44220
  var mkdir = require_mkdirs();
45665
44221
  var pathExists = require_path_exists().pathExists;
@@ -45859,7 +44415,7 @@ var require_lib$3 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
45859
44415
  //#endregion
45860
44416
  //#region ../../node_modules/streamroller/lib/fileNameFormatter.js
45861
44417
  var require_fileNameFormatter = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45862
- var debug = require_src()("streamroller:fileNameFormatter");
44418
+ var debug = require_graceful_fs$1.require_src()("streamroller:fileNameFormatter");
45863
44419
  var path$17 = require("path");
45864
44420
  var FILENAME_SEP = ".";
45865
44421
  var ZIP_EXT = ".gz";
@@ -45891,7 +44447,7 @@ var require_fileNameFormatter = /* @__PURE__ */ require_chunk.__commonJSMin(((ex
45891
44447
  //#endregion
45892
44448
  //#region ../../node_modules/streamroller/lib/fileNameParser.js
45893
44449
  var require_fileNameParser = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45894
- var debug = require_src()("streamroller:fileNameParser");
44450
+ var debug = require_graceful_fs$1.require_src()("streamroller:fileNameParser");
45895
44451
  var FILENAME_SEP = ".";
45896
44452
  var ZIP_EXT = ".gz";
45897
44453
  var format = require_lib$3();
@@ -45970,7 +44526,7 @@ var require_fileNameParser = /* @__PURE__ */ require_chunk.__commonJSMin(((expor
45970
44526
  //#endregion
45971
44527
  //#region ../../node_modules/streamroller/lib/moveAndMaybeCompressFile.js
45972
44528
  var require_moveAndMaybeCompressFile = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
45973
- var debug = require_src()("streamroller:moveAndMaybeCompressFile");
44529
+ var debug = require_graceful_fs$1.require_src()("streamroller:moveAndMaybeCompressFile");
45974
44530
  var fs = require_lib$4();
45975
44531
  var zlib$1 = require("zlib");
45976
44532
  var moveAndMaybeCompressFile = async (sourceFilePath, targetFilePath, needCompress) => {
@@ -46007,7 +44563,7 @@ var require_moveAndMaybeCompressFile = /* @__PURE__ */ require_chunk.__commonJSM
46007
44563
  //#endregion
46008
44564
  //#region ../../node_modules/streamroller/lib/RollingFileWriteStream.js
46009
44565
  var require_RollingFileWriteStream = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
46010
- var debug = require_src()("streamroller:RollingFileWriteStream");
44566
+ var debug = require_graceful_fs$1.require_src()("streamroller:RollingFileWriteStream");
46011
44567
  var fs = require_lib$4();
46012
44568
  var path$16 = require("path");
46013
44569
  var newNow = require_now();
@@ -46251,7 +44807,7 @@ var require_lib$2 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, modul
46251
44807
  //#endregion
46252
44808
  //#region ../../node_modules/log4js/lib/appenders/file.js
46253
44809
  var require_file = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
46254
- var debug = require_src()("log4js:file");
44810
+ var debug = require_graceful_fs$1.require_src()("log4js:file");
46255
44811
  var path$15 = require("path");
46256
44812
  var streams = require_lib$2();
46257
44813
  var eol$2 = require("os").EOL;
@@ -46357,7 +44913,7 @@ var require_dateFile = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
46357
44913
  //#endregion
46358
44914
  //#region ../../node_modules/log4js/lib/appenders/fileSync.js
46359
44915
  var require_fileSync = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
46360
- var debug = require_src()("log4js:fileSync");
44916
+ var debug = require_graceful_fs$1.require_src()("log4js:fileSync");
46361
44917
  var path$14 = require("path");
46362
44918
  var fs$13 = require("fs");
46363
44919
  var eol = require("os").EOL || "\n";
@@ -46491,7 +45047,7 @@ var require_fileSync = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
46491
45047
  //#region ../../node_modules/log4js/lib/appenders/index.js
46492
45048
  var require_appenders = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
46493
45049
  var path$13 = require("path");
46494
- var debug = require_src()("log4js:appenders");
45050
+ var debug = require_graceful_fs$1.require_src()("log4js:appenders");
46495
45051
  var configuration = require_configuration();
46496
45052
  var clustering = require_clustering();
46497
45053
  var levels = require_levels$1();
@@ -46575,7 +45131,7 @@ var require_appenders = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
46575
45131
  //#endregion
46576
45132
  //#region ../../node_modules/log4js/lib/categories.js
46577
45133
  var require_categories = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
46578
- var debug = require_src()("log4js:categories");
45134
+ var debug = require_graceful_fs$1.require_src()("log4js:categories");
46579
45135
  var configuration = require_configuration();
46580
45136
  var levels = require_levels$1();
46581
45137
  var appenders = require_appenders();
@@ -46702,7 +45258,7 @@ var require_categories = /* @__PURE__ */ require_chunk.__commonJSMin(((exports,
46702
45258
  //#endregion
46703
45259
  //#region ../../node_modules/log4js/lib/logger.js
46704
45260
  var require_logger = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
46705
- var debug = require_src()("log4js:logger");
45261
+ var debug = require_graceful_fs$1.require_src()("log4js:logger");
46706
45262
  var LoggingEvent = require_LoggingEvent();
46707
45263
  var levels = require_levels$1();
46708
45264
  var clustering = require_clustering();
@@ -47063,7 +45619,7 @@ var require_log4js$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
47063
45619
  * @since 2005-05-20
47064
45620
  * Website: http://log4js.berlios.de
47065
45621
  */
47066
- var debug = require_src()("log4js:main");
45622
+ var debug = require_graceful_fs$1.require_src()("log4js:main");
47067
45623
  var fs$12 = require("fs");
47068
45624
  var deepClone = require_rfdc()({ proto: true });
47069
45625
  var configuration = require_configuration();
@@ -61047,7 +59603,7 @@ var require_parser$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, mo
61047
59603
  var { EventEmitter: EventEmitter$4 } = require("events");
61048
59604
  var Packet = require_packet();
61049
59605
  var constants = require_constants$4();
61050
- var debug = require_src()("mqtt-packet:parser");
59606
+ var debug = require_graceful_fs$1.require_src()("mqtt-packet:parser");
61051
59607
  module.exports = class Parser extends EventEmitter$4 {
61052
59608
  constructor() {
61053
59609
  super();
@@ -61659,7 +60215,7 @@ var require_writeToStream = /* @__PURE__ */ require_chunk.__commonJSMin(((export
61659
60215
  var zeroBuf = Buffer$2.from([0]);
61660
60216
  var numbers = require_numbers();
61661
60217
  var nextTick = require_process_nextick_args().nextTick;
61662
- var debug = require_src()("mqtt-packet:writeToStream");
60218
+ var debug = require_graceful_fs$1.require_src()("mqtt-packet:writeToStream");
61663
60219
  var numCache = numbers.cache;
61664
60220
  var generateNumber = numbers.generateNumber;
61665
60221
  var generateCache = numbers.generateCache;
@@ -67566,8 +66122,8 @@ var init_esm = require_chunk.__esmMin((() => {
67566
66122
  //#region ../../node_modules/number-allocator/lib/number-allocator.js
67567
66123
  var require_number_allocator$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
67568
66124
  var SortedSet = (init_esm(), require_chunk.__toCommonJS(esm_exports)).OrderedSet;
67569
- var debugTrace = require_src()("number-allocator:trace");
67570
- var debugError = require_src()("number-allocator:error");
66125
+ var debugTrace = require_graceful_fs$1.require_src()("number-allocator:trace");
66126
+ var debugError = require_graceful_fs$1.require_src()("number-allocator:error");
67571
66127
  /**
67572
66128
  * Interval constructor
67573
66129
  * @constructor
@@ -68563,7 +67119,7 @@ var require_client = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
68563
67119
  var mqtt_packet_1 = __importDefault(require_mqtt$2());
68564
67120
  var readable_stream_1 = require_ours();
68565
67121
  var default_1 = __importDefault(require_default());
68566
- var debug_1 = __importDefault(require_src());
67122
+ var debug_1 = __importDefault(require_graceful_fs$1.require_src());
68567
67123
  var validations = __importStar(require_validations());
68568
67124
  var store_1 = __importDefault(require_store());
68569
67125
  var handlers_1 = __importDefault(require_handlers());
@@ -69698,7 +68254,7 @@ var require_ws = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
69698
68254
  exports.streamBuilder = exports.browserStreamBuilder = void 0;
69699
68255
  var buffer_1$3 = require("buffer");
69700
68256
  var ws_1 = __importDefault(require("ws"));
69701
- var debug_1 = __importDefault(require_src());
68257
+ var debug_1 = __importDefault(require_graceful_fs$1.require_src());
69702
68258
  var readable_stream_1 = require_ours();
69703
68259
  var is_browser_1 = __importDefault(require_is_browser());
69704
68260
  var BufferedDuplex_1 = require_BufferedDuplex();
@@ -73732,7 +72288,7 @@ var require_socks = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
73732
72288
  };
73733
72289
  Object.defineProperty(exports, "__esModule", { value: true });
73734
72290
  exports.default = openSocks;
73735
- var debug_1 = __importDefault(require_src());
72291
+ var debug_1 = __importDefault(require_graceful_fs$1.require_src());
73736
72292
  var stream_1 = require("stream");
73737
72293
  var socks_1 = require_build$1();
73738
72294
  var dns = __importStar(require("dns"));
@@ -73864,7 +72420,7 @@ var require_tcp$1 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
73864
72420
  };
73865
72421
  Object.defineProperty(exports, "__esModule", { value: true });
73866
72422
  var net_1$1 = __importDefault(require("net"));
73867
- var debug_1 = __importDefault(require_src());
72423
+ var debug_1 = __importDefault(require_graceful_fs$1.require_src());
73868
72424
  var socks_1 = __importDefault(require_socks());
73869
72425
  var debug = (0, debug_1.default)("mqttjs:tcp");
73870
72426
  var buildStream = (client, opts) => {
@@ -73891,7 +72447,7 @@ var require_tls = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
73891
72447
  Object.defineProperty(exports, "__esModule", { value: true });
73892
72448
  var tls_1 = require("tls");
73893
72449
  var net_1 = __importDefault(require("net"));
73894
- var debug_1 = __importDefault(require_src());
72450
+ var debug_1 = __importDefault(require_graceful_fs$1.require_src());
73895
72451
  var socks_1 = __importDefault(require_socks());
73896
72452
  var debug = (0, debug_1.default)("mqttjs:tls");
73897
72453
  function connect(opts) {
@@ -74119,7 +72675,7 @@ var require_connect = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) =>
74119
72675
  };
74120
72676
  Object.defineProperty(exports, "__esModule", { value: true });
74121
72677
  exports.connectAsync = connectAsync;
74122
- var debug_1 = __importDefault(require_src());
72678
+ var debug_1 = __importDefault(require_graceful_fs$1.require_src());
74123
72679
  var url_1 = __importDefault(require("url"));
74124
72680
  var client_1 = __importDefault(require_client());
74125
72681
  var is_browser_1 = __importDefault(require_is_browser());
@@ -77375,7 +75931,7 @@ var require_tcp = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module)
77375
75931
  var { isObject, isString } = require_utils$3();
77376
75932
  var fs$10 = require("fs");
77377
75933
  var kleur = require_kleur();
77378
- var Node = require_node$1();
75934
+ var Node = require_node();
77379
75935
  var P = require_packets();
77380
75936
  var { resolvePacketID } = require_constants();
77381
75937
  var { MoleculerServerError } = require_errors$2();
@@ -91905,6 +90461,9 @@ function resolveUseHostname() {
91905
90461
  function createBroker(config) {
91906
90462
  const { nodeID, mode, hubAddress, logLevel = "warn", secret, tcpPort = DEFAULT_HUB_TCP_PORT, udpPort = DEFAULT_UDP_PORT } = config;
91907
90463
  const useHostname = resolveUseHostname();
90464
+ const moleculerDebug = process.env["CAMSTACK_MOLECULER_DEBUG"] === "1" || process.env["CAMSTACK_MOLECULER_DEBUG"] === "true";
90465
+ const infraLevel = moleculerDebug ? "debug" : "error";
90466
+ const wildcardLevel = moleculerDebug ? "debug" : logLevel;
91908
90467
  if (mode === "test") return new ServiceBroker({
91909
90468
  nodeID,
91910
90469
  transporter: "Fake",
@@ -91933,17 +90492,19 @@ function createBroker(config) {
91933
90492
  useHostname,
91934
90493
  udpDiscovery: true,
91935
90494
  udpPort,
91936
- udpPeriod: 5
90495
+ udpPeriod: 5,
90496
+ debug: moleculerDebug
91937
90497
  }
91938
90498
  },
91939
90499
  logger: {
91940
90500
  type: "Console",
91941
90501
  options: { level: {
91942
- BROKER: "error",
91943
- TRANSPORTER: "error",
91944
- REGISTRY: "error",
91945
- DISCOVERER: "error",
91946
- "**": logLevel
90502
+ BROKER: infraLevel,
90503
+ TRANSPORTER: infraLevel,
90504
+ TRANSIT: infraLevel,
90505
+ REGISTRY: infraLevel,
90506
+ DISCOVERER: infraLevel,
90507
+ "**": wildcardLevel
91947
90508
  } }
91948
90509
  },
91949
90510
  metrics: metricsConfig
@@ -91951,7 +90512,8 @@ function createBroker(config) {
91951
90512
  const tcpOptions = {
91952
90513
  maxPacketSize: 10 * 1024 * 1024,
91953
90514
  port: config.agentListenPort ?? deriveAgentListenPort(nodeID),
91954
- useHostname
90515
+ useHostname,
90516
+ debug: moleculerDebug
91955
90517
  };
91956
90518
  if (hubAddress) {
91957
90519
  tcpOptions.urls = normalizeHubUrl(hubAddress, tcpPort);
@@ -91972,11 +90534,12 @@ function createBroker(config) {
91972
90534
  logger: {
91973
90535
  type: "Console",
91974
90536
  options: { level: {
91975
- BROKER: "error",
91976
- TRANSPORTER: "error",
91977
- REGISTRY: "error",
91978
- DISCOVERER: "error",
91979
- "**": logLevel
90537
+ BROKER: infraLevel,
90538
+ TRANSPORTER: infraLevel,
90539
+ TRANSIT: infraLevel,
90540
+ REGISTRY: infraLevel,
90541
+ DISCOVERER: infraLevel,
90542
+ "**": wildcardLevel
91980
90543
  } }
91981
90544
  },
91982
90545
  metrics: metricsConfig
@@ -93182,6 +91745,409 @@ var RingBuffer = class {
93182
91745
  }
93183
91746
  };
93184
91747
  //#endregion
91748
+ //#region src/kernel/lifecycle/job-journal.ts
91749
+ var JobJournal = class {
91750
+ jobsDir;
91751
+ indexPath;
91752
+ constructor(jobsDir) {
91753
+ this.jobsDir = jobsDir;
91754
+ this.indexPath = node_path.join(jobsDir, "index.json");
91755
+ }
91756
+ jobPath(id) {
91757
+ return node_path.join(this.jobsDir, `${id}.json`);
91758
+ }
91759
+ writeAtomic(filePath, data) {
91760
+ node_fs.mkdirSync(node_path.dirname(filePath), { recursive: true });
91761
+ const tmp = `${filePath}.tmp.${process.pid}.${Date.now()}`;
91762
+ node_fs.writeFileSync(tmp, JSON.stringify(data, null, 2), {
91763
+ encoding: "utf-8",
91764
+ mode: 384
91765
+ });
91766
+ node_fs.renameSync(tmp, filePath);
91767
+ }
91768
+ readIndex() {
91769
+ try {
91770
+ const raw = JSON.parse(node_fs.readFileSync(this.indexPath, "utf-8"));
91771
+ if (raw && Array.isArray(raw.jobIds)) return {
91772
+ version: 1,
91773
+ jobIds: raw.jobIds
91774
+ };
91775
+ } catch {}
91776
+ return {
91777
+ version: 1,
91778
+ jobIds: []
91779
+ };
91780
+ }
91781
+ addToIndex(id) {
91782
+ const idx = this.readIndex();
91783
+ if (idx.jobIds.includes(id)) return;
91784
+ this.writeAtomic(this.indexPath, {
91785
+ version: 1,
91786
+ jobIds: [...idx.jobIds, id]
91787
+ });
91788
+ }
91789
+ createJob(job) {
91790
+ this.writeAtomic(this.jobPath(job.jobId), job);
91791
+ this.addToIndex(job.jobId);
91792
+ }
91793
+ getJob(id) {
91794
+ try {
91795
+ const parsed = _camstack_types.lifecycleJobSchema.safeParse(JSON.parse(node_fs.readFileSync(this.jobPath(id), "utf-8")));
91796
+ return parsed.success ? parsed.data : null;
91797
+ } catch {
91798
+ return null;
91799
+ }
91800
+ }
91801
+ listJobs(opts) {
91802
+ const out = [];
91803
+ for (const id of this.readIndex().jobIds) {
91804
+ const j = this.getJob(id);
91805
+ if (j && (!opts?.activeOnly || j.state === "running")) out.push(j);
91806
+ }
91807
+ return out;
91808
+ }
91809
+ mutate(id, fn) {
91810
+ const job = this.getJob(id);
91811
+ if (!job) throw new Error(`JobJournal: job '${id}' not found`);
91812
+ const next = fn(job);
91813
+ this.writeAtomic(this.jobPath(id), next);
91814
+ return next;
91815
+ }
91816
+ patchTask(jobId, taskId, patch) {
91817
+ return this.mutate(jobId, (j) => ({
91818
+ ...j,
91819
+ tasks: j.tasks.map((t) => t.taskId === taskId ? {
91820
+ ...t,
91821
+ ...patch
91822
+ } : t)
91823
+ }));
91824
+ }
91825
+ appendLog(jobId, taskId, entry) {
91826
+ return this.mutate(jobId, (j) => ({
91827
+ ...j,
91828
+ tasks: j.tasks.map((t) => t.taskId === taskId ? {
91829
+ ...t,
91830
+ steps: [...t.steps, entry]
91831
+ } : t)
91832
+ }));
91833
+ }
91834
+ setJobState(jobId, state) {
91835
+ return this.mutate(jobId, (j) => ({
91836
+ ...j,
91837
+ state
91838
+ }));
91839
+ }
91840
+ };
91841
+ //#endregion
91842
+ //#region src/kernel/lifecycle/staging-area.ts
91843
+ function safeSegment$1(name) {
91844
+ return name.replace(/[^a-zA-Z0-9._-]/g, "_");
91845
+ }
91846
+ var StagingArea = class {
91847
+ stagingDir;
91848
+ deps;
91849
+ constructor(stagingDir, deps) {
91850
+ this.stagingDir = stagingDir;
91851
+ this.deps = deps;
91852
+ }
91853
+ async fetchAndStage(input) {
91854
+ const destDir = node_path.join(this.stagingDir, input.jobId, safeSegment$1(input.name));
91855
+ node_fs.rmSync(destDir, {
91856
+ recursive: true,
91857
+ force: true
91858
+ });
91859
+ const tgz = await this.deps.fetchTarball(input.name, input.version, input.signal);
91860
+ if (input.signal.aborted) throw new Error("staging aborted after fetch");
91861
+ await this.deps.extract(tgz, destDir);
91862
+ const raw = JSON.parse(node_fs.readFileSync(node_path.join(destDir, "package.json"), "utf-8"));
91863
+ if (raw.version !== input.version) throw new Error(`staging validation failed: ${input.name} expected version ${input.version}, got ${String(raw.version)}`);
91864
+ return { stagedPath: destDir };
91865
+ }
91866
+ cleanup(jobId) {
91867
+ node_fs.rmSync(node_path.join(this.stagingDir, jobId), {
91868
+ recursive: true,
91869
+ force: true
91870
+ });
91871
+ }
91872
+ };
91873
+ //#endregion
91874
+ //#region src/kernel/lifecycle/lifecycle-job-engine.ts
91875
+ var DEFAULT_FETCH_TIMEOUT_MS = 6e4;
91876
+ var DEFAULT_FETCH_CONCURRENCY = 3;
91877
+ var LifecycleJobEngine = class {
91878
+ deps;
91879
+ constructor(deps) {
91880
+ this.deps = deps;
91881
+ }
91882
+ advance(jobId, task, phase, patch = {}) {
91883
+ this.deps.journal.patchTask(jobId, task.taskId, {
91884
+ phase,
91885
+ ...patch
91886
+ });
91887
+ const entry = {
91888
+ tsMs: this.deps.now(),
91889
+ nodeId: task.nodeId,
91890
+ packageName: task.packageName,
91891
+ phase,
91892
+ message: `${task.packageName} → ${phase}`
91893
+ };
91894
+ const job = this.deps.journal.appendLog(jobId, task.taskId, entry);
91895
+ this.deps.emit("progress", job);
91896
+ this.deps.emit("log", job, entry);
91897
+ return job;
91898
+ }
91899
+ /**
91900
+ * Fetch + stage a single addon task (advancing it to `staged`), wrapped in a
91901
+ * per-task abort timeout. On success the resolved `stagedPath` is returned; on
91902
+ * failure the task is marked `failed` and `null` is returned (so the apply
91903
+ * phase skips it). Other tasks are unaffected.
91904
+ */
91905
+ async fetchAddonTask(job, task) {
91906
+ try {
91907
+ this.advance(job.jobId, task, "fetching", {
91908
+ startedAtMs: this.deps.now(),
91909
+ attempts: task.attempts + 1
91910
+ });
91911
+ const ac = new AbortController();
91912
+ const timer = setTimeout(() => ac.abort(), this.deps.fetchTimeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS);
91913
+ let stagedPath;
91914
+ try {
91915
+ stagedPath = (await this.deps.staging.fetchAndStage({
91916
+ jobId: job.jobId,
91917
+ name: task.packageName,
91918
+ version: task.toVersion,
91919
+ signal: ac.signal
91920
+ })).stagedPath;
91921
+ } finally {
91922
+ clearTimeout(timer);
91923
+ }
91924
+ this.advance(job.jobId, task, "staged", { stagedPath });
91925
+ return {
91926
+ task,
91927
+ stagedPath
91928
+ };
91929
+ } catch (err) {
91930
+ this.advance(job.jobId, task, "failed", {
91931
+ error: err instanceof Error ? err.message : String(err),
91932
+ finishedAtMs: this.deps.now()
91933
+ });
91934
+ return {
91935
+ task,
91936
+ stagedPath: null
91937
+ };
91938
+ }
91939
+ }
91940
+ /**
91941
+ * Apply a single already-staged addon task serially:
91942
+ * `validating` → `applying` → applyAddonUpdate → `restarting` → `done`.
91943
+ * Returns true on success, false if the apply throws (task marked `failed`).
91944
+ */
91945
+ async applyAddonTask(job, task, stagedPath) {
91946
+ try {
91947
+ this.advance(job.jobId, task, "validating");
91948
+ this.advance(job.jobId, task, "applying");
91949
+ await this.deps.applyAddonUpdate({
91950
+ name: task.packageName,
91951
+ version: task.toVersion,
91952
+ stagedPath
91953
+ });
91954
+ this.advance(job.jobId, task, "restarting");
91955
+ this.advance(job.jobId, task, "done", { finishedAtMs: this.deps.now() });
91956
+ return true;
91957
+ } catch (err) {
91958
+ this.advance(job.jobId, task, "failed", {
91959
+ error: err instanceof Error ? err.message : String(err),
91960
+ finishedAtMs: this.deps.now()
91961
+ });
91962
+ return false;
91963
+ }
91964
+ }
91965
+ /**
91966
+ * Run the framework task: stage lockstep → `staged` → requestFrameworkSwap.
91967
+ * In production the process exits after requestFrameworkSwap and the reboot
91968
+ * finalizes the job, so this returns the current durable job WITHOUT
91969
+ * finalization. Returns null only if the framework deps are not wired (the
91970
+ * task is marked `failed` and the caller finalizes the job).
91971
+ */
91972
+ async runFrameworkTask(job, task) {
91973
+ const { stageFramework, requestFrameworkSwap } = this.deps;
91974
+ if (stageFramework === void 0 || requestFrameworkSwap === void 0) {
91975
+ this.advance(job.jobId, task, "failed", {
91976
+ error: "framework swap deps not wired",
91977
+ finishedAtMs: this.deps.now()
91978
+ });
91979
+ return null;
91980
+ }
91981
+ try {
91982
+ this.advance(job.jobId, task, "fetching", {
91983
+ startedAtMs: this.deps.now(),
91984
+ attempts: task.attempts + 1
91985
+ });
91986
+ const ac = new AbortController();
91987
+ const timer = setTimeout(() => ac.abort(), this.deps.fetchTimeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS);
91988
+ let packages;
91989
+ try {
91990
+ packages = await stageFramework(task, ac.signal);
91991
+ } finally {
91992
+ clearTimeout(timer);
91993
+ }
91994
+ if (packages.length === 0) throw new Error("stageFramework returned no packages");
91995
+ const [firstPackage] = packages;
91996
+ this.advance(job.jobId, task, "staged", { stagedPath: firstPackage.stagedPath });
91997
+ requestFrameworkSwap({
91998
+ jobId: job.jobId,
91999
+ taskId: task.taskId,
92000
+ packages
92001
+ });
92002
+ return this.deps.journal.getJob(job.jobId) ?? job;
92003
+ } catch (err) {
92004
+ this.advance(job.jobId, task, "failed", {
92005
+ error: err instanceof Error ? err.message : String(err),
92006
+ finishedAtMs: this.deps.now()
92007
+ });
92008
+ return null;
92009
+ }
92010
+ }
92011
+ /**
92012
+ * Run the addon fetch phase with a bounded-concurrency worker pool. At most
92013
+ * `fetchConcurrency` fetches are in flight at once; completion order may vary
92014
+ * but the returned outcomes preserve the input task order.
92015
+ */
92016
+ async fetchAddonsBounded(job, addonTasks) {
92017
+ const limit = Math.max(1, this.deps.fetchConcurrency ?? DEFAULT_FETCH_CONCURRENCY);
92018
+ const outcomes = new Array(addonTasks.length);
92019
+ let nextIndex = 0;
92020
+ const worker = async () => {
92021
+ for (;;) {
92022
+ const index = nextIndex;
92023
+ nextIndex += 1;
92024
+ if (index >= addonTasks.length) return;
92025
+ outcomes[index] = await this.fetchAddonTask(job, addonTasks[index]);
92026
+ }
92027
+ };
92028
+ const workerCount = Math.min(limit, addonTasks.length);
92029
+ await Promise.all(Array.from({ length: workerCount }, () => worker()));
92030
+ return outcomes.filter((o) => o !== void 0);
92031
+ }
92032
+ /**
92033
+ * §10 boot reconcile: re-drive every NON-TERMINAL addon task of a job that
92034
+ * was interrupted mid-flight (e.g. a crash) from its on-disk checkpoint.
92035
+ *
92036
+ * Framework tasks are LEFT UNTOUCHED — they are owned by the F2
92037
+ * `resumeFrameworkSwapJob` path (which marks `applied`→`done` on a healthy
92038
+ * reboot). Terminal addon tasks (`done`/`failed`/`skipped`) are skipped.
92039
+ *
92040
+ * Apply is idempotent (`applyAddonUpdate` backs up the live dir + restores on
92041
+ * failure), so every non-terminal addon phase collapses to:
92042
+ * ensure staged (reuse a still-valid `stagedPath` or re-fetch) → apply → done;
92043
+ * on failure → `failed`.
92044
+ *
92045
+ * The job is finalized (`completed`/`partially-failed`/`failed` + staging
92046
+ * cleanup) ONLY when ALL tasks — including any framework task — are terminal.
92047
+ * If a framework task is still non-terminal the job is LEFT `running` (the
92048
+ * reboot/F2 path finalizes it).
92049
+ */
92050
+ async reconcileJob(job) {
92051
+ const exists = this.deps.stagedPathExists ?? ((p) => node_fs.existsSync(p));
92052
+ for (const task of job.tasks) {
92053
+ if (task.target === "framework") continue;
92054
+ if (this.isTerminal(task.phase)) continue;
92055
+ await this.reconcileAddonTask(job, task, exists);
92056
+ }
92057
+ return this.finalizeReconciledJob(job.jobId);
92058
+ }
92059
+ isTerminal(phase) {
92060
+ return phase === "done" || phase === "failed" || phase === "skipped";
92061
+ }
92062
+ /**
92063
+ * Re-drive a single non-terminal addon task: reuse a still-valid `stagedPath`
92064
+ * when present (idempotent re-apply), otherwise re-fetch + stage, then apply.
92065
+ */
92066
+ async reconcileAddonTask(job, task, exists) {
92067
+ let stagedPath = null;
92068
+ if (task.stagedPath !== null && exists(task.stagedPath)) stagedPath = task.stagedPath;
92069
+ else stagedPath = (await this.fetchAddonTask(job, task)).stagedPath;
92070
+ if (stagedPath === null) return;
92071
+ await this.applyAddonTask(job, task, stagedPath);
92072
+ }
92073
+ /**
92074
+ * Finalize a reconciled job: `completed` if all addon tasks succeeded,
92075
+ * `failed` if all failed, `partially-failed` if mixed — but ONLY when every
92076
+ * task (including framework) is terminal. If any task is still non-terminal
92077
+ * (a framework task pending its reboot resume), leave the job `running`.
92078
+ */
92079
+ finalizeReconciledJob(jobId) {
92080
+ const current = this.deps.journal.getJob(jobId);
92081
+ if (current === null) throw new Error(`LifecycleJobEngine: job '${jobId}' vanished during reconcile`);
92082
+ if (!current.tasks.every((t) => this.isTerminal(t.phase))) return current;
92083
+ const anyFailed = current.tasks.some((t) => t.phase === "failed");
92084
+ const allFailed = current.tasks.every((t) => t.phase === "failed");
92085
+ const state = !anyFailed ? "completed" : allFailed ? "failed" : "partially-failed";
92086
+ const finalJob = this.deps.journal.setJobState(jobId, state);
92087
+ this.deps.staging.cleanup(jobId);
92088
+ return finalJob;
92089
+ }
92090
+ async runJob(job) {
92091
+ const addonTasks = job.tasks.filter((t) => t.target !== "framework");
92092
+ const frameworkTasks = job.tasks.filter((t) => t.target === "framework");
92093
+ let failures = 0;
92094
+ let successes = 0;
92095
+ const fetchOutcomes = await this.fetchAddonsBounded(job, addonTasks);
92096
+ for (const outcome of fetchOutcomes) if (outcome.stagedPath === null) failures += 1;
92097
+ for (const outcome of fetchOutcomes) {
92098
+ if (outcome.stagedPath === null) continue;
92099
+ if (await this.applyAddonTask(job, outcome.task, outcome.stagedPath)) successes += 1;
92100
+ else failures += 1;
92101
+ }
92102
+ for (const task of frameworkTasks) {
92103
+ const result = await this.runFrameworkTask(job, task);
92104
+ if (result !== null) return result;
92105
+ failures += 1;
92106
+ }
92107
+ const state = failures === 0 ? "completed" : successes === 0 ? "failed" : "partially-failed";
92108
+ const finalJob = this.deps.journal.setJobState(job.jobId, state);
92109
+ this.deps.staging.cleanup(job.jobId);
92110
+ return finalJob;
92111
+ }
92112
+ };
92113
+ //#endregion
92114
+ //#region src/kernel/lifecycle/framework-staging.ts
92115
+ var FRAMEWORK_LOCKSTEP = [
92116
+ "@camstack/system",
92117
+ "@camstack/types",
92118
+ "@camstack/sdk",
92119
+ "@camstack/shm-ring"
92120
+ ];
92121
+ function safeSegment(name) {
92122
+ return name.replace(/[^a-zA-Z0-9._-]/g, "_");
92123
+ }
92124
+ async function stageFrameworkLockstep(input) {
92125
+ const stagingArea = new StagingArea(input.stagingDir, {
92126
+ fetchTarball: input.fetchTarball,
92127
+ extract: input.extract
92128
+ });
92129
+ const results = [];
92130
+ for (const pkg of FRAMEWORK_LOCKSTEP) {
92131
+ const version = await input.resolveVersion(pkg);
92132
+ const { stagedPath } = await stagingArea.fetchAndStage({
92133
+ jobId: input.jobId,
92134
+ name: pkg,
92135
+ version,
92136
+ signal: input.signal
92137
+ });
92138
+ const backupPath = node_path.join(input.stagingDir, input.jobId, ".bak-fw", safeSegment(pkg));
92139
+ const fromVersion = input.currentVersionOf(pkg);
92140
+ results.push({
92141
+ name: pkg,
92142
+ stagedPath,
92143
+ backupPath,
92144
+ toVersion: version,
92145
+ fromVersion
92146
+ });
92147
+ }
92148
+ return results;
92149
+ }
92150
+ //#endregion
93185
92151
  exports.AGENT_CAP_FWD_ACTION = require_manifest_python_deps.AGENT_CAP_FWD_ACTION;
93186
92152
  exports.AGENT_CAP_FWD_SERVICE = require_manifest_python_deps.AGENT_CAP_FWD_SERVICE;
93187
92153
  exports.AddonApiFactory = AddonApiFactory;
@@ -93217,6 +92183,7 @@ exports.DeviceStore = require_builtins_sqlite_storage_index.DeviceStore$1;
93217
92183
  exports.EVENT_TOPIC_PREFIX = require_manifest_python_deps.EVENT_TOPIC_PREFIX;
93218
92184
  exports.EngineManagerResolver = EngineManagerResolver;
93219
92185
  exports.EventBus = EventBus;
92186
+ exports.FRAMEWORK_LOCKSTEP = FRAMEWORK_LOCKSTEP;
93220
92187
  exports.FeatureManager = FeatureManager;
93221
92188
  exports.FilesystemStorageAddon = require_builtins_sqlite_storage_filesystem_storage_addon.FilesystemStorageAddon;
93222
92189
  exports.FilesystemStorageProvider = require_builtins_sqlite_storage_filesystem_storage_addon.FilesystemStorageProvider;
@@ -93231,6 +92198,8 @@ exports.HubLogForwarder = HubLogForwarder;
93231
92198
  exports.HubNodeRegistry = HubNodeRegistry;
93232
92199
  exports.INFRA_CAPABILITIES = INFRA_CAPABILITIES;
93233
92200
  exports.IntegrationRegistry = IntegrationRegistry;
92201
+ exports.JobJournal = JobJournal;
92202
+ exports.LifecycleJobEngine = LifecycleJobEngine;
93234
92203
  exports.LifecycleStateMachine = LifecycleStateMachine;
93235
92204
  exports.LocalAuthAddon = require_builtins_local_auth_local_auth_addon.LocalAuthAddon;
93236
92205
  exports.LocalChildClient = require_manifest_python_deps.LocalChildClient;
@@ -93278,6 +92247,7 @@ exports.ScopedTokenManager = require_builtins_local_auth_local_auth_addon.Scoped
93278
92247
  exports.SocketChannel = require_manifest_python_deps.SocketChannel;
93279
92248
  exports.SqliteSettingsAddon = require_builtins_sqlite_storage_sqlite_settings_addon.SqliteSettingsAddon;
93280
92249
  exports.SqliteSettingsBackend = require_builtins_sqlite_storage_sqlite_settings_addon.SqliteSettingsBackend;
92250
+ exports.StagingArea = StagingArea;
93281
92251
  exports.StorageLocationManager = StorageLocationManager;
93282
92252
  exports.StorageManager = StorageManager;
93283
92253
  exports.StorageOrchestratorAddon = require_builtins_storage_orchestrator_storage_orchestrator_addon.StorageOrchestratorAddon;
@@ -93418,7 +92388,7 @@ exports.getRestartMarkerPath = getRestartMarkerPath;
93418
92388
  exports.getSinglePidStats = require_resource_monitor.getSinglePidStats;
93419
92389
  exports.getWorkerDeviceRegistry = require_manifest_python_deps.getWorkerDeviceRegistry;
93420
92390
  exports.hashClusterSecret = hashClusterSecret;
93421
- exports.installManifestNativeDeps = installManifestNativeDeps;
92391
+ exports.installManifestNativeDeps = require_manifest_python_deps.installManifestNativeDeps;
93422
92392
  exports.installManifestPythonDeps = require_manifest_python_deps.installManifestPythonDeps;
93423
92393
  exports.installPackageFromNpmSync = installPackageFromNpmSync;
93424
92394
  Object.defineProperty(exports, "installPythonPackages", {
@@ -93455,18 +92425,6 @@ Object.defineProperty(exports, "readinessKey", {
93455
92425
  }
93456
92426
  });
93457
92427
  exports.registerEventBusService = require_manifest_python_deps.registerEventBusService;
93458
- Object.defineProperty(exports, "require_graceful_fs", {
93459
- enumerable: true,
93460
- get: function() {
93461
- return require_graceful_fs;
93462
- }
93463
- });
93464
- Object.defineProperty(exports, "require_src", {
93465
- enumerable: true,
93466
- get: function() {
93467
- return require_src;
93468
- }
93469
- });
93470
92428
  exports.resolveFilePath = resolveFilePath;
93471
92429
  exports.resolveHwAccel = require_manifest_python_deps.resolveHwAccel;
93472
92430
  exports.scheduleSelfRestart = scheduleSelfRestart;
@@ -93479,6 +92437,7 @@ Object.defineProperty(exports, "scopeKey", {
93479
92437
  exports.scopesAllowDeviceCap = scopesAllowDeviceCap;
93480
92438
  exports.serializeTypedArrays = require_manifest_python_deps.serializeTypedArrays;
93481
92439
  exports.setHubConnected = require_manifest_python_deps.setHubConnected;
92440
+ exports.stageFrameworkLockstep = stageFrameworkLockstep;
93482
92441
  exports.stripCamstackDeps = stripCamstackDeps;
93483
92442
  exports.udsChildLogToWorkerEntry = require_manifest_python_deps.udsChildLogToWorkerEntry;
93484
92443
  exports.validateProviderRegistrations = require_manifest_python_deps.validateProviderRegistrations;