@camstack/server 1.2.821 → 1.2.823
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/dist/api/trpc/generated-cap-routers.js +20 -0
- package/package.json +9 -10
- package/system/dist/addon-runner.js +18 -13
- package/system/dist/addon-runner.mjs +19 -14
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/{agent-https-N6Or6UAu.mjs → agent-https-CDl7mB_F.mjs} +1 -1
- package/system/dist/{agent-https-Bp5yzi8b.js → agent-https-Df53Fvk1.js} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composed-device-set.d.ts +5 -1
- package/system/dist/builtins/composer/composed-device.d.ts +4 -0
- package/system/dist/builtins/composer/composed-name.d.ts +30 -0
- package/system/dist/builtins/composer/composer.addon.js +94 -6
- package/system/dist/builtins/composer/composer.addon.mjs +94 -6
- package/system/dist/builtins/composer/composer.d.ts +13 -0
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/actions-service.d.ts +16 -0
- package/system/dist/builtins/core-blocks/composition-api.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +214 -8
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +214 -8
- package/system/dist/builtins/core-blocks/device-template-door.d.ts +25 -0
- package/system/dist/builtins/core-blocks/fan-presets-service.d.ts +5 -0
- package/system/dist/builtins/core-blocks/rename-composition-block.d.ts +16 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-engine.d.ts +5 -0
- package/system/dist/builtins/core-blocks/step-condition-door.d.ts +19 -0
- package/system/dist/builtins/core-blocks/sync-composed-device-name.d.ts +19 -0
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.d.ts +7 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +691 -4
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +689 -3
- package/system/dist/builtins/device-manager/device-template/template-host.d.ts +60 -0
- package/system/dist/builtins/device-manager/device-template-actions.d.ts +33 -0
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +10 -10
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -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 +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +9 -9
- package/system/dist/builtins/system-config/system-config.addon.mjs +287 -287
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-4lB0sLCf.js → capture-engine-C0Z5rwCO.js} +1 -1
- package/system/dist/{capture-engine-Cz7z5d36.mjs → capture-engine-D_GQBgrZ.mjs} +1 -1
- package/system/dist/{composition-sources-C9gEj25e.js → composition-sources-DIZx3mW3.js} +1 -1
- package/system/dist/{composition-sources-C0e2g_VP.mjs → composition-sources-mx-2yCDv.mjs} +1 -1
- package/system/dist/{constants-CZMy7dor.mjs → constants-BQlx9HDp.mjs} +1 -1
- package/system/dist/{constants-Cq3B9yzj.js → constants-CAOcKiWT.js} +1 -1
- package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
- package/system/dist/{custom-action-registry-B9zFBNVa.mjs → custom-action-registry-N7flBDwT.mjs} +37 -37
- package/system/dist/{device-ca-BenyQXJV.js → device-ca-93LsCF_Q.js} +1 -1
- package/system/dist/{device-ca-BmQ6N-A-.mjs → device-ca-CK6GTnNh.mjs} +1 -1
- package/system/dist/device-template-worker.js +5 -7032
- package/system/dist/device-template-worker.mjs +1 -7026
- package/system/dist/{dist-DuKMbGBM.mjs → dist-BQiyo22b.mjs} +667 -50
- package/system/dist/{dist-M5VX8Hqf.js → dist-izXDzt4g.js} +714 -49
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-k3pOKWyZ.js → hub-mdns-ciao-Dt_tgvol.js} +2 -2
- package/system/dist/{hub-mdns-ciao-CXBfBwAy.mjs → hub-mdns-ciao-srpOrqIP.mjs} +2 -2
- package/system/dist/index.js +26 -21
- package/system/dist/index.mjs +238 -233
- package/system/dist/{legacy-integration-rows-door-mIpR3e6X.js → legacy-integration-rows-door-BH43eDu6.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-C13OeuW9.mjs → legacy-integration-rows-door-wu2GWY6U.mjs} +1 -1
- package/system/dist/rename-composition-block-6oLQVzft.js +112 -0
- package/system/dist/rename-composition-block-CH6ZoSJA.mjs +101 -0
- package/system/dist/{restore-archive-DDeQFJN5.mjs → restore-archive-C4rR2SYV.mjs} +154 -154
- package/system/dist/{restore-archive-CCgt7SZ8.js → restore-archive-DpZ2PbLN.js} +7 -7
- package/system/dist/template-protocol-BmMM5VBf.mjs +7033 -0
- package/system/dist/template-protocol-CTP4eAo_.js +7059 -0
- package/system/dist/{wal-maintenance-Cj7xe4wN.mjs → wal-maintenance-CNfp0HHX.mjs} +0 -0
- package/system/dist/{wal-maintenance-D5M6hl53.js → wal-maintenance-DAA2qJja.js} +0 -0
- package/system/package.json +1 -1
package/system/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as __require } from "./chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import {
|
|
3
|
-
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-
|
|
2
|
+
import { Bc as resolveCapMount, Ci as looseSchema, Ct as LOG_LEVEL_RANK, D as CatalogFileSchema, Ds as RUNTIME_DEFAULTS, En as bareAddonId, Fc as parseJsonObject, Ft as PackageRequiresSchema, Gs as asString$1, Hc as scopeKey, Hi as objectInputDeclaresRequiredDeviceId, Ia as scopesAllowAddon, Ic as parseJsonUnknown, Ja as splitTranslationRef, La as scopesAllowDeviceCap, Os as ReadinessRegistry, Pr as extractNestedAddonId, Qc as withoutCallerStamp, Qs as collectSecretMarkerRefs, Rc as readinessKey, Si as logLevelAtMost, Us as asJsonObject$1, Vi as objectInputDeclaresAddonId, Ws as asNumber, Xc as userError, Zr as interpolate, _n as addonSettingsCapability, a as AGENT_MDNS_SERVICE_TYPE, al as EventCategory$1, b as CATALOG_LANGS, cc as emitDownForOwnedCaps, cs as CALLER_STAMPED_CAPABILITIES$1, dc as expandCapMethods, ds as DEVICE_STATUS_METHOD, hi as lifecycleJobSchema, hr as describeUnmet, ks as ReadinessTimeoutError, li as isVoidInput, ls as DATAPLANE_SECRET_HEADER$1, nc as createEvent$1, ni as isCollectionArrayMethod, o as AGENT_MDNS_TXT_KEYS, pc as getDebugInterest, po as unmetRequirements, qn as compareVersions, ra as procedureAuthKey, rl as errMsg$1, ro as supportedRuntimes, s as ALL_CAPABILITY_DEFINITIONS, sc as defineRecordKinds, si as isObjectInput, ti as isArrayOutputSchema, ui as kebabToCamel$1, us as DEVICE_SETTINGS_CONTRIBUTION_METHODS, vc as isDebugChannelName, wa as resolveMethodAuth, wt as METHOD_ACCESS_MAP } from "./dist-BQiyo22b.mjs";
|
|
3
|
+
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-CK6GTnNh.mjs";
|
|
4
4
|
import { t as require_read_all_rows } from "./read-all-rows-TaPqdWNF.mjs";
|
|
5
5
|
import { a as redactLogText, i as redactLogMeta, r as redactLogEntry, t as isCredentialKeyName } from "./log-redactor-XLDrPzOi.mjs";
|
|
6
6
|
import { AlertCenterAddon, n as lastCauseAfterChunk, r as readRunnerDisplayName, t as CRASH_BREAKER_ERROR_PREFIX } from "./builtins/alerts/alerts.addon.mjs";
|
|
@@ -26,33 +26,33 @@ import { LokiDestination, LokiLoggingAddon } from "./builtins/loki-logging/index
|
|
|
26
26
|
import NativeMetricsAddon, { a as NativeMetricsProvider, i as parseProcStatusRss, n as nodeProcReader, r as parseProcStat } from "./builtins/native-metrics/native-metrics.addon.mjs";
|
|
27
27
|
import { DeviceHistoryAddon } from "./builtins/device-history/device-history.addon.mjs";
|
|
28
28
|
import { FilesystemStorageAddon, t as FilesystemStorageProvider } from "./builtins/sqlite-storage/filesystem-storage.addon.mjs";
|
|
29
|
-
import { D as RecordsEngine, l as SqliteSettingsBackend } from "./wal-maintenance-
|
|
30
|
-
import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-
|
|
29
|
+
import { D as RecordsEngine, l as SqliteSettingsBackend } from "./wal-maintenance-CNfp0HHX.mjs";
|
|
30
|
+
import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-wu2GWY6U.mjs";
|
|
31
31
|
import { SqliteSettingsAddon } from "./builtins/sqlite-storage/sqlite-settings.addon.mjs";
|
|
32
32
|
import { ConfigStore, DeviceStore } from "./builtins/sqlite-storage/index.mjs";
|
|
33
33
|
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";
|
|
34
34
|
import "./builtins/storage-orchestrator/index.mjs";
|
|
35
|
-
import { A as buildNameConstraintSet, B as setProcessAgentHttpsNames, C as LEAF_RENEWAL_WINDOW_DAYS, E as evaluateExistingCert, F as readNameConstraints, I as AGENT_HTTPS_NAMES_COLLECTION, L as AGENT_HTTPS_NAMES_COLUMNS, M as isLocalOnlyHostname, N as permitsIdentity, O as PERMITTED_DNS_SUFFIXES, P as permitsName, R as AgentHttpsNames, S as CA_VALIDITY_DAYS, T as SERVER_AUTH_OID, a as collectAgentNames, b as collectCertIdentity, c as installAgentHttps, d as issueAgentHttpsLeaf, f as loadAgentHttps, h as CA_COMMON_NAME, i as certificateNames, j as isConstrainedCa, k as PERMITTED_IP_RANGES, l as isContainerBridgeAddress, m as pinnedHttpsCaFingerprint, n as acceptAgentSans, o as createAgentHttpsRequest, p as pemDigest, r as agentHttpsPaths, s as describeHttpsLeaf, t as AgentHttpsInstallError, u as isPrivateAddress, w as MAX_LEAF_VALIDITY_DAYS, x as systemHostFacts, y as localCaCommonName, z as getProcessAgentHttpsNames } from "./agent-https-
|
|
36
|
-
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-
|
|
35
|
+
import { A as buildNameConstraintSet, B as setProcessAgentHttpsNames, C as LEAF_RENEWAL_WINDOW_DAYS, E as evaluateExistingCert, F as readNameConstraints, I as AGENT_HTTPS_NAMES_COLLECTION, L as AGENT_HTTPS_NAMES_COLUMNS, M as isLocalOnlyHostname, N as permitsIdentity, O as PERMITTED_DNS_SUFFIXES, P as permitsName, R as AgentHttpsNames, S as CA_VALIDITY_DAYS, T as SERVER_AUTH_OID, a as collectAgentNames, b as collectCertIdentity, c as installAgentHttps, d as issueAgentHttpsLeaf, f as loadAgentHttps, h as CA_COMMON_NAME, i as certificateNames, j as isConstrainedCa, k as PERMITTED_IP_RANGES, l as isContainerBridgeAddress, m as pinnedHttpsCaFingerprint, n as acceptAgentSans, o as createAgentHttpsRequest, p as pemDigest, r as agentHttpsPaths, s as describeHttpsLeaf, t as AgentHttpsInstallError, u as isPrivateAddress, w as MAX_LEAF_VALIDITY_DAYS, x as systemHostFacts, y as localCaCommonName, z as getProcessAgentHttpsNames } from "./agent-https-CDl7mB_F.mjs";
|
|
36
|
+
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-BQlx9HDp.mjs";
|
|
37
37
|
import { $ as caFingerprintCompact, A as getProcessNodeMeshTransport, B as MESH_NODE_CERTIFICATES_COLLECTION, C as MESH_TLS_PORT_HELLO_FIELD, Ct as readOriginSetting, D as setProcessMeshTlsEnabler, Dt as readCidrSetting, E as ServiceBroker, Et as parseCidrList, F as renewMeshCertificate, G as getProcessMeshCertificateRegistry, H as MeshCertificateRegistry, I as revokeMeshCertificate, J as processMeshCrl, K as setProcessMeshCertificateRegistry, L as getProcessMeshTlsListenerState, M as isProcessVerifiedMeshPeer, N as onProcessNodeRegistered, O as dropProcessPeer, P as setProcessMeshPeerTransportLookup, Q as caFingerprint, R as openMeshTlsWhenRevocationsLoaded, S as verifyMembershipAnswer, St as parseOriginList, SystemConfigAddon, T as Errors, Tt as normalizeIp, U as RENEWAL_ABANDONED, V as MESH_NODE_CERTIFICATES_COLUMNS, W as describeMeshLeaf, X as getProcessMeshCaState, Y as MeshCaKeeper, Z as requireProcessMeshCa, _ as signPairingProof, _t as verifyAgentUiUnlockTicket, a as hubHostFromMeshAddress, at as issueMeshLeafForNode, b as MembershipResponder, bt as isInsecureOrigin, c as PAIRING_MAX_SESSIONS, ct as AGENT_DASHBOARD_ORIGINS_FIELD, d as PAIRING_PROTOCOL, dt as AGENT_UI_UNLOCK_USE, et as createMeshCsrPem, f as PAIRING_TTL_MS, ft as AGENT_UI_UNLOCK_VERSION, g as keyFingerprintShort, gt as parseAgentDashboardOrigins, h as describeCsr, ht as mintAgentUiUnlockTicket, i as AgentPairing, it as isValidAgentNodeId, j as getProcessPeerLeaf, k as emitProcessNodeRegistered, l as PAIRING_PATHS, lt as AGENT_UI_UNLOCK_TTL_MS, m as computePairingSas, mt as isAllowedAgentDashboardReturnTo, n as HubPairing, nt as generateMeshCa, o as PAIRING_CODE_DIGITS, ot as issueMeshLeafFromCsr, p as computePairingCommitment, pt as UnlockTicketJtiStore, q as MeshCrl, r as PairingHttpError, rt as generateMeshKeyPair, s as PAIRING_MAX_CODE_ATTEMPTS, st as loadMeshCa, tt as exportMeshPrivateKeyPem, u as PAIRING_PIN_DIGITS, ut as AGENT_UI_UNLOCK_TYP, v as verifyPairingProof, vt as InvalidCorsOriginError, w as TlsTcpTransporter, wt as createCidrMatcher, x as signMembershipProof, xt as normalizeOrigin, y as MEMBERSHIP_PATHS, yt as OPAQUE_ORIGIN, z as setProcessMeshTlsListenerState } from "./builtins/system-config/system-config.addon.mjs";
|
|
38
38
|
import "./builtins/system-config/index.mjs";
|
|
39
39
|
import { WinstonDestination, WinstonLoggingAddon } from "./builtins/winston-logging/index.mjs";
|
|
40
|
-
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-
|
|
41
|
-
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-
|
|
40
|
+
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-N7flBDwT.mjs";
|
|
41
|
+
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-srpOrqIP.mjs";
|
|
42
42
|
import { n as getPlatformKeychainKey, r as setPlatformKeychainKey, t as clearPlatformKeychainKey } from "./platform-key-source-BWlq0jjn.mjs";
|
|
43
43
|
import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-Di9daRwI.mjs";
|
|
44
|
-
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-
|
|
45
|
-
import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-
|
|
44
|
+
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-C4rR2SYV.mjs";
|
|
45
|
+
import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-BW3OcrLD.mjs";
|
|
46
46
|
import { z } from "zod";
|
|
47
47
|
import * as crypto$1 from "node:crypto";
|
|
48
48
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
49
49
|
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, installPythonPackages, installPythonPackages as installPythonPackages$1, installPythonRequirements, installPythonRequirements as installPythonRequirements$1 } from "@camstack/types/node";
|
|
50
50
|
import { connect, createConnection, createServer } from "node:net";
|
|
51
|
-
import * as fs
|
|
51
|
+
import * as fs from "node:fs";
|
|
52
52
|
import { accessSync, constants, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
|
|
53
53
|
import * as path$1 from "node:path";
|
|
54
54
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
55
|
-
import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, CAP_METHOD_TIMEOUTS_MS, COLLECTION_ARRAY_METHODS, CommandOriginClaimSchema, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, MIGRATION_API_VERSION, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry as ReadinessRegistry$1, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, createDebugEmitter, createDeviceProxy, createEvent, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods as expandCapMethods$1, isCommand, readCommandOrigin, readErrorI18n, readNodePin, resolveDeviceSettings, scopeKey as scopeKey$1, sleep, withCapInputDefaults } from "@camstack/types/addon";
|
|
55
|
+
import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, CAP_METHOD_TIMEOUTS_MS, COLLECTION_ARRAY_METHODS, COMPOSED_DEVICE_STABLE_ID_PREFIX, CommandOriginClaimSchema, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, MIGRATION_API_VERSION, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry as ReadinessRegistry$1, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, createDebugEmitter, createDeviceProxy, createEvent, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods as expandCapMethods$1, isCommand, readCommandOrigin, readErrorI18n, readNodePin, resolveDeviceSettings, scopeKey as scopeKey$1, sleep, withCapInputDefaults } from "@camstack/types/addon";
|
|
56
56
|
import { mkdir, rm, stat, unlink } from "node:fs/promises";
|
|
57
57
|
import * as util from "node:util";
|
|
58
58
|
import { promisify } from "node:util";
|
|
@@ -5021,7 +5021,7 @@ var PythonEnvManager = class {
|
|
|
5021
5021
|
async ensure(options) {
|
|
5022
5022
|
const probe = await this.probe();
|
|
5023
5023
|
if (!probe.available || !probe.path) throw userError("system.python-required", void 0, "Python 3.10+ is required but not found on this system");
|
|
5024
|
-
if (!fs
|
|
5024
|
+
if (!fs.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
|
|
5025
5025
|
"-m",
|
|
5026
5026
|
"venv",
|
|
5027
5027
|
this.venvPath
|
|
@@ -5044,7 +5044,7 @@ var PythonEnvManager = class {
|
|
|
5044
5044
|
}
|
|
5045
5045
|
spawn(script, args) {
|
|
5046
5046
|
const venvPython = path$1.join(this.venvPath, "bin", "python");
|
|
5047
|
-
if (!fs
|
|
5047
|
+
if (!fs.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
|
|
5048
5048
|
return spawn(venvPython, [script, ...args]);
|
|
5049
5049
|
}
|
|
5050
5050
|
};
|
|
@@ -5396,20 +5396,20 @@ var StorageManager = class {
|
|
|
5396
5396
|
const basePath = this.locationManager.getBackend(mappedName).basePath;
|
|
5397
5397
|
location.files = {
|
|
5398
5398
|
async readFile(p) {
|
|
5399
|
-
return fs
|
|
5399
|
+
return fs.promises.readFile(path$1.join(basePath, p));
|
|
5400
5400
|
},
|
|
5401
5401
|
async writeFile(p, data) {
|
|
5402
5402
|
const full = path$1.join(basePath, p);
|
|
5403
|
-
await fs
|
|
5404
|
-
await fs
|
|
5403
|
+
await fs.promises.mkdir(path$1.dirname(full), { recursive: true });
|
|
5404
|
+
await fs.promises.writeFile(full, data);
|
|
5405
5405
|
},
|
|
5406
5406
|
async deleteFile(p) {
|
|
5407
|
-
await fs
|
|
5407
|
+
await fs.promises.rm(path$1.join(basePath, p), { force: true });
|
|
5408
5408
|
},
|
|
5409
5409
|
async listFiles(prefix) {
|
|
5410
5410
|
const dir = prefix ? path$1.join(basePath, prefix) : basePath;
|
|
5411
5411
|
try {
|
|
5412
|
-
return (await fs
|
|
5412
|
+
return (await fs.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
|
|
5413
5413
|
} catch {
|
|
5414
5414
|
return [];
|
|
5415
5415
|
}
|
|
@@ -5419,7 +5419,7 @@ var StorageManager = class {
|
|
|
5419
5419
|
},
|
|
5420
5420
|
async exists(p) {
|
|
5421
5421
|
try {
|
|
5422
|
-
await fs
|
|
5422
|
+
await fs.promises.access(path$1.join(basePath, p));
|
|
5423
5423
|
return true;
|
|
5424
5424
|
} catch {
|
|
5425
5425
|
return false;
|
|
@@ -5869,7 +5869,7 @@ var TRADITIONAL_NATIVE_PACKAGES = ["better-sqlite3"];
|
|
|
5869
5869
|
function hasDotNode(dir, maxDepth) {
|
|
5870
5870
|
let entries;
|
|
5871
5871
|
try {
|
|
5872
|
-
entries = fs
|
|
5872
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
5873
5873
|
} catch {
|
|
5874
5874
|
return false;
|
|
5875
5875
|
}
|
|
@@ -5880,7 +5880,7 @@ function hasDotNode(dir, maxDepth) {
|
|
|
5880
5880
|
}
|
|
5881
5881
|
/** Locate the bundled `prebuild-install` bin.js inside the staged closure. */
|
|
5882
5882
|
function resolvePrebuildInstallBin(closureDir, moduleDir) {
|
|
5883
|
-
return [path$1.join(moduleDir, "node_modules", "prebuild-install", "bin.js"), path$1.join(closureDir, "node_modules", "prebuild-install", "bin.js")].find((c) => fs
|
|
5883
|
+
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;
|
|
5884
5884
|
}
|
|
5885
5885
|
/**
|
|
5886
5886
|
* Default fetcher: run the closure's own `prebuild-install` under the CURRENT
|
|
@@ -5933,7 +5933,7 @@ async function ensureNativePrebuilds(closureDir, options) {
|
|
|
5933
5933
|
const fetched = [];
|
|
5934
5934
|
for (const pkg of packages) {
|
|
5935
5935
|
const moduleDir = path$1.join(nm, pkg);
|
|
5936
|
-
if (!fs
|
|
5936
|
+
if (!fs.existsSync(moduleDir)) continue;
|
|
5937
5937
|
if (hasDotNode(moduleDir, 4)) continue;
|
|
5938
5938
|
options.logger.warn("staged closure native prebuild missing — fetching for running ABI", { meta: {
|
|
5939
5939
|
pkg,
|
|
@@ -5996,12 +5996,12 @@ async function ensureNativePrebuilds(closureDir, options) {
|
|
|
5996
5996
|
function replantFromBundled(srcModuleDir, dstModuleDir, hasNative) {
|
|
5997
5997
|
if (!hasNative(srcModuleDir)) return false;
|
|
5998
5998
|
try {
|
|
5999
|
-
fs
|
|
5999
|
+
fs.rmSync(dstModuleDir, {
|
|
6000
6000
|
recursive: true,
|
|
6001
6001
|
force: true
|
|
6002
6002
|
});
|
|
6003
|
-
fs
|
|
6004
|
-
fs
|
|
6003
|
+
fs.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
|
|
6004
|
+
fs.cpSync(srcModuleDir, dstModuleDir, {
|
|
6005
6005
|
recursive: true,
|
|
6006
6006
|
dereference: true
|
|
6007
6007
|
});
|
|
@@ -6030,7 +6030,7 @@ async function ensureAddonNativePrebuilds(addonDir, options) {
|
|
|
6030
6030
|
const missing = [];
|
|
6031
6031
|
for (const pkg of packages) {
|
|
6032
6032
|
const moduleDir = path$1.join(nm, pkg);
|
|
6033
|
-
if (!fs
|
|
6033
|
+
if (!fs.existsSync(moduleDir)) continue;
|
|
6034
6034
|
if (hasNative(moduleDir)) {
|
|
6035
6035
|
results.push({
|
|
6036
6036
|
pkg,
|
|
@@ -6129,7 +6129,7 @@ async function defaultDownloadTarball(url, destTgz) {
|
|
|
6129
6129
|
const res = await fetch(url);
|
|
6130
6130
|
if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} downloading ${url}`);
|
|
6131
6131
|
const bytes = Buffer.from(await res.arrayBuffer());
|
|
6132
|
-
await fs
|
|
6132
|
+
await fs.promises.writeFile(destTgz, bytes);
|
|
6133
6133
|
}
|
|
6134
6134
|
async function defaultExtractTarball(tgzPath, destDir) {
|
|
6135
6135
|
await execFileAsync$5("tar", [
|
|
@@ -6215,7 +6215,7 @@ async function resolveUncached(options) {
|
|
|
6215
6215
|
argsPrefix: []
|
|
6216
6216
|
};
|
|
6217
6217
|
const cliPath = bootstrappedCliPath(options.cacheDir);
|
|
6218
|
-
if (fs
|
|
6218
|
+
if (fs.existsSync(cliPath)) {
|
|
6219
6219
|
options.logger.info("system npm unavailable — using bootstrapped npm", { meta: { cliPath } });
|
|
6220
6220
|
return {
|
|
6221
6221
|
command: process.execPath,
|
|
@@ -6227,12 +6227,12 @@ async function resolveUncached(options) {
|
|
|
6227
6227
|
const registry = (options.registry ?? DEFAULT_REGISTRY$1).replace(/\/+$/, "");
|
|
6228
6228
|
const tarballUrl = tarballUrlOf(await (options.fetchJson ?? defaultFetchJson)(`${registry}/npm/latest`));
|
|
6229
6229
|
if (!tarballUrl) throw new Error(`registry metadata for 'npm' carries no dist.tarball (${registry})`);
|
|
6230
|
-
await fs
|
|
6230
|
+
await fs.promises.mkdir(options.cacheDir, { recursive: true });
|
|
6231
6231
|
const tgzPath = path$1.join(options.cacheDir, "npm-bootstrap.tgz");
|
|
6232
6232
|
await (options.downloadTarball ?? defaultDownloadTarball)(tarballUrl, tgzPath);
|
|
6233
6233
|
await (options.extractTarball ?? defaultExtractTarball)(tgzPath, options.cacheDir);
|
|
6234
|
-
await fs
|
|
6235
|
-
if (!fs
|
|
6234
|
+
await fs.promises.rm(tgzPath, { force: true });
|
|
6235
|
+
if (!fs.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
|
|
6236
6236
|
options.logger.info("npm bootstrapped", { meta: { cliPath } });
|
|
6237
6237
|
return {
|
|
6238
6238
|
command: process.execPath,
|
|
@@ -6298,7 +6298,7 @@ function readOwningPackageVersion(entryPath) {
|
|
|
6298
6298
|
let dir = path$1.dirname(entryPath);
|
|
6299
6299
|
for (let hop = 0; hop < PACKAGE_JSON_LOOKUP_DEPTH; hop++) {
|
|
6300
6300
|
try {
|
|
6301
|
-
const version = asJsonObject$1(parseJsonUnknown(fs
|
|
6301
|
+
const version = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
|
|
6302
6302
|
if (typeof version === "string" && version.length > 0) return version;
|
|
6303
6303
|
} catch {}
|
|
6304
6304
|
const parent = path$1.dirname(dir);
|
|
@@ -6342,14 +6342,14 @@ function readOwningPackageVersion(entryPath) {
|
|
|
6342
6342
|
function addonModuleCacheKey(entryPath) {
|
|
6343
6343
|
let stat;
|
|
6344
6344
|
try {
|
|
6345
|
-
stat = fs
|
|
6345
|
+
stat = fs.statSync(entryPath);
|
|
6346
6346
|
} catch {
|
|
6347
6347
|
return null;
|
|
6348
6348
|
}
|
|
6349
6349
|
const version = readOwningPackageVersion(entryPath) ?? `m${stat.mtimeMs}`;
|
|
6350
6350
|
let content;
|
|
6351
6351
|
try {
|
|
6352
|
-
content = createHash("sha1").update(fs
|
|
6352
|
+
content = createHash("sha1").update(fs.readFileSync(entryPath)).digest("hex").slice(0, 16);
|
|
6353
6353
|
} catch {
|
|
6354
6354
|
content = `m${stat.mtimeMs}s${stat.size}`;
|
|
6355
6355
|
}
|
|
@@ -6453,14 +6453,14 @@ var AddonLoader = class {
|
|
|
6453
6453
|
* BUILTINS from the active closure, not the (now-inert) addons-dir copy, so
|
|
6454
6454
|
* the addons-dir `@camstack/server/system` must NOT be double-loaded here. */
|
|
6455
6455
|
async loadFromDirectory(addonsDir, skipPackages = []) {
|
|
6456
|
-
if (!fs
|
|
6456
|
+
if (!fs.existsSync(addonsDir)) return;
|
|
6457
6457
|
const skip = new Set(skipPackages);
|
|
6458
|
-
const entries = fs
|
|
6458
|
+
const entries = fs.readdirSync(addonsDir, { withFileTypes: true });
|
|
6459
6459
|
for (const entry of entries) {
|
|
6460
6460
|
if (!isDirectoryEntry(entry, addonsDir)) continue;
|
|
6461
6461
|
if (entry.name.startsWith("@")) {
|
|
6462
6462
|
const scopeDir = path$1.join(addonsDir, entry.name);
|
|
6463
|
-
const scopeEntries = fs
|
|
6463
|
+
const scopeEntries = fs.readdirSync(scopeDir, { withFileTypes: true });
|
|
6464
6464
|
for (const scopeEntry of scopeEntries) {
|
|
6465
6465
|
if (!isDirectoryEntry(scopeEntry, scopeDir)) continue;
|
|
6466
6466
|
if (skip.has(`${entry.name}/${scopeEntry.name}`)) continue;
|
|
@@ -6474,7 +6474,7 @@ var AddonLoader = class {
|
|
|
6474
6474
|
}
|
|
6475
6475
|
async tryLoadAddon(addonDir) {
|
|
6476
6476
|
const pkgJsonPath = path$1.join(addonDir, "package.json");
|
|
6477
|
-
if (!fs
|
|
6477
|
+
if (!fs.existsSync(pkgJsonPath)) return;
|
|
6478
6478
|
try {
|
|
6479
6479
|
await this.loadFromAddonDir(addonDir);
|
|
6480
6480
|
} catch (err) {
|
|
@@ -6492,7 +6492,7 @@ var AddonLoader = class {
|
|
|
6492
6492
|
/** Load addon from a specific directory (package.json + dist/) */
|
|
6493
6493
|
async loadFromAddonDir(addonDir) {
|
|
6494
6494
|
const pkgJsonPath = path$1.join(addonDir, "package.json");
|
|
6495
|
-
const pkgJson = asJsonObject$1(parseJsonUnknown(fs
|
|
6495
|
+
const pkgJson = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
|
|
6496
6496
|
const packageNameRaw = pkgJson["name"];
|
|
6497
6497
|
const packageName = typeof packageNameRaw === "string" ? packageNameRaw : "";
|
|
6498
6498
|
const packageVersionRaw = pkgJson["version"];
|
|
@@ -6540,7 +6540,7 @@ var AddonLoader = class {
|
|
|
6540
6540
|
}
|
|
6541
6541
|
const entryFile = declaration.entry.replace(/^\.\//, "").replace(/^src\//, "dist/").replace(/\.ts$/, ".js");
|
|
6542
6542
|
let entryPath = path$1.resolve(addonDir, entryFile);
|
|
6543
|
-
if (!fs
|
|
6543
|
+
if (!fs.existsSync(entryPath)) {
|
|
6544
6544
|
const base = entryPath.replace(/\.(js|cjs|mjs)$/, "");
|
|
6545
6545
|
entryPath = [
|
|
6546
6546
|
`${base}.cjs`,
|
|
@@ -6549,9 +6549,9 @@ var AddonLoader = class {
|
|
|
6549
6549
|
path$1.resolve(addonDir, "dist", "index.cjs"),
|
|
6550
6550
|
path$1.resolve(addonDir, "dist", "index.mjs"),
|
|
6551
6551
|
path$1.resolve(addonDir, declaration.entry)
|
|
6552
|
-
].find((p) => fs
|
|
6552
|
+
].find((p) => fs.existsSync(p)) ?? entryPath;
|
|
6553
6553
|
}
|
|
6554
|
-
if (!fs
|
|
6554
|
+
if (!fs.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
|
|
6555
6555
|
const modUnknown = await importAddonModuleFresh(entryPath);
|
|
6556
6556
|
const mod = isRecord$5(modUnknown) ? modUnknown : {};
|
|
6557
6557
|
const AddonClass = resolveAddonClass(mod);
|
|
@@ -6663,7 +6663,7 @@ function isDirectoryEntry(entry, parentDir) {
|
|
|
6663
6663
|
if (entry.name.startsWith(".")) return false;
|
|
6664
6664
|
if (entry.isDirectory()) return true;
|
|
6665
6665
|
if (entry.isSymbolicLink()) try {
|
|
6666
|
-
return fs
|
|
6666
|
+
return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
|
|
6667
6667
|
} catch {
|
|
6668
6668
|
return false;
|
|
6669
6669
|
}
|
|
@@ -6757,7 +6757,7 @@ var execFileAsync$4 = promisify(execFile);
|
|
|
6757
6757
|
* Single source of truth — replaces scattered mkdirSync calls.
|
|
6758
6758
|
*/
|
|
6759
6759
|
function ensureDir(dirPath) {
|
|
6760
|
-
fs
|
|
6760
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
6761
6761
|
}
|
|
6762
6762
|
/**
|
|
6763
6763
|
* Copy a directory recursively — ASYNC so it never blocks the event loop.
|
|
@@ -6770,7 +6770,7 @@ function ensureDir(dirPath) {
|
|
|
6770
6770
|
* `fs.promises.cp` keeps the I/O off the event loop. (Node ≥18 stable.)
|
|
6771
6771
|
*/
|
|
6772
6772
|
async function copyDirRecursive(src, dest) {
|
|
6773
|
-
await fs
|
|
6773
|
+
await fs.promises.cp(src, dest, {
|
|
6774
6774
|
recursive: true,
|
|
6775
6775
|
force: true
|
|
6776
6776
|
});
|
|
@@ -6875,13 +6875,13 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
|
|
|
6875
6875
|
if (typeof fileEntry !== "string") continue;
|
|
6876
6876
|
if (fileEntry === "dist" || fileEntry.includes("*")) continue;
|
|
6877
6877
|
const srcPath = path$1.join(sourceDir, fileEntry);
|
|
6878
|
-
if (!fs
|
|
6878
|
+
if (!fs.existsSync(srcPath)) continue;
|
|
6879
6879
|
const destPath = path$1.join(destDir, fileEntry);
|
|
6880
|
-
const stat = await fs
|
|
6880
|
+
const stat = await fs.promises.stat(srcPath);
|
|
6881
6881
|
if (stat.isDirectory()) await copyDirRecursive(srcPath, destPath);
|
|
6882
6882
|
else if (stat.isFile()) {
|
|
6883
6883
|
ensureDir(path$1.dirname(destPath));
|
|
6884
|
-
await fs
|
|
6884
|
+
await fs.promises.copyFile(srcPath, destPath);
|
|
6885
6885
|
}
|
|
6886
6886
|
}
|
|
6887
6887
|
}
|
|
@@ -6892,10 +6892,10 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
|
|
|
6892
6892
|
function isSourceNewer(packageDir) {
|
|
6893
6893
|
const srcDir = path$1.join(packageDir, "src");
|
|
6894
6894
|
const distDir = path$1.join(packageDir, "dist");
|
|
6895
|
-
if (!fs
|
|
6895
|
+
if (!fs.existsSync(srcDir) || !fs.existsSync(distDir)) return true;
|
|
6896
6896
|
try {
|
|
6897
|
-
const distMtime = fs
|
|
6898
|
-
const entries = fs
|
|
6897
|
+
const distMtime = fs.statSync(distDir).mtimeMs;
|
|
6898
|
+
const entries = fs.readdirSync(srcDir, {
|
|
6899
6899
|
withFileTypes: true,
|
|
6900
6900
|
recursive: true
|
|
6901
6901
|
});
|
|
@@ -6903,7 +6903,7 @@ function isSourceNewer(packageDir) {
|
|
|
6903
6903
|
if (!entry.isFile()) continue;
|
|
6904
6904
|
const parentDir = entry.parentPath ?? String(Reflect.get(entry, "path") ?? "");
|
|
6905
6905
|
const filePath = path$1.join(parentDir, entry.name);
|
|
6906
|
-
if (fs
|
|
6906
|
+
if (fs.statSync(filePath).mtimeMs > distMtime) return true;
|
|
6907
6907
|
}
|
|
6908
6908
|
return false;
|
|
6909
6909
|
} catch {
|
|
@@ -6920,7 +6920,7 @@ function isSourceNewer(packageDir) {
|
|
|
6920
6920
|
* `copyDirRecursive` for the wedge this prevents.
|
|
6921
6921
|
*/
|
|
6922
6922
|
async function installPackageFromNpm(packageName, targetDir) {
|
|
6923
|
-
const tmpDir = await fs
|
|
6923
|
+
const tmpDir = await fs.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
|
|
6924
6924
|
try {
|
|
6925
6925
|
const { stdout } = await execFileAsync$4("npm", [
|
|
6926
6926
|
"pack",
|
|
@@ -6943,21 +6943,21 @@ async function installPackageFromNpm(packageName, targetDir) {
|
|
|
6943
6943
|
extractDir
|
|
6944
6944
|
], { timeout: 3e4 });
|
|
6945
6945
|
const packageSubDir = path$1.join(extractDir, "package");
|
|
6946
|
-
const srcPkgJsonDir = fs
|
|
6947
|
-
await fs
|
|
6946
|
+
const srcPkgJsonDir = fs.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
|
|
6947
|
+
await fs.promises.rm(targetDir, {
|
|
6948
6948
|
recursive: true,
|
|
6949
6949
|
force: true
|
|
6950
6950
|
});
|
|
6951
6951
|
ensureDir(targetDir);
|
|
6952
|
-
await fs
|
|
6952
|
+
await fs.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
|
|
6953
6953
|
const distSrc = path$1.join(srcPkgJsonDir, "dist");
|
|
6954
|
-
if (fs
|
|
6954
|
+
if (fs.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
|
|
6955
6955
|
try {
|
|
6956
|
-
const npmPkg = asJsonObject$1(parseJsonUnknown(await fs
|
|
6956
|
+
const npmPkg = asJsonObject$1(parseJsonUnknown(await fs.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
|
|
6957
6957
|
if (npmPkg) await copyExtraFileDirs(npmPkg, srcPkgJsonDir, targetDir);
|
|
6958
6958
|
} catch {}
|
|
6959
6959
|
} finally {
|
|
6960
|
-
await fs
|
|
6960
|
+
await fs.promises.rm(tmpDir, {
|
|
6961
6961
|
recursive: true,
|
|
6962
6962
|
force: true
|
|
6963
6963
|
});
|
|
@@ -6982,7 +6982,7 @@ function packageDirName$1(declaredName) {
|
|
|
6982
6982
|
}
|
|
6983
6983
|
function isDirLike$1(p) {
|
|
6984
6984
|
try {
|
|
6985
|
-
return fs
|
|
6985
|
+
return fs.statSync(p).isDirectory();
|
|
6986
6986
|
} catch {
|
|
6987
6987
|
return false;
|
|
6988
6988
|
}
|
|
@@ -7000,12 +7000,12 @@ var AddonManifest = class {
|
|
|
7000
7000
|
*/
|
|
7001
7001
|
read() {
|
|
7002
7002
|
if (this.cache != null) return this.cache;
|
|
7003
|
-
if (!fs
|
|
7003
|
+
if (!fs.existsSync(this.manifestPath)) {
|
|
7004
7004
|
this.cache = this.empty();
|
|
7005
7005
|
return this.cache;
|
|
7006
7006
|
}
|
|
7007
7007
|
try {
|
|
7008
|
-
const raw = fs
|
|
7008
|
+
const raw = fs.readFileSync(this.manifestPath, "utf-8");
|
|
7009
7009
|
const parsed = JSON.parse(raw);
|
|
7010
7010
|
if (parsed.version !== MANIFEST_VERSION) {
|
|
7011
7011
|
process.stderr.write(`[AddonManifest] schema mismatch (file=${parsed.version} vs runtime=${MANIFEST_VERSION}); starting empty\n`);
|
|
@@ -7026,13 +7026,13 @@ var AddonManifest = class {
|
|
|
7026
7026
|
* a half-written file.
|
|
7027
7027
|
*/
|
|
7028
7028
|
write(manifest) {
|
|
7029
|
-
fs
|
|
7029
|
+
fs.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
|
|
7030
7030
|
const tmp = `${this.manifestPath}.tmp.${process.pid}.${Date.now()}`;
|
|
7031
|
-
fs
|
|
7031
|
+
fs.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
|
|
7032
7032
|
encoding: "utf-8",
|
|
7033
7033
|
mode: 384
|
|
7034
7034
|
});
|
|
7035
|
-
fs
|
|
7035
|
+
fs.renameSync(tmp, this.manifestPath);
|
|
7036
7036
|
this.cache = manifest;
|
|
7037
7037
|
}
|
|
7038
7038
|
/** Lookup a single addon's manifest entry, or `null` if not tracked. */
|
|
@@ -7107,22 +7107,22 @@ var AddonManifest = class {
|
|
|
7107
7107
|
* exactly what moved. Returns the total number of changes.
|
|
7108
7108
|
*/
|
|
7109
7109
|
reconcileFromDisk(addonsDir, onChange) {
|
|
7110
|
-
if (!fs
|
|
7110
|
+
if (!fs.existsSync(addonsDir)) return 0;
|
|
7111
7111
|
const m = this.read();
|
|
7112
7112
|
let changes = 0;
|
|
7113
7113
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7114
7114
|
/** Package name → version, for every ADDON package actually installed. */
|
|
7115
7115
|
const onDisk = /* @__PURE__ */ new Map();
|
|
7116
|
-
for (const scope of fs
|
|
7116
|
+
for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
|
|
7117
7117
|
if (!scope.name.startsWith("@") || !isDirLike$1(path$1.join(addonsDir, scope.name))) continue;
|
|
7118
7118
|
const scopeDir = path$1.join(addonsDir, scope.name);
|
|
7119
|
-
for (const pkg of fs
|
|
7119
|
+
for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
|
|
7120
7120
|
if (!isDirLike$1(path$1.join(scopeDir, pkg.name))) continue;
|
|
7121
7121
|
const pkgJsonPath = path$1.join(scopeDir, pkg.name, "package.json");
|
|
7122
|
-
if (!fs
|
|
7122
|
+
if (!fs.existsSync(pkgJsonPath)) continue;
|
|
7123
7123
|
let pkgJson;
|
|
7124
7124
|
try {
|
|
7125
|
-
const parsed = JSON.parse(fs
|
|
7125
|
+
const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
7126
7126
|
if (typeof parsed !== "object" || parsed == null) continue;
|
|
7127
7127
|
pkgJson = parsed;
|
|
7128
7128
|
} catch {
|
|
@@ -7193,28 +7193,28 @@ var AddonManifest = class {
|
|
|
7193
7193
|
migrateFromInstallSourceMarkers(addonsDir) {
|
|
7194
7194
|
const m = this.read();
|
|
7195
7195
|
if (Object.keys(m.addons).length > 0) return 0;
|
|
7196
|
-
if (!fs
|
|
7196
|
+
if (!fs.existsSync(addonsDir)) return 0;
|
|
7197
7197
|
let migrated = 0;
|
|
7198
7198
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7199
|
-
for (const scope of fs
|
|
7199
|
+
for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
|
|
7200
7200
|
if (!scope.isDirectory() || !scope.name.startsWith("@")) continue;
|
|
7201
7201
|
const scopeDir = path$1.join(addonsDir, scope.name);
|
|
7202
|
-
for (const pkg of fs
|
|
7202
|
+
for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
|
|
7203
7203
|
if (!pkg.isDirectory()) continue;
|
|
7204
7204
|
const pkgDir = path$1.join(scopeDir, pkg.name);
|
|
7205
7205
|
const markerPath = path$1.join(pkgDir, ".install-source");
|
|
7206
7206
|
const pkgJsonPath = path$1.join(pkgDir, "package.json");
|
|
7207
|
-
if (!fs
|
|
7207
|
+
if (!fs.existsSync(pkgJsonPath)) continue;
|
|
7208
7208
|
let pkgJson;
|
|
7209
7209
|
try {
|
|
7210
|
-
const parsed = JSON.parse(fs
|
|
7210
|
+
const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
7211
7211
|
if (typeof parsed !== "object" || parsed == null) continue;
|
|
7212
7212
|
pkgJson = parsed;
|
|
7213
7213
|
} catch {
|
|
7214
7214
|
continue;
|
|
7215
7215
|
}
|
|
7216
7216
|
if (!pkgJson.name || !pkgJson.version) continue;
|
|
7217
|
-
const source = fs
|
|
7217
|
+
const source = fs.existsSync(markerPath) ? fs.readFileSync(markerPath, "utf-8").trim() : "bundled";
|
|
7218
7218
|
m.addons[pkgJson.name] = {
|
|
7219
7219
|
name: pkgJson.name,
|
|
7220
7220
|
version: pkgJson.version,
|
|
@@ -7418,7 +7418,7 @@ function planClosureDedupe(input) {
|
|
|
7418
7418
|
function readTreeManifest(pkgJsonPath) {
|
|
7419
7419
|
let raw;
|
|
7420
7420
|
try {
|
|
7421
|
-
raw = asJsonObject$1(parseJsonUnknown(fs
|
|
7421
|
+
raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
|
|
7422
7422
|
} catch {
|
|
7423
7423
|
return null;
|
|
7424
7424
|
}
|
|
@@ -7443,7 +7443,7 @@ function readTreeManifest(pkgJsonPath) {
|
|
|
7443
7443
|
function listTopLevelEntries(nodeModulesDir) {
|
|
7444
7444
|
let entries;
|
|
7445
7445
|
try {
|
|
7446
|
-
entries = fs
|
|
7446
|
+
entries = fs.readdirSync(nodeModulesDir, { withFileTypes: true });
|
|
7447
7447
|
} catch {
|
|
7448
7448
|
return [];
|
|
7449
7449
|
}
|
|
@@ -7453,7 +7453,7 @@ function listTopLevelEntries(nodeModulesDir) {
|
|
|
7453
7453
|
if (entry.name.startsWith("@")) {
|
|
7454
7454
|
let inner;
|
|
7455
7455
|
try {
|
|
7456
|
-
inner = fs
|
|
7456
|
+
inner = fs.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
|
|
7457
7457
|
} catch {
|
|
7458
7458
|
continue;
|
|
7459
7459
|
}
|
|
@@ -7486,14 +7486,14 @@ function collectAddonTreeState(addonDir) {
|
|
|
7486
7486
|
const entryDir = path$1.join(nodeModulesDir, name);
|
|
7487
7487
|
let isLink = false;
|
|
7488
7488
|
try {
|
|
7489
|
-
isLink = fs
|
|
7489
|
+
isLink = fs.lstatSync(entryDir).isSymbolicLink();
|
|
7490
7490
|
} catch {
|
|
7491
7491
|
continue;
|
|
7492
7492
|
}
|
|
7493
7493
|
if (isLink) {
|
|
7494
7494
|
let target = "";
|
|
7495
7495
|
try {
|
|
7496
|
-
target = fs
|
|
7496
|
+
target = fs.readlinkSync(entryDir);
|
|
7497
7497
|
} catch {}
|
|
7498
7498
|
existingLinks.push({
|
|
7499
7499
|
name,
|
|
@@ -7507,7 +7507,7 @@ function collectAddonTreeState(addonDir) {
|
|
|
7507
7507
|
version: manifest.version
|
|
7508
7508
|
});
|
|
7509
7509
|
for (const [depName, range] of manifest.ranges) {
|
|
7510
|
-
if (fs
|
|
7510
|
+
if (fs.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
|
|
7511
7511
|
addRange(depName, range);
|
|
7512
7512
|
}
|
|
7513
7513
|
}
|
|
@@ -7537,7 +7537,7 @@ function resolveClosureNodeModulesDir(explicitDir) {
|
|
|
7537
7537
|
const frameworkDir = explicitDir ?? process.env["CAMSTACK_FRAMEWORK_DIR"];
|
|
7538
7538
|
if (frameworkDir === void 0 || frameworkDir.length === 0) return null;
|
|
7539
7539
|
const nodeModulesDir = explicitDir ?? path$1.join(frameworkDir, "node_modules");
|
|
7540
|
-
return fs
|
|
7540
|
+
return fs.existsSync(nodeModulesDir) ? nodeModulesDir : null;
|
|
7541
7541
|
}
|
|
7542
7542
|
function symlinkType() {
|
|
7543
7543
|
return process.platform === "win32" ? "junction" : "dir";
|
|
@@ -7556,10 +7556,10 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
|
|
|
7556
7556
|
const nodeModulesDir = path$1.join(addonDir, "node_modules");
|
|
7557
7557
|
const probePath = path$1.join(nodeModulesDir, ".closure-link-probe");
|
|
7558
7558
|
try {
|
|
7559
|
-
fs
|
|
7560
|
-
fs
|
|
7561
|
-
fs
|
|
7562
|
-
fs
|
|
7559
|
+
fs.mkdirSync(nodeModulesDir, { recursive: true });
|
|
7560
|
+
fs.rmSync(probePath, { force: true });
|
|
7561
|
+
fs.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
|
|
7562
|
+
fs.rmSync(probePath, { force: true });
|
|
7563
7563
|
} catch (err) {
|
|
7564
7564
|
logger.warn("closure dedupe skipped — symlinks unavailable on this volume", { meta: {
|
|
7565
7565
|
addonDir,
|
|
@@ -7581,12 +7581,12 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
|
|
|
7581
7581
|
}
|
|
7582
7582
|
const entryDir = path$1.join(nodeModulesDir, link.name);
|
|
7583
7583
|
try {
|
|
7584
|
-
fs
|
|
7584
|
+
fs.rmSync(entryDir, {
|
|
7585
7585
|
recursive: true,
|
|
7586
7586
|
force: true
|
|
7587
7587
|
});
|
|
7588
|
-
fs
|
|
7589
|
-
fs
|
|
7588
|
+
fs.mkdirSync(path$1.dirname(entryDir), { recursive: true });
|
|
7589
|
+
fs.symlinkSync(target, entryDir, symlinkType());
|
|
7590
7590
|
linked.push(link.name);
|
|
7591
7591
|
} catch (err) {
|
|
7592
7592
|
logger.warn("closure dedupe — link failed; entry removed copy may need reinstall", { meta: {
|
|
@@ -7662,7 +7662,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
|
|
|
7662
7662
|
count: Object.keys(native).length
|
|
7663
7663
|
} });
|
|
7664
7664
|
try {
|
|
7665
|
-
fs
|
|
7665
|
+
fs.writeFileSync(markerFile, markerHash);
|
|
7666
7666
|
} catch (err) {
|
|
7667
7667
|
logger.warn("Failed to write native deps marker", { meta: {
|
|
7668
7668
|
markerFile,
|
|
@@ -7700,7 +7700,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
|
|
|
7700
7700
|
}
|
|
7701
7701
|
await rebuildNativeDeps(addonDir, pending.map(([name]) => name), logger, npmCacheDir ?? defaultNpmCacheDir(), registry);
|
|
7702
7702
|
try {
|
|
7703
|
-
fs
|
|
7703
|
+
fs.writeFileSync(markerFile, markerHash);
|
|
7704
7704
|
} catch (err) {
|
|
7705
7705
|
logger.warn("Failed to write native deps marker", { meta: {
|
|
7706
7706
|
markerFile,
|
|
@@ -7722,12 +7722,12 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
|
|
|
7722
7722
|
if (source === target) continue;
|
|
7723
7723
|
if (!hasBuiltBinary(source)) continue;
|
|
7724
7724
|
try {
|
|
7725
|
-
fs
|
|
7725
|
+
fs.rmSync(target, {
|
|
7726
7726
|
recursive: true,
|
|
7727
7727
|
force: true
|
|
7728
7728
|
});
|
|
7729
|
-
fs
|
|
7730
|
-
fs
|
|
7729
|
+
fs.mkdirSync(path$1.dirname(target), { recursive: true });
|
|
7730
|
+
fs.cpSync(source, target, {
|
|
7731
7731
|
recursive: true,
|
|
7732
7732
|
dereference: true
|
|
7733
7733
|
});
|
|
@@ -7763,7 +7763,7 @@ var BUNDLED_NATIVE_SIBLING_SCOPES = {
|
|
|
7763
7763
|
function hasAnyDotNode(dir, maxDepth) {
|
|
7764
7764
|
let entries;
|
|
7765
7765
|
try {
|
|
7766
|
-
entries = fs
|
|
7766
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
7767
7767
|
} catch {
|
|
7768
7768
|
return false;
|
|
7769
7769
|
}
|
|
@@ -7777,12 +7777,12 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
|
|
|
7777
7777
|
if (!hasAnyDotNode(src, 5)) return;
|
|
7778
7778
|
if (hasAnyDotNode(dst, 5)) return;
|
|
7779
7779
|
try {
|
|
7780
|
-
fs
|
|
7780
|
+
fs.rmSync(dst, {
|
|
7781
7781
|
recursive: true,
|
|
7782
7782
|
force: true
|
|
7783
7783
|
});
|
|
7784
|
-
fs
|
|
7785
|
-
fs
|
|
7784
|
+
fs.mkdirSync(path$1.dirname(dst), { recursive: true });
|
|
7785
|
+
fs.cpSync(src, dst, {
|
|
7786
7786
|
recursive: true,
|
|
7787
7787
|
dereference: true
|
|
7788
7788
|
});
|
|
@@ -7817,7 +7817,7 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
|
|
|
7817
7817
|
*/
|
|
7818
7818
|
function copyBundledNativeModules(sourceDir, targetDir, logger) {
|
|
7819
7819
|
const srcNm = path$1.join(sourceDir, "node_modules");
|
|
7820
|
-
if (!fs
|
|
7820
|
+
if (!fs.existsSync(srcNm)) return;
|
|
7821
7821
|
const dstNm = path$1.join(targetDir, "node_modules");
|
|
7822
7822
|
for (const [name, scopes] of Object.entries(BUNDLED_NATIVE_SIBLING_SCOPES)) {
|
|
7823
7823
|
copyPrebuiltModuleDir(path$1.join(srcNm, name), path$1.join(dstNm, name), name, logger);
|
|
@@ -7825,7 +7825,7 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
|
|
|
7825
7825
|
const scopeSrc = path$1.join(srcNm, scope);
|
|
7826
7826
|
let siblings;
|
|
7827
7827
|
try {
|
|
7828
|
-
siblings = fs
|
|
7828
|
+
siblings = fs.readdirSync(scopeSrc);
|
|
7829
7829
|
} catch {
|
|
7830
7830
|
continue;
|
|
7831
7831
|
}
|
|
@@ -7835,12 +7835,12 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
|
|
|
7835
7835
|
}
|
|
7836
7836
|
/** A package dir is "built" when it carries a compiled `.node` or a prebuilds tree. */
|
|
7837
7837
|
function hasBuiltBinary(pkgDir) {
|
|
7838
|
-
if (!fs
|
|
7838
|
+
if (!fs.existsSync(path$1.join(pkgDir, "package.json"))) return false;
|
|
7839
7839
|
const releaseDir = path$1.join(pkgDir, "build", "Release");
|
|
7840
7840
|
try {
|
|
7841
|
-
if (fs
|
|
7841
|
+
if (fs.existsSync(releaseDir) && fs.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
|
|
7842
7842
|
} catch {}
|
|
7843
|
-
return fs
|
|
7843
|
+
return fs.existsSync(path$1.join(pkgDir, "prebuilds"));
|
|
7844
7844
|
}
|
|
7845
7845
|
/** Candidate hoisted locations for `<name>`: NODE_PATH entries + ancestors of `addonDir`. */
|
|
7846
7846
|
function candidateHoistedDirs(name, addonDir) {
|
|
@@ -7878,7 +7878,7 @@ function hashDeclaration(deps) {
|
|
|
7878
7878
|
}
|
|
7879
7879
|
function markerMatches(markerFile, expected) {
|
|
7880
7880
|
try {
|
|
7881
|
-
return fs
|
|
7881
|
+
return fs.readFileSync(markerFile, "utf-8").trim() === expected;
|
|
7882
7882
|
} catch {
|
|
7883
7883
|
return false;
|
|
7884
7884
|
}
|
|
@@ -8089,7 +8089,7 @@ function parseInstallSource(value) {
|
|
|
8089
8089
|
function readPackageJson(pkgJsonPath) {
|
|
8090
8090
|
let raw;
|
|
8091
8091
|
try {
|
|
8092
|
-
raw = asJsonObject$1(parseJsonUnknown(fs
|
|
8092
|
+
raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
|
|
8093
8093
|
} catch {
|
|
8094
8094
|
return null;
|
|
8095
8095
|
}
|
|
@@ -8133,7 +8133,7 @@ var REGISTRY_LATEST_TIMEOUT_MS = 15e3;
|
|
|
8133
8133
|
var FALLBACK_VERSION_PROBES = 25;
|
|
8134
8134
|
function readInstalledPackageVersion(addonDir) {
|
|
8135
8135
|
try {
|
|
8136
|
-
const raw = JSON.parse(fs
|
|
8136
|
+
const raw = JSON.parse(fs.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
|
|
8137
8137
|
if (raw === null || typeof raw !== "object") return null;
|
|
8138
8138
|
const version = Reflect.get(raw, "version");
|
|
8139
8139
|
return typeof version === "string" && version.length > 0 ? version : null;
|
|
@@ -8281,7 +8281,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8281
8281
|
} catch {
|
|
8282
8282
|
return Object.freeze([]);
|
|
8283
8283
|
}
|
|
8284
|
-
const raw = fs
|
|
8284
|
+
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
8285
8285
|
const parsed = JSON.parse(raw);
|
|
8286
8286
|
const deps = Object.keys(parsed.dependencies ?? {});
|
|
8287
8287
|
const agentOnly = new Set(parsed.camstack?.agentOnlyBootstrapAddons ?? []);
|
|
@@ -8326,7 +8326,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8326
8326
|
} catch {
|
|
8327
8327
|
return Object.freeze([]);
|
|
8328
8328
|
}
|
|
8329
|
-
const raw = fs
|
|
8329
|
+
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
8330
8330
|
const addons = JSON.parse(raw).camstack?.agentBootstrapAddons ?? [];
|
|
8331
8331
|
return Object.freeze(["@camstack/server", ...addons]);
|
|
8332
8332
|
}
|
|
@@ -8356,7 +8356,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8356
8356
|
this.logger.info(`Install source: ${isLocal ? `bundle (${this.bundledAddonsDir})` : "npm"}, ${pkgList.length} package(s)`);
|
|
8357
8357
|
for (const packageName of pkgList) {
|
|
8358
8358
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
8359
|
-
if (fs
|
|
8359
|
+
if (fs.existsSync(path$1.join(addonDir, "package.json"))) {
|
|
8360
8360
|
if (isLocal || shouldSkipClosureProvidedSeed(packageName, this.isResolvableFromClosure(packageName))) {
|
|
8361
8361
|
this.logger.debug(`${packageName} — already installed, skipping`);
|
|
8362
8362
|
continue;
|
|
@@ -8607,7 +8607,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8607
8607
|
const installedPackages = this.listInstalled();
|
|
8608
8608
|
for (const pkg of installedPackages) {
|
|
8609
8609
|
try {
|
|
8610
|
-
if (fs
|
|
8610
|
+
if (fs.lstatSync(pkg.dir).isSymbolicLink()) continue;
|
|
8611
8611
|
} catch {
|
|
8612
8612
|
continue;
|
|
8613
8613
|
}
|
|
@@ -8647,7 +8647,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8647
8647
|
if (closureNodeModules !== null) for (const link of state.existingLinks) {
|
|
8648
8648
|
if (!isClosureLinkTarget(link.target, closureNodeModules)) continue;
|
|
8649
8649
|
const linkDir = path$1.join(nodeModulesDir, link.name);
|
|
8650
|
-
const targetManifest = fs
|
|
8650
|
+
const targetManifest = fs.existsSync(path$1.join(linkDir, "package.json"));
|
|
8651
8651
|
const ranges = state.requirements.get(link.name) ?? [];
|
|
8652
8652
|
let holds = targetManifest;
|
|
8653
8653
|
if (holds && ranges.length > 0) {
|
|
@@ -8656,14 +8656,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8656
8656
|
}
|
|
8657
8657
|
if (!holds) {
|
|
8658
8658
|
this.logger.warn(`${packageName} — closure link for ${link.name} no longer holds; reinstalling this addon's deps`, { meta: { target: link.target } });
|
|
8659
|
-
fs
|
|
8659
|
+
fs.rmSync(linkDir, { force: true });
|
|
8660
8660
|
needsInstall = true;
|
|
8661
8661
|
}
|
|
8662
8662
|
}
|
|
8663
8663
|
const linked = [];
|
|
8664
8664
|
for (const [depName, range] of declaredEntries) {
|
|
8665
8665
|
if (typeof range !== "string") continue;
|
|
8666
|
-
if (fs
|
|
8666
|
+
if (fs.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
|
|
8667
8667
|
const closureVersion = closureNodeModules === null ? void 0 : readClosureVersions(closureNodeModules, [depName]).get(depName);
|
|
8668
8668
|
if (closureNodeModules !== null && closureVersion !== void 0 && closureSatisfiesRange(range, closureVersion)) {
|
|
8669
8669
|
if (executeClosureDedupe(addonDir, closureNodeModules, {
|
|
@@ -8696,7 +8696,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8696
8696
|
const closureNodeModules = resolveClosureNodeModulesDir(this.closureNodeModulesDir);
|
|
8697
8697
|
if (closureNodeModules !== null) {
|
|
8698
8698
|
const state = collectAddonTreeState(addonDir);
|
|
8699
|
-
for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs
|
|
8699
|
+
for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
|
|
8700
8700
|
}
|
|
8701
8701
|
this.logger.info(`${packageName} — reinstalling runtime dependencies`, { meta: { addonDir } });
|
|
8702
8702
|
await runNpm([
|
|
@@ -8741,7 +8741,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8741
8741
|
async realignFromClosure(packageName, closureDir) {
|
|
8742
8742
|
const targetDir = path$1.join(this.addonsDir, packageName);
|
|
8743
8743
|
const result = await this.installLocal(packageName, closureDir);
|
|
8744
|
-
await fs
|
|
8744
|
+
await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
|
|
8745
8745
|
this.manifest.upsert(result.name, {
|
|
8746
8746
|
version: result.version,
|
|
8747
8747
|
source: "closure"
|
|
@@ -8757,17 +8757,17 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8757
8757
|
async installCopy(packageName, sourceDir, pkgData, targetDir) {
|
|
8758
8758
|
await this.ensureBuilt(packageName, sourceDir, pkgData);
|
|
8759
8759
|
const distDir = path$1.join(sourceDir, "dist");
|
|
8760
|
-
if (!fs
|
|
8761
|
-
await fs
|
|
8760
|
+
if (!fs.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
|
|
8761
|
+
await fs.promises.rm(targetDir, {
|
|
8762
8762
|
recursive: true,
|
|
8763
8763
|
force: true
|
|
8764
8764
|
});
|
|
8765
8765
|
ensureDir(targetDir);
|
|
8766
|
-
await fs
|
|
8766
|
+
await fs.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
|
|
8767
8767
|
await copyDirRecursive(distDir, path$1.join(targetDir, "dist"));
|
|
8768
8768
|
await copyExtraFileDirs(pkgData, sourceDir, targetDir);
|
|
8769
8769
|
copyBundledNativeModules(sourceDir, targetDir, this.logger);
|
|
8770
|
-
await fs
|
|
8770
|
+
await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
|
|
8771
8771
|
const localPkgVersion = asString$1(pkgData.version, "0.0.0");
|
|
8772
8772
|
this.manifest.upsert(packageName, {
|
|
8773
8773
|
version: localPkgVersion,
|
|
@@ -8808,7 +8808,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8808
8808
|
* unusual auth, offline mode, etc).
|
|
8809
8809
|
*/
|
|
8810
8810
|
async installFromNpm(packageName, version) {
|
|
8811
|
-
const tmpDir = fs
|
|
8811
|
+
const tmpDir = fs.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
|
|
8812
8812
|
const packageSpec = version ? `${packageName}@${version}` : packageName;
|
|
8813
8813
|
this.logger.info(`${packageName} — installing from npm`);
|
|
8814
8814
|
try {
|
|
@@ -8822,19 +8822,19 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8822
8822
|
];
|
|
8823
8823
|
if (this.registry) args.push("--registry", this.registry);
|
|
8824
8824
|
const { stdout } = await runNpm(args, this.npmRunOptions(tmpDir, 12e4));
|
|
8825
|
-
const tgzFiles = fs
|
|
8825
|
+
const tgzFiles = fs.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
|
|
8826
8826
|
if (tgzFiles.length === 0) throw new Error(`npm pack produced no tgz. stdout: ${stdout.trim()}`);
|
|
8827
8827
|
return path$1.join(tmpDir, tgzFiles[0]);
|
|
8828
8828
|
});
|
|
8829
8829
|
const result = await this.installFromTgz(tgzPath);
|
|
8830
|
-
fs
|
|
8830
|
+
fs.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
|
|
8831
8831
|
this.manifest.upsert(result.name, {
|
|
8832
8832
|
version: result.version,
|
|
8833
8833
|
source: "npm"
|
|
8834
8834
|
});
|
|
8835
8835
|
return result;
|
|
8836
8836
|
} finally {
|
|
8837
|
-
fs
|
|
8837
|
+
fs.rmSync(tmpDir, {
|
|
8838
8838
|
recursive: true,
|
|
8839
8839
|
force: true
|
|
8840
8840
|
});
|
|
@@ -8872,7 +8872,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8872
8872
|
if (!tarRes.ok) throw new Error(`tarball GET ${tarballUrl} → ${tarRes.status}`);
|
|
8873
8873
|
const tgzPath = path$1.join(tmpDir, `${packageName.replace(/[/@]/g, "-").replace(/^-+/, "")}-${resolvedVersion}.tgz`);
|
|
8874
8874
|
const buf = Buffer.from(await tarRes.arrayBuffer());
|
|
8875
|
-
fs
|
|
8875
|
+
fs.writeFileSync(tgzPath, buf);
|
|
8876
8876
|
return tgzPath;
|
|
8877
8877
|
}
|
|
8878
8878
|
/**
|
|
@@ -8893,7 +8893,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8893
8893
|
* on the next deploy.
|
|
8894
8894
|
*/
|
|
8895
8895
|
async evictInstallDir(targetDir) {
|
|
8896
|
-
if (!fs
|
|
8896
|
+
if (!fs.existsSync(targetDir)) return;
|
|
8897
8897
|
const graveyard = path$1.join(this.addonsDir, ".evicting");
|
|
8898
8898
|
ensureDir(graveyard);
|
|
8899
8899
|
await this.sweepGraveyard(graveyard);
|
|
@@ -8901,10 +8901,10 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8901
8901
|
const flatName = path$1.relative(this.addonsDir, targetDir).replace(/[/\\]/g, "-");
|
|
8902
8902
|
const asideDir = path$1.join(graveyard, `${flatName}-${ts}`);
|
|
8903
8903
|
try {
|
|
8904
|
-
fs
|
|
8904
|
+
fs.renameSync(targetDir, asideDir);
|
|
8905
8905
|
} catch (renameErr) {
|
|
8906
8906
|
if (renameErr.code === "EXDEV") {
|
|
8907
|
-
await fs
|
|
8907
|
+
await fs.promises.rm(targetDir, {
|
|
8908
8908
|
recursive: true,
|
|
8909
8909
|
force: true
|
|
8910
8910
|
});
|
|
@@ -8912,7 +8912,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8912
8912
|
}
|
|
8913
8913
|
throw renameErr;
|
|
8914
8914
|
}
|
|
8915
|
-
await fs
|
|
8915
|
+
await fs.promises.rm(asideDir, {
|
|
8916
8916
|
recursive: true,
|
|
8917
8917
|
force: true
|
|
8918
8918
|
}).catch((cleanupErr) => {
|
|
@@ -8933,14 +8933,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8933
8933
|
async sweepStagingResidue(stagingRoot) {
|
|
8934
8934
|
let names;
|
|
8935
8935
|
try {
|
|
8936
|
-
names = fs
|
|
8936
|
+
names = fs.readdirSync(stagingRoot);
|
|
8937
8937
|
} catch {
|
|
8938
8938
|
return;
|
|
8939
8939
|
}
|
|
8940
8940
|
const now = Date.now();
|
|
8941
8941
|
const ages = [];
|
|
8942
8942
|
for (const name of names) try {
|
|
8943
|
-
const stat = fs
|
|
8943
|
+
const stat = fs.statSync(path$1.join(stagingRoot, name));
|
|
8944
8944
|
ages.push({
|
|
8945
8945
|
name,
|
|
8946
8946
|
ageMs: now - stat.mtimeMs
|
|
@@ -8951,7 +8951,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8951
8951
|
stagingRoot,
|
|
8952
8952
|
entries: sweepable
|
|
8953
8953
|
} });
|
|
8954
|
-
await Promise.all(sweepable.map((name) => fs
|
|
8954
|
+
await Promise.all(sweepable.map((name) => fs.promises.rm(path$1.join(stagingRoot, name), {
|
|
8955
8955
|
recursive: true,
|
|
8956
8956
|
force: true
|
|
8957
8957
|
}).catch(() => void 0)));
|
|
@@ -8960,11 +8960,11 @@ var AddonInstaller = class AddonInstaller {
|
|
|
8960
8960
|
async sweepGraveyard(graveyard) {
|
|
8961
8961
|
let entries;
|
|
8962
8962
|
try {
|
|
8963
|
-
entries = fs
|
|
8963
|
+
entries = fs.readdirSync(graveyard);
|
|
8964
8964
|
} catch {
|
|
8965
8965
|
return;
|
|
8966
8966
|
}
|
|
8967
|
-
await Promise.all(entries.map((name) => fs
|
|
8967
|
+
await Promise.all(entries.map((name) => fs.promises.rm(path$1.join(graveyard, name), {
|
|
8968
8968
|
recursive: true,
|
|
8969
8969
|
force: true
|
|
8970
8970
|
}).catch(() => void 0)));
|
|
@@ -9015,7 +9015,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9015
9015
|
return;
|
|
9016
9016
|
}
|
|
9017
9017
|
const strippedManifest = stripBundledDeps(pkgView.raw);
|
|
9018
|
-
await fs
|
|
9018
|
+
await fs.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
|
|
9019
9019
|
const deps = asJsonObject$1(strippedManifest["dependencies"]);
|
|
9020
9020
|
const depNames = deps ? Object.keys(deps) : [];
|
|
9021
9021
|
if (depNames.length === 0) return;
|
|
@@ -9147,9 +9147,9 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9147
9147
|
"-C",
|
|
9148
9148
|
stagingDir
|
|
9149
9149
|
], { timeout: 12e4 });
|
|
9150
|
-
const pkgDir = fs
|
|
9150
|
+
const pkgDir = fs.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
|
|
9151
9151
|
const pkgJsonPath = path$1.join(pkgDir, "package.json");
|
|
9152
|
-
if (!fs
|
|
9152
|
+
if (!fs.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
|
|
9153
9153
|
const pkgView = readPackageJson(pkgJsonPath);
|
|
9154
9154
|
if (!pkgView) throw new Error(`Invalid package.json at ${pkgJsonPath}`);
|
|
9155
9155
|
if (!pkgView.camstackAddons) throw new Error(`Package ${pkgView.name} has no camstack.addons manifest`);
|
|
@@ -9159,7 +9159,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9159
9159
|
this.dedupeTreeAgainstClosure(pkgDir, pkgView.name);
|
|
9160
9160
|
await this.evictInstallDir(targetDir);
|
|
9161
9161
|
ensureDir(path$1.dirname(targetDir));
|
|
9162
|
-
await fs
|
|
9162
|
+
await fs.promises.rename(pkgDir, targetDir);
|
|
9163
9163
|
this.manifest.upsert(pkgView.name, {
|
|
9164
9164
|
version: pkgView.version,
|
|
9165
9165
|
source: "bundled"
|
|
@@ -9170,7 +9170,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9170
9170
|
};
|
|
9171
9171
|
} finally {
|
|
9172
9172
|
this.inFlightStaging.delete(stagingName);
|
|
9173
|
-
await fs
|
|
9173
|
+
await fs.promises.rm(stagingDir, {
|
|
9174
9174
|
recursive: true,
|
|
9175
9175
|
force: true
|
|
9176
9176
|
}).catch(() => void 0);
|
|
@@ -9200,24 +9200,24 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9200
9200
|
const current = this.manifest.get(packageName);
|
|
9201
9201
|
if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
|
|
9202
9202
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9203
|
-
if (!fs
|
|
9203
|
+
if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
|
|
9204
9204
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
9205
9205
|
const backupRoot = path$1.join(this.addonsDir, ".backups", packageName);
|
|
9206
9206
|
ensureDir(backupRoot);
|
|
9207
9207
|
const backupDir = path$1.join(backupRoot, ts);
|
|
9208
9208
|
this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
|
|
9209
|
-
fs
|
|
9209
|
+
fs.renameSync(addonDir, backupDir);
|
|
9210
9210
|
let result;
|
|
9211
9211
|
try {
|
|
9212
9212
|
result = await this.installFromNpm(packageName, version);
|
|
9213
9213
|
} catch (installErr) {
|
|
9214
9214
|
this.logger.error(`${packageName} — install failed, restoring backup`, { meta: { error: errMsg$1(installErr) } });
|
|
9215
9215
|
try {
|
|
9216
|
-
if (fs
|
|
9216
|
+
if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
|
|
9217
9217
|
recursive: true,
|
|
9218
9218
|
force: true
|
|
9219
9219
|
});
|
|
9220
|
-
fs
|
|
9220
|
+
fs.renameSync(backupDir, addonDir);
|
|
9221
9221
|
this.manifest.upsert(packageName, {
|
|
9222
9222
|
version: current.version,
|
|
9223
9223
|
source: current.source,
|
|
@@ -9278,7 +9278,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9278
9278
|
const current = this.manifest.get(packageName);
|
|
9279
9279
|
if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
|
|
9280
9280
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9281
|
-
if (!fs
|
|
9281
|
+
if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
|
|
9282
9282
|
await this.installRuntimeDependencies(stagedPath, packageName);
|
|
9283
9283
|
await this.installNativeDependencies(stagedPath, packageName);
|
|
9284
9284
|
this.dedupeTreeAgainstClosure(stagedPath, packageName);
|
|
@@ -9287,14 +9287,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9287
9287
|
ensureDir(backupRoot);
|
|
9288
9288
|
const backupDir = path$1.join(backupRoot, ts);
|
|
9289
9289
|
this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
|
|
9290
|
-
fs
|
|
9290
|
+
fs.renameSync(addonDir, backupDir);
|
|
9291
9291
|
try {
|
|
9292
9292
|
try {
|
|
9293
|
-
fs
|
|
9293
|
+
fs.renameSync(stagedPath, addonDir);
|
|
9294
9294
|
} catch (renameErr) {
|
|
9295
9295
|
if (renameErr.code === "EXDEV") {
|
|
9296
|
-
fs
|
|
9297
|
-
fs
|
|
9296
|
+
fs.cpSync(stagedPath, addonDir, { recursive: true });
|
|
9297
|
+
fs.rmSync(stagedPath, {
|
|
9298
9298
|
recursive: true,
|
|
9299
9299
|
force: true
|
|
9300
9300
|
});
|
|
@@ -9303,11 +9303,11 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9303
9303
|
} catch (swapErr) {
|
|
9304
9304
|
this.logger.error(`${packageName} — staged swap failed, restoring backup`, { meta: { error: errMsg$1(swapErr) } });
|
|
9305
9305
|
try {
|
|
9306
|
-
if (fs
|
|
9306
|
+
if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
|
|
9307
9307
|
recursive: true,
|
|
9308
9308
|
force: true
|
|
9309
9309
|
});
|
|
9310
|
-
fs
|
|
9310
|
+
fs.renameSync(backupDir, addonDir);
|
|
9311
9311
|
this.manifest.upsert(packageName, {
|
|
9312
9312
|
version: current.version,
|
|
9313
9313
|
source: current.source,
|
|
@@ -9346,20 +9346,20 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9346
9346
|
this.logger.warn(`${packageName} — no backup to rollback to`);
|
|
9347
9347
|
return null;
|
|
9348
9348
|
}
|
|
9349
|
-
if (!fs
|
|
9349
|
+
if (!fs.existsSync(entry.lastBackupDir)) {
|
|
9350
9350
|
this.logger.warn(`${packageName} — backup dir vanished: ${entry.lastBackupDir}`);
|
|
9351
9351
|
return null;
|
|
9352
9352
|
}
|
|
9353
9353
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9354
|
-
if (fs
|
|
9354
|
+
if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
|
|
9355
9355
|
recursive: true,
|
|
9356
9356
|
force: true
|
|
9357
9357
|
});
|
|
9358
|
-
fs
|
|
9358
|
+
fs.renameSync(entry.lastBackupDir, addonDir);
|
|
9359
9359
|
const pkgJsonPath = path$1.join(addonDir, "package.json");
|
|
9360
9360
|
let restoredVersion = entry.version;
|
|
9361
|
-
if (fs
|
|
9362
|
-
const parsed = JSON.parse(fs
|
|
9361
|
+
if (fs.existsSync(pkgJsonPath)) try {
|
|
9362
|
+
const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
9363
9363
|
if (typeof parsed === "object" && parsed != null) {
|
|
9364
9364
|
const v = parsed.version;
|
|
9365
9365
|
if (typeof v === "string" && v.length > 0) restoredVersion = v;
|
|
@@ -9407,7 +9407,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9407
9407
|
return false;
|
|
9408
9408
|
}
|
|
9409
9409
|
try {
|
|
9410
|
-
await fs
|
|
9410
|
+
await fs.promises.rm(target, {
|
|
9411
9411
|
recursive: true,
|
|
9412
9412
|
force: true
|
|
9413
9413
|
});
|
|
@@ -9425,7 +9425,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9425
9425
|
listBackupsFor(packageName) {
|
|
9426
9426
|
const dir = path$1.join(this.backupsRoot, packageName);
|
|
9427
9427
|
try {
|
|
9428
|
-
return fs
|
|
9428
|
+
return fs.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
|
|
9429
9429
|
} catch {
|
|
9430
9430
|
return [];
|
|
9431
9431
|
}
|
|
@@ -9457,7 +9457,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9457
9457
|
for (const dir of [pkgDir, path$1.dirname(pkgDir)]) {
|
|
9458
9458
|
if (!this.isInsideBackups(dir)) continue;
|
|
9459
9459
|
try {
|
|
9460
|
-
await fs
|
|
9460
|
+
await fs.promises.rmdir(dir);
|
|
9461
9461
|
} catch {
|
|
9462
9462
|
return;
|
|
9463
9463
|
}
|
|
@@ -9539,7 +9539,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9539
9539
|
*/
|
|
9540
9540
|
resolveBackupToKeep(packageName, backups) {
|
|
9541
9541
|
const liveDir = path$1.join(this.addonsDir, packageName);
|
|
9542
|
-
if (!fs
|
|
9542
|
+
if (!fs.existsSync(liveDir)) {
|
|
9543
9543
|
const newest = backups[backups.length - 1] ?? null;
|
|
9544
9544
|
if (newest != null) this.logger.warn(`${packageName} — live install dir missing; retaining its newest backup as the only surviving copy`, { meta: {
|
|
9545
9545
|
liveDir,
|
|
@@ -9556,7 +9556,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9556
9556
|
listBackedUpPackages() {
|
|
9557
9557
|
let entries;
|
|
9558
9558
|
try {
|
|
9559
|
-
entries = fs
|
|
9559
|
+
entries = fs.readdirSync(this.backupsRoot, { withFileTypes: true });
|
|
9560
9560
|
} catch {
|
|
9561
9561
|
return [];
|
|
9562
9562
|
}
|
|
@@ -9568,14 +9568,14 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9568
9568
|
continue;
|
|
9569
9569
|
}
|
|
9570
9570
|
const scopeDir = path$1.join(this.backupsRoot, entry.name);
|
|
9571
|
-
for (const inner of fs
|
|
9571
|
+
for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
|
|
9572
9572
|
}
|
|
9573
9573
|
return names;
|
|
9574
9574
|
}
|
|
9575
9575
|
async uninstall(packageName) {
|
|
9576
9576
|
const addonDir = path$1.join(this.addonsDir, packageName);
|
|
9577
|
-
if (fs
|
|
9578
|
-
fs
|
|
9577
|
+
if (fs.existsSync(addonDir)) {
|
|
9578
|
+
fs.rmSync(addonDir, {
|
|
9579
9579
|
recursive: true,
|
|
9580
9580
|
force: true
|
|
9581
9581
|
});
|
|
@@ -9583,8 +9583,8 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9583
9583
|
return;
|
|
9584
9584
|
}
|
|
9585
9585
|
const legacyDir = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""));
|
|
9586
|
-
if (fs
|
|
9587
|
-
fs
|
|
9586
|
+
if (fs.existsSync(legacyDir)) {
|
|
9587
|
+
fs.rmSync(legacyDir, {
|
|
9588
9588
|
recursive: true,
|
|
9589
9589
|
force: true
|
|
9590
9590
|
});
|
|
@@ -9592,22 +9592,22 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9592
9592
|
}
|
|
9593
9593
|
}
|
|
9594
9594
|
listInstalled() {
|
|
9595
|
-
if (!fs
|
|
9595
|
+
if (!fs.existsSync(this.addonsDir)) return [];
|
|
9596
9596
|
const packageDirs = [];
|
|
9597
|
-
for (const entry of fs
|
|
9597
|
+
for (const entry of fs.readdirSync(this.addonsDir, { withFileTypes: true })) {
|
|
9598
9598
|
if (!isDirEntry(entry, this.addonsDir)) continue;
|
|
9599
9599
|
if (entry.name.startsWith("@")) {
|
|
9600
9600
|
const scopeDir = path$1.join(this.addonsDir, entry.name);
|
|
9601
|
-
for (const inner of fs
|
|
9601
|
+
for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
|
|
9602
9602
|
} else packageDirs.push(path$1.join(this.addonsDir, entry.name));
|
|
9603
9603
|
}
|
|
9604
9604
|
return packageDirs.map((dir) => {
|
|
9605
9605
|
const pkgPath = path$1.join(dir, "package.json");
|
|
9606
|
-
if (!fs
|
|
9606
|
+
if (!fs.existsSync(pkgPath)) return null;
|
|
9607
9607
|
const pkg = readPackageJson(pkgPath);
|
|
9608
9608
|
if (!pkg || !pkg.camstackAddons) return null;
|
|
9609
9609
|
const sourceFile = path$1.join(dir, ".install-source");
|
|
9610
|
-
const installSource = fs
|
|
9610
|
+
const installSource = fs.existsSync(sourceFile) ? parseInstallSource(fs.readFileSync(sourceFile, "utf-8").trim()) : void 0;
|
|
9611
9611
|
return {
|
|
9612
9612
|
name: pkg.name,
|
|
9613
9613
|
version: pkg.version,
|
|
@@ -9617,13 +9617,13 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9617
9617
|
}).filter((item) => item !== null);
|
|
9618
9618
|
}
|
|
9619
9619
|
isInstalled(packageName) {
|
|
9620
|
-
if (fs
|
|
9621
|
-
return fs
|
|
9620
|
+
if (fs.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
|
|
9621
|
+
return fs.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
|
|
9622
9622
|
}
|
|
9623
9623
|
getInstalledPackage(packageName) {
|
|
9624
9624
|
let pkgPath = path$1.join(this.addonsDir, packageName, "package.json");
|
|
9625
|
-
if (!fs
|
|
9626
|
-
if (!fs
|
|
9625
|
+
if (!fs.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
|
|
9626
|
+
if (!fs.existsSync(pkgPath)) return null;
|
|
9627
9627
|
const pkg = readPackageJson(pkgPath);
|
|
9628
9628
|
if (!pkg) return null;
|
|
9629
9629
|
return {
|
|
@@ -9642,7 +9642,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9642
9642
|
]) {
|
|
9643
9643
|
const candidate = path$1.join(this.bundledAddonsDir, dirName);
|
|
9644
9644
|
try {
|
|
9645
|
-
const pkg = asJsonObject$1(parseJsonUnknown(fs
|
|
9645
|
+
const pkg = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
|
|
9646
9646
|
if (pkg && asString$1(pkg["name"]) === packageName) return candidate;
|
|
9647
9647
|
} catch {}
|
|
9648
9648
|
}
|
|
@@ -9651,7 +9651,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9651
9651
|
/** Ensure a package is built (dist/ exists and page bundles present) */
|
|
9652
9652
|
async ensureBuilt(packageName, sourceDir, pkgData) {
|
|
9653
9653
|
const distDir = path$1.join(sourceDir, "dist");
|
|
9654
|
-
if (!(!fs
|
|
9654
|
+
if (!(!fs.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
|
|
9655
9655
|
this.logger.info(`${packageName} — building (dist/ missing or incomplete)`);
|
|
9656
9656
|
try {
|
|
9657
9657
|
await runNpm(["run", "build"], this.npmRunOptions(sourceDir, 18e4));
|
|
@@ -9666,7 +9666,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9666
9666
|
if (!camstack?.addons) return false;
|
|
9667
9667
|
for (const addon of camstack.addons) {
|
|
9668
9668
|
if (!addon.pages) continue;
|
|
9669
|
-
for (const page of addon.pages) if (page.bundle && !fs
|
|
9669
|
+
for (const page of addon.pages) if (page.bundle && !fs.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
|
|
9670
9670
|
}
|
|
9671
9671
|
return false;
|
|
9672
9672
|
}
|
|
@@ -9675,7 +9675,7 @@ var AddonInstaller = class AddonInstaller {
|
|
|
9675
9675
|
function isDirEntry(entry, parentDir) {
|
|
9676
9676
|
if (entry.isDirectory()) return true;
|
|
9677
9677
|
if (entry.isSymbolicLink()) try {
|
|
9678
|
-
return fs
|
|
9678
|
+
return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
|
|
9679
9679
|
} catch {
|
|
9680
9680
|
return false;
|
|
9681
9681
|
}
|
|
@@ -9774,7 +9774,7 @@ function selectAddonResidue(candidates) {
|
|
|
9774
9774
|
}
|
|
9775
9775
|
function readDeclaredName(dir) {
|
|
9776
9776
|
try {
|
|
9777
|
-
const parsed = JSON.parse(fs
|
|
9777
|
+
const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
9778
9778
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
9779
9779
|
const name = parsed.name;
|
|
9780
9780
|
return typeof name === "string" ? name : null;
|
|
@@ -9784,7 +9784,7 @@ function readDeclaredName(dir) {
|
|
|
9784
9784
|
}
|
|
9785
9785
|
function readDeclaredVersion(dir) {
|
|
9786
9786
|
try {
|
|
9787
|
-
const parsed = JSON.parse(fs
|
|
9787
|
+
const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
9788
9788
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
9789
9789
|
const version = parsed.version;
|
|
9790
9790
|
return typeof version === "string" ? version : null;
|
|
@@ -9794,7 +9794,7 @@ function readDeclaredVersion(dir) {
|
|
|
9794
9794
|
}
|
|
9795
9795
|
function isDirLike(p) {
|
|
9796
9796
|
try {
|
|
9797
|
-
return fs
|
|
9797
|
+
return fs.statSync(p).isDirectory();
|
|
9798
9798
|
} catch {
|
|
9799
9799
|
return false;
|
|
9800
9800
|
}
|
|
@@ -9804,7 +9804,7 @@ function freeQuarantineTarget(store, scope, dirName) {
|
|
|
9804
9804
|
const base = scope === null ? dirName : `${scope.replace("@", "")}__${dirName}`;
|
|
9805
9805
|
let candidate = path$1.join(store, base);
|
|
9806
9806
|
let n = 1;
|
|
9807
|
-
while (fs
|
|
9807
|
+
while (fs.existsSync(candidate)) {
|
|
9808
9808
|
candidate = path$1.join(store, `${base}-${n}`);
|
|
9809
9809
|
n += 1;
|
|
9810
9810
|
}
|
|
@@ -9821,7 +9821,7 @@ function freeQuarantineTarget(store, scope, dirName) {
|
|
|
9821
9821
|
function quarantineAddonResidue(addonsDir, log) {
|
|
9822
9822
|
const quarantined = [];
|
|
9823
9823
|
const failed = [];
|
|
9824
|
-
if (!fs
|
|
9824
|
+
if (!fs.existsSync(addonsDir)) return {
|
|
9825
9825
|
quarantined,
|
|
9826
9826
|
failed
|
|
9827
9827
|
};
|
|
@@ -9829,7 +9829,7 @@ function quarantineAddonResidue(addonsDir, log) {
|
|
|
9829
9829
|
const scan = (parent, scope) => {
|
|
9830
9830
|
let names;
|
|
9831
9831
|
try {
|
|
9832
|
-
names = fs
|
|
9832
|
+
names = fs.readdirSync(parent);
|
|
9833
9833
|
} catch {
|
|
9834
9834
|
return;
|
|
9835
9835
|
}
|
|
@@ -9848,8 +9848,8 @@ function quarantineAddonResidue(addonsDir, log) {
|
|
|
9848
9848
|
const version = readDeclaredVersion(full);
|
|
9849
9849
|
const to = freeQuarantineTarget(store, scope, dirName);
|
|
9850
9850
|
try {
|
|
9851
|
-
fs
|
|
9852
|
-
fs
|
|
9851
|
+
fs.mkdirSync(store, { recursive: true });
|
|
9852
|
+
fs.renameSync(full, to);
|
|
9853
9853
|
} catch (err) {
|
|
9854
9854
|
const error = err instanceof Error ? err.message : String(err);
|
|
9855
9855
|
failed.push({
|
|
@@ -9907,11 +9907,11 @@ function getRestartMarkerPath(dataDir) {
|
|
|
9907
9907
|
* intact or no marker at all (never a half-written file).
|
|
9908
9908
|
*/
|
|
9909
9909
|
function writePendingRestart(dataDir, marker) {
|
|
9910
|
-
fs
|
|
9910
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
9911
9911
|
const markerPath = getRestartMarkerPath(dataDir);
|
|
9912
9912
|
const tmpPath = `${markerPath}.tmp`;
|
|
9913
|
-
fs
|
|
9914
|
-
fs
|
|
9913
|
+
fs.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
|
|
9914
|
+
fs.renameSync(tmpPath, markerPath);
|
|
9915
9915
|
}
|
|
9916
9916
|
/**
|
|
9917
9917
|
* Read + consume the marker. Returns the parsed payload on success and
|
|
@@ -9936,10 +9936,10 @@ function writePendingRestart(dataDir, marker) {
|
|
|
9936
9936
|
*/
|
|
9937
9937
|
function readPendingRestart(dataDir) {
|
|
9938
9938
|
const markerPath = getRestartMarkerPath(dataDir);
|
|
9939
|
-
if (!fs
|
|
9939
|
+
if (!fs.existsSync(markerPath)) return null;
|
|
9940
9940
|
let raw;
|
|
9941
9941
|
try {
|
|
9942
|
-
raw = fs
|
|
9942
|
+
raw = fs.readFileSync(markerPath, "utf-8");
|
|
9943
9943
|
} catch (err) {
|
|
9944
9944
|
console.error("[restart-coordinator] Marker unreadable — leaving in place:", err);
|
|
9945
9945
|
return null;
|
|
@@ -9978,7 +9978,7 @@ function readPendingRestart(dataDir) {
|
|
|
9978
9978
|
/** Remove the marker if present. No-op if missing. */
|
|
9979
9979
|
function clearPendingRestart(dataDir) {
|
|
9980
9980
|
const markerPath = getRestartMarkerPath(dataDir);
|
|
9981
|
-
fs
|
|
9981
|
+
fs.rmSync(markerPath, { force: true });
|
|
9982
9982
|
}
|
|
9983
9983
|
function isRestartKind(value) {
|
|
9984
9984
|
return value === "framework-update" || value === "manual" || value === "system";
|
|
@@ -9990,7 +9990,7 @@ function scheduleSelfRestart(options = {}) {
|
|
|
9990
9990
|
const touchTarget = process.env["CAMSTACK_RESTART_TOUCH_FILE"];
|
|
9991
9991
|
if (touchTarget !== void 0 && touchTarget.length > 0) try {
|
|
9992
9992
|
const now = /* @__PURE__ */ new Date();
|
|
9993
|
-
fs
|
|
9993
|
+
fs.utimesSync(touchTarget, now, now);
|
|
9994
9994
|
return;
|
|
9995
9995
|
} catch (err) {
|
|
9996
9996
|
console.error("[restart-coordinator] dev touch-reload failed; falling through to process exit:", err);
|
|
@@ -14383,7 +14383,7 @@ function legacyConfigYamlCandidates(env) {
|
|
|
14383
14383
|
];
|
|
14384
14384
|
}
|
|
14385
14385
|
function findLegacyFile(env) {
|
|
14386
|
-
return legacyConfigYamlCandidates(env).find((candidate) => fs
|
|
14386
|
+
return legacyConfigYamlCandidates(env).find((candidate) => fs.existsSync(candidate));
|
|
14387
14387
|
}
|
|
14388
14388
|
/** The legacy value of a key when it is well-formed, else undefined. */
|
|
14389
14389
|
function legacyValue(server, key) {
|
|
@@ -14419,7 +14419,7 @@ function reconcileLegacyConfigYaml(env, effective) {
|
|
|
14419
14419
|
if (file === void 0) return NOTHING_TO_APPLY;
|
|
14420
14420
|
let raw;
|
|
14421
14421
|
try {
|
|
14422
|
-
raw = asJsonObject(load(fs
|
|
14422
|
+
raw = asJsonObject(load(fs.readFileSync(file, "utf-8"))) ?? {};
|
|
14423
14423
|
} catch (err) {
|
|
14424
14424
|
return {
|
|
14425
14425
|
overrides: {},
|
|
@@ -16938,18 +16938,22 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
16938
16938
|
create: async (stableId, DeviceClass, config, parentDeviceId = null, initialMeta = void 0) => {
|
|
16939
16939
|
const id = await deviceApi.allocateDeviceId(stableId);
|
|
16940
16940
|
if (initialMeta) {
|
|
16941
|
-
if (initialMeta.name !== void 0)
|
|
16942
|
-
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
|
|
16946
|
-
|
|
16947
|
-
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16941
|
+
if (initialMeta.name !== void 0) {
|
|
16942
|
+
const systemName = stableId.startsWith(COMPOSED_DEVICE_STABLE_ID_PREFIX);
|
|
16943
|
+
await callDeviceManager(api, "setName", {
|
|
16944
|
+
deviceId: id,
|
|
16945
|
+
name: initialMeta.name,
|
|
16946
|
+
...systemName ? { stampUserNamed: false } : {}
|
|
16947
|
+
}).catch((err) => {
|
|
16948
|
+
opts.logger.warn("create: setName pre-seed failed", {
|
|
16949
|
+
tags: {
|
|
16950
|
+
stableId,
|
|
16951
|
+
deviceId: id
|
|
16952
|
+
},
|
|
16953
|
+
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
16954
|
+
});
|
|
16951
16955
|
});
|
|
16952
|
-
}
|
|
16956
|
+
}
|
|
16953
16957
|
if (initialMeta.location !== void 0) await callDeviceManager(api, "setLocation", {
|
|
16954
16958
|
deviceId: id,
|
|
16955
16959
|
location: initialMeta.location
|
|
@@ -17067,10 +17071,11 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
17067
17071
|
});
|
|
17068
17072
|
return id;
|
|
17069
17073
|
},
|
|
17070
|
-
setName: async (deviceId, name) => {
|
|
17074
|
+
setName: async (deviceId, name, write) => {
|
|
17071
17075
|
await callDeviceManager(api, "setName", {
|
|
17072
17076
|
deviceId,
|
|
17073
|
-
name
|
|
17077
|
+
name,
|
|
17078
|
+
...write?.stampUserNamed === false ? { stampUserNamed: false } : {}
|
|
17074
17079
|
});
|
|
17075
17080
|
},
|
|
17076
17081
|
setLocation: async (deviceId, location) => {
|
|
@@ -22840,7 +22845,7 @@ async function probeVaapiInit(renderNode) {
|
|
|
22840
22845
|
*/
|
|
22841
22846
|
function safeExistsSync(path) {
|
|
22842
22847
|
try {
|
|
22843
|
-
return fs
|
|
22848
|
+
return fs.existsSync(path);
|
|
22844
22849
|
} catch {
|
|
22845
22850
|
return false;
|
|
22846
22851
|
}
|
|
@@ -22859,11 +22864,11 @@ function probeLinuxGpus() {
|
|
|
22859
22864
|
if (safeExistsSync("/dev/nvidia0") || safeExistsSync("/proc/driver/nvidia/version")) signals.hasNvidiaGpu = true;
|
|
22860
22865
|
try {
|
|
22861
22866
|
const drmDir = "/sys/class/drm";
|
|
22862
|
-
if (fs
|
|
22867
|
+
if (fs.existsSync(drmDir)) for (const entry of fs.readdirSync(drmDir)) {
|
|
22863
22868
|
if (!entry.startsWith("card")) continue;
|
|
22864
22869
|
const vendorPath = `${drmDir}/${entry}/device/vendor`;
|
|
22865
22870
|
if (!safeExistsSync(vendorPath)) continue;
|
|
22866
|
-
const vendor = fs
|
|
22871
|
+
const vendor = fs.readFileSync(vendorPath, "utf8").trim().toLowerCase();
|
|
22867
22872
|
if (vendor === "0x10de") signals.hasNvidiaGpu = true;
|
|
22868
22873
|
else if (vendor === "0x1002") signals.hasAmdGpu = true;
|
|
22869
22874
|
else if (vendor === "0x8086") signals.hasIntelGpu = true;
|
|
@@ -23081,21 +23086,21 @@ function sleep$1(ms) {
|
|
|
23081
23086
|
* crashed holder) is stolen.
|
|
23082
23087
|
*/
|
|
23083
23088
|
async function withFileLock(lockPath, fn) {
|
|
23084
|
-
fs
|
|
23089
|
+
fs.mkdirSync(join(lockPath, ".."), { recursive: true });
|
|
23085
23090
|
for (;;) try {
|
|
23086
|
-
const fd = fs
|
|
23087
|
-
fs
|
|
23091
|
+
const fd = fs.openSync(lockPath, "wx");
|
|
23092
|
+
fs.closeSync(fd);
|
|
23088
23093
|
break;
|
|
23089
23094
|
} catch {
|
|
23090
23095
|
try {
|
|
23091
|
-
if (Date.now() - fs
|
|
23096
|
+
if (Date.now() - fs.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs.rmSync(lockPath, { force: true });
|
|
23092
23097
|
else await sleep$1(LOCK_POLL_MS);
|
|
23093
23098
|
} catch {}
|
|
23094
23099
|
}
|
|
23095
23100
|
try {
|
|
23096
23101
|
return await fn();
|
|
23097
23102
|
} finally {
|
|
23098
|
-
fs
|
|
23103
|
+
fs.rmSync(lockPath, { force: true });
|
|
23099
23104
|
}
|
|
23100
23105
|
}
|
|
23101
23106
|
/** Coalesce in-process + serialize cross-process for one binary id. */
|
|
@@ -23153,7 +23158,7 @@ var AddonDepsManager = class {
|
|
|
23153
23158
|
* failed or tampered download throws, and provisioning reports it.
|
|
23154
23159
|
*/
|
|
23155
23160
|
async stageNativeDepsDeclaredBy(requirementsFile) {
|
|
23156
|
-
if (!declaresEdgetpuDelegate(fs
|
|
23161
|
+
if (!declaresEdgetpuDelegate(fs.readFileSync(requirementsFile, "utf8"))) return;
|
|
23157
23162
|
await singleFlight(this.depsDir, "edgetpu-delegate", () => ensureEdgetpuDelegate(this.nodeRoot, this.logger));
|
|
23158
23163
|
}
|
|
23159
23164
|
getDepsDir() {
|
|
@@ -24184,7 +24189,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
24184
24189
|
const addonId = declaration.id;
|
|
24185
24190
|
const nodeDataDir = process.env["CAMSTACK_DATA"] ?? dataDir;
|
|
24186
24191
|
const addonDataDir = path$1.resolve(nodeDataDir, "addons-data", addonId);
|
|
24187
|
-
fs
|
|
24192
|
+
fs.mkdirSync(addonDataDir, { recursive: true });
|
|
24188
24193
|
if (runtime.mode === "broker") ensureBindingSubscription(runtime.broker);
|
|
24189
24194
|
const regs = getRegistries(nodeId);
|
|
24190
24195
|
const workerResolver = {
|
|
@@ -26134,7 +26139,7 @@ var FailedRunnerRetryLedger = class {
|
|
|
26134
26139
|
function readRunnerPackageVersions(addonDirs) {
|
|
26135
26140
|
const out = {};
|
|
26136
26141
|
for (const dir of addonDirs) try {
|
|
26137
|
-
const raw = JSON.parse(fs
|
|
26142
|
+
const raw = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
|
|
26138
26143
|
const version = typeof raw === "object" && raw !== null ? Reflect.get(raw, "version") : null;
|
|
26139
26144
|
out[dir] = typeof version === "string" && version.length > 0 ? version : null;
|
|
26140
26145
|
} catch {
|
|
@@ -26195,7 +26200,7 @@ function readAddonHeapDeclaration(spec) {
|
|
|
26195
26200
|
if (cached !== void 0) return cached;
|
|
26196
26201
|
let declaration = EMPTY_HEAP_DECLARATION;
|
|
26197
26202
|
for (const manifestPath of [path$1.join(spec.addonDir, "package.json"), path$1.join(path$1.dirname(spec.addonDir), "package.json")]) try {
|
|
26198
|
-
const raw = fs
|
|
26203
|
+
const raw = fs.readFileSync(manifestPath, "utf8");
|
|
26199
26204
|
const parsed = JSON.parse(raw);
|
|
26200
26205
|
const profile = extractHeapProfile(parsed, spec.addonId);
|
|
26201
26206
|
const maxOldSpaceMb = extractMaxOldSpaceMb(parsed, spec.addonId);
|
|
@@ -27428,17 +27433,17 @@ var JobJournal = class {
|
|
|
27428
27433
|
return path$1.join(this.jobsDir, `${id}.json`);
|
|
27429
27434
|
}
|
|
27430
27435
|
writeAtomic(filePath, data) {
|
|
27431
|
-
fs
|
|
27436
|
+
fs.mkdirSync(path$1.dirname(filePath), { recursive: true });
|
|
27432
27437
|
const tmp = `${filePath}.tmp.${process.pid}.${Date.now()}`;
|
|
27433
|
-
fs
|
|
27438
|
+
fs.writeFileSync(tmp, JSON.stringify(data, null, 2), {
|
|
27434
27439
|
encoding: "utf-8",
|
|
27435
27440
|
mode: 384
|
|
27436
27441
|
});
|
|
27437
|
-
fs
|
|
27442
|
+
fs.renameSync(tmp, filePath);
|
|
27438
27443
|
}
|
|
27439
27444
|
readIndex() {
|
|
27440
27445
|
try {
|
|
27441
|
-
const raw = JSON.parse(fs
|
|
27446
|
+
const raw = JSON.parse(fs.readFileSync(this.indexPath, "utf-8"));
|
|
27442
27447
|
if (raw && Array.isArray(raw.jobIds)) return {
|
|
27443
27448
|
version: 1,
|
|
27444
27449
|
jobIds: raw.jobIds
|
|
@@ -27463,7 +27468,7 @@ var JobJournal = class {
|
|
|
27463
27468
|
}
|
|
27464
27469
|
getJob(id) {
|
|
27465
27470
|
try {
|
|
27466
|
-
const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs
|
|
27471
|
+
const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs.readFileSync(this.jobPath(id), "utf-8")));
|
|
27467
27472
|
return parsed.success ? parsed.data : null;
|
|
27468
27473
|
} catch {
|
|
27469
27474
|
return null;
|
|
@@ -27528,14 +27533,14 @@ var StagingArea = class {
|
|
|
27528
27533
|
}
|
|
27529
27534
|
async fetchAndStage(input) {
|
|
27530
27535
|
const destDir = path$1.join(this.stagingDir, input.jobId, safeSegment(input.name));
|
|
27531
|
-
fs
|
|
27536
|
+
fs.rmSync(destDir, {
|
|
27532
27537
|
recursive: true,
|
|
27533
27538
|
force: true
|
|
27534
27539
|
});
|
|
27535
27540
|
const tgz = await this.deps.fetchTarball(input.name, input.version, input.signal);
|
|
27536
27541
|
if (input.signal.aborted) throw new Error("staging aborted after fetch");
|
|
27537
27542
|
await this.deps.extract(tgz, destDir);
|
|
27538
|
-
const raw = JSON.parse(fs
|
|
27543
|
+
const raw = JSON.parse(fs.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
|
|
27539
27544
|
if (typeof raw.version !== "string" || raw.version.length === 0) throw new Error(`staging validation failed: ${input.name} staged a package.json with no version`);
|
|
27540
27545
|
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}`);
|
|
27541
27546
|
return {
|
|
@@ -27544,7 +27549,7 @@ var StagingArea = class {
|
|
|
27544
27549
|
};
|
|
27545
27550
|
}
|
|
27546
27551
|
cleanup(jobId) {
|
|
27547
|
-
fs
|
|
27552
|
+
fs.rmSync(path$1.join(this.stagingDir, jobId), {
|
|
27548
27553
|
recursive: true,
|
|
27549
27554
|
force: true
|
|
27550
27555
|
});
|
|
@@ -27559,13 +27564,13 @@ var StagingArea = class {
|
|
|
27559
27564
|
sweepOrphans() {
|
|
27560
27565
|
let entries;
|
|
27561
27566
|
try {
|
|
27562
|
-
entries = fs
|
|
27567
|
+
entries = fs.readdirSync(this.stagingDir);
|
|
27563
27568
|
} catch {
|
|
27564
27569
|
return 0;
|
|
27565
27570
|
}
|
|
27566
27571
|
let removed = 0;
|
|
27567
27572
|
for (const name of entries) try {
|
|
27568
|
-
fs
|
|
27573
|
+
fs.rmSync(path$1.join(this.stagingDir, name), {
|
|
27569
27574
|
recursive: true,
|
|
27570
27575
|
force: true
|
|
27571
27576
|
});
|
|
@@ -27743,7 +27748,7 @@ var LifecycleJobEngine = class {
|
|
|
27743
27748
|
* on failure → `failed`.
|
|
27744
27749
|
*/
|
|
27745
27750
|
async reconcileJob(job) {
|
|
27746
|
-
const exists = this.deps.stagedPathExists ?? ((p) => fs
|
|
27751
|
+
const exists = this.deps.stagedPathExists ?? ((p) => fs.existsSync(p));
|
|
27747
27752
|
for (const task of job.tasks) {
|
|
27748
27753
|
if (task.target === "framework") {
|
|
27749
27754
|
if (!this.isTerminal(task.phase)) this.skipFrameworkTask(job, task);
|
|
@@ -28378,7 +28383,7 @@ var CatalogRegistry = class {
|
|
|
28378
28383
|
const file = path$1.join(packageDir, "i18n", `${lang}.json`);
|
|
28379
28384
|
let text;
|
|
28380
28385
|
try {
|
|
28381
|
-
text = fs
|
|
28386
|
+
text = fs.readFileSync(file, "utf8");
|
|
28382
28387
|
} catch {
|
|
28383
28388
|
continue;
|
|
28384
28389
|
}
|