@gadicc/loom 1.38.0 → 2.0.0
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/.loom-source-manifest.json +97 -0
- package/README.md +103 -31
- package/db/databaseTls.js +6 -3
- package/db/databaseUrl.js +3 -2
- package/db/drizzle-config.js +14 -16
- package/db/fixtures.d.ts +1 -3
- package/db/fixtures.js +4 -7
- package/esm/bin/loom.d.ts +2 -1
- package/esm/bin/loom.d.ts.map +1 -1
- package/esm/bin/loom.js +37 -10
- package/esm/bin/loom.js.map +1 -0
- package/esm/mod.d.ts +0 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/esm/mod.js.map +1 -0
- package/esm/src/apiKeys/authorize.d.ts.map +1 -1
- package/esm/src/apiKeys/authorize.js +15 -14
- package/esm/src/apiKeys/authorize.js.map +1 -0
- package/esm/src/apiKeys/betterAuth.d.ts.map +1 -1
- package/esm/src/apiKeys/betterAuth.js +1 -0
- package/esm/src/apiKeys/betterAuth.js.map +1 -0
- package/esm/src/apiKeys/country.d.ts.map +1 -1
- package/esm/src/apiKeys/country.js +1 -0
- package/esm/src/apiKeys/country.js.map +1 -0
- package/esm/src/apiKeys/credentials.d.ts.map +1 -1
- package/esm/src/apiKeys/credentials.js +3 -1
- package/esm/src/apiKeys/credentials.js.map +1 -0
- package/esm/src/apiKeys/fingerprint.d.ts.map +1 -1
- package/esm/src/apiKeys/fingerprint.js +1 -0
- package/esm/src/apiKeys/fingerprint.js.map +1 -0
- package/esm/src/apiKeys/lifecycle.d.ts.map +1 -1
- package/esm/src/apiKeys/lifecycle.js +1 -0
- package/esm/src/apiKeys/lifecycle.js.map +1 -0
- package/esm/src/apiKeys/limits.d.ts.map +1 -1
- package/esm/src/apiKeys/limits.js +10 -10
- package/esm/src/apiKeys/limits.js.map +1 -0
- package/esm/src/apiKeys/mod.d.ts +0 -1
- package/esm/src/apiKeys/mod.d.ts.map +1 -1
- package/esm/src/apiKeys/mod.js +1 -1
- package/esm/src/apiKeys/mod.js.map +1 -0
- package/esm/src/apiKeys/permissions.d.ts.map +1 -1
- package/esm/src/apiKeys/permissions.js +1 -0
- package/esm/src/apiKeys/permissions.js.map +1 -0
- package/esm/src/apiKeys/policy.d.ts.map +1 -1
- package/esm/src/apiKeys/policy.js +1 -0
- package/esm/src/apiKeys/policy.js.map +1 -0
- package/esm/src/apiKeys/retention.d.ts.map +1 -1
- package/esm/src/apiKeys/retention.js +1 -0
- package/esm/src/apiKeys/retention.js.map +1 -0
- package/esm/src/apiKeys/types.d.ts.map +1 -1
- package/esm/src/apiKeys/types.js +1 -0
- package/esm/src/apiKeys/types.js.map +1 -0
- package/esm/src/cli/atomicText.d.ts +3 -0
- package/esm/src/cli/atomicText.d.ts.map +1 -0
- package/esm/src/cli/atomicText.js +33 -0
- package/esm/src/cli/atomicText.js.map +1 -0
- package/esm/src/cli/bunLocalDev.d.ts +65 -0
- package/esm/src/cli/bunLocalDev.d.ts.map +1 -0
- package/esm/src/cli/bunLocalDev.js +459 -0
- package/esm/src/cli/bunLocalDev.js.map +1 -0
- package/esm/src/cli/bunProject.d.ts +30 -0
- package/esm/src/cli/bunProject.d.ts.map +1 -0
- package/esm/src/cli/bunProject.js +309 -0
- package/esm/src/cli/bunProject.js.map +1 -0
- package/esm/src/cli/cliBootstrap.d.ts +83 -0
- package/esm/src/cli/cliBootstrap.d.ts.map +1 -0
- package/esm/src/cli/cliBootstrap.js +186 -0
- package/esm/src/cli/cliBootstrap.js.map +1 -0
- package/esm/src/cli/externalSkills.d.ts.map +1 -1
- package/esm/src/cli/externalSkills.js +9 -5
- package/esm/src/cli/externalSkills.js.map +1 -0
- package/esm/src/cli/filesR2Policy.d.ts.map +1 -1
- package/esm/src/cli/filesR2Policy.js +18 -11
- package/esm/src/cli/filesR2Policy.js.map +1 -0
- package/esm/src/cli/generatedBuild.d.ts +42 -0
- package/esm/src/cli/generatedBuild.d.ts.map +1 -0
- package/esm/src/cli/generatedBuild.js +259 -0
- package/esm/src/cli/generatedBuild.js.map +1 -0
- package/esm/src/cli/generatedCleanup.d.ts +7 -0
- package/esm/src/cli/generatedCleanup.d.ts.map +1 -0
- package/esm/src/cli/generatedCleanup.js +67 -0
- package/esm/src/cli/generatedCleanup.js.map +1 -0
- package/esm/src/cli/generatedDevLease.d.ts +8 -0
- package/esm/src/cli/generatedDevLease.d.ts.map +1 -0
- package/esm/src/cli/generatedDevLease.js +39 -0
- package/esm/src/cli/generatedDevLease.js.map +1 -0
- package/esm/src/cli/generatedInstall.d.ts +64 -0
- package/esm/src/cli/generatedInstall.d.ts.map +1 -0
- package/esm/src/cli/generatedInstall.js +466 -0
- package/esm/src/cli/generatedInstall.js.map +1 -0
- package/esm/src/cli/generatedWorkflow.d.ts +34 -0
- package/esm/src/cli/generatedWorkflow.d.ts.map +1 -0
- package/esm/src/cli/generatedWorkflow.js +85 -0
- package/esm/src/cli/generatedWorkflow.js.map +1 -0
- package/esm/src/cli/legacyManagedOutputs.d.ts.map +1 -1
- package/esm/src/cli/legacyManagedOutputs.js +1 -0
- package/esm/src/cli/legacyManagedOutputs.js.map +1 -0
- package/esm/src/cli/localDb.d.ts.map +1 -1
- package/esm/src/cli/localDb.js +33 -28
- package/esm/src/cli/localDb.js.map +1 -0
- package/esm/src/cli/localDevLock.d.ts +9 -0
- package/esm/src/cli/localDevLock.d.ts.map +1 -1
- package/esm/src/cli/localDevLock.js +54 -13
- package/esm/src/cli/localDevLock.js.map +1 -0
- package/esm/src/cli/localDevPackage.d.ts +6 -11
- package/esm/src/cli/localDevPackage.d.ts.map +1 -1
- package/esm/src/cli/localDevPackage.js +51 -48
- package/esm/src/cli/localDevPackage.js.map +1 -0
- package/esm/src/cli/managedFiles.d.ts.map +1 -1
- package/esm/src/cli/managedFiles.js +34 -18
- package/esm/src/cli/managedFiles.js.map +1 -0
- package/esm/src/cli/migrationEnv.d.ts +16 -3
- package/esm/src/cli/migrationEnv.d.ts.map +1 -1
- package/esm/src/cli/migrationEnv.js +7 -4
- package/esm/src/cli/migrationEnv.js.map +1 -0
- package/esm/src/cli/mod.d.ts +19 -7
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +2000 -742
- package/esm/src/cli/mod.js.map +1 -0
- package/esm/src/cli/packageTreeSignature.d.ts +8 -0
- package/esm/src/cli/packageTreeSignature.d.ts.map +1 -0
- package/esm/src/cli/packageTreeSignature.js +60 -0
- package/esm/src/cli/packageTreeSignature.js.map +1 -0
- package/esm/src/cli/processIdentity.d.ts +7 -0
- package/esm/src/cli/processIdentity.d.ts.map +1 -0
- package/esm/src/cli/processIdentity.js +39 -0
- package/esm/src/cli/processIdentity.js.map +1 -0
- package/esm/src/cli/projectSkills.d.ts +1 -1
- package/esm/src/cli/projectSkills.d.ts.map +1 -1
- package/esm/src/cli/projectSkills.js +31 -23
- package/esm/src/cli/projectSkills.js.map +1 -0
- package/esm/src/cli/projectTooling.d.ts +6 -3
- package/esm/src/cli/projectTooling.d.ts.map +1 -1
- package/esm/src/cli/projectTooling.js +86 -41
- package/esm/src/cli/projectTooling.js.map +1 -0
- package/esm/src/cli/releaseConfig.d.ts.map +1 -1
- package/esm/src/cli/releaseConfig.js +5 -3
- package/esm/src/cli/releaseConfig.js.map +1 -0
- package/esm/src/cli/releaseCredentials.d.ts.map +1 -1
- package/esm/src/cli/releaseCredentials.js +19 -31
- package/esm/src/cli/releaseCredentials.js.map +1 -0
- package/esm/src/cli/releaseTrust.d.ts.map +1 -1
- package/esm/src/cli/releaseTrust.js +11 -4
- package/esm/src/cli/releaseTrust.js.map +1 -0
- package/esm/src/cli/releaseTrustCommand.d.ts.map +1 -1
- package/esm/src/cli/releaseTrustCommand.js +6 -4
- package/esm/src/cli/releaseTrustCommand.js.map +1 -0
- package/esm/src/cli/sourceConfig.d.ts +3 -0
- package/esm/src/cli/sourceConfig.d.ts.map +1 -0
- package/esm/src/cli/sourceConfig.js +91 -0
- package/esm/src/cli/sourceConfig.js.map +1 -0
- package/esm/src/cli/sourceDev.d.ts +77 -0
- package/esm/src/cli/sourceDev.d.ts.map +1 -0
- package/esm/src/cli/sourceDev.js +974 -0
- package/esm/src/cli/sourceDev.js.map +1 -0
- package/esm/src/cli/vercelBuildEnv.d.ts.map +1 -1
- package/esm/src/cli/vercelBuildEnv.js +21 -15
- package/esm/src/cli/vercelBuildEnv.js.map +1 -0
- package/esm/src/cli/vercelEnvMask.d.ts +2 -2
- package/esm/src/cli/vercelEnvMask.d.ts.map +1 -1
- package/esm/src/cli/vercelEnvMask.js +8 -4
- package/esm/src/cli/vercelEnvMask.js.map +1 -0
- package/esm/src/cli/vercelProjectRelease.d.ts.map +1 -1
- package/esm/src/cli/vercelProjectRelease.js +45 -22
- package/esm/src/cli/vercelProjectRelease.js.map +1 -0
- package/esm/src/cli/vercelPulledEnv.d.ts +1 -1
- package/esm/src/cli/vercelPulledEnv.d.ts.map +1 -1
- package/esm/src/cli/vercelPulledEnv.js +1 -0
- package/esm/src/cli/vercelPulledEnv.js.map +1 -0
- package/esm/src/clientData/identity.d.ts.map +1 -1
- package/esm/src/clientData/identity.js +1 -0
- package/esm/src/clientData/identity.js.map +1 -0
- package/esm/src/clientData/mod.d.ts +0 -1
- package/esm/src/clientData/mod.d.ts.map +1 -1
- package/esm/src/clientData/mod.js +1 -0
- package/esm/src/clientData/mod.js.map +1 -0
- package/esm/src/files/client.d.ts +1 -1
- package/esm/src/files/client.d.ts.map +1 -1
- package/esm/src/files/client.js +3 -4
- package/esm/src/files/client.js.map +1 -0
- package/esm/src/files/errors.d.ts.map +1 -1
- package/esm/src/files/errors.js +3 -12
- package/esm/src/files/errors.js.map +1 -0
- package/esm/src/files/hash.d.ts +1 -1
- package/esm/src/files/hash.d.ts.map +1 -1
- package/esm/src/files/hash.js +1 -0
- package/esm/src/files/hash.js.map +1 -0
- package/esm/src/files/memory.d.ts.map +1 -1
- package/esm/src/files/memory.js +2 -1
- package/esm/src/files/memory.js.map +1 -0
- package/esm/src/files/metadata.d.ts.map +1 -1
- package/esm/src/files/metadata.js +11 -18
- package/esm/src/files/metadata.js.map +1 -0
- package/esm/src/files/mod.d.ts +0 -1
- package/esm/src/files/mod.d.ts.map +1 -1
- package/esm/src/files/mod.js +1 -1
- package/esm/src/files/mod.js.map +1 -0
- package/esm/src/files/s3.d.ts.map +1 -1
- package/esm/src/files/s3.js +6 -4
- package/esm/src/files/s3.js.map +1 -0
- package/esm/src/files/service.d.ts.map +1 -1
- package/esm/src/files/service.js +3 -4
- package/esm/src/files/service.js.map +1 -0
- package/esm/src/files/types.d.ts.map +1 -1
- package/esm/src/files/types.js +1 -0
- package/esm/src/files/types.js.map +1 -0
- package/esm/src/jobs/catalog.d.ts.map +1 -1
- package/esm/src/jobs/catalog.js +5 -1
- package/esm/src/jobs/catalog.js.map +1 -0
- package/esm/src/jobs/controller.d.ts +1 -1
- package/esm/src/jobs/controller.d.ts.map +1 -1
- package/esm/src/jobs/controller.js +11 -55
- package/esm/src/jobs/controller.js.map +1 -0
- package/esm/src/jobs/direct.d.ts.map +1 -1
- package/esm/src/jobs/direct.js +3 -3
- package/esm/src/jobs/direct.js.map +1 -0
- package/esm/src/jobs/events.d.ts.map +1 -1
- package/esm/src/jobs/events.js +1 -0
- package/esm/src/jobs/events.js.map +1 -0
- package/esm/src/jobs/format.d.ts +5 -5
- package/esm/src/jobs/format.d.ts.map +1 -1
- package/esm/src/jobs/format.js +2 -1
- package/esm/src/jobs/format.js.map +1 -0
- package/esm/src/jobs/http.d.ts +3 -3
- package/esm/src/jobs/http.d.ts.map +1 -1
- package/esm/src/jobs/http.js +1 -0
- package/esm/src/jobs/http.js.map +1 -0
- package/esm/src/jobs/log.d.ts.map +1 -1
- package/esm/src/jobs/log.js +1 -0
- package/esm/src/jobs/log.js.map +1 -0
- package/esm/src/jobs/mod.d.ts.map +1 -1
- package/esm/src/jobs/mod.js +1 -0
- package/esm/src/jobs/mod.js.map +1 -0
- package/esm/src/jobs/run.d.ts.map +1 -1
- package/esm/src/jobs/run.js +1 -0
- package/esm/src/jobs/run.js.map +1 -0
- package/esm/src/jobs/sanitize.d.ts.map +1 -1
- package/esm/src/jobs/sanitize.js +1 -0
- package/esm/src/jobs/sanitize.js.map +1 -0
- package/esm/src/jobs/types.d.ts +1 -0
- package/esm/src/jobs/types.d.ts.map +1 -1
- package/esm/src/jobs/types.js +1 -0
- package/esm/src/jobs/types.js.map +1 -0
- package/esm/src/mail/errors.d.ts.map +1 -1
- package/esm/src/mail/errors.js +8 -42
- package/esm/src/mail/errors.js.map +1 -0
- package/esm/src/mail/memory.d.ts +1 -1
- package/esm/src/mail/memory.d.ts.map +1 -1
- package/esm/src/mail/memory.js +10 -14
- package/esm/src/mail/memory.js.map +1 -0
- package/esm/src/mail/mod.d.ts +0 -1
- package/esm/src/mail/mod.d.ts.map +1 -1
- package/esm/src/mail/mod.js +1 -1
- package/esm/src/mail/mod.js.map +1 -0
- package/esm/src/mail/postal.d.ts +1 -2
- package/esm/src/mail/postal.d.ts.map +1 -1
- package/esm/src/mail/postal.js +22 -18
- package/esm/src/mail/postal.js.map +1 -0
- package/esm/src/mail/retry.d.ts.map +1 -1
- package/esm/src/mail/retry.js +1 -0
- package/esm/src/mail/retry.js.map +1 -0
- package/esm/src/mail/sender.d.ts.map +1 -1
- package/esm/src/mail/sender.js +1 -0
- package/esm/src/mail/sender.js.map +1 -0
- package/esm/src/mail/service.d.ts.map +1 -1
- package/esm/src/mail/service.js +6 -7
- package/esm/src/mail/service.js.map +1 -0
- package/esm/src/mail/types.d.ts.map +1 -1
- package/esm/src/mail/types.js +1 -0
- package/esm/src/mail/types.js.map +1 -0
- package/esm/src/mui/apiKeys.d.ts +10 -11
- package/esm/src/mui/apiKeys.d.ts.map +1 -1
- package/esm/src/mui/apiKeys.js +83 -214
- package/esm/src/mui/apiKeys.js.map +1 -0
- package/esm/src/mui/apiKeysView.d.ts +1 -1
- package/esm/src/mui/apiKeysView.d.ts.map +1 -1
- package/esm/src/mui/apiKeysView.js +11 -9
- package/esm/src/mui/apiKeysView.js.map +1 -0
- package/esm/src/mui/confirm.d.ts +2 -2
- package/esm/src/mui/confirm.d.ts.map +1 -1
- package/esm/src/mui/confirm.js +3 -7
- package/esm/src/mui/confirm.js.map +1 -0
- package/esm/src/mui/mail.d.ts +4 -4
- package/esm/src/mui/mail.d.ts.map +1 -1
- package/esm/src/mui/mail.js +11 -71
- package/esm/src/mui/mail.js.map +1 -0
- package/esm/src/mui/mailView.d.ts +1 -1
- package/esm/src/mui/mailView.d.ts.map +1 -1
- package/esm/src/mui/mailView.js +1 -0
- package/esm/src/mui/mailView.js.map +1 -0
- package/esm/src/mui/mod.d.ts +0 -1
- package/esm/src/mui/mod.d.ts.map +1 -1
- package/esm/src/mui/mod.js +1 -0
- package/esm/src/mui/mod.js.map +1 -0
- package/esm/src/next/apiKeys/mod.d.ts +2 -3
- package/esm/src/next/apiKeys/mod.d.ts.map +1 -1
- package/esm/src/next/apiKeys/mod.js +6 -5
- package/esm/src/next/apiKeys/mod.js.map +1 -0
- package/esm/src/next/auth/client.d.ts +0 -1
- package/esm/src/next/auth/client.d.ts.map +1 -1
- package/esm/src/next/auth/client.js +1 -0
- package/esm/src/next/auth/client.js.map +1 -0
- package/esm/src/next/auth/config.d.ts.map +1 -1
- package/esm/src/next/auth/config.js +11 -17
- package/esm/src/next/auth/config.js.map +1 -0
- package/esm/src/next/auth/localTestLogin.d.ts.map +1 -1
- package/esm/src/next/auth/localTestLogin.js +13 -9
- package/esm/src/next/auth/localTestLogin.js.map +1 -0
- package/esm/src/next/auth/mod.d.ts.map +1 -1
- package/esm/src/next/auth/mod.js +1 -0
- package/esm/src/next/auth/mod.js.map +1 -0
- package/esm/src/next/auth/server.d.ts +2 -2
- package/esm/src/next/auth/server.d.ts.map +1 -1
- package/esm/src/next/auth/server.js +1 -0
- package/esm/src/next/auth/server.js.map +1 -0
- package/esm/src/next/files/mod.d.ts +0 -1
- package/esm/src/next/files/mod.d.ts.map +1 -1
- package/esm/src/next/files/mod.js +1 -1
- package/esm/src/next/files/mod.js.map +1 -0
- package/esm/src/next/files/route.d.ts +1 -1
- package/esm/src/next/files/route.d.ts.map +1 -1
- package/esm/src/next/files/route.js +11 -11
- package/esm/src/next/files/route.js.map +1 -0
- package/esm/src/next/jobs/list.d.ts +5 -5
- package/esm/src/next/jobs/list.d.ts.map +1 -1
- package/esm/src/next/jobs/list.js +15 -19
- package/esm/src/next/jobs/list.js.map +1 -0
- package/esm/src/next/jobs/mod.d.ts.map +1 -1
- package/esm/src/next/jobs/mod.js +1 -0
- package/esm/src/next/jobs/mod.js.map +1 -0
- package/esm/src/next/jobs/paths.d.ts +2 -2
- package/esm/src/next/jobs/paths.d.ts.map +1 -1
- package/esm/src/next/jobs/paths.js +1 -0
- package/esm/src/next/jobs/paths.js.map +1 -0
- package/esm/src/next/jobs/route.d.ts +2 -2
- package/esm/src/next/jobs/route.d.ts.map +1 -1
- package/esm/src/next/jobs/route.js +4 -4
- package/esm/src/next/jobs/route.js.map +1 -0
- package/esm/src/next/jobs/run.d.ts +2 -2
- package/esm/src/next/jobs/run.d.ts.map +1 -1
- package/esm/src/next/jobs/run.js +68 -132
- package/esm/src/next/jobs/run.js.map +1 -0
- package/esm/src/next/jobs/runRequest.d.ts +1 -1
- package/esm/src/next/jobs/runRequest.d.ts.map +1 -1
- package/esm/src/next/jobs/runRequest.js +3 -4
- package/esm/src/next/jobs/runRequest.js.map +1 -0
- package/esm/src/next/jobs/stream.d.ts.map +1 -1
- package/esm/src/next/jobs/stream.js +1 -0
- package/esm/src/next/jobs/stream.js.map +1 -0
- package/esm/src/next/mail/mod.d.ts +0 -1
- package/esm/src/next/mail/mod.d.ts.map +1 -1
- package/esm/src/next/mail/mod.js +1 -1
- package/esm/src/next/mail/mod.js.map +1 -0
- package/esm/src/next/mail/route.d.ts +2 -2
- package/esm/src/next/mail/route.d.ts.map +1 -1
- package/esm/src/next/mail/route.js +1 -0
- package/esm/src/next/mail/route.js.map +1 -0
- package/esm/src/next/pwa/mod.d.ts +0 -4
- package/esm/src/next/pwa/mod.d.ts.map +1 -1
- package/esm/src/next/pwa/mod.js +32 -16
- package/esm/src/next/pwa/mod.js.map +1 -0
- package/esm/src/next/pwa/worker.d.ts +0 -1
- package/esm/src/next/pwa/worker.d.ts.map +1 -1
- package/esm/src/next/pwa/worker.js +1 -0
- package/esm/src/next/pwa/worker.js.map +1 -0
- package/esm/src/next/secrets/constants.d.ts +3 -0
- package/esm/src/next/secrets/constants.d.ts.map +1 -0
- package/esm/src/next/secrets/constants.js +3 -0
- package/esm/src/next/secrets/constants.js.map +1 -0
- package/esm/src/next/secrets/mod.d.ts +1 -3
- package/esm/src/next/secrets/mod.d.ts.map +1 -1
- package/esm/src/next/secrets/mod.js +6 -7
- package/esm/src/next/secrets/mod.js.map +1 -0
- package/esm/src/next/sourceDev.d.ts +6 -0
- package/esm/src/next/sourceDev.d.ts.map +1 -0
- package/esm/src/next/sourceDev.js +41 -0
- package/esm/src/next/sourceDev.js.map +1 -0
- package/esm/src/secrets/encoding.d.ts.map +1 -1
- package/esm/src/secrets/encoding.js +1 -0
- package/esm/src/secrets/encoding.js.map +1 -0
- package/esm/src/secrets/errors.d.ts.map +1 -1
- package/esm/src/secrets/errors.js +3 -7
- package/esm/src/secrets/errors.js.map +1 -0
- package/esm/src/secrets/fingerprint.d.ts.map +1 -1
- package/esm/src/secrets/fingerprint.js +1 -0
- package/esm/src/secrets/fingerprint.js.map +1 -0
- package/esm/src/secrets/frame.d.ts.map +1 -1
- package/esm/src/secrets/frame.js +4 -3
- package/esm/src/secrets/frame.js.map +1 -0
- package/esm/src/secrets/keyring.d.ts.map +1 -1
- package/esm/src/secrets/keyring.js +6 -6
- package/esm/src/secrets/keyring.js.map +1 -0
- package/esm/src/secrets/legacy.d.ts +0 -1
- package/esm/src/secrets/legacy.d.ts.map +1 -1
- package/esm/src/secrets/legacy.js +13 -10
- package/esm/src/secrets/legacy.js.map +1 -0
- package/esm/src/secrets/maintenance.d.ts +0 -1
- package/esm/src/secrets/maintenance.d.ts.map +1 -1
- package/esm/src/secrets/maintenance.js +9 -24
- package/esm/src/secrets/maintenance.js.map +1 -0
- package/esm/src/secrets/mod.d.ts +0 -1
- package/esm/src/secrets/mod.d.ts.map +1 -1
- package/esm/src/secrets/mod.js +1 -1
- package/esm/src/secrets/mod.js.map +1 -0
- package/esm/src/secrets/secrets.d.ts.map +1 -1
- package/esm/src/secrets/secrets.js +38 -30
- package/esm/src/secrets/secrets.js.map +1 -0
- package/package.json +111 -135
- package/skills/loom/SKILL.md +40 -5
- package/skills/loom/references/esm-package.md +35 -0
- package/skills/loom/references/local-development.md +261 -29
- package/skills/loom-mail/SKILL.md +1 -0
- package/skills/upgrade-deps/SKILL.md +4 -2
- package/source/bin/loom.ts +50 -0
- package/source/mod.ts +10 -0
- package/source/src/apiKeys/authorize.ts +294 -0
- package/source/src/apiKeys/betterAuth.ts +253 -0
- package/source/src/apiKeys/country.ts +7 -0
- package/source/src/apiKeys/credentials.ts +171 -0
- package/source/src/apiKeys/fingerprint.ts +10 -0
- package/{script/src/apiKeys/lifecycle.d.ts → source/src/apiKeys/lifecycle.ts} +21 -23
- package/source/src/apiKeys/limits.ts +372 -0
- package/source/src/apiKeys/mod.ts +11 -0
- package/source/src/apiKeys/permissions.ts +153 -0
- package/source/src/apiKeys/policy.ts +189 -0
- package/source/src/apiKeys/retention.ts +136 -0
- package/source/src/apiKeys/types.ts +288 -0
- package/source/src/cli/atomicText.ts +38 -0
- package/source/src/cli/bunLocalDev.ts +646 -0
- package/source/src/cli/bunProject.ts +433 -0
- package/source/src/cli/cliBootstrap.ts +313 -0
- package/source/src/cli/externalSkills.ts +315 -0
- package/source/src/cli/filesR2Policy.ts +212 -0
- package/source/src/cli/generatedBuild.ts +380 -0
- package/source/src/cli/generatedCleanup.ts +87 -0
- package/source/src/cli/generatedDevLease.ts +52 -0
- package/source/src/cli/generatedInstall.ts +630 -0
- package/source/src/cli/generatedWorkflow.ts +135 -0
- package/{script/src/cli/legacyManagedOutputs.js → source/src/cli/legacyManagedOutputs.ts} +36 -30
- package/source/src/cli/localDb.ts +548 -0
- package/source/src/cli/localDevLock.ts +462 -0
- package/source/src/cli/localDevPackage.ts +754 -0
- package/source/src/cli/managedFiles.ts +688 -0
- package/source/src/cli/migrationEnv.ts +267 -0
- package/source/src/cli/mod.ts +26788 -0
- package/source/src/cli/packageTreeSignature.ts +65 -0
- package/source/src/cli/processIdentity.ts +38 -0
- package/source/src/cli/projectSkills.ts +1102 -0
- package/source/src/cli/projectTooling.ts +1140 -0
- package/source/src/cli/releaseConfig.ts +36 -0
- package/source/src/cli/releaseCredentials.ts +642 -0
- package/source/src/cli/releaseTrust.ts +194 -0
- package/source/src/cli/releaseTrustCommand.ts +210 -0
- package/source/src/cli/sourceConfig.ts +106 -0
- package/source/src/cli/sourceDev.ts +1279 -0
- package/source/src/cli/vercelBuildEnv.ts +714 -0
- package/source/src/cli/vercelEnvMask.ts +182 -0
- package/source/src/cli/vercelProjectRelease.ts +807 -0
- package/source/src/cli/vercelPulledEnv.ts +174 -0
- package/source/src/clientData/identity.ts +229 -0
- package/source/src/clientData/mod.ts +1 -0
- package/source/src/files/client.ts +75 -0
- package/source/src/files/errors.ts +69 -0
- package/source/src/files/hash.ts +109 -0
- package/source/src/files/memory.ts +158 -0
- package/source/src/files/metadata.ts +251 -0
- package/source/src/files/mod.ts +8 -0
- package/source/src/files/s3.ts +182 -0
- package/source/src/files/service.ts +210 -0
- package/source/src/files/types.ts +171 -0
- package/source/src/jobs/catalog.ts +303 -0
- package/source/src/jobs/controller.ts +156 -0
- package/source/src/jobs/direct.ts +177 -0
- package/source/src/jobs/events.ts +74 -0
- package/source/src/jobs/format.ts +233 -0
- package/source/src/jobs/http.ts +83 -0
- package/source/src/jobs/log.ts +10 -0
- package/source/src/jobs/mod.ts +10 -0
- package/source/src/jobs/run.ts +141 -0
- package/source/src/jobs/sanitize.ts +142 -0
- package/source/src/jobs/types.ts +43 -0
- package/source/src/mail/errors.ts +77 -0
- package/source/src/mail/memory.ts +451 -0
- package/source/src/mail/mod.ts +5 -0
- package/source/src/mail/postal.ts +363 -0
- package/source/src/mail/retry.ts +30 -0
- package/source/src/mail/sender.ts +57 -0
- package/source/src/mail/service.ts +252 -0
- package/source/src/mail/types.ts +229 -0
- package/source/src/mui/apiKeys.tsx +1044 -0
- package/source/src/mui/apiKeysView.ts +535 -0
- package/source/src/mui/confirm.tsx +138 -0
- package/source/src/mui/mail.tsx +279 -0
- package/source/src/mui/mailView.ts +50 -0
- package/source/src/mui/mod.ts +3 -0
- package/source/src/next/apiKeys/mod.ts +393 -0
- package/{script/src/next/auth/client.d.ts → source/src/next/auth/client.ts} +19 -5
- package/source/src/next/auth/config.ts +207 -0
- package/source/src/next/auth/localTestLogin.ts +412 -0
- package/source/src/next/auth/mod.ts +3 -0
- package/source/src/next/auth/server.ts +94 -0
- package/source/src/next/files/mod.ts +1 -0
- package/source/src/next/files/route.ts +621 -0
- package/source/src/next/jobs/list.tsx +90 -0
- package/source/src/next/jobs/mod.ts +5 -0
- package/source/src/next/jobs/paths.ts +70 -0
- package/source/src/next/jobs/route.ts +207 -0
- package/source/src/next/jobs/run.tsx +888 -0
- package/source/src/next/jobs/runRequest.ts +92 -0
- package/source/src/next/jobs/stream.ts +33 -0
- package/source/src/next/mail/mod.ts +1 -0
- package/source/src/next/mail/route.ts +75 -0
- package/source/src/next/pwa/mod.tsx +453 -0
- package/source/src/next/pwa/worker.ts +59 -0
- package/source/src/next/secrets/constants.ts +2 -0
- package/source/src/next/secrets/mod.ts +319 -0
- package/source/src/next/sourceDev.ts +50 -0
- package/source/src/secrets/encoding.ts +102 -0
- package/source/src/secrets/errors.ts +58 -0
- package/source/src/secrets/fingerprint.ts +132 -0
- package/source/src/secrets/frame.ts +119 -0
- package/source/src/secrets/keyring.ts +225 -0
- package/source/src/secrets/legacy.ts +244 -0
- package/source/src/secrets/maintenance.ts +517 -0
- package/source/src/secrets/mod.ts +38 -0
- package/source/src/secrets/secrets.ts +926 -0
- package/db/databaseTls.test.ts +0 -171
- package/db/databaseUrl.test.ts +0 -72
- package/db/neonEndpoint.test.ts +0 -51
- package/db/testing.test.ts +0 -28
- package/deno.json +0 -3
- package/esm/_dnt.polyfills.d.ts +0 -166
- package/esm/_dnt.polyfills.d.ts.map +0 -1
- package/esm/_dnt.polyfills.js +0 -177
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/package.json +0 -3
- package/script/_dnt.polyfills.d.ts +0 -166
- package/script/_dnt.polyfills.d.ts.map +0 -1
- package/script/_dnt.polyfills.js +0 -180
- package/script/_dnt.shims.d.ts +0 -2
- package/script/_dnt.shims.d.ts.map +0 -1
- package/script/_dnt.shims.js +0 -60
- package/script/bin/loom.d.ts +0 -2
- package/script/bin/loom.d.ts.map +0 -1
- package/script/bin/loom.js +0 -17
- package/script/mod.d.ts +0 -12
- package/script/mod.d.ts.map +0 -1
- package/script/mod.js +0 -27
- package/script/package.json +0 -3
- package/script/src/apiKeys/authorize.d.ts +0 -4
- package/script/src/apiKeys/authorize.d.ts.map +0 -1
- package/script/src/apiKeys/authorize.js +0 -258
- package/script/src/apiKeys/betterAuth.d.ts +0 -123
- package/script/src/apiKeys/betterAuth.d.ts.map +0 -1
- package/script/src/apiKeys/betterAuth.js +0 -169
- package/script/src/apiKeys/country.d.ts +0 -3
- package/script/src/apiKeys/country.d.ts.map +0 -1
- package/script/src/apiKeys/country.js +0 -10
- package/script/src/apiKeys/credentials.d.ts +0 -39
- package/script/src/apiKeys/credentials.d.ts.map +0 -1
- package/script/src/apiKeys/credentials.js +0 -121
- package/script/src/apiKeys/fingerprint.d.ts +0 -3
- package/script/src/apiKeys/fingerprint.d.ts.map +0 -1
- package/script/src/apiKeys/fingerprint.js +0 -8
- package/script/src/apiKeys/lifecycle.d.ts.map +0 -1
- package/script/src/apiKeys/lifecycle.js +0 -7
- package/script/src/apiKeys/limits.d.ts +0 -132
- package/script/src/apiKeys/limits.d.ts.map +0 -1
- package/script/src/apiKeys/limits.js +0 -254
- package/script/src/apiKeys/mod.d.ts +0 -13
- package/script/src/apiKeys/mod.d.ts.map +0 -1
- package/script/src/apiKeys/mod.js +0 -28
- package/script/src/apiKeys/permissions.d.ts +0 -56
- package/script/src/apiKeys/permissions.d.ts.map +0 -1
- package/script/src/apiKeys/permissions.js +0 -136
- package/script/src/apiKeys/policy.d.ts +0 -61
- package/script/src/apiKeys/policy.d.ts.map +0 -1
- package/script/src/apiKeys/policy.js +0 -94
- package/script/src/apiKeys/retention.d.ts +0 -55
- package/script/src/apiKeys/retention.d.ts.map +0 -1
- package/script/src/apiKeys/retention.js +0 -70
- package/script/src/apiKeys/types.d.ts +0 -242
- package/script/src/apiKeys/types.d.ts.map +0 -1
- package/script/src/apiKeys/types.js +0 -2
- package/script/src/cli/externalSkills.d.ts +0 -39
- package/script/src/cli/externalSkills.d.ts.map +0 -1
- package/script/src/cli/externalSkills.js +0 -204
- package/script/src/cli/filesR2Policy.d.ts +0 -33
- package/script/src/cli/filesR2Policy.d.ts.map +0 -1
- package/script/src/cli/filesR2Policy.js +0 -135
- package/script/src/cli/legacyManagedOutputs.d.ts +0 -33
- package/script/src/cli/legacyManagedOutputs.d.ts.map +0 -1
- package/script/src/cli/localDb.d.ts +0 -28
- package/script/src/cli/localDb.d.ts.map +0 -1
- package/script/src/cli/localDb.js +0 -370
- package/script/src/cli/localDevLock.d.ts +0 -97
- package/script/src/cli/localDevLock.d.ts.map +0 -1
- package/script/src/cli/localDevLock.js +0 -320
- package/script/src/cli/localDevPackage.d.ts +0 -172
- package/script/src/cli/localDevPackage.d.ts.map +0 -1
- package/script/src/cli/localDevPackage.js +0 -635
- package/script/src/cli/managedFiles.d.ts +0 -131
- package/script/src/cli/managedFiles.d.ts.map +0 -1
- package/script/src/cli/managedFiles.js +0 -536
- package/script/src/cli/migrationEnv.d.ts +0 -63
- package/script/src/cli/migrationEnv.d.ts.map +0 -1
- package/script/src/cli/migrationEnv.js +0 -217
- package/script/src/cli/mod.d.ts +0 -582
- package/script/src/cli/mod.d.ts.map +0 -1
- package/script/src/cli/mod.js +0 -17010
- package/script/src/cli/projectSkills.d.ts +0 -109
- package/script/src/cli/projectSkills.d.ts.map +0 -1
- package/script/src/cli/projectSkills.js +0 -749
- package/script/src/cli/projectTooling.d.ts +0 -164
- package/script/src/cli/projectTooling.d.ts.map +0 -1
- package/script/src/cli/projectTooling.js +0 -847
- package/script/src/cli/releaseConfig.d.ts +0 -10
- package/script/src/cli/releaseConfig.d.ts.map +0 -1
- package/script/src/cli/releaseConfig.js +0 -26
- package/script/src/cli/releaseCredentials.d.ts +0 -32
- package/script/src/cli/releaseCredentials.d.ts.map +0 -1
- package/script/src/cli/releaseCredentials.js +0 -392
- package/script/src/cli/releaseTrust.d.ts +0 -39
- package/script/src/cli/releaseTrust.d.ts.map +0 -1
- package/script/src/cli/releaseTrust.js +0 -130
- package/script/src/cli/releaseTrustCommand.d.ts +0 -18
- package/script/src/cli/releaseTrustCommand.d.ts.map +0 -1
- package/script/src/cli/releaseTrustCommand.js +0 -145
- package/script/src/cli/vercelBuildEnv.d.ts +0 -62
- package/script/src/cli/vercelBuildEnv.d.ts.map +0 -1
- package/script/src/cli/vercelBuildEnv.js +0 -418
- package/script/src/cli/vercelEnvMask.d.ts +0 -38
- package/script/src/cli/vercelEnvMask.d.ts.map +0 -1
- package/script/src/cli/vercelEnvMask.js +0 -142
- package/script/src/cli/vercelProjectRelease.d.ts +0 -38
- package/script/src/cli/vercelProjectRelease.d.ts.map +0 -1
- package/script/src/cli/vercelProjectRelease.js +0 -607
- package/script/src/cli/vercelPulledEnv.d.ts +0 -65
- package/script/src/cli/vercelPulledEnv.d.ts.map +0 -1
- package/script/src/cli/vercelPulledEnv.js +0 -138
- package/script/src/clientData/identity.d.ts +0 -89
- package/script/src/clientData/identity.d.ts.map +0 -1
- package/script/src/clientData/identity.js +0 -134
- package/script/src/clientData/mod.d.ts +0 -3
- package/script/src/clientData/mod.d.ts.map +0 -1
- package/script/src/clientData/mod.js +0 -18
- package/script/src/files/client.d.ts +0 -29
- package/script/src/files/client.d.ts.map +0 -1
- package/script/src/files/client.js +0 -45
- package/script/src/files/errors.d.ts +0 -37
- package/script/src/files/errors.d.ts.map +0 -1
- package/script/src/files/errors.js +0 -76
- package/script/src/files/hash.d.ts +0 -15
- package/script/src/files/hash.d.ts.map +0 -1
- package/script/src/files/hash.js +0 -89
- package/script/src/files/memory.d.ts +0 -29
- package/script/src/files/memory.d.ts.map +0 -1
- package/script/src/files/memory.js +0 -113
- package/script/src/files/metadata.d.ts +0 -10
- package/script/src/files/metadata.d.ts.map +0 -1
- package/script/src/files/metadata.js +0 -189
- package/script/src/files/mod.d.ts +0 -10
- package/script/src/files/mod.d.ts.map +0 -1
- package/script/src/files/mod.js +0 -25
- package/script/src/files/s3.d.ts +0 -29
- package/script/src/files/s3.d.ts.map +0 -1
- package/script/src/files/s3.js +0 -110
- package/script/src/files/service.d.ts +0 -27
- package/script/src/files/service.d.ts.map +0 -1
- package/script/src/files/service.js +0 -139
- package/script/src/files/types.d.ts +0 -134
- package/script/src/files/types.d.ts.map +0 -1
- package/script/src/files/types.js +0 -2
- package/script/src/jobs/catalog.d.ts +0 -32
- package/script/src/jobs/catalog.d.ts.map +0 -1
- package/script/src/jobs/catalog.js +0 -223
- package/script/src/jobs/controller.d.ts +0 -41
- package/script/src/jobs/controller.d.ts.map +0 -1
- package/script/src/jobs/controller.js +0 -151
- package/script/src/jobs/direct.d.ts +0 -36
- package/script/src/jobs/direct.d.ts.map +0 -1
- package/script/src/jobs/direct.js +0 -128
- package/script/src/jobs/events.d.ts +0 -23
- package/script/src/jobs/events.d.ts.map +0 -1
- package/script/src/jobs/events.js +0 -50
- package/script/src/jobs/format.d.ts +0 -16
- package/script/src/jobs/format.d.ts.map +0 -1
- package/script/src/jobs/format.js +0 -193
- package/script/src/jobs/http.d.ts +0 -22
- package/script/src/jobs/http.d.ts.map +0 -1
- package/script/src/jobs/http.js +0 -50
- package/script/src/jobs/log.d.ts +0 -2
- package/script/src/jobs/log.d.ts.map +0 -1
- package/script/src/jobs/log.js +0 -13
- package/script/src/jobs/mod.d.ts +0 -11
- package/script/src/jobs/mod.d.ts.map +0 -1
- package/script/src/jobs/mod.js +0 -26
- package/script/src/jobs/run.d.ts +0 -39
- package/script/src/jobs/run.d.ts.map +0 -1
- package/script/src/jobs/run.js +0 -86
- package/script/src/jobs/sanitize.d.ts +0 -30
- package/script/src/jobs/sanitize.d.ts.map +0 -1
- package/script/src/jobs/sanitize.js +0 -97
- package/script/src/jobs/types.d.ts +0 -31
- package/script/src/jobs/types.d.ts.map +0 -1
- package/script/src/jobs/types.js +0 -2
- package/script/src/mail/errors.d.ts +0 -33
- package/script/src/mail/errors.d.ts.map +0 -1
- package/script/src/mail/errors.js +0 -97
- package/script/src/mail/memory.d.ts +0 -30
- package/script/src/mail/memory.d.ts.map +0 -1
- package/script/src/mail/memory.js +0 -345
- package/script/src/mail/mod.d.ts +0 -7
- package/script/src/mail/mod.d.ts.map +0 -1
- package/script/src/mail/mod.js +0 -22
- package/script/src/mail/postal.d.ts +0 -57
- package/script/src/mail/postal.d.ts.map +0 -1
- package/script/src/mail/postal.js +0 -251
- package/script/src/mail/retry.d.ts +0 -9
- package/script/src/mail/retry.d.ts.map +0 -1
- package/script/src/mail/retry.js +0 -22
- package/script/src/mail/sender.d.ts +0 -5
- package/script/src/mail/sender.d.ts.map +0 -1
- package/script/src/mail/sender.js +0 -52
- package/script/src/mail/service.d.ts +0 -23
- package/script/src/mail/service.d.ts.map +0 -1
- package/script/src/mail/service.js +0 -191
- package/script/src/mail/types.d.ts +0 -176
- package/script/src/mail/types.d.ts.map +0 -1
- package/script/src/mail/types.js +0 -2
- package/script/src/mui/apiKeys.d.ts +0 -171
- package/script/src/mui/apiKeys.d.ts.map +0 -1
- package/script/src/mui/apiKeys.js +0 -470
- package/script/src/mui/apiKeysView.d.ts +0 -193
- package/script/src/mui/apiKeysView.d.ts.map +0 -1
- package/script/src/mui/apiKeysView.js +0 -331
- package/script/src/mui/confirm.d.ts +0 -12
- package/script/src/mui/confirm.d.ts.map +0 -1
- package/script/src/mui/confirm.js +0 -85
- package/script/src/mui/mail.d.ts +0 -29
- package/script/src/mui/mail.d.ts.map +0 -1
- package/script/src/mui/mail.js +0 -159
- package/script/src/mui/mailView.d.ts +0 -20
- package/script/src/mui/mailView.d.ts.map +0 -1
- package/script/src/mui/mailView.js +0 -32
- package/script/src/mui/mod.d.ts +0 -5
- package/script/src/mui/mod.d.ts.map +0 -1
- package/script/src/mui/mod.js +0 -20
- package/script/src/next/apiKeys/mod.d.ts +0 -71
- package/script/src/next/apiKeys/mod.d.ts.map +0 -1
- package/script/src/next/apiKeys/mod.js +0 -227
- package/script/src/next/auth/client.d.ts.map +0 -1
- package/script/src/next/auth/client.js +0 -39
- package/script/src/next/auth/config.d.ts +0 -62
- package/script/src/next/auth/config.d.ts.map +0 -1
- package/script/src/next/auth/config.js +0 -178
- package/script/src/next/auth/localTestLogin.d.ts +0 -75
- package/script/src/next/auth/localTestLogin.d.ts.map +0 -1
- package/script/src/next/auth/localTestLogin.js +0 -291
- package/script/src/next/auth/mod.d.ts +0 -4
- package/script/src/next/auth/mod.d.ts.map +0 -1
- package/script/src/next/auth/mod.js +0 -19
- package/script/src/next/auth/server.d.ts +0 -44
- package/script/src/next/auth/server.d.ts.map +0 -1
- package/script/src/next/auth/server.js +0 -39
- package/script/src/next/files/mod.d.ts +0 -3
- package/script/src/next/files/mod.d.ts.map +0 -1
- package/script/src/next/files/mod.js +0 -18
- package/script/src/next/files/route.d.ts +0 -99
- package/script/src/next/files/route.d.ts.map +0 -1
- package/script/src/next/files/route.js +0 -353
- package/script/src/next/jobs/list.d.ts +0 -25
- package/script/src/next/jobs/list.d.ts.map +0 -1
- package/script/src/next/jobs/list.js +0 -48
- package/script/src/next/jobs/mod.d.ts +0 -6
- package/script/src/next/jobs/mod.d.ts.map +0 -1
- package/script/src/next/jobs/mod.js +0 -21
- package/script/src/next/jobs/paths.d.ts +0 -14
- package/script/src/next/jobs/paths.d.ts.map +0 -1
- package/script/src/next/jobs/paths.js +0 -47
- package/script/src/next/jobs/route.d.ts +0 -48
- package/script/src/next/jobs/route.d.ts.map +0 -1
- package/script/src/next/jobs/route.js +0 -105
- package/script/src/next/jobs/run.d.ts +0 -58
- package/script/src/next/jobs/run.d.ts.map +0 -1
- package/script/src/next/jobs/run.js +0 -592
- package/script/src/next/jobs/runRequest.d.ts +0 -19
- package/script/src/next/jobs/runRequest.d.ts.map +0 -1
- package/script/src/next/jobs/runRequest.js +0 -81
- package/script/src/next/jobs/stream.d.ts +0 -3
- package/script/src/next/jobs/stream.d.ts.map +0 -1
- package/script/src/next/jobs/stream.js +0 -28
- package/script/src/next/mail/mod.d.ts +0 -3
- package/script/src/next/mail/mod.d.ts.map +0 -1
- package/script/src/next/mail/mod.js +0 -18
- package/script/src/next/mail/route.d.ts +0 -12
- package/script/src/next/mail/route.d.ts.map +0 -1
- package/script/src/next/mail/route.js +0 -46
- package/script/src/next/pwa/mod.d.ts +0 -112
- package/script/src/next/pwa/mod.d.ts.map +0 -1
- package/script/src/next/pwa/mod.js +0 -303
- package/script/src/next/pwa/worker.d.ts +0 -27
- package/script/src/next/pwa/worker.d.ts.map +0 -1
- package/script/src/next/pwa/worker.js +0 -33
- package/script/src/next/secrets/mod.d.ts +0 -108
- package/script/src/next/secrets/mod.d.ts.map +0 -1
- package/script/src/next/secrets/mod.js +0 -218
- package/script/src/secrets/encoding.d.ts +0 -32
- package/script/src/secrets/encoding.d.ts.map +0 -1
- package/script/src/secrets/encoding.js +0 -95
- package/script/src/secrets/errors.d.ts +0 -45
- package/script/src/secrets/errors.d.ts.map +0 -1
- package/script/src/secrets/errors.js +0 -45
- package/script/src/secrets/fingerprint.d.ts +0 -43
- package/script/src/secrets/fingerprint.d.ts.map +0 -1
- package/script/src/secrets/fingerprint.js +0 -92
- package/script/src/secrets/frame.d.ts +0 -34
- package/script/src/secrets/frame.d.ts.map +0 -1
- package/script/src/secrets/frame.js +0 -91
- package/script/src/secrets/keyring.d.ts +0 -62
- package/script/src/secrets/keyring.d.ts.map +0 -1
- package/script/src/secrets/keyring.js +0 -202
- package/script/src/secrets/legacy.d.ts +0 -60
- package/script/src/secrets/legacy.d.ts.map +0 -1
- package/script/src/secrets/legacy.js +0 -186
- package/script/src/secrets/maintenance.d.ts +0 -173
- package/script/src/secrets/maintenance.d.ts.map +0 -1
- package/script/src/secrets/maintenance.js +0 -323
- package/script/src/secrets/mod.d.ts +0 -6
- package/script/src/secrets/mod.d.ts.map +0 -1
- package/script/src/secrets/mod.js +0 -24
- package/script/src/secrets/secrets.d.ts +0 -192
- package/script/src/secrets/secrets.d.ts.map +0 -1
- package/script/src/secrets/secrets.js +0 -532
|
@@ -0,0 +1,974 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { hostname } from "node:os";
|
|
3
|
+
import { readGeneratedBuild } from "./generatedBuild.js";
|
|
4
|
+
import { withGeneratedDevLease, hasGeneratedDevState, } from "./generatedDevLease.js";
|
|
5
|
+
import { assertGeneratedInstallerIdle } from "./generatedInstall.js";
|
|
6
|
+
import { assertSourceConfig } from "./sourceConfig.js";
|
|
7
|
+
/** Consumer-scoped source development; generated artifacts retain release authority. */
|
|
8
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
9
|
+
import { watch } from "node:fs";
|
|
10
|
+
import { lstat, mkdir, readdir, readFile, readlink, realpath, rename, rm, rmdir, symlink, writeFile, } from "node:fs/promises";
|
|
11
|
+
import { createRequire } from "node:module";
|
|
12
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
13
|
+
import process from "node:process";
|
|
14
|
+
import { withLocalDevLock } from "./localDevLock.js";
|
|
15
|
+
import { computeLoomSourceFingerprint, computePackageContentDigest, findPackageTreeDifference, LOOM_PACKAGE_RELEVANT_PATHS, readLoomBuildStamp, } from "./localDevPackage.js";
|
|
16
|
+
import { parseJsonc, patchJsonText } from "./projectTooling.js";
|
|
17
|
+
export const SOURCE_MANIFEST_FILE = ".loom-source-manifest.json";
|
|
18
|
+
const STATE = ".loom/source-state.json";
|
|
19
|
+
const OVERLAY = ".loom/source-package";
|
|
20
|
+
const OWNER = ".loom-source-owner.json";
|
|
21
|
+
const LOCK = ".loom/dev-sync.lock";
|
|
22
|
+
const NAME = "@gadicc/loom";
|
|
23
|
+
// A lease belongs to one async operation, never a process-global/project-global flag.
|
|
24
|
+
const mutationLease = new AsyncLocalStorage();
|
|
25
|
+
async function assertMutation() {
|
|
26
|
+
const lease = mutationLease.getStore();
|
|
27
|
+
if (!lease) {
|
|
28
|
+
throw new Error("Source mutation requires the project local-dev lease.");
|
|
29
|
+
}
|
|
30
|
+
await lease.assertHeld(true);
|
|
31
|
+
}
|
|
32
|
+
async function withSourceLock(cwd, action) {
|
|
33
|
+
await safeParents(cwd, join(cwd, LOCK));
|
|
34
|
+
await safeParents(cwd, join(cwd, LOCK + ".break"));
|
|
35
|
+
return await withGeneratedDevLease(cwd, async (lease) => {
|
|
36
|
+
await safeParents(cwd, join(cwd, LOCK));
|
|
37
|
+
await safeParents(cwd, join(cwd, LOCK + ".break"));
|
|
38
|
+
return await mutationLease.run(lease, action);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** Derives opt-in source exports without changing the published runtime exports. */
|
|
42
|
+
export function createSourceManifest(pkg, sources, supportDigest, supportSources = []) {
|
|
43
|
+
const entries = {};
|
|
44
|
+
for (const [key, value] of Object.entries(pkg.exports ?? {})) {
|
|
45
|
+
const target = value.import;
|
|
46
|
+
// CLI and Next config guard always execute from the compiled authority.
|
|
47
|
+
if (!target?.startsWith("./esm/") ||
|
|
48
|
+
target.includes("/bin/") ||
|
|
49
|
+
target.endsWith("/sourceDev.js"))
|
|
50
|
+
continue;
|
|
51
|
+
const prefix = target.slice("./esm/".length).replace(/\.js$/, "");
|
|
52
|
+
if (prefix.includes("*"))
|
|
53
|
+
entries[key] = prefix;
|
|
54
|
+
else {
|
|
55
|
+
const source = sources.find((file) => file === prefix + ".ts" || file === prefix + ".tsx");
|
|
56
|
+
if (source)
|
|
57
|
+
entries[key] = source;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
version: 1,
|
|
62
|
+
supportDigest,
|
|
63
|
+
supportSources,
|
|
64
|
+
stable: true,
|
|
65
|
+
exports: entries,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Fingerprints everything source mode keeps compiled, including metadata/dependency ownership. */
|
|
69
|
+
export async function computeSourceSupportDigest(root, supportSources = []) {
|
|
70
|
+
const hash = createHash("sha256");
|
|
71
|
+
async function visit(path) {
|
|
72
|
+
if (/(?:\.test|_test)\.[cm]?tsx?$/.test(path) ||
|
|
73
|
+
path
|
|
74
|
+
.split(/[\\/]/)
|
|
75
|
+
.some((part) => ["fixtures", "__tests__", "testing"].includes(part)))
|
|
76
|
+
return;
|
|
77
|
+
const entry = await info(join(root, path));
|
|
78
|
+
if (!entry) {
|
|
79
|
+
hash.update(`${path}\0missing\0`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (entry.isSymbolicLink()) {
|
|
83
|
+
throw new Error(`Source support input is redirected: ${path}`);
|
|
84
|
+
}
|
|
85
|
+
if (entry.isDirectory()) {
|
|
86
|
+
for (const name of (await readdir(join(root, path))).sort()) {
|
|
87
|
+
await visit(join(path, name));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const bytes = await readFile(join(root, path));
|
|
92
|
+
hash.update(`${path}\0${bytes.length}\0`);
|
|
93
|
+
hash.update(bytes);
|
|
94
|
+
hash.update("\0");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// This digest is emitted package metadata, so every static input must also be
|
|
98
|
+
// covered by build mutation detection and release package-equivalence proofs.
|
|
99
|
+
for (const path of [
|
|
100
|
+
...LOOM_PACKAGE_RELEVANT_PATHS.filter((path) => !["src", "mod.ts"].includes(path)),
|
|
101
|
+
"src/cli",
|
|
102
|
+
"src/next/sourceDev.ts",
|
|
103
|
+
])
|
|
104
|
+
await visit(path);
|
|
105
|
+
for (const path of [...new Set(supportSources)].sort()) {
|
|
106
|
+
if (!/^(?:src\/|mod\.ts$)/.test(path) ||
|
|
107
|
+
path.split("/").includes("..") ||
|
|
108
|
+
path.includes("\\"))
|
|
109
|
+
throw new Error("Invalid compiled support source path.");
|
|
110
|
+
await visit(path);
|
|
111
|
+
}
|
|
112
|
+
return hash.digest("hex");
|
|
113
|
+
}
|
|
114
|
+
function inside(root, path) {
|
|
115
|
+
const rel = relative(resolve(root), resolve(path));
|
|
116
|
+
return rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
|
|
117
|
+
}
|
|
118
|
+
async function info(path) {
|
|
119
|
+
try {
|
|
120
|
+
return await lstat(path);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
if (e.code === "ENOENT")
|
|
124
|
+
return null;
|
|
125
|
+
throw e;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function json(path) {
|
|
129
|
+
return JSON.parse(await readFile(path, "utf8"));
|
|
130
|
+
}
|
|
131
|
+
async function safeParents(cwd, path) {
|
|
132
|
+
if (!inside(cwd, path)) {
|
|
133
|
+
throw new Error(`Source-mode path escapes this project: ${path}`);
|
|
134
|
+
}
|
|
135
|
+
const rel = relative(cwd, path);
|
|
136
|
+
let parent = cwd;
|
|
137
|
+
for (const part of rel.split(sep).slice(0, -1)) {
|
|
138
|
+
parent = join(parent, part);
|
|
139
|
+
const entry = await info(parent);
|
|
140
|
+
if (entry && (!entry.isDirectory() || entry.isSymbolicLink())) {
|
|
141
|
+
throw new Error(`Source mode refuses redirected directory ${parent}.`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if ((await info(path))?.isSymbolicLink()) {
|
|
145
|
+
throw new Error(`Source mode refuses redirected file ${path}.`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async function atomic(cwd, path, text) {
|
|
149
|
+
await safeParents(cwd, path);
|
|
150
|
+
await assertMutation();
|
|
151
|
+
await mkdir(dirname(path), { recursive: true });
|
|
152
|
+
const temp = `${path}.${randomUUID()}.tmp`;
|
|
153
|
+
try {
|
|
154
|
+
await assertMutation();
|
|
155
|
+
await writeFile(temp, text, { encoding: "utf8", mode: 0o600, flag: "wx" });
|
|
156
|
+
await assertMutation();
|
|
157
|
+
await rename(temp, path);
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
await rm(temp, { force: true });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async function writeState(cwd, state) {
|
|
164
|
+
await atomic(cwd, join(cwd, STATE), JSON.stringify(state, null, 2) + "\n");
|
|
165
|
+
}
|
|
166
|
+
async function marker(cwd, active) {
|
|
167
|
+
const path = join(cwd, "loom.json");
|
|
168
|
+
await safeParents(cwd, path);
|
|
169
|
+
const text = await readFile(path, "utf8");
|
|
170
|
+
const manifest = parseJsonc(text, "loom.json");
|
|
171
|
+
const development = manifest.development;
|
|
172
|
+
if (development !== undefined &&
|
|
173
|
+
(typeof development !== "object" ||
|
|
174
|
+
development === null ||
|
|
175
|
+
Array.isArray(development)))
|
|
176
|
+
throw new Error("loom.json development must be an object.");
|
|
177
|
+
const next = { ...development };
|
|
178
|
+
if (active)
|
|
179
|
+
next.source = true;
|
|
180
|
+
else
|
|
181
|
+
delete next.source;
|
|
182
|
+
if (Object.keys(next).length)
|
|
183
|
+
manifest.development = next;
|
|
184
|
+
else
|
|
185
|
+
delete manifest.development;
|
|
186
|
+
const nextText = patchJsonText(text, manifest);
|
|
187
|
+
if (nextText !== text)
|
|
188
|
+
await atomic(cwd, path, nextText);
|
|
189
|
+
}
|
|
190
|
+
/** Detects activation independently of registry pins, locks and installed content proofs. */
|
|
191
|
+
export async function sourceDevIssue(cwd) {
|
|
192
|
+
try {
|
|
193
|
+
const text = await readFile(join(cwd, "loom.json"), "utf8").catch((e) => {
|
|
194
|
+
if (e.code === "ENOENT")
|
|
195
|
+
return "{}";
|
|
196
|
+
throw e;
|
|
197
|
+
});
|
|
198
|
+
const manifest = parseJsonc(text, "loom.json");
|
|
199
|
+
if (manifest.development && Object.hasOwn(manifest.development, "source")) {
|
|
200
|
+
return "Loom source mode is enabled in loom.json; run `loom dev generated` before production or publication.";
|
|
201
|
+
}
|
|
202
|
+
if (await info(join(cwd, STATE))) {
|
|
203
|
+
return "Loom source-mode recovery state remains; run `loom dev generated` before production or publication.";
|
|
204
|
+
}
|
|
205
|
+
const installed = join(cwd, "node_modules", NAME);
|
|
206
|
+
if ((await json(join(installed, "package.json")).catch(() => null))
|
|
207
|
+
?.loomSource) {
|
|
208
|
+
return "The installed Loom package is a source overlay; restore it with `loom dev generated`.";
|
|
209
|
+
}
|
|
210
|
+
if ((await info(installed)) &&
|
|
211
|
+
inside(join(cwd, OVERLAY), await realpath(installed).catch(() => join(cwd, "node_modules", NAME)))) {
|
|
212
|
+
return "The installed Loom path still targets the source overlay; run `loom dev generated`.";
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
return "Loom source-mode state is unreadable; repair it with `loom dev generated` before production or publication.";
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async function stateAt(cwd) {
|
|
221
|
+
await safeParents(cwd, join(cwd, STATE));
|
|
222
|
+
const state = await json(join(cwd, STATE));
|
|
223
|
+
if (state.version !== 1 ||
|
|
224
|
+
state.projectRoot !== cwd ||
|
|
225
|
+
!/^[a-f0-9-]{36}$/.test(state.token ?? "") ||
|
|
226
|
+
!isAbsolute(state.sourceRoot ?? "") ||
|
|
227
|
+
!inside(join(cwd, "node_modules"), state.baseRoot ?? "") ||
|
|
228
|
+
!state.baseDigest?.startsWith("sha256:") ||
|
|
229
|
+
typeof state.restoreTarget !== "string" ||
|
|
230
|
+
!["preparing", "active", "leaving"].includes(state.phase)) {
|
|
231
|
+
throw new Error("Invalid source-mode ownership state; do not remove paths from it manually.");
|
|
232
|
+
}
|
|
233
|
+
if ((await realpath(state.sourceRoot)) !== state.sourceRoot) {
|
|
234
|
+
throw new Error("The recorded source checkout was redirected. Restore its original path before reconciliation.");
|
|
235
|
+
}
|
|
236
|
+
if (state.retiredPath !== undefined &&
|
|
237
|
+
!/^\.loom\/source-retired-[a-f0-9-]{36}$/.test(state.retiredPath))
|
|
238
|
+
throw new Error("Invalid source quarantine ownership path.");
|
|
239
|
+
const restored = resolve(dirname(join(cwd, "node_modules", NAME)), state.restoreTarget);
|
|
240
|
+
if ((await info(restored)) && (await realpath(restored)) !== state.baseRoot) {
|
|
241
|
+
throw new Error("The saved Loom install target was redirected; reinstall the compiled package first.");
|
|
242
|
+
}
|
|
243
|
+
return state;
|
|
244
|
+
}
|
|
245
|
+
async function sourceFiles(root) {
|
|
246
|
+
const files = new Map();
|
|
247
|
+
for (const name of ["mod.ts", "src"]) {
|
|
248
|
+
const visit = async (path) => {
|
|
249
|
+
const entry = await info(join(root, path));
|
|
250
|
+
if (!entry)
|
|
251
|
+
throw new Error(`Source path disappeared: ${path}`);
|
|
252
|
+
if (entry.isSymbolicLink()) {
|
|
253
|
+
throw new Error(`Source mode refuses symlinked source ${path}.`);
|
|
254
|
+
}
|
|
255
|
+
if (entry.isDirectory()) {
|
|
256
|
+
for (const child of (await readdir(join(root, path))).sort()) {
|
|
257
|
+
if ([
|
|
258
|
+
"testing",
|
|
259
|
+
"fixtures",
|
|
260
|
+
"__tests__",
|
|
261
|
+
"node_modules",
|
|
262
|
+
".git",
|
|
263
|
+
].includes(child))
|
|
264
|
+
continue;
|
|
265
|
+
await visit(join(path, child));
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else if (/\.tsx?$/.test(path) &&
|
|
269
|
+
!/(?:\.test|_test|\.dom\.test)\.tsx?$/.test(path)) {
|
|
270
|
+
files.set(path.split(sep).join("/"), await readFile(join(root, path), "utf8"));
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
await visit(name);
|
|
274
|
+
}
|
|
275
|
+
const hash = createHash("sha256");
|
|
276
|
+
for (const [path, text] of files) {
|
|
277
|
+
hash.update(`${path}\0${text.length}\0${text}\0`);
|
|
278
|
+
}
|
|
279
|
+
return { files, digest: hash.digest("hex") };
|
|
280
|
+
}
|
|
281
|
+
async function validateBase(cwd, baseRoot) {
|
|
282
|
+
if (!inside(join(cwd, "node_modules"), baseRoot)) {
|
|
283
|
+
throw new Error("Source mode requires a project-local pnpm/Bun installed package, not a global or enclosing workspace store.");
|
|
284
|
+
}
|
|
285
|
+
const pkg = await json(join(baseRoot, "package.json"));
|
|
286
|
+
const contract = await json(join(baseRoot, SOURCE_MANIFEST_FILE)).catch(() => null);
|
|
287
|
+
if (pkg.name !== NAME ||
|
|
288
|
+
pkg.loomSource ||
|
|
289
|
+
!contract ||
|
|
290
|
+
contract.version !== 1 ||
|
|
291
|
+
typeof contract.supportDigest !== "string" ||
|
|
292
|
+
!Array.isArray(contract.supportSources) ||
|
|
293
|
+
contract.stable !== true ||
|
|
294
|
+
typeof contract.exports !== "object" ||
|
|
295
|
+
!contract.exports["."]) {
|
|
296
|
+
throw new Error("The installed Loom lacks the native source-mode contract. Build this Loom checkout, run `loom dev local <checkout>`, then retry.");
|
|
297
|
+
}
|
|
298
|
+
return { pkg, contract };
|
|
299
|
+
}
|
|
300
|
+
async function installed(cwd) {
|
|
301
|
+
const path = join(cwd, "node_modules", NAME);
|
|
302
|
+
await safeParents(cwd, dirname(path));
|
|
303
|
+
if (!(await info(path))?.isSymbolicLink()) {
|
|
304
|
+
throw new Error("Source mode requires a project-local pnpm/Bun Loom symlink. Reinstall the compiled package first.");
|
|
305
|
+
}
|
|
306
|
+
const target = await readlink(path);
|
|
307
|
+
const root = await realpath(path).catch((error) => {
|
|
308
|
+
// A removed owned overlay may leave its exact alias dangling; state validation still gates every mutation.
|
|
309
|
+
if (error.code === "ENOENT" &&
|
|
310
|
+
resolve(dirname(path), target) === join(cwd, OVERLAY))
|
|
311
|
+
return join(cwd, OVERLAY);
|
|
312
|
+
throw new Error("The installed Loom symlink is dangling. Reinstall the compiled dependency, then retry source recovery.");
|
|
313
|
+
});
|
|
314
|
+
return { path, target, root };
|
|
315
|
+
}
|
|
316
|
+
async function ownedOverlay(cwd, state, allowCreate = false) {
|
|
317
|
+
const path = join(cwd, OVERLAY);
|
|
318
|
+
await safeParents(cwd, join(path, OWNER));
|
|
319
|
+
if (await info(path)) {
|
|
320
|
+
const owner = await json(join(path, OWNER)).catch(() => null);
|
|
321
|
+
if (owner?.projectRoot !== cwd || owner.token !== state.token) {
|
|
322
|
+
throw new Error("Refusing to replace an unowned .loom/source-package directory.");
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
else if (!allowCreate) {
|
|
326
|
+
throw new Error("The source overlay is missing; rerun `loom dev source` or `loom dev generated`.");
|
|
327
|
+
}
|
|
328
|
+
return path;
|
|
329
|
+
}
|
|
330
|
+
async function link(cwd, path, target) {
|
|
331
|
+
// Only the explicitly selected package alias may itself be a symlink.
|
|
332
|
+
await safeParents(cwd, dirname(path));
|
|
333
|
+
const temp = `${path}.${randomUUID()}.tmp`;
|
|
334
|
+
try {
|
|
335
|
+
await assertMutation();
|
|
336
|
+
await symlink(target, temp, "dir");
|
|
337
|
+
await assertMutation();
|
|
338
|
+
await rename(temp, path);
|
|
339
|
+
}
|
|
340
|
+
finally {
|
|
341
|
+
await rm(temp, { force: true });
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
async function hardPackages(baseRoot, pkg) {
|
|
345
|
+
const require = createRequire(join(baseRoot, "package.json"));
|
|
346
|
+
const resolved = new Map();
|
|
347
|
+
for (const [name, range] of Object.entries(pkg.dependencies ?? {})) {
|
|
348
|
+
if (!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/i.test(name)) {
|
|
349
|
+
throw new Error(`Invalid hard dependency ${name}.`);
|
|
350
|
+
}
|
|
351
|
+
let owner = dirname(require.resolve(name));
|
|
352
|
+
for (;;) {
|
|
353
|
+
if ((await json(join(owner, "package.json")).catch(() => null))
|
|
354
|
+
?.name === name)
|
|
355
|
+
break;
|
|
356
|
+
const parent = dirname(owner);
|
|
357
|
+
if (parent === owner) {
|
|
358
|
+
throw new Error(`Cannot locate installed hard dependency ${name}.`);
|
|
359
|
+
}
|
|
360
|
+
owner = parent;
|
|
361
|
+
}
|
|
362
|
+
const version = (await json(join(owner, "package.json"))).version ?? "";
|
|
363
|
+
// Native Loom metadata uses stable exact/caret ranges. Fail closed for a new range language.
|
|
364
|
+
const minimum = range.match(/^(\^)?(\d+)\.(\d+)\.(\d+)$/);
|
|
365
|
+
const actual = version.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
366
|
+
const floor = minimum?.slice(2).map(Number), found = actual?.slice(1).map(Number);
|
|
367
|
+
const same = floor && found && found.every((value, index) => value === floor[index]);
|
|
368
|
+
const caret = floor &&
|
|
369
|
+
found &&
|
|
370
|
+
minimum?.[1] &&
|
|
371
|
+
(found[0] > floor[0] ||
|
|
372
|
+
(found[0] === floor[0] &&
|
|
373
|
+
(found[1] > floor[1] ||
|
|
374
|
+
(found[1] === floor[1] && found[2] >= floor[2])))) &&
|
|
375
|
+
(floor[0] > 0
|
|
376
|
+
? found[0] === floor[0]
|
|
377
|
+
: floor[1] > 0
|
|
378
|
+
? found[0] === 0 && found[1] === floor[1]
|
|
379
|
+
: found[0] === 0 && found[1] === 0 && found[2] === floor[2]);
|
|
380
|
+
if (!same && !caret) {
|
|
381
|
+
throw new Error(`Installed hard dependency ${name}@${version} does not satisfy supported Loom range ${range}. Reinstall the compiled dependency graph before source mode.`);
|
|
382
|
+
}
|
|
383
|
+
resolved.set(name, owner);
|
|
384
|
+
}
|
|
385
|
+
return resolved;
|
|
386
|
+
}
|
|
387
|
+
async function dependencyTreeMatches(overlay, names) {
|
|
388
|
+
const root = join(overlay, "node_modules");
|
|
389
|
+
const entry = await info(root);
|
|
390
|
+
if (!entry)
|
|
391
|
+
return names.length === 0;
|
|
392
|
+
if (!entry.isDirectory() || entry.isSymbolicLink())
|
|
393
|
+
return false;
|
|
394
|
+
for (const name of await readdir(root)) {
|
|
395
|
+
const path = join(root, name);
|
|
396
|
+
if (name.startsWith("@")) {
|
|
397
|
+
const scope = await info(path);
|
|
398
|
+
if (!scope?.isDirectory() || scope.isSymbolicLink())
|
|
399
|
+
return false;
|
|
400
|
+
for (const child of await readdir(path)) {
|
|
401
|
+
if (!names.includes(`${name}/${child}`))
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
if (!names.some((dependency) => dependency.startsWith(name + "/"))) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
else if (!names.includes(name))
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
async function hardDependencies(cwd, overlay, baseRoot, pkg) {
|
|
414
|
+
const dependencies = await hardPackages(baseRoot, pkg);
|
|
415
|
+
const nodeModules = join(overlay, "node_modules");
|
|
416
|
+
if ((await info(nodeModules)) &&
|
|
417
|
+
!(await dependencyTreeMatches(overlay, [...dependencies.keys()]))) {
|
|
418
|
+
throw new Error("Unexpected source-overlay dependencies could shadow app peers. Return to generated mode, then reactivate source mode.");
|
|
419
|
+
}
|
|
420
|
+
for (const [name, owner] of dependencies) {
|
|
421
|
+
const target = join(overlay, "node_modules", name);
|
|
422
|
+
await safeParents(cwd, dirname(target));
|
|
423
|
+
await assertMutation();
|
|
424
|
+
await mkdir(dirname(target), { recursive: true });
|
|
425
|
+
const entry = await info(target);
|
|
426
|
+
if (entry && !entry.isSymbolicLink()) {
|
|
427
|
+
throw new Error(`Refusing unowned dependency path ${target}.`);
|
|
428
|
+
}
|
|
429
|
+
if (entry && (await readlink(target)) === owner)
|
|
430
|
+
continue;
|
|
431
|
+
await assertMutation();
|
|
432
|
+
if (entry)
|
|
433
|
+
await rm(target);
|
|
434
|
+
await assertMutation();
|
|
435
|
+
await symlink(owner, target, "dir");
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function rawExports(pkg, contract, files) {
|
|
439
|
+
const exports = { ...pkg.exports };
|
|
440
|
+
for (const [key, source] of Object.entries(contract.exports)) {
|
|
441
|
+
if (!/^(?:src\/|mod\.ts$)/.test(source) ||
|
|
442
|
+
source.split("/").includes("..") ||
|
|
443
|
+
source.includes("\\"))
|
|
444
|
+
throw new Error(`Invalid source export ${source}.`);
|
|
445
|
+
if (key.includes("*")) {
|
|
446
|
+
if (!source.includes("*") ||
|
|
447
|
+
source.split("*").length !== 2 ||
|
|
448
|
+
key.split("*").length !== 2)
|
|
449
|
+
throw new Error(`Invalid source pattern ${key}.`);
|
|
450
|
+
const [before, after] = source.split("*");
|
|
451
|
+
// Remove the compiled fallback so removed/new wildcard source files cannot silently use stale JS.
|
|
452
|
+
delete exports[key];
|
|
453
|
+
for (const file of files.keys()) {
|
|
454
|
+
const extensionless = file.replace(/\.tsx?$/, "");
|
|
455
|
+
if (extensionless.startsWith(before) && extensionless.endsWith(after)) {
|
|
456
|
+
const captured = extensionless.slice(before.length, extensionless.length - after.length || undefined);
|
|
457
|
+
const target = `./source/${file}`;
|
|
458
|
+
exports[key.replace("*", captured)] = {
|
|
459
|
+
types: target,
|
|
460
|
+
import: target,
|
|
461
|
+
default: target,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
if (!files.has(source)) {
|
|
468
|
+
throw new Error(`Source export ${key} is missing ${source}; repair the checkout or return to generated mode.`);
|
|
469
|
+
}
|
|
470
|
+
const target = `./source/${source}`;
|
|
471
|
+
exports[key] = { types: target, import: target, default: target };
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return exports;
|
|
475
|
+
}
|
|
476
|
+
async function overlayMatches(cwd, state, pkg, contract, files) {
|
|
477
|
+
const overlay = await ownedOverlay(cwd, state);
|
|
478
|
+
const expected = {
|
|
479
|
+
...pkg,
|
|
480
|
+
exports: rawExports(pkg, contract, files),
|
|
481
|
+
main: "./source/mod.ts",
|
|
482
|
+
module: "./source/mod.ts",
|
|
483
|
+
types: "./source/mod.ts",
|
|
484
|
+
loomSource: {
|
|
485
|
+
version: 1,
|
|
486
|
+
projectRoot: cwd,
|
|
487
|
+
sourceRoot: state.sourceRoot,
|
|
488
|
+
token: state.token,
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
if ((await readFile(join(overlay, "package.json"), "utf8")) !==
|
|
492
|
+
JSON.stringify(expected, null, 2) + "\n")
|
|
493
|
+
return false;
|
|
494
|
+
for (const name of await readdir(state.baseRoot)) {
|
|
495
|
+
if (["package.json", "node_modules", "source", ".loom-build.json"].includes(name))
|
|
496
|
+
continue;
|
|
497
|
+
const path = join(overlay, name);
|
|
498
|
+
if (!(await info(path))?.isSymbolicLink() ||
|
|
499
|
+
(await readlink(path)) !== join(state.baseRoot, name) ||
|
|
500
|
+
(await realpath(path)) !== (await realpath(join(state.baseRoot, name))))
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
const owners = await hardPackages(state.baseRoot, pkg);
|
|
504
|
+
if (!(await dependencyTreeMatches(overlay, [...owners.keys()])))
|
|
505
|
+
return false;
|
|
506
|
+
for (const [name, owner] of owners) {
|
|
507
|
+
const path = join(overlay, "node_modules", name);
|
|
508
|
+
if (!(await info(path))?.isSymbolicLink() ||
|
|
509
|
+
(await readlink(path)) !== owner)
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
let seen = 0;
|
|
513
|
+
async function visit(path) {
|
|
514
|
+
const entry = await info(path);
|
|
515
|
+
if (!entry || entry.isSymbolicLink())
|
|
516
|
+
return false;
|
|
517
|
+
if (entry.isDirectory()) {
|
|
518
|
+
for (const name of await readdir(path))
|
|
519
|
+
if (!(await visit(join(path, name))))
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
const rel = relative(join(overlay, "source"), path).split(sep).join("/");
|
|
524
|
+
if (!files.has(rel) ||
|
|
525
|
+
(await readFile(path, "utf8")) !== files.get(rel)) {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
seen++;
|
|
529
|
+
}
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
return (await visit(join(overlay, "source"))) && seen === files.size;
|
|
533
|
+
}
|
|
534
|
+
async function synchronize(cwd, state, reattach) {
|
|
535
|
+
const current = await installed(cwd);
|
|
536
|
+
const overlay = join(cwd, OVERLAY);
|
|
537
|
+
if (current.root !== overlay) {
|
|
538
|
+
if (!reattach) {
|
|
539
|
+
throw new Error("A package install detached source mode. Stop Next, run `loom dev source` to reattach, then restart Next.");
|
|
540
|
+
}
|
|
541
|
+
await validateBase(cwd, current.root);
|
|
542
|
+
state.baseRoot = current.root;
|
|
543
|
+
state.restoreTarget = current.target;
|
|
544
|
+
state.baseDigest = await computePackageContentDigest(current.root);
|
|
545
|
+
}
|
|
546
|
+
const { pkg, contract } = await validateBase(cwd, state.baseRoot);
|
|
547
|
+
if ((await computePackageContentDigest(state.baseRoot)) !== state.baseDigest) {
|
|
548
|
+
throw new Error("The compiled Loom authority changed in place. Reinstall the compiled package before reattaching source mode.");
|
|
549
|
+
}
|
|
550
|
+
if ((await computeSourceSupportDigest(state.sourceRoot, contract.supportSources)) !== contract.supportDigest) {
|
|
551
|
+
throw new Error("Compiled CLI, assets or dependency/export metadata changed. Run `loom dev generated` to rebuild them, then enable source mode again.");
|
|
552
|
+
}
|
|
553
|
+
const snapshot = await sourceFiles(state.sourceRoot);
|
|
554
|
+
const exports = rawExports(pkg, contract, snapshot.files);
|
|
555
|
+
await ownedOverlay(cwd, state, state.phase === "preparing" || reattach);
|
|
556
|
+
if (!(await info(overlay))) {
|
|
557
|
+
await atomic(cwd, join(overlay, OWNER), JSON.stringify({ projectRoot: cwd, token: state.token }) + "\n");
|
|
558
|
+
}
|
|
559
|
+
const overlayPackage = {
|
|
560
|
+
...pkg,
|
|
561
|
+
exports,
|
|
562
|
+
main: "./source/mod.ts",
|
|
563
|
+
module: "./source/mod.ts",
|
|
564
|
+
types: "./source/mod.ts",
|
|
565
|
+
loomSource: {
|
|
566
|
+
version: 1,
|
|
567
|
+
projectRoot: cwd,
|
|
568
|
+
sourceRoot: state.sourceRoot,
|
|
569
|
+
token: state.token,
|
|
570
|
+
},
|
|
571
|
+
};
|
|
572
|
+
const packageText = JSON.stringify(overlayPackage, null, 2) + "\n";
|
|
573
|
+
if ((await readFile(join(overlay, "package.json"), "utf8").catch(() => null)) !== packageText)
|
|
574
|
+
await atomic(cwd, join(overlay, "package.json"), packageText);
|
|
575
|
+
// Compiled CLI/runtime assets remain owned by the installed package and resolve its dependencies.
|
|
576
|
+
for (const name of await readdir(state.baseRoot)) {
|
|
577
|
+
if (["package.json", "node_modules", "source", ".loom-build.json"].includes(name))
|
|
578
|
+
continue;
|
|
579
|
+
const target = join(overlay, name);
|
|
580
|
+
await safeParents(cwd, overlay);
|
|
581
|
+
const previous = await info(target);
|
|
582
|
+
if (previous && !previous.isSymbolicLink()) {
|
|
583
|
+
throw new Error(`Refusing unowned overlay asset ${target}.`);
|
|
584
|
+
}
|
|
585
|
+
if (previous && (await readlink(target)) === join(state.baseRoot, name)) {
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
await assertMutation();
|
|
589
|
+
if (previous)
|
|
590
|
+
await rm(target);
|
|
591
|
+
const entry = await lstat(join(state.baseRoot, name));
|
|
592
|
+
if (entry.isSymbolicLink()) {
|
|
593
|
+
throw new Error(`Refusing redirected compiled asset ${name}.`);
|
|
594
|
+
}
|
|
595
|
+
await assertMutation();
|
|
596
|
+
await symlink(join(state.baseRoot, name), target, entry.isDirectory() ? "dir" : "file");
|
|
597
|
+
}
|
|
598
|
+
await hardDependencies(cwd, overlay, state.baseRoot, pkg);
|
|
599
|
+
const sourcePath = join(overlay, "source");
|
|
600
|
+
// Enumerate the previous mirror without following symlinks, including files since deleted in the checkout.
|
|
601
|
+
let changed = false;
|
|
602
|
+
async function prune(path) {
|
|
603
|
+
const entry = await info(path);
|
|
604
|
+
if (!entry)
|
|
605
|
+
return;
|
|
606
|
+
if (entry.isSymbolicLink()) {
|
|
607
|
+
throw new Error(`Refusing redirected mirrored source ${path}.`);
|
|
608
|
+
}
|
|
609
|
+
if (entry.isDirectory()) {
|
|
610
|
+
for (const name of await readdir(path))
|
|
611
|
+
await prune(join(path, name));
|
|
612
|
+
}
|
|
613
|
+
else if (!snapshot.files.has(relative(sourcePath, path).split(sep).join("/"))) {
|
|
614
|
+
await assertMutation();
|
|
615
|
+
await rm(path);
|
|
616
|
+
changed = true;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
await prune(sourcePath);
|
|
620
|
+
for (const [path, text] of snapshot.files) {
|
|
621
|
+
const target = join(sourcePath, path);
|
|
622
|
+
if ((await readFile(target, "utf8").catch((e) => {
|
|
623
|
+
if (e.code === "ENOENT")
|
|
624
|
+
return null;
|
|
625
|
+
throw e;
|
|
626
|
+
})) !== text) {
|
|
627
|
+
await atomic(cwd, target, text);
|
|
628
|
+
changed = true;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
if (current.root !== overlay)
|
|
632
|
+
await link(cwd, current.path, overlay);
|
|
633
|
+
if (changed ||
|
|
634
|
+
current.root !== overlay ||
|
|
635
|
+
state.phase !== "active" ||
|
|
636
|
+
state.sourceDigest !== snapshot.digest) {
|
|
637
|
+
state.phase = "active";
|
|
638
|
+
state.sourceDigest = snapshot.digest;
|
|
639
|
+
state.syncedAt = new Date().toISOString();
|
|
640
|
+
await writeState(cwd, state);
|
|
641
|
+
}
|
|
642
|
+
return { changed, files: snapshot.files.size };
|
|
643
|
+
}
|
|
644
|
+
/** Activates or reconciles source mode under the same lock as generated sync. */
|
|
645
|
+
export async function enableSourceDev(cwd, sourceRoot, validateManaged) {
|
|
646
|
+
cwd = await realpath(cwd);
|
|
647
|
+
sourceRoot = await realpath(sourceRoot);
|
|
648
|
+
return await withSourceLock(cwd, async () => {
|
|
649
|
+
await validateManaged?.();
|
|
650
|
+
if (!(await info(join(sourceRoot, "deno.json"))) ||
|
|
651
|
+
!(await info(join(sourceRoot, "scripts/build_npm.ts"))))
|
|
652
|
+
throw new Error("Source mode needs a Loom source checkout.");
|
|
653
|
+
const configs = (await readdir(cwd)).filter((name) => /^next\.config\.(?:ts|js|mjs)$/.test(name));
|
|
654
|
+
if (configs.length !== 1) {
|
|
655
|
+
throw new Error("Source mode requires one next.config.ts, .js or .mjs.");
|
|
656
|
+
}
|
|
657
|
+
await safeParents(cwd, join(cwd, configs[0]));
|
|
658
|
+
const config = await readFile(join(cwd, configs[0]), "utf8");
|
|
659
|
+
assertSourceConfig(config);
|
|
660
|
+
const tsconfig = parseJsonc(await readFile(join(cwd, "tsconfig.json"), "utf8"), "tsconfig.json");
|
|
661
|
+
if (tsconfig.compilerOptions?.allowImportingTsExtensions !== true &&
|
|
662
|
+
tsconfig.compilerOptions?.rewriteRelativeImportExtensions !== true) {
|
|
663
|
+
throw new Error("Source mode needs TypeScript >=5.9 and an explicit compilerOptions.allowImportingTsExtensions: true in the app tsconfig.json (normally with noEmit and bundler resolution). Inherited settings may be repeated locally. Generated mode needs no such change.");
|
|
664
|
+
}
|
|
665
|
+
if (!tsconfig.compilerOptions?.lib?.some((lib) => /^(?:esnext|es202[4-9])$/i.test(lib))) {
|
|
666
|
+
throw new Error("Raw Loom source needs compilerOptions.lib including ES2024 or newer (usually alongside DOM and DOM.Iterable). Generated declarations do not require this source-only compiler setting.");
|
|
667
|
+
}
|
|
668
|
+
if (!tsconfig.exclude?.includes(".loom/source-package")) {
|
|
669
|
+
throw new Error('Add ".loom/source-package" to tsconfig.json exclude. Imported source still gets checked; unused mirrored modules must not enter the app through broad file globs.');
|
|
670
|
+
}
|
|
671
|
+
let state;
|
|
672
|
+
if (await info(join(cwd, STATE))) {
|
|
673
|
+
state = await stateAt(cwd);
|
|
674
|
+
if (state.phase === "leaving") {
|
|
675
|
+
throw new Error("Source mode is returning to generated output; finish `loom dev generated` first.");
|
|
676
|
+
}
|
|
677
|
+
if (state.sourceRoot !== sourceRoot) {
|
|
678
|
+
throw new Error("Return to generated mode before selecting another source checkout.");
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
if (await sourceDevIssue(cwd)) {
|
|
683
|
+
throw new Error("Source-mode marker exists without ownership state. Restore .loom/source-state.json or reinstall generated Loom and remove only the development.source marker.");
|
|
684
|
+
}
|
|
685
|
+
const current = await installed(cwd);
|
|
686
|
+
await validateBase(cwd, current.root);
|
|
687
|
+
state = {
|
|
688
|
+
version: 1,
|
|
689
|
+
projectRoot: cwd,
|
|
690
|
+
sourceRoot,
|
|
691
|
+
baseRoot: current.root,
|
|
692
|
+
restoreTarget: current.target,
|
|
693
|
+
baseDigest: await computePackageContentDigest(current.root),
|
|
694
|
+
phase: "preparing",
|
|
695
|
+
token: randomUUID(),
|
|
696
|
+
};
|
|
697
|
+
await ownedOverlay(cwd, state, true);
|
|
698
|
+
await writeState(cwd, state);
|
|
699
|
+
const ignore = join(cwd, ".gitignore");
|
|
700
|
+
await safeParents(cwd, ignore);
|
|
701
|
+
let text = await readFile(ignore, "utf8").catch((e) => {
|
|
702
|
+
if (e.code === "ENOENT")
|
|
703
|
+
return "";
|
|
704
|
+
throw e;
|
|
705
|
+
});
|
|
706
|
+
for (const line of [
|
|
707
|
+
".loom/source-package/",
|
|
708
|
+
".loom/source-state.json",
|
|
709
|
+
".loom/source-watch.lock*",
|
|
710
|
+
".loom/source-retired-*/",
|
|
711
|
+
".loom/dev-sync.lock*",
|
|
712
|
+
]) {
|
|
713
|
+
if (!text.split(/\r?\n/).includes(line)) {
|
|
714
|
+
text += (text.endsWith("\n") || !text ? "" : "\n") + line + "\n";
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
await atomic(cwd, ignore, text);
|
|
718
|
+
}
|
|
719
|
+
await marker(cwd, true);
|
|
720
|
+
return await synchronize(cwd, state, true);
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
/** Copies current source without rebuilding or refreshing the generated install. */
|
|
724
|
+
export async function syncSourceDev(cwd, reattach = true) {
|
|
725
|
+
cwd = await realpath(cwd);
|
|
726
|
+
return await withSourceLock(cwd, async () => {
|
|
727
|
+
const state = await stateAt(cwd);
|
|
728
|
+
if (state.phase === "leaving") {
|
|
729
|
+
throw new Error("Finish `loom dev generated` before syncing again.");
|
|
730
|
+
}
|
|
731
|
+
await marker(cwd, true);
|
|
732
|
+
return await synchronize(cwd, state, reattach);
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
/** Restores the compiled alias but retains a release block until generated sync succeeds. */
|
|
736
|
+
export async function beginGeneratedDev(cwd) {
|
|
737
|
+
cwd = await realpath(cwd);
|
|
738
|
+
return await withSourceLock(cwd, async () => {
|
|
739
|
+
const state = await stateAt(cwd);
|
|
740
|
+
const current = await installed(cwd);
|
|
741
|
+
if (current.root === join(cwd, OVERLAY)) {
|
|
742
|
+
await validateBase(cwd, state.baseRoot);
|
|
743
|
+
if ((await realpath(resolve(dirname(current.path), state.restoreTarget))) !== state.baseRoot) {
|
|
744
|
+
throw new Error("The saved compiled install disappeared. Reinstall dependencies, then retry.");
|
|
745
|
+
}
|
|
746
|
+
await link(cwd, current.path, state.restoreTarget);
|
|
747
|
+
}
|
|
748
|
+
else
|
|
749
|
+
await validateBase(cwd, current.root);
|
|
750
|
+
state.phase = "leaving";
|
|
751
|
+
await writeState(cwd, state);
|
|
752
|
+
return state;
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
/** Allows retargeting compiled output only after source alias restoration has begun. */
|
|
756
|
+
export async function assertGeneratedDevTransition(cwd) {
|
|
757
|
+
const state = await stateAt(cwd);
|
|
758
|
+
if (state.phase !== "leaving" ||
|
|
759
|
+
(await installed(cwd)).root === join(cwd, OVERLAY))
|
|
760
|
+
throw new Error("Begin the generated transition before replacing compiled output.");
|
|
761
|
+
}
|
|
762
|
+
/** Clears source ownership only after the caller proves the generated checkout/install fresh. */
|
|
763
|
+
export async function finishGeneratedDev(cwd, generatedPackagePath) {
|
|
764
|
+
cwd = await realpath(cwd);
|
|
765
|
+
await withSourceLock(cwd, async () => {
|
|
766
|
+
const state = await stateAt(cwd);
|
|
767
|
+
if (state.phase !== "leaving") {
|
|
768
|
+
throw new Error("The generated transition has not begun.");
|
|
769
|
+
}
|
|
770
|
+
const current = await installed(cwd);
|
|
771
|
+
if (current.root === join(cwd, OVERLAY)) {
|
|
772
|
+
throw new Error("The source alias is still active.");
|
|
773
|
+
}
|
|
774
|
+
await validateBase(cwd, current.root);
|
|
775
|
+
const built = generatedPackagePath ?? join(state.sourceRoot, "npm");
|
|
776
|
+
const generation = await readGeneratedBuild(built, cwd);
|
|
777
|
+
if (generation &&
|
|
778
|
+
(generation.owner.phase !== "ready" ||
|
|
779
|
+
generation.owner.sourceRoot !== state.sourceRoot))
|
|
780
|
+
throw new Error("The generated package does not belong to this source transition.");
|
|
781
|
+
const stamp = await readLoomBuildStamp(built);
|
|
782
|
+
if (!stamp ||
|
|
783
|
+
stamp.packageDigest !== (await computePackageContentDigest(built)) ||
|
|
784
|
+
stamp.sourceFingerprint !==
|
|
785
|
+
(await computeLoomSourceFingerprint(state.sourceRoot)) ||
|
|
786
|
+
(await findPackageTreeDifference(built, current.root))) {
|
|
787
|
+
throw new Error("Generated output/installed content is not fresh for this checkout; finish `loom dev generated` before clearing source mode.");
|
|
788
|
+
}
|
|
789
|
+
async function cleanRetired() {
|
|
790
|
+
if (!state.retiredPath)
|
|
791
|
+
return;
|
|
792
|
+
const retired = join(cwd, state.retiredPath);
|
|
793
|
+
if (!(await info(retired)))
|
|
794
|
+
return;
|
|
795
|
+
await safeParents(cwd, join(retired, OWNER));
|
|
796
|
+
const children = await readdir(retired);
|
|
797
|
+
if (!children.length) {
|
|
798
|
+
// A crash after deleting the owner proof but before rmdir leaves only an empty owned quarantine.
|
|
799
|
+
await assertMutation();
|
|
800
|
+
await rmdir(retired);
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
const owner = await json(join(retired, OWNER));
|
|
804
|
+
if (owner.projectRoot !== cwd || owner.token !== state.token) {
|
|
805
|
+
throw new Error("Source quarantine no longer has this project's ownership marker.");
|
|
806
|
+
}
|
|
807
|
+
// Keep ownership durable while any content remains; recursive rm could remove the proof first.
|
|
808
|
+
for (const name of children.filter((name) => name !== OWNER)) {
|
|
809
|
+
await assertMutation();
|
|
810
|
+
await rm(join(retired, name), { recursive: true, force: true });
|
|
811
|
+
}
|
|
812
|
+
await assertMutation();
|
|
813
|
+
await rm(join(retired, OWNER));
|
|
814
|
+
await assertMutation();
|
|
815
|
+
await rmdir(retired);
|
|
816
|
+
}
|
|
817
|
+
await cleanRetired();
|
|
818
|
+
await ownedOverlay(cwd, state, true);
|
|
819
|
+
await safeParents(cwd, join(cwd, OVERLAY));
|
|
820
|
+
if (await info(join(cwd, OVERLAY))) {
|
|
821
|
+
state.retiredPath = `.loom/source-retired-${randomUUID()}`;
|
|
822
|
+
await writeState(cwd, state);
|
|
823
|
+
await assertMutation();
|
|
824
|
+
await rename(join(cwd, OVERLAY), join(cwd, state.retiredPath));
|
|
825
|
+
await cleanRetired();
|
|
826
|
+
}
|
|
827
|
+
await marker(cwd, false);
|
|
828
|
+
await assertMutation();
|
|
829
|
+
await rm(join(cwd, STATE));
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
async function watcherStatus(cwd) {
|
|
833
|
+
try {
|
|
834
|
+
const path = join(cwd, ".loom/source-watch.lock");
|
|
835
|
+
const entry = await info(path);
|
|
836
|
+
if (!entry)
|
|
837
|
+
return "stopped";
|
|
838
|
+
if (entry.isSymbolicLink())
|
|
839
|
+
return "unknown";
|
|
840
|
+
const holder = await json(path);
|
|
841
|
+
if (holder.hostname !== hostname() ||
|
|
842
|
+
!Number.isSafeInteger(holder.pid) ||
|
|
843
|
+
holder.pid < 1)
|
|
844
|
+
return "unknown";
|
|
845
|
+
try {
|
|
846
|
+
process.kill(holder.pid, 0);
|
|
847
|
+
}
|
|
848
|
+
catch (error) {
|
|
849
|
+
return error.code === "ESRCH"
|
|
850
|
+
? "stopped"
|
|
851
|
+
: "unknown";
|
|
852
|
+
}
|
|
853
|
+
return Date.now() - entry.mtimeMs < 15_000 ? "running" : "unknown";
|
|
854
|
+
}
|
|
855
|
+
catch {
|
|
856
|
+
return "unknown";
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
/** Reports actual source identity; timestamps and watcher presence never imply freshness. */
|
|
860
|
+
export async function getSourceDevStatus(cwd) {
|
|
861
|
+
cwd = await realpath(cwd);
|
|
862
|
+
if (!(await sourceDevIssue(cwd))) {
|
|
863
|
+
return {
|
|
864
|
+
active: false,
|
|
865
|
+
attached: false,
|
|
866
|
+
fresh: false,
|
|
867
|
+
message: "Generated mode (default).",
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
try {
|
|
871
|
+
const state = await stateAt(cwd);
|
|
872
|
+
const current = await installed(cwd);
|
|
873
|
+
const attached = current.root === join(cwd, OVERLAY);
|
|
874
|
+
const snapshot = await sourceFiles(state.sourceRoot);
|
|
875
|
+
const base = await validateBase(cwd, state.baseRoot);
|
|
876
|
+
const mirrorFresh = await overlayMatches(cwd, state, base.pkg, base.contract, snapshot.files);
|
|
877
|
+
const fresh = attached &&
|
|
878
|
+
mirrorFresh &&
|
|
879
|
+
state.phase === "active" &&
|
|
880
|
+
state.sourceDigest === snapshot.digest &&
|
|
881
|
+
(await computeSourceSupportDigest(state.sourceRoot, base.contract.supportSources)) === base.contract.supportDigest &&
|
|
882
|
+
(await computePackageContentDigest(state.baseRoot)) === state.baseDigest;
|
|
883
|
+
return {
|
|
884
|
+
active: true,
|
|
885
|
+
attached,
|
|
886
|
+
fresh,
|
|
887
|
+
watcher: await watcherStatus(cwd),
|
|
888
|
+
state,
|
|
889
|
+
message: !attached
|
|
890
|
+
? "Source mode detached by an install; reattach and restart Next."
|
|
891
|
+
: fresh
|
|
892
|
+
? "Library source is fresh; compiled CLI/assets remain authoritative."
|
|
893
|
+
: "Source mode needs reconciliation; run `loom dev sync` or `loom dev source --watch`.",
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
catch (e) {
|
|
897
|
+
return {
|
|
898
|
+
active: true,
|
|
899
|
+
attached: false,
|
|
900
|
+
fresh: false,
|
|
901
|
+
watcher: await watcherStatus(cwd),
|
|
902
|
+
message: `Source mode needs recovery: ${e.message}`,
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
/** Foreground watcher with full polling reconciliation; never relies solely on filesystem events. */
|
|
907
|
+
export async function watchSourceDev(cwd, report, signal) {
|
|
908
|
+
cwd = await realpath(cwd);
|
|
909
|
+
await safeParents(cwd, join(cwd, ".loom/source-watch.lock"));
|
|
910
|
+
await safeParents(cwd, join(cwd, ".loom/source-watch.lock.break"));
|
|
911
|
+
await withLocalDevLock(join(cwd, ".loom/source-watch.lock"), async () => {
|
|
912
|
+
await safeParents(cwd, join(cwd, ".loom/source-watch.lock"));
|
|
913
|
+
await safeParents(cwd, join(cwd, ".loom/source-watch.lock.break"));
|
|
914
|
+
await assertGeneratedInstallerIdle(cwd);
|
|
915
|
+
const state = await stateAt(cwd);
|
|
916
|
+
let dirty = true;
|
|
917
|
+
let watcher;
|
|
918
|
+
try {
|
|
919
|
+
watcher = watch(state.sourceRoot, { recursive: true }, (_event, name) => {
|
|
920
|
+
if (name === "mod.ts" || name?.startsWith(`src${sep}`))
|
|
921
|
+
dirty = true;
|
|
922
|
+
});
|
|
923
|
+
watcher.on("error", (error) => report(`Filesystem watch unavailable (${error.message}); polling remains active.`));
|
|
924
|
+
}
|
|
925
|
+
catch (error) {
|
|
926
|
+
report(`Filesystem watch unavailable (${error.message}); polling remains active.`);
|
|
927
|
+
}
|
|
928
|
+
try {
|
|
929
|
+
let nextPoll = 0;
|
|
930
|
+
let lastError = "";
|
|
931
|
+
while (!signal?.aborted) {
|
|
932
|
+
if (dirty || Date.now() >= nextPoll) {
|
|
933
|
+
dirty = false;
|
|
934
|
+
nextPoll = Date.now() + 1_000;
|
|
935
|
+
try {
|
|
936
|
+
const result = await syncSourceDev(cwd, false);
|
|
937
|
+
if (lastError)
|
|
938
|
+
report("Source reconciliation recovered.");
|
|
939
|
+
lastError = "";
|
|
940
|
+
if (result.changed) {
|
|
941
|
+
report(`Mirrored ${result.files} source files; no package rebuild/install.`);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
catch (error) {
|
|
945
|
+
// Atomic editor saves and temporarily invalid exports must recover without restarting the watcher.
|
|
946
|
+
const currentState = await stateAt(cwd).catch(() => null);
|
|
947
|
+
if (!currentState || currentState.phase === "leaving") {
|
|
948
|
+
report("Source watching stopped: source mode is leaving or its ownership state was removed.");
|
|
949
|
+
break;
|
|
950
|
+
}
|
|
951
|
+
if ((await installed(cwd)).root !== join(cwd, OVERLAY))
|
|
952
|
+
throw error;
|
|
953
|
+
const message = error.message;
|
|
954
|
+
if (message !== lastError) {
|
|
955
|
+
report(`Source reconciliation blocked: ${message}`);
|
|
956
|
+
}
|
|
957
|
+
lastError = message;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
await new Promise((done) => setTimeout(done, 50));
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
finally {
|
|
964
|
+
watcher?.close();
|
|
965
|
+
}
|
|
966
|
+
}, {
|
|
967
|
+
// The shared lock observes an unrefreshed dead holder for 12s before breaking it.
|
|
968
|
+
// A shorter timeout would make a killed watcher's lock permanently unrecoverable.
|
|
969
|
+
timeoutMs: 30_000,
|
|
970
|
+
strict: await hasGeneratedDevState(cwd),
|
|
971
|
+
onWait: () => report("Waiting for the source watcher lease; a stale/dead watcher is recovered after observation."),
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
//# sourceMappingURL=sourceDev.js.map
|