@agimon-ai/po 0.0.0-alpha.21 → 0.0.0-alpha.211
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/LICENSE +97 -8
- package/README.md +37 -722
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +2 -2
- package/dist/bin/cli.cjs +12 -7
- package/dist/bin/cli.cjs.map +1 -1
- package/dist/bin/cli.mjs +12 -7
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/bin/poRunner.cjs +24 -7
- package/dist/bin/poRunner.cjs.map +1 -1
- package/dist/bin/poRunner.d.mts +8 -0
- package/dist/bin/poRunner.d.mts.map +1 -1
- package/dist/bin/poRunner.mjs +24 -7
- package/dist/bin/poRunner.mjs.map +1 -1
- package/dist/bin/serve.cjs +28 -17
- package/dist/bin/serve.cjs.map +1 -1
- package/dist/bin/serve.mjs +28 -17
- package/dist/bin/serve.mjs.map +1 -1
- package/dist/builders/cli/extensionAssembler/index.cjs +53 -40
- package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -1
- package/dist/builders/cli/extensionAssembler/index.d.mts +11 -6
- package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -1
- package/dist/builders/cli/extensionAssembler/index.mjs +53 -41
- package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -1
- package/dist/catalog/index.json +662 -105
- package/dist/cli.cjs +9 -14
- package/dist/cli.d.mts +1 -3
- package/dist/cli.mjs +1 -3
- package/dist/commands.cjs +13 -15
- package/dist/commands.d.mts +1 -2
- package/dist/commands.mjs +1 -2
- package/dist/config.cjs +9 -14
- package/dist/config.d.mts +3 -2
- package/dist/config.mjs +3 -2
- package/dist/extensions/server.cjs +30 -23
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +31 -24
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/harnessContext.cjs +0 -1
- package/dist/harnessContext.d.mts +2 -2
- package/dist/harnessContext.mjs +1 -1
- package/dist/harnessState.cjs +2 -1
- package/dist/help.cjs +9 -11
- package/dist/help.d.mts +1 -2
- package/dist/help.mjs +1 -2
- package/dist/index.cjs +40 -67
- package/dist/index.d.mts +7 -16
- package/dist/index.mjs +7 -14
- package/dist/locales/vi.cjs +218 -0
- package/dist/locales/vi.cjs.map +1 -0
- package/dist/locales/vi.mjs +213 -0
- package/dist/locales/vi.mjs.map +1 -0
- package/dist/locales/zh-CN.cjs +218 -0
- package/dist/locales/zh-CN.cjs.map +1 -0
- package/dist/locales/zh-CN.mjs +213 -0
- package/dist/locales/zh-CN.mjs.map +1 -0
- package/dist/matrixOptions.cjs +10 -5
- package/dist/matrixOptions.d.mts +2 -2
- package/dist/matrixOptions.mjs +1 -1
- package/dist/package.cjs +11 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.mjs +6 -0
- package/dist/package.mjs.map +1 -0
- package/dist/projectTrust.cjs +3 -0
- package/dist/projectTrust.d.mts +2 -2
- package/dist/projectTrust.mjs +1 -1
- package/dist/repository.cjs +1 -0
- package/dist/repository.d.mts +2 -2
- package/dist/repository.mjs +1 -1
- package/dist/services.cjs +5 -20
- package/dist/services.d.mts +3 -8
- package/dist/services.mjs +3 -8
- package/dist/shared.cjs +4 -17
- package/dist/shared.d.mts +2 -2
- package/dist/shared.mjs +1 -1
- package/dist/src/bin/agentDirectory.cjs +19 -15
- package/dist/src/bin/agentDirectory.cjs.map +1 -1
- package/dist/src/bin/agentDirectory.mjs +16 -13
- package/dist/src/bin/agentDirectory.mjs.map +1 -1
- package/dist/src/builders/apiContractExport/index.cjs +23 -22
- package/dist/src/builders/apiContractExport/index.cjs.map +1 -1
- package/dist/src/builders/apiContractExport/index.mjs +22 -21
- package/dist/src/builders/apiContractExport/index.mjs.map +1 -1
- package/dist/src/builders/cli/entryResolution.cjs +2 -2
- package/dist/src/builders/cli/entryResolution.cjs.map +1 -1
- package/dist/src/builders/cli/entryResolution.mjs +1 -1
- package/dist/src/builders/cli/entryResolution.mjs.map +1 -1
- package/dist/src/builders/cli/harnessContext.cjs +38 -43
- package/dist/src/builders/cli/harnessContext.cjs.map +1 -1
- package/dist/src/builders/cli/harnessContext.d.mts +11 -10
- package/dist/src/builders/cli/harnessContext.d.mts.map +1 -1
- package/dist/src/builders/cli/harnessContext.mjs +37 -41
- package/dist/src/builders/cli/harnessContext.mjs.map +1 -1
- package/dist/src/builders/cli/sessionComposition.cjs +23 -12
- package/dist/src/builders/cli/sessionComposition.cjs.map +1 -1
- package/dist/src/builders/cli/sessionComposition.mjs +23 -12
- package/dist/src/builders/cli/sessionComposition.mjs.map +1 -1
- package/dist/src/builders/isolate/compile.cjs +226 -0
- package/dist/src/builders/isolate/compile.cjs.map +1 -0
- package/dist/src/builders/isolate/compile.mjs +222 -0
- package/dist/src/builders/isolate/compile.mjs.map +1 -0
- package/dist/src/builders/isolate/index.cjs +195 -0
- package/dist/src/builders/isolate/index.cjs.map +1 -0
- package/dist/src/builders/isolate/index.mjs +192 -0
- package/dist/src/builders/isolate/index.mjs.map +1 -0
- package/dist/src/builders/isolate/membrane.cjs +198 -0
- package/dist/src/builders/isolate/membrane.cjs.map +1 -0
- package/dist/src/builders/isolate/membrane.mjs +198 -0
- package/dist/src/builders/isolate/membrane.mjs.map +1 -0
- package/dist/src/builders/isolate/names.cjs +10 -0
- package/dist/src/builders/isolate/names.cjs.map +1 -0
- package/dist/src/builders/isolate/names.mjs +9 -0
- package/dist/src/builders/isolate/names.mjs.map +1 -0
- package/dist/src/builders/native/index.cjs +229 -67
- package/dist/src/builders/native/index.cjs.map +1 -1
- package/dist/src/builders/native/index.d.mts +4 -2
- package/dist/src/builders/native/index.d.mts.map +1 -1
- package/dist/src/builders/native/index.mjs +229 -68
- package/dist/src/builders/native/index.mjs.map +1 -1
- package/dist/src/builders/npm/index.cjs +76 -0
- package/dist/src/builders/npm/index.cjs.map +1 -0
- package/dist/src/builders/npm/index.mjs +73 -0
- package/dist/src/builders/npm/index.mjs.map +1 -0
- package/dist/src/builders/server/backgroundSync.cjs +62 -39
- package/dist/src/builders/server/backgroundSync.cjs.map +1 -1
- package/dist/src/builders/server/backgroundSync.mjs +62 -38
- package/dist/src/builders/server/backgroundSync.mjs.map +1 -1
- package/dist/src/builders/server/bundlerService.cjs +165 -35
- package/dist/src/builders/server/bundlerService.cjs.map +1 -1
- package/dist/src/builders/server/bundlerService.mjs +164 -36
- package/dist/src/builders/server/bundlerService.mjs.map +1 -1
- package/dist/src/builders/server/capabilities.cjs +103 -0
- package/dist/src/builders/server/capabilities.cjs.map +1 -0
- package/dist/src/builders/server/capabilities.mjs +101 -0
- package/dist/src/builders/server/capabilities.mjs.map +1 -0
- package/dist/src/builders/server/computerUseBinding.cjs +62 -10
- package/dist/src/builders/server/computerUseBinding.cjs.map +1 -1
- package/dist/src/builders/server/computerUseBinding.mjs +60 -8
- package/dist/src/builders/server/computerUseBinding.mjs.map +1 -1
- package/dist/src/builders/server/computerUseRecordings.cjs +152 -51
- package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -1
- package/dist/src/builders/server/computerUseRecordings.mjs +158 -59
- package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -1
- package/dist/src/builders/server/containedSessions.cjs +152 -0
- package/dist/src/builders/server/containedSessions.cjs.map +1 -0
- package/dist/src/builders/server/containedSessions.mjs +146 -0
- package/dist/src/builders/server/containedSessions.mjs.map +1 -0
- package/dist/src/builders/server/defaultWorkspace.cjs +46 -11
- package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -1
- package/dist/src/builders/server/defaultWorkspace.mjs +42 -10
- package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -1
- package/dist/src/builders/server/electronBinding.cjs +82 -0
- package/dist/src/builders/server/electronBinding.cjs.map +1 -0
- package/dist/src/builders/server/electronBinding.mjs +82 -0
- package/dist/src/builders/server/electronBinding.mjs.map +1 -0
- package/dist/src/builders/server/federation.cjs +364 -0
- package/dist/src/builders/server/federation.cjs.map +1 -0
- package/dist/src/builders/server/federation.mjs +363 -0
- package/dist/src/builders/server/federation.mjs.map +1 -0
- package/dist/src/builders/server/hostDisplayName.cjs +14 -0
- package/dist/src/builders/server/hostDisplayName.cjs.map +1 -0
- package/dist/src/builders/server/hostDisplayName.mjs +14 -0
- package/dist/src/builders/server/hostDisplayName.mjs.map +1 -0
- package/dist/src/builders/server/hostModelGateway.cjs +41 -0
- package/dist/src/builders/server/hostModelGateway.cjs.map +1 -0
- package/dist/src/builders/server/hostModelGateway.mjs +39 -0
- package/dist/src/builders/server/hostModelGateway.mjs.map +1 -0
- package/dist/src/builders/server/hostTeam.cjs +188 -0
- package/dist/src/builders/server/hostTeam.cjs.map +1 -0
- package/dist/src/builders/server/hostTeam.mjs +180 -0
- package/dist/src/builders/server/hostTeam.mjs.map +1 -0
- package/dist/src/builders/server/idleRestart.cjs +185 -40
- package/dist/src/builders/server/idleRestart.cjs.map +1 -1
- package/dist/src/builders/server/idleRestart.mjs +176 -39
- package/dist/src/builders/server/idleRestart.mjs.map +1 -1
- package/dist/src/builders/server/index.cjs +58 -19
- package/dist/src/builders/server/index.cjs.map +1 -1
- package/dist/src/builders/server/index.mjs +57 -19
- package/dist/src/builders/server/index.mjs.map +1 -1
- package/dist/src/builders/server/liveActivityPush.cjs +202 -0
- package/dist/src/builders/server/liveActivityPush.cjs.map +1 -0
- package/dist/src/builders/server/liveActivityPush.mjs +202 -0
- package/dist/src/builders/server/liveActivityPush.mjs.map +1 -0
- package/dist/src/builders/server/logSink.cjs +12 -10
- package/dist/src/builders/server/logSink.cjs.map +1 -1
- package/dist/src/builders/server/logSink.mjs +12 -10
- package/dist/src/builders/server/logSink.mjs.map +1 -1
- package/dist/src/builders/server/mcpApp.cjs +27 -20
- package/dist/src/builders/server/mcpApp.cjs.map +1 -1
- package/dist/src/builders/server/mcpApp.mjs +25 -18
- package/dist/src/builders/server/mcpApp.mjs.map +1 -1
- package/dist/src/builders/server/mcpAppBuild.cjs +61 -41
- package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -1
- package/dist/src/builders/server/mcpAppBuild.d.mts +3 -6
- package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -1
- package/dist/src/builders/server/mcpAppBuild.mjs +61 -40
- package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -1
- package/dist/src/builders/server/mcpBundle.cjs +20 -16
- package/dist/src/builders/server/mcpBundle.cjs.map +1 -1
- package/dist/src/builders/server/mcpBundle.d.mts +2 -1
- package/dist/src/builders/server/mcpBundle.d.mts.map +1 -1
- package/dist/src/builders/server/mcpBundle.mjs +20 -15
- package/dist/src/builders/server/mcpBundle.mjs.map +1 -1
- package/dist/src/builders/server/nativePush.cjs +229 -0
- package/dist/src/builders/server/nativePush.cjs.map +1 -0
- package/dist/src/builders/server/nativePush.mjs +228 -0
- package/dist/src/builders/server/nativePush.mjs.map +1 -0
- package/dist/src/builders/server/network.cjs +887 -0
- package/dist/src/builders/server/network.cjs.map +1 -0
- package/dist/src/builders/server/network.mjs +886 -0
- package/dist/src/builders/server/network.mjs.map +1 -0
- package/dist/src/builders/server/networkGateway.cjs +123 -0
- package/dist/src/builders/server/networkGateway.cjs.map +1 -0
- package/dist/src/builders/server/networkGateway.mjs +123 -0
- package/dist/src/builders/server/networkGateway.mjs.map +1 -0
- package/dist/src/builders/server/networkRelay.cjs +83 -0
- package/dist/src/builders/server/networkRelay.cjs.map +1 -0
- package/dist/src/builders/server/networkRelay.mjs +81 -0
- package/dist/src/builders/server/networkRelay.mjs.map +1 -0
- package/dist/src/builders/server/orgPluginLibraryBinding.cjs +72 -0
- package/dist/src/builders/server/orgPluginLibraryBinding.cjs.map +1 -0
- package/dist/src/builders/server/orgPluginLibraryBinding.mjs +72 -0
- package/dist/src/builders/server/orgPluginLibraryBinding.mjs.map +1 -0
- package/dist/src/builders/server/packageReloadCheck.cjs +46 -2
- package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -1
- package/dist/src/builders/server/packageReloadCheck.mjs +46 -3
- package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -1
- package/dist/src/builders/server/packageUrl.cjs +161 -58
- package/dist/src/builders/server/packageUrl.cjs.map +1 -1
- package/dist/src/builders/server/packageUrl.mjs +162 -58
- package/dist/src/builders/server/packageUrl.mjs.map +1 -1
- package/dist/src/builders/server/privateRelay.cjs +309 -0
- package/dist/src/builders/server/privateRelay.cjs.map +1 -0
- package/dist/src/builders/server/privateRelay.mjs +305 -0
- package/dist/src/builders/server/privateRelay.mjs.map +1 -0
- package/dist/src/builders/server/privateRelayCarrier.cjs +316 -0
- package/dist/src/builders/server/privateRelayCarrier.cjs.map +1 -0
- package/dist/src/builders/server/privateRelayCarrier.mjs +309 -0
- package/dist/src/builders/server/privateRelayCarrier.mjs.map +1 -0
- package/dist/src/builders/server/runtime.cjs +2750 -486
- package/dist/src/builders/server/runtime.cjs.map +1 -1
- package/dist/src/builders/server/runtime.mjs +2760 -500
- package/dist/src/builders/server/runtime.mjs.map +1 -1
- package/dist/src/builders/server/runtimeResources.cjs +37 -0
- package/dist/src/builders/server/runtimeResources.cjs.map +1 -1
- package/dist/src/builders/server/runtimeResources.mjs +38 -2
- package/dist/src/builders/server/runtimeResources.mjs.map +1 -1
- package/dist/src/builders/server/sandboxRouter.cjs +815 -0
- package/dist/src/builders/server/sandboxRouter.cjs.map +1 -0
- package/dist/src/builders/server/sandboxRouter.mjs +811 -0
- package/dist/src/builders/server/sandboxRouter.mjs.map +1 -0
- package/dist/src/builders/server/sandboxSessionHandoff.cjs +298 -0
- package/dist/src/builders/server/sandboxSessionHandoff.cjs.map +1 -0
- package/dist/src/builders/server/sandboxSessionHandoff.mjs +287 -0
- package/dist/src/builders/server/sandboxSessionHandoff.mjs.map +1 -0
- package/dist/src/builders/server/scopeReloadController.cjs +80 -0
- package/dist/src/builders/server/scopeReloadController.cjs.map +1 -0
- package/dist/src/builders/server/scopeReloadController.mjs +80 -0
- package/dist/src/builders/server/scopeReloadController.mjs.map +1 -0
- package/dist/src/builders/server/selectionStatus.cjs +2 -2
- package/dist/src/builders/server/selectionStatus.cjs.map +1 -1
- package/dist/src/builders/server/selectionStatus.mjs +2 -2
- package/dist/src/builders/server/selectionStatus.mjs.map +1 -1
- package/dist/src/builders/server/sessionArguments.cjs +65 -7
- package/dist/src/builders/server/sessionArguments.cjs.map +1 -1
- package/dist/src/builders/server/sessionArguments.mjs +64 -8
- package/dist/src/builders/server/sessionArguments.mjs.map +1 -1
- package/dist/src/builders/server/sessionRemoval.cjs +233 -0
- package/dist/src/builders/server/sessionRemoval.cjs.map +1 -0
- package/dist/src/builders/server/sessionRemoval.mjs +224 -0
- package/dist/src/builders/server/sessionRemoval.mjs.map +1 -0
- package/dist/src/builders/server/sessionSummaries.cjs +32 -0
- package/dist/src/builders/server/sessionSummaries.cjs.map +1 -0
- package/dist/src/builders/server/sessionSummaries.mjs +31 -0
- package/dist/src/builders/server/sessionSummaries.mjs.map +1 -0
- package/dist/src/builders/server/shutdown.cjs +23 -0
- package/dist/src/builders/server/shutdown.cjs.map +1 -1
- package/dist/src/builders/server/shutdown.mjs +21 -1
- package/dist/src/builders/server/shutdown.mjs.map +1 -1
- package/dist/src/builders/server/shutdownStack.cjs +44 -0
- package/dist/src/builders/server/shutdownStack.cjs.map +1 -0
- package/dist/src/builders/server/shutdownStack.mjs +43 -0
- package/dist/src/builders/server/shutdownStack.mjs.map +1 -0
- package/dist/src/builders/server/toolBoundaryHold.cjs +55 -0
- package/dist/src/builders/server/toolBoundaryHold.cjs.map +1 -0
- package/dist/src/builders/server/toolBoundaryHold.mjs +55 -0
- package/dist/src/builders/server/toolBoundaryHold.mjs.map +1 -0
- package/dist/src/builders/server/watcherService.cjs +55 -28
- package/dist/src/builders/server/watcherService.cjs.map +1 -1
- package/dist/src/builders/server/watcherService.mjs +55 -27
- package/dist/src/builders/server/watcherService.mjs.map +1 -1
- package/dist/src/builders/server/webTemplateDecision.cjs +7 -3
- package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -1
- package/dist/src/builders/server/webTemplateDecision.mjs +7 -3
- package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -1
- package/dist/src/builders/server/workspaceAdmission.cjs +96 -0
- package/dist/src/builders/server/workspaceAdmission.cjs.map +1 -0
- package/dist/src/builders/server/workspaceAdmission.mjs +90 -0
- package/dist/src/builders/server/workspaceAdmission.mjs.map +1 -0
- package/dist/src/builders/server/workspaceCheckout.cjs +16 -7
- package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -1
- package/dist/src/builders/server/workspaceCheckout.mjs +16 -7
- package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -1
- package/dist/src/builders/web/bundle.cjs +16 -14
- package/dist/src/builders/web/bundle.cjs.map +1 -1
- package/dist/src/builders/web/bundle.d.mts +3 -0
- package/dist/src/builders/web/bundle.d.mts.map +1 -1
- package/dist/src/builders/web/bundle.mjs +15 -13
- package/dist/src/builders/web/bundle.mjs.map +1 -1
- package/dist/src/builders/web/index.cjs +92 -59
- package/dist/src/builders/web/index.cjs.map +1 -1
- package/dist/src/builders/web/index.d.mts +21 -14
- package/dist/src/builders/web/index.d.mts.map +1 -1
- package/dist/src/builders/web/index.mjs +91 -59
- package/dist/src/builders/web/index.mjs.map +1 -1
- package/dist/src/builders/web/webPluginGenerate.cjs +84 -45
- package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -1
- package/dist/src/builders/web/webPluginGenerate.d.mts +13 -4
- package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -1
- package/dist/src/builders/web/webPluginGenerate.mjs +82 -44
- package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -1
- package/dist/src/builders/web/webPluginManifest.cjs +24 -17
- package/dist/src/builders/web/webPluginManifest.cjs.map +1 -1
- package/dist/src/builders/web/webPluginManifest.d.mts +11 -23
- package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -1
- package/dist/src/builders/web/webPluginManifest.mjs +23 -16
- package/dist/src/builders/web/webPluginManifest.mjs.map +1 -1
- package/dist/src/builders/web/webPluginScan.cjs +11 -8
- package/dist/src/builders/web/webPluginScan.cjs.map +1 -1
- package/dist/src/builders/web/webPluginScan.d.mts +1 -1
- package/dist/src/builders/web/webPluginScan.d.mts.map +1 -1
- package/dist/src/builders/web/webPluginScan.mjs +10 -7
- package/dist/src/builders/web/webPluginScan.mjs.map +1 -1
- package/dist/src/builders/web/webPluginVite.cjs +5 -5
- package/dist/src/builders/web/webPluginVite.cjs.map +1 -1
- package/dist/src/builders/web/webPluginVite.d.mts +1 -1
- package/dist/src/builders/web/webPluginVite.d.mts.map +1 -1
- package/dist/src/builders/web/webPluginVite.mjs +3 -3
- package/dist/src/builders/web/webPluginVite.mjs.map +1 -1
- package/dist/src/cli/cliApp.cjs +18 -19
- package/dist/src/cli/cliApp.cjs.map +1 -1
- package/dist/src/cli/cliApp.d.mts +1 -1
- package/dist/src/cli/cliApp.d.mts.map +1 -1
- package/dist/src/cli/cliApp.mjs +18 -19
- package/dist/src/cli/cliApp.mjs.map +1 -1
- package/dist/src/cli/commands/api-export/index.cjs +14 -13
- package/dist/src/cli/commands/api-export/index.cjs.map +1 -1
- package/dist/src/cli/commands/api-export/index.mjs +13 -12
- package/dist/src/cli/commands/api-export/index.mjs.map +1 -1
- package/dist/src/cli/commands/doctor/help.cjs +4 -3
- package/dist/src/cli/commands/doctor/help.cjs.map +1 -1
- package/dist/src/cli/commands/doctor/help.d.mts.map +1 -1
- package/dist/src/cli/commands/doctor/help.mjs +4 -3
- package/dist/src/cli/commands/doctor/help.mjs.map +1 -1
- package/dist/src/cli/commands/doctor/index.cjs +30 -17
- package/dist/src/cli/commands/doctor/index.cjs.map +1 -1
- package/dist/src/cli/commands/doctor/index.d.mts +4 -4
- package/dist/src/cli/commands/doctor/index.d.mts.map +1 -1
- package/dist/src/cli/commands/doctor/index.mjs +28 -15
- package/dist/src/cli/commands/doctor/index.mjs.map +1 -1
- package/dist/src/cli/commands/emit-mcp/index.cjs +3 -2
- package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -1
- package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -1
- package/dist/src/cli/commands/emit-mcp/index.mjs +3 -2
- package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -1
- package/dist/src/cli/commands/explain/index.cjs +53 -38
- package/dist/src/cli/commands/explain/index.cjs.map +1 -1
- package/dist/src/cli/commands/explain/index.d.mts +3 -4
- package/dist/src/cli/commands/explain/index.d.mts.map +1 -1
- package/dist/src/cli/commands/explain/index.mjs +52 -37
- package/dist/src/cli/commands/explain/index.mjs.map +1 -1
- package/dist/src/cli/commands/init/help.cjs +3 -2
- package/dist/src/cli/commands/init/help.cjs.map +1 -1
- package/dist/src/cli/commands/init/help.d.mts.map +1 -1
- package/dist/src/cli/commands/init/help.mjs +3 -2
- package/dist/src/cli/commands/init/help.mjs.map +1 -1
- package/dist/src/cli/commands/init/index.cjs +17 -12
- package/dist/src/cli/commands/init/index.cjs.map +1 -1
- package/dist/src/cli/commands/init/index.d.mts.map +1 -1
- package/dist/src/cli/commands/init/index.mjs +16 -11
- package/dist/src/cli/commands/init/index.mjs.map +1 -1
- package/dist/src/cli/commands/init/presenter.cjs +29 -21
- package/dist/src/cli/commands/init/presenter.cjs.map +1 -1
- package/dist/src/cli/commands/init/presenter.mjs +29 -21
- package/dist/src/cli/commands/init/presenter.mjs.map +1 -1
- package/dist/src/cli/commands/sync/help.cjs +7 -3
- package/dist/src/cli/commands/sync/help.cjs.map +1 -1
- package/dist/src/cli/commands/sync/help.d.mts.map +1 -1
- package/dist/src/cli/commands/sync/help.mjs +7 -3
- package/dist/src/cli/commands/sync/help.mjs.map +1 -1
- package/dist/src/cli/commands/sync/index.cjs +72 -40
- package/dist/src/cli/commands/sync/index.cjs.map +1 -1
- package/dist/src/cli/commands/sync/index.d.mts.map +1 -1
- package/dist/src/cli/commands/sync/index.mjs +69 -37
- package/dist/src/cli/commands/sync/index.mjs.map +1 -1
- package/dist/src/cli/commands/sync/presenter.cjs +10 -1
- package/dist/src/cli/commands/sync/presenter.cjs.map +1 -1
- package/dist/src/cli/commands/sync/presenter.d.mts +0 -9
- package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -1
- package/dist/src/cli/commands/sync/presenter.mjs +10 -1
- package/dist/src/cli/commands/sync/presenter.mjs.map +1 -1
- package/dist/src/cli/commands/web/index.cjs +7 -6
- package/dist/src/cli/commands/web/index.cjs.map +1 -1
- package/dist/src/cli/commands/web/index.mjs +6 -5
- package/dist/src/cli/commands/web/index.mjs.map +1 -1
- package/dist/src/cli/harnessOptions.cjs +15 -24
- package/dist/src/cli/harnessOptions.cjs.map +1 -1
- package/dist/src/cli/harnessOptions.d.mts +2 -2
- package/dist/src/cli/harnessOptions.d.mts.map +1 -1
- package/dist/src/cli/harnessOptions.mjs +14 -22
- package/dist/src/cli/harnessOptions.mjs.map +1 -1
- package/dist/src/cli/help.cjs +20 -26
- package/dist/src/cli/help.cjs.map +1 -1
- package/dist/src/cli/help.d.mts +1 -2
- package/dist/src/cli/help.d.mts.map +1 -1
- package/dist/src/cli/help.mjs +15 -20
- package/dist/src/cli/help.mjs.map +1 -1
- package/dist/src/cli/locale.cjs +30 -0
- package/dist/src/cli/locale.cjs.map +1 -0
- package/dist/src/cli/locale.mjs +27 -0
- package/dist/src/cli/locale.mjs.map +1 -0
- package/dist/src/cli/matrixOptions.cjs +85 -37
- package/dist/src/cli/matrixOptions.cjs.map +1 -1
- package/dist/src/cli/matrixOptions.d.mts +22 -16
- package/dist/src/cli/matrixOptions.d.mts.map +1 -1
- package/dist/src/cli/matrixOptions.mjs +76 -33
- package/dist/src/cli/matrixOptions.mjs.map +1 -1
- package/dist/src/cli/options.cjs +51 -128
- package/dist/src/cli/options.cjs.map +1 -1
- package/dist/src/cli/options.d.mts +1 -1
- package/dist/src/cli/options.d.mts.map +1 -1
- package/dist/src/cli/options.mjs +53 -130
- package/dist/src/cli/options.mjs.map +1 -1
- package/dist/src/cli/router.cjs +0 -1
- package/dist/src/cli/router.cjs.map +1 -1
- package/dist/src/cli/router.d.mts +1 -1
- package/dist/src/cli/router.mjs +0 -1
- package/dist/src/cli/router.mjs.map +1 -1
- package/dist/src/cli/server/options.cjs +37 -7
- package/dist/src/cli/server/options.cjs.map +1 -1
- package/dist/src/cli/server/options.mjs +37 -7
- package/dist/src/cli/server/options.mjs.map +1 -1
- package/dist/src/cli/server/processGuards.cjs +22 -15
- package/dist/src/cli/server/processGuards.cjs.map +1 -1
- package/dist/src/cli/server/processGuards.mjs +21 -14
- package/dist/src/cli/server/processGuards.mjs.map +1 -1
- package/dist/src/cli/server/restartPolicy.cjs +38 -0
- package/dist/src/cli/server/restartPolicy.cjs.map +1 -0
- package/dist/src/cli/server/restartPolicy.d.mts +21 -0
- package/dist/src/cli/server/restartPolicy.d.mts.map +1 -0
- package/dist/src/cli/server/restartPolicy.mjs +36 -0
- package/dist/src/cli/server/restartPolicy.mjs.map +1 -0
- package/dist/src/cli/server/run.cjs +12 -11
- package/dist/src/cli/server/run.cjs.map +1 -1
- package/dist/src/cli/server/run.mjs +11 -10
- package/dist/src/cli/server/run.mjs.map +1 -1
- package/dist/src/cli/server/supervise.cjs +89 -0
- package/dist/src/cli/server/supervise.cjs.map +1 -0
- package/dist/src/cli/server/supervise.mjs +89 -0
- package/dist/src/cli/server/supervise.mjs.map +1 -0
- package/dist/src/composition/harnessState/index.cjs +2 -1
- package/dist/src/composition/harnessState/index.cjs.map +1 -1
- package/dist/src/composition/harnessState/index.d.mts +2 -1
- package/dist/src/composition/harnessState/index.d.mts.map +1 -1
- package/dist/src/composition/harnessState/index.mjs +2 -1
- package/dist/src/composition/harnessState/index.mjs.map +1 -1
- package/dist/src/composition/layerPackageInstaller/index.cjs +293 -86
- package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -1
- package/dist/src/composition/layerPackageInstaller/index.d.mts +25 -2
- package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -1
- package/dist/src/composition/layerPackageInstaller/index.mjs +295 -94
- package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -1
- package/dist/src/composition/marketplaceCatalog/index.cjs +136 -0
- package/dist/src/composition/marketplaceCatalog/index.cjs.map +1 -0
- package/dist/src/composition/marketplaceCatalog/index.mjs +132 -0
- package/dist/src/composition/marketplaceCatalog/index.mjs.map +1 -0
- package/dist/src/composition/orgPluginActivation/index.cjs +179 -0
- package/dist/src/composition/orgPluginActivation/index.cjs.map +1 -0
- package/dist/src/composition/orgPluginActivation/index.mjs +177 -0
- package/dist/src/composition/orgPluginActivation/index.mjs.map +1 -0
- package/dist/src/composition/orgPluginLibrary/index.cjs +205 -0
- package/dist/src/composition/orgPluginLibrary/index.cjs.map +1 -0
- package/dist/src/composition/orgPluginLibrary/index.mjs +200 -0
- package/dist/src/composition/orgPluginLibrary/index.mjs.map +1 -0
- package/dist/src/composition/pluginMarketplace/index.cjs +304 -0
- package/dist/src/composition/pluginMarketplace/index.cjs.map +1 -0
- package/dist/src/composition/pluginMarketplace/index.mjs +302 -0
- package/dist/src/composition/pluginMarketplace/index.mjs.map +1 -0
- package/dist/src/composition/poHomeMigration/index.cjs +46 -26
- package/dist/src/composition/poHomeMigration/index.cjs.map +1 -1
- package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -1
- package/dist/src/composition/poHomeMigration/index.mjs +45 -25
- package/dist/src/composition/poHomeMigration/index.mjs.map +1 -1
- package/dist/src/composition/projectTrust/index.cjs +40 -3
- package/dist/src/composition/projectTrust/index.cjs.map +1 -1
- package/dist/src/composition/projectTrust/index.d.mts +8 -0
- package/dist/src/composition/projectTrust/index.d.mts.map +1 -1
- package/dist/src/composition/projectTrust/index.mjs +33 -2
- package/dist/src/composition/projectTrust/index.mjs.map +1 -1
- package/dist/src/composition/repository/index.cjs +29 -12
- package/dist/src/composition/repository/index.cjs.map +1 -1
- package/dist/src/composition/repository/index.d.mts +10 -3
- package/dist/src/composition/repository/index.d.mts.map +1 -1
- package/dist/src/composition/repository/index.mjs +29 -13
- package/dist/src/composition/repository/index.mjs.map +1 -1
- package/dist/src/composition/syncPrune/index.cjs +23 -16
- package/dist/src/composition/syncPrune/index.cjs.map +1 -1
- package/dist/src/composition/syncPrune/index.d.mts.map +1 -1
- package/dist/src/composition/syncPrune/index.mjs +22 -15
- package/dist/src/composition/syncPrune/index.mjs.map +1 -1
- package/dist/src/composition/syncService/index.cjs +441 -194
- package/dist/src/composition/syncService/index.cjs.map +1 -1
- package/dist/src/composition/syncService/index.d.mts +4 -1
- package/dist/src/composition/syncService/index.d.mts.map +1 -1
- package/dist/src/composition/syncService/index.mjs +440 -196
- package/dist/src/composition/syncService/index.mjs.map +1 -1
- package/dist/src/composition/syncService/localBuilds.cjs +41 -37
- package/dist/src/composition/syncService/localBuilds.cjs.map +1 -1
- package/dist/src/composition/syncService/localBuilds.mjs +40 -37
- package/dist/src/composition/syncService/localBuilds.mjs.map +1 -1
- package/dist/src/composition/transitionLayers.cjs.map +1 -1
- package/dist/src/composition/transitionLayers.d.mts +3 -3
- package/dist/src/composition/transitionLayers.d.mts.map +1 -1
- package/dist/src/composition/transitionLayers.mjs.map +1 -1
- package/dist/src/composition/types/harness.d.mts +4 -9
- package/dist/src/composition/types/harness.d.mts.map +1 -1
- package/dist/src/extensions/setupDiagnostics.cjs +8 -8
- package/dist/src/extensions/setupDiagnostics.cjs.map +1 -1
- package/dist/src/extensions/setupDiagnostics.mjs +8 -8
- package/dist/src/extensions/setupDiagnostics.mjs.map +1 -1
- package/dist/webBuilder.cjs +2 -0
- package/dist/webBuilder.d.mts +3 -3
- package/dist/webBuilder.mjs +3 -3
- package/docs/server/api-export.md +9 -9
- package/docs/server/api.md +22 -125
- package/docs/server/getting-started.md +21 -85
- package/docs/server/index.md +13 -58
- package/docs/server/ipc.md +26 -72
- package/docs/server/lifecycle.md +18 -91
- package/docs/server/security.md +20 -80
- package/locales/vi.json +208 -0
- package/locales/zh-CN.json +208 -0
- package/package.json +52 -69
- package/src/prompts/po-author-extension/SKILL.md +2 -2
- package/src/prompts/po-author-extension/references/extension-contract.md +4 -6
- package/dist/antigravity.cjs +0 -5
- package/dist/antigravity.d.mts +0 -2
- package/dist/antigravity.mjs +0 -1
- package/dist/codex.cjs +0 -8
- package/dist/codex.d.mts +0 -2
- package/dist/codex.mjs +0 -1
- package/dist/compatibility.cjs +0 -27
- package/dist/compatibility.d.mts +0 -6
- package/dist/compatibility.mjs +0 -6
- package/dist/compatibilityCommand.cjs +0 -4
- package/dist/compatibilityCommand.d.mts +0 -2
- package/dist/compatibilityCommand.mjs +0 -1
- package/dist/compatibilityContext.cjs +0 -3
- package/dist/compatibilityContext.d.mts +0 -2
- package/dist/compatibilityContext.mjs +0 -1
- package/dist/compatibilityOptions.cjs +0 -5
- package/dist/compatibilityOptions.d.mts +0 -2
- package/dist/compatibilityOptions.mjs +0 -1
- package/dist/process.cjs +0 -12
- package/dist/process.d.mts +0 -2
- package/dist/process.mjs +0 -1
- package/dist/src/builders/hooks/index.cjs +0 -238
- package/dist/src/builders/hooks/index.cjs.map +0 -1
- package/dist/src/builders/hooks/index.mjs +0 -231
- package/dist/src/builders/hooks/index.mjs.map +0 -1
- package/dist/src/cli/commands/compat/context.cjs +0 -115
- package/dist/src/cli/commands/compat/context.cjs.map +0 -1
- package/dist/src/cli/commands/compat/context.d.mts +0 -22
- package/dist/src/cli/commands/compat/context.d.mts.map +0 -1
- package/dist/src/cli/commands/compat/context.mjs +0 -110
- package/dist/src/cli/commands/compat/context.mjs.map +0 -1
- package/dist/src/cli/commands/compat/help.cjs +0 -26
- package/dist/src/cli/commands/compat/help.cjs.map +0 -1
- package/dist/src/cli/commands/compat/help.d.mts +0 -4
- package/dist/src/cli/commands/compat/help.d.mts.map +0 -1
- package/dist/src/cli/commands/compat/help.mjs +0 -25
- package/dist/src/cli/commands/compat/help.mjs.map +0 -1
- package/dist/src/cli/commands/compat/index.cjs +0 -73
- package/dist/src/cli/commands/compat/index.cjs.map +0 -1
- package/dist/src/cli/commands/compat/index.d.mts +0 -14
- package/dist/src/cli/commands/compat/index.d.mts.map +0 -1
- package/dist/src/cli/commands/compat/index.mjs +0 -70
- package/dist/src/cli/commands/compat/index.mjs.map +0 -1
- package/dist/src/cli/commands/compat/options.cjs +0 -88
- package/dist/src/cli/commands/compat/options.cjs.map +0 -1
- package/dist/src/cli/commands/compat/options.d.mts +0 -15
- package/dist/src/cli/commands/compat/options.d.mts.map +0 -1
- package/dist/src/cli/commands/compat/options.mjs +0 -86
- package/dist/src/cli/commands/compat/options.mjs.map +0 -1
- package/dist/src/cli/commands/compat/providers/antigravity.cjs +0 -294
- package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +0 -1
- package/dist/src/cli/commands/compat/providers/antigravity.d.mts +0 -9
- package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +0 -1
- package/dist/src/cli/commands/compat/providers/antigravity.mjs +0 -289
- package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +0 -1
- package/dist/src/cli/commands/compat/providers/codex.cjs +0 -178
- package/dist/src/cli/commands/compat/providers/codex.cjs.map +0 -1
- package/dist/src/cli/commands/compat/providers/codex.d.mts +0 -17
- package/dist/src/cli/commands/compat/providers/codex.d.mts.map +0 -1
- package/dist/src/cli/commands/compat/providers/codex.mjs +0 -170
- package/dist/src/cli/commands/compat/providers/codex.mjs.map +0 -1
- package/dist/src/cli/commands/compat/providers/index.cjs +0 -65
- package/dist/src/cli/commands/compat/providers/index.cjs.map +0 -1
- package/dist/src/cli/commands/compat/providers/index.d.mts +0 -15
- package/dist/src/cli/commands/compat/providers/index.d.mts.map +0 -1
- package/dist/src/cli/commands/compat/providers/index.mjs +0 -45
- package/dist/src/cli/commands/compat/providers/index.mjs.map +0 -1
- package/dist/src/cli/commands/compat/providers/process.cjs +0 -172
- package/dist/src/cli/commands/compat/providers/process.cjs.map +0 -1
- package/dist/src/cli/commands/compat/providers/process.d.mts +0 -33
- package/dist/src/cli/commands/compat/providers/process.d.mts.map +0 -1
- package/dist/src/cli/commands/compat/providers/process.mjs +0 -159
- package/dist/src/cli/commands/compat/providers/process.mjs.map +0 -1
- package/dist/src/cli/commands/compat/providers/shared.cjs +0 -76
- package/dist/src/cli/commands/compat/providers/shared.cjs.map +0 -1
- package/dist/src/cli/commands/compat/providers/shared.d.mts +0 -40
- package/dist/src/cli/commands/compat/providers/shared.d.mts.map +0 -1
- package/dist/src/cli/commands/compat/providers/shared.mjs +0 -61
- package/dist/src/cli/commands/compat/providers/shared.mjs.map +0 -1
- package/dist/src/cli/commands/compat/types.d.mts +0 -31
- package/dist/src/cli/commands/compat/types.d.mts.map +0 -1
- package/dist/src/cli/commands/init/constants.cjs +0 -11
- package/dist/src/cli/commands/init/constants.cjs.map +0 -1
- package/dist/src/cli/commands/init/constants.mjs +0 -11
- package/dist/src/cli/commands/init/constants.mjs.map +0 -1
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_webPluginScan = require("./webPluginScan.cjs");
|
|
3
|
-
let
|
|
4
|
-
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
3
|
+
let node_module = require("node:module");
|
|
5
4
|
let node_path = require("node:path");
|
|
6
5
|
node_path = require_runtime.__toESM(node_path, 1);
|
|
7
|
-
let
|
|
6
|
+
let node_fs_promises = require("node:fs/promises");
|
|
7
|
+
node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
|
|
8
8
|
let node_url = require("node:url");
|
|
9
|
+
let node_crypto = require("node:crypto");
|
|
9
10
|
//#region src/builders/web/webPluginGenerate.ts
|
|
10
11
|
const HEADER = "// Generated by po web builder. Do not edit by hand.";
|
|
11
|
-
/** The
|
|
12
|
-
const
|
|
12
|
+
/** The templates po-web bundles: Elegant is the default, Advanced and Desktop the alternatives, so all always compile. */
|
|
13
|
+
const FALLBACK_TEMPLATE_PACKAGES = [
|
|
14
|
+
"@agimon-ai/po-template-elegant",
|
|
15
|
+
"@agimon-ai/po-template-advanced",
|
|
16
|
+
"@agimon-ai/po-template-desktop"
|
|
17
|
+
];
|
|
13
18
|
const BUILTIN_CLIENT_MODULE = node_path.default.join("src", "web", "app", "webPlugins.generated.ts");
|
|
14
19
|
const BUILTIN_CSS_MODULE = node_path.default.join("src", "web", "styles", "webPluginSources.generated.css");
|
|
15
20
|
/**
|
|
@@ -24,7 +29,26 @@ function relativeImport(fromDir, toFile) {
|
|
|
24
29
|
const spec = node_path.default.relative(fromDir, toFile).split(node_path.default.sep).join("/");
|
|
25
30
|
return spec.startsWith(".") ? spec : `./${spec}`;
|
|
26
31
|
}
|
|
27
|
-
|
|
32
|
+
/**
|
|
33
|
+
* v1 content identity: SHA-256 of a domain-separated JSON tuple containing the
|
|
34
|
+
* package name, declared version (empty for unpublished packages), declared entry
|
|
35
|
+
* path and its exact bytes (base64). Installation paths, slots and mtimes never
|
|
36
|
+
* enter the digest, so the same published package is reproducible across hosts.
|
|
37
|
+
* Version binds transitive package content; entry bytes also detect local entry
|
|
38
|
+
* edits. This is not a digest of the dependency graph or a code-signing claim.
|
|
39
|
+
*/
|
|
40
|
+
async function webPluginPackageFingerprint(plugin) {
|
|
41
|
+
const manifest = JSON.parse(await node_fs_promises.default.readFile(node_path.default.join(plugin.packageDir, "package.json"), "utf8"));
|
|
42
|
+
const entry = await node_fs_promises.default.readFile(node_path.default.join(plugin.packageDir, plugin.client.entry));
|
|
43
|
+
return (0, node_crypto.createHash)("sha256").update(JSON.stringify([
|
|
44
|
+
"po/web-plugin-package/v1",
|
|
45
|
+
plugin.packageName,
|
|
46
|
+
typeof manifest.version === "string" ? manifest.version : "",
|
|
47
|
+
plugin.client.entry,
|
|
48
|
+
entry.toString("base64")
|
|
49
|
+
])).digest("hex");
|
|
50
|
+
}
|
|
51
|
+
async function renderClientModule(plugins, style, packageRoot) {
|
|
28
52
|
const lines = [HEADER, "import type { WebPluginDefinition } from '@agimon-ai/po-core/web';"];
|
|
29
53
|
const names = [];
|
|
30
54
|
const fromDir = node_path.default.join(packageRoot, "src", "web", "app");
|
|
@@ -32,10 +56,15 @@ function renderClientModule(plugins, style, packageRoot) {
|
|
|
32
56
|
const name = `${slotIdentifier(plugin.slot)}Plugin`;
|
|
33
57
|
names.push(name);
|
|
34
58
|
const entry = node_path.default.join(plugin.packageDir, plugin.client.entry);
|
|
35
|
-
const specifier = style === "relative" ? relativeImport(fromDir, entry) : (0, node_url.pathToFileURL)(
|
|
59
|
+
const specifier = style === "relative" ? relativeImport(fromDir, entry) : (0, node_url.pathToFileURL)(await node_fs_promises.default.realpath(entry)).href;
|
|
36
60
|
lines.push(`import { webPlugin as ${name} } from '${specifier}';`);
|
|
37
61
|
}
|
|
38
|
-
|
|
62
|
+
const packages = await Promise.all(plugins.map(async (plugin) => ({
|
|
63
|
+
packageName: plugin.packageName,
|
|
64
|
+
pluginId: plugin.pluginId,
|
|
65
|
+
fingerprint: await webPluginPackageFingerprint(plugin)
|
|
66
|
+
})));
|
|
67
|
+
lines.push("", `export const webPlugins: readonly WebPluginDefinition[] = [${names.join(", ")}];`, `export const webPluginPackages: readonly { packageName: string; pluginId: string; fingerprint: string }[] = ${JSON.stringify(packages)};`, "");
|
|
39
68
|
return lines.join("\n");
|
|
40
69
|
}
|
|
41
70
|
/**
|
|
@@ -43,7 +72,7 @@ function renderClientModule(plugins, style, packageRoot) {
|
|
|
43
72
|
*
|
|
44
73
|
* `src/extensions` wins, because a plugin's components colocate with the routed
|
|
45
74
|
* file that renders them, in private `_components` and `_lib` folders. The
|
|
46
|
-
* legacy `src/web` root is only a fallback:
|
|
75
|
+
* legacy `src/web` root is only a fallback: an existence check passes for a
|
|
47
76
|
* half-emptied directory holding nothing but a tsconfig, and packages have been
|
|
48
77
|
* in exactly that state, so preferring it would hand Tailwind a directory with
|
|
49
78
|
* no components in it and silently drop every class.
|
|
@@ -52,60 +81,70 @@ function renderClientModule(plugins, style, packageRoot) {
|
|
|
52
81
|
* `src/exports/webClient.ts`, a one-line re-export, or generated outside `src`
|
|
53
82
|
* entirely, so it holds no components either.
|
|
54
83
|
*/
|
|
55
|
-
function pluginSourceRoot(plugin) {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
84
|
+
async function pluginSourceRoot(plugin) {
|
|
85
|
+
for (const root of [node_path.default.join(plugin.packageDir, "src", "extensions"), node_path.default.join(plugin.packageDir, "src", "web")]) if (await node_fs_promises.default.access(root).then(() => true, (error) => {
|
|
86
|
+
if (error.code === "ENOENT") return false;
|
|
87
|
+
throw error;
|
|
88
|
+
})) return root;
|
|
60
89
|
return node_path.default.dirname(node_path.default.join(plugin.packageDir, plugin.client.entry));
|
|
61
90
|
}
|
|
62
91
|
/**
|
|
63
|
-
* Where Tailwind finds
|
|
92
|
+
* Where Tailwind finds a bundled template's classes. app.css names it by a
|
|
64
93
|
* path from its own folder into po-web's node_modules, which holds only in
|
|
65
94
|
* this repository; an installed po-web has the template beside it instead,
|
|
66
95
|
* so a sync build that scanned only that path shipped the cockpit without the
|
|
67
96
|
* template's responsive layout. Resolving it as Node does works in both.
|
|
68
97
|
*/
|
|
69
|
-
function fallbackTemplateSourceRoot(packageRoot) {
|
|
98
|
+
async function fallbackTemplateSourceRoot(packageRoot, name) {
|
|
70
99
|
let manifest;
|
|
71
100
|
try {
|
|
72
|
-
manifest = (0, node_module.createRequire)(node_path.default.join(packageRoot, "package.json")).resolve(`${
|
|
101
|
+
manifest = (0, node_module.createRequire)(node_path.default.join(packageRoot, "package.json")).resolve(`${name}/package.json`);
|
|
73
102
|
} catch {
|
|
74
103
|
return;
|
|
75
104
|
}
|
|
76
105
|
const extensions = node_path.default.join(node_path.default.dirname(manifest), "dist", "extensions");
|
|
77
|
-
return
|
|
106
|
+
return node_fs_promises.default.access(extensions).then(() => extensions, (error) => {
|
|
107
|
+
if (error.code === "ENOENT") return void 0;
|
|
108
|
+
throw error;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/** Every bundled template that is installed, in FALLBACK_TEMPLATE_PACKAGES order. */
|
|
112
|
+
async function fallbackTemplateSourceRoots(packageRoot) {
|
|
113
|
+
return (await Promise.all(FALLBACK_TEMPLATE_PACKAGES.map((name) => fallbackTemplateSourceRoot(packageRoot, name)))).filter((root) => root !== void 0);
|
|
78
114
|
}
|
|
79
|
-
function renderCssModule(plugins, leadingSourceRoots) {
|
|
115
|
+
async function renderCssModule(plugins, leadingSourceRoots) {
|
|
80
116
|
const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source "${root}";`)];
|
|
81
117
|
for (const plugin of plugins) {
|
|
82
118
|
if (plugin.isHost) continue;
|
|
83
|
-
lines.push(`@source "${pluginSourceRoot(plugin)}";`);
|
|
119
|
+
lines.push(`@source "${await pluginSourceRoot(plugin)}";`);
|
|
84
120
|
}
|
|
85
121
|
lines.push("");
|
|
86
122
|
return lines.join("\n");
|
|
87
123
|
}
|
|
88
124
|
/** The committed client registry, rendered from the host package alone. */
|
|
89
|
-
function renderBuiltinWebPluginModules(packageRoot) {
|
|
90
|
-
const plugins = require_webPluginScan.scanWebPlugins(packageRoot);
|
|
91
|
-
return /* @__PURE__ */ new Map([[BUILTIN_CLIENT_MODULE, renderClientModule(plugins, "relative", packageRoot)], [BUILTIN_CSS_MODULE, renderCssModule(plugins, [])]]);
|
|
125
|
+
async function renderBuiltinWebPluginModules(packageRoot) {
|
|
126
|
+
const plugins = await require_webPluginScan.scanWebPlugins(packageRoot);
|
|
127
|
+
return /* @__PURE__ */ new Map([[BUILTIN_CLIENT_MODULE, await renderClientModule(plugins, "relative", packageRoot)], [BUILTIN_CSS_MODULE, await renderCssModule(plugins, [])]]);
|
|
92
128
|
}
|
|
93
129
|
/**
|
|
94
130
|
* Keeps the committed client registry fresh: write-if-changed locally,
|
|
95
131
|
* check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call
|
|
96
132
|
* this at config-load time.
|
|
97
133
|
*/
|
|
98
|
-
function ensureBuiltinWebPluginModules({ packageRoot, check = false }) {
|
|
134
|
+
async function ensureBuiltinWebPluginModules({ packageRoot, check = false }) {
|
|
99
135
|
const stale = [];
|
|
100
|
-
for (const [relativePath, content] of renderBuiltinWebPluginModules(packageRoot)) {
|
|
136
|
+
for (const [relativePath, content] of await renderBuiltinWebPluginModules(packageRoot)) {
|
|
101
137
|
const filePath = node_path.default.join(packageRoot, relativePath);
|
|
102
|
-
if (
|
|
138
|
+
if (await node_fs_promises.default.readFile(filePath, "utf8").catch((error) => {
|
|
139
|
+
if (error.code === "ENOENT") return void 0;
|
|
140
|
+
throw error;
|
|
141
|
+
}) === content) continue;
|
|
103
142
|
if (check) {
|
|
104
143
|
stale.push(relativePath);
|
|
105
144
|
continue;
|
|
106
145
|
}
|
|
107
|
-
|
|
108
|
-
|
|
146
|
+
await node_fs_promises.default.mkdir(node_path.default.dirname(filePath), { recursive: true });
|
|
147
|
+
await node_fs_promises.default.writeFile(filePath, content);
|
|
109
148
|
}
|
|
110
149
|
if (stale.length > 0) throw new Error(`Stale generated web plugin modules: ${stale.join(", ")}. Run pnpm build in po-web and commit them.`);
|
|
111
150
|
}
|
|
@@ -113,15 +152,15 @@ function ensureBuiltinWebPluginModules({ packageRoot, check = false }) {
|
|
|
113
152
|
const BASE_STYLE_ENTRY = "base";
|
|
114
153
|
const pluginStyleEntryName = (slot) => `plugin-${slot}`;
|
|
115
154
|
/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */
|
|
116
|
-
function writeWebPluginStyleEntries(plugins, generatedDir, packageRoot) {
|
|
155
|
+
async function writeWebPluginStyleEntries(plugins, generatedDir, packageRoot) {
|
|
117
156
|
const stylesDir = node_path.default.join(generatedDir, "styles");
|
|
118
|
-
|
|
119
|
-
const
|
|
157
|
+
await node_fs_promises.default.mkdir(stylesDir, { recursive: true });
|
|
158
|
+
const fallbackTemplates = await fallbackTemplateSourceRoots(packageRoot);
|
|
120
159
|
const baseSourcesPath = node_path.default.join(generatedDir, "webPluginBaseSources.generated.css");
|
|
121
|
-
|
|
122
|
-
const appCss = relativeImport(
|
|
160
|
+
await node_fs_promises.default.writeFile(baseSourcesPath, await renderCssModule(plugins, [node_path.default.join(packageRoot, "src", "web"), ...fallbackTemplates]));
|
|
161
|
+
const appCss = relativeImport(await node_fs_promises.default.realpath(stylesDir), await node_fs_promises.default.realpath(node_path.default.join(packageRoot, "src", "web", "styles", "app.css")));
|
|
123
162
|
const baseEntryPath = node_path.default.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);
|
|
124
|
-
|
|
163
|
+
await node_fs_promises.default.writeFile(baseEntryPath, `/* ${HEADER.slice(3)} */\n@import '${appCss}';\n`);
|
|
125
164
|
return {
|
|
126
165
|
baseSourcesPath,
|
|
127
166
|
baseEntryPath,
|
|
@@ -133,30 +172,29 @@ function writeWebPluginStyleEntries(plugins, generatedDir, packageRoot) {
|
|
|
133
172
|
* the installed composition's packages) into a generation directory the bundler
|
|
134
173
|
* aliases over the committed builtin modules.
|
|
135
174
|
*/
|
|
136
|
-
function writeSyncWebPluginModules(plugins, generatedDir, packageRoot) {
|
|
137
|
-
|
|
175
|
+
async function writeSyncWebPluginModules(plugins, generatedDir, packageRoot) {
|
|
176
|
+
await node_fs_promises.default.mkdir(generatedDir, { recursive: true });
|
|
138
177
|
const clientModulePath = node_path.default.join(generatedDir, "webPlugins.generated.ts");
|
|
139
178
|
const cssModulePath = node_path.default.join(generatedDir, "webPluginSources.generated.css");
|
|
140
|
-
|
|
179
|
+
await node_fs_promises.default.writeFile(clientModulePath, await renderClientModule(plugins, "absolute", packageRoot));
|
|
141
180
|
const slotsDir = node_path.default.join(generatedDir, "slots");
|
|
142
|
-
|
|
181
|
+
await node_fs_promises.default.mkdir(slotsDir, { recursive: true });
|
|
143
182
|
const slotEntryPaths = {};
|
|
144
183
|
for (const plugin of plugins) {
|
|
145
184
|
const entryPath = node_path.default.join(slotsDir, `${plugin.slot}.ts`);
|
|
146
|
-
const specifier = (0, node_url.pathToFileURL)(
|
|
147
|
-
|
|
185
|
+
const specifier = (0, node_url.pathToFileURL)(await node_fs_promises.default.realpath(node_path.default.join(plugin.packageDir, plugin.client.entry))).href;
|
|
186
|
+
await node_fs_promises.default.writeFile(entryPath, `${HEADER}\nexport { webPlugin } from '${specifier}';\n`);
|
|
148
187
|
slotEntryPaths[plugin.slot] = entryPath;
|
|
149
188
|
}
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
node_fs.default.writeFileSync(cssModulePath, renderCssModule(plugins, leadingSourceRoots));
|
|
189
|
+
const leadingSourceRoots = [node_path.default.join(packageRoot, "src", "web"), ...await fallbackTemplateSourceRoots(packageRoot)];
|
|
190
|
+
await node_fs_promises.default.writeFile(cssModulePath, await renderCssModule(plugins, leadingSourceRoots));
|
|
153
191
|
const hostPlugins = plugins.filter((plugin) => plugin.isHost);
|
|
154
192
|
const shell = {
|
|
155
193
|
clientModulePath: node_path.default.join(generatedDir, "webPluginShell.generated.ts"),
|
|
156
194
|
cssModulePath: node_path.default.join(generatedDir, "webPluginShellSources.generated.css")
|
|
157
195
|
};
|
|
158
|
-
|
|
159
|
-
|
|
196
|
+
await node_fs_promises.default.writeFile(shell.clientModulePath, await renderClientModule(hostPlugins, "absolute", packageRoot));
|
|
197
|
+
await node_fs_promises.default.writeFile(shell.cssModulePath, await renderCssModule(hostPlugins, leadingSourceRoots));
|
|
160
198
|
return {
|
|
161
199
|
clientModulePath,
|
|
162
200
|
slotEntryPaths,
|
|
@@ -171,6 +209,7 @@ exports.BUILTIN_CSS_MODULE = BUILTIN_CSS_MODULE;
|
|
|
171
209
|
exports.ensureBuiltinWebPluginModules = ensureBuiltinWebPluginModules;
|
|
172
210
|
exports.pluginStyleEntryName = pluginStyleEntryName;
|
|
173
211
|
exports.renderBuiltinWebPluginModules = renderBuiltinWebPluginModules;
|
|
212
|
+
exports.webPluginPackageFingerprint = webPluginPackageFingerprint;
|
|
174
213
|
exports.writeSyncWebPluginModules = writeSyncWebPluginModules;
|
|
175
214
|
exports.writeWebPluginStyleEntries = writeWebPluginStyleEntries;
|
|
176
215
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webPluginGenerate.cjs","names":["path","pathToFileURL","fs","createRequire","scanWebPlugins"],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { DeclaredWebPlugin } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\n\nconst HEADER = '// Generated by po web builder. Do not edit by hand.';\n/** The template po-web renders when a composition names none, so its classes always compile. */\nconst FALLBACK_TEMPLATE_PACKAGE = '@agimon-ai/po-template-advanced';\nexport const BUILTIN_CLIENT_MODULE = path.join('src', 'web', 'app', 'webPlugins.generated.ts');\nexport const BUILTIN_CSS_MODULE = path.join('src', 'web', 'styles', 'webPluginSources.generated.css');\n\n/**\n * The import name of one plugin copy, derived from its slot so two copies of one pluginId\n * never collide. A host slot is its kebab-case pluginId and keeps the committed module's\n * names; a copy slot's '.' becomes '_', which no host name can contain.\n */\nfunction slotIdentifier(slot: string): string {\n return slot.replace(/-([a-z0-9])/g, (_, ch: string) => ch.toUpperCase()).replace(/[^A-Za-z0-9_$]/g, '_');\n}\n\nfunction relativeImport(fromDir: string, toFile: string): string {\n const spec = path.relative(fromDir, toFile).split(path.sep).join('/');\n return spec.startsWith('.') ? spec : `./${spec}`;\n}\n\nfunction renderClientModule(\n plugins: readonly DeclaredWebPlugin[],\n style: 'relative' | 'absolute',\n packageRoot: string,\n): string {\n const lines = [HEADER, \"import type { WebPluginDefinition } from '@agimon-ai/po-core/web';\"];\n const names: string[] = [];\n const fromDir = path.join(packageRoot, 'src', 'web', 'app');\n for (const plugin of plugins) {\n const name = `${slotIdentifier(plugin.slot)}Plugin`;\n names.push(name);\n const entry = path.join(plugin.packageDir, plugin.client.entry);\n // The committed builtin module keeps machine-neutral relative imports; the\n // sync-generated module lives outside src, is aliased over the committed\n // path, and resolves imports against its real location, so every entry\n // becomes an absolute file URL into the installed packages.\n const specifier =\n style === 'relative' ? relativeImport(fromDir, entry) : pathToFileURL(fs.realpathSync(entry)).href;\n lines.push(`import { webPlugin as ${name} } from '${specifier}';`);\n }\n lines.push('', `export const webPlugins: readonly WebPluginDefinition[] = [${names.join(', ')}];`, '');\n return lines.join('\\n');\n}\n\n/**\n * The directory Tailwind scans for a plugin's class names.\n *\n * `src/extensions` wins, because a plugin's components colocate with the routed\n * file that renders them, in private `_components` and `_lib` folders. The\n * legacy `src/web` root is only a fallback: `existsSync` is true for a\n * half-emptied directory holding nothing but a tsconfig, and packages have been\n * in exactly that state, so preferring it would hand Tailwind a directory with\n * no components in it and silently drop every class.\n *\n * The client entry's own directory is the last resort. It is published through\n * `src/exports/webClient.ts`, a one-line re-export, or generated outside `src`\n * entirely, so it holds no components either.\n */\nfunction pluginSourceRoot(plugin: DeclaredWebPlugin): string {\n const routingRoot = path.join(plugin.packageDir, 'src', 'extensions');\n if (fs.existsSync(routingRoot)) return routingRoot;\n const webRoot = path.join(plugin.packageDir, 'src', 'web');\n if (fs.existsSync(webRoot)) return webRoot;\n return path.dirname(path.join(plugin.packageDir, plugin.client.entry));\n}\n\n/**\n * Where Tailwind finds the fallback template's classes. app.css names it by a\n * path from its own folder into po-web's node_modules, which holds only in\n * this repository; an installed po-web has the template beside it instead,\n * so a sync build that scanned only that path shipped the cockpit without the\n * template's responsive layout. Resolving it as Node does works in both.\n */\nfunction fallbackTemplateSourceRoot(packageRoot: string): string | undefined {\n let manifest: string;\n try {\n manifest = createRequire(path.join(packageRoot, 'package.json')).resolve(\n `${FALLBACK_TEMPLATE_PACKAGE}/package.json`,\n );\n } catch {\n // Not installed: the cockpit then has no fallback template to render either.\n return undefined;\n }\n const extensions = path.join(path.dirname(manifest), 'dist', 'extensions');\n return fs.existsSync(extensions) ? extensions : undefined;\n}\n\nfunction renderCssModule(plugins: readonly DeclaredWebPlugin[], leadingSourceRoots: readonly string[]): string {\n // Sync CSS is compiled from a generated directory, so Tailwind cannot infer\n // the stable shell tree from app.css. Its caller names that tree explicitly\n // so later plugin utilities do not override missing responsive shell utilities.\n const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source \"${root}\";`)];\n for (const plugin of plugins) {\n if (plugin.isHost) continue;\n lines.push(`@source \"${pluginSourceRoot(plugin)}\";`);\n }\n lines.push('');\n return lines.join('\\n');\n}\n\n/** The committed client registry, rendered from the host package alone. */\nexport function renderBuiltinWebPluginModules(packageRoot: string): Map<string, string> {\n const plugins = scanWebPlugins(packageRoot);\n return new Map([\n [BUILTIN_CLIENT_MODULE, renderClientModule(plugins, 'relative', packageRoot)],\n [BUILTIN_CSS_MODULE, renderCssModule(plugins, [])],\n ]);\n}\n\n/**\n * Keeps the committed client registry fresh: write-if-changed locally,\n * check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call\n * this at config-load time.\n */\nexport function ensureBuiltinWebPluginModules({\n packageRoot,\n check = false,\n}: {\n packageRoot: string;\n check?: boolean;\n}): void {\n const stale: string[] = [];\n for (const [relativePath, content] of renderBuiltinWebPluginModules(packageRoot)) {\n const filePath = path.join(packageRoot, relativePath);\n const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : undefined;\n if (existing === content) continue;\n if (check) {\n stale.push(relativePath);\n continue;\n }\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n fs.writeFileSync(filePath, content);\n }\n if (stale.length > 0) {\n throw new Error(\n `Stale generated web plugin modules: ${stale.join(', ')}. Run pnpm build in po-web and commit them.`,\n );\n }\n}\n\n/** A client plugin registry and the Tailwind source list that goes with it. */\nexport interface WebPluginRegistryModules {\n clientModulePath: string;\n cssModulePath: string;\n}\n\nexport interface SyncGeneratedModules extends WebPluginRegistryModules {\n /** One entry module per slot, each re-exporting only that copy's `webPlugin`. */\n slotEntryPaths: Record<string, string>;\n /**\n * The signed shell's registry: host plugins only. Every other plugin reaches the\n * browser through its slot entry, and the global mount replaces the shell's\n * registry once it loads, so compiling them into the shell too shipped each plugin's\n * code and emitted assets (the voice VAD model among them) a second time.\n */\n shell: WebPluginRegistryModules;\n}\n\nexport interface WebPluginStyleEntries {\n /** Shell, fallback-template, and plugin sources, aliased over app.css's source list. */\n baseSourcesPath: string;\n /** The shared Tailwind entry every mount loads. */\n baseEntryPath: string;\n /** ponytail: empty compatibility field; remove only with a public webBuilder API change. */\n pluginEntryPaths: Map<string, string>;\n}\n\n/** The shared stylesheet's Rollup input name. */\nexport const BASE_STYLE_ENTRY = 'base';\nexport const pluginStyleEntryName = (slot: string): string => `plugin-${slot}`;\n\n/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */\nexport function writeWebPluginStyleEntries(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): WebPluginStyleEntries {\n const stylesDir = path.join(generatedDir, 'styles');\n fs.mkdirSync(stylesDir, { recursive: true });\n const fallbackTemplate = fallbackTemplateSourceRoot(packageRoot);\n const baseSourcesPath = path.join(generatedDir, 'webPluginBaseSources.generated.css');\n fs.writeFileSync(\n baseSourcesPath,\n renderCssModule(plugins, [\n path.join(packageRoot, 'src', 'web'),\n ...(fallbackTemplate === undefined ? [] : [fallbackTemplate]),\n ]),\n );\n // Resolvers follow real paths (a temp dir under /var is /private/var), so relate real paths.\n const appCss = relativeImport(\n fs.realpathSync(stylesDir),\n fs.realpathSync(path.join(packageRoot, 'src', 'web', 'styles', 'app.css')),\n );\n const baseEntryPath = path.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);\n fs.writeFileSync(baseEntryPath, `/* ${HEADER.slice(3)} */\\n@import '${appCss}';\\n`);\n const pluginEntryPaths = new Map<string, string>();\n return { baseSourcesPath, baseEntryPath, pluginEntryPaths };\n}\n\n/**\n * The sync-time variant: renders the full client plugin set (host built-ins plus\n * the installed composition's packages) into a generation directory the bundler\n * aliases over the committed builtin modules.\n */\nexport function writeSyncWebPluginModules(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): SyncGeneratedModules {\n fs.mkdirSync(generatedDir, { recursive: true });\n const clientModulePath = path.join(generatedDir, 'webPlugins.generated.ts');\n const cssModulePath = path.join(generatedDir, 'webPluginSources.generated.css');\n fs.writeFileSync(clientModulePath, renderClientModule(plugins, 'absolute', packageRoot));\n // Tailwind styles compile separately as one shared sheet, so slot entries carry none.\n const slotsDir = path.join(generatedDir, 'slots');\n fs.mkdirSync(slotsDir, { recursive: true });\n const slotEntryPaths: Record<string, string> = {};\n for (const plugin of plugins) {\n const entryPath = path.join(slotsDir, `${plugin.slot}.ts`);\n const specifier = pathToFileURL(fs.realpathSync(path.join(plugin.packageDir, plugin.client.entry))).href;\n fs.writeFileSync(entryPath, `${HEADER}\\nexport { webPlugin } from '${specifier}';\\n`);\n slotEntryPaths[plugin.slot] = entryPath;\n }\n const fallbackTemplate = fallbackTemplateSourceRoot(packageRoot);\n const leadingSourceRoots = [\n path.join(packageRoot, 'src', 'web'),\n ...(fallbackTemplate === undefined ? [] : [fallbackTemplate]),\n ];\n fs.writeFileSync(cssModulePath, renderCssModule(plugins, leadingSourceRoots));\n const hostPlugins = plugins.filter((plugin) => plugin.isHost);\n const shell = {\n clientModulePath: path.join(generatedDir, 'webPluginShell.generated.ts'),\n cssModulePath: path.join(generatedDir, 'webPluginShellSources.generated.css'),\n };\n fs.writeFileSync(shell.clientModulePath, renderClientModule(hostPlugins, 'absolute', packageRoot));\n fs.writeFileSync(shell.cssModulePath, renderCssModule(hostPlugins, leadingSourceRoots));\n return {\n clientModulePath,\n slotEntryPaths,\n cssModulePath,\n shell,\n };\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,SAAS;;AAEf,MAAM,4BAA4B;AAClC,MAAa,wBAAwBA,UAAAA,QAAK,KAAK,OAAO,OAAO,OAAO,yBAAyB;AAC7F,MAAa,qBAAqBA,UAAAA,QAAK,KAAK,OAAO,OAAO,UAAU,gCAAgC;;;;;;AAOpG,SAAS,eAAe,MAAsB;CAC5C,OAAO,KAAK,QAAQ,iBAAiB,GAAG,OAAe,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ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G,cAAc,kBAAkB,mBAAmB,SAAS,YAAY,WAAW,CAAC;CAEvF,MAAM,WAAWA,UAAAA,QAAK,KAAK,cAAc,OAAO;CAChD,QAAA,QAAG,UAAU,UAAU,EAAE,WAAW,KAAK,CAAC;CAC1C,MAAM,iBAAyC,CAAC;CAChD,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,YAAYA,UAAAA,QAAK,KAAK,UAAU,GAAG,OAAO,KAAK,IAAI;EACzD,MAAM,aAAA,GAAYC,SAAAA,cAAAA,CAAcC,QAAAA,QAAG,aAAaF,UAAAA,QAAK,KAAK,OAAO,YAAY,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;EACpG,QAAA,QAAG,cAAc,WAAW,GAAG,OAAO,+BAA+B,UAAU,KAAK;EACpF,eAAe,OAAO,QAAQ;CAChC;CACA,MAAM,mBAAmB,2BAA2B,WAAW;CAC/D,MAAM,qBAAqB,CACzBA,UAAAA,QAAK,KAAK,aAAa,OAAO,KAAK,GACnC,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,CAAC,gBAAgB,CAC7D;CACA,QAAA,QAAG,cAAc,eAAe,gBAAgB,SAAS,kBAAkB,CAAC;CAC5E,MAAM,cAAc,QAAQ,QAAQ,WAAW,OAAO,MAAM;CAC5D,MAAM,QAAQ;EACZ,kBAAkBA,UAAAA,QAAK,KAAK,cAAc,6BAA6B;EACvE,eAAeA,UAAAA,QAAK,KAAK,cAAc,qCAAqC;CAC9E;CACA,QAAA,QAAG,cAAc,MAAM,kBAAkB,mBAAmB,aAAa,YAAY,WAAW,CAAC;CACjG,QAAA,QAAG,cAAc,MAAM,eAAe,gBAAgB,aAAa,kBAAkB,CAAC;CACtF,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"webPluginGenerate.cjs","names":["path","fs","createHash","pathToFileURL","createRequire","scanWebPlugins"],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { DeclaredWebPlugin } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\n\nconst HEADER = '// Generated by po web builder. Do not edit by hand.';\n/** The templates po-web bundles: Elegant is the default, Advanced and Desktop the alternatives, so all always compile. */\nconst FALLBACK_TEMPLATE_PACKAGES = [\n '@agimon-ai/po-template-elegant',\n '@agimon-ai/po-template-advanced',\n '@agimon-ai/po-template-desktop',\n];\nexport const BUILTIN_CLIENT_MODULE = path.join('src', 'web', 'app', 'webPlugins.generated.ts');\nexport const BUILTIN_CSS_MODULE = path.join('src', 'web', 'styles', 'webPluginSources.generated.css');\n\n/**\n * The import name of one plugin copy, derived from its slot so two copies of one pluginId\n * never collide. A host slot is its kebab-case pluginId and keeps the committed module's\n * names; a copy slot's '.' becomes '_', which no host name can contain.\n */\nfunction slotIdentifier(slot: string): string {\n return slot.replace(/-([a-z0-9])/g, (_, ch: string) => ch.toUpperCase()).replace(/[^A-Za-z0-9_$]/g, '_');\n}\n\nfunction relativeImport(fromDir: string, toFile: string): string {\n const spec = path.relative(fromDir, toFile).split(path.sep).join('/');\n return spec.startsWith('.') ? spec : `./${spec}`;\n}\n\n/**\n * v1 content identity: SHA-256 of a domain-separated JSON tuple containing the\n * package name, declared version (empty for unpublished packages), declared entry\n * path and its exact bytes (base64). Installation paths, slots and mtimes never\n * enter the digest, so the same published package is reproducible across hosts.\n * Version binds transitive package content; entry bytes also detect local entry\n * edits. This is not a digest of the dependency graph or a code-signing claim.\n */\nexport async function webPluginPackageFingerprint(plugin: DeclaredWebPlugin): Promise<string> {\n const manifest: { version?: unknown } = JSON.parse(\n await fs.readFile(path.join(plugin.packageDir, 'package.json'), 'utf8'),\n );\n const entry = await fs.readFile(path.join(plugin.packageDir, plugin.client.entry));\n return createHash('sha256')\n .update(\n JSON.stringify([\n 'po/web-plugin-package/v1',\n plugin.packageName,\n typeof manifest.version === 'string' ? manifest.version : '',\n plugin.client.entry,\n entry.toString('base64'),\n ]),\n )\n .digest('hex');\n}\n\nasync function renderClientModule(\n plugins: readonly DeclaredWebPlugin[],\n style: 'relative' | 'absolute',\n packageRoot: string,\n): Promise<string> {\n const lines = [HEADER, \"import type { WebPluginDefinition } from '@agimon-ai/po-core/web';\"];\n const names: string[] = [];\n const fromDir = path.join(packageRoot, 'src', 'web', 'app');\n for (const plugin of plugins) {\n const name = `${slotIdentifier(plugin.slot)}Plugin`;\n names.push(name);\n const entry = path.join(plugin.packageDir, plugin.client.entry);\n // The committed builtin module keeps machine-neutral relative imports; the\n // sync-generated module lives outside src, is aliased over the committed\n // path, and resolves imports against its real location, so every entry\n // becomes an absolute file URL into the installed packages.\n const specifier =\n style === 'relative' ? relativeImport(fromDir, entry) : pathToFileURL(await fs.realpath(entry)).href;\n lines.push(`import { webPlugin as ${name} } from '${specifier}';`);\n }\n const packages = await Promise.all(\n plugins.map(async (plugin) => ({\n packageName: plugin.packageName,\n pluginId: plugin.pluginId,\n fingerprint: await webPluginPackageFingerprint(plugin),\n })),\n );\n lines.push(\n '',\n `export const webPlugins: readonly WebPluginDefinition[] = [${names.join(', ')}];`,\n `export const webPluginPackages: readonly { packageName: string; pluginId: string; fingerprint: string }[] = ${JSON.stringify(packages)};`,\n '',\n );\n return lines.join('\\n');\n}\n\n/**\n * The directory Tailwind scans for a plugin's class names.\n *\n * `src/extensions` wins, because a plugin's components colocate with the routed\n * file that renders them, in private `_components` and `_lib` folders. The\n * legacy `src/web` root is only a fallback: an existence check passes for a\n * half-emptied directory holding nothing but a tsconfig, and packages have been\n * in exactly that state, so preferring it would hand Tailwind a directory with\n * no components in it and silently drop every class.\n *\n * The client entry's own directory is the last resort. It is published through\n * `src/exports/webClient.ts`, a one-line re-export, or generated outside `src`\n * entirely, so it holds no components either.\n */\nasync function pluginSourceRoot(plugin: DeclaredWebPlugin): Promise<string> {\n for (const root of [path.join(plugin.packageDir, 'src', 'extensions'), path.join(plugin.packageDir, 'src', 'web')]) {\n const exists = await fs.access(root).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return false;\n throw error;\n },\n );\n if (exists) return root;\n }\n return path.dirname(path.join(plugin.packageDir, plugin.client.entry));\n}\n\n/**\n * Where Tailwind finds a bundled template's classes. app.css names it by a\n * path from its own folder into po-web's node_modules, which holds only in\n * this repository; an installed po-web has the template beside it instead,\n * so a sync build that scanned only that path shipped the cockpit without the\n * template's responsive layout. Resolving it as Node does works in both.\n */\nasync function fallbackTemplateSourceRoot(packageRoot: string, name: string): Promise<string | undefined> {\n let manifest: string;\n try {\n manifest = createRequire(path.join(packageRoot, 'package.json')).resolve(`${name}/package.json`);\n } catch {\n // Not installed: the cockpit then has no fallback template to render either.\n return undefined;\n }\n const extensions = path.join(path.dirname(manifest), 'dist', 'extensions');\n return fs.access(extensions).then(\n () => extensions,\n (error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n },\n );\n}\n\n/** Every bundled template that is installed, in FALLBACK_TEMPLATE_PACKAGES order. */\nasync function fallbackTemplateSourceRoots(packageRoot: string): Promise<string[]> {\n const roots = await Promise.all(\n FALLBACK_TEMPLATE_PACKAGES.map((name) => fallbackTemplateSourceRoot(packageRoot, name)),\n );\n return roots.filter((root) => root !== undefined);\n}\n\nasync function renderCssModule(\n plugins: readonly DeclaredWebPlugin[],\n leadingSourceRoots: readonly string[],\n): Promise<string> {\n // Sync CSS is compiled from a generated directory, so Tailwind cannot infer\n // the stable shell tree from app.css. Its caller names that tree explicitly\n // so later plugin utilities do not override missing responsive shell utilities.\n const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source \"${root}\";`)];\n for (const plugin of plugins) {\n if (plugin.isHost) continue;\n lines.push(`@source \"${await pluginSourceRoot(plugin)}\";`);\n }\n lines.push('');\n return lines.join('\\n');\n}\n\n/** The committed client registry, rendered from the host package alone. */\nexport async function renderBuiltinWebPluginModules(packageRoot: string): Promise<Map<string, string>> {\n const plugins = await scanWebPlugins(packageRoot);\n return new Map([\n [BUILTIN_CLIENT_MODULE, await renderClientModule(plugins, 'relative', packageRoot)],\n [BUILTIN_CSS_MODULE, await renderCssModule(plugins, [])],\n ]);\n}\n\n/**\n * Keeps the committed client registry fresh: write-if-changed locally,\n * check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call\n * this at config-load time.\n */\nexport async function ensureBuiltinWebPluginModules({\n packageRoot,\n check = false,\n}: {\n packageRoot: string;\n check?: boolean;\n}): Promise<void> {\n const stale: string[] = [];\n for (const [relativePath, content] of await renderBuiltinWebPluginModules(packageRoot)) {\n const filePath = path.join(packageRoot, relativePath);\n const existing = await fs.readFile(filePath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (existing === content) continue;\n if (check) {\n stale.push(relativePath);\n continue;\n }\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, content);\n }\n if (stale.length > 0) {\n throw new Error(\n `Stale generated web plugin modules: ${stale.join(', ')}. Run pnpm build in po-web and commit them.`,\n );\n }\n}\n\n/** A client plugin registry and the Tailwind source list that goes with it. */\nexport interface WebPluginRegistryModules {\n clientModulePath: string;\n cssModulePath: string;\n}\n\nexport interface SyncGeneratedModules extends WebPluginRegistryModules {\n /** One entry module per slot, each re-exporting only that copy's `webPlugin`. */\n slotEntryPaths: Record<string, string>;\n /**\n * The signed shell's registry: host plugins only. Every other plugin reaches the\n * browser through its slot entry, and the global mount replaces the shell's\n * registry once it loads, so compiling them into the shell too shipped each plugin's\n * code and emitted assets (the voice VAD model among them) a second time.\n */\n shell: WebPluginRegistryModules;\n}\n\nexport interface WebPluginStyleEntries {\n /** Shell, fallback-template, and plugin sources, aliased over app.css's source list. */\n baseSourcesPath: string;\n /** The shared Tailwind entry every mount loads. */\n baseEntryPath: string;\n /** ponytail: empty compatibility field; remove only with a public webBuilder API change. */\n pluginEntryPaths: Map<string, string>;\n}\n\n/** The shared stylesheet's Rollup input name. */\nexport const BASE_STYLE_ENTRY = 'base';\nexport const pluginStyleEntryName = (slot: string): string => `plugin-${slot}`;\n\n/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */\nexport async function writeWebPluginStyleEntries(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<WebPluginStyleEntries> {\n const stylesDir = path.join(generatedDir, 'styles');\n await fs.mkdir(stylesDir, { recursive: true });\n const fallbackTemplates = await fallbackTemplateSourceRoots(packageRoot);\n const baseSourcesPath = path.join(generatedDir, 'webPluginBaseSources.generated.css');\n await fs.writeFile(\n baseSourcesPath,\n await renderCssModule(plugins, [path.join(packageRoot, 'src', 'web'), ...fallbackTemplates]),\n );\n // Resolvers follow real paths (a temp dir under /var is /private/var), so relate real paths.\n const appCss = relativeImport(\n await fs.realpath(stylesDir),\n await fs.realpath(path.join(packageRoot, 'src', 'web', 'styles', 'app.css')),\n );\n const baseEntryPath = path.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);\n await fs.writeFile(baseEntryPath, `/* ${HEADER.slice(3)} */\\n@import '${appCss}';\\n`);\n const pluginEntryPaths = new Map<string, string>();\n return { baseSourcesPath, baseEntryPath, pluginEntryPaths };\n}\n\n/**\n * The sync-time variant: renders the full client plugin set (host built-ins plus\n * the installed composition's packages) into a generation directory the bundler\n * aliases over the committed builtin modules.\n */\nexport async function writeSyncWebPluginModules(\n plugins: readonly DeclaredWebPlugin[],\n generatedDir: string,\n packageRoot: string,\n): Promise<SyncGeneratedModules> {\n await fs.mkdir(generatedDir, { recursive: true });\n const clientModulePath = path.join(generatedDir, 'webPlugins.generated.ts');\n const cssModulePath = path.join(generatedDir, 'webPluginSources.generated.css');\n await fs.writeFile(clientModulePath, await renderClientModule(plugins, 'absolute', packageRoot));\n // Tailwind styles compile separately as one shared sheet, so slot entries carry none.\n const slotsDir = path.join(generatedDir, 'slots');\n await fs.mkdir(slotsDir, { recursive: true });\n const slotEntryPaths: Record<string, string> = {};\n for (const plugin of plugins) {\n const entryPath = path.join(slotsDir, `${plugin.slot}.ts`);\n const specifier = pathToFileURL(await fs.realpath(path.join(plugin.packageDir, plugin.client.entry))).href;\n await fs.writeFile(entryPath, `${HEADER}\\nexport { webPlugin } from '${specifier}';\\n`);\n slotEntryPaths[plugin.slot] = entryPath;\n }\n const leadingSourceRoots = [\n path.join(packageRoot, 'src', 'web'),\n ...(await fallbackTemplateSourceRoots(packageRoot)),\n ];\n await fs.writeFile(cssModulePath, await renderCssModule(plugins, leadingSourceRoots));\n const hostPlugins = plugins.filter((plugin) => plugin.isHost);\n const shell = {\n clientModulePath: path.join(generatedDir, 'webPluginShell.generated.ts'),\n cssModulePath: path.join(generatedDir, 'webPluginShellSources.generated.css'),\n };\n await fs.writeFile(shell.clientModulePath, await renderClientModule(hostPlugins, 'absolute', packageRoot));\n await fs.writeFile(shell.cssModulePath, await renderCssModule(hostPlugins, leadingSourceRoots));\n return {\n clientModulePath,\n slotEntryPaths,\n cssModulePath,\n shell,\n };\n}\n"],"mappings":";;;;;;;;;;AASA,MAAM,SAAS;;AAEf,MAAM,6BAA6B;CACjC;CACA;CACA;AACF;AACA,MAAa,wBAAwBA,UAAAA,QAAK,KAAK,OAAO,OAAO,OAAO,yBAAyB;AAC7F,MAAa,qBAAqBA,UAAAA,QAAK,KAAK,OAAO,OAAO,UAAU,gCAAgC;;;;;;AAOpG,SAAS,eAAe,MAAsB;CAC5C,OAAO,KAAK,QAAQ,iBAAiB,GAAG,OAAe,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,mBAAmB,GAAG;AACzG;AAEA,SAAS,eAAe,SAAiB,QAAwB;CAC/D,MAAM,OAAOA,UAAAA,QAAK,SAAS,SAAS,MAAM,CAAC,CAAC,MAAMA,UAAAA,QAAK,GAAG,CAAC,CAAC,KAAK,GAAG;CACpE,OAAO,KAAK,WAAW,GAAG,IAAI,OAAO,KA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c,MAAMF,iBAAAA,QAAG,SAASD,UAAAA,QAAK,KAAK,OAAO,YAAY,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;EACtG,MAAMC,iBAAAA,QAAG,UAAU,WAAW,GAAG,OAAO,+BAA+B,UAAU,KAAK;EACtF,eAAe,OAAO,QAAQ;CAChC;CACA,MAAM,qBAAqB,CACzBD,UAAAA,QAAK,KAAK,aAAa,OAAO,KAAK,GACnC,GAAI,MAAM,4BAA4B,WAAW,CACnD;CACA,MAAMC,iBAAAA,QAAG,UAAU,eAAe,MAAM,gBAAgB,SAAS,kBAAkB,CAAC;CACpF,MAAM,cAAc,QAAQ,QAAQ,WAAW,OAAO,MAAM;CAC5D,MAAM,QAAQ;EACZ,kBAAkBD,UAAAA,QAAK,KAAK,cAAc,6BAA6B;EACvE,eAAeA,UAAAA,QAAK,KAAK,cAAc,qCAAqC;CAC9E;CACA,MAAMC,iBAAAA,QAAG,UAAU,MAAM,kBAAkB,MAAM,mBAAmB,aAAa,YAAY,WAAW,CAAC;CACzG,MAAMA,iBAAAA,QAAG,UAAU,MAAM,eAAe,MAAM,gBAAgB,aAAa,kBAAkB,CAAC;CAC9F,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -2,8 +2,17 @@ import { DeclaredWebPlugin } from "./webPluginManifest.mjs";
|
|
|
2
2
|
//#region src/builders/web/webPluginGenerate.d.ts
|
|
3
3
|
export declare const BUILTIN_CLIENT_MODULE: string;
|
|
4
4
|
export declare const BUILTIN_CSS_MODULE: string;
|
|
5
|
+
/**
|
|
6
|
+
* v1 content identity: SHA-256 of a domain-separated JSON tuple containing the
|
|
7
|
+
* package name, declared version (empty for unpublished packages), declared entry
|
|
8
|
+
* path and its exact bytes (base64). Installation paths, slots and mtimes never
|
|
9
|
+
* enter the digest, so the same published package is reproducible across hosts.
|
|
10
|
+
* Version binds transitive package content; entry bytes also detect local entry
|
|
11
|
+
* edits. This is not a digest of the dependency graph or a code-signing claim.
|
|
12
|
+
*/
|
|
13
|
+
export declare function webPluginPackageFingerprint(plugin: DeclaredWebPlugin): Promise<string>;
|
|
5
14
|
/** The committed client registry, rendered from the host package alone. */
|
|
6
|
-
export declare function renderBuiltinWebPluginModules(packageRoot: string): Map<string, string
|
|
15
|
+
export declare function renderBuiltinWebPluginModules(packageRoot: string): Promise<Map<string, string>>;
|
|
7
16
|
/**
|
|
8
17
|
* Keeps the committed client registry fresh: write-if-changed locally,
|
|
9
18
|
* check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call
|
|
@@ -12,7 +21,7 @@ export declare function renderBuiltinWebPluginModules(packageRoot: string): Map<
|
|
|
12
21
|
export declare function ensureBuiltinWebPluginModules({ packageRoot, check }: {
|
|
13
22
|
packageRoot: string;
|
|
14
23
|
check?: boolean;
|
|
15
|
-
}): void
|
|
24
|
+
}): Promise<void>;
|
|
16
25
|
/** A client plugin registry and the Tailwind source list that goes with it. */
|
|
17
26
|
export interface WebPluginRegistryModules {
|
|
18
27
|
clientModulePath: string;
|
|
@@ -41,12 +50,12 @@ export interface WebPluginStyleEntries {
|
|
|
41
50
|
export declare const BASE_STYLE_ENTRY = "base";
|
|
42
51
|
export declare const pluginStyleEntryName: (slot: string) => string;
|
|
43
52
|
/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */
|
|
44
|
-
export declare function writeWebPluginStyleEntries(plugins: readonly DeclaredWebPlugin[], generatedDir: string, packageRoot: string): WebPluginStyleEntries
|
|
53
|
+
export declare function writeWebPluginStyleEntries(plugins: readonly DeclaredWebPlugin[], generatedDir: string, packageRoot: string): Promise<WebPluginStyleEntries>;
|
|
45
54
|
/**
|
|
46
55
|
* The sync-time variant: renders the full client plugin set (host built-ins plus
|
|
47
56
|
* the installed composition's packages) into a generation directory the bundler
|
|
48
57
|
* aliases over the committed builtin modules.
|
|
49
58
|
*/
|
|
50
|
-
export declare function writeSyncWebPluginModules(plugins: readonly DeclaredWebPlugin[], generatedDir: string, packageRoot: string): SyncGeneratedModules
|
|
59
|
+
export declare function writeSyncWebPluginModules(plugins: readonly DeclaredWebPlugin[], generatedDir: string, packageRoot: string): Promise<SyncGeneratedModules>;
|
|
51
60
|
//#endregion
|
|
52
61
|
//# sourceMappingURL=webPluginGenerate.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webPluginGenerate.d.mts","names":[],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"webPluginGenerate.d.mts","names":[],"sources":["../../../../src/builders/web/webPluginGenerate.ts"],"mappings":";;qBAgBa;qBACA;;;;;;;;;wBAwBS,4BAA4B,QAAQ,oBAAoB;;wBAoIxD,8BAA8B,sBAAsB,QAAQ;;;;;;wBAa5D,gCACpB,aACA;EAEA;EACA;IACE;;iBAwBa;EACf;EACA;;iBAGe,6BAA6B;;EAE5C,gBAAgB;;;;;;;EAOhB,OAAO;;iBAGQ;;EAEf;;EAEA;;EAEA,kBAAkB;;;qBAIP;qBACA,uBAAoB;;wBAGX,2BACpB,kBAAkB,qBAClB,sBACA,sBACC,QAAQ;;;;;;wBAyBW,0BACpB,kBAAkB,qBAClB,sBACA,sBACC,QAAQ"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { scanWebPlugins } from "./webPluginScan.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import fs from "node:fs";
|
|
4
3
|
import path from "node:path";
|
|
4
|
+
import fs from "node:fs/promises";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
6
7
|
//#region src/builders/web/webPluginGenerate.ts
|
|
7
8
|
const HEADER = "// Generated by po web builder. Do not edit by hand.";
|
|
8
|
-
/** The
|
|
9
|
-
const
|
|
9
|
+
/** The templates po-web bundles: Elegant is the default, Advanced and Desktop the alternatives, so all always compile. */
|
|
10
|
+
const FALLBACK_TEMPLATE_PACKAGES = [
|
|
11
|
+
"@agimon-ai/po-template-elegant",
|
|
12
|
+
"@agimon-ai/po-template-advanced",
|
|
13
|
+
"@agimon-ai/po-template-desktop"
|
|
14
|
+
];
|
|
10
15
|
const BUILTIN_CLIENT_MODULE = path.join("src", "web", "app", "webPlugins.generated.ts");
|
|
11
16
|
const BUILTIN_CSS_MODULE = path.join("src", "web", "styles", "webPluginSources.generated.css");
|
|
12
17
|
/**
|
|
@@ -21,7 +26,26 @@ function relativeImport(fromDir, toFile) {
|
|
|
21
26
|
const spec = path.relative(fromDir, toFile).split(path.sep).join("/");
|
|
22
27
|
return spec.startsWith(".") ? spec : `./${spec}`;
|
|
23
28
|
}
|
|
24
|
-
|
|
29
|
+
/**
|
|
30
|
+
* v1 content identity: SHA-256 of a domain-separated JSON tuple containing the
|
|
31
|
+
* package name, declared version (empty for unpublished packages), declared entry
|
|
32
|
+
* path and its exact bytes (base64). Installation paths, slots and mtimes never
|
|
33
|
+
* enter the digest, so the same published package is reproducible across hosts.
|
|
34
|
+
* Version binds transitive package content; entry bytes also detect local entry
|
|
35
|
+
* edits. This is not a digest of the dependency graph or a code-signing claim.
|
|
36
|
+
*/
|
|
37
|
+
async function webPluginPackageFingerprint(plugin) {
|
|
38
|
+
const manifest = JSON.parse(await fs.readFile(path.join(plugin.packageDir, "package.json"), "utf8"));
|
|
39
|
+
const entry = await fs.readFile(path.join(plugin.packageDir, plugin.client.entry));
|
|
40
|
+
return createHash("sha256").update(JSON.stringify([
|
|
41
|
+
"po/web-plugin-package/v1",
|
|
42
|
+
plugin.packageName,
|
|
43
|
+
typeof manifest.version === "string" ? manifest.version : "",
|
|
44
|
+
plugin.client.entry,
|
|
45
|
+
entry.toString("base64")
|
|
46
|
+
])).digest("hex");
|
|
47
|
+
}
|
|
48
|
+
async function renderClientModule(plugins, style, packageRoot) {
|
|
25
49
|
const lines = [HEADER, "import type { WebPluginDefinition } from '@agimon-ai/po-core/web';"];
|
|
26
50
|
const names = [];
|
|
27
51
|
const fromDir = path.join(packageRoot, "src", "web", "app");
|
|
@@ -29,10 +53,15 @@ function renderClientModule(plugins, style, packageRoot) {
|
|
|
29
53
|
const name = `${slotIdentifier(plugin.slot)}Plugin`;
|
|
30
54
|
names.push(name);
|
|
31
55
|
const entry = path.join(plugin.packageDir, plugin.client.entry);
|
|
32
|
-
const specifier = style === "relative" ? relativeImport(fromDir, entry) : pathToFileURL(fs.
|
|
56
|
+
const specifier = style === "relative" ? relativeImport(fromDir, entry) : pathToFileURL(await fs.realpath(entry)).href;
|
|
33
57
|
lines.push(`import { webPlugin as ${name} } from '${specifier}';`);
|
|
34
58
|
}
|
|
35
|
-
|
|
59
|
+
const packages = await Promise.all(plugins.map(async (plugin) => ({
|
|
60
|
+
packageName: plugin.packageName,
|
|
61
|
+
pluginId: plugin.pluginId,
|
|
62
|
+
fingerprint: await webPluginPackageFingerprint(plugin)
|
|
63
|
+
})));
|
|
64
|
+
lines.push("", `export const webPlugins: readonly WebPluginDefinition[] = [${names.join(", ")}];`, `export const webPluginPackages: readonly { packageName: string; pluginId: string; fingerprint: string }[] = ${JSON.stringify(packages)};`, "");
|
|
36
65
|
return lines.join("\n");
|
|
37
66
|
}
|
|
38
67
|
/**
|
|
@@ -40,7 +69,7 @@ function renderClientModule(plugins, style, packageRoot) {
|
|
|
40
69
|
*
|
|
41
70
|
* `src/extensions` wins, because a plugin's components colocate with the routed
|
|
42
71
|
* file that renders them, in private `_components` and `_lib` folders. The
|
|
43
|
-
* legacy `src/web` root is only a fallback:
|
|
72
|
+
* legacy `src/web` root is only a fallback: an existence check passes for a
|
|
44
73
|
* half-emptied directory holding nothing but a tsconfig, and packages have been
|
|
45
74
|
* in exactly that state, so preferring it would hand Tailwind a directory with
|
|
46
75
|
* no components in it and silently drop every class.
|
|
@@ -49,60 +78,70 @@ function renderClientModule(plugins, style, packageRoot) {
|
|
|
49
78
|
* `src/exports/webClient.ts`, a one-line re-export, or generated outside `src`
|
|
50
79
|
* entirely, so it holds no components either.
|
|
51
80
|
*/
|
|
52
|
-
function pluginSourceRoot(plugin) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
81
|
+
async function pluginSourceRoot(plugin) {
|
|
82
|
+
for (const root of [path.join(plugin.packageDir, "src", "extensions"), path.join(plugin.packageDir, "src", "web")]) if (await fs.access(root).then(() => true, (error) => {
|
|
83
|
+
if (error.code === "ENOENT") return false;
|
|
84
|
+
throw error;
|
|
85
|
+
})) return root;
|
|
57
86
|
return path.dirname(path.join(plugin.packageDir, plugin.client.entry));
|
|
58
87
|
}
|
|
59
88
|
/**
|
|
60
|
-
* Where Tailwind finds
|
|
89
|
+
* Where Tailwind finds a bundled template's classes. app.css names it by a
|
|
61
90
|
* path from its own folder into po-web's node_modules, which holds only in
|
|
62
91
|
* this repository; an installed po-web has the template beside it instead,
|
|
63
92
|
* so a sync build that scanned only that path shipped the cockpit without the
|
|
64
93
|
* template's responsive layout. Resolving it as Node does works in both.
|
|
65
94
|
*/
|
|
66
|
-
function fallbackTemplateSourceRoot(packageRoot) {
|
|
95
|
+
async function fallbackTemplateSourceRoot(packageRoot, name) {
|
|
67
96
|
let manifest;
|
|
68
97
|
try {
|
|
69
|
-
manifest = createRequire(path.join(packageRoot, "package.json")).resolve(`${
|
|
98
|
+
manifest = createRequire(path.join(packageRoot, "package.json")).resolve(`${name}/package.json`);
|
|
70
99
|
} catch {
|
|
71
100
|
return;
|
|
72
101
|
}
|
|
73
102
|
const extensions = path.join(path.dirname(manifest), "dist", "extensions");
|
|
74
|
-
return fs.
|
|
103
|
+
return fs.access(extensions).then(() => extensions, (error) => {
|
|
104
|
+
if (error.code === "ENOENT") return void 0;
|
|
105
|
+
throw error;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/** Every bundled template that is installed, in FALLBACK_TEMPLATE_PACKAGES order. */
|
|
109
|
+
async function fallbackTemplateSourceRoots(packageRoot) {
|
|
110
|
+
return (await Promise.all(FALLBACK_TEMPLATE_PACKAGES.map((name) => fallbackTemplateSourceRoot(packageRoot, name)))).filter((root) => root !== void 0);
|
|
75
111
|
}
|
|
76
|
-
function renderCssModule(plugins, leadingSourceRoots) {
|
|
112
|
+
async function renderCssModule(plugins, leadingSourceRoots) {
|
|
77
113
|
const lines = [`/* ${HEADER.slice(3)} */`, ...leadingSourceRoots.map((root) => `@source "${root}";`)];
|
|
78
114
|
for (const plugin of plugins) {
|
|
79
115
|
if (plugin.isHost) continue;
|
|
80
|
-
lines.push(`@source "${pluginSourceRoot(plugin)}";`);
|
|
116
|
+
lines.push(`@source "${await pluginSourceRoot(plugin)}";`);
|
|
81
117
|
}
|
|
82
118
|
lines.push("");
|
|
83
119
|
return lines.join("\n");
|
|
84
120
|
}
|
|
85
121
|
/** The committed client registry, rendered from the host package alone. */
|
|
86
|
-
function renderBuiltinWebPluginModules(packageRoot) {
|
|
87
|
-
const plugins = scanWebPlugins(packageRoot);
|
|
88
|
-
return /* @__PURE__ */ new Map([[BUILTIN_CLIENT_MODULE, renderClientModule(plugins, "relative", packageRoot)], [BUILTIN_CSS_MODULE, renderCssModule(plugins, [])]]);
|
|
122
|
+
async function renderBuiltinWebPluginModules(packageRoot) {
|
|
123
|
+
const plugins = await scanWebPlugins(packageRoot);
|
|
124
|
+
return /* @__PURE__ */ new Map([[BUILTIN_CLIENT_MODULE, await renderClientModule(plugins, "relative", packageRoot)], [BUILTIN_CSS_MODULE, await renderCssModule(plugins, [])]]);
|
|
89
125
|
}
|
|
90
126
|
/**
|
|
91
127
|
* Keeps the committed client registry fresh: write-if-changed locally,
|
|
92
128
|
* check-only (throw) in CI. Both vite.config.ts and tsdown.config.ts call
|
|
93
129
|
* this at config-load time.
|
|
94
130
|
*/
|
|
95
|
-
function ensureBuiltinWebPluginModules({ packageRoot, check = false }) {
|
|
131
|
+
async function ensureBuiltinWebPluginModules({ packageRoot, check = false }) {
|
|
96
132
|
const stale = [];
|
|
97
|
-
for (const [relativePath, content] of renderBuiltinWebPluginModules(packageRoot)) {
|
|
133
|
+
for (const [relativePath, content] of await renderBuiltinWebPluginModules(packageRoot)) {
|
|
98
134
|
const filePath = path.join(packageRoot, relativePath);
|
|
99
|
-
if (
|
|
135
|
+
if (await fs.readFile(filePath, "utf8").catch((error) => {
|
|
136
|
+
if (error.code === "ENOENT") return void 0;
|
|
137
|
+
throw error;
|
|
138
|
+
}) === content) continue;
|
|
100
139
|
if (check) {
|
|
101
140
|
stale.push(relativePath);
|
|
102
141
|
continue;
|
|
103
142
|
}
|
|
104
|
-
fs.
|
|
105
|
-
fs.
|
|
143
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
144
|
+
await fs.writeFile(filePath, content);
|
|
106
145
|
}
|
|
107
146
|
if (stale.length > 0) throw new Error(`Stale generated web plugin modules: ${stale.join(", ")}. Run pnpm build in po-web and commit them.`);
|
|
108
147
|
}
|
|
@@ -110,15 +149,15 @@ function ensureBuiltinWebPluginModules({ packageRoot, check = false }) {
|
|
|
110
149
|
const BASE_STYLE_ENTRY = "base";
|
|
111
150
|
const pluginStyleEntryName = (slot) => `plugin-${slot}`;
|
|
112
151
|
/** One Tailwind entry for the whole build, so later sheets cannot override earlier variants. */
|
|
113
|
-
function writeWebPluginStyleEntries(plugins, generatedDir, packageRoot) {
|
|
152
|
+
async function writeWebPluginStyleEntries(plugins, generatedDir, packageRoot) {
|
|
114
153
|
const stylesDir = path.join(generatedDir, "styles");
|
|
115
|
-
fs.
|
|
116
|
-
const
|
|
154
|
+
await fs.mkdir(stylesDir, { recursive: true });
|
|
155
|
+
const fallbackTemplates = await fallbackTemplateSourceRoots(packageRoot);
|
|
117
156
|
const baseSourcesPath = path.join(generatedDir, "webPluginBaseSources.generated.css");
|
|
118
|
-
fs.
|
|
119
|
-
const appCss = relativeImport(fs.
|
|
157
|
+
await fs.writeFile(baseSourcesPath, await renderCssModule(plugins, [path.join(packageRoot, "src", "web"), ...fallbackTemplates]));
|
|
158
|
+
const appCss = relativeImport(await fs.realpath(stylesDir), await fs.realpath(path.join(packageRoot, "src", "web", "styles", "app.css")));
|
|
120
159
|
const baseEntryPath = path.join(stylesDir, `${BASE_STYLE_ENTRY}.css`);
|
|
121
|
-
fs.
|
|
160
|
+
await fs.writeFile(baseEntryPath, `/* ${HEADER.slice(3)} */\n@import '${appCss}';\n`);
|
|
122
161
|
return {
|
|
123
162
|
baseSourcesPath,
|
|
124
163
|
baseEntryPath,
|
|
@@ -130,30 +169,29 @@ function writeWebPluginStyleEntries(plugins, generatedDir, packageRoot) {
|
|
|
130
169
|
* the installed composition's packages) into a generation directory the bundler
|
|
131
170
|
* aliases over the committed builtin modules.
|
|
132
171
|
*/
|
|
133
|
-
function writeSyncWebPluginModules(plugins, generatedDir, packageRoot) {
|
|
134
|
-
fs.
|
|
172
|
+
async function writeSyncWebPluginModules(plugins, generatedDir, packageRoot) {
|
|
173
|
+
await fs.mkdir(generatedDir, { recursive: true });
|
|
135
174
|
const clientModulePath = path.join(generatedDir, "webPlugins.generated.ts");
|
|
136
175
|
const cssModulePath = path.join(generatedDir, "webPluginSources.generated.css");
|
|
137
|
-
fs.
|
|
176
|
+
await fs.writeFile(clientModulePath, await renderClientModule(plugins, "absolute", packageRoot));
|
|
138
177
|
const slotsDir = path.join(generatedDir, "slots");
|
|
139
|
-
fs.
|
|
178
|
+
await fs.mkdir(slotsDir, { recursive: true });
|
|
140
179
|
const slotEntryPaths = {};
|
|
141
180
|
for (const plugin of plugins) {
|
|
142
181
|
const entryPath = path.join(slotsDir, `${plugin.slot}.ts`);
|
|
143
|
-
const specifier = pathToFileURL(fs.
|
|
144
|
-
fs.
|
|
182
|
+
const specifier = pathToFileURL(await fs.realpath(path.join(plugin.packageDir, plugin.client.entry))).href;
|
|
183
|
+
await fs.writeFile(entryPath, `${HEADER}\nexport { webPlugin } from '${specifier}';\n`);
|
|
145
184
|
slotEntryPaths[plugin.slot] = entryPath;
|
|
146
185
|
}
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
fs.writeFileSync(cssModulePath, renderCssModule(plugins, leadingSourceRoots));
|
|
186
|
+
const leadingSourceRoots = [path.join(packageRoot, "src", "web"), ...await fallbackTemplateSourceRoots(packageRoot)];
|
|
187
|
+
await fs.writeFile(cssModulePath, await renderCssModule(plugins, leadingSourceRoots));
|
|
150
188
|
const hostPlugins = plugins.filter((plugin) => plugin.isHost);
|
|
151
189
|
const shell = {
|
|
152
190
|
clientModulePath: path.join(generatedDir, "webPluginShell.generated.ts"),
|
|
153
191
|
cssModulePath: path.join(generatedDir, "webPluginShellSources.generated.css")
|
|
154
192
|
};
|
|
155
|
-
fs.
|
|
156
|
-
fs.
|
|
193
|
+
await fs.writeFile(shell.clientModulePath, await renderClientModule(hostPlugins, "absolute", packageRoot));
|
|
194
|
+
await fs.writeFile(shell.cssModulePath, await renderCssModule(hostPlugins, leadingSourceRoots));
|
|
157
195
|
return {
|
|
158
196
|
clientModulePath,
|
|
159
197
|
slotEntryPaths,
|
|
@@ -162,6 +200,6 @@ function writeSyncWebPluginModules(plugins, generatedDir, packageRoot) {
|
|
|
162
200
|
};
|
|
163
201
|
}
|
|
164
202
|
//#endregion
|
|
165
|
-
export { BASE_STYLE_ENTRY, BUILTIN_CLIENT_MODULE, BUILTIN_CSS_MODULE, ensureBuiltinWebPluginModules, pluginStyleEntryName, renderBuiltinWebPluginModules, writeSyncWebPluginModules, writeWebPluginStyleEntries };
|
|
203
|
+
export { BASE_STYLE_ENTRY, BUILTIN_CLIENT_MODULE, BUILTIN_CSS_MODULE, ensureBuiltinWebPluginModules, pluginStyleEntryName, renderBuiltinWebPluginModules, webPluginPackageFingerprint, writeSyncWebPluginModules, writeWebPluginStyleEntries };
|
|
166
204
|
|
|
167
205
|
//# sourceMappingURL=webPluginGenerate.mjs.map
|