alchemy 2.0.0-beta.84 → 2.0.0-beta.85
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/THIRD_PARTY_LICENSES.md +2 -2
- package/bin/cli.js +14 -6
- package/bin/register-oxc.js +16 -12
- package/lib/AdoptPolicy.d.ts +73 -0
- package/lib/AdoptPolicy.d.ts.map +1 -1
- package/lib/AdoptPolicy.js +54 -0
- package/lib/AdoptPolicy.js.map +1 -1
- package/lib/Alchemist/AuthRegistry.d.ts +31 -0
- package/lib/Alchemist/AuthRegistry.d.ts.map +1 -0
- package/lib/Alchemist/AuthRegistry.js +95 -0
- package/lib/Alchemist/AuthRegistry.js.map +1 -0
- package/lib/Alchemist/Drift.d.ts +70 -0
- package/lib/Alchemist/Drift.d.ts.map +1 -0
- package/lib/Alchemist/Drift.js +54 -0
- package/lib/Alchemist/Drift.js.map +1 -0
- package/lib/Alchemist/Entrypoint.d.ts +27 -3
- package/lib/Alchemist/Entrypoint.d.ts.map +1 -1
- package/lib/Alchemist/Entrypoint.js +34 -3
- package/lib/Alchemist/Entrypoint.js.map +1 -1
- package/lib/Alchemist/Errors.d.ts +1 -1
- package/lib/Alchemist/Errors.d.ts.map +1 -1
- package/lib/Alchemist/Errors.js +1 -1
- package/lib/Alchemist/Errors.js.map +1 -1
- package/lib/Alchemist/Logs.d.ts +46 -0
- package/lib/Alchemist/Logs.d.ts.map +1 -0
- package/lib/Alchemist/{routes/logs.js → Logs.js} +21 -26
- package/lib/Alchemist/Logs.js.map +1 -0
- package/lib/Alchemist/Nuke.d.ts +69 -0
- package/lib/Alchemist/Nuke.d.ts.map +1 -0
- package/lib/Alchemist/Nuke.js +35 -0
- package/lib/Alchemist/Nuke.js.map +1 -0
- package/lib/Alchemist/Operations.d.ts +168 -0
- package/lib/Alchemist/Operations.d.ts.map +1 -0
- package/lib/Alchemist/Operations.js +165 -0
- package/lib/Alchemist/Operations.js.map +1 -0
- package/lib/Alchemist/Profile.d.ts +132 -0
- package/lib/Alchemist/Profile.d.ts.map +1 -0
- package/lib/Alchemist/{routes/profile.js → Profile.js} +20 -21
- package/lib/Alchemist/Profile.js.map +1 -0
- package/lib/Alchemist/{routes/provider.d.ts → Provider.d.ts} +4 -4
- package/lib/Alchemist/Provider.d.ts.map +1 -0
- package/lib/Alchemist/{routes/provider.js → Provider.js} +7 -6
- package/lib/Alchemist/Provider.js.map +1 -0
- package/lib/Alchemist/Runtime.d.ts +10 -6
- package/lib/Alchemist/Runtime.d.ts.map +1 -1
- package/lib/Alchemist/Runtime.js +38 -2
- package/lib/Alchemist/Runtime.js.map +1 -1
- package/lib/Alchemist/{routes/state.d.ts → State.d.ts} +36 -16
- package/lib/Alchemist/State.d.ts.map +1 -0
- package/lib/Alchemist/{routes/state.js → State.js} +50 -15
- package/lib/Alchemist/State.js.map +1 -0
- package/lib/Alchemist/index.d.ts +11 -10
- package/lib/Alchemist/index.d.ts.map +1 -1
- package/lib/Alchemist/index.js +10 -9
- package/lib/Alchemist/index.js.map +1 -1
- package/lib/Apply.d.ts +2 -8
- package/lib/Apply.d.ts.map +1 -1
- package/lib/Apply.js +364 -184
- package/lib/Apply.js.map +1 -1
- package/lib/Auth/AuthProvider.d.ts +24 -11
- package/lib/Auth/AuthProvider.d.ts.map +1 -1
- package/lib/Auth/AuthProvider.js +28 -12
- package/lib/Auth/AuthProvider.js.map +1 -1
- package/lib/Auth/BrowserOAuth.d.ts +6 -8
- package/lib/Auth/BrowserOAuth.d.ts.map +1 -1
- package/lib/Auth/BrowserOAuth.js +25 -41
- package/lib/Auth/BrowserOAuth.js.map +1 -1
- package/lib/Auth/Credentials.d.ts.map +1 -1
- package/lib/Auth/Credentials.js +2 -2
- package/lib/Auth/Credentials.js.map +1 -1
- package/lib/Auth/Demand.d.ts +4 -4
- package/lib/Auth/Demand.d.ts.map +1 -1
- package/lib/Auth/Demand.js +16 -10
- package/lib/Auth/Demand.js.map +1 -1
- package/lib/Auth/Env.d.ts +2 -1
- package/lib/Auth/Env.d.ts.map +1 -1
- package/lib/Auth/Env.js +4 -2
- package/lib/Auth/Env.js.map +1 -1
- package/lib/Auth/Inspect.d.ts +2 -2
- package/lib/Auth/Inspect.d.ts.map +1 -1
- package/lib/Auth/Inspect.js +3 -1
- package/lib/Auth/Inspect.js.map +1 -1
- package/lib/Auth/Lock.d.ts.map +1 -1
- package/lib/Auth/Lock.js +4 -8
- package/lib/Auth/Lock.js.map +1 -1
- package/lib/Auth/OAuthFlow.d.ts +3 -12
- package/lib/Auth/OAuthFlow.d.ts.map +1 -1
- package/lib/Auth/OAuthFlow.js +7 -17
- package/lib/Auth/OAuthFlow.js.map +1 -1
- package/lib/Auth/Paths.d.ts +2 -1
- package/lib/Auth/Paths.d.ts.map +1 -1
- package/lib/Auth/Paths.js +3 -2
- package/lib/Auth/Paths.js.map +1 -1
- package/lib/Auth/Profile.d.ts +10 -0
- package/lib/Auth/Profile.d.ts.map +1 -1
- package/lib/Auth/Profile.js +19 -2
- package/lib/Auth/Profile.js.map +1 -1
- package/lib/Auth/Registry.d.ts +20 -0
- package/lib/Auth/Registry.d.ts.map +1 -0
- package/lib/Auth/Registry.js +17 -0
- package/lib/Auth/Registry.js.map +1 -0
- package/lib/Auth/Resolve.d.ts +34 -2
- package/lib/Auth/Resolve.d.ts.map +1 -1
- package/lib/Auth/Resolve.js +51 -3
- package/lib/Auth/Resolve.js.map +1 -1
- package/lib/Auth/StoredAuthProvider.d.ts +1 -1
- package/lib/Auth/StoredAuthProvider.d.ts.map +1 -1
- package/lib/Auth/StoredAuthProvider.js +1 -2
- package/lib/Auth/StoredAuthProvider.js.map +1 -1
- package/lib/Binding.d.ts.map +1 -1
- package/lib/Binding.js +3 -1
- package/lib/Binding.js.map +1 -1
- package/lib/Bundle/Bundle.d.ts +5 -0
- package/lib/Bundle/Bundle.d.ts.map +1 -1
- package/lib/Bundle/Bundle.js +36 -6
- package/lib/Bundle/Bundle.js.map +1 -1
- package/lib/Bundle/NamespaceImportPlugin.d.ts +55 -0
- package/lib/Bundle/NamespaceImportPlugin.d.ts.map +1 -0
- package/lib/Bundle/NamespaceImportPlugin.js +226 -0
- package/lib/Bundle/NamespaceImportPlugin.js.map +1 -0
- package/lib/Bundle/index.d.ts +1 -0
- package/lib/Bundle/index.d.ts.map +1 -1
- package/lib/Bundle/index.js +1 -0
- package/lib/Bundle/index.js.map +1 -1
- package/lib/Cli/Format.d.ts.map +1 -1
- package/lib/Cli/Format.js +2 -1
- package/lib/Cli/Format.js.map +1 -1
- package/lib/Cli/GlobalLog.d.ts +72 -26
- package/lib/Cli/GlobalLog.d.ts.map +1 -1
- package/lib/Cli/GlobalLog.js +151 -59
- package/lib/Cli/GlobalLog.js.map +1 -1
- package/lib/Cli/LoggingCli.d.ts.map +1 -1
- package/lib/Cli/LoggingCli.js +24 -18
- package/lib/Cli/LoggingCli.js.map +1 -1
- package/lib/Cli/PlainCliFormatter.d.ts.map +1 -1
- package/lib/Cli/PlainCliFormatter.js +4 -1
- package/lib/Cli/PlainCliFormatter.js.map +1 -1
- package/lib/Cli/Present.d.ts +14 -0
- package/lib/Cli/Present.d.ts.map +1 -0
- package/lib/Cli/Present.js +22 -0
- package/lib/Cli/Present.js.map +1 -0
- package/lib/Cli/SigilRenderer.d.ts +58 -0
- package/lib/Cli/SigilRenderer.d.ts.map +1 -0
- package/lib/Cli/SigilRenderer.js +39 -0
- package/lib/Cli/SigilRenderer.js.map +1 -0
- package/lib/Cli/checkVersion.d.ts +11 -14
- package/lib/Cli/checkVersion.d.ts.map +1 -1
- package/lib/Cli/checkVersion.js +19 -77
- package/lib/Cli/checkVersion.js.map +1 -1
- package/lib/Cli/commands/confirm.d.ts +2 -2
- package/lib/Cli/commands/confirm.d.ts.map +1 -1
- package/lib/Cli/commands/confirm.js +3 -3
- package/lib/Cli/commands/confirm.js.map +1 -1
- package/lib/Cli/commands/deploy.d.ts +4 -4
- package/lib/Cli/commands/deploy.d.ts.map +1 -1
- package/lib/Cli/commands/deploy.js +40 -39
- package/lib/Cli/commands/deploy.js.map +1 -1
- package/lib/Cli/commands/dev.d.ts.map +1 -1
- package/lib/Cli/commands/dev.js +41 -3
- package/lib/Cli/commands/dev.js.map +1 -1
- package/lib/Cli/commands/drift.d.ts +2 -2
- package/lib/Cli/commands/drift.d.ts.map +1 -1
- package/lib/Cli/commands/drift.js +14 -13
- package/lib/Cli/commands/drift.js.map +1 -1
- package/lib/Cli/commands/errors.d.ts.map +1 -1
- package/lib/Cli/commands/errors.js +2 -1
- package/lib/Cli/commands/errors.js.map +1 -1
- package/lib/Cli/commands/instrument.d.ts +15 -5
- package/lib/Cli/commands/instrument.d.ts.map +1 -1
- package/lib/Cli/commands/instrument.js +33 -8
- package/lib/Cli/commands/instrument.js.map +1 -1
- package/lib/Cli/commands/logs.d.ts +1 -1
- package/lib/Cli/commands/logs.d.ts.map +1 -1
- package/lib/Cli/commands/logs.js +22 -22
- package/lib/Cli/commands/logs.js.map +1 -1
- package/lib/Cli/commands/nuke.d.ts +3 -2
- package/lib/Cli/commands/nuke.d.ts.map +1 -1
- package/lib/Cli/commands/nuke.js +19 -17
- package/lib/Cli/commands/nuke.js.map +1 -1
- package/lib/Cli/commands/profile/commands.d.ts +3 -2
- package/lib/Cli/commands/profile/commands.d.ts.map +1 -1
- package/lib/Cli/commands/profile/commands.js +26 -27
- package/lib/Cli/commands/profile/commands.js.map +1 -1
- package/lib/Cli/commands/profile/flows.d.ts +6 -5
- package/lib/Cli/commands/profile/flows.d.ts.map +1 -1
- package/lib/Cli/commands/profile/flows.js +19 -17
- package/lib/Cli/commands/profile/flows.js.map +1 -1
- package/lib/Cli/commands/profile/hub.d.ts +1 -2
- package/lib/Cli/commands/profile/hub.d.ts.map +1 -1
- package/lib/Cli/commands/profile/hub.js +15 -17
- package/lib/Cli/commands/profile/hub.js.map +1 -1
- package/lib/Cli/commands/provider.d.ts +3 -1
- package/lib/Cli/commands/provider.d.ts.map +1 -1
- package/lib/Cli/commands/provider.js +4 -4
- package/lib/Cli/commands/provider.js.map +1 -1
- package/lib/Cli/commands/render.d.ts +2 -4
- package/lib/Cli/commands/render.d.ts.map +1 -1
- package/lib/Cli/commands/render.js +33 -56
- package/lib/Cli/commands/render.js.map +1 -1
- package/lib/Cli/commands/state.d.ts +1 -2
- package/lib/Cli/commands/state.d.ts.map +1 -1
- package/lib/Cli/commands/state.js +74 -27
- package/lib/Cli/commands/state.js.map +1 -1
- package/lib/Cli/components/capabilities.d.ts +4 -0
- package/lib/Cli/components/capabilities.d.ts.map +1 -0
- package/lib/Cli/components/capabilities.js +18 -0
- package/lib/Cli/components/capabilities.js.map +1 -0
- package/lib/Cli/components/types.d.ts +2 -81
- package/lib/Cli/components/types.d.ts.map +1 -1
- package/lib/Cli/components/types.js +1 -3
- package/lib/Cli/components/types.js.map +1 -1
- package/lib/Cli/components/ui/Environment.d.ts +3 -3
- package/lib/Cli/components/ui/Environment.d.ts.map +1 -1
- package/lib/Cli/components/ui/Environment.js.map +1 -1
- package/lib/Cli/components/ui/Interactive.d.ts +17 -4
- package/lib/Cli/components/ui/Interactive.d.ts.map +1 -1
- package/lib/Cli/components/ui/Interactive.js +7 -11
- package/lib/Cli/components/ui/Interactive.js.map +1 -1
- package/lib/Cli/components/ui/Layout.d.ts +1 -1
- package/lib/Cli/components/ui/Layout.d.ts.map +1 -1
- package/lib/Cli/components/ui/Layout.js +1 -1
- package/lib/Cli/components/ui/Layout.js.map +1 -1
- package/lib/Cli/components/ui/Typography.d.ts +1 -1
- package/lib/Cli/components/ui/Typography.d.ts.map +1 -1
- package/lib/Cli/components/ui/Typography.js +1 -1
- package/lib/Cli/components/ui/Typography.js.map +1 -1
- package/lib/Cli/components/ui/index.d.ts +2 -2
- package/lib/Cli/components/ui/index.js +2 -2
- package/lib/Cli/components/view/ApprovePlan.d.ts +1 -1
- package/lib/Cli/components/view/ApprovePlan.d.ts.map +1 -1
- package/lib/Cli/components/view/ApprovePlan.js +2 -1
- package/lib/Cli/components/view/ApprovePlan.js.map +1 -1
- package/lib/Cli/components/view/Format.d.ts +5 -0
- package/lib/Cli/components/view/Format.d.ts.map +1 -0
- package/lib/Cli/components/view/Format.js +39 -0
- package/lib/Cli/components/view/Format.js.map +1 -0
- package/lib/Cli/components/view/Help.d.ts +2 -2
- package/lib/Cli/components/view/Help.d.ts.map +1 -1
- package/lib/Cli/components/view/Help.js +7 -5
- package/lib/Cli/components/view/Help.js.map +1 -1
- package/lib/Cli/components/view/Logo.js +1 -1
- package/lib/Cli/components/view/Logo.js.map +1 -1
- package/lib/Cli/components/view/Nuke.d.ts +8 -9
- package/lib/Cli/components/view/Nuke.d.ts.map +1 -1
- package/lib/Cli/components/view/Nuke.js +49 -52
- package/lib/Cli/components/view/Nuke.js.map +1 -1
- package/lib/Cli/components/view/PlanDecision.d.ts +1 -1
- package/lib/Cli/components/view/PlanDecision.d.ts.map +1 -1
- package/lib/Cli/components/view/PlanDecision.js +1 -1
- package/lib/Cli/components/view/PlanDecision.js.map +1 -1
- package/lib/Cli/components/view/PlanRow.js +1 -1
- package/lib/Cli/components/view/PlanRow.js.map +1 -1
- package/lib/Cli/components/view/PlanTree.d.ts +1 -1
- package/lib/Cli/components/view/PlanTree.d.ts.map +1 -1
- package/lib/Cli/components/view/PlanTree.js +1 -1
- package/lib/Cli/components/view/PlanView.js +1 -1
- package/lib/Cli/components/view/PlanView.js.map +1 -1
- package/lib/Cli/components/view/Profile.d.ts +1 -1
- package/lib/Cli/components/view/Profile.js +2 -2
- package/lib/Cli/components/view/Profile.js.map +1 -1
- package/lib/Cli/components/view/ProfileDashboard.d.ts +4 -4
- package/lib/Cli/components/view/ProfileDashboard.d.ts.map +1 -1
- package/lib/Cli/components/view/ProfileDashboard.js +9 -8
- package/lib/Cli/components/view/ProfileDashboard.js.map +1 -1
- package/lib/Cli/components/view/Prompts.d.ts +3 -3
- package/lib/Cli/components/view/Prompts.d.ts.map +1 -1
- package/lib/Cli/components/view/Prompts.js +11 -18
- package/lib/Cli/components/view/Prompts.js.map +1 -1
- package/lib/Cli/components/view/Runtime.d.ts +5 -5
- package/lib/Cli/components/view/Runtime.d.ts.map +1 -1
- package/lib/Cli/components/view/Runtime.js +136 -219
- package/lib/Cli/components/view/Runtime.js.map +1 -1
- package/lib/Cli/components/view/SigilCli.d.ts +2 -2
- package/lib/Cli/components/view/SigilCli.d.ts.map +1 -1
- package/lib/Cli/components/view/SigilCli.js +7 -7
- package/lib/Cli/components/view/SigilCli.js.map +1 -1
- package/lib/Cli/components/view/StateExplorer.d.ts +1 -1
- package/lib/Cli/components/view/StateExplorer.d.ts.map +1 -1
- package/lib/Cli/components/view/StateExplorer.js +2 -1
- package/lib/Cli/components/view/StateExplorer.js.map +1 -1
- package/lib/Cli/components/view/statusStyle.d.ts +2 -2
- package/lib/Cli/components/view/statusStyle.d.ts.map +1 -1
- package/lib/Cli/components/view/statusStyle.js +1 -1
- package/lib/Cli/components/view/statusStyle.js.map +1 -1
- package/lib/Cli/exec.d.ts +6 -1
- package/lib/Cli/exec.d.ts.map +1 -1
- package/lib/Cli/exec.js +29 -34
- package/lib/Cli/exec.js.map +1 -1
- package/lib/Cli/main.d.ts.map +1 -1
- package/lib/Cli/main.js +35 -26
- package/lib/Cli/main.js.map +1 -1
- package/lib/Cli/selectCli.d.ts +2 -2
- package/lib/Cli/selectCli.d.ts.map +1 -1
- package/lib/Cli/selectCli.js +2 -2
- package/lib/Cli/selectCli.js.map +1 -1
- package/lib/Command/Command.js +1 -1
- package/lib/Command/Command.js.map +1 -1
- package/lib/Command/Dev.d.ts +58 -4
- package/lib/Command/Dev.d.ts.map +1 -1
- package/lib/Command/Dev.js +87 -30
- package/lib/Command/Dev.js.map +1 -1
- package/lib/Command/Local.d.ts +1 -1
- package/lib/Command/Memo.js +1 -1
- package/lib/Command/Memo.js.map +1 -1
- package/lib/Command/Providers.d.ts +1 -1
- package/lib/Command/Providers.d.ts.map +1 -1
- package/lib/Contributions.d.ts +2 -3
- package/lib/Contributions.d.ts.map +1 -1
- package/lib/Contributions.js +38 -6
- package/lib/Contributions.js.map +1 -1
- package/lib/DNS/Adapter.d.ts +204 -0
- package/lib/DNS/Adapter.d.ts.map +1 -0
- package/lib/DNS/Adapter.js +112 -0
- package/lib/DNS/Adapter.js.map +1 -0
- package/lib/DNS/index.d.ts +2 -0
- package/lib/DNS/index.d.ts.map +1 -0
- package/lib/DNS/index.js +2 -0
- package/lib/DNS/index.js.map +1 -0
- package/lib/Deploy.d.ts +7 -2
- package/lib/Deploy.d.ts.map +1 -1
- package/lib/Deploy.js +8 -3
- package/lib/Deploy.js.map +1 -1
- package/lib/Destroy.d.ts +5 -8
- package/lib/Destroy.d.ts.map +1 -1
- package/lib/Destroy.js +10 -7
- package/lib/Destroy.js.map +1 -1
- package/lib/Diff.d.ts.map +1 -1
- package/lib/Diff.js +14 -4
- package/lib/Diff.js.map +1 -1
- package/lib/Drift.d.ts +7 -7
- package/lib/Drift.d.ts.map +1 -1
- package/lib/Drift.js +184 -101
- package/lib/Drift.js.map +1 -1
- package/lib/EvalStack.d.ts +23 -0
- package/lib/EvalStack.d.ts.map +1 -0
- package/lib/EvalStack.js +47 -0
- package/lib/EvalStack.js.map +1 -0
- package/lib/Events.d.ts +210 -0
- package/lib/Events.d.ts.map +1 -0
- package/lib/Events.js +244 -0
- package/lib/Events.js.map +1 -0
- package/lib/Interaction.d.ts +159 -48
- package/lib/Interaction.d.ts.map +1 -1
- package/lib/Interaction.js +139 -58
- package/lib/Interaction.js.map +1 -1
- package/lib/Local/LocalProvider.d.ts.map +1 -1
- package/lib/Local/LocalProvider.js +31 -9
- package/lib/Local/LocalProvider.js.map +1 -1
- package/lib/Local/RpcProvider.d.ts.map +1 -1
- package/lib/Local/RpcProvider.js +10 -1
- package/lib/Local/RpcProvider.js.map +1 -1
- package/lib/Local/RpcProviderProxy.d.ts +16 -0
- package/lib/Local/RpcProviderProxy.d.ts.map +1 -1
- package/lib/Local/RpcProviderProxy.js +19 -10
- package/lib/Local/RpcProviderProxy.js.map +1 -1
- package/lib/Local/RpcSerialization.d.ts +3 -2
- package/lib/Local/RpcSerialization.d.ts.map +1 -1
- package/lib/Local/RpcSerialization.js +13 -10
- package/lib/Local/RpcSerialization.js.map +1 -1
- package/lib/Local/RpcServer.d.ts +2 -1
- package/lib/Local/RpcServer.d.ts.map +1 -1
- package/lib/Local/RpcServer.js +19 -14
- package/lib/Local/RpcServer.js.map +1 -1
- package/lib/Local/RpcServerBun.d.ts.map +1 -1
- package/lib/Local/RpcServerBun.js +8 -4
- package/lib/Local/RpcServerBun.js.map +1 -1
- package/lib/Local/RpcServerEnvironment.d.ts +2 -3
- package/lib/Local/RpcServerEnvironment.d.ts.map +1 -1
- package/lib/Local/RpcServerEnvironment.js +2 -2
- package/lib/Local/RpcServerEnvironment.js.map +1 -1
- package/lib/Local/RpcServerNode.d.ts.map +1 -1
- package/lib/Local/RpcServerNode.js +5 -1
- package/lib/Local/RpcServerNode.js.map +1 -1
- package/lib/Local/RpcServerSession.d.ts +1 -1
- package/lib/Local/RpcServerSession.d.ts.map +1 -1
- package/lib/Local/RpcServerSession.js.map +1 -1
- package/lib/Local/RpcSpawner.d.ts +6 -8
- package/lib/Local/RpcSpawner.d.ts.map +1 -1
- package/lib/Local/RpcSpawner.js +45 -36
- package/lib/Local/RpcSpawner.js.map +1 -1
- package/lib/Local/Sidecar.d.ts +23 -0
- package/lib/Local/Sidecar.d.ts.map +1 -1
- package/lib/Local/Sidecar.js +14 -9
- package/lib/Local/Sidecar.js.map +1 -1
- package/lib/Nuke.d.ts +5 -23
- package/lib/Nuke.d.ts.map +1 -1
- package/lib/Nuke.js +48 -13
- package/lib/Nuke.js.map +1 -1
- package/lib/Output.d.ts +19 -1
- package/lib/Output.d.ts.map +1 -1
- package/lib/Output.js +96 -3
- package/lib/Output.js.map +1 -1
- package/lib/Plan.d.ts +5 -1
- package/lib/Plan.d.ts.map +1 -1
- package/lib/Plan.js +111 -33
- package/lib/Plan.js.map +1 -1
- package/lib/Platform.d.ts.map +1 -1
- package/lib/Platform.js +31 -7
- package/lib/Platform.js.map +1 -1
- package/lib/Provider.d.ts +45 -0
- package/lib/Provider.d.ts.map +1 -1
- package/lib/Provider.js +2 -2
- package/lib/Provider.js.map +1 -1
- package/lib/Report.d.ts +17 -195
- package/lib/Report.d.ts.map +1 -1
- package/lib/Report.js +39 -12
- package/lib/Report.js.map +1 -1
- package/lib/Runtime/ManagedHttpShutdown.d.ts +17 -0
- package/lib/Runtime/ManagedHttpShutdown.d.ts.map +1 -1
- package/lib/Runtime/ManagedHttpShutdown.js +11 -2
- package/lib/Runtime/ManagedHttpShutdown.js.map +1 -1
- package/lib/RuntimeContext.js +1 -1
- package/lib/RuntimeContext.js.map +1 -1
- package/lib/Stack.d.ts +49 -29
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js +25 -31
- package/lib/Stack.js.map +1 -1
- package/lib/State/BucketState.d.ts.map +1 -1
- package/lib/State/BucketState.js +43 -14
- package/lib/State/BucketState.js.map +1 -1
- package/lib/State/LocalState.d.ts.map +1 -1
- package/lib/State/LocalState.js +3 -3
- package/lib/State/LocalState.js.map +1 -1
- package/lib/State/Provisioning.d.ts +5 -0
- package/lib/State/Provisioning.d.ts.map +1 -1
- package/lib/State/Provisioning.js +3 -1
- package/lib/State/Provisioning.js.map +1 -1
- package/lib/State/ResourceState.d.ts +2 -0
- package/lib/State/ResourceState.d.ts.map +1 -1
- package/lib/State/State.d.ts +26 -0
- package/lib/State/State.d.ts.map +1 -1
- package/lib/State/StateEncoding.d.ts +7 -0
- package/lib/State/StateEncoding.d.ts.map +1 -1
- package/lib/State/StateEncoding.js +19 -0
- package/lib/State/StateEncoding.js.map +1 -1
- package/lib/State/index.js +2 -2
- package/lib/State/index.js.map +1 -1
- package/lib/Telemetry/Layer.d.ts +2 -5
- package/lib/Telemetry/Layer.d.ts.map +1 -1
- package/lib/Telemetry/Layer.js +3 -23
- package/lib/Telemetry/Layer.js.map +1 -1
- package/lib/Telemetry/Metrics.d.ts +1 -1
- package/lib/Telemetry/Metrics.d.ts.map +1 -1
- package/lib/TelemetryRelay.js +1 -1
- package/lib/TelemetryRelay.js.map +1 -1
- package/lib/TelemetryRuntime.d.ts +1 -1
- package/lib/TelemetryRuntime.d.ts.map +1 -1
- package/lib/TelemetryRuntime.js +4 -3
- package/lib/TelemetryRuntime.js.map +1 -1
- package/lib/Util/ConsoleSink.d.ts +23 -2
- package/lib/Util/ConsoleSink.d.ts.map +1 -1
- package/lib/Util/ConsoleSink.js +54 -14
- package/lib/Util/ConsoleSink.js.map +1 -1
- package/lib/Util/LogAnnotation.d.ts +19 -0
- package/lib/Util/LogAnnotation.d.ts.map +1 -0
- package/lib/Util/LogAnnotation.js +19 -0
- package/lib/Util/LogAnnotation.js.map +1 -0
- package/lib/Util/LogRecord.d.ts +281 -0
- package/lib/Util/LogRecord.d.ts.map +1 -0
- package/lib/Util/LogRecord.js +267 -0
- package/lib/Util/LogRecord.js.map +1 -0
- package/lib/Util/Node.d.ts +9 -0
- package/lib/Util/Node.d.ts.map +1 -1
- package/lib/Util/Node.js +10 -6
- package/lib/Util/Node.js.map +1 -1
- package/lib/Util/PlatformServices.d.ts +3 -2
- package/lib/Util/PlatformServices.d.ts.map +1 -1
- package/lib/Util/PlatformServices.js +6 -2
- package/lib/Util/PlatformServices.js.map +1 -1
- package/lib/Util/ResourceOutput.d.ts +18 -10
- package/lib/Util/ResourceOutput.d.ts.map +1 -1
- package/lib/Util/ResourceOutput.js +22 -23
- package/lib/Util/ResourceOutput.js.map +1 -1
- package/lib/Util/Shutdown.d.ts +10 -0
- package/lib/Util/Shutdown.d.ts.map +1 -0
- package/lib/Util/Shutdown.js +32 -0
- package/lib/Util/Shutdown.js.map +1 -0
- package/lib/Util/Terminal.d.ts +2 -4
- package/lib/Util/Terminal.d.ts.map +1 -1
- package/lib/Util/Terminal.js +3 -11
- package/lib/Util/Terminal.js.map +1 -1
- package/lib/Util/TraceParent.d.ts +32 -0
- package/lib/Util/TraceParent.d.ts.map +1 -0
- package/lib/Util/TraceParent.js +42 -0
- package/lib/Util/TraceParent.js.map +1 -0
- package/lib/Util/base64.d.ts +7 -0
- package/lib/Util/base64.d.ts.map +1 -0
- package/lib/Util/base64.js +24 -0
- package/lib/Util/base64.js.map +1 -0
- package/lib/Util/cached-function.d.ts +5 -0
- package/lib/Util/cached-function.d.ts.map +1 -1
- package/lib/Util/cached-function.js +13 -8
- package/lib/Util/cached-function.js.map +1 -1
- package/lib/Util/data.d.ts +1 -1
- package/lib/Util/data.d.ts.map +1 -1
- package/lib/Util/data.js +1 -1
- package/lib/Util/data.js.map +1 -1
- package/lib/Util/equal.d.ts.map +1 -1
- package/lib/Util/equal.js +3 -2
- package/lib/Util/equal.js.map +1 -1
- package/lib/Util/extraFiles.d.ts.map +1 -1
- package/lib/Util/extraFiles.js +5 -5
- package/lib/Util/extraFiles.js.map +1 -1
- package/lib/Util/interactive.js +1 -1
- package/lib/Website/AstroOutput.d.ts +42 -0
- package/lib/Website/AstroOutput.d.ts.map +1 -0
- package/lib/Website/AstroOutput.js +34 -0
- package/lib/Website/AstroOutput.js.map +1 -0
- package/lib/Website/FrontendCore.d.ts +1 -1
- package/lib/Workflows.d.ts +9 -0
- package/lib/Workflows.d.ts.map +1 -1
- package/lib/Workflows.js +8 -0
- package/lib/Workflows.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +21 -28
- package/src/AdoptPolicy.ts +76 -0
- package/src/Alchemist/AuthRegistry.ts +164 -0
- package/src/Alchemist/Drift.ts +103 -0
- package/src/Alchemist/Entrypoint.ts +51 -3
- package/src/Alchemist/Errors.ts +1 -1
- package/src/Alchemist/{routes/logs.ts → Logs.ts} +28 -30
- package/src/Alchemist/Nuke.ts +90 -0
- package/src/Alchemist/Operations.ts +309 -0
- package/src/Alchemist/{routes/profile.ts → Profile.ts} +22 -22
- package/src/Alchemist/{routes/provider.ts → Provider.ts} +7 -6
- package/src/Alchemist/Runtime.ts +46 -12
- package/src/Alchemist/{routes/state.ts → State.ts} +78 -21
- package/src/Alchemist/index.ts +32 -15
- package/src/Apply.ts +513 -274
- package/src/Auth/AuthProvider.ts +76 -23
- package/src/Auth/BrowserOAuth.ts +37 -60
- package/src/Auth/Credentials.ts +2 -4
- package/src/Auth/Demand.ts +27 -18
- package/src/Auth/Env.ts +13 -8
- package/src/Auth/Inspect.ts +5 -2
- package/src/Auth/Lock.ts +4 -8
- package/src/Auth/OAuthFlow.ts +12 -26
- package/src/Auth/Paths.ts +3 -2
- package/src/Auth/Profile.ts +30 -2
- package/src/Auth/Registry.ts +27 -0
- package/src/Auth/Resolve.ts +75 -3
- package/src/Auth/StoredAuthProvider.ts +1 -2
- package/src/Binding.ts +3 -4
- package/src/Bundle/Bundle.ts +58 -7
- package/src/Bundle/NamespaceImportPlugin.ts +259 -0
- package/src/Bundle/index.ts +1 -0
- package/src/Cli/Format.ts +2 -1
- package/src/Cli/GlobalLog.ts +206 -68
- package/src/Cli/LoggingCli.ts +33 -20
- package/src/Cli/PlainCliFormatter.ts +4 -1
- package/src/Cli/Present.ts +34 -0
- package/src/Cli/SigilRenderer.ts +75 -0
- package/src/Cli/checkVersion.ts +25 -78
- package/src/Cli/commands/confirm.ts +3 -3
- package/src/Cli/commands/deploy.ts +53 -44
- package/src/Cli/commands/dev.ts +65 -7
- package/src/Cli/commands/drift.ts +20 -16
- package/src/Cli/commands/errors.ts +2 -3
- package/src/Cli/commands/instrument.ts +39 -8
- package/src/Cli/commands/logs.ts +22 -30
- package/src/Cli/commands/nuke.ts +25 -26
- package/src/Cli/commands/profile/commands.ts +34 -34
- package/src/Cli/commands/profile/flows.ts +26 -20
- package/src/Cli/commands/profile/hub.ts +16 -18
- package/src/Cli/commands/provider.ts +4 -4
- package/src/Cli/commands/render.ts +43 -71
- package/src/Cli/commands/state.ts +113 -33
- package/src/Cli/components/capabilities.ts +20 -0
- package/src/Cli/components/types.ts +13 -99
- package/src/Cli/components/ui/Environment.tsx +5 -5
- package/src/Cli/components/ui/Interactive.tsx +24 -15
- package/src/Cli/components/ui/Layout.tsx +1 -1
- package/src/Cli/components/ui/Typography.tsx +1 -1
- package/src/Cli/components/ui/index.ts +2 -2
- package/src/Cli/components/view/ApprovePlan.tsx +2 -1
- package/src/Cli/components/view/Format.tsx +58 -0
- package/src/Cli/components/view/Help.tsx +14 -17
- package/src/Cli/components/view/Logo.tsx +1 -1
- package/src/Cli/components/view/Nuke.tsx +74 -49
- package/src/Cli/components/view/PlanDecision.tsx +1 -1
- package/src/Cli/components/view/PlanRow.tsx +1 -1
- package/src/Cli/components/view/PlanTree.ts +2 -2
- package/src/Cli/components/view/PlanView.tsx +2 -2
- package/src/Cli/components/view/Profile.tsx +2 -2
- package/src/Cli/components/view/ProfileDashboard.tsx +12 -11
- package/src/Cli/components/view/Prompts.tsx +37 -75
- package/src/Cli/components/view/Runtime.tsx +132 -238
- package/src/Cli/components/view/SigilCli.tsx +12 -12
- package/src/Cli/components/view/StateExplorer.tsx +2 -1
- package/src/Cli/components/view/statusStyle.ts +2 -2
- package/src/Cli/exec.ts +48 -41
- package/src/Cli/main.ts +52 -33
- package/src/Cli/selectCli.ts +3 -3
- package/src/Command/Command.ts +1 -1
- package/src/Command/Dev.ts +129 -36
- package/src/Command/Memo.ts +1 -1
- package/src/Contributions.ts +42 -8
- package/src/DNS/Adapter.ts +289 -0
- package/src/DNS/index.ts +1 -0
- package/src/Deploy.ts +11 -3
- package/src/Destroy.ts +19 -13
- package/src/Diff.ts +17 -4
- package/src/Drift.ts +256 -127
- package/src/EvalStack.ts +97 -0
- package/src/Events.ts +296 -0
- package/src/Interaction.ts +332 -97
- package/src/Local/LocalProvider.ts +40 -9
- package/src/Local/RpcProvider.ts +11 -1
- package/src/Local/RpcProviderProxy.ts +29 -21
- package/src/Local/RpcSerialization.ts +32 -17
- package/src/Local/RpcServer.ts +25 -17
- package/src/Local/RpcServerBun.ts +10 -6
- package/src/Local/RpcServerEnvironment.ts +2 -2
- package/src/Local/RpcServerNode.ts +8 -1
- package/src/Local/RpcServerSession.ts +2 -2
- package/src/Local/RpcSpawner.ts +61 -37
- package/src/Local/Sidecar.ts +10 -1
- package/src/Nuke.ts +66 -43
- package/src/Output.ts +120 -7
- package/src/Plan.ts +140 -52
- package/src/Platform.ts +47 -18
- package/src/Provider.ts +48 -3
- package/src/Report.ts +77 -275
- package/src/Runtime/ManagedHttpShutdown.ts +21 -4
- package/src/RuntimeContext.ts +1 -1
- package/src/Stack.ts +113 -135
- package/src/State/BucketState.ts +53 -21
- package/src/State/LocalState.ts +7 -9
- package/src/State/Provisioning.ts +8 -1
- package/src/State/ResourceState.ts +2 -0
- package/src/State/State.ts +30 -0
- package/src/State/StateEncoding.ts +22 -0
- package/src/State/index.ts +2 -2
- package/src/Telemetry/Layer.ts +3 -24
- package/src/Telemetry/Metrics.ts +1 -1
- package/src/TelemetryRelay.ts +1 -1
- package/src/TelemetryRuntime.ts +8 -8
- package/src/Util/ConsoleSink.ts +76 -13
- package/src/Util/LogAnnotation.ts +18 -0
- package/src/Util/LogRecord.ts +386 -0
- package/src/Util/Node.ts +20 -6
- package/src/Util/PlatformServices.ts +17 -4
- package/src/Util/ResourceOutput.ts +26 -25
- package/src/Util/Shutdown.ts +52 -0
- package/src/Util/Terminal.ts +3 -20
- package/src/Util/TraceParent.ts +70 -0
- package/src/Util/base64.ts +22 -0
- package/src/Util/cached-function.ts +30 -19
- package/src/Util/data.ts +2 -2
- package/src/Util/equal.ts +3 -2
- package/src/Util/extraFiles.ts +9 -8
- package/src/Util/interactive.ts +1 -1
- package/src/Website/AstroOutput.ts +83 -0
- package/src/Workflows.ts +11 -0
- package/src/index.ts +1 -0
- package/lib/Alchemist/Progress.d.ts +0 -16
- package/lib/Alchemist/Progress.d.ts.map +0 -1
- package/lib/Alchemist/Progress.js +0 -123
- package/lib/Alchemist/Progress.js.map +0 -1
- package/lib/Alchemist/Session.d.ts +0 -116
- package/lib/Alchemist/Session.d.ts.map +0 -1
- package/lib/Alchemist/Session.js +0 -212
- package/lib/Alchemist/Session.js.map +0 -1
- package/lib/Alchemist/routes/drift.d.ts +0 -55
- package/lib/Alchemist/routes/drift.d.ts.map +0 -1
- package/lib/Alchemist/routes/drift.js +0 -52
- package/lib/Alchemist/routes/drift.js.map +0 -1
- package/lib/Alchemist/routes/logs.d.ts +0 -41
- package/lib/Alchemist/routes/logs.d.ts.map +0 -1
- package/lib/Alchemist/routes/logs.js.map +0 -1
- package/lib/Alchemist/routes/nuke.d.ts +0 -46
- package/lib/Alchemist/routes/nuke.d.ts.map +0 -1
- package/lib/Alchemist/routes/nuke.js +0 -80
- package/lib/Alchemist/routes/nuke.js.map +0 -1
- package/lib/Alchemist/routes/profile.d.ts +0 -133
- package/lib/Alchemist/routes/profile.d.ts.map +0 -1
- package/lib/Alchemist/routes/profile.js.map +0 -1
- package/lib/Alchemist/routes/provider.d.ts.map +0 -1
- package/lib/Alchemist/routes/provider.js.map +0 -1
- package/lib/Alchemist/routes/stack.d.ts +0 -95
- package/lib/Alchemist/routes/stack.d.ts.map +0 -1
- package/lib/Alchemist/routes/stack.js +0 -73
- package/lib/Alchemist/routes/stack.js.map +0 -1
- package/lib/Alchemist/routes/state.d.ts.map +0 -1
- package/lib/Alchemist/routes/state.js.map +0 -1
- package/lib/Cli/CliKit/CliKit.d.ts +0 -92
- package/lib/Cli/CliKit/CliKit.d.ts.map +0 -1
- package/lib/Cli/CliKit/CliKit.js +0 -27
- package/lib/Cli/CliKit/CliKit.js.map +0 -1
- package/lib/Cli/CliKit/index.d.ts +0 -9
- package/lib/Cli/CliKit/index.d.ts.map +0 -1
- package/lib/Cli/CliKit/index.js +0 -9
- package/lib/Cli/CliKit/index.js.map +0 -1
- package/lib/Cli/CliKit/interaction.d.ts +0 -13
- package/lib/Cli/CliKit/interaction.d.ts.map +0 -1
- package/lib/Cli/CliKit/interaction.js +0 -17
- package/lib/Cli/CliKit/interaction.js.map +0 -1
- package/lib/Cli/CliKit/layer.d.ts +0 -7
- package/lib/Cli/CliKit/layer.d.ts.map +0 -1
- package/lib/Cli/CliKit/layer.js +0 -33
- package/lib/Cli/CliKit/layer.js.map +0 -1
- package/lib/Local/DevLog.d.ts +0 -32
- package/lib/Local/DevLog.d.ts.map +0 -1
- package/lib/Local/DevLog.js +0 -112
- package/lib/Local/DevLog.js.map +0 -1
- package/lib/Test/Alchemy.d.ts +0 -79
- package/lib/Test/Alchemy.d.ts.map +0 -1
- package/lib/Test/Alchemy.js +0 -193
- package/lib/Test/Alchemy.js.map +0 -1
- package/lib/Test/Bun.d.ts +0 -69
- package/lib/Test/Bun.d.ts.map +0 -1
- package/lib/Test/Bun.js +0 -126
- package/lib/Test/Bun.js.map +0 -1
- package/lib/Test/Core.d.ts +0 -277
- package/lib/Test/Core.d.ts.map +0 -1
- package/lib/Test/Core.js +0 -362
- package/lib/Test/Core.js.map +0 -1
- package/lib/Test/Http.d.ts +0 -109
- package/lib/Test/Http.d.ts.map +0 -1
- package/lib/Test/Http.js +0 -123
- package/lib/Test/Http.js.map +0 -1
- package/lib/Test/TestState.d.ts +0 -12
- package/lib/Test/TestState.d.ts.map +0 -1
- package/lib/Test/TestState.js +0 -15
- package/lib/Test/TestState.js.map +0 -1
- package/lib/Test/Vitest.d.ts +0 -60
- package/lib/Test/Vitest.d.ts.map +0 -1
- package/lib/Test/Vitest.js +0 -132
- package/lib/Test/Vitest.js.map +0 -1
- package/lib/Test/index.d.ts +0 -3
- package/lib/Test/index.d.ts.map +0 -1
- package/lib/Test/index.js +0 -3
- package/lib/Test/index.js.map +0 -1
- package/lib/Util/FileLogger.d.ts +0 -7
- package/lib/Util/FileLogger.d.ts.map +0 -1
- package/lib/Util/FileLogger.js +0 -16
- package/lib/Util/FileLogger.js.map +0 -1
- package/src/Alchemist/Progress.ts +0 -167
- package/src/Alchemist/Session.ts +0 -415
- package/src/Alchemist/routes/drift.ts +0 -87
- package/src/Alchemist/routes/nuke.ts +0 -131
- package/src/Alchemist/routes/stack.ts +0 -173
- package/src/Cli/CliKit/CliKit.ts +0 -159
- package/src/Cli/CliKit/index.ts +0 -41
- package/src/Cli/CliKit/interaction.ts +0 -19
- package/src/Cli/CliKit/layer.ts +0 -44
- package/src/Local/DevLog.ts +0 -122
- package/src/Test/Alchemy.ts +0 -334
- package/src/Test/Bun.ts +0 -230
- package/src/Test/Core.ts +0 -785
- package/src/Test/Http.ts +0 -201
- package/src/Test/TestState.ts +0 -35
- package/src/Test/Vitest.ts +0 -239
- package/src/Test/index.ts +0 -2
- package/src/Util/FileLogger.ts +0 -20
package/src/Auth/Resolve.ts
CHANGED
|
@@ -6,7 +6,8 @@ import * as Schema from "effect/Schema";
|
|
|
6
6
|
import { UserFacingError } from "../UserFacingError.ts";
|
|
7
7
|
import { loadConfigProvider } from "../Util/ConfigProvider.ts";
|
|
8
8
|
import { AuthError, getAuthProvider, presentEnvironment } from "./AuthProvider.ts";
|
|
9
|
-
import {
|
|
9
|
+
import { cacheUntilExpiry } from "./CredentialsCache.ts";
|
|
10
|
+
import { ProfileStore, reloadProviderConfig, SuppressMissingProviderConfig } from "./Profile.ts";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Resolve the selected Alchemy profile after the command's dotenv provider is
|
|
@@ -86,7 +87,9 @@ export const resolveProviderConfig = <C extends { method: string } = any, Creden
|
|
|
86
87
|
auth,
|
|
87
88
|
profileName,
|
|
88
89
|
config,
|
|
89
|
-
resolve:
|
|
90
|
+
// Reload under the credentials lock on every resolve: a refresh
|
|
91
|
+
// rotates the stored token, so `config` goes stale after the first one.
|
|
92
|
+
resolve: auth.read(profileName, reloadProviderConfig(profile, auth, profileName), (updated) =>
|
|
90
93
|
profile.setProviderConfig(profileName, providerName, updated).pipe(
|
|
91
94
|
Effect.mapError((cause) =>
|
|
92
95
|
AuthError.make({
|
|
@@ -105,9 +108,21 @@ export const resolveProviderConfig = <C extends { method: string } = any, Creden
|
|
|
105
108
|
* runs on first use, outside the layer build, so the services it needs are
|
|
106
109
|
* captured now and provided to it. Building the layer then never runs the
|
|
107
110
|
* effect, e.g. never requires a configured profile.
|
|
111
|
+
*
|
|
112
|
+
* The `ConfigProvider` is a reference, so it is not part of `R`; capture it
|
|
113
|
+
* too. Otherwise the first use reads config through whatever provider is
|
|
114
|
+
* ambient there — e.g. a Function's init, which binds every key it loads into
|
|
115
|
+
* the Function's env and would ship the deployer's credentials (#1842).
|
|
108
116
|
*/
|
|
109
117
|
export const deferUntilFirstUse = <A, E, R>(resolve: Effect.Effect<A, E, R>) =>
|
|
110
|
-
Effect.map(
|
|
118
|
+
Effect.map(
|
|
119
|
+
Effect.all([Effect.context<R>(), ConfigProvider.ConfigProvider]),
|
|
120
|
+
([context, configProvider]) =>
|
|
121
|
+
resolve.pipe(
|
|
122
|
+
Effect.provideService(ConfigProvider.ConfigProvider, configProvider),
|
|
123
|
+
Effect.provideContext(context),
|
|
124
|
+
),
|
|
125
|
+
);
|
|
111
126
|
|
|
112
127
|
/**
|
|
113
128
|
* A provider's credentials could not be resolved when a cloud operation first
|
|
@@ -145,6 +160,63 @@ export const orDieCredentialsUnavailable =
|
|
|
145
160
|
Effect.orDie,
|
|
146
161
|
);
|
|
147
162
|
|
|
163
|
+
/**
|
|
164
|
+
* The credential recipe behind every provider's `fromAuthProvider` layer:
|
|
165
|
+
* {@link resolveProviderConfig}'s precedence, deferred until first use (so
|
|
166
|
+
* building provider layers never needs a configured profile), cached until
|
|
167
|
+
* shortly before the credentials expire (forever when `expiresAt` is omitted
|
|
168
|
+
* or returns `undefined`; failures are never cached, so a later `alchemy
|
|
169
|
+
* profile` login is picked up), and mapped onto the client's shape.
|
|
170
|
+
*
|
|
171
|
+
* A failed resolution fails with {@link CredentialsUnavailable}, which the
|
|
172
|
+
* engine reports as `CredentialsRequired`. `E` types that failure into the
|
|
173
|
+
* client SDK's own credentials channel (e.g. distilled's `ConfigError`), so
|
|
174
|
+
* users never see a new error type.
|
|
175
|
+
*
|
|
176
|
+
* ```ts
|
|
177
|
+
* export const fromAuthProvider = () =>
|
|
178
|
+
* Layer.effect(
|
|
179
|
+
* Credentials,
|
|
180
|
+
* lazyCredentials<StripeResolvedCredentials, ConfigError>()(
|
|
181
|
+
* STRIPE_AUTH_PROVIDER_NAME,
|
|
182
|
+
* (creds) => ({ apiKey: creds.apiKey, apiBaseUrl: creds.apiBaseUrl }),
|
|
183
|
+
* ),
|
|
184
|
+
* );
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export const lazyCredentials = <Resolved, E = CredentialsUnavailable>() =>
|
|
188
|
+
Effect.fn("lazyCredentials")(function* <A>(
|
|
189
|
+
providerName: string,
|
|
190
|
+
toClient: (resolved: Resolved) => A,
|
|
191
|
+
options?: { readonly expiresAt?: (resolved: Resolved) => number | undefined },
|
|
192
|
+
) {
|
|
193
|
+
const unavailable = (prefix: string) => (cause: { readonly message: string }) =>
|
|
194
|
+
CredentialsUnavailable.make({
|
|
195
|
+
provider: providerName,
|
|
196
|
+
message: `${prefix}${cause.message}`,
|
|
197
|
+
cause,
|
|
198
|
+
});
|
|
199
|
+
const resolve = yield* resolveProviderConfig<{ method: string }, Resolved>(providerName).pipe(
|
|
200
|
+
Effect.mapError(unavailable("")),
|
|
201
|
+
Effect.flatMap(({ profileName, resolve }) => {
|
|
202
|
+
const from = profileName === undefined ? "the environment" : `profile '${profileName}'`;
|
|
203
|
+
return Effect.logDebug(`${providerName}: credentials from ${from}`).pipe(
|
|
204
|
+
Effect.annotateLogs({ provider: providerName }),
|
|
205
|
+
Effect.andThen(resolve),
|
|
206
|
+
Effect.mapError(
|
|
207
|
+
unavailable(`Failed to resolve ${providerName} credentials from ${from}: `),
|
|
208
|
+
),
|
|
209
|
+
);
|
|
210
|
+
}),
|
|
211
|
+
deferUntilFirstUse,
|
|
212
|
+
);
|
|
213
|
+
const cached = yield* cacheUntilExpiry(resolve, options?.expiresAt ?? (() => undefined));
|
|
214
|
+
// SAFETY: E is only the SDK channel the CredentialsUnavailable fails
|
|
215
|
+
// through; the engine matches its tag around every provider call.
|
|
216
|
+
// oxlint-disable-next-line effecttsgo/unsafe-effect-type-assertion -- see SAFETY above
|
|
217
|
+
return cached.pipe(Effect.map(toClient)) as Effect.Effect<A, E>;
|
|
218
|
+
});
|
|
219
|
+
|
|
148
220
|
/** Let an explicit profile override configured selection without disturbing other keys. */
|
|
149
221
|
export const withProfileOverride = (
|
|
150
222
|
base: ConfigProvider.ConfigProvider,
|
|
@@ -188,12 +188,11 @@ export const makeStoredAuthProvider = <Resolved>(config: StoredAuthProviderConfi
|
|
|
188
188
|
const layer = AuthProviderLayer<StoredAuthConfig, Resolved>()(
|
|
189
189
|
provider,
|
|
190
190
|
Effect.gen(function* () {
|
|
191
|
-
const interaction = Interaction.accessors;
|
|
192
191
|
const persist = (_profileName: string, values: StoredValues) =>
|
|
193
192
|
Effect.gen(function* () {
|
|
194
193
|
const complete = config.complete?.(values) ?? Effect.succeed(values);
|
|
195
194
|
const completed = yield* complete;
|
|
196
|
-
yield*
|
|
195
|
+
yield* Interaction.success(`${provider}: credentials saved.`);
|
|
197
196
|
return {
|
|
198
197
|
method: "stored" as const,
|
|
199
198
|
...Object.fromEntries(
|
package/src/Binding.ts
CHANGED
|
@@ -107,10 +107,9 @@ export const Service = <
|
|
|
107
107
|
const tag = Context.Service<Self, (...args: any[]) => Effect.Effect<any>>(id);
|
|
108
108
|
const callable = (...args: any[]) =>
|
|
109
109
|
tag.use((f: (...a: any[]) => Effect.Effect<any>) =>
|
|
110
|
-
Effect.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
).pipe(
|
|
110
|
+
Effect.forEach(args, (arg) => (Effect.isEffect(arg) ? arg : Effect.succeed(arg)), {
|
|
111
|
+
concurrency: "unbounded",
|
|
112
|
+
}).pipe(
|
|
114
113
|
Effect.flatMap((resolved) =>
|
|
115
114
|
f(...resolved).pipe(
|
|
116
115
|
// Deploy-time data-plane routing: the client's calls must target
|
package/src/Bundle/Bundle.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
2
3
|
import * as Effect from "effect/Effect";
|
|
3
4
|
import * as Option from "effect/Option";
|
|
4
5
|
import * as Path from "effect/Path";
|
|
@@ -11,8 +12,10 @@ import { dotAlchemyDirectory } from "../AlchemyContext.ts";
|
|
|
11
12
|
import { encodeFqn } from "../FQN.ts";
|
|
12
13
|
import { ResourceContext } from "../ResourceContext.ts";
|
|
13
14
|
import { StackContext } from "../StackContext.ts";
|
|
15
|
+
import { LogAnnotation } from "../Util/LogAnnotation.ts";
|
|
14
16
|
import { sha256, sha256Object } from "../Util/sha256.ts";
|
|
15
17
|
import { bundleAnalyzerPlugin, type BundleAnalyzerPluginOptions } from "./BundleAnalyzerPlugin.ts";
|
|
18
|
+
import { namespaceImportPlugin } from "./NamespaceImportPlugin.ts";
|
|
16
19
|
import { purePlugin, type PurePluginOptions } from "./PurePlugin.ts";
|
|
17
20
|
import { rawPlugin } from "./RawPlugin.ts";
|
|
18
21
|
import { unreachableChunksPlugin } from "./UnreachableChunksPlugin.ts";
|
|
@@ -119,6 +122,11 @@ export interface BundleFile {
|
|
|
119
122
|
readonly path: string;
|
|
120
123
|
readonly content: string | Uint8Array<ArrayBufferLike>;
|
|
121
124
|
readonly hash: string;
|
|
125
|
+
/**
|
|
126
|
+
* The platform's module type for this file, when its extension doesn't
|
|
127
|
+
* decide it (e.g. a Cloudflare `Text` rule over `.md` files).
|
|
128
|
+
*/
|
|
129
|
+
readonly type?: string;
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
export class BundleError extends Schema.TaggedError<BundleError>()("BundleError", {
|
|
@@ -185,9 +193,18 @@ const ALCHEMY_MODULE_TYPES: NonNullable<rolldown.InputOptions["moduleTypes"]> =
|
|
|
185
193
|
* framework flags win over any caller-provided keys) and
|
|
186
194
|
* {@link ALCHEMY_MODULE_TYPES} into the caller's `moduleTypes` (caller
|
|
187
195
|
* keys win, so an extension can be remapped or disabled per bundle).
|
|
196
|
+
*
|
|
197
|
+
* Also enables `experimental.lazyBarrel` unless the caller sets it, so a
|
|
198
|
+
* runtime importing one service from `@alchemy.run/aws` (a barrel of every
|
|
199
|
+
* AWS service) compiles that service, not all of them. See
|
|
200
|
+
* {@link namespaceImportPlugin} for `import * as AWS`.
|
|
188
201
|
*/
|
|
189
202
|
const withAlchemyDefine = (inputOptions: rolldown.InputOptions): rolldown.InputOptions => ({
|
|
190
203
|
...inputOptions,
|
|
204
|
+
experimental: {
|
|
205
|
+
lazyBarrel: true,
|
|
206
|
+
...inputOptions.experimental,
|
|
207
|
+
},
|
|
191
208
|
transform: {
|
|
192
209
|
...inputOptions.transform,
|
|
193
210
|
define: {
|
|
@@ -283,6 +300,35 @@ const bundleConcurrency = (() => {
|
|
|
283
300
|
})();
|
|
284
301
|
const buildPermits = Semaphore.makeUnsafe(bundleConcurrency);
|
|
285
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Rolldown's own logs (warnings such as `UNRESOLVED_IMPORT`, plugin timings)
|
|
305
|
+
* as `output` records in the context of the build: the resource's `fqn` and
|
|
306
|
+
* trace, one record per log instead of raw lines on stderr. Like any tool
|
|
307
|
+
* output, they stay in the run log and are never exported. A caller's own
|
|
308
|
+
* `onLog` wins.
|
|
309
|
+
*/
|
|
310
|
+
const withRolldownLogs = (
|
|
311
|
+
inputOptions: rolldown.InputOptions,
|
|
312
|
+
context: Context.Context<never>,
|
|
313
|
+
): rolldown.InputOptions =>
|
|
314
|
+
inputOptions.onLog !== undefined
|
|
315
|
+
? inputOptions
|
|
316
|
+
: {
|
|
317
|
+
...inputOptions,
|
|
318
|
+
onLog: (level, log) =>
|
|
319
|
+
Effect.runSyncWith(context)(
|
|
320
|
+
Effect.logWithLevel(level === "warn" ? "Warn" : level === "debug" ? "Debug" : "Info")(
|
|
321
|
+
log.frame === undefined ? log.message : `${log.message}\n${log.frame}`,
|
|
322
|
+
).pipe(
|
|
323
|
+
Effect.annotateLogs({
|
|
324
|
+
[LogAnnotation.stream]: "stderr",
|
|
325
|
+
...(log.code === undefined ? {} : { code: log.code }),
|
|
326
|
+
...(log.plugin === undefined ? {} : { plugin: log.plugin }),
|
|
327
|
+
}),
|
|
328
|
+
),
|
|
329
|
+
),
|
|
330
|
+
};
|
|
331
|
+
|
|
286
332
|
/**
|
|
287
333
|
* Build a bundle using rolldown from the given input options and output options.
|
|
288
334
|
* @param inputOptions - The input options for the bundle.
|
|
@@ -294,13 +340,13 @@ export const build = (
|
|
|
294
340
|
outputOptions?: rolldown.OutputOptions,
|
|
295
341
|
extra?: BundleExtraOptions,
|
|
296
342
|
): Effect.Effect<BundleOutput, BundleError> =>
|
|
297
|
-
resolveOutputOptions(outputOptions).pipe(
|
|
298
|
-
Effect.flatMap((options) =>
|
|
343
|
+
Effect.zip(resolveOutputOptions(outputOptions), Effect.context<never>()).pipe(
|
|
344
|
+
Effect.flatMap(([options, context]) =>
|
|
299
345
|
Effect.tryPromise({
|
|
300
346
|
try: async () => {
|
|
301
347
|
const rolldown = await loadRolldown();
|
|
302
348
|
const bundle = await rolldown.rolldown({
|
|
303
|
-
...withAlchemyDefine(inputOptions),
|
|
349
|
+
...withAlchemyDefine(withRolldownLogs(inputOptions, context)),
|
|
304
350
|
plugins: [inputOptions.plugins, await builtInPlugins(extra)],
|
|
305
351
|
optimization: inputOptions.optimization ?? {
|
|
306
352
|
inlineConst: {
|
|
@@ -334,7 +380,11 @@ export const watch = (
|
|
|
334
380
|
extra?: BundleExtraOptions,
|
|
335
381
|
): Stream.Stream<BundleWatchEvent> =>
|
|
336
382
|
Stream.unwrap(
|
|
337
|
-
Effect.
|
|
383
|
+
Effect.zipWith(
|
|
384
|
+
resolveOutputOptions(outputOptions),
|
|
385
|
+
Effect.context<never>(),
|
|
386
|
+
(options, context) => watchResolved(withRolldownLogs(inputOptions, context), extra)(options),
|
|
387
|
+
),
|
|
338
388
|
);
|
|
339
389
|
|
|
340
390
|
const watchResolved =
|
|
@@ -405,11 +455,12 @@ const watchResolved =
|
|
|
405
455
|
Effect.gen(function* () {
|
|
406
456
|
// Hold a build permit until the watcher's initial build settles.
|
|
407
457
|
yield* buildPermits.take(1);
|
|
458
|
+
const context = yield* Effect.context();
|
|
408
459
|
let initialBuildSettled = false;
|
|
409
460
|
const settleInitialBuild = () => {
|
|
410
461
|
if (initialBuildSettled) return;
|
|
411
462
|
initialBuildSettled = true;
|
|
412
|
-
Effect.
|
|
463
|
+
Effect.runForkWith(context)(buildPermits.release(1));
|
|
413
464
|
};
|
|
414
465
|
const watcher = yield* Effect.promise(() => createWatcher(settleInitialBuild)).pipe(
|
|
415
466
|
Effect.onError(() => Effect.sync(settleInitialBuild)),
|
|
@@ -444,14 +495,12 @@ const watchResolved =
|
|
|
444
495
|
);
|
|
445
496
|
|
|
446
497
|
const ENTRY_PREFIX = "\0virtual:alchemy-entry:";
|
|
447
|
-
// oxlint-disable-next-line no-control-regex
|
|
448
498
|
const ENTRY_REGEX = /^\0virtual:alchemy-entry:/;
|
|
449
499
|
/**
|
|
450
500
|
* Ids the `resolveId` hook looks at: the virtual entry ids themselves, plus
|
|
451
501
|
* bare package specifiers (not starting with `.`, `/` or `\0`) so an
|
|
452
502
|
* unresolvable import in a generated entry fails the build (below).
|
|
453
503
|
*/
|
|
454
|
-
// oxlint-disable-next-line no-control-regex
|
|
455
504
|
const ENTRY_OR_BARE_REGEX = /^(?:\0virtual:alchemy-entry:|[^./\0])/;
|
|
456
505
|
|
|
457
506
|
export const virtualEntryPlugin = Effect.gen(function* () {
|
|
@@ -563,6 +612,7 @@ async function builtInPlugins(extra?: BundleExtraOptions): Promise<rolldown.Roll
|
|
|
563
612
|
extra?.bundleAnalyzer
|
|
564
613
|
? await bundleAnalyzerPlugin(extra.bundleAnalyzer === true ? {} : extra.bundleAnalyzer)
|
|
565
614
|
: undefined,
|
|
615
|
+
namespaceImportPlugin(),
|
|
566
616
|
extra?.pure !== false ? purePlugin(extra?.pure ?? {}) : undefined,
|
|
567
617
|
rawPlugin(),
|
|
568
618
|
unreachableChunksPlugin(),
|
|
@@ -585,6 +635,7 @@ export function bundleOutputFromFiles(
|
|
|
585
635
|
files.map((file) => ({
|
|
586
636
|
path: file.path,
|
|
587
637
|
hash: file.hash,
|
|
638
|
+
...(file.type ? { type: file.type } : {}),
|
|
588
639
|
})),
|
|
589
640
|
),
|
|
590
641
|
(hash) => ({ files, hash }),
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import type { ImportDeclaration, Program } from "@oxc-project/types";
|
|
2
|
+
import picomatch from "picomatch";
|
|
3
|
+
import type * as rolldown from "rolldown";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `rolldown` and `rolldown/parseAst` load `@rolldown/binding-*` at module
|
|
7
|
+
* scope, so they are imported lazily on first use (#562).
|
|
8
|
+
*/
|
|
9
|
+
const loadRolldown = () => import("rolldown");
|
|
10
|
+
const loadParseAst = () => import("rolldown/parseAst");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Packages whose namespace imports are rewritten by default. Their root
|
|
14
|
+
* modules re-export every service (`export * as Lambda from "./Lambda/index.ts"`),
|
|
15
|
+
* and every one of them declares `"sideEffects": false`.
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_NAMESPACE_IMPORT_PACKAGES: ReadonlyArray<string> = [
|
|
18
|
+
"alchemy",
|
|
19
|
+
"@alchemy.run/*",
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Options for {@link namespaceImportPlugin}.
|
|
24
|
+
*/
|
|
25
|
+
export interface NamespaceImportPluginOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Extra package names or globs whose namespace imports are rewritten, in
|
|
28
|
+
* addition to {@link DEFAULT_NAMESPACE_IMPORT_PACKAGES}. Matched with
|
|
29
|
+
* picomatch against the package name of the import specifier. Only list
|
|
30
|
+
* packages that declare `"sideEffects": false`.
|
|
31
|
+
*/
|
|
32
|
+
readonly packages?: ReadonlyArray<string>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const SUPPORTED_FILE_RE = /\.(?:m?[jt]sx?|cjs|cts)$/;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Rolldown plugin that rewrites namespace imports of barrel packages into
|
|
39
|
+
* named imports, so `experimental.lazyBarrel` only compiles the re-exports
|
|
40
|
+
* a module actually uses.
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* import * as AWS from "@alchemy.run/aws";
|
|
44
|
+
* AWS.Lambda.Function;
|
|
45
|
+
* // becomes
|
|
46
|
+
* import { Lambda as AWS$Lambda } from "@alchemy.run/aws";
|
|
47
|
+
* AWS$Lambda.Function;
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* Rolldown loads every export of a barrel imported with `import * as ns`,
|
|
51
|
+
* even when only `ns.X` is read, so without this rewrite one
|
|
52
|
+
* `import * as AWS from "@alchemy.run/aws"` parses every AWS service.
|
|
53
|
+
*
|
|
54
|
+
* A namespace is only rewritten when every reference to its name is a
|
|
55
|
+
* static member access (`ns.X`, or `ns.X` in a type). Anything else —
|
|
56
|
+
* passing the namespace around, computed access, a shadowing binding,
|
|
57
|
+
* JSX — leaves the import untouched.
|
|
58
|
+
*/
|
|
59
|
+
export const namespaceImportPlugin = (
|
|
60
|
+
options: NamespaceImportPluginOptions = {},
|
|
61
|
+
): rolldown.Plugin => {
|
|
62
|
+
const isMatch = picomatch([...DEFAULT_NAMESPACE_IMPORT_PACKAGES, ...(options.packages ?? [])]);
|
|
63
|
+
const matchesSpecifier = (specifier: string) => {
|
|
64
|
+
const name = packageNameOf(specifier);
|
|
65
|
+
return name !== null && isMatch(name);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
name: "alchemy:namespace-imports",
|
|
70
|
+
transform: {
|
|
71
|
+
filter: { id: SUPPORTED_FILE_RE, code: /import\s*\*\s*as\s/ },
|
|
72
|
+
async handler(code, id, meta) {
|
|
73
|
+
const edits = await collectNamespaceImportEdits(code, id, matchesSpecifier);
|
|
74
|
+
if (edits.length === 0) return null;
|
|
75
|
+
const s = meta.magicString ?? new (await loadRolldown()).RolldownMagicString(code);
|
|
76
|
+
for (const edit of edits) s.overwrite(edit.start, edit.end, edit.text);
|
|
77
|
+
return { code: s };
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** A source replacement over `[start, end)`. */
|
|
84
|
+
export interface NamespaceImportEdit {
|
|
85
|
+
readonly start: number;
|
|
86
|
+
readonly end: number;
|
|
87
|
+
readonly text: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Returns the edits that rewrite each eligible namespace import in `code`
|
|
92
|
+
* (see {@link namespaceImportPlugin}), or an empty array when nothing is
|
|
93
|
+
* rewritten.
|
|
94
|
+
*/
|
|
95
|
+
export async function collectNamespaceImportEdits(
|
|
96
|
+
code: string,
|
|
97
|
+
filename: string,
|
|
98
|
+
matchesSpecifier: (specifier: string) => boolean,
|
|
99
|
+
): Promise<NamespaceImportEdit[]> {
|
|
100
|
+
const { parseAst } = await loadParseAst();
|
|
101
|
+
let program: Program;
|
|
102
|
+
try {
|
|
103
|
+
program = parseAst(code, { sourceType: "module", lang: langOf(filename) }, filename);
|
|
104
|
+
} catch {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const candidates = new Map<string, ImportDeclaration>();
|
|
109
|
+
for (const statement of program.body) {
|
|
110
|
+
if (statement.type !== "ImportDeclaration") continue;
|
|
111
|
+
if (statement.importKind === "type" || statement.phase) continue;
|
|
112
|
+
if (statement.attributes.length > 0) continue;
|
|
113
|
+
const [specifier, ...rest] = statement.specifiers;
|
|
114
|
+
if (specifier?.type !== "ImportNamespaceSpecifier" || rest.length > 0) continue;
|
|
115
|
+
if (!matchesSpecifier(statement.source.value)) continue;
|
|
116
|
+
// Two imports binding the same name is a syntax error; skip defensively.
|
|
117
|
+
if (candidates.has(specifier.local.name)) {
|
|
118
|
+
candidates.delete(specifier.local.name);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
candidates.set(specifier.local.name, statement);
|
|
122
|
+
}
|
|
123
|
+
if (candidates.size === 0) return [];
|
|
124
|
+
|
|
125
|
+
interface Usage {
|
|
126
|
+
/** Identifier nodes with the namespace's name, wherever they appear. */
|
|
127
|
+
identifiers: number;
|
|
128
|
+
/** Rewritable member accesses: `[start, end, member, isType]`. */
|
|
129
|
+
members: Array<readonly [number, number, string, boolean]>;
|
|
130
|
+
/** A reference that can't be rewritten (JSX). */
|
|
131
|
+
blocked: boolean;
|
|
132
|
+
}
|
|
133
|
+
const usages = new Map<string, Usage>(
|
|
134
|
+
[...candidates.keys()].map((name) => [name, { identifiers: 0, members: [], blocked: false }]),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// `inType` is set once the walk enters a type: everything below it is
|
|
138
|
+
// erased by the TypeScript transform, so its members import as `type`.
|
|
139
|
+
const visit = (node: unknown, inType: boolean): void => {
|
|
140
|
+
if (Array.isArray(node)) {
|
|
141
|
+
for (const child of node) visit(child, inType);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (node === null || typeof node !== "object") return;
|
|
145
|
+
const n = node as { type?: unknown } & Record<string, unknown>;
|
|
146
|
+
const type = n.type as string;
|
|
147
|
+
if (type === "Identifier" || type === "JSXIdentifier") {
|
|
148
|
+
const usage = usages.get(n.name as string);
|
|
149
|
+
if (usage) {
|
|
150
|
+
usage.identifiers++;
|
|
151
|
+
if (type === "JSXIdentifier") usage.blocked = true;
|
|
152
|
+
}
|
|
153
|
+
// Fall through: a binding's `typeAnnotation` hangs off its Identifier.
|
|
154
|
+
} else if (type === "TSImportEqualsDeclaration") {
|
|
155
|
+
// `import L = AWS.Lambda` aliases a value through a type-shaped name.
|
|
156
|
+
const usage = usages.get(rootName(n.moduleReference));
|
|
157
|
+
if (usage) usage.blocked = true;
|
|
158
|
+
} else if (type === "MemberExpression" || type === "TSQualifiedName") {
|
|
159
|
+
const [object, property] =
|
|
160
|
+
type === "MemberExpression" ? [n.object, n.property] : [n.left, n.right];
|
|
161
|
+
const o = object as { type: string; name?: string };
|
|
162
|
+
const p = property as { type: string; name?: string };
|
|
163
|
+
const usage = o.type === "Identifier" ? usages.get(o.name!) : undefined;
|
|
164
|
+
if (usage && p.type === "Identifier" && n.computed !== true) {
|
|
165
|
+
usage.members.push([n.start as number, n.end as number, p.name!, inType]);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const childInType = inType || TYPE_NODES.has(type);
|
|
169
|
+
for (const key in n) {
|
|
170
|
+
if (key === "parent" || key === "type" || key === "start" || key === "end") continue;
|
|
171
|
+
visit(n[key], childInType);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
visit(program.body, false);
|
|
175
|
+
|
|
176
|
+
const edits: NamespaceImportEdit[] = [];
|
|
177
|
+
const taken = new Set<string>();
|
|
178
|
+
for (const [name, declaration] of candidates) {
|
|
179
|
+
const usage = usages.get(name)!;
|
|
180
|
+
// One identifier is the import's own binding; every other one must be
|
|
181
|
+
// the object of a rewritable member access.
|
|
182
|
+
if (usage.blocked || usage.members.length === 0) continue;
|
|
183
|
+
if (usage.identifiers !== usage.members.length + 1) continue;
|
|
184
|
+
|
|
185
|
+
const aliases = new Map<string, { alias: string; value: boolean }>();
|
|
186
|
+
for (const [, , member, isType] of usage.members) {
|
|
187
|
+
const existing = aliases.get(member);
|
|
188
|
+
if (existing) {
|
|
189
|
+
existing.value ||= !isType;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const alias = uniqueAlias(code, taken, `${name}$${member}`);
|
|
193
|
+
taken.add(alias);
|
|
194
|
+
aliases.set(member, { alias, value: !isType });
|
|
195
|
+
}
|
|
196
|
+
const specifiers = [...aliases]
|
|
197
|
+
.map(([member, { alias, value }]) => `${value ? "" : "type "}${member} as ${alias}`)
|
|
198
|
+
.join(", ");
|
|
199
|
+
const source = code.slice(declaration.source.start, declaration.source.end);
|
|
200
|
+
edits.push({
|
|
201
|
+
start: declaration.start,
|
|
202
|
+
end: declaration.end,
|
|
203
|
+
text: `import { ${specifiers} } from ${source};`,
|
|
204
|
+
});
|
|
205
|
+
for (const [start, end, member] of usage.members) {
|
|
206
|
+
edits.push({ start, end, text: aliases.get(member)!.alias });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return edits;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Nodes whose descendants are all types. `typeof ns.X` is a type query over
|
|
214
|
+
* a value, which a `type` import still satisfies.
|
|
215
|
+
*/
|
|
216
|
+
const TYPE_NODES = new Set([
|
|
217
|
+
"TSTypeAnnotation",
|
|
218
|
+
"TSTypeReference",
|
|
219
|
+
"TSTypeQuery",
|
|
220
|
+
"TSInterfaceDeclaration",
|
|
221
|
+
"TSInterfaceHeritage",
|
|
222
|
+
"TSClassImplements",
|
|
223
|
+
"TSTypeAliasDeclaration",
|
|
224
|
+
"TSTypeParameterInstantiation",
|
|
225
|
+
"TSTypeParameterDeclaration",
|
|
226
|
+
]);
|
|
227
|
+
|
|
228
|
+
/** The leftmost identifier of `a.b.c` (or `a`), or `""`. */
|
|
229
|
+
const rootName = (node: unknown): string => {
|
|
230
|
+
let n = node as { type?: string; name?: string; left?: unknown; object?: unknown } | null;
|
|
231
|
+
while (n && (n.type === "TSQualifiedName" || n.type === "MemberExpression")) {
|
|
232
|
+
n = (n.left ?? n.object) as typeof n;
|
|
233
|
+
}
|
|
234
|
+
return n?.type === "Identifier" ? n.name! : "";
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/** The package name of a bare import specifier, or `null` for relative/absolute ones. */
|
|
238
|
+
const packageNameOf = (specifier: string): string | null => {
|
|
239
|
+
if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.includes(":")) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
const parts = specifier.split("/");
|
|
243
|
+
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0]!;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const langOf = (filename: string): "js" | "jsx" | "ts" | "tsx" => {
|
|
247
|
+
const clean = filename.replace(/[?#].*$/, "");
|
|
248
|
+
if (clean.endsWith(".tsx")) return "tsx";
|
|
249
|
+
if (clean.endsWith(".jsx")) return "jsx";
|
|
250
|
+
// TS is a superset of JS for parsing published `.js` files.
|
|
251
|
+
return "ts";
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
/** `base`, suffixed until it occurs nowhere in `code` and isn't already `taken`. */
|
|
255
|
+
const uniqueAlias = (code: string, taken: ReadonlySet<string>, base: string): string => {
|
|
256
|
+
let alias = base;
|
|
257
|
+
while (code.includes(alias) || taken.has(alias)) alias += "$";
|
|
258
|
+
return alias;
|
|
259
|
+
};
|
package/src/Bundle/index.ts
CHANGED
package/src/Cli/Format.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ansiFg
|
|
1
|
+
import { ansiFg } from "../Util/Terminal.ts";
|
|
2
|
+
import { theme } from "../Util/Theme.ts";
|
|
2
3
|
|
|
3
4
|
/** `450ms` under a second, `1.2s` at or above — shared by every renderer. */
|
|
4
5
|
export const formatElapsed = (ms: number): string =>
|