@camstack/server 1.2.928 → 1.2.930
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/package.json +10 -10
- package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
- package/system/dist/addon-id-Di0lNJ89.js +50 -0
- package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
- package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
- package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
- package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
- package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
- package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
- package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
- package/system/dist/base-device-2sL1DMm1.js +1103 -0
- package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +6 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +7 -5
- package/system/dist/builtins/alerts/alerts.addon.js +113 -56
- package/system/dist/builtins/alerts/alerts.addon.mjs +60 -3
- package/system/dist/builtins/autotrack/index.js +21 -17
- package/system/dist/builtins/autotrack/index.mjs +5 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +8 -5
- package/system/dist/builtins/calendars/calendars.addon.js +8 -6
- package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
- package/system/dist/builtins/camera-grid/index.js +615 -58
- package/system/dist/builtins/camera-grid/index.mjs +558 -1
- package/system/dist/builtins/composer/composer.addon.js +788 -209
- package/system/dist/builtins/composer/composer.addon.mjs +583 -4
- package/system/dist/builtins/console-logging/index.js +4 -3
- package/system/dist/builtins/console-logging/index.mjs +2 -1
- package/system/dist/builtins/core-blocks/actions-service.d.ts +18 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +8670 -386
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +8294 -11
- package/system/dist/builtins/core-blocks/tcp-connect.d.ts +3 -0
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +250 -21
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +230 -1
- package/system/dist/builtins/device-history/device-history.addon.js +110 -31
- package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
- package/system/dist/builtins/hub-forwarder/index.js +4 -3
- package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
- package/system/dist/builtins/keychain/index.js +31 -28
- package/system/dist/builtins/keychain/index.mjs +7 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +106 -6
- package/system/dist/builtins/local-network/local-network.addon.js +43 -39
- package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
- package/system/dist/builtins/loki-logging/index.js +23 -17
- package/system/dist/builtins/loki-logging/index.mjs +7 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +151 -10
- package/system/dist/builtins/platform-probe/index.js +25 -23
- package/system/dist/builtins/platform-probe/index.mjs +12 -10
- package/system/dist/builtins/record-entries/index.js +9 -7
- package/system/dist/builtins/record-entries/index.mjs +3 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +97 -44
- package/system/dist/builtins/snapshot/index.mjs +54 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +21 -20
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +87 -61
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
- package/system/dist/builtins/system-config/system-config.addon.js +17 -14
- package/system/dist/builtins/system-config/system-config.addon.mjs +118 -115
- package/system/dist/builtins/winston-logging/index.js +7 -5
- package/system/dist/builtins/winston-logging/index.mjs +3 -1
- package/system/dist/calendars.cap-CaFlShS9.js +155 -0
- package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
- package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
- package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
- package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
- package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
- package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
- package/system/dist/capability-definition-HCmTem8c.js +242 -0
- package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
- package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
- package/system/dist/command-origin-claim-Cief660O.js +35 -0
- package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
- package/system/dist/composition-sources-BEUWn2s_.mjs +391 -0
- package/system/dist/composition-sources-acfR4hDq.js +408 -0
- package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
- package/system/dist/constants-C860Y6U4.js +26 -0
- package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
- package/system/dist/constants-DCLpoF4L.mjs +21 -0
- package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
- package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
- package/system/dist/core-blocks.cap-BMeMCBrx.js +18733 -0
- package/system/dist/core-blocks.cap-BRPsLAij.mjs +18008 -0
- package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
- package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
- package/system/dist/custom-actions-D92NRi2c.js +36 -0
- package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
- package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
- package/system/dist/declared-device-BWphj9WE.js +303 -0
- package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
- package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
- package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
- package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
- package/system/dist/device-certificate-CguVACQO.js +162 -0
- package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
- package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
- package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
- package/system/dist/device-kind-CsSiv_YF.js +101 -0
- package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
- package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
- package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
- package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
- package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
- package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
- package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
- package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
- package/system/dist/device-type-CbQsnFdC.js +477 -0
- package/system/dist/device-type-DgEvK3ch.mjs +454 -0
- package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
- package/system/dist/entry-kind-cq90c--V.js +55 -0
- package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
- package/system/dist/error.cap-DBhgPeWK.js +3848 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/history-catalog-BKRarIL_.js +831 -0
- package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
- package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
- package/system/dist/{hub-identity-CYC1820R.mjs → hub-identity-DjMN9Ac2.mjs} +10 -10
- package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
- package/system/dist/{hub-mdns-ciao-CCDxM5qz.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
- package/system/dist/index.js +763 -151
- package/system/dist/index.mjs +832 -220
- package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
- package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
- package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
- package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
- package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
- package/system/dist/l10n-CGMvp7NF.js +15 -0
- package/system/dist/labels-DX5S8deC.js +81 -0
- package/system/dist/labels-DsBcU7md.mjs +64 -0
- package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
- package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
- package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
- package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
- package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
- package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
- package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
- package/system/dist/mask-shape-CmPA2fst.js +92 -0
- package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
- package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
- package/system/dist/migration-BMjgkyG2.js +380 -0
- package/system/dist/migration-DRJAtdy7.mjs +321 -0
- package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
- package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
- package/system/dist/notification-rules.cap-BDh0LDhV.js +3428 -0
- package/system/dist/notification-rules.cap-DUmiMBQB.mjs +3357 -0
- package/system/dist/notification-targets-CRH-9Dy5.js +509 -0
- package/system/dist/notification-targets-DaNE-pIt.mjs +486 -0
- package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
- package/system/dist/ops-log-pxt9176Z.js +81 -0
- package/system/dist/pinned-binary-BOhOSNff.js +28 -0
- package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
- package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
- package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
- package/system/dist/prefix-walk-BkMxoXpL.js +843 -0
- package/system/dist/prefix-walk-ifwg_ukx.mjs +790 -0
- package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
- package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
- package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
- package/system/dist/quantity-lY1KiTSZ.js +143 -0
- package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
- package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
- package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
- package/system/dist/record-entries.cap-ti1C046R.js +80 -0
- package/system/dist/record-kind-DoBfYHCs.js +203 -0
- package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
- package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
- package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
- package/system/dist/records.cap-ClcWV64i.js +329 -0
- package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
- package/system/dist/relocate-CdVQAk-w.js +804 -0
- package/system/dist/relocate-CoZZTui1.mjs +661 -0
- package/system/dist/rename-composition-block-BJsL58Ih.js +34798 -0
- package/system/dist/rename-composition-block-OAtErZgq.mjs +33631 -0
- package/system/dist/{restore-archive-BJfyu0sG.mjs → restore-archive-CjAyKpgX.mjs} +96 -94
- package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
- package/system/dist/scoped-settings-CylSSq_8.js +955 -0
- package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
- package/system/dist/server-name-BIhLuHvX.mjs +35 -0
- package/system/dist/server-name-OALNvpqC.js +52 -0
- package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
- package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
- package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
- package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
- package/system/dist/source-info-DGB7SdB_.mjs +190 -0
- package/system/dist/source-info-DtWf4k2j.js +225 -0
- package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
- package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
- package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
- package/system/dist/storage-location-CTweDMZf.js +198 -0
- package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
- package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
- package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
- package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
- package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
- package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
- package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
- package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
- package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
- package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
- package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
- package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
- package/system/dist/system-reasons-Be_k1W8g.js +25 -0
- package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
- package/system/dist/tag-BxLazvVb.js +2138 -0
- package/system/dist/tag-uZBAq6ox.mjs +2073 -0
- package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
- package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
- package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
- package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
- package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
- package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
- package/system/dist/zod-secret-DS7mj1bk.js +78 -0
- package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
- package/system/package.json +1 -1
- package/system/dist/composition-sources-BI614LJx.mjs +0 -141
- package/system/dist/composition-sources-v_kkb8A9.js +0 -152
- package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
- package/system/dist/coral-accelerators-BW3OcrLD.mjs +0 -231
- package/system/dist/dist-BCHMSqzc.mjs +0 -143467
- package/system/dist/dist-BZfvhfS1.js +0 -146970
- package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
- package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
- package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
- package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
package/system/dist/index.mjs
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { i as __require } from "./chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { b as EventCategory$1, i as collectSecretMarkerRefs, p as createEvent$1 } from "./base-addon-Md14i7pe.mjs";
|
|
3
|
+
import { Z as errMsg$1 } from "./scoped-settings-DVWUIP7Z.mjs";
|
|
4
|
+
import { Un as lifecycleJobSchema, a as isCollectionArrayMethod, c as kebabToCamel$1, d as objectInputDeclaresRequiredDeviceId, dr as compareVersions, f as procedureAuthKey, fr as describeUnmet, i as isArrayOutputSchema, l as looseSchema, m as ALL_CAPABILITY_DEFINITIONS, o as isObjectInput, p as resolveMethodAuth, pr as unmetRequirements, r as extractNestedAddonId, s as isVoidInput, u as objectInputDeclaresAddonId, ur as PackageRequiresSchema } from "./rename-composition-block-OAtErZgq.mjs";
|
|
5
|
+
import { t as userError } from "./camstack-error-viZYfcj9.mjs";
|
|
6
|
+
import { a as expandCapMethods, n as DEVICE_STATUS_METHOD, t as DEVICE_SETTINGS_CONTRIBUTION_METHODS, u as resolveCapMount } from "./capability-definition-C2rJdVeX.mjs";
|
|
7
|
+
import { s as defineRecordKinds } from "./record-kind-ub6NXqfh.mjs";
|
|
8
|
+
import { D as RecordsEngine, J as asNumber, X as parseJsonObject, Y as asString$1, Z as parseJsonUnknown, l as SqliteSettingsBackend, q as asJsonObject$1 } from "./wal-maintenance-BG01rOn9.mjs";
|
|
9
|
+
import { f as AppPageLangSchema } from "./device-certificate-Cddm4Idn.mjs";
|
|
10
|
+
import { i as addonSettingsCapability } from "./addon-settings.cap-3-TIIMq_.mjs";
|
|
11
|
+
import { t as loadPrefixed } from "./prefix-walk-ifwg_ukx.mjs";
|
|
12
|
+
import { a as AGENT_MDNS_TXT_KEYS, i as AGENT_MDNS_SERVICE_TYPE } from "./network-access.cap-BJnGbE6n.mjs";
|
|
13
|
+
import { t as RUNTIME_DEFAULTS } from "./constants-DCLpoF4L.mjs";
|
|
14
|
+
import { t as bareAddonId } from "./addon-id-CVg1_r5E.mjs";
|
|
15
|
+
import { r as nodeCoralFs, s as supportedRuntimes, t as classifyCoralAccelerator } from "./coral-accelerators-BKcXP59c.mjs";
|
|
16
|
+
import { d as JWT_SIGNING_KEY_REF, f as JwtSigningKeyUnavailableError, g as processJwtSigningKey, i as generateDeviceCa, l as verifyDeviceLeaf, m as getProcessJwtSigningKeyState, n as DEVICE_CA_KEY_REF, o as issueDeviceLeaf, p as SYSTEM_SECRET_OWNER, s as loadDeviceCa, u as verifyDeviceSignature, v as staticJwtSigningKey } from "./device-ca-BLM6fccc.mjs";
|
|
4
17
|
import { t as require_read_all_rows } from "./read-all-rows-TaPqdWNF.mjs";
|
|
5
18
|
import { a as redactLogText, i as redactLogMeta, r as redactLogEntry, t as isCredentialKeyName } from "./log-redactor-XLDrPzOi.mjs";
|
|
6
19
|
import { AlertCenterAddon, n as lastCauseAfterChunk, r as readRunnerDisplayName, t as CRASH_BREAKER_ERROR_PREFIX } from "./builtins/alerts/alerts.addon.mjs";
|
|
@@ -11,47 +24,44 @@ import { ComposerAddon } from "./builtins/composer/composer.addon.mjs";
|
|
|
11
24
|
import "./builtins/composer/index.mjs";
|
|
12
25
|
import { t as formatLogLine } from "./formatter-DkYZ4LXp.mjs";
|
|
13
26
|
import { ConsoleDestination, ConsoleLoggingAddon } from "./builtins/console-logging/index.mjs";
|
|
14
|
-
import { t as loadPrefixed } from "./prefix-walk-DAOBSyH1.mjs";
|
|
15
27
|
import { n as readCurrentCommandOrigin, r as runWithCapCallContext, t as currentCapCallContext } from "./cap-call-scope-Bic6Ekfw.mjs";
|
|
16
28
|
import { CoreBlocksAddon, c as readUnscopedAddonSettings, o as clearNodeSettings, s as createAddonSettingsStore } from "./builtins/core-blocks/core-blocks.addon.mjs";
|
|
17
29
|
import "./builtins/core-blocks/index.mjs";
|
|
18
30
|
import { CoreNotifierAddon } from "./builtins/core-notifier/core-notifier.addon.mjs";
|
|
19
31
|
import "./builtins/core-notifier/index.mjs";
|
|
20
|
-
import { C as deviceIdOfArgs, D as createDeviceSettingsStore, DeviceManagerAddon, E as observable, O as readDeviceOrThrow, S as commandFollowUpTarget, T as withCommandFollowUp, _ as getCommandObserverRegistry, a as childRefreshSource, b as CommandFollowUpRegistry, c as IN_PROCESS_HOLD_SOURCE, d as getCommandHoldOverrideRegistry, f as CommandObserverRegistry, g as commandObserverLink, h as commandActorFromContext, i as __resetStateRefreshPolicyRegistryForTests, k as setWrapperActive, l as childCommandHoldEntries, m as addonCommandActor, o as childStateRefreshEntries, p as __resetCommandObserverRegistryForTests, r as StateRefreshPolicyRegistry, s as getStateRefreshPolicyRegistry, t as IN_PROCESS_REFRESH_SOURCE, u as childHoldSource, v as reportCommand, w as getCommandFollowUpRegistry, x as __resetCommandFollowUpRegistryForTests, y as runObservedCommand } from "./builtins/device-manager/device-manager.addon.mjs";
|
|
32
|
+
import { A as METHOD_ACCESS_MAP, C as deviceIdOfArgs, D as createDeviceSettingsStore, DeviceManagerAddon, E as observable, O as readDeviceOrThrow, S as commandFollowUpTarget, T as withCommandFollowUp, _ as getCommandObserverRegistry, a as childRefreshSource, b as CommandFollowUpRegistry, c as IN_PROCESS_HOLD_SOURCE, d as getCommandHoldOverrideRegistry, f as CommandObserverRegistry, g as commandObserverLink, h as commandActorFromContext, i as __resetStateRefreshPolicyRegistryForTests, k as setWrapperActive, l as childCommandHoldEntries, m as addonCommandActor, o as childStateRefreshEntries, p as __resetCommandObserverRegistryForTests, r as StateRefreshPolicyRegistry, s as getStateRefreshPolicyRegistry, t as IN_PROCESS_REFRESH_SOURCE, u as childHoldSource, v as reportCommand, w as getCommandFollowUpRegistry, x as __resetCommandFollowUpRegistryForTests, y as runObservedCommand } from "./builtins/device-manager/device-manager.addon.mjs";
|
|
21
33
|
import "./builtins/device-manager/index.mjs";
|
|
22
34
|
import { HubForwarderAddon, HubForwarderDestination } from "./builtins/hub-forwarder/index.mjs";
|
|
23
35
|
import { LivenessMonitorAddon } from "./builtins/liveness-monitor/liveness-monitor.addon.mjs";
|
|
24
36
|
import "./builtins/liveness-monitor/index.mjs";
|
|
25
|
-
import { LocalAuthAddon, _ as SettingsReadUnavailableError, a as attachUserManagementInternal, c as DeviceCaStore, d as onSessionsRevoked, f as DeviceCredentialManager, g as parseTokenExpiry, h as AuthManager, i as USER_MANAGEMENT_INTERNAL, l as LoginSessionManager, m as AuthAuditLog, n as FIRST_BOOT_ADMIN_USERNAME, o as getUserManagementInternal, p as PREVIOUS_LEAF_GRACE_MS, r as UserManager, s as preferencesLimitReasonOf, t as FIRST_BOOT_ADMIN_PASSWORD, u as REFRESH_TOKEN_PREFIX, v as isSettingsReadUnavailable } from "./builtins/local-auth/local-auth.addon.mjs";
|
|
37
|
+
import { LocalAuthAddon, _ as SettingsReadUnavailableError, a as attachUserManagementInternal, c as DeviceCaStore, d as onSessionsRevoked, f as DeviceCredentialManager, g as parseTokenExpiry, h as AuthManager, i as USER_MANAGEMENT_INTERNAL, l as LoginSessionManager, m as AuthAuditLog, n as FIRST_BOOT_ADMIN_USERNAME, o as getUserManagementInternal, p as PREVIOUS_LEAF_GRACE_MS, r as UserManager, s as preferencesLimitReasonOf, t as FIRST_BOOT_ADMIN_PASSWORD, u as REFRESH_TOKEN_PREFIX, v as isSettingsReadUnavailable, y as DATAPLANE_SECRET_HEADER$1 } from "./builtins/local-auth/local-auth.addon.mjs";
|
|
26
38
|
import "./builtins/local-auth/index.mjs";
|
|
27
39
|
import { a as lineContainsText, i as levelRank, n as compileLogFilter, o as lineMatches, r as filterIsEmpty, s as originNodeOf, t as bareAddonOf } from "./log-read-filter-D7Ev3zm-.mjs";
|
|
28
40
|
import { LokiDestination, LokiLoggingAddon } from "./builtins/loki-logging/index.mjs";
|
|
29
41
|
import NativeMetricsAddon, { a as NativeMetricsProvider, i as parseProcStatusRss, n as nodeProcReader, r as parseProcStat } from "./builtins/native-metrics/native-metrics.addon.mjs";
|
|
30
42
|
import { DeviceHistoryAddon } from "./builtins/device-history/device-history.addon.mjs";
|
|
31
43
|
import { FilesystemStorageAddon, t as FilesystemStorageProvider } from "./builtins/sqlite-storage/filesystem-storage.addon.mjs";
|
|
32
|
-
import {
|
|
33
|
-
import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-D9tQOUzh.mjs";
|
|
44
|
+
import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-nTvo_6jQ.mjs";
|
|
34
45
|
import { SqliteSettingsAddon } from "./builtins/sqlite-storage/sqlite-settings.addon.mjs";
|
|
35
46
|
import { ConfigStore, DeviceStore } from "./builtins/sqlite-storage/index.mjs";
|
|
36
47
|
import { StorageOrchestratorAddon, a as createHubCapForwardService, i as HUB_CAP_FWD_SERVICE, o as stripForwardedCaller, r as HUB_CAP_FWD_ACTION, s as buildStorageLocationRegistry, t as StorageOrchestratorService, u as storageOrchestratorRecordKinds } from "./builtins/storage-orchestrator/storage-orchestrator.addon.mjs";
|
|
37
48
|
import "./builtins/storage-orchestrator/index.mjs";
|
|
38
|
-
import { A as evaluateExistingCert, B as AGENT_HTTPS_NAMES_COLLECTION, C as localCaCommonName, D as LEAF_RENEWAL_WINDOW_DAYS, E as CA_VALIDITY_DAYS, F as isConstrainedCa, H as AgentHttpsNames, I as isLocalOnlyHostname, L as permitsIdentity, M as PERMITTED_DNS_SUFFIXES, N as PERMITTED_IP_RANGES, O as MAX_LEAF_VALIDITY_DAYS, P as buildNameConstraintSet, R as permitsName, T as systemHostFacts, U as getProcessAgentHttpsNames, V as AGENT_HTTPS_NAMES_COLUMNS, W as setProcessAgentHttpsNames, _ as pemDigest, a as AgentHttpsInstallError, c as certificateNames, d as describeHttpsLeaf, f as installAgentHttps, g as loadAgentHttps, h as issueAgentHttpsLeaf, i as loadOrCreateHubId, k as SERVER_AUTH_OID, l as collectAgentNames, m as isPrivateAddress, n as HUB_IDENTITY_RELATIVE, o as acceptAgentSans, p as isContainerBridgeAddress, r as isAnnouncedHubId, s as agentHttpsPaths, t as HUB_IDENTITY_FILE, u as createAgentHttpsRequest, v as pinnedHttpsCaFingerprint, w as collectCertIdentity, y as CA_COMMON_NAME, z as readNameConstraints } from "./hub-identity-
|
|
39
|
-
import { a as MESH_CA_KEY_REF, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY } from "./constants-
|
|
49
|
+
import { A as evaluateExistingCert, B as AGENT_HTTPS_NAMES_COLLECTION, C as localCaCommonName, D as LEAF_RENEWAL_WINDOW_DAYS, E as CA_VALIDITY_DAYS, F as isConstrainedCa, H as AgentHttpsNames, I as isLocalOnlyHostname, L as permitsIdentity, M as PERMITTED_DNS_SUFFIXES, N as PERMITTED_IP_RANGES, O as MAX_LEAF_VALIDITY_DAYS, P as buildNameConstraintSet, R as permitsName, T as systemHostFacts, U as getProcessAgentHttpsNames, V as AGENT_HTTPS_NAMES_COLUMNS, W as setProcessAgentHttpsNames, _ as pemDigest, a as AgentHttpsInstallError, c as certificateNames, d as describeHttpsLeaf, f as installAgentHttps, g as loadAgentHttps, h as issueAgentHttpsLeaf, i as loadOrCreateHubId, k as SERVER_AUTH_OID, l as collectAgentNames, m as isPrivateAddress, n as HUB_IDENTITY_RELATIVE, o as acceptAgentSans, p as isContainerBridgeAddress, r as isAnnouncedHubId, s as agentHttpsPaths, t as HUB_IDENTITY_FILE, u as createAgentHttpsRequest, v as pinnedHttpsCaFingerprint, w as collectCertIdentity, y as CA_COMMON_NAME, z as readNameConstraints } from "./hub-identity-DjMN9Ac2.mjs";
|
|
50
|
+
import { a as MESH_CA_KEY_REF, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY } from "./constants-DB4piTD5.mjs";
|
|
40
51
|
import { $ as getProcessMeshCaState, A as emitProcessNodeRegistered, At as readCidrSetting, B as getProcessMeshTlsListenerState, C as verifyMembershipAnswer, Ct as isInsecureOrigin, D as ServiceBroker, Dt as createCidrMatcher, E as Errors, Et as readOriginSetting, F as onProcessNodeRegistered, G as MeshCertificateRegistry, H as setProcessMeshTlsListenerState, I as setProcessMeshHandshakeReporter, J as getProcessMeshCertificateRegistry, K as RENEWAL_ABANDONED, L as setProcessMeshPeerTransportLookup, M as getProcessNodeMeshTransport, N as getProcessPeerLeaf, O as setProcessMeshTlsEnabler, Ot as normalizeIp, P as isProcessVerifiedMeshPeer, Q as MeshCaKeeper, R as renewMeshCertificate, S as signMembershipProof, St as OPAQUE_ORIGIN, SystemConfigAddon, T as TlsTcpTransporter, Tt as parseOriginList, U as MESH_NODE_CERTIFICATES_COLLECTION, V as openMeshTlsWhenRevocationsLoaded, W as MESH_NODE_CERTIFICATES_COLUMNS, X as MeshCrl, Y as setProcessMeshCertificateRegistry, Z as processMeshCrl, _ as keyFingerprintShort, _t as isAllowedAgentDashboardReturnTo, a as dialableHubHost, at as generateMeshCa, b as MEMBERSHIP_PATHS, bt as verifyAgentUiUnlockTicket, c as PAIRING_MAX_CODE_ATTEMPTS, ct as issueMeshLeafForNode, d as PAIRING_PIN_DIGITS, dt as AGENT_DASHBOARD_ORIGINS_FIELD, et as requireProcessMeshCa, f as PAIRING_PROTOCOL, ft as AGENT_UI_UNLOCK_TTL_MS, g as describeCsr, gt as UnlockTicketJtiStore, h as computePairingSas, ht as AGENT_UI_UNLOCK_VERSION, i as AgentPairing, it as exportMeshPrivateKeyPem, j as getProcessMeshHandshakeReporter, k as dropProcessPeer, kt as parseCidrList, l as PAIRING_MAX_SESSIONS, lt as issueMeshLeafFromCsr, m as computePairingCommitment, mt as AGENT_UI_UNLOCK_USE, n as HubPairing, nt as caFingerprintCompact, o as hubHostFromMeshAddress, ot as generateMeshKeyPair, p as PAIRING_TTL_MS, pt as AGENT_UI_UNLOCK_TYP, q as describeMeshLeaf, r as PairingHttpError, rt as createMeshCsrPem, s as PAIRING_CODE_DIGITS, st as isValidAgentNodeId, tt as caFingerprint, u as PAIRING_PATHS, ut as loadMeshCa, v as signPairingProof, vt as mintAgentUiUnlockTicket, w as MESH_TLS_PORT_HELLO_FIELD, wt as normalizeOrigin, x as MembershipResponder, xt as InvalidCorsOriginError, y as verifyPairingProof, yt as parseAgentDashboardOrigins, z as revokeMeshCertificate } from "./builtins/system-config/system-config.addon.mjs";
|
|
41
52
|
import "./builtins/system-config/index.mjs";
|
|
42
53
|
import { WinstonDestination, WinstonLoggingAddon } from "./builtins/winston-logging/index.mjs";
|
|
43
|
-
import { C as isModelDownloaded, E as setHuggingFaceReachabilityObserver, T as revisionWeightUrl, _ as downloadFile, a as startEventLoopStallMonitor, b as fetchJson, c as createAuthenticatedFileServer, d as resolveFilePath, f as ModelDownloadService, g as deleteModelFromDisk, h as collectModelFiles, i as attributeStall, l as parseRangeHeader, m as adoptModelRevisions, n as STALL_REPORT_MS, o as createFileDataPlaneHandler, r as STALL_TICK_MS, s as contentTypeFor, t as CustomActionRegistry, u as parseTokenizedUrl, v as downloadModel, w as resolveFormatRevision, x as getModelFilePath, y as ensureModel } from "./custom-action-registry-
|
|
44
|
-
import { A as retirePreviousLocalCa, C as checkUploadedCa, D as loadTlsCert, E as ensureTlsCert, F as closeLanHttp, I as readLanHttpState, L as registerLanHttpHandler, M as allFamiliesListenHost, N as applyLanHttp, O as reissueTlsLeaf, P as bindPendingLanHttp, S as chainsToPublicRoot, T as caReplacementMarkerFile, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, c as leafFingerprintOf, d as servedHttpsLeafFingerprint, f as prepareBootTls, g as readTlsEnabled, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, k as replaceUnconstrainedLocalCa, l as registerHttpsListener, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, p as UPLOADED_CA_FILE, r as regenerateCertificate, s as clearHttpsListener, t as createCiaoPublisher, u as reloadHttpsListener, v as splitPemCertificates, w as validateUploadedTls, x as writeTlsMode, y as writeExtraSans } from "./hub-mdns-ciao-
|
|
54
|
+
import { C as isModelDownloaded, E as setHuggingFaceReachabilityObserver, T as revisionWeightUrl, _ as downloadFile, a as startEventLoopStallMonitor, b as fetchJson, c as createAuthenticatedFileServer, d as resolveFilePath, f as ModelDownloadService, g as deleteModelFromDisk, h as collectModelFiles, i as attributeStall, l as parseRangeHeader, m as adoptModelRevisions, n as STALL_REPORT_MS, o as createFileDataPlaneHandler, r as STALL_TICK_MS, s as contentTypeFor, t as CustomActionRegistry, u as parseTokenizedUrl, v as downloadModel, w as resolveFormatRevision, x as getModelFilePath, y as ensureModel } from "./custom-action-registry-B9zFBNVa.mjs";
|
|
55
|
+
import { A as retirePreviousLocalCa, C as checkUploadedCa, D as loadTlsCert, E as ensureTlsCert, F as closeLanHttp, I as readLanHttpState, L as registerLanHttpHandler, M as allFamiliesListenHost, N as applyLanHttp, O as reissueTlsLeaf, P as bindPendingLanHttp, S as chainsToPublicRoot, T as caReplacementMarkerFile, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, c as leafFingerprintOf, d as servedHttpsLeafFingerprint, f as prepareBootTls, g as readTlsEnabled, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, k as replaceUnconstrainedLocalCa, l as registerHttpsListener, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, p as UPLOADED_CA_FILE, r as regenerateCertificate, s as clearHttpsListener, t as createCiaoPublisher, u as reloadHttpsListener, v as splitPemCertificates, w as validateUploadedTls, x as writeTlsMode, y as writeExtraSans } from "./hub-mdns-ciao-DBrtHOcc.mjs";
|
|
45
56
|
import { n as getPlatformKeychainKey, r as setPlatformKeychainKey, t as clearPlatformKeychainKey } from "./platform-key-source-BWlq0jjn.mjs";
|
|
46
57
|
import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-Di9daRwI.mjs";
|
|
47
|
-
import { _ as backupRecordStoresOf, c as BackupDecryptError, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, h as readBackupEncryptionHeader, l as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, t as BackupKeyRequiredError, u as BackupKeyMismatchError } from "./restore-archive-
|
|
48
|
-
import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-BW3OcrLD.mjs";
|
|
58
|
+
import { _ as backupRecordStoresOf, c as BackupDecryptError, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, h as readBackupEncryptionHeader, l as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, t as BackupKeyRequiredError, u as BackupKeyMismatchError } from "./restore-archive-CjAyKpgX.mjs";
|
|
49
59
|
import { z } from "zod";
|
|
50
60
|
import * as crypto$1 from "node:crypto";
|
|
51
61
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
52
62
|
import { PYTHON_VERSION, buildBinaryPath, declaresEdgetpuDelegate, downloadBinary, ensureBinary, ensureBinary as ensureBinary$1, ensureEdgetpuDelegate, ensureFfmpeg, ensureFfmpeg as ensureFfmpeg$1, ensurePython, ensurePython as ensurePython$1, findInPath, getFfmpegDownloadUrl, getPlatformInfo, getPythonDownloadUrl, implementedMethodsOf, installPythonPackages, installPythonPackages as installPythonPackages$1, installPythonRequirements, installPythonRequirements as installPythonRequirements$1 } from "@camstack/types/node";
|
|
53
63
|
import { connect, createConnection, createServer } from "node:net";
|
|
54
|
-
import * as fs from "node:fs";
|
|
64
|
+
import * as fs$1 from "node:fs";
|
|
55
65
|
import { accessSync, constants, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
|
|
56
66
|
import * as path$1 from "node:path";
|
|
57
67
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
@@ -71,6 +81,608 @@ import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
|
71
81
|
import * as vm from "node:vm";
|
|
72
82
|
import { TRPCClientError, createTRPCClient } from "@trpc/client";
|
|
73
83
|
import { noiseEventCategories } from "@camstack/types/enums";
|
|
84
|
+
//#region ../types/dist/esm/addon/addon-instance.mjs
|
|
85
|
+
/**
|
|
86
|
+
* The integration instance of an addon, as it appears in an address or on an
|
|
87
|
+
* OAuth link (planning#415, D1046).
|
|
88
|
+
*
|
|
89
|
+
* The DEFAULT instance has two spellings on the wire and one in the code: a
|
|
90
|
+
* path with no instance segment and a link with no instance both mean it, and
|
|
91
|
+
* its id is the addon id. {@link oauthLinkServesInstance} is the one
|
|
92
|
+
* comparison a per-instance route is meant to call, so nobody compares
|
|
93
|
+
* `undefined` with an id. The Alexa export's routes are its first caller.
|
|
94
|
+
*/
|
|
95
|
+
/** An instance id as it may appear in a path or a query: no separator, no escape, bounded. */
|
|
96
|
+
var ADDON_INSTANCE_ID_RE = /^[A-Za-z0-9._-]{1,64}$/;
|
|
97
|
+
function isAddonInstanceId(value) {
|
|
98
|
+
return ADDON_INSTANCE_ID_RE.test(value);
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region ../types/dist/esm/interfaces/logging.mjs
|
|
102
|
+
/**
|
|
103
|
+
* Severity ordering. Declared once here because it had already been re-declared
|
|
104
|
+
* three times independently (`kernel/transport/uds-logger.ts`,
|
|
105
|
+
* `builtins/loki-logging/loki-destination.ts`, and the log buffer) — four copies
|
|
106
|
+
* of the same four numbers is four chances for one of them to disagree.
|
|
107
|
+
*
|
|
108
|
+
* `uds-logger` keeps its own copy on purpose: it ranks a plain `string` coming off
|
|
109
|
+
* the wire and needs a tolerant fallback for an unknown value, which this typed
|
|
110
|
+
* map deliberately does not offer.
|
|
111
|
+
*/
|
|
112
|
+
var LOG_LEVEL_RANK = {
|
|
113
|
+
debug: 0,
|
|
114
|
+
info: 1,
|
|
115
|
+
warn: 2,
|
|
116
|
+
error: 3
|
|
117
|
+
};
|
|
118
|
+
/** True when `level` is no more severe than `threshold` — i.e. prunable/filterable. */
|
|
119
|
+
function logLevelAtMost(level, threshold) {
|
|
120
|
+
return LOG_LEVEL_RANK[level] <= LOG_LEVEL_RANK[threshold];
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region ../types/dist/esm/logging/debug-watch.mjs
|
|
124
|
+
/** Every debug channel's name starts with this; the ring denies it by default. */
|
|
125
|
+
var DEBUG_CHANNEL_PREFIX = "debug.";
|
|
126
|
+
function isDebugChannelName(name) {
|
|
127
|
+
return name.startsWith(DEBUG_CHANNEL_PREFIX);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Who is watching what, in THIS process. In-memory, moved off the log path.
|
|
131
|
+
*
|
|
132
|
+
* `active` is a plain boolean FIELD, read first: with no watch anywhere, a
|
|
133
|
+
* `ctx.debug` call is one load and one branch.
|
|
134
|
+
*/
|
|
135
|
+
var DebugInterest = class {
|
|
136
|
+
active = false;
|
|
137
|
+
windows = /* @__PURE__ */ new Map();
|
|
138
|
+
/**
|
|
139
|
+
* Replace the interest with the FULL set of windows. Non-debug windows are
|
|
140
|
+
* ignored and an absent one is dropped, so a lost disarm cannot leave a
|
|
141
|
+
* channel running.
|
|
142
|
+
*/
|
|
143
|
+
apply(windows, nowMs) {
|
|
144
|
+
this.windows.clear();
|
|
145
|
+
for (const window of windows) {
|
|
146
|
+
if (!isDebugChannelName(window.channel) || window.armedUntilMs <= nowMs) continue;
|
|
147
|
+
const ids = window.deviceIds;
|
|
148
|
+
this.windows.set(window.channel, {
|
|
149
|
+
untilMs: window.armedUntilMs,
|
|
150
|
+
devices: ids === null || ids.length === 0 ? null : new Set(ids)
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
this.active = this.windows.size > 0;
|
|
154
|
+
}
|
|
155
|
+
/** Drop what has lapsed. Called on a timer, never from a log path. */
|
|
156
|
+
tick(nowMs) {
|
|
157
|
+
const closed = [];
|
|
158
|
+
for (const [name, window] of this.windows) if (window.untilMs <= nowMs) {
|
|
159
|
+
this.windows.delete(name);
|
|
160
|
+
closed.push(name);
|
|
161
|
+
}
|
|
162
|
+
this.active = this.windows.size > 0;
|
|
163
|
+
return closed;
|
|
164
|
+
}
|
|
165
|
+
/** `channel` is the full name, `debug.<channel>`. */
|
|
166
|
+
wants(channel, deviceId) {
|
|
167
|
+
if (!this.active) return false;
|
|
168
|
+
const window = this.windows.get(channel);
|
|
169
|
+
if (window === void 0) return false;
|
|
170
|
+
return window.devices === null || window.devices.has(deviceId);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var interestInstance = null;
|
|
174
|
+
function getDebugInterest() {
|
|
175
|
+
interestInstance ??= new DebugInterest();
|
|
176
|
+
return interestInstance;
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region ../types/dist/esm/readiness/readiness-registry.mjs
|
|
180
|
+
var ReadinessTimeoutError = class extends Error {
|
|
181
|
+
capName;
|
|
182
|
+
scope;
|
|
183
|
+
waitedMs;
|
|
184
|
+
constructor(capName, scope, waitedMs) {
|
|
185
|
+
super(`Timed out waiting for ${capName} (${scopeKey(scope)}) to become ready after ${waitedMs}ms`);
|
|
186
|
+
this.name = "ReadinessTimeoutError";
|
|
187
|
+
this.capName = capName;
|
|
188
|
+
this.scope = scope;
|
|
189
|
+
this.waitedMs = waitedMs;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Build a canonical string key for a `(capName, scope)` pair. Used as
|
|
194
|
+
* the snapshot map key and for log/debug output.
|
|
195
|
+
*/
|
|
196
|
+
function readinessKey(capName, scope) {
|
|
197
|
+
return `${capName}|${scopeKey(scope)}`;
|
|
198
|
+
}
|
|
199
|
+
function scopeKey(scope) {
|
|
200
|
+
switch (scope.type) {
|
|
201
|
+
case "global": return "global";
|
|
202
|
+
case "node": return `node:${scope.nodeId}`;
|
|
203
|
+
case "device": return `device:${scope.deviceId}`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Producer transition order within ONE generation: `starting → ready →
|
|
208
|
+
* down`. Used by `hydrate` to accept only forward moves for
|
|
209
|
+
* same-generation snapshot records (a snapshot can be ahead of a lost
|
|
210
|
+
* delta, never behind it, within one producer generation).
|
|
211
|
+
*/
|
|
212
|
+
function stateRank(state) {
|
|
213
|
+
switch (state) {
|
|
214
|
+
case "starting": return 0;
|
|
215
|
+
case "ready": return 1;
|
|
216
|
+
case "down": return 2;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function scopesEqual(a, b) {
|
|
220
|
+
if (a.type !== b.type) return false;
|
|
221
|
+
if (a.type === "global" || b.type === "global") return true;
|
|
222
|
+
if (a.type === "node" && b.type === "node") return a.nodeId === b.nodeId;
|
|
223
|
+
if (a.type === "device" && b.type === "device") return a.deviceId === b.deviceId;
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
var ReadinessRegistry = class {
|
|
227
|
+
bus;
|
|
228
|
+
sourceNodeId;
|
|
229
|
+
logger;
|
|
230
|
+
now;
|
|
231
|
+
generation;
|
|
232
|
+
verboseDeviceScopeLogs;
|
|
233
|
+
snapshot = /* @__PURE__ */ new Map();
|
|
234
|
+
subscriptions = /* @__PURE__ */ new Set();
|
|
235
|
+
unsubscribeBus;
|
|
236
|
+
unsubscribeAgentOffline;
|
|
237
|
+
constructor(options) {
|
|
238
|
+
this.bus = options.eventBus;
|
|
239
|
+
this.sourceNodeId = options.sourceNodeId;
|
|
240
|
+
this.logger = options.logger;
|
|
241
|
+
this.now = options.now ?? (() => Date.now());
|
|
242
|
+
this.generation = options.generation ?? randomGeneration();
|
|
243
|
+
this.verboseDeviceScopeLogs = options.verboseDeviceScopeLogs ?? false;
|
|
244
|
+
this.unsubscribeBus = this.bus.subscribe({ category: "system.ready-state" }, (event) => this.ingest(event.data));
|
|
245
|
+
this.unsubscribeAgentOffline = this.bus.subscribe({ category: "agent.offline" }, (event) => this.synthesizeDownForNode(event.data.agentId));
|
|
246
|
+
if (typeof this.bus.getRecent === "function") try {
|
|
247
|
+
const recent = this.bus.getRecent({ category: "system.ready-state" });
|
|
248
|
+
for (const event of recent) this.ingest(event.data);
|
|
249
|
+
} catch {}
|
|
250
|
+
}
|
|
251
|
+
/** Release the event-bus subscription. Idempotent. */
|
|
252
|
+
close() {
|
|
253
|
+
this.unsubscribeBus();
|
|
254
|
+
this.unsubscribeAgentOffline();
|
|
255
|
+
this.subscriptions.clear();
|
|
256
|
+
}
|
|
257
|
+
/** Current snapshot for a `(capName, scope)` pair, or `null` if never seen. */
|
|
258
|
+
get(capName, scope) {
|
|
259
|
+
return this.snapshot.get(readinessKey(capName, scope)) ?? null;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Serializable snapshot for cross-process transport. Returns an array
|
|
263
|
+
* of `ReadinessRecord` plain objects — safe for MsgPack / JSON
|
|
264
|
+
* transport. Used by the hub's `$readiness.getSnapshot` Moleculer
|
|
265
|
+
* action; consumers hydrate their local registry from the result.
|
|
266
|
+
*/
|
|
267
|
+
getSnapshotForTransport() {
|
|
268
|
+
return Array.from(this.snapshot.values());
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Hydrate the snapshot from an authoritative source — a RECONCILE, not
|
|
272
|
+
* an add-only merge (D8: readiness events are telemetry and may be
|
|
273
|
+
* lost; the on-reconnect/periodic snapshot re-pull is the repair path,
|
|
274
|
+
* so it MUST be able to advance a stale record — the 2026-07-17
|
|
275
|
+
* "still awaiting platform-probe forever" wedge was this method
|
|
276
|
+
* skipping every already-seen key).
|
|
277
|
+
*
|
|
278
|
+
* - **Unseen keys** are added (epoch 1 — mirrors the value the
|
|
279
|
+
* consumer would have derived from the first observed `ready`).
|
|
280
|
+
* - **Existing keys** are UPDATED when the authoritative record
|
|
281
|
+
* carries a different generation (producer restart / synthetic-down
|
|
282
|
+
* superseded — epoch bumps on a new-generation `ready`, mirroring
|
|
283
|
+
* `ingest`), or a FORWARD state move within the same generation
|
|
284
|
+
* (`starting → ready → down`; within one producer generation a
|
|
285
|
+
* snapshot can only be ahead of a lost delta, never behind it).
|
|
286
|
+
* - **Never a same-generation regress** — a snapshot pulled just
|
|
287
|
+
* before a live delta landed must not un-ready a record (the next
|
|
288
|
+
* reconcile round converges it anyway).
|
|
289
|
+
* - **Never a record this process is authoritative for** — node-scoped
|
|
290
|
+
* records for our own nodeId, and device/global records we emitted,
|
|
291
|
+
* keep local truth (an authority's stale copy of OUR record must
|
|
292
|
+
* not regress us).
|
|
293
|
+
*
|
|
294
|
+
* Every applied entry dispatches a one-shot transition to matching
|
|
295
|
+
* subscriptions so pending `awaitReady` callers unblock without having
|
|
296
|
+
* to wait for a fresh event.
|
|
297
|
+
*
|
|
298
|
+
* Returns the number of records APPLIED (added or advanced). Callers
|
|
299
|
+
* doing periodic reconciles use this to stay silent when the snapshot
|
|
300
|
+
* changed nothing — the every-60s "hydrated 1446 record(s)" heartbeat
|
|
301
|
+
* from every child process was pure noise (≈2 800 lines/hour observed
|
|
302
|
+
* live on 2026-08-01).
|
|
303
|
+
*/
|
|
304
|
+
hydrate(records) {
|
|
305
|
+
const now = this.now();
|
|
306
|
+
let applied = 0;
|
|
307
|
+
for (const record of records) {
|
|
308
|
+
const key = readinessKey(record.capName, record.scope);
|
|
309
|
+
const prev = this.snapshot.get(key) ?? null;
|
|
310
|
+
let epoch;
|
|
311
|
+
let durationInPrevState;
|
|
312
|
+
if (prev !== null) {
|
|
313
|
+
if (this.isLocallyAuthoritative(prev)) continue;
|
|
314
|
+
const sameGeneration = prev.generation === record.generation;
|
|
315
|
+
if (sameGeneration && stateRank(record.state) <= stateRank(prev.state)) continue;
|
|
316
|
+
epoch = !sameGeneration && record.state === "ready" ? prev.epoch + 1 : prev.epoch;
|
|
317
|
+
durationInPrevState = Math.max(0, now - prev.lastChange);
|
|
318
|
+
} else {
|
|
319
|
+
epoch = 1;
|
|
320
|
+
durationInPrevState = 0;
|
|
321
|
+
}
|
|
322
|
+
const hydrated = {
|
|
323
|
+
capName: record.capName,
|
|
324
|
+
scope: record.scope,
|
|
325
|
+
state: record.state,
|
|
326
|
+
generation: record.generation,
|
|
327
|
+
epoch,
|
|
328
|
+
lastChange: now,
|
|
329
|
+
sourceNodeId: record.sourceNodeId
|
|
330
|
+
};
|
|
331
|
+
this.snapshot.set(key, hydrated);
|
|
332
|
+
applied++;
|
|
333
|
+
this.logPerRecord(record.scope, `readiness: ${record.capName} (${scopeKey(record.scope)}) → ${record.state} (hydrated${prev !== null ? " update" : ""}, gen=${record.generation.slice(0, 6)})`);
|
|
334
|
+
const transition = {
|
|
335
|
+
capName: record.capName,
|
|
336
|
+
scope: record.scope,
|
|
337
|
+
state: record.state,
|
|
338
|
+
epoch,
|
|
339
|
+
generation: record.generation,
|
|
340
|
+
sourceNodeId: "hydrated",
|
|
341
|
+
ts: now,
|
|
342
|
+
durationInPrevState
|
|
343
|
+
};
|
|
344
|
+
for (const sub of this.subscriptions) {
|
|
345
|
+
if (sub.capName !== record.capName) continue;
|
|
346
|
+
if (!scopesEqual(sub.scope, record.scope)) continue;
|
|
347
|
+
try {
|
|
348
|
+
sub.handler(transition);
|
|
349
|
+
} catch (err) {
|
|
350
|
+
this.logger?.warn(`readiness hydrate handler threw for ${record.capName}: ${err.message ?? String(err)}`);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return applied;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Per-record debug line, volume-gated: device-scoped records are logged
|
|
358
|
+
* only when `verboseDeviceScopeLogs` is set (see the option's doc for
|
|
359
|
+
* the 21 577-lines-per-boot-minute incident that forced the gate);
|
|
360
|
+
* node/global records always log. Device lines carry `tags.deviceId`
|
|
361
|
+
* so they group per-camera (CLAUDE.md logging rule).
|
|
362
|
+
*/
|
|
363
|
+
logPerRecord(scope, message) {
|
|
364
|
+
if (!this.logger) return;
|
|
365
|
+
if (scope.type === "device") {
|
|
366
|
+
if (!this.verboseDeviceScopeLogs) return;
|
|
367
|
+
this.logger.debug(message, { tags: { deviceId: scope.deviceId } });
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
this.logger.debug(message);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* True when THIS process is the origin authority for `record` — a
|
|
374
|
+
* snapshot pulled from elsewhere must never overwrite it:
|
|
375
|
+
* - node-scoped records whose `scope.nodeId` is our own node id
|
|
376
|
+
* (this process — or a child bridged onto our bus — emits them);
|
|
377
|
+
* - device/global-scoped records whose latest transition WE emitted.
|
|
378
|
+
*/
|
|
379
|
+
isLocallyAuthoritative(record) {
|
|
380
|
+
if (record.scope.type === "node") return record.scope.nodeId === this.sourceNodeId;
|
|
381
|
+
return record.sourceNodeId === this.sourceNodeId;
|
|
382
|
+
}
|
|
383
|
+
/** Shallow copy of the full snapshot — mainly for diagnostics/tests. */
|
|
384
|
+
getAll() {
|
|
385
|
+
return new Map(this.snapshot);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Emit a `ready` transition for a locally-owned capability. The
|
|
389
|
+
* payload carries this registry's `generation` so remote registries
|
|
390
|
+
* can derive their own `epoch`.
|
|
391
|
+
*/
|
|
392
|
+
emitReady(capName, scope) {
|
|
393
|
+
this.emitTransition(capName, scope, "ready");
|
|
394
|
+
}
|
|
395
|
+
emitStarting(capName, scope) {
|
|
396
|
+
this.emitTransition(capName, scope, "starting");
|
|
397
|
+
}
|
|
398
|
+
emitDown(capName, scope) {
|
|
399
|
+
this.emitTransition(capName, scope, "down");
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* One-shot: resolve once the cap is `ready`. Reads the snapshot
|
|
403
|
+
* first — if already ready, resolves synchronously on the next tick.
|
|
404
|
+
*
|
|
405
|
+
* Default behaviour is **wait indefinitely** (timeoutMs = `Infinity`):
|
|
406
|
+
* the orchestrator and other callers never want to attach a camera
|
|
407
|
+
* with empty steps just because a cap took longer than 30s to come
|
|
408
|
+
* up. Pass an explicit finite `timeoutMs` to bound the wait, or an
|
|
409
|
+
* `AbortSignal` to cancel externally. `Infinity` is honoured natively
|
|
410
|
+
* — no `setTimeout` is registered (Node's setTimeout silently clamps
|
|
411
|
+
* values above ~24.8d, so we must skip the timer entirely).
|
|
412
|
+
*/
|
|
413
|
+
awaitReady(capName, scope, opts = {}) {
|
|
414
|
+
const timeoutMs = opts.timeoutMs ?? Number.POSITIVE_INFINITY;
|
|
415
|
+
const start = this.now();
|
|
416
|
+
if (this.get(capName, scope)?.state === "ready") return Promise.resolve();
|
|
417
|
+
if (opts.signal?.aborted) return Promise.reject(opts.signal.reason ?? /* @__PURE__ */ new Error("aborted"));
|
|
418
|
+
return new Promise((resolve, reject) => {
|
|
419
|
+
let settled = false;
|
|
420
|
+
const unsubscribe = this.onReadyState(capName, scope, (t) => {
|
|
421
|
+
if (t.state !== "ready") return;
|
|
422
|
+
if (settled) return;
|
|
423
|
+
settled = true;
|
|
424
|
+
cleanup();
|
|
425
|
+
resolve();
|
|
426
|
+
});
|
|
427
|
+
const timer = !Number.isFinite(timeoutMs) ? null : setTimeout(() => {
|
|
428
|
+
if (settled) return;
|
|
429
|
+
settled = true;
|
|
430
|
+
cleanup();
|
|
431
|
+
reject(new ReadinessTimeoutError(capName, scope, this.now() - start));
|
|
432
|
+
}, timeoutMs);
|
|
433
|
+
const pendingLogTimer = setInterval(() => {
|
|
434
|
+
if (settled) return;
|
|
435
|
+
this.logger?.warn(`readiness: still awaiting ${capName} (${scopeKey(scope)}) after ${this.now() - start}ms`);
|
|
436
|
+
}, 3e4);
|
|
437
|
+
if (typeof pendingLogTimer.unref === "function") pendingLogTimer.unref();
|
|
438
|
+
const onAbort = () => {
|
|
439
|
+
if (settled) return;
|
|
440
|
+
settled = true;
|
|
441
|
+
cleanup();
|
|
442
|
+
reject(opts.signal?.reason ?? /* @__PURE__ */ new Error("aborted"));
|
|
443
|
+
};
|
|
444
|
+
opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
445
|
+
function cleanup() {
|
|
446
|
+
unsubscribe();
|
|
447
|
+
if (timer !== null) clearTimeout(timer);
|
|
448
|
+
clearInterval(pendingLogTimer);
|
|
449
|
+
opts.signal?.removeEventListener("abort", onAbort);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Observable: every transition (starting/ready/down) dispatches to
|
|
455
|
+
* `handler`. On subscription, if the snapshot has a current state,
|
|
456
|
+
* the handler fires ONCE asynchronously with that state as the
|
|
457
|
+
* initial transition (duration = 0) so late subscribers can pick up
|
|
458
|
+
* current state without racing the next transition.
|
|
459
|
+
*
|
|
460
|
+
* Returns an unsubscribe function.
|
|
461
|
+
*/
|
|
462
|
+
onReadyState(capName, scope, handler) {
|
|
463
|
+
const sub = {
|
|
464
|
+
capName,
|
|
465
|
+
scope,
|
|
466
|
+
handler
|
|
467
|
+
};
|
|
468
|
+
this.subscriptions.add(sub);
|
|
469
|
+
const current = this.get(capName, scope);
|
|
470
|
+
if (current !== null) queueMicrotask(() => {
|
|
471
|
+
if (!this.subscriptions.has(sub)) return;
|
|
472
|
+
handler({
|
|
473
|
+
capName,
|
|
474
|
+
scope,
|
|
475
|
+
state: current.state,
|
|
476
|
+
epoch: current.epoch,
|
|
477
|
+
generation: current.generation,
|
|
478
|
+
sourceNodeId: this.sourceNodeId,
|
|
479
|
+
ts: current.lastChange,
|
|
480
|
+
durationInPrevState: 0
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
return () => {
|
|
484
|
+
this.subscriptions.delete(sub);
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
emitTransition(capName, scope, state) {
|
|
488
|
+
const ts = this.now();
|
|
489
|
+
this.bus.emit(createEvent$1("system.ready-state", {
|
|
490
|
+
type: "capability",
|
|
491
|
+
id: capName,
|
|
492
|
+
nodeId: this.sourceNodeId
|
|
493
|
+
}, {
|
|
494
|
+
capName,
|
|
495
|
+
scope,
|
|
496
|
+
state,
|
|
497
|
+
generation: this.generation,
|
|
498
|
+
sourceNodeId: this.sourceNodeId,
|
|
499
|
+
ts
|
|
500
|
+
}));
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Update snapshot + dispatch to subscribers. Idempotent: same
|
|
504
|
+
* `generation + state` replay is a no-op for both snapshot and
|
|
505
|
+
* subscribers.
|
|
506
|
+
*
|
|
507
|
+
* Defensive against malformed payloads (legal reason: a mock bus's
|
|
508
|
+
* `getRecent` may ignore the category filter and replay unrelated
|
|
509
|
+
* events when we hydrate at construction time).
|
|
510
|
+
*/
|
|
511
|
+
ingest(payload) {
|
|
512
|
+
if (typeof payload?.capName !== "string") return;
|
|
513
|
+
if (payload.state !== "ready" && payload.state !== "starting" && payload.state !== "down") return;
|
|
514
|
+
if (typeof payload.generation !== "string") return;
|
|
515
|
+
if (payload.scope?.type !== "global" && payload.scope?.type !== "node" && payload.scope?.type !== "device") return;
|
|
516
|
+
const key = readinessKey(payload.capName, payload.scope);
|
|
517
|
+
const prev = this.snapshot.get(key) ?? null;
|
|
518
|
+
const now = this.now();
|
|
519
|
+
let epoch;
|
|
520
|
+
if (prev === null) epoch = payload.state === "ready" ? 1 : 0;
|
|
521
|
+
else if (prev.generation !== payload.generation && payload.state === "ready") epoch = prev.epoch + 1;
|
|
522
|
+
else epoch = prev.epoch;
|
|
523
|
+
if (prev !== null && prev.generation === payload.generation && prev.state === payload.state) return;
|
|
524
|
+
const durationInPrevState = prev === null ? 0 : Math.max(0, now - prev.lastChange);
|
|
525
|
+
const next = {
|
|
526
|
+
capName: payload.capName,
|
|
527
|
+
scope: payload.scope,
|
|
528
|
+
state: payload.state,
|
|
529
|
+
generation: payload.generation,
|
|
530
|
+
epoch,
|
|
531
|
+
lastChange: now,
|
|
532
|
+
sourceNodeId: payload.sourceNodeId
|
|
533
|
+
};
|
|
534
|
+
this.snapshot.set(key, next);
|
|
535
|
+
const transition = {
|
|
536
|
+
capName: payload.capName,
|
|
537
|
+
scope: payload.scope,
|
|
538
|
+
state: payload.state,
|
|
539
|
+
epoch,
|
|
540
|
+
generation: payload.generation,
|
|
541
|
+
sourceNodeId: payload.sourceNodeId,
|
|
542
|
+
ts: payload.ts,
|
|
543
|
+
durationInPrevState
|
|
544
|
+
};
|
|
545
|
+
this.logPerRecord(payload.scope, `readiness: ${payload.capName} (${scopeKey(payload.scope)}) → ${payload.state} epoch=${epoch} gen=${payload.generation.slice(0, 6)} (prev ${durationInPrevState}ms)`);
|
|
546
|
+
for (const sub of this.subscriptions) {
|
|
547
|
+
if (sub.capName !== payload.capName) continue;
|
|
548
|
+
if (!scopesEqual(sub.scope, payload.scope)) continue;
|
|
549
|
+
try {
|
|
550
|
+
sub.handler(transition);
|
|
551
|
+
} catch (err) {
|
|
552
|
+
this.logger?.warn(`readiness handler threw for ${payload.capName}: ${err.message ?? String(err)}`);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* `agent.offline` demux. When an agent disconnects ungracefully,
|
|
558
|
+
* its BaseAddon's shutdown hook doesn't fire — consumers would
|
|
559
|
+
* otherwise keep waiting on a stale `ready`. Walk the snapshot and
|
|
560
|
+
* synthesize a `down` transition for every node-scoped record bound
|
|
561
|
+
* to the disconnected `nodeId`, skipping records already `down`.
|
|
562
|
+
*
|
|
563
|
+
* Synthesis is LOCAL: we don't re-emit on the bus. Every registry
|
|
564
|
+
* (one per process) receives the same `agent.offline` and reacts
|
|
565
|
+
* independently, which means no duplicated downs and no central
|
|
566
|
+
* supervisor required.
|
|
567
|
+
*/
|
|
568
|
+
synthesizeDownForNode(offlineNodeId) {
|
|
569
|
+
const now = this.now();
|
|
570
|
+
for (const [key, record] of this.snapshot) {
|
|
571
|
+
if (record.state === "down") continue;
|
|
572
|
+
if (!(record.scope.type === "node" && record.scope.nodeId === offlineNodeId || record.scope.type === "device" && record.sourceNodeId === offlineNodeId)) continue;
|
|
573
|
+
const durationInPrevState = Math.max(0, now - record.lastChange);
|
|
574
|
+
const next = {
|
|
575
|
+
...record,
|
|
576
|
+
state: "down",
|
|
577
|
+
lastChange: now
|
|
578
|
+
};
|
|
579
|
+
this.snapshot.set(key, next);
|
|
580
|
+
const transition = {
|
|
581
|
+
capName: record.capName,
|
|
582
|
+
scope: record.scope,
|
|
583
|
+
state: "down",
|
|
584
|
+
epoch: record.epoch,
|
|
585
|
+
generation: record.generation,
|
|
586
|
+
sourceNodeId: this.sourceNodeId,
|
|
587
|
+
ts: now,
|
|
588
|
+
durationInPrevState
|
|
589
|
+
};
|
|
590
|
+
this.logPerRecord(record.scope, `readiness: ${record.capName} (${scopeKey(record.scope)}) → down (synthesized from agent.offline ${offlineNodeId})`);
|
|
591
|
+
for (const sub of this.subscriptions) {
|
|
592
|
+
if (sub.capName !== record.capName) continue;
|
|
593
|
+
if (!scopesEqual(sub.scope, record.scope)) continue;
|
|
594
|
+
try {
|
|
595
|
+
sub.handler(transition);
|
|
596
|
+
} catch (err) {
|
|
597
|
+
this.logger?.warn(`readiness handler threw during agent.offline demux for ${record.capName}: ${err.message ?? String(err)}`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
function randomGeneration() {
|
|
604
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) return crypto.randomUUID();
|
|
605
|
+
return Math.random().toString(36).slice(2, 14);
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Given a list of `(capName, scope)` pairs that a just-disconnected
|
|
609
|
+
* node owned, emit a `down` transition for each. Callers (kernel
|
|
610
|
+
* supervisor, hub `$node.disconnected` handler) wire this up once they
|
|
611
|
+
* know which caps the node held.
|
|
612
|
+
*/
|
|
613
|
+
function emitDownForOwnedCaps(registry, owned) {
|
|
614
|
+
for (const { capName, scope } of owned) registry.emitDown(capName, scope);
|
|
615
|
+
}
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region ../types/dist/esm/auth/principal-scope.mjs
|
|
618
|
+
/**
|
|
619
|
+
* True if the scope set grants `access` on device-scoped capabilities.
|
|
620
|
+
* A `category:device` grant covers every device cap (the broad grant).
|
|
621
|
+
*/
|
|
622
|
+
function scopesAllowDeviceCap(scopes, access) {
|
|
623
|
+
return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* True if the scope set names this addon with at least `access`.
|
|
627
|
+
*
|
|
628
|
+
* Deliberately NOT satisfied by `category:device`: a grant over per-camera
|
|
629
|
+
* capabilities says nothing about an addon's own HTTP surface, and conflating
|
|
630
|
+
* the two is precisely the confusion that let an Alexa token drive Home
|
|
631
|
+
* Assistant's command route.
|
|
632
|
+
*/
|
|
633
|
+
function scopesAllowAddon(scopes, addonId, access) {
|
|
634
|
+
return scopes.some((s) => s.type === "addon" && s.target === addonId && s.access.includes(access));
|
|
635
|
+
}
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region ../types/dist/esm/capabilities/caller-stamp.mjs
|
|
638
|
+
/**
|
|
639
|
+
* Every cap whose provider reads a `callerAddonId` in its input (the keychain's
|
|
640
|
+
* owner check, device-history's `not-owner`, records' owner).
|
|
641
|
+
*
|
|
642
|
+
* The stamp is set ONLY by the transport (`stampCallerAddonId`, or stated by a
|
|
643
|
+
* hub in-process caller). HTTP/WS mounts parse input with `.loose()`, so a
|
|
644
|
+
* session could add the key itself and act as another addon — those procedures
|
|
645
|
+
* strip it when `ctx.req` is present. Mesh / `$core-caps` calls have no request;
|
|
646
|
+
* the transport stamp must survive to the provider.
|
|
647
|
+
*/
|
|
648
|
+
var CALLER_STAMPED_CAPABILITIES$1 = [
|
|
649
|
+
"keychain",
|
|
650
|
+
"device-history",
|
|
651
|
+
"records",
|
|
652
|
+
"integrations",
|
|
653
|
+
"device-manager",
|
|
654
|
+
"core-blocks",
|
|
655
|
+
"migrations",
|
|
656
|
+
"device-transitions",
|
|
657
|
+
"integration-instances"
|
|
658
|
+
];
|
|
659
|
+
/** A copy of `input` without the caller stamp. Anything that is not a plain object passes through. */
|
|
660
|
+
function withoutCallerStamp(input) {
|
|
661
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) return input;
|
|
662
|
+
if (!Object.prototype.hasOwnProperty.call(input, "callerAddonId")) return input;
|
|
663
|
+
return Object.fromEntries(Object.entries(input).filter(([key]) => key !== "callerAddonId"));
|
|
664
|
+
}
|
|
665
|
+
var CATALOG_LANGS = AppPageLangSchema.options;
|
|
666
|
+
/** One catalog file: flat key to text. A file of any other shape is rejected whole. */
|
|
667
|
+
var CatalogFileSchema = /* @__PURE__ */ z.record(/* @__PURE__ */ z.string().min(1), /* @__PURE__ */ z.string());
|
|
668
|
+
/** Fills `{name}` placeholders; an unknown placeholder is left as written. */
|
|
669
|
+
function interpolate(template, params) {
|
|
670
|
+
if (params === void 0) return template;
|
|
671
|
+
return template.replace(/\{(\w+)\}/g, (whole, name) => {
|
|
672
|
+
const value = params[name];
|
|
673
|
+
return value === void 0 ? whole : String(value);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
/** Splits `"ns:key"`; `null` when the reference has no namespace. */
|
|
677
|
+
function splitTranslationRef(ref) {
|
|
678
|
+
const at = ref.indexOf(":");
|
|
679
|
+
if (at <= 0 || at === ref.length - 1) return null;
|
|
680
|
+
return {
|
|
681
|
+
ns: ref.slice(0, at),
|
|
682
|
+
key: ref.slice(at + 1)
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
//#endregion
|
|
74
686
|
//#region src/addon/addon-api-factory.ts
|
|
75
687
|
/**
|
|
76
688
|
* Wrap a raw tRPC caller (from `createCallerFactory`) in a proxy that
|
|
@@ -5088,7 +5700,7 @@ var PythonEnvManager = class {
|
|
|
5088
5700
|
async ensure(options) {
|
|
5089
5701
|
const probe = await this.probe();
|
|
5090
5702
|
if (!probe.available || !probe.path) throw userError("system.python-required", void 0, "Python 3.10+ is required but not found on this system");
|
|
5091
|
-
if (!fs.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
|
|
5703
|
+
if (!fs$1.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
|
|
5092
5704
|
"-m",
|
|
5093
5705
|
"venv",
|
|
5094
5706
|
this.venvPath
|
|
@@ -5111,7 +5723,7 @@ var PythonEnvManager = class {
|
|
|
5111
5723
|
}
|
|
5112
5724
|
spawn(script, args) {
|
|
5113
5725
|
const venvPython = path$1.join(this.venvPath, "bin", "python");
|
|
5114
|
-
if (!fs.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
|
|
5726
|
+
if (!fs$1.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
|
|
5115
5727
|
return spawn(venvPython, [script, ...args]);
|
|
5116
5728
|
}
|
|
5117
5729
|
};
|
|
@@ -5463,20 +6075,20 @@ var StorageManager = class {
|
|
|
5463
6075
|
const basePath = this.locationManager.getBackend(mappedName).basePath;
|
|
5464
6076
|
location.files = {
|
|
5465
6077
|
async readFile(p) {
|
|
5466
|
-
return fs.promises.readFile(path$1.join(basePath, p));
|
|
6078
|
+
return fs$1.promises.readFile(path$1.join(basePath, p));
|
|
5467
6079
|
},
|
|
5468
6080
|
async writeFile(p, data) {
|
|
5469
6081
|
const full = path$1.join(basePath, p);
|
|
5470
|
-
await fs.promises.mkdir(path$1.dirname(full), { recursive: true });
|
|
5471
|
-
await fs.promises.writeFile(full, data);
|
|
6082
|
+
await fs$1.promises.mkdir(path$1.dirname(full), { recursive: true });
|
|
6083
|
+
await fs$1.promises.writeFile(full, data);
|
|
5472
6084
|
},
|
|
5473
6085
|
async deleteFile(p) {
|
|
5474
|
-
await fs.promises.rm(path$1.join(basePath, p), { force: true });
|
|
6086
|
+
await fs$1.promises.rm(path$1.join(basePath, p), { force: true });
|
|
5475
6087
|
},
|
|
5476
6088
|
async listFiles(prefix) {
|
|
5477
6089
|
const dir = prefix ? path$1.join(basePath, prefix) : basePath;
|
|
5478
6090
|
try {
|
|
5479
|
-
return (await fs.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
|
|
6091
|
+
return (await fs$1.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
|
|
5480
6092
|
} catch {
|
|
5481
6093
|
return [];
|
|
5482
6094
|
}
|
|
@@ -5486,7 +6098,7 @@ var StorageManager = class {
|
|
|
5486
6098
|
},
|
|
5487
6099
|
async exists(p) {
|
|
5488
6100
|
try {
|
|
5489
|
-
await fs.promises.access(path$1.join(basePath, p));
|
|
6101
|
+
await fs$1.promises.access(path$1.join(basePath, p));
|
|
5490
6102
|
return true;
|
|
5491
6103
|
} catch {
|
|
5492
6104
|
return false;
|
|
@@ -5936,7 +6548,7 @@ var TRADITIONAL_NATIVE_PACKAGES = ["better-sqlite3"];
|
|
|
5936
6548
|
function hasDotNode(dir, maxDepth) {
|
|
5937
6549
|
let entries;
|
|
5938
6550
|
try {
|
|
5939
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
6551
|
+
entries = fs$1.readdirSync(dir, { withFileTypes: true });
|
|
5940
6552
|
} catch {
|
|
5941
6553
|
return false;
|
|
5942
6554
|
}
|
|
@@ -5947,7 +6559,7 @@ function hasDotNode(dir, maxDepth) {
|
|
|
5947
6559
|
}
|
|
5948
6560
|
/** Locate the bundled `prebuild-install` bin.js inside the staged closure. */
|
|
5949
6561
|
function resolvePrebuildInstallBin(closureDir, moduleDir) {
|
|
5950
|
-
return [path$1.join(moduleDir, "node_modules", "prebuild-install", "bin.js"), path$1.join(closureDir, "node_modules", "prebuild-install", "bin.js")].find((c) => fs.existsSync(c)) ?? null;
|
|
6562
|
+
return [path$1.join(moduleDir, "node_modules", "prebuild-install", "bin.js"), path$1.join(closureDir, "node_modules", "prebuild-install", "bin.js")].find((c) => fs$1.existsSync(c)) ?? null;
|
|
5951
6563
|
}
|
|
5952
6564
|
/**
|
|
5953
6565
|
* Default fetcher: run the closure's own `prebuild-install` under the CURRENT
|
|
@@ -6000,7 +6612,7 @@ async function ensureNativePrebuilds(closureDir, options) {
|
|
|
6000
6612
|
const fetched = [];
|
|
6001
6613
|
for (const pkg of packages) {
|
|
6002
6614
|
const moduleDir = path$1.join(nm, pkg);
|
|
6003
|
-
if (!fs.existsSync(moduleDir)) continue;
|
|
6615
|
+
if (!fs$1.existsSync(moduleDir)) continue;
|
|
6004
6616
|
if (hasDotNode(moduleDir, 4)) continue;
|
|
6005
6617
|
options.logger.warn("staged closure native prebuild missing — fetching for running ABI", { meta: {
|
|
6006
6618
|
pkg,
|
|
@@ -6063,12 +6675,12 @@ async function ensureNativePrebuilds(closureDir, options) {
|
|
|
6063
6675
|
function replantFromBundled(srcModuleDir, dstModuleDir, hasNative) {
|
|
6064
6676
|
if (!hasNative(srcModuleDir)) return false;
|
|
6065
6677
|
try {
|
|
6066
|
-
fs.rmSync(dstModuleDir, {
|
|
6678
|
+
fs$1.rmSync(dstModuleDir, {
|
|
6067
6679
|
recursive: true,
|
|
6068
6680
|
force: true
|
|
6069
6681
|
});
|
|
6070
|
-
fs.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
|
|
6071
|
-
fs.cpSync(srcModuleDir, dstModuleDir, {
|
|
6682
|
+
fs$1.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
|
|
6683
|
+
fs$1.cpSync(srcModuleDir, dstModuleDir, {
|
|
6072
6684
|
recursive: true,
|
|
6073
6685
|
dereference: true
|
|
6074
6686
|
});
|
|
@@ -6097,7 +6709,7 @@ async function ensureAddonNativePrebuilds(addonDir, options) {
|
|
|
6097
6709
|
const missing = [];
|
|
6098
6710
|
for (const pkg of packages) {
|
|
6099
6711
|
const moduleDir = path$1.join(nm, pkg);
|
|
6100
|
-
if (!fs.existsSync(moduleDir)) continue;
|
|
6712
|
+
if (!fs$1.existsSync(moduleDir)) continue;
|
|
6101
6713
|
if (hasNative(moduleDir)) {
|
|
6102
6714
|
results.push({
|
|
6103
6715
|
pkg,
|
|
@@ -6196,7 +6808,7 @@ async function defaultDownloadTarball(url, destTgz) {
|
|
|
6196
6808
|
const res = await fetch(url);
|
|
6197
6809
|
if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} downloading ${url}`);
|
|
6198
6810
|
const bytes = Buffer.from(await res.arrayBuffer());
|
|
6199
|
-
await fs.promises.writeFile(destTgz, bytes);
|
|
6811
|
+
await fs$1.promises.writeFile(destTgz, bytes);
|
|
6200
6812
|
}
|
|
6201
6813
|
async function defaultExtractTarball(tgzPath, destDir) {
|
|
6202
6814
|
await execFileAsync$5("tar", [
|
|
@@ -6282,7 +6894,7 @@ async function resolveUncached(options) {
|
|
|
6282
6894
|
argsPrefix: []
|
|
6283
6895
|
};
|
|
6284
6896
|
const cliPath = bootstrappedCliPath(options.cacheDir);
|
|
6285
|
-
if (fs.existsSync(cliPath)) {
|
|
6897
|
+
if (fs$1.existsSync(cliPath)) {
|
|
6286
6898
|
options.logger.info("system npm unavailable — using bootstrapped npm", { meta: { cliPath } });
|
|
6287
6899
|
return {
|
|
6288
6900
|
command: process.execPath,
|
|
@@ -6294,12 +6906,12 @@ async function resolveUncached(options) {
|
|
|
6294
6906
|
const registry = (options.registry ?? DEFAULT_REGISTRY$1).replace(/\/+$/, "");
|
|
6295
6907
|
const tarballUrl = tarballUrlOf(await (options.fetchJson ?? defaultFetchJson)(`${registry}/npm/latest`));
|
|
6296
6908
|
if (!tarballUrl) throw new Error(`registry metadata for 'npm' carries no dist.tarball (${registry})`);
|
|
6297
|
-
await fs.promises.mkdir(options.cacheDir, { recursive: true });
|
|
6909
|
+
await fs$1.promises.mkdir(options.cacheDir, { recursive: true });
|
|
6298
6910
|
const tgzPath = path$1.join(options.cacheDir, "npm-bootstrap.tgz");
|
|
6299
6911
|
await (options.downloadTarball ?? defaultDownloadTarball)(tarballUrl, tgzPath);
|
|
6300
6912
|
await (options.extractTarball ?? defaultExtractTarball)(tgzPath, options.cacheDir);
|
|
6301
|
-
await fs.promises.rm(tgzPath, { force: true });
|
|
6302
|
-
if (!fs.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
|
|
6913
|
+
await fs$1.promises.rm(tgzPath, { force: true });
|
|
6914
|
+
if (!fs$1.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
|
|
6303
6915
|
options.logger.info("npm bootstrapped", { meta: { cliPath } });
|
|
6304
6916
|
return {
|
|
6305
6917
|
command: process.execPath,
|
|
@@ -6365,7 +6977,7 @@ function readOwningPackageVersion(entryPath) {
|
|
|
6365
6977
|
let dir = path$1.dirname(entryPath);
|
|
6366
6978
|
for (let hop = 0; hop < PACKAGE_JSON_LOOKUP_DEPTH; hop++) {
|
|
6367
6979
|
try {
|
|
6368
|
-
const version = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
|
|
6980
|
+
const version = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
|
|
6369
6981
|
if (typeof version === "string" && version.length > 0) return version;
|
|
6370
6982
|
} catch {}
|
|
6371
6983
|
const parent = path$1.dirname(dir);
|
|
@@ -6409,14 +7021,14 @@ function readOwningPackageVersion(entryPath) {
|
|
|
6409
7021
|
function addonModuleCacheKey(entryPath) {
|
|
6410
7022
|
let stat;
|
|
6411
7023
|
try {
|
|
6412
|
-
stat = fs.statSync(entryPath);
|
|
7024
|
+
stat = fs$1.statSync(entryPath);
|
|
6413
7025
|
} catch {
|
|
6414
7026
|
return null;
|
|
6415
7027
|
}
|
|
6416
7028
|
const version = readOwningPackageVersion(entryPath) ?? `m${stat.mtimeMs}`;
|
|
6417
7029
|
let content;
|
|
6418
7030
|
try {
|
|
6419
|
-
content = createHash("sha1").update(fs.readFileSync(entryPath)).digest("hex").slice(0, 16);
|
|
7031
|
+
content = createHash("sha1").update(fs$1.readFileSync(entryPath)).digest("hex").slice(0, 16);
|
|
6420
7032
|
} catch {
|
|
6421
7033
|
content = `m${stat.mtimeMs}s${stat.size}`;
|
|
6422
7034
|
}
|
|
@@ -6520,14 +7132,14 @@ var AddonLoader = class {
|
|
|
6520
7132
|
* BUILTINS from the active closure, not the (now-inert) addons-dir copy, so
|
|
6521
7133
|
* the addons-dir `@camstack/server/system` must NOT be double-loaded here. */
|
|
6522
7134
|
async loadFromDirectory(addonsDir, skipPackages = []) {
|
|
6523
|
-
if (!fs.existsSync(addonsDir)) return;
|
|
7135
|
+
if (!fs$1.existsSync(addonsDir)) return;
|
|
6524
7136
|
const skip = new Set(skipPackages);
|
|
6525
|
-
const entries = fs.readdirSync(addonsDir, { withFileTypes: true });
|
|
7137
|
+
const entries = fs$1.readdirSync(addonsDir, { withFileTypes: true });
|
|
6526
7138
|
for (const entry of entries) {
|
|
6527
7139
|
if (!isDirectoryEntry(entry, addonsDir)) continue;
|
|
6528
7140
|
if (entry.name.startsWith("@")) {
|
|
6529
7141
|
const scopeDir = path$1.join(addonsDir, entry.name);
|
|
6530
|
-
const scopeEntries = fs.readdirSync(scopeDir, { withFileTypes: true });
|
|
7142
|
+
const scopeEntries = fs$1.readdirSync(scopeDir, { withFileTypes: true });
|
|
6531
7143
|
for (const scopeEntry of scopeEntries) {
|
|
6532
7144
|
if (!isDirectoryEntry(scopeEntry, scopeDir)) continue;
|
|
6533
7145
|
if (skip.has(`${entry.name}/${scopeEntry.name}`)) continue;
|
|
@@ -6541,7 +7153,7 @@ var AddonLoader = class {
|
|
|
6541
7153
|
}
|
|
6542
7154
|
async tryLoadAddon(addonDir) {
|
|
6543
7155
|
const pkgJsonPath = path$1.join(addonDir, "package.json");
|
|
6544
|
-
if (!fs.existsSync(pkgJsonPath)) return;
|
|
7156
|
+
if (!fs$1.existsSync(pkgJsonPath)) return;
|
|
6545
7157
|
try {
|
|
6546
7158
|
await this.loadFromAddonDir(addonDir);
|
|
6547
7159
|
} catch (err) {
|
|
@@ -6559,7 +7171,7 @@ var AddonLoader = class {
|
|
|
6559
7171
|
/** Load addon from a specific directory (package.json + dist/) */
|
|
6560
7172
|
async loadFromAddonDir(addonDir) {
|
|
6561
7173
|
const pkgJsonPath = path$1.join(addonDir, "package.json");
|
|
6562
|
-
const pkgJson = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
|
|
7174
|
+
const pkgJson = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
|
|
6563
7175
|
const packageNameRaw = pkgJson["name"];
|
|
6564
7176
|
const packageName = typeof packageNameRaw === "string" ? packageNameRaw : "";
|
|
6565
7177
|
const packageVersionRaw = pkgJson["version"];
|
|
@@ -6607,7 +7219,7 @@ var AddonLoader = class {
|
|
|
6607
7219
|
}
|
|
6608
7220
|
const entryFile = declaration.entry.replace(/^\.\//, "").replace(/^src\//, "dist/").replace(/\.ts$/, ".js");
|
|
6609
7221
|
let entryPath = path$1.resolve(addonDir, entryFile);
|
|
6610
|
-
if (!fs.existsSync(entryPath)) {
|
|
7222
|
+
if (!fs$1.existsSync(entryPath)) {
|
|
6611
7223
|
const base = entryPath.replace(/\.(js|cjs|mjs)$/, "");
|
|
6612
7224
|
entryPath = [
|
|
6613
7225
|
`${base}.cjs`,
|
|
@@ -6616,9 +7228,9 @@ var AddonLoader = class {
|
|
|
6616
7228
|
path$1.resolve(addonDir, "dist", "index.cjs"),
|
|
6617
7229
|
path$1.resolve(addonDir, "dist", "index.mjs"),
|
|
6618
7230
|
path$1.resolve(addonDir, declaration.entry)
|
|
6619
|
-
].find((p) => fs.existsSync(p)) ?? entryPath;
|
|
7231
|
+
].find((p) => fs$1.existsSync(p)) ?? entryPath;
|
|
6620
7232
|
}
|
|
6621
|
-
if (!fs.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
|
|
7233
|
+
if (!fs$1.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
|
|
6622
7234
|
const modUnknown = await importAddonModuleFresh(entryPath);
|
|
6623
7235
|
const mod = isRecord$4(modUnknown) ? modUnknown : {};
|
|
6624
7236
|
const AddonClass = resolveAddonClass(mod);
|
|
@@ -6730,7 +7342,7 @@ function isDirectoryEntry(entry, parentDir) {
|
|
|
6730
7342
|
if (entry.name.startsWith(".")) return false;
|
|
6731
7343
|
if (entry.isDirectory()) return true;
|
|
6732
7344
|
if (entry.isSymbolicLink()) try {
|
|
6733
|
-
return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
|
|
7345
|
+
return fs$1.statSync(path$1.join(parentDir, entry.name)).isDirectory();
|
|
6734
7346
|
} catch {
|
|
6735
7347
|
return false;
|
|
6736
7348
|
}
|
|
@@ -6824,7 +7436,7 @@ var execFileAsync$4 = promisify(execFile);
|
|
|
6824
7436
|
* Single source of truth — replaces scattered mkdirSync calls.
|
|
6825
7437
|
*/
|
|
6826
7438
|
function ensureDir(dirPath) {
|
|
6827
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
7439
|
+
fs$1.mkdirSync(dirPath, { recursive: true });
|
|
6828
7440
|
}
|
|
6829
7441
|
/**
|
|
6830
7442
|
* Copy a directory recursively — ASYNC so it never blocks the event loop.
|
|
@@ -6837,7 +7449,7 @@ function ensureDir(dirPath) {
|
|
|
6837
7449
|
* `fs.promises.cp` keeps the I/O off the event loop. (Node ≥18 stable.)
|
|
6838
7450
|
*/
|
|
6839
7451
|
async function copyDirRecursive(src, dest) {
|
|
6840
|
-
await fs.promises.cp(src, dest, {
|
|
7452
|
+
await fs$1.promises.cp(src, dest, {
|
|
6841
7453
|
recursive: true,
|
|
6842
7454
|
force: true
|
|
6843
7455
|
});
|
|
@@ -6942,13 +7554,13 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
|
|
|
6942
7554
|
if (typeof fileEntry !== "string") continue;
|
|
6943
7555
|
if (fileEntry === "dist" || fileEntry.includes("*")) continue;
|
|
6944
7556
|
const srcPath = path$1.join(sourceDir, fileEntry);
|
|
6945
|
-
if (!fs.existsSync(srcPath)) continue;
|
|
7557
|
+
if (!fs$1.existsSync(srcPath)) continue;
|
|
6946
7558
|
const destPath = path$1.join(destDir, fileEntry);
|
|
6947
|
-
const stat = await fs.promises.stat(srcPath);
|
|
7559
|
+
const stat = await fs$1.promises.stat(srcPath);
|
|
6948
7560
|
if (stat.isDirectory()) await copyDirRecursive(srcPath, destPath);
|
|
6949
7561
|
else if (stat.isFile()) {
|
|
6950
7562
|
ensureDir(path$1.dirname(destPath));
|
|
6951
|
-
await fs.promises.copyFile(srcPath, destPath);
|
|
7563
|
+
await fs$1.promises.copyFile(srcPath, destPath);
|
|
6952
7564
|
}
|
|
6953
7565
|
}
|
|
6954
7566
|
}
|
|
@@ -6959,10 +7571,10 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
|
|
|
6959
7571
|
function isSourceNewer(packageDir) {
|
|
6960
7572
|
const srcDir = path$1.join(packageDir, "src");
|
|
6961
7573
|
const distDir = path$1.join(packageDir, "dist");
|
|
6962
|
-
if (!fs.existsSync(srcDir) || !fs.existsSync(distDir)) return true;
|
|
7574
|
+
if (!fs$1.existsSync(srcDir) || !fs$1.existsSync(distDir)) return true;
|
|
6963
7575
|
try {
|
|
6964
|
-
const distMtime = fs.statSync(distDir).mtimeMs;
|
|
6965
|
-
const entries = fs.readdirSync(srcDir, {
|
|
7576
|
+
const distMtime = fs$1.statSync(distDir).mtimeMs;
|
|
7577
|
+
const entries = fs$1.readdirSync(srcDir, {
|
|
6966
7578
|
withFileTypes: true,
|
|
6967
7579
|
recursive: true
|
|
6968
7580
|
});
|
|
@@ -6970,7 +7582,7 @@ function isSourceNewer(packageDir) {
|
|
|
6970
7582
|
if (!entry.isFile()) continue;
|
|
6971
7583
|
const parentDir = entry.parentPath ?? String(Reflect.get(entry, "path") ?? "");
|
|
6972
7584
|
const filePath = path$1.join(parentDir, entry.name);
|
|
6973
|
-
if (fs.statSync(filePath).mtimeMs > distMtime) return true;
|
|
7585
|
+
if (fs$1.statSync(filePath).mtimeMs > distMtime) return true;
|
|
6974
7586
|
}
|
|
6975
7587
|
return false;
|
|
6976
7588
|
} catch {
|
|
@@ -6987,7 +7599,7 @@ function isSourceNewer(packageDir) {
|
|
|
6987
7599
|
* `copyDirRecursive` for the wedge this prevents.
|
|
6988
7600
|
*/
|
|
6989
7601
|
async function installPackageFromNpm(packageName, targetDir) {
|
|
6990
|
-
const tmpDir = await fs.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
|
|
7602
|
+
const tmpDir = await fs$1.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
|
|
6991
7603
|
try {
|
|
6992
7604
|
const { stdout } = await execFileAsync$4("npm", [
|
|
6993
7605
|
"pack",
|
|
@@ -7010,21 +7622,21 @@ async function installPackageFromNpm(packageName, targetDir) {
|
|
|
7010
7622
|
extractDir
|
|
7011
7623
|
], { timeout: 3e4 });
|
|
7012
7624
|
const packageSubDir = path$1.join(extractDir, "package");
|
|
7013
|
-
const srcPkgJsonDir = fs.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
|
|
7014
|
-
await fs.promises.rm(targetDir, {
|
|
7625
|
+
const srcPkgJsonDir = fs$1.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
|
|
7626
|
+
await fs$1.promises.rm(targetDir, {
|
|
7015
7627
|
recursive: true,
|
|
7016
7628
|
force: true
|
|
7017
7629
|
});
|
|
7018
7630
|
ensureDir(targetDir);
|
|
7019
|
-
await fs.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
|
|
7631
|
+
await fs$1.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
|
|
7020
7632
|
const distSrc = path$1.join(srcPkgJsonDir, "dist");
|
|
7021
|
-
if (fs.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
|
|
7633
|
+
if (fs$1.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
|
|
7022
7634
|
try {
|
|
7023
|
-
const npmPkg = asJsonObject$1(parseJsonUnknown(await fs.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
|
|
7635
|
+
const npmPkg = asJsonObject$1(parseJsonUnknown(await fs$1.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
|
|
7024
7636
|
if (npmPkg) await copyExtraFileDirs(npmPkg, srcPkgJsonDir, targetDir);
|
|
7025
7637
|
} catch {}
|
|
7026
7638
|
} finally {
|
|
7027
|
-
await fs.promises.rm(tmpDir, {
|
|
7639
|
+
await fs$1.promises.rm(tmpDir, {
|
|
7028
7640
|
recursive: true,
|
|
7029
7641
|
force: true
|
|
7030
7642
|
});
|
|
@@ -7049,7 +7661,7 @@ function packageDirName$1(declaredName) {
|
|
|
7049
7661
|
}
|
|
7050
7662
|
function isDirLike$1(p) {
|
|
7051
7663
|
try {
|
|
7052
|
-
return fs.statSync(p).isDirectory();
|
|
7664
|
+
return fs$1.statSync(p).isDirectory();
|
|
7053
7665
|
} catch {
|
|
7054
7666
|
return false;
|
|
7055
7667
|
}
|
|
@@ -7067,12 +7679,12 @@ var AddonManifest = class {
|
|
|
7067
7679
|
*/
|
|
7068
7680
|
read() {
|
|
7069
7681
|
if (this.cache != null) return this.cache;
|
|
7070
|
-
if (!fs.existsSync(this.manifestPath)) {
|
|
7682
|
+
if (!fs$1.existsSync(this.manifestPath)) {
|
|
7071
7683
|
this.cache = this.empty();
|
|
7072
7684
|
return this.cache;
|
|
7073
7685
|
}
|
|
7074
7686
|
try {
|
|
7075
|
-
const raw = fs.readFileSync(this.manifestPath, "utf-8");
|
|
7687
|
+
const raw = fs$1.readFileSync(this.manifestPath, "utf-8");
|
|
7076
7688
|
const parsed = JSON.parse(raw);
|
|
7077
7689
|
if (parsed.version !== MANIFEST_VERSION) {
|
|
7078
7690
|
process.stderr.write(`[AddonManifest] schema mismatch (file=${parsed.version} vs runtime=${MANIFEST_VERSION}); starting empty\n`);
|
|
@@ -7093,13 +7705,13 @@ var AddonManifest = class {
|
|
|
7093
7705
|
* a half-written file.
|
|
7094
7706
|
*/
|
|
7095
7707
|
write(manifest) {
|
|
7096
|
-
fs.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
|
|
7708
|
+
fs$1.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
|
|
7097
7709
|
const tmp = `${this.manifestPath}.tmp.${process.pid}.${Date.now()}`;
|
|
7098
|
-
fs.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
|
|
7710
|
+
fs$1.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
|
|
7099
7711
|
encoding: "utf-8",
|
|
7100
7712
|
mode: 384
|
|
7101
7713
|
});
|
|
7102
|
-
fs.renameSync(tmp, this.manifestPath);
|
|
7714
|
+
fs$1.renameSync(tmp, this.manifestPath);
|
|
7103
7715
|
this.cache = manifest;
|
|
7104
7716
|
}
|
|
7105
7717
|
/** Lookup a single addon's manifest entry, or `null` if not tracked. */
|
|
@@ -7174,22 +7786,22 @@ var AddonManifest = class {
|
|
|
7174
7786
|
* exactly what moved. Returns the total number of changes.
|
|
7175
7787
|
*/
|
|
7176
7788
|
reconcileFromDisk(addonsDir, onChange) {
|
|
7177
|
-
if (!fs.existsSync(addonsDir)) return 0;
|
|
7789
|
+
if (!fs$1.existsSync(addonsDir)) return 0;
|
|
7178
7790
|
const m = this.read();
|
|
7179
7791
|
let changes = 0;
|
|
7180
7792
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7181
7793
|
/** Package name → version, for every ADDON package actually installed. */
|
|
7182
7794
|
const onDisk = /* @__PURE__ */ new Map();
|
|
7183
|
-
for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
|
|
7795
|
+
for (const scope of fs$1.readdirSync(addonsDir, { withFileTypes: true })) {
|
|
7184
7796
|
if (!scope.name.startsWith("@") || !isDirLike$1(path$1.join(addonsDir, scope.name))) continue;
|
|
7185
7797
|
const scopeDir = path$1.join(addonsDir, scope.name);
|
|
7186
|
-
for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
|
|
7798
|
+
for (const pkg of fs$1.readdirSync(scopeDir, { withFileTypes: true })) {
|
|
7187
7799
|
if (!isDirLike$1(path$1.join(scopeDir, pkg.name))) continue;
|
|
7188
7800
|
const pkgJsonPath = path$1.join(scopeDir, pkg.name, "package.json");
|
|
7189
|
-
if (!fs.existsSync(pkgJsonPath)) continue;
|
|
7801
|
+
if (!fs$1.existsSync(pkgJsonPath)) continue;
|
|
7190
7802
|
let pkgJson;
|
|
7191
7803
|
try {
|
|
7192
|
-
const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
7804
|
+
const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
|
|
7193
7805
|
if (typeof parsed !== "object" || parsed == null) continue;
|
|
7194
7806
|
pkgJson = parsed;
|
|
7195
7807
|
} catch {
|
|
@@ -7260,28 +7872,28 @@ var AddonManifest = class {
|
|
|
7260
7872
|
migrateFromInstallSourceMarkers(addonsDir) {
|
|
7261
7873
|
const m = this.read();
|
|
7262
7874
|
if (Object.keys(m.addons).length > 0) return 0;
|
|
7263
|
-
if (!fs.existsSync(addonsDir)) return 0;
|
|
7875
|
+
if (!fs$1.existsSync(addonsDir)) return 0;
|
|
7264
7876
|
let migrated = 0;
|
|
7265
7877
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7266
|
-
for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
|
|
7878
|
+
for (const scope of fs$1.readdirSync(addonsDir, { withFileTypes: true })) {
|
|
7267
7879
|
if (!scope.isDirectory() || !scope.name.startsWith("@")) continue;
|
|
7268
7880
|
const scopeDir = path$1.join(addonsDir, scope.name);
|
|
7269
|
-
for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
|
|
7881
|
+
for (const pkg of fs$1.readdirSync(scopeDir, { withFileTypes: true })) {
|
|
7270
7882
|
if (!pkg.isDirectory()) continue;
|
|
7271
7883
|
const pkgDir = path$1.join(scopeDir, pkg.name);
|
|
7272
7884
|
const markerPath = path$1.join(pkgDir, ".install-source");
|
|
7273
7885
|
const pkgJsonPath = path$1.join(pkgDir, "package.json");
|
|
7274
|
-
if (!fs.existsSync(pkgJsonPath)) continue;
|
|
7886
|
+
if (!fs$1.existsSync(pkgJsonPath)) continue;
|
|
7275
7887
|
let pkgJson;
|
|
7276
7888
|
try {
|
|
7277
|
-
const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
7889
|
+
const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
|
|
7278
7890
|
if (typeof parsed !== "object" || parsed == null) continue;
|
|
7279
7891
|
pkgJson = parsed;
|
|
7280
7892
|
} catch {
|
|
7281
7893
|
continue;
|
|
7282
7894
|
}
|
|
7283
7895
|
if (!pkgJson.name || !pkgJson.version) continue;
|
|
7284
|
-
const source = fs.existsSync(markerPath) ? fs.readFileSync(markerPath, "utf-8").trim() : "bundled";
|
|
7896
|
+
const source = fs$1.existsSync(markerPath) ? fs$1.readFileSync(markerPath, "utf-8").trim() : "bundled";
|
|
7285
7897
|
m.addons[pkgJson.name] = {
|
|
7286
7898
|
name: pkgJson.name,
|
|
7287
7899
|
version: pkgJson.version,
|
|
@@ -7485,7 +8097,7 @@ function planClosureDedupe(input) {
|
|
|
7485
8097
|
function readTreeManifest(pkgJsonPath) {
|
|
7486
8098
|
let raw;
|
|
7487
8099
|
try {
|
|
7488
|
-
raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
|
|
8100
|
+
raw = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8")));
|
|
7489
8101
|
} catch {
|
|
7490
8102
|
return null;
|
|
7491
8103
|
}
|
|
@@ -7510,7 +8122,7 @@ function readTreeManifest(pkgJsonPath) {
|
|
|
7510
8122
|
function listTopLevelEntries(nodeModulesDir) {
|
|
7511
8123
|
let entries;
|
|
7512
8124
|
try {
|
|
7513
|
-
entries = fs.readdirSync(nodeModulesDir, { withFileTypes: true });
|
|
8125
|
+
entries = fs$1.readdirSync(nodeModulesDir, { withFileTypes: true });
|
|
7514
8126
|
} catch {
|
|
7515
8127
|
return [];
|
|
7516
8128
|
}
|
|
@@ -7520,7 +8132,7 @@ function listTopLevelEntries(nodeModulesDir) {
|
|
|
7520
8132
|
if (entry.name.startsWith("@")) {
|
|
7521
8133
|
let inner;
|
|
7522
8134
|
try {
|
|
7523
|
-
inner = fs.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
|
|
8135
|
+
inner = fs$1.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
|
|
7524
8136
|
} catch {
|
|
7525
8137
|
continue;
|
|
7526
8138
|
}
|
|
@@ -7553,14 +8165,14 @@ function collectAddonTreeState(addonDir) {
|
|
|
7553
8165
|
const entryDir = path$1.join(nodeModulesDir, name);
|
|
7554
8166
|
let isLink = false;
|
|
7555
8167
|
try {
|
|
7556
|
-
isLink = fs.lstatSync(entryDir).isSymbolicLink();
|
|
8168
|
+
isLink = fs$1.lstatSync(entryDir).isSymbolicLink();
|
|
7557
8169
|
} catch {
|
|
7558
8170
|
continue;
|
|
7559
8171
|
}
|
|
7560
8172
|
if (isLink) {
|
|
7561
8173
|
let target = "";
|
|
7562
8174
|
try {
|
|
7563
|
-
target = fs.readlinkSync(entryDir);
|
|
8175
|
+
target = fs$1.readlinkSync(entryDir);
|
|
7564
8176
|
} catch {}
|
|
7565
8177
|
existingLinks.push({
|
|
7566
8178
|
name,
|
|
@@ -7574,7 +8186,7 @@ function collectAddonTreeState(addonDir) {
|
|
|
7574
8186
|
version: manifest.version
|
|
7575
8187
|
});
|
|
7576
8188
|
for (const [depName, range] of manifest.ranges) {
|
|
7577
|
-
if (fs.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
|
|
8189
|
+
if (fs$1.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
|
|
7578
8190
|
addRange(depName, range);
|
|
7579
8191
|
}
|
|
7580
8192
|
}
|
|
@@ -7604,7 +8216,7 @@ function resolveClosureNodeModulesDir(explicitDir) {
|
|
|
7604
8216
|
const frameworkDir = explicitDir ?? process.env["CAMSTACK_FRAMEWORK_DIR"];
|
|
7605
8217
|
if (frameworkDir === void 0 || frameworkDir.length === 0) return null;
|
|
7606
8218
|
const nodeModulesDir = explicitDir ?? path$1.join(frameworkDir, "node_modules");
|
|
7607
|
-
return fs.existsSync(nodeModulesDir) ? nodeModulesDir : null;
|
|
8219
|
+
return fs$1.existsSync(nodeModulesDir) ? nodeModulesDir : null;
|
|
7608
8220
|
}
|
|
7609
8221
|
function symlinkType() {
|
|
7610
8222
|
return process.platform === "win32" ? "junction" : "dir";
|
|
@@ -7623,10 +8235,10 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
|
|
|
7623
8235
|
const nodeModulesDir = path$1.join(addonDir, "node_modules");
|
|
7624
8236
|
const probePath = path$1.join(nodeModulesDir, ".closure-link-probe");
|
|
7625
8237
|
try {
|
|
7626
|
-
fs.mkdirSync(nodeModulesDir, { recursive: true });
|
|
7627
|
-
fs.rmSync(probePath, { force: true });
|
|
7628
|
-
fs.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
|
|
7629
|
-
fs.rmSync(probePath, { force: true });
|
|
8238
|
+
fs$1.mkdirSync(nodeModulesDir, { recursive: true });
|
|
8239
|
+
fs$1.rmSync(probePath, { force: true });
|
|
8240
|
+
fs$1.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
|
|
8241
|
+
fs$1.rmSync(probePath, { force: true });
|
|
7630
8242
|
} catch (err) {
|
|
7631
8243
|
logger.warn("closure dedupe skipped — symlinks unavailable on this volume", { meta: {
|
|
7632
8244
|
addonDir,
|
|
@@ -7648,12 +8260,12 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
|
|
|
7648
8260
|
}
|
|
7649
8261
|
const entryDir = path$1.join(nodeModulesDir, link.name);
|
|
7650
8262
|
try {
|
|
7651
|
-
fs.rmSync(entryDir, {
|
|
8263
|
+
fs$1.rmSync(entryDir, {
|
|
7652
8264
|
recursive: true,
|
|
7653
8265
|
force: true
|
|
7654
8266
|
});
|
|
7655
|
-
fs.mkdirSync(path$1.dirname(entryDir), { recursive: true });
|
|
7656
|
-
fs.symlinkSync(target, entryDir, symlinkType());
|
|
8267
|
+
fs$1.mkdirSync(path$1.dirname(entryDir), { recursive: true });
|
|
8268
|
+
fs$1.symlinkSync(target, entryDir, symlinkType());
|
|
7657
8269
|
linked.push(link.name);
|
|
7658
8270
|
} catch (err) {
|
|
7659
8271
|
logger.warn("closure dedupe — link failed; entry removed copy may need reinstall", { meta: {
|
|
@@ -7729,7 +8341,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
|
|
|
7729
8341
|
count: Object.keys(native).length
|
|
7730
8342
|
} });
|
|
7731
8343
|
try {
|
|
7732
|
-
fs.writeFileSync(markerFile, markerHash);
|
|
8344
|
+
fs$1.writeFileSync(markerFile, markerHash);
|
|
7733
8345
|
} catch (err) {
|
|
7734
8346
|
logger.warn("Failed to write native deps marker", { meta: {
|
|
7735
8347
|
markerFile,
|
|
@@ -7767,7 +8379,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
|
|
|
7767
8379
|
}
|
|
7768
8380
|
await rebuildNativeDeps(addonDir, pending.map(([name]) => name), logger, npmCacheDir ?? defaultNpmCacheDir(), registry);
|
|
7769
8381
|
try {
|
|
7770
|
-
fs.writeFileSync(markerFile, markerHash);
|
|
8382
|
+
fs$1.writeFileSync(markerFile, markerHash);
|
|
7771
8383
|
} catch (err) {
|
|
7772
8384
|
logger.warn("Failed to write native deps marker", { meta: {
|
|
7773
8385
|
markerFile,
|
|
@@ -7789,12 +8401,12 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
|
|
|
7789
8401
|
if (source === target) continue;
|
|
7790
8402
|
if (!hasBuiltBinary(source)) continue;
|
|
7791
8403
|
try {
|
|
7792
|
-
fs.rmSync(target, {
|
|
8404
|
+
fs$1.rmSync(target, {
|
|
7793
8405
|
recursive: true,
|
|
7794
8406
|
force: true
|
|
7795
8407
|
});
|
|
7796
|
-
fs.mkdirSync(path$1.dirname(target), { recursive: true });
|
|
7797
|
-
fs.cpSync(source, target, {
|
|
8408
|
+
fs$1.mkdirSync(path$1.dirname(target), { recursive: true });
|
|
8409
|
+
fs$1.cpSync(source, target, {
|
|
7798
8410
|
recursive: true,
|
|
7799
8411
|
dereference: true
|
|
7800
8412
|
});
|
|
@@ -7830,7 +8442,7 @@ var BUNDLED_NATIVE_SIBLING_SCOPES = {
|
|
|
7830
8442
|
function hasAnyDotNode(dir, maxDepth) {
|
|
7831
8443
|
let entries;
|
|
7832
8444
|
try {
|
|
7833
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
8445
|
+
entries = fs$1.readdirSync(dir, { withFileTypes: true });
|
|
7834
8446
|
} catch {
|
|
7835
8447
|
return false;
|
|
7836
8448
|
}
|
|
@@ -7844,12 +8456,12 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
|
|
|
7844
8456
|
if (!hasAnyDotNode(src, 5)) return;
|
|
7845
8457
|
if (hasAnyDotNode(dst, 5)) return;
|
|
7846
8458
|
try {
|
|
7847
|
-
fs.rmSync(dst, {
|
|
8459
|
+
fs$1.rmSync(dst, {
|
|
7848
8460
|
recursive: true,
|
|
7849
8461
|
force: true
|
|
7850
8462
|
});
|
|
7851
|
-
fs.mkdirSync(path$1.dirname(dst), { recursive: true });
|
|
7852
|
-
fs.cpSync(src, dst, {
|
|
8463
|
+
fs$1.mkdirSync(path$1.dirname(dst), { recursive: true });
|
|
8464
|
+
fs$1.cpSync(src, dst, {
|
|
7853
8465
|
recursive: true,
|
|
7854
8466
|
dereference: true
|
|
7855
8467
|
});
|
|
@@ -7884,7 +8496,7 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
|
|
|
7884
8496
|
*/
|
|
7885
8497
|
function copyBundledNativeModules(sourceDir, targetDir, logger) {
|
|
7886
8498
|
const srcNm = path$1.join(sourceDir, "node_modules");
|
|
7887
|
-
if (!fs.existsSync(srcNm)) return;
|
|
8499
|
+
if (!fs$1.existsSync(srcNm)) return;
|
|
7888
8500
|
const dstNm = path$1.join(targetDir, "node_modules");
|
|
7889
8501
|
for (const [name, scopes] of Object.entries(BUNDLED_NATIVE_SIBLING_SCOPES)) {
|
|
7890
8502
|
copyPrebuiltModuleDir(path$1.join(srcNm, name), path$1.join(dstNm, name), name, logger);
|
|
@@ -7892,7 +8504,7 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
|
|
|
7892
8504
|
const scopeSrc = path$1.join(srcNm, scope);
|
|
7893
8505
|
let siblings;
|
|
7894
8506
|
try {
|
|
7895
|
-
siblings = fs.readdirSync(scopeSrc);
|
|
8507
|
+
siblings = fs$1.readdirSync(scopeSrc);
|
|
7896
8508
|
} catch {
|
|
7897
8509
|
continue;
|
|
7898
8510
|
}
|
|
@@ -7902,12 +8514,12 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
|
|
|
7902
8514
|
}
|
|
7903
8515
|
/** A package dir is "built" when it carries a compiled `.node` or a prebuilds tree. */
|
|
7904
8516
|
function hasBuiltBinary(pkgDir) {
|
|
7905
|
-
if (!fs.existsSync(path$1.join(pkgDir, "package.json"))) return false;
|
|
8517
|
+
if (!fs$1.existsSync(path$1.join(pkgDir, "package.json"))) return false;
|
|
7906
8518
|
const releaseDir = path$1.join(pkgDir, "build", "Release");
|
|
7907
8519
|
try {
|
|
7908
|
-
if (fs.existsSync(releaseDir) && fs.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
|
|
8520
|
+
if (fs$1.existsSync(releaseDir) && fs$1.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
|
|
7909
8521
|
} catch {}
|
|
7910
|
-
return fs.existsSync(path$1.join(pkgDir, "prebuilds"));
|
|
8522
|
+
return fs$1.existsSync(path$1.join(pkgDir, "prebuilds"));
|
|
7911
8523
|
}
|
|
7912
8524
|
/** Candidate hoisted locations for `<name>`: NODE_PATH entries + ancestors of `addonDir`. */
|
|
7913
8525
|
function candidateHoistedDirs(name, addonDir) {
|
|
@@ -7945,7 +8557,7 @@ function hashDeclaration(deps) {
|
|
|
7945
8557
|
}
|
|
7946
8558
|
function markerMatches(markerFile, expected) {
|
|
7947
8559
|
try {
|
|
7948
|
-
return fs.readFileSync(markerFile, "utf-8").trim() === expected;
|
|
8560
|
+
return fs$1.readFileSync(markerFile, "utf-8").trim() === expected;
|
|
7949
8561
|
} catch {
|
|
7950
8562
|
return false;
|
|
7951
8563
|
}
|
|
@@ -8156,7 +8768,7 @@ function parseInstallSource(value) {
|
|
|
8156
8768
|
function readPackageJson(pkgJsonPath) {
|
|
8157
8769
|
let raw;
|
|
8158
8770
|
try {
|
|
8159
|
-
raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
|
|
8771
|
+
raw = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8")));
|
|
8160
8772
|
} catch {
|
|
8161
8773
|
return null;
|
|
8162
8774
|
}
|
|
@@ -8200,7 +8812,7 @@ var REGISTRY_LATEST_TIMEOUT_MS = 15e3;
|
|
|
8200
8812
|
var FALLBACK_VERSION_PROBES = 25;
|
|
8201
8813
|
function readInstalledPackageVersion(addonDir) {
|
|
8202
8814
|
try {
|
|
8203
|
-
const raw = JSON.parse(fs.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
|
|
8815
|
+
const raw = JSON.parse(fs$1.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
|
|
8204
8816
|
if (raw === null || typeof raw !== "object") return null;
|
|
8205
8817
|
const version = Reflect.get(raw, "version");
|
|
8206
8818
|
return typeof version === "string" && version.length > 0 ? version : null;
|
|
@@ -8348,7 +8960,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8348
8960
|
} catch {
|
|
8349
8961
|
return Object.freeze([]);
|
|
8350
8962
|
}
|
|
8351
|
-
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
8963
|
+
const raw = fs$1.readFileSync(pkgPath, "utf-8");
|
|
8352
8964
|
const parsed = JSON.parse(raw);
|
|
8353
8965
|
const deps = Object.keys(parsed.dependencies ?? {});
|
|
8354
8966
|
const agentOnly = new Set(parsed.camstack?.agentOnlyBootstrapAddons ?? []);
|
|
@@ -8393,7 +9005,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8393
9005
|
} catch {
|
|
8394
9006
|
return Object.freeze([]);
|
|
8395
9007
|
}
|
|
8396
|
-
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
9008
|
+
const raw = fs$1.readFileSync(pkgPath, "utf-8");
|
|
8397
9009
|
const addons = JSON.parse(raw).camstack?.agentBootstrapAddons ?? [];
|
|
8398
9010
|
return Object.freeze(["@camstack/server", ...addons]);
|
|
8399
9011
|
}
|
|
@@ -8423,7 +9035,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8423
9035
|
this.logger.info(`Install source: ${isLocal ? `bundle (${this.bundledAddonsDir})` : "npm"}, ${pkgList.length} package(s)`);
|
|
8424
9036
|
for (const packageName of pkgList) {
|
|
8425
9037
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
8426
|
-
if (fs.existsSync(path$1.join(addonDir, "package.json"))) {
|
|
9038
|
+
if (fs$1.existsSync(path$1.join(addonDir, "package.json"))) {
|
|
8427
9039
|
if (isLocal || shouldSkipClosureProvidedSeed(packageName, this.isResolvableFromClosure(packageName))) {
|
|
8428
9040
|
this.logger.debug(`${packageName} — already installed, skipping`);
|
|
8429
9041
|
continue;
|
|
@@ -8674,7 +9286,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8674
9286
|
const installedPackages = this.listInstalled();
|
|
8675
9287
|
for (const pkg of installedPackages) {
|
|
8676
9288
|
try {
|
|
8677
|
-
if (fs.lstatSync(pkg.dir).isSymbolicLink()) continue;
|
|
9289
|
+
if (fs$1.lstatSync(pkg.dir).isSymbolicLink()) continue;
|
|
8678
9290
|
} catch {
|
|
8679
9291
|
continue;
|
|
8680
9292
|
}
|
|
@@ -8714,7 +9326,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8714
9326
|
if (closureNodeModules !== null) for (const link of state.existingLinks) {
|
|
8715
9327
|
if (!isClosureLinkTarget(link.target, closureNodeModules)) continue;
|
|
8716
9328
|
const linkDir = path$1.join(nodeModulesDir, link.name);
|
|
8717
|
-
const targetManifest = fs.existsSync(path$1.join(linkDir, "package.json"));
|
|
9329
|
+
const targetManifest = fs$1.existsSync(path$1.join(linkDir, "package.json"));
|
|
8718
9330
|
const ranges = state.requirements.get(link.name) ?? [];
|
|
8719
9331
|
let holds = targetManifest;
|
|
8720
9332
|
if (holds && ranges.length > 0) {
|
|
@@ -8723,14 +9335,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8723
9335
|
}
|
|
8724
9336
|
if (!holds) {
|
|
8725
9337
|
this.logger.warn(`${packageName} — closure link for ${link.name} no longer holds; reinstalling this addon's deps`, { meta: { target: link.target } });
|
|
8726
|
-
fs.rmSync(linkDir, { force: true });
|
|
9338
|
+
fs$1.rmSync(linkDir, { force: true });
|
|
8727
9339
|
needsInstall = true;
|
|
8728
9340
|
}
|
|
8729
9341
|
}
|
|
8730
9342
|
const linked = [];
|
|
8731
9343
|
for (const [depName, range] of declaredEntries) {
|
|
8732
9344
|
if (typeof range !== "string") continue;
|
|
8733
|
-
if (fs.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
|
|
9345
|
+
if (fs$1.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
|
|
8734
9346
|
const closureVersion = closureNodeModules === null ? void 0 : readClosureVersions(closureNodeModules, [depName]).get(depName);
|
|
8735
9347
|
if (closureNodeModules !== null && closureVersion !== void 0 && closureSatisfiesRange(range, closureVersion)) {
|
|
8736
9348
|
if (executeClosureDedupe(addonDir, closureNodeModules, {
|
|
@@ -8763,7 +9375,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8763
9375
|
const closureNodeModules = resolveClosureNodeModulesDir(this.closureNodeModulesDir);
|
|
8764
9376
|
if (closureNodeModules !== null) {
|
|
8765
9377
|
const state = collectAddonTreeState(addonDir);
|
|
8766
|
-
for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
|
|
9378
|
+
for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs$1.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
|
|
8767
9379
|
}
|
|
8768
9380
|
this.logger.info(`${packageName} — reinstalling runtime dependencies`, { meta: { addonDir } });
|
|
8769
9381
|
await runNpm([
|
|
@@ -8808,7 +9420,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8808
9420
|
async realignFromClosure(packageName, closureDir) {
|
|
8809
9421
|
const targetDir = path$1.join(this.addonsDir, packageName);
|
|
8810
9422
|
const result = await this.installLocal(packageName, closureDir);
|
|
8811
|
-
await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
|
|
9423
|
+
await fs$1.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
|
|
8812
9424
|
this.manifest.upsert(result.name, {
|
|
8813
9425
|
version: result.version,
|
|
8814
9426
|
source: "closure"
|
|
@@ -8824,17 +9436,17 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8824
9436
|
async installCopy(packageName, sourceDir, pkgData, targetDir) {
|
|
8825
9437
|
await this.ensureBuilt(packageName, sourceDir, pkgData);
|
|
8826
9438
|
const distDir = path$1.join(sourceDir, "dist");
|
|
8827
|
-
if (!fs.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
|
|
8828
|
-
await fs.promises.rm(targetDir, {
|
|
9439
|
+
if (!fs$1.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
|
|
9440
|
+
await fs$1.promises.rm(targetDir, {
|
|
8829
9441
|
recursive: true,
|
|
8830
9442
|
force: true
|
|
8831
9443
|
});
|
|
8832
9444
|
ensureDir(targetDir);
|
|
8833
|
-
await fs.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
|
|
9445
|
+
await fs$1.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
|
|
8834
9446
|
await copyDirRecursive(distDir, path$1.join(targetDir, "dist"));
|
|
8835
9447
|
await copyExtraFileDirs(pkgData, sourceDir, targetDir);
|
|
8836
9448
|
copyBundledNativeModules(sourceDir, targetDir, this.logger);
|
|
8837
|
-
await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
|
|
9449
|
+
await fs$1.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
|
|
8838
9450
|
const localPkgVersion = asString$1(pkgData.version, "0.0.0");
|
|
8839
9451
|
this.manifest.upsert(packageName, {
|
|
8840
9452
|
version: localPkgVersion,
|
|
@@ -8875,7 +9487,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8875
9487
|
* unusual auth, offline mode, etc).
|
|
8876
9488
|
*/
|
|
8877
9489
|
async installFromNpm(packageName, version) {
|
|
8878
|
-
const tmpDir = fs.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
|
|
9490
|
+
const tmpDir = fs$1.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
|
|
8879
9491
|
const packageSpec = version ? `${packageName}@${version}` : packageName;
|
|
8880
9492
|
this.logger.info(`${packageName} — installing from npm`);
|
|
8881
9493
|
try {
|
|
@@ -8889,19 +9501,19 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8889
9501
|
];
|
|
8890
9502
|
if (this.registry) args.push("--registry", this.registry);
|
|
8891
9503
|
const { stdout } = await runNpm(args, this.npmRunOptions(tmpDir, 12e4));
|
|
8892
|
-
const tgzFiles = fs.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
|
|
9504
|
+
const tgzFiles = fs$1.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
|
|
8893
9505
|
if (tgzFiles.length === 0) throw new Error(`npm pack produced no tgz. stdout: ${stdout.trim()}`);
|
|
8894
9506
|
return path$1.join(tmpDir, tgzFiles[0]);
|
|
8895
9507
|
});
|
|
8896
9508
|
const result = await this.installFromTgz(tgzPath);
|
|
8897
|
-
fs.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
|
|
9509
|
+
fs$1.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
|
|
8898
9510
|
this.manifest.upsert(result.name, {
|
|
8899
9511
|
version: result.version,
|
|
8900
9512
|
source: "npm"
|
|
8901
9513
|
});
|
|
8902
9514
|
return result;
|
|
8903
9515
|
} finally {
|
|
8904
|
-
fs.rmSync(tmpDir, {
|
|
9516
|
+
fs$1.rmSync(tmpDir, {
|
|
8905
9517
|
recursive: true,
|
|
8906
9518
|
force: true
|
|
8907
9519
|
});
|
|
@@ -8939,7 +9551,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8939
9551
|
if (!tarRes.ok) throw new Error(`tarball GET ${tarballUrl} → ${tarRes.status}`);
|
|
8940
9552
|
const tgzPath = path$1.join(tmpDir, `${packageName.replace(/[/@]/g, "-").replace(/^-+/, "")}-${resolvedVersion}.tgz`);
|
|
8941
9553
|
const buf = Buffer.from(await tarRes.arrayBuffer());
|
|
8942
|
-
fs.writeFileSync(tgzPath, buf);
|
|
9554
|
+
fs$1.writeFileSync(tgzPath, buf);
|
|
8943
9555
|
return tgzPath;
|
|
8944
9556
|
}
|
|
8945
9557
|
/**
|
|
@@ -8960,7 +9572,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8960
9572
|
* on the next deploy.
|
|
8961
9573
|
*/
|
|
8962
9574
|
async evictInstallDir(targetDir) {
|
|
8963
|
-
if (!fs.existsSync(targetDir)) return;
|
|
9575
|
+
if (!fs$1.existsSync(targetDir)) return;
|
|
8964
9576
|
const graveyard = path$1.join(this.addonsDir, ".evicting");
|
|
8965
9577
|
ensureDir(graveyard);
|
|
8966
9578
|
await this.sweepGraveyard(graveyard);
|
|
@@ -8968,10 +9580,10 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8968
9580
|
const flatName = path$1.relative(this.addonsDir, targetDir).replace(/[/\\]/g, "-");
|
|
8969
9581
|
const asideDir = path$1.join(graveyard, `${flatName}-${ts}`);
|
|
8970
9582
|
try {
|
|
8971
|
-
fs.renameSync(targetDir, asideDir);
|
|
9583
|
+
fs$1.renameSync(targetDir, asideDir);
|
|
8972
9584
|
} catch (renameErr) {
|
|
8973
9585
|
if (renameErr.code === "EXDEV") {
|
|
8974
|
-
await fs.promises.rm(targetDir, {
|
|
9586
|
+
await fs$1.promises.rm(targetDir, {
|
|
8975
9587
|
recursive: true,
|
|
8976
9588
|
force: true
|
|
8977
9589
|
});
|
|
@@ -8979,7 +9591,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8979
9591
|
}
|
|
8980
9592
|
throw renameErr;
|
|
8981
9593
|
}
|
|
8982
|
-
await fs.promises.rm(asideDir, {
|
|
9594
|
+
await fs$1.promises.rm(asideDir, {
|
|
8983
9595
|
recursive: true,
|
|
8984
9596
|
force: true
|
|
8985
9597
|
}).catch((cleanupErr) => {
|
|
@@ -9000,14 +9612,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9000
9612
|
async sweepStagingResidue(stagingRoot) {
|
|
9001
9613
|
let names;
|
|
9002
9614
|
try {
|
|
9003
|
-
names = fs.readdirSync(stagingRoot);
|
|
9615
|
+
names = fs$1.readdirSync(stagingRoot);
|
|
9004
9616
|
} catch {
|
|
9005
9617
|
return;
|
|
9006
9618
|
}
|
|
9007
9619
|
const now = Date.now();
|
|
9008
9620
|
const ages = [];
|
|
9009
9621
|
for (const name of names) try {
|
|
9010
|
-
const stat = fs.statSync(path$1.join(stagingRoot, name));
|
|
9622
|
+
const stat = fs$1.statSync(path$1.join(stagingRoot, name));
|
|
9011
9623
|
ages.push({
|
|
9012
9624
|
name,
|
|
9013
9625
|
ageMs: now - stat.mtimeMs
|
|
@@ -9018,7 +9630,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9018
9630
|
stagingRoot,
|
|
9019
9631
|
entries: sweepable
|
|
9020
9632
|
} });
|
|
9021
|
-
await Promise.all(sweepable.map((name) => fs.promises.rm(path$1.join(stagingRoot, name), {
|
|
9633
|
+
await Promise.all(sweepable.map((name) => fs$1.promises.rm(path$1.join(stagingRoot, name), {
|
|
9022
9634
|
recursive: true,
|
|
9023
9635
|
force: true
|
|
9024
9636
|
}).catch(() => void 0)));
|
|
@@ -9027,11 +9639,11 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9027
9639
|
async sweepGraveyard(graveyard) {
|
|
9028
9640
|
let entries;
|
|
9029
9641
|
try {
|
|
9030
|
-
entries = fs.readdirSync(graveyard);
|
|
9642
|
+
entries = fs$1.readdirSync(graveyard);
|
|
9031
9643
|
} catch {
|
|
9032
9644
|
return;
|
|
9033
9645
|
}
|
|
9034
|
-
await Promise.all(entries.map((name) => fs.promises.rm(path$1.join(graveyard, name), {
|
|
9646
|
+
await Promise.all(entries.map((name) => fs$1.promises.rm(path$1.join(graveyard, name), {
|
|
9035
9647
|
recursive: true,
|
|
9036
9648
|
force: true
|
|
9037
9649
|
}).catch(() => void 0)));
|
|
@@ -9082,7 +9694,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9082
9694
|
return;
|
|
9083
9695
|
}
|
|
9084
9696
|
const strippedManifest = stripBundledDeps(pkgView.raw);
|
|
9085
|
-
await fs.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
|
|
9697
|
+
await fs$1.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
|
|
9086
9698
|
const deps = asJsonObject$1(strippedManifest["dependencies"]);
|
|
9087
9699
|
const depNames = deps ? Object.keys(deps) : [];
|
|
9088
9700
|
if (depNames.length === 0) return;
|
|
@@ -9214,9 +9826,9 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9214
9826
|
"-C",
|
|
9215
9827
|
stagingDir
|
|
9216
9828
|
], { timeout: 12e4 });
|
|
9217
|
-
const pkgDir = fs.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
|
|
9829
|
+
const pkgDir = fs$1.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
|
|
9218
9830
|
const pkgJsonPath = path$1.join(pkgDir, "package.json");
|
|
9219
|
-
if (!fs.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
|
|
9831
|
+
if (!fs$1.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
|
|
9220
9832
|
const pkgView = readPackageJson(pkgJsonPath);
|
|
9221
9833
|
if (!pkgView) throw new Error(`Invalid package.json at ${pkgJsonPath}`);
|
|
9222
9834
|
if (!pkgView.camstackAddons) throw new Error(`Package ${pkgView.name} has no camstack.addons manifest`);
|
|
@@ -9226,7 +9838,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9226
9838
|
this.dedupeTreeAgainstClosure(pkgDir, pkgView.name);
|
|
9227
9839
|
await this.evictInstallDir(targetDir);
|
|
9228
9840
|
ensureDir(path$1.dirname(targetDir));
|
|
9229
|
-
await fs.promises.rename(pkgDir, targetDir);
|
|
9841
|
+
await fs$1.promises.rename(pkgDir, targetDir);
|
|
9230
9842
|
this.manifest.upsert(pkgView.name, {
|
|
9231
9843
|
version: pkgView.version,
|
|
9232
9844
|
source: "bundled"
|
|
@@ -9237,7 +9849,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9237
9849
|
};
|
|
9238
9850
|
} finally {
|
|
9239
9851
|
this.inFlightStaging.delete(stagingName);
|
|
9240
|
-
await fs.promises.rm(stagingDir, {
|
|
9852
|
+
await fs$1.promises.rm(stagingDir, {
|
|
9241
9853
|
recursive: true,
|
|
9242
9854
|
force: true
|
|
9243
9855
|
}).catch(() => void 0);
|
|
@@ -9267,24 +9879,24 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9267
9879
|
const current = this.manifest.get(packageName);
|
|
9268
9880
|
if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
|
|
9269
9881
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9270
|
-
if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
|
|
9882
|
+
if (!fs$1.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
|
|
9271
9883
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
9272
9884
|
const backupRoot = path$1.join(this.addonsDir, ".backups", packageName);
|
|
9273
9885
|
ensureDir(backupRoot);
|
|
9274
9886
|
const backupDir = path$1.join(backupRoot, ts);
|
|
9275
9887
|
this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
|
|
9276
|
-
fs.renameSync(addonDir, backupDir);
|
|
9888
|
+
fs$1.renameSync(addonDir, backupDir);
|
|
9277
9889
|
let result;
|
|
9278
9890
|
try {
|
|
9279
9891
|
result = await this.installFromNpm(packageName, version);
|
|
9280
9892
|
} catch (installErr) {
|
|
9281
9893
|
this.logger.error(`${packageName} — install failed, restoring backup`, { meta: { error: errMsg$1(installErr) } });
|
|
9282
9894
|
try {
|
|
9283
|
-
if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
|
|
9895
|
+
if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
|
|
9284
9896
|
recursive: true,
|
|
9285
9897
|
force: true
|
|
9286
9898
|
});
|
|
9287
|
-
fs.renameSync(backupDir, addonDir);
|
|
9899
|
+
fs$1.renameSync(backupDir, addonDir);
|
|
9288
9900
|
this.manifest.upsert(packageName, {
|
|
9289
9901
|
version: current.version,
|
|
9290
9902
|
source: current.source,
|
|
@@ -9345,7 +9957,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9345
9957
|
const current = this.manifest.get(packageName);
|
|
9346
9958
|
if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
|
|
9347
9959
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9348
|
-
if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
|
|
9960
|
+
if (!fs$1.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
|
|
9349
9961
|
await this.installRuntimeDependencies(stagedPath, packageName);
|
|
9350
9962
|
await this.installNativeDependencies(stagedPath, packageName);
|
|
9351
9963
|
this.dedupeTreeAgainstClosure(stagedPath, packageName);
|
|
@@ -9354,14 +9966,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9354
9966
|
ensureDir(backupRoot);
|
|
9355
9967
|
const backupDir = path$1.join(backupRoot, ts);
|
|
9356
9968
|
this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
|
|
9357
|
-
fs.renameSync(addonDir, backupDir);
|
|
9969
|
+
fs$1.renameSync(addonDir, backupDir);
|
|
9358
9970
|
try {
|
|
9359
9971
|
try {
|
|
9360
|
-
fs.renameSync(stagedPath, addonDir);
|
|
9972
|
+
fs$1.renameSync(stagedPath, addonDir);
|
|
9361
9973
|
} catch (renameErr) {
|
|
9362
9974
|
if (renameErr.code === "EXDEV") {
|
|
9363
|
-
fs.cpSync(stagedPath, addonDir, { recursive: true });
|
|
9364
|
-
fs.rmSync(stagedPath, {
|
|
9975
|
+
fs$1.cpSync(stagedPath, addonDir, { recursive: true });
|
|
9976
|
+
fs$1.rmSync(stagedPath, {
|
|
9365
9977
|
recursive: true,
|
|
9366
9978
|
force: true
|
|
9367
9979
|
});
|
|
@@ -9370,11 +9982,11 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9370
9982
|
} catch (swapErr) {
|
|
9371
9983
|
this.logger.error(`${packageName} — staged swap failed, restoring backup`, { meta: { error: errMsg$1(swapErr) } });
|
|
9372
9984
|
try {
|
|
9373
|
-
if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
|
|
9985
|
+
if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
|
|
9374
9986
|
recursive: true,
|
|
9375
9987
|
force: true
|
|
9376
9988
|
});
|
|
9377
|
-
fs.renameSync(backupDir, addonDir);
|
|
9989
|
+
fs$1.renameSync(backupDir, addonDir);
|
|
9378
9990
|
this.manifest.upsert(packageName, {
|
|
9379
9991
|
version: current.version,
|
|
9380
9992
|
source: current.source,
|
|
@@ -9413,20 +10025,20 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9413
10025
|
this.logger.warn(`${packageName} — no backup to rollback to`);
|
|
9414
10026
|
return null;
|
|
9415
10027
|
}
|
|
9416
|
-
if (!fs.existsSync(entry.lastBackupDir)) {
|
|
10028
|
+
if (!fs$1.existsSync(entry.lastBackupDir)) {
|
|
9417
10029
|
this.logger.warn(`${packageName} — backup dir vanished: ${entry.lastBackupDir}`);
|
|
9418
10030
|
return null;
|
|
9419
10031
|
}
|
|
9420
10032
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9421
|
-
if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
|
|
10033
|
+
if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
|
|
9422
10034
|
recursive: true,
|
|
9423
10035
|
force: true
|
|
9424
10036
|
});
|
|
9425
|
-
fs.renameSync(entry.lastBackupDir, addonDir);
|
|
10037
|
+
fs$1.renameSync(entry.lastBackupDir, addonDir);
|
|
9426
10038
|
const pkgJsonPath = path$1.join(addonDir, "package.json");
|
|
9427
10039
|
let restoredVersion = entry.version;
|
|
9428
|
-
if (fs.existsSync(pkgJsonPath)) try {
|
|
9429
|
-
const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
10040
|
+
if (fs$1.existsSync(pkgJsonPath)) try {
|
|
10041
|
+
const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
|
|
9430
10042
|
if (typeof parsed === "object" && parsed != null) {
|
|
9431
10043
|
const v = parsed.version;
|
|
9432
10044
|
if (typeof v === "string" && v.length > 0) restoredVersion = v;
|
|
@@ -9474,7 +10086,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9474
10086
|
return false;
|
|
9475
10087
|
}
|
|
9476
10088
|
try {
|
|
9477
|
-
await fs.promises.rm(target, {
|
|
10089
|
+
await fs$1.promises.rm(target, {
|
|
9478
10090
|
recursive: true,
|
|
9479
10091
|
force: true
|
|
9480
10092
|
});
|
|
@@ -9492,7 +10104,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9492
10104
|
listBackupsFor(packageName) {
|
|
9493
10105
|
const dir = path$1.join(this.backupsRoot, packageName);
|
|
9494
10106
|
try {
|
|
9495
|
-
return fs.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
|
|
10107
|
+
return fs$1.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
|
|
9496
10108
|
} catch {
|
|
9497
10109
|
return [];
|
|
9498
10110
|
}
|
|
@@ -9524,7 +10136,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9524
10136
|
for (const dir of [pkgDir, path$1.dirname(pkgDir)]) {
|
|
9525
10137
|
if (!this.isInsideBackups(dir)) continue;
|
|
9526
10138
|
try {
|
|
9527
|
-
await fs.promises.rmdir(dir);
|
|
10139
|
+
await fs$1.promises.rmdir(dir);
|
|
9528
10140
|
} catch {
|
|
9529
10141
|
return;
|
|
9530
10142
|
}
|
|
@@ -9606,7 +10218,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9606
10218
|
*/
|
|
9607
10219
|
resolveBackupToKeep(packageName, backups) {
|
|
9608
10220
|
const liveDir = path$1.join(this.addonsDir, packageName);
|
|
9609
|
-
if (!fs.existsSync(liveDir)) {
|
|
10221
|
+
if (!fs$1.existsSync(liveDir)) {
|
|
9610
10222
|
const newest = backups[backups.length - 1] ?? null;
|
|
9611
10223
|
if (newest != null) this.logger.warn(`${packageName} — live install dir missing; retaining its newest backup as the only surviving copy`, { meta: {
|
|
9612
10224
|
liveDir,
|
|
@@ -9623,7 +10235,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9623
10235
|
listBackedUpPackages() {
|
|
9624
10236
|
let entries;
|
|
9625
10237
|
try {
|
|
9626
|
-
entries = fs.readdirSync(this.backupsRoot, { withFileTypes: true });
|
|
10238
|
+
entries = fs$1.readdirSync(this.backupsRoot, { withFileTypes: true });
|
|
9627
10239
|
} catch {
|
|
9628
10240
|
return [];
|
|
9629
10241
|
}
|
|
@@ -9635,14 +10247,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9635
10247
|
continue;
|
|
9636
10248
|
}
|
|
9637
10249
|
const scopeDir = path$1.join(this.backupsRoot, entry.name);
|
|
9638
|
-
for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
|
|
10250
|
+
for (const inner of fs$1.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
|
|
9639
10251
|
}
|
|
9640
10252
|
return names;
|
|
9641
10253
|
}
|
|
9642
10254
|
async uninstall(packageName) {
|
|
9643
10255
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9644
|
-
if (fs.existsSync(addonDir)) {
|
|
9645
|
-
fs.rmSync(addonDir, {
|
|
10256
|
+
if (fs$1.existsSync(addonDir)) {
|
|
10257
|
+
fs$1.rmSync(addonDir, {
|
|
9646
10258
|
recursive: true,
|
|
9647
10259
|
force: true
|
|
9648
10260
|
});
|
|
@@ -9650,8 +10262,8 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9650
10262
|
return;
|
|
9651
10263
|
}
|
|
9652
10264
|
const legacyDir = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""));
|
|
9653
|
-
if (fs.existsSync(legacyDir)) {
|
|
9654
|
-
fs.rmSync(legacyDir, {
|
|
10265
|
+
if (fs$1.existsSync(legacyDir)) {
|
|
10266
|
+
fs$1.rmSync(legacyDir, {
|
|
9655
10267
|
recursive: true,
|
|
9656
10268
|
force: true
|
|
9657
10269
|
});
|
|
@@ -9659,22 +10271,22 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9659
10271
|
}
|
|
9660
10272
|
}
|
|
9661
10273
|
listInstalled() {
|
|
9662
|
-
if (!fs.existsSync(this.addonsDir)) return [];
|
|
10274
|
+
if (!fs$1.existsSync(this.addonsDir)) return [];
|
|
9663
10275
|
const packageDirs = [];
|
|
9664
|
-
for (const entry of fs.readdirSync(this.addonsDir, { withFileTypes: true })) {
|
|
10276
|
+
for (const entry of fs$1.readdirSync(this.addonsDir, { withFileTypes: true })) {
|
|
9665
10277
|
if (!isDirEntry(entry, this.addonsDir)) continue;
|
|
9666
10278
|
if (entry.name.startsWith("@")) {
|
|
9667
10279
|
const scopeDir = path$1.join(this.addonsDir, entry.name);
|
|
9668
|
-
for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
|
|
10280
|
+
for (const inner of fs$1.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
|
|
9669
10281
|
} else packageDirs.push(path$1.join(this.addonsDir, entry.name));
|
|
9670
10282
|
}
|
|
9671
10283
|
return packageDirs.map((dir) => {
|
|
9672
10284
|
const pkgPath = path$1.join(dir, "package.json");
|
|
9673
|
-
if (!fs.existsSync(pkgPath)) return null;
|
|
10285
|
+
if (!fs$1.existsSync(pkgPath)) return null;
|
|
9674
10286
|
const pkg = readPackageJson(pkgPath);
|
|
9675
10287
|
if (!pkg || !pkg.camstackAddons) return null;
|
|
9676
10288
|
const sourceFile = path$1.join(dir, ".install-source");
|
|
9677
|
-
const installSource = fs.existsSync(sourceFile) ? parseInstallSource(fs.readFileSync(sourceFile, "utf-8").trim()) : void 0;
|
|
10289
|
+
const installSource = fs$1.existsSync(sourceFile) ? parseInstallSource(fs$1.readFileSync(sourceFile, "utf-8").trim()) : void 0;
|
|
9678
10290
|
return {
|
|
9679
10291
|
name: pkg.name,
|
|
9680
10292
|
version: pkg.version,
|
|
@@ -9684,13 +10296,13 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9684
10296
|
}).filter((item) => item !== null);
|
|
9685
10297
|
}
|
|
9686
10298
|
isInstalled(packageName) {
|
|
9687
|
-
if (fs.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
|
|
9688
|
-
return fs.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
|
|
10299
|
+
if (fs$1.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
|
|
10300
|
+
return fs$1.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
|
|
9689
10301
|
}
|
|
9690
10302
|
getInstalledPackage(packageName) {
|
|
9691
10303
|
let pkgPath = path$1.join(this.addonsDir, packageName, "package.json");
|
|
9692
|
-
if (!fs.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
|
|
9693
|
-
if (!fs.existsSync(pkgPath)) return null;
|
|
10304
|
+
if (!fs$1.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
|
|
10305
|
+
if (!fs$1.existsSync(pkgPath)) return null;
|
|
9694
10306
|
const pkg = readPackageJson(pkgPath);
|
|
9695
10307
|
if (!pkg) return null;
|
|
9696
10308
|
return {
|
|
@@ -9709,7 +10321,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9709
10321
|
]) {
|
|
9710
10322
|
const candidate = path$1.join(this.bundledAddonsDir, dirName);
|
|
9711
10323
|
try {
|
|
9712
|
-
const pkg = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
|
|
10324
|
+
const pkg = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
|
|
9713
10325
|
if (pkg && asString$1(pkg["name"]) === packageName) return candidate;
|
|
9714
10326
|
} catch {}
|
|
9715
10327
|
}
|
|
@@ -9718,7 +10330,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9718
10330
|
/** Ensure a package is built (dist/ exists and page bundles present) */
|
|
9719
10331
|
async ensureBuilt(packageName, sourceDir, pkgData) {
|
|
9720
10332
|
const distDir = path$1.join(sourceDir, "dist");
|
|
9721
|
-
if (!(!fs.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
|
|
10333
|
+
if (!(!fs$1.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
|
|
9722
10334
|
this.logger.info(`${packageName} — building (dist/ missing or incomplete)`);
|
|
9723
10335
|
try {
|
|
9724
10336
|
await runNpm(["run", "build"], this.npmRunOptions(sourceDir, 18e4));
|
|
@@ -9733,7 +10345,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9733
10345
|
if (!camstack?.addons) return false;
|
|
9734
10346
|
for (const addon of camstack.addons) {
|
|
9735
10347
|
if (!addon.pages) continue;
|
|
9736
|
-
for (const page of addon.pages) if (page.bundle && !fs.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
|
|
10348
|
+
for (const page of addon.pages) if (page.bundle && !fs$1.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
|
|
9737
10349
|
}
|
|
9738
10350
|
return false;
|
|
9739
10351
|
}
|
|
@@ -9742,7 +10354,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9742
10354
|
function isDirEntry(entry, parentDir) {
|
|
9743
10355
|
if (entry.isDirectory()) return true;
|
|
9744
10356
|
if (entry.isSymbolicLink()) try {
|
|
9745
|
-
return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
|
|
10357
|
+
return fs$1.statSync(path$1.join(parentDir, entry.name)).isDirectory();
|
|
9746
10358
|
} catch {
|
|
9747
10359
|
return false;
|
|
9748
10360
|
}
|
|
@@ -9841,7 +10453,7 @@ function selectAddonResidue(candidates) {
|
|
|
9841
10453
|
}
|
|
9842
10454
|
function readDeclaredName(dir) {
|
|
9843
10455
|
try {
|
|
9844
|
-
const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
10456
|
+
const parsed = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
9845
10457
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
9846
10458
|
const name = parsed.name;
|
|
9847
10459
|
return typeof name === "string" ? name : null;
|
|
@@ -9851,7 +10463,7 @@ function readDeclaredName(dir) {
|
|
|
9851
10463
|
}
|
|
9852
10464
|
function readDeclaredVersion(dir) {
|
|
9853
10465
|
try {
|
|
9854
|
-
const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
10466
|
+
const parsed = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
9855
10467
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
9856
10468
|
const version = parsed.version;
|
|
9857
10469
|
return typeof version === "string" ? version : null;
|
|
@@ -9861,7 +10473,7 @@ function readDeclaredVersion(dir) {
|
|
|
9861
10473
|
}
|
|
9862
10474
|
function isDirLike(p) {
|
|
9863
10475
|
try {
|
|
9864
|
-
return fs.statSync(p).isDirectory();
|
|
10476
|
+
return fs$1.statSync(p).isDirectory();
|
|
9865
10477
|
} catch {
|
|
9866
10478
|
return false;
|
|
9867
10479
|
}
|
|
@@ -9871,7 +10483,7 @@ function freeQuarantineTarget(store, scope, dirName) {
|
|
|
9871
10483
|
const base = scope === null ? dirName : `${scope.replace("@", "")}__${dirName}`;
|
|
9872
10484
|
let candidate = path$1.join(store, base);
|
|
9873
10485
|
let n = 1;
|
|
9874
|
-
while (fs.existsSync(candidate)) {
|
|
10486
|
+
while (fs$1.existsSync(candidate)) {
|
|
9875
10487
|
candidate = path$1.join(store, `${base}-${n}`);
|
|
9876
10488
|
n += 1;
|
|
9877
10489
|
}
|
|
@@ -9888,7 +10500,7 @@ function freeQuarantineTarget(store, scope, dirName) {
|
|
|
9888
10500
|
function quarantineAddonResidue(addonsDir, log) {
|
|
9889
10501
|
const quarantined = [];
|
|
9890
10502
|
const failed = [];
|
|
9891
|
-
if (!fs.existsSync(addonsDir)) return {
|
|
10503
|
+
if (!fs$1.existsSync(addonsDir)) return {
|
|
9892
10504
|
quarantined,
|
|
9893
10505
|
failed
|
|
9894
10506
|
};
|
|
@@ -9896,7 +10508,7 @@ function quarantineAddonResidue(addonsDir, log) {
|
|
|
9896
10508
|
const scan = (parent, scope) => {
|
|
9897
10509
|
let names;
|
|
9898
10510
|
try {
|
|
9899
|
-
names = fs.readdirSync(parent);
|
|
10511
|
+
names = fs$1.readdirSync(parent);
|
|
9900
10512
|
} catch {
|
|
9901
10513
|
return;
|
|
9902
10514
|
}
|
|
@@ -9915,8 +10527,8 @@ function quarantineAddonResidue(addonsDir, log) {
|
|
|
9915
10527
|
const version = readDeclaredVersion(full);
|
|
9916
10528
|
const to = freeQuarantineTarget(store, scope, dirName);
|
|
9917
10529
|
try {
|
|
9918
|
-
fs.mkdirSync(store, { recursive: true });
|
|
9919
|
-
fs.renameSync(full, to);
|
|
10530
|
+
fs$1.mkdirSync(store, { recursive: true });
|
|
10531
|
+
fs$1.renameSync(full, to);
|
|
9920
10532
|
} catch (err) {
|
|
9921
10533
|
const error = err instanceof Error ? err.message : String(err);
|
|
9922
10534
|
failed.push({
|
|
@@ -9974,11 +10586,11 @@ function getRestartMarkerPath(dataDir) {
|
|
|
9974
10586
|
* intact or no marker at all (never a half-written file).
|
|
9975
10587
|
*/
|
|
9976
10588
|
function writePendingRestart(dataDir, marker) {
|
|
9977
|
-
fs.mkdirSync(dataDir, { recursive: true });
|
|
10589
|
+
fs$1.mkdirSync(dataDir, { recursive: true });
|
|
9978
10590
|
const markerPath = getRestartMarkerPath(dataDir);
|
|
9979
10591
|
const tmpPath = `${markerPath}.tmp`;
|
|
9980
|
-
fs.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
|
|
9981
|
-
fs.renameSync(tmpPath, markerPath);
|
|
10592
|
+
fs$1.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
|
|
10593
|
+
fs$1.renameSync(tmpPath, markerPath);
|
|
9982
10594
|
}
|
|
9983
10595
|
/**
|
|
9984
10596
|
* Read + consume the marker. Returns the parsed payload on success and
|
|
@@ -10003,10 +10615,10 @@ function writePendingRestart(dataDir, marker) {
|
|
|
10003
10615
|
*/
|
|
10004
10616
|
function readPendingRestart(dataDir) {
|
|
10005
10617
|
const markerPath = getRestartMarkerPath(dataDir);
|
|
10006
|
-
if (!fs.existsSync(markerPath)) return null;
|
|
10618
|
+
if (!fs$1.existsSync(markerPath)) return null;
|
|
10007
10619
|
let raw;
|
|
10008
10620
|
try {
|
|
10009
|
-
raw = fs.readFileSync(markerPath, "utf-8");
|
|
10621
|
+
raw = fs$1.readFileSync(markerPath, "utf-8");
|
|
10010
10622
|
} catch (err) {
|
|
10011
10623
|
console.error("[restart-coordinator] Marker unreadable — leaving in place:", err);
|
|
10012
10624
|
return null;
|
|
@@ -10045,7 +10657,7 @@ function readPendingRestart(dataDir) {
|
|
|
10045
10657
|
/** Remove the marker if present. No-op if missing. */
|
|
10046
10658
|
function clearPendingRestart(dataDir) {
|
|
10047
10659
|
const markerPath = getRestartMarkerPath(dataDir);
|
|
10048
|
-
fs.rmSync(markerPath, { force: true });
|
|
10660
|
+
fs$1.rmSync(markerPath, { force: true });
|
|
10049
10661
|
}
|
|
10050
10662
|
function isRestartKind(value) {
|
|
10051
10663
|
return value === "framework-update" || value === "manual" || value === "system";
|
|
@@ -10057,7 +10669,7 @@ function scheduleSelfRestart(options = {}) {
|
|
|
10057
10669
|
const touchTarget = process.env["CAMSTACK_RESTART_TOUCH_FILE"];
|
|
10058
10670
|
if (touchTarget !== void 0 && touchTarget.length > 0) try {
|
|
10059
10671
|
const now = /* @__PURE__ */ new Date();
|
|
10060
|
-
fs.utimesSync(touchTarget, now, now);
|
|
10672
|
+
fs$1.utimesSync(touchTarget, now, now);
|
|
10061
10673
|
return;
|
|
10062
10674
|
} catch (err) {
|
|
10063
10675
|
console.error("[restart-coordinator] dev touch-reload failed; falling through to process exit:", err);
|
|
@@ -20819,7 +21431,7 @@ async function probeVaapiInit(renderNode) {
|
|
|
20819
21431
|
*/
|
|
20820
21432
|
function safeExistsSync(path) {
|
|
20821
21433
|
try {
|
|
20822
|
-
return fs.existsSync(path);
|
|
21434
|
+
return fs$1.existsSync(path);
|
|
20823
21435
|
} catch {
|
|
20824
21436
|
return false;
|
|
20825
21437
|
}
|
|
@@ -20838,11 +21450,11 @@ function probeLinuxGpus() {
|
|
|
20838
21450
|
if (safeExistsSync("/dev/nvidia0") || safeExistsSync("/proc/driver/nvidia/version")) signals.hasNvidiaGpu = true;
|
|
20839
21451
|
try {
|
|
20840
21452
|
const drmDir = "/sys/class/drm";
|
|
20841
|
-
if (fs.existsSync(drmDir)) for (const entry of fs.readdirSync(drmDir)) {
|
|
21453
|
+
if (fs$1.existsSync(drmDir)) for (const entry of fs$1.readdirSync(drmDir)) {
|
|
20842
21454
|
if (!entry.startsWith("card")) continue;
|
|
20843
21455
|
const vendorPath = `${drmDir}/${entry}/device/vendor`;
|
|
20844
21456
|
if (!safeExistsSync(vendorPath)) continue;
|
|
20845
|
-
const vendor = fs.readFileSync(vendorPath, "utf8").trim().toLowerCase();
|
|
21457
|
+
const vendor = fs$1.readFileSync(vendorPath, "utf8").trim().toLowerCase();
|
|
20846
21458
|
if (vendor === "0x10de") signals.hasNvidiaGpu = true;
|
|
20847
21459
|
else if (vendor === "0x1002") signals.hasAmdGpu = true;
|
|
20848
21460
|
else if (vendor === "0x8086") signals.hasIntelGpu = true;
|
|
@@ -21065,21 +21677,21 @@ function sleep$1(ms) {
|
|
|
21065
21677
|
* crashed holder) is stolen.
|
|
21066
21678
|
*/
|
|
21067
21679
|
async function withFileLock(lockPath, fn) {
|
|
21068
|
-
fs.mkdirSync(join(lockPath, ".."), { recursive: true });
|
|
21680
|
+
fs$1.mkdirSync(join(lockPath, ".."), { recursive: true });
|
|
21069
21681
|
for (;;) try {
|
|
21070
|
-
const fd = fs.openSync(lockPath, "wx");
|
|
21071
|
-
fs.closeSync(fd);
|
|
21682
|
+
const fd = fs$1.openSync(lockPath, "wx");
|
|
21683
|
+
fs$1.closeSync(fd);
|
|
21072
21684
|
break;
|
|
21073
21685
|
} catch {
|
|
21074
21686
|
try {
|
|
21075
|
-
if (Date.now() - fs.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs.rmSync(lockPath, { force: true });
|
|
21687
|
+
if (Date.now() - fs$1.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs$1.rmSync(lockPath, { force: true });
|
|
21076
21688
|
else await sleep$1(LOCK_POLL_MS);
|
|
21077
21689
|
} catch {}
|
|
21078
21690
|
}
|
|
21079
21691
|
try {
|
|
21080
21692
|
return await fn();
|
|
21081
21693
|
} finally {
|
|
21082
|
-
fs.rmSync(lockPath, { force: true });
|
|
21694
|
+
fs$1.rmSync(lockPath, { force: true });
|
|
21083
21695
|
}
|
|
21084
21696
|
}
|
|
21085
21697
|
/** Coalesce in-process + serialize cross-process for one binary id. */
|
|
@@ -21137,7 +21749,7 @@ var AddonDepsManager = class {
|
|
|
21137
21749
|
* failed or tampered download throws, and provisioning reports it.
|
|
21138
21750
|
*/
|
|
21139
21751
|
async stageNativeDepsDeclaredBy(requirementsFile) {
|
|
21140
|
-
if (!declaresEdgetpuDelegate(fs.readFileSync(requirementsFile, "utf8"))) return;
|
|
21752
|
+
if (!declaresEdgetpuDelegate(fs$1.readFileSync(requirementsFile, "utf8"))) return;
|
|
21141
21753
|
await singleFlight(this.depsDir, "edgetpu-delegate", () => ensureEdgetpuDelegate(this.nodeRoot, this.logger));
|
|
21142
21754
|
}
|
|
21143
21755
|
getDepsDir() {
|
|
@@ -22168,7 +22780,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
22168
22780
|
const addonId = declaration.id;
|
|
22169
22781
|
const nodeDataDir = process.env["CAMSTACK_DATA"] ?? dataDir;
|
|
22170
22782
|
const addonDataDir = path$1.resolve(nodeDataDir, "addons-data", addonId);
|
|
22171
|
-
fs.mkdirSync(addonDataDir, { recursive: true });
|
|
22783
|
+
fs$1.mkdirSync(addonDataDir, { recursive: true });
|
|
22172
22784
|
if (runtime.mode === "broker") ensureBindingSubscription(runtime.broker);
|
|
22173
22785
|
const regs = getRegistries(nodeId);
|
|
22174
22786
|
const workerResolver = {
|
|
@@ -24145,7 +24757,7 @@ var FailedRunnerRetryLedger = class {
|
|
|
24145
24757
|
function readRunnerPackageVersions(addonDirs) {
|
|
24146
24758
|
const out = {};
|
|
24147
24759
|
for (const dir of addonDirs) try {
|
|
24148
|
-
const raw = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
24760
|
+
const raw = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
24149
24761
|
const version = typeof raw === "object" && raw !== null ? Reflect.get(raw, "version") : null;
|
|
24150
24762
|
out[dir] = typeof version === "string" && version.length > 0 ? version : null;
|
|
24151
24763
|
} catch {
|
|
@@ -24206,7 +24818,7 @@ function readAddonHeapDeclaration(spec) {
|
|
|
24206
24818
|
if (cached !== void 0) return cached;
|
|
24207
24819
|
let declaration = EMPTY_HEAP_DECLARATION;
|
|
24208
24820
|
for (const manifestPath of [path$1.join(spec.addonDir, "package.json"), path$1.join(path$1.dirname(spec.addonDir), "package.json")]) try {
|
|
24209
|
-
const raw = fs.readFileSync(manifestPath, "utf8");
|
|
24821
|
+
const raw = fs$1.readFileSync(manifestPath, "utf8");
|
|
24210
24822
|
const parsed = JSON.parse(raw);
|
|
24211
24823
|
const profile = extractHeapProfile(parsed, spec.addonId);
|
|
24212
24824
|
const maxOldSpaceMb = extractMaxOldSpaceMb(parsed, spec.addonId);
|
|
@@ -25439,17 +26051,17 @@ var JobJournal = class {
|
|
|
25439
26051
|
return path$1.join(this.jobsDir, `${id}.json`);
|
|
25440
26052
|
}
|
|
25441
26053
|
writeAtomic(filePath, data) {
|
|
25442
|
-
fs.mkdirSync(path$1.dirname(filePath), { recursive: true });
|
|
26054
|
+
fs$1.mkdirSync(path$1.dirname(filePath), { recursive: true });
|
|
25443
26055
|
const tmp = `${filePath}.tmp.${process.pid}.${Date.now()}`;
|
|
25444
|
-
fs.writeFileSync(tmp, JSON.stringify(data, null, 2), {
|
|
26056
|
+
fs$1.writeFileSync(tmp, JSON.stringify(data, null, 2), {
|
|
25445
26057
|
encoding: "utf-8",
|
|
25446
26058
|
mode: 384
|
|
25447
26059
|
});
|
|
25448
|
-
fs.renameSync(tmp, filePath);
|
|
26060
|
+
fs$1.renameSync(tmp, filePath);
|
|
25449
26061
|
}
|
|
25450
26062
|
readIndex() {
|
|
25451
26063
|
try {
|
|
25452
|
-
const raw = JSON.parse(fs.readFileSync(this.indexPath, "utf-8"));
|
|
26064
|
+
const raw = JSON.parse(fs$1.readFileSync(this.indexPath, "utf-8"));
|
|
25453
26065
|
if (raw && Array.isArray(raw.jobIds)) return {
|
|
25454
26066
|
version: 1,
|
|
25455
26067
|
jobIds: raw.jobIds
|
|
@@ -25474,7 +26086,7 @@ var JobJournal = class {
|
|
|
25474
26086
|
}
|
|
25475
26087
|
getJob(id) {
|
|
25476
26088
|
try {
|
|
25477
|
-
const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs.readFileSync(this.jobPath(id), "utf-8")));
|
|
26089
|
+
const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs$1.readFileSync(this.jobPath(id), "utf-8")));
|
|
25478
26090
|
return parsed.success ? parsed.data : null;
|
|
25479
26091
|
} catch {
|
|
25480
26092
|
return null;
|
|
@@ -25539,14 +26151,14 @@ var StagingArea = class {
|
|
|
25539
26151
|
}
|
|
25540
26152
|
async fetchAndStage(input) {
|
|
25541
26153
|
const destDir = path$1.join(this.stagingDir, input.jobId, safeSegment(input.name));
|
|
25542
|
-
fs.rmSync(destDir, {
|
|
26154
|
+
fs$1.rmSync(destDir, {
|
|
25543
26155
|
recursive: true,
|
|
25544
26156
|
force: true
|
|
25545
26157
|
});
|
|
25546
26158
|
const tgz = await this.deps.fetchTarball(input.name, input.version, input.signal);
|
|
25547
26159
|
if (input.signal.aborted) throw new Error("staging aborted after fetch");
|
|
25548
26160
|
await this.deps.extract(tgz, destDir);
|
|
25549
|
-
const raw = JSON.parse(fs.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
|
|
26161
|
+
const raw = JSON.parse(fs$1.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
|
|
25550
26162
|
if (typeof raw.version !== "string" || raw.version.length === 0) throw new Error(`staging validation failed: ${input.name} staged a package.json with no version`);
|
|
25551
26163
|
if (EXACT_SEMVER.test(input.version) && raw.version !== input.version) throw new Error(`staging validation failed: ${input.name} expected version ${input.version}, got ${raw.version}`);
|
|
25552
26164
|
return {
|
|
@@ -25555,7 +26167,7 @@ var StagingArea = class {
|
|
|
25555
26167
|
};
|
|
25556
26168
|
}
|
|
25557
26169
|
cleanup(jobId) {
|
|
25558
|
-
fs.rmSync(path$1.join(this.stagingDir, jobId), {
|
|
26170
|
+
fs$1.rmSync(path$1.join(this.stagingDir, jobId), {
|
|
25559
26171
|
recursive: true,
|
|
25560
26172
|
force: true
|
|
25561
26173
|
});
|
|
@@ -25570,13 +26182,13 @@ var StagingArea = class {
|
|
|
25570
26182
|
sweepOrphans() {
|
|
25571
26183
|
let entries;
|
|
25572
26184
|
try {
|
|
25573
|
-
entries = fs.readdirSync(this.stagingDir);
|
|
26185
|
+
entries = fs$1.readdirSync(this.stagingDir);
|
|
25574
26186
|
} catch {
|
|
25575
26187
|
return 0;
|
|
25576
26188
|
}
|
|
25577
26189
|
let removed = 0;
|
|
25578
26190
|
for (const name of entries) try {
|
|
25579
|
-
fs.rmSync(path$1.join(this.stagingDir, name), {
|
|
26191
|
+
fs$1.rmSync(path$1.join(this.stagingDir, name), {
|
|
25580
26192
|
recursive: true,
|
|
25581
26193
|
force: true
|
|
25582
26194
|
});
|
|
@@ -25754,7 +26366,7 @@ var LifecycleJobEngine = class {
|
|
|
25754
26366
|
* on failure → `failed`.
|
|
25755
26367
|
*/
|
|
25756
26368
|
async reconcileJob(job) {
|
|
25757
|
-
const exists = this.deps.stagedPathExists ?? ((p) => fs.existsSync(p));
|
|
26369
|
+
const exists = this.deps.stagedPathExists ?? ((p) => fs$1.existsSync(p));
|
|
25758
26370
|
for (const task of job.tasks) {
|
|
25759
26371
|
if (task.target === "framework") {
|
|
25760
26372
|
if (!this.isTerminal(task.phase)) this.skipFrameworkTask(job, task);
|
|
@@ -26403,7 +27015,7 @@ var CatalogRegistry = class {
|
|
|
26403
27015
|
const file = path$1.join(packageDir, "i18n", `${lang}.json`);
|
|
26404
27016
|
let text;
|
|
26405
27017
|
try {
|
|
26406
|
-
text = fs.readFileSync(file, "utf8");
|
|
27018
|
+
text = fs$1.readFileSync(file, "utf8");
|
|
26407
27019
|
} catch {
|
|
26408
27020
|
continue;
|
|
26409
27021
|
}
|