resuxjs 0.4.0-beta.2 → 0.4.0-beta.3
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/dist/bin.d.ts +1 -1
- package/dist/bin.js +3 -2
- package/dist/bin.js.map +1 -1
- package/dist/build/index.d.ts +9 -8
- package/dist/build/index.js +2 -2
- package/dist/build/index.js.map +1 -1
- package/dist/cli.d.ts +5 -4
- package/dist/cli.js +115 -127
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapter.d.ts +6 -5
- package/dist/compiler/adapter.js +2 -1
- package/dist/compiler/adapter.js.map +1 -1
- package/dist/compiler/dev-warnings.d.ts +6 -5
- package/dist/compiler/dev-warnings.js +7 -6
- package/dist/compiler/dev-warnings.js.map +1 -1
- package/dist/compiler/directives.d.ts +4 -3
- package/dist/compiler/directives.js +2 -1
- package/dist/compiler/directives.js.map +1 -1
- package/dist/compiler/implementation.d.ts +21 -19
- package/dist/compiler/implementation.js +124 -133
- package/dist/compiler/index.d.ts +6 -5
- package/dist/compiler/index.js +2 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +7 -5
- package/dist/core/config.js +1 -1
- package/dist/core/config.js.map +1 -1
- package/dist/core/hooks.d.ts +7 -6
- package/dist/core/hooks.js +1 -1
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/module-container.d.ts +22 -20
- package/dist/core/module-container.js +3 -3
- package/dist/core/module-container.js.map +1 -1
- package/dist/core/resux.d.ts +5 -3
- package/dist/core/resux.js +2 -1
- package/dist/core/resux.js.map +1 -1
- package/dist/create-bin.d.ts +1 -1
- package/dist/create-bin.js +3 -2
- package/dist/create-bin.js.map +1 -1
- package/dist/create.d.ts +3 -2
- package/dist/create.js +7 -10
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +3 -1
- package/dist/deploy/cloudflare.js +2 -1
- package/dist/deploy/cloudflare.js.map +1 -1
- package/dist/deploy/common.d.ts +13 -11
- package/dist/deploy/common.js +2 -1
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/framework-runtime.d.ts +2 -1
- package/dist/deploy/framework-runtime.js +2 -1
- package/dist/deploy/framework-runtime.js.map +1 -1
- package/dist/deploy/index.d.ts +4 -2
- package/dist/deploy/index.js +4 -6
- package/dist/deploy/index.js.map +1 -1
- package/dist/deploy/netlify.d.ts +3 -1
- package/dist/deploy/netlify.js +2 -1
- package/dist/deploy/netlify.js.map +1 -1
- package/dist/deploy/node.d.ts +3 -1
- package/dist/deploy/node.js +3 -3
- package/dist/deploy/node.js.map +1 -1
- package/dist/deploy/production-report.d.ts +2 -1
- package/dist/deploy/production-report.js +2 -1
- package/dist/deploy/production-report.js.map +1 -1
- package/dist/deploy/runtime-dependencies.d.ts +5 -4
- package/dist/deploy/runtime-dependencies.js +3 -3
- package/dist/deploy/runtime-dependencies.js.map +1 -1
- package/dist/deploy/static.d.ts +3 -1
- package/dist/deploy/static.js +2 -1
- package/dist/deploy/static.js.map +1 -1
- package/dist/deploy/types.d.ts +8 -7
- package/dist/deploy/types.js +1 -1
- package/dist/deploy/vercel.d.ts +4 -2
- package/dist/deploy/vercel.js +2 -1
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/fonts/index.d.ts +5 -4
- package/dist/fonts/index.js +3 -2
- package/dist/fonts/index.js.map +1 -1
- package/dist/globals.d.ts +2 -2
- package/dist/globals.js +1 -1
- package/dist/halal-core/ai/classifyProject.d.ts +5 -3
- package/dist/halal-core/ai/classifyProject.js +2 -1
- package/dist/halal-core/ai/classifyProject.js.map +1 -1
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +3 -1
- package/dist/halal-core/ai/classifyRuntimeContent.js +2 -1
- package/dist/halal-core/ai/classifyRuntimeContent.js.map +1 -1
- package/dist/halal-core/ai/createProjectSummary.d.ts +2 -1
- package/dist/halal-core/ai/createProjectSummary.js +2 -1
- package/dist/halal-core/ai/createProjectSummary.js.map +1 -1
- package/dist/halal-core/ai/halalClassifierPrompt.d.ts +2 -1
- package/dist/halal-core/ai/halalClassifierPrompt.js +1 -1
- package/dist/halal-core/ai/redactSensitiveData.d.ts +2 -1
- package/dist/halal-core/ai/redactSensitiveData.js +1 -1
- package/dist/halal-core/ai/redactSensitiveData.js.map +1 -1
- package/dist/halal-core/ai/validateAiResponse.d.ts +3 -1
- package/dist/halal-core/ai/validateAiResponse.js +3 -3
- package/dist/halal-core/ai/validateAiResponse.js.map +1 -1
- package/dist/halal-core/cli/check.d.ts +2 -1
- package/dist/halal-core/cli/check.js +3 -3
- package/dist/halal-core/cli/check.js.map +1 -1
- package/dist/halal-core/cli/explain.d.ts +2 -1
- package/dist/halal-core/cli/explain.js +3 -3
- package/dist/halal-core/cli/explain.js.map +1 -1
- package/dist/halal-core/cli/report.d.ts +2 -1
- package/dist/halal-core/cli/report.js +3 -3
- package/dist/halal-core/cli/report.js.map +1 -1
- package/dist/halal-core/cli/submitReview.d.ts +2 -1
- package/dist/halal-core/cli/submitReview.js +3 -3
- package/dist/halal-core/cli/submitReview.js.map +1 -1
- package/dist/halal-core/cli/verifyReview.d.ts +2 -1
- package/dist/halal-core/cli/verifyReview.js +3 -4
- package/dist/halal-core/cli/verifyReview.js.map +1 -1
- package/dist/halal-core/config.d.ts +9 -8
- package/dist/halal-core/config.js +2 -1
- package/dist/halal-core/config.js.map +1 -1
- package/dist/halal-core/crypto/integrity.d.ts +6 -5
- package/dist/halal-core/crypto/integrity.js +2 -1
- package/dist/halal-core/crypto/integrity.js.map +1 -1
- package/dist/halal-core/enforce.d.ts +6 -5
- package/dist/halal-core/enforce.js +13 -15
- package/dist/halal-core/enforce.js.map +1 -1
- package/dist/halal-core/index.js +2 -1
- package/dist/halal-core/lifecycle.d.ts +2 -1
- package/dist/halal-core/lifecycle.js +2 -1
- package/dist/halal-core/lifecycle.js.map +1 -1
- package/dist/halal-core/policy.d.ts +3 -1
- package/dist/halal-core/policy.js +2 -1
- package/dist/halal-core/policy.js.map +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.d.ts +3 -1
- package/dist/halal-core/report/formatBrowserOverlay.js +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.js.map +1 -1
- package/dist/halal-core/report/formatTerminalReport.d.ts +3 -1
- package/dist/halal-core/report/formatTerminalReport.js +1 -1
- package/dist/halal-core/report/formatTerminalReport.js.map +1 -1
- package/dist/halal-core/report/generateHalalReport.d.ts +4 -2
- package/dist/halal-core/report/generateHalalReport.js +5 -7
- package/dist/halal-core/report/generateHalalReport.js.map +1 -1
- package/dist/halal-core/report/signReport.d.ts +4 -2
- package/dist/halal-core/report/signReport.js +2 -1
- package/dist/halal-core/report/signReport.js.map +1 -1
- package/dist/halal-core/report/verifyReport.d.ts +5 -3
- package/dist/halal-core/report/verifyReport.js +4 -3
- package/dist/halal-core/report/verifyReport.js.map +1 -1
- package/dist/halal-core/review/createReviewRequest.d.ts +3 -1
- package/dist/halal-core/review/createReviewRequest.js +3 -3
- package/dist/halal-core/review/createReviewRequest.js.map +1 -1
- package/dist/halal-core/review/reviewPolicy.d.ts +4 -3
- package/dist/halal-core/review/reviewPolicy.js +1 -1
- package/dist/halal-core/review/reviewPolicy.js.map +1 -1
- package/dist/halal-core/review/signedReviewFile.d.ts +6 -4
- package/dist/halal-core/review/signedReviewFile.js +2 -1
- package/dist/halal-core/review/signedReviewFile.js.map +1 -1
- package/dist/halal-core/review/verifyReviewApproval.d.ts +3 -2
- package/dist/halal-core/review/verifyReviewApproval.js +2 -1
- package/dist/halal-core/review/verifyReviewApproval.js.map +1 -1
- package/dist/halal-core/rules/adultContentRules.d.ts +3 -2
- package/dist/halal-core/rules/adultContentRules.js +1 -1
- package/dist/halal-core/rules/adultContentRules.js.map +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +3 -2
- package/dist/halal-core/rules/alcoholDrugVapeRules.js +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.js.map +1 -1
- package/dist/halal-core/rules/childSafetyRules.d.ts +3 -2
- package/dist/halal-core/rules/childSafetyRules.js +1 -1
- package/dist/halal-core/rules/childSafetyRules.js.map +1 -1
- package/dist/halal-core/rules/coreCategories.d.ts +3 -2
- package/dist/halal-core/rules/coreCategories.js +1 -1
- package/dist/halal-core/rules/coreCategories.js.map +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.d.ts +3 -2
- package/dist/halal-core/rules/cyberAbuseRules.js +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/defaultBlockedRules.d.ts +3 -1
- package/dist/halal-core/rules/defaultBlockedRules.js +9 -11
- package/dist/halal-core/rules/defaultBlockedRules.js.map +1 -1
- package/dist/halal-core/rules/dependencyRules.d.ts +3 -2
- package/dist/halal-core/rules/dependencyRules.js +1 -1
- package/dist/halal-core/rules/dependencyRules.js.map +1 -1
- package/dist/halal-core/rules/endpointRules.d.ts +3 -2
- package/dist/halal-core/rules/endpointRules.js +1 -1
- package/dist/halal-core/rules/endpointRules.js.map +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/environmentalHarmRules.js +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/financeRibaRules.d.ts +3 -2
- package/dist/halal-core/rules/financeRibaRules.js +1 -1
- package/dist/halal-core/rules/financeRibaRules.js.map +1 -1
- package/dist/halal-core/rules/gamblingRules.d.ts +3 -2
- package/dist/halal-core/rules/gamblingRules.js +1 -1
- package/dist/halal-core/rules/gamblingRules.js.map +1 -1
- package/dist/halal-core/rules/generalHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/generalHarmRules.js +1 -1
- package/dist/halal-core/rules/generalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/healthHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/healthHarmRules.js +1 -1
- package/dist/halal-core/rules/healthHarmRules.js.map +1 -1
- package/dist/halal-core/rules/keywordRules.d.ts +2 -1
- package/dist/halal-core/rules/keywordRules.js +1 -1
- package/dist/halal-core/rules/keywordRules.js.map +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.d.ts +3 -2
- package/dist/halal-core/rules/privacyAbuseRules.js +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/scamFraudRules.d.ts +3 -2
- package/dist/halal-core/rules/scamFraudRules.js +1 -1
- package/dist/halal-core/rules/scamFraudRules.js.map +1 -1
- package/dist/halal-core/rules/selfHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/selfHarmRules.js +1 -1
- package/dist/halal-core/rules/selfHarmRules.js.map +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.d.ts +3 -2
- package/dist/halal-core/rules/violenceExtremismRules.js +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.js.map +1 -1
- package/dist/halal-core/runtime/guard.d.ts +5 -3
- package/dist/halal-core/runtime/guard.js +2 -1
- package/dist/halal-core/runtime/guard.js.map +1 -1
- package/dist/halal-core/runtime/index.js +2 -1
- package/dist/halal-core/runtime/reviewedMemory.d.ts +6 -4
- package/dist/halal-core/runtime/reviewedMemory.js +3 -2
- package/dist/halal-core/runtime/reviewedMemory.js.map +1 -1
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +7 -5
- package/dist/halal-core/runtime/serializeRuntimeContent.js +4 -3
- package/dist/halal-core/runtime/serializeRuntimeContent.js.map +1 -1
- package/dist/halal-core/runtime/types.d.ts +11 -9
- package/dist/halal-core/runtime/types.js +1 -1
- package/dist/halal-core/scanner/scanApiRoutes.d.ts +2 -1
- package/dist/halal-core/scanner/scanApiRoutes.js +2 -1
- package/dist/halal-core/scanner/scanApiRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanComponents.d.ts +2 -1
- package/dist/halal-core/scanner/scanComponents.js +2 -1
- package/dist/halal-core/scanner/scanComponents.js.map +1 -1
- package/dist/halal-core/scanner/scanContent.d.ts +3 -2
- package/dist/halal-core/scanner/scanContent.js +4 -3
- package/dist/halal-core/scanner/scanContent.js.map +1 -1
- package/dist/halal-core/scanner/scanDependencies.d.ts +2 -1
- package/dist/halal-core/scanner/scanDependencies.js +2 -1
- package/dist/halal-core/scanner/scanDependencies.js.map +1 -1
- package/dist/halal-core/scanner/scanDomains.d.ts +2 -1
- package/dist/halal-core/scanner/scanDomains.js +1 -1
- package/dist/halal-core/scanner/scanDomains.js.map +1 -1
- package/dist/halal-core/scanner/scanEnvNames.d.ts +2 -1
- package/dist/halal-core/scanner/scanEnvNames.js +2 -1
- package/dist/halal-core/scanner/scanEnvNames.js.map +1 -1
- package/dist/halal-core/scanner/scanMetadata.d.ts +3 -2
- package/dist/halal-core/scanner/scanMetadata.js +2 -1
- package/dist/halal-core/scanner/scanMetadata.js.map +1 -1
- package/dist/halal-core/scanner/scanPages.d.ts +2 -1
- package/dist/halal-core/scanner/scanPages.js +2 -1
- package/dist/halal-core/scanner/scanPages.js.map +1 -1
- package/dist/halal-core/scanner/scanProject.d.ts +4 -2
- package/dist/halal-core/scanner/scanProject.js +2 -1
- package/dist/halal-core/scanner/scanProject.js.map +1 -1
- package/dist/halal-core/scanner/scanRoutes.d.ts +2 -1
- package/dist/halal-core/scanner/scanRoutes.js +2 -1
- package/dist/halal-core/scanner/scanRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanTranslations.d.ts +2 -1
- package/dist/halal-core/scanner/scanTranslations.js +2 -1
- package/dist/halal-core/scanner/scanTranslations.js.map +1 -1
- package/dist/halal-core/status.d.ts +3 -2
- package/dist/halal-core/status.js +1 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +2 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.js +2 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.js.map +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +2 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.js +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.js.map +1 -1
- package/dist/halal-core/tamper/verifyReportSignature.d.ts +3 -1
- package/dist/halal-core/tamper/verifyReportSignature.js +3 -3
- package/dist/halal-core/tamper/verifyReportSignature.js.map +1 -1
- package/dist/halal.js +2 -1
- package/dist/i18n/index.d.ts +12 -11
- package/dist/i18n/index.js +5 -6
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.d.ts +15 -14
- package/dist/i18n/shared.js +4 -4
- package/dist/i18n/shared.js.map +1 -1
- package/dist/icons/index.d.ts +20 -18
- package/dist/icons/index.js +5 -4
- package/dist/icons/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/kit/index.d.ts +23 -21
- package/dist/kit/index.js +2 -1
- package/dist/kit/index.js.map +1 -1
- package/dist/nitro-server/index.d.ts +3 -2
- package/dist/nitro-server/index.js +1 -1
- package/dist/nitro-server/index.js.map +1 -1
- package/dist/node.d.ts +4 -2
- package/dist/node.js +7 -6
- package/dist/node.js.map +1 -1
- package/dist/reactivity/computed.d.ts +5 -3
- package/dist/reactivity/computed.js +3 -3
- package/dist/reactivity/computed.js.map +1 -1
- package/dist/reactivity/effect.d.ts +15 -13
- package/dist/reactivity/effect.js +9 -10
- package/dist/reactivity/effect.js.map +1 -1
- package/dist/reactivity/index.js +2 -1
- package/dist/reactivity/reactive.d.ts +6 -5
- package/dist/reactivity/reactive.js +5 -4
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/readonly.js +2 -1
- package/dist/reactivity/ref.d.ts +9 -7
- package/dist/reactivity/ref.js +2 -4
- package/dist/reactivity/ref.js.map +1 -1
- package/dist/reactivity/scheduler.d.ts +5 -4
- package/dist/reactivity/scheduler.js +1 -1
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/reactivity/types.d.ts +12 -11
- package/dist/reactivity/types.js +1 -1
- package/dist/reactivity/utils.d.ts +10 -9
- package/dist/reactivity/utils.js +1 -1
- package/dist/reactivity/utils.js.map +1 -1
- package/dist/reactivity/watch.d.ts +4 -2
- package/dist/reactivity/watch.js +4 -5
- package/dist/reactivity/watch.js.map +1 -1
- package/dist/runtime/core.d.ts +5 -4
- package/dist/runtime/core.js +9 -10
- package/dist/runtime/core.js.map +1 -1
- package/dist/runtime/index.d.ts +123 -122
- package/dist/runtime/index.js +45 -58
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/reactivity.js +2 -1
- package/dist/runtime/resume.d.ts +15 -14
- package/dist/runtime/resume.js +3 -3
- package/dist/runtime/resume.js.map +1 -1
- package/dist/runtime/router.d.ts +5 -4
- package/dist/runtime/router.js +1 -1
- package/dist/runtime/router.js.map +1 -1
- package/dist/runtime/streaming.d.ts +7 -6
- package/dist/runtime/streaming.js +3 -3
- package/dist/runtime/streaming.js.map +1 -1
- package/dist/security/media-fetch.d.ts +11 -10
- package/dist/security/media-fetch.js +5 -4
- package/dist/security/media-fetch.js.map +1 -1
- package/dist/security/path-boundary.d.ts +5 -4
- package/dist/security/path-boundary.js +2 -1
- package/dist/security/path-boundary.js.map +1 -1
- package/dist/ui/index.d.ts +195 -193
- package/dist/ui/index.js +7 -8
- package/dist/ui/index.js.map +1 -1
- package/dist/vite-builder/index.d.ts +3 -2
- package/dist/vite-builder/index.js +1 -1
- package/dist/vite-builder/index.js.map +1 -1
- package/package.json +2 -2
package/dist/deploy/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/deploy/index.ts"],"sourcesContent":["import {\n detectDeployProviderFromEnv,\n loadResuxDeployConfig,\n normalizeProviderPreset,\n} from \"./common.js\";\nimport { cloudflareDeployModule } from \"./cloudflare.js\";\nimport { netlifyDeployModule } from \"./netlify.js\";\nimport { nodeDeployModule } from \"./node.js\";\nimport { staticDeployModule } from \"./static.js\";\nimport type {\n DeployBuildContext,\n DeployDetectionContext,\n DeploymentResolution,\n DeployTargetModule,\n ResuxResolvedDeployTarget,\n} from \"./types.js\";\nimport { vercelDeployModule } from \"./vercel.js\";\n\nconst deployModules: DeployTargetModule[] = [\n vercelDeployModule,\n netlifyDeployModule,\n cloudflareDeployModule,\n staticDeployModule,\n nodeDeployModule,\n];\n\nconst moduleByTarget = new Map<ResuxResolvedDeployTarget, DeployTargetModule>(\n deployModules.map((module) => [module.target, module]),\n);\n\nfunction moduleFromPreset(preset: string): DeployTargetModule | null {\n const normalized = preset.trim().toLowerCase();\n if (!normalized) {\n return null;\n }\n\n return deployModules.find((module) =>\n module.presetAliases.some((alias) => alias === normalized)\n ) ?? null;\n}\n\nfunction buildDetectionContext(\n appRoot: string,\n outDir: string,\n env: NodeJS.ProcessEnv,\n explicitNitroPreset: string | null,\n deployConfig: DeployDetectionContext[\"deployConfig\"],\n): DeployDetectionContext {\n return {\n appRoot,\n outDir,\n env,\n explicitNitroPreset,\n deployConfig,\n };\n}\n\nfunction resolveModuleFromTarget(target: string | undefined): DeployTargetModule | null {\n if (!target || target === \"auto\") {\n return null;\n }\n return moduleByTarget.get(target as ResuxResolvedDeployTarget) ?? null;\n}\n\nfunction readExplicitNitroPreset(\n env: NodeJS.ProcessEnv,\n configPreset: string | undefined,\n): string | null {\n const envPreset = (env.NITRO_PRESET ?? env.RESUX_NITRO_PRESET)?.trim();\n if (envPreset) {\n return envPreset;\n }\n const normalizedConfigPreset = configPreset?.trim();\n return normalizedConfigPreset || null;\n}\n\nfunction createResolution(\n module: DeployTargetModule,\n nitroPreset: string | null,\n reason: string,\n): DeploymentResolution {\n return {\n target: module.target,\n nitroPreset,\n outputLabel: module.outputLabel,\n reason,\n };\n}\n\nexport async function resolveDeployment(\n appRoot: string,\n outDir: string,\n env: NodeJS.ProcessEnv,\n): Promise<DeploymentResolution> {\n const deployConfig = await loadResuxDeployConfig(appRoot, outDir);\n const explicitNitroPreset = readExplicitNitroPreset(env, deployConfig.nitroPreset);\n const detectionContext = buildDetectionContext(\n appRoot,\n outDir,\n env,\n explicitNitroPreset,\n deployConfig,\n );\n\n if (explicitNitroPreset) {\n const presetModule = moduleFromPreset(explicitNitroPreset);\n if (presetModule) {\n return createResolution(\n presetModule,\n explicitNitroPreset,\n \"explicit Nitro preset\",\n );\n }\n }\n\n const configuredTargetModule = resolveModuleFromTarget(deployConfig.target);\n if (configuredTargetModule) {\n const configuredPreset =\n deployConfig.nitroPreset\n ?? configuredTargetModule.inferPreset?.(detectionContext)\n ?? null;\n return createResolution(\n configuredTargetModule,\n configuredPreset,\n \"resux.config deploy.target\",\n );\n }\n\n const provider = detectDeployProviderFromEnv(env);\n if (provider) {\n const providerPreset = normalizeProviderPreset(provider);\n const providerModule = moduleFromPreset(providerPreset);\n if (providerModule) {\n if (providerModule.target === \"cloudflare\" && deployConfig.target !== \"cloudflare\") {\n // Cloudflare worker presets need an edge-compatible app handler.\n // Keep auto mode on node fallback unless the app explicitly opts in.\n } else {\n return createResolution(\n providerModule,\n providerPreset,\n `environment provider (${provider})`,\n );\n }\n }\n }\n\n for (const module of deployModules) {\n if (module.target === \"cloudflare\" && deployConfig.target !== \"cloudflare\") {\n continue;\n }\n if (!(await module.detect?.(detectionContext))) {\n continue;\n }\n const inferredPreset = module.inferPreset?.(detectionContext) ?? null;\n return createResolution(module, inferredPreset, `${module.target} project detection`);\n }\n\n const fallbackPreset = nodeDeployModule.inferPreset?.(detectionContext) ?? null;\n return createResolution(nodeDeployModule, fallbackPreset, \"default node target\");\n}\n\nexport async function applyDeploymentPostBuild(context: DeployBuildContext): Promise<void> {\n const module = moduleByTarget.get(context.target);\n await module?.postBuild?.(context);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/deploy/index.ts"],"sourcesContent":["import {\n detectDeployProviderFromEnv,\n loadResuxDeployConfig,\n normalizeProviderPreset,\n} from \"./common.js\";\nimport { cloudflareDeployModule } from \"./cloudflare.js\";\nimport { netlifyDeployModule } from \"./netlify.js\";\nimport { nodeDeployModule } from \"./node.js\";\nimport { staticDeployModule } from \"./static.js\";\nimport type {\n DeployBuildContext,\n DeployDetectionContext,\n DeploymentResolution,\n DeployTargetModule,\n ResuxResolvedDeployTarget,\n} from \"./types.js\";\nimport { vercelDeployModule } from \"./vercel.js\";\n\nconst deployModules: DeployTargetModule[] = [\n vercelDeployModule,\n netlifyDeployModule,\n cloudflareDeployModule,\n staticDeployModule,\n nodeDeployModule,\n];\n\nconst moduleByTarget = new Map<ResuxResolvedDeployTarget, DeployTargetModule>(\n deployModules.map((module) => [module.target, module]),\n);\n\nfunction moduleFromPreset(preset: string): DeployTargetModule | null {\n const normalized = preset.trim().toLowerCase();\n if (!normalized) {\n return null;\n }\n\n return deployModules.find((module) =>\n module.presetAliases.some((alias) => alias === normalized)\n ) ?? null;\n}\n\nfunction buildDetectionContext(\n appRoot: string,\n outDir: string,\n env: NodeJS.ProcessEnv,\n explicitNitroPreset: string | null,\n deployConfig: DeployDetectionContext[\"deployConfig\"],\n): DeployDetectionContext {\n return {\n appRoot,\n outDir,\n env,\n explicitNitroPreset,\n deployConfig,\n };\n}\n\nfunction resolveModuleFromTarget(target: string | undefined): DeployTargetModule | null {\n if (!target || target === \"auto\") {\n return null;\n }\n return moduleByTarget.get(target as ResuxResolvedDeployTarget) ?? null;\n}\n\nfunction readExplicitNitroPreset(\n env: NodeJS.ProcessEnv,\n configPreset: string | undefined,\n): string | null {\n const envPreset = (env.NITRO_PRESET ?? env.RESUX_NITRO_PRESET)?.trim();\n if (envPreset) {\n return envPreset;\n }\n const normalizedConfigPreset = configPreset?.trim();\n return normalizedConfigPreset || null;\n}\n\nfunction createResolution(\n module: DeployTargetModule,\n nitroPreset: string | null,\n reason: string,\n): DeploymentResolution {\n return {\n target: module.target,\n nitroPreset,\n outputLabel: module.outputLabel,\n reason,\n };\n}\n\nexport async function resolveDeployment(\n appRoot: string,\n outDir: string,\n env: NodeJS.ProcessEnv,\n): Promise<DeploymentResolution> {\n const deployConfig = await loadResuxDeployConfig(appRoot, outDir);\n const explicitNitroPreset = readExplicitNitroPreset(env, deployConfig.nitroPreset);\n const detectionContext = buildDetectionContext(\n appRoot,\n outDir,\n env,\n explicitNitroPreset,\n deployConfig,\n );\n\n if (explicitNitroPreset) {\n const presetModule = moduleFromPreset(explicitNitroPreset);\n if (presetModule) {\n return createResolution(\n presetModule,\n explicitNitroPreset,\n \"explicit Nitro preset\",\n );\n }\n }\n\n const configuredTargetModule = resolveModuleFromTarget(deployConfig.target);\n if (configuredTargetModule) {\n const configuredPreset =\n deployConfig.nitroPreset\n ?? configuredTargetModule.inferPreset?.(detectionContext)\n ?? null;\n return createResolution(\n configuredTargetModule,\n configuredPreset,\n \"resux.config deploy.target\",\n );\n }\n\n const provider = detectDeployProviderFromEnv(env);\n if (provider) {\n const providerPreset = normalizeProviderPreset(provider);\n const providerModule = moduleFromPreset(providerPreset);\n if (providerModule) {\n if (providerModule.target === \"cloudflare\" && deployConfig.target !== \"cloudflare\") {\n // Cloudflare worker presets need an edge-compatible app handler.\n // Keep auto mode on node fallback unless the app explicitly opts in.\n } else {\n return createResolution(\n providerModule,\n providerPreset,\n `environment provider (${provider})`,\n );\n }\n }\n }\n\n for (const module of deployModules) {\n if (module.target === \"cloudflare\" && deployConfig.target !== \"cloudflare\") {\n continue;\n }\n if (!(await module.detect?.(detectionContext))) {\n continue;\n }\n const inferredPreset = module.inferPreset?.(detectionContext) ?? null;\n return createResolution(module, inferredPreset, `${module.target} project detection`);\n }\n\n const fallbackPreset = nodeDeployModule.inferPreset?.(detectionContext) ?? null;\n return createResolution(nodeDeployModule, fallbackPreset, \"default node target\");\n}\n\nexport async function applyDeploymentPostBuild(context: DeployBuildContext): Promise<void> {\n const module = moduleByTarget.get(context.target);\n await module?.postBuild?.(context);\n}\n"],"mappings":";;;;;;;;AAkBA,MAAM,gBAAsC;CAC1C;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,iBAAiB,IAAI,IACzB,cAAc,KAAK,WAAW,CAAC,OAAO,QAAQ,OAAO,CAAC,CACvD;AAED,SAAS,iBAAiB,QAA2C;CACnE,MAAM,aAAa,OAAO,MAAM,CAAC,aAAa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I,OAAO,WAAW,gBAAgB,aAAa,WAAW,aAC5D;AAEF,MAAI,CAAE,MAAM,OAAO,SAAS,iBAAiB,CAC3C;AAGF,SAAO,iBAAiB,QADD,OAAO,cAAc,iBAAiB,IAAI,MACjB,GAAG,OAAO,OAAO,oBAAoB;;AAIvF,QAAO,iBAAiB,kBADD,iBAAiB,cAAc,iBAAiB,IAAI,MACjB,sBAAsB;;AAGlF,eAAsB,yBAAyB,SAA4C;AAEzF,OADe,eAAe,IAAI,QAAQ,OAAO,EACnC,YAAY,QAAQ"}
|
package/dist/deploy/netlify.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DeployTargetModule } from "./types.js";
|
|
2
|
+
|
|
2
3
|
//#region src/deploy/netlify.d.ts
|
|
3
|
-
|
|
4
|
+
declare const netlifyDeployModule: DeployTargetModule;
|
|
4
5
|
//#endregion
|
|
6
|
+
export { netlifyDeployModule };
|
|
5
7
|
//# sourceMappingURL=netlify.d.ts.map
|
package/dist/deploy/netlify.js
CHANGED
|
@@ -4,6 +4,7 @@ import { ensureResuxProductionReport } from "./production-report.js";
|
|
|
4
4
|
import { ensureRuntimeDependencyTrees, ensureServerRuntimeDependencyTrees } from "./runtime-dependencies.js";
|
|
5
5
|
import { readdir } from "node:fs/promises";
|
|
6
6
|
import path from "node:path";
|
|
7
|
+
|
|
7
8
|
//#region src/deploy/netlify.ts
|
|
8
9
|
async function detect(context) {
|
|
9
10
|
if (context.env.NETLIFY && !context.env.NETLIFY_LOCAL) return true;
|
|
@@ -44,7 +45,7 @@ const netlifyDeployModule = {
|
|
|
44
45
|
inferPreset: () => "netlify",
|
|
45
46
|
postBuild
|
|
46
47
|
};
|
|
48
|
+
|
|
47
49
|
//#endregion
|
|
48
50
|
export { netlifyDeployModule };
|
|
49
|
-
|
|
50
51
|
//# sourceMappingURL=netlify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netlify.js","names":[],"sources":["../../src/deploy/netlify.ts"],"sourcesContent":["import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n assertRuntimeClientAsset,\n ensureResuxClientAssets,\n ensureResuxServerPayload,\n pathExists,\n} from \"./common.js\";\nimport { ensureResuxFrameworkRuntime } from \"./framework-runtime.js\";\nimport { ensureResuxProductionReport } from \"./production-report.js\";\nimport {\n ensureRuntimeDependencyTrees,\n ensureServerRuntimeDependencyTrees,\n} from \"./runtime-dependencies.js\";\nimport type {\n DeployBuildContext,\n DeployDetectionContext,\n DeployTargetModule,\n} from \"./types.js\";\n\nasync function detect(context: DeployDetectionContext): Promise<boolean> {\n if (context.env.NETLIFY && !context.env.NETLIFY_LOCAL) {\n return true;\n }\n\n return pathExists(path.join(context.appRoot, \"netlify.toml\"));\n}\n\nasync function listInternalFunctionRoots(appRoot: string): Promise<string[]> {\n const functionsInternalDir = path.join(appRoot, \".netlify\", \"functions-internal\");\n const entries = await readdir(functionsInternalDir, { withFileTypes: true }).catch(() => []);\n return entries\n .filter((entry) => entry.isDirectory())\n .map((entry) => path.join(functionsInternalDir, entry.name));\n}\n\nasync function postBuild(context: DeployBuildContext): Promise<void> {\n await ensureResuxClientAssets(context.appRoot, [\n {\n root: path.join(context.appRoot, \"dist\"),\n target: path.join(context.appRoot, \"dist\", \"__resux\"),\n },\n {\n root: path.join(context.appRoot, \".output\"),\n target: path.join(context.appRoot, \".output\", \"public\", \"__resux\"),\n },\n ]);\n\n const functionRoots = await listInternalFunctionRoots(context.appRoot);\n if (!functionRoots.length) {\n throw new Error(\n \"Resux netlify deployment output is missing .netlify/functions-internal server functions.\",\n );\n }\n const payloadTargets = functionRoots.map((functionRoot) =>\n path.join(functionRoot, \".resux\", \"server\")\n );\n await ensureResuxServerPayload(context.appRoot, payloadTargets);\n await ensureResuxProductionReport(context.appRoot, functionRoots);\n await ensureResuxFrameworkRuntime(context.appRoot, functionRoots);\n await ensureServerRuntimeDependencyTrees(\n context.appRoot,\n path.join(context.appRoot, \".resux\", \"server\"),\n functionRoots,\n \"Resux Netlify\",\n );\n await ensureRuntimeDependencyTrees(\n context.appRoot,\n functionRoots,\n \"sharp\",\n \"Resux Netlify image optimizer\",\n );\n await assertRuntimeClientAsset(path.join(context.appRoot, \"dist\"));\n}\n\nexport const netlifyDeployModule: DeployTargetModule = {\n target: \"netlify\",\n presetAliases: [\"netlify\", \"netlify_builder\", \"netlify-builder\", \"netlify-edge\"],\n outputLabel: \"dist + .netlify/functions-internal\",\n detect,\n inferPreset: () => \"netlify\",\n postBuild,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"netlify.js","names":[],"sources":["../../src/deploy/netlify.ts"],"sourcesContent":["import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n assertRuntimeClientAsset,\n ensureResuxClientAssets,\n ensureResuxServerPayload,\n pathExists,\n} from \"./common.js\";\nimport { ensureResuxFrameworkRuntime } from \"./framework-runtime.js\";\nimport { ensureResuxProductionReport } from \"./production-report.js\";\nimport {\n ensureRuntimeDependencyTrees,\n ensureServerRuntimeDependencyTrees,\n} from \"./runtime-dependencies.js\";\nimport type {\n DeployBuildContext,\n DeployDetectionContext,\n DeployTargetModule,\n} from \"./types.js\";\n\nasync function detect(context: DeployDetectionContext): Promise<boolean> {\n if (context.env.NETLIFY && !context.env.NETLIFY_LOCAL) {\n return true;\n }\n\n return pathExists(path.join(context.appRoot, \"netlify.toml\"));\n}\n\nasync function listInternalFunctionRoots(appRoot: string): Promise<string[]> {\n const functionsInternalDir = path.join(appRoot, \".netlify\", \"functions-internal\");\n const entries = await readdir(functionsInternalDir, { withFileTypes: true }).catch(() => []);\n return entries\n .filter((entry) => entry.isDirectory())\n .map((entry) => path.join(functionsInternalDir, entry.name));\n}\n\nasync function postBuild(context: DeployBuildContext): Promise<void> {\n await ensureResuxClientAssets(context.appRoot, [\n {\n root: path.join(context.appRoot, \"dist\"),\n target: path.join(context.appRoot, \"dist\", \"__resux\"),\n },\n {\n root: path.join(context.appRoot, \".output\"),\n target: path.join(context.appRoot, \".output\", \"public\", \"__resux\"),\n },\n ]);\n\n const functionRoots = await listInternalFunctionRoots(context.appRoot);\n if (!functionRoots.length) {\n throw new Error(\n \"Resux netlify deployment output is missing .netlify/functions-internal server functions.\",\n );\n }\n const payloadTargets = functionRoots.map((functionRoot) =>\n path.join(functionRoot, \".resux\", \"server\")\n );\n await ensureResuxServerPayload(context.appRoot, payloadTargets);\n await ensureResuxProductionReport(context.appRoot, functionRoots);\n await ensureResuxFrameworkRuntime(context.appRoot, functionRoots);\n await ensureServerRuntimeDependencyTrees(\n context.appRoot,\n path.join(context.appRoot, \".resux\", \"server\"),\n functionRoots,\n \"Resux Netlify\",\n );\n await ensureRuntimeDependencyTrees(\n context.appRoot,\n functionRoots,\n \"sharp\",\n \"Resux Netlify image optimizer\",\n );\n await assertRuntimeClientAsset(path.join(context.appRoot, \"dist\"));\n}\n\nexport const netlifyDeployModule: DeployTargetModule = {\n target: \"netlify\",\n presetAliases: [\"netlify\", \"netlify_builder\", \"netlify-builder\", \"netlify-edge\"],\n outputLabel: \"dist + .netlify/functions-internal\",\n detect,\n inferPreset: () => \"netlify\",\n postBuild,\n};\n"],"mappings":";;;;;;;;AAoBA,eAAe,OAAO,SAAmD;AACvE,KAAI,QAAQ,IAAI,WAAW,CAAC,QAAQ,IAAI,cACtC,QAAO;AAGT,QAAO,WAAW,KAAK,KAAK,QAAQ,SAAS,eAAe,CAAC;;AAG/D,eAAe,0BAA0B,SAAoC;CAC3E,MAAM,uBAAuB,KAAK,KAAK,SAAS,YAAY,qBAAqB;AAEjF,SADgB,MAAM,QAAQ,sBAAsB,EAAE,eAAe,MAAM,CAAC,CAAC,YAAY,EAAE,CAAC,EAEzF,QAAQ,UAAU,MAAM,aAAa,CAAC,CACtC,KAAK,UAAU,KAAK,KAAK,sBAAsB,MAAM,KAAK,CAAC;;AAGhE,eAAe,UAAU,SAA4C;AACnE,OAAM,wBAAwB,QAAQ,SAAS,CAC7C;EACE,MAAM,KAAK,KAAK,QAAQ,SAAS,OAAO;EACxC,QAAQ,KAAK,KAAK,QAAQ,SAAS,QAAQ,UAAU;EACtD,EACD;EACE,MAAM,KAAK,KAAK,QAAQ,SAAS,UAAU;EAC3C,QAAQ,KAAK,KAAK,QAAQ,SAAS,WAAW,UAAU,UAAU;EACnE,CACF,CAAC;CAEF,MAAM,gBAAgB,MAAM,0BAA0B,QAAQ,QAAQ;AACtE,KAAI,CAAC,cAAc,OACjB,OAAM,IAAI,MACR,2FACD;CAEH,MAAM,iBAAiB,cAAc,KAAK,iBACxC,KAAK,KAAK,cAAc,UAAU,SAAS,CAC5C;AACD,OAAM,yBAAyB,QAAQ,SAAS,eAAe;AAC/D,OAAM,4BAA4B,QAAQ,SAAS,cAAc;AACjE,OAAM,4BAA4B,QAAQ,SAAS,cAAc;AACjE,OAAM,mCACJ,QAAQ,SACR,KAAK,KAAK,QAAQ,SAAS,UAAU,SAAS,EAC9C,eACA,gBACD;AACD,OAAM,6BACJ,QAAQ,SACR,eACA,SACA,gCACD;AACD,OAAM,yBAAyB,KAAK,KAAK,QAAQ,SAAS,OAAO,CAAC;;AAGpE,MAAa,sBAA0C;CACrD,QAAQ;CACR,eAAe;EAAC;EAAW;EAAmB;EAAmB;EAAe;CAChF,aAAa;CACb;CACA,mBAAmB;CACnB;CACD"}
|
package/dist/deploy/node.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DeployTargetModule } from "./types.js";
|
|
2
|
+
|
|
2
3
|
//#region src/deploy/node.d.ts
|
|
3
|
-
|
|
4
|
+
declare const nodeDeployModule: DeployTargetModule;
|
|
4
5
|
//#endregion
|
|
6
|
+
export { nodeDeployModule };
|
|
5
7
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/deploy/node.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertResuxServerManifest, assertRuntimeClientAsset, ensureResuxClientAssets, pathExists } from "./common.js";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
|
|
3
4
|
//#region src/deploy/node.ts
|
|
4
5
|
async function postBuild(context) {
|
|
5
6
|
await ensureResuxClientAssets(context.appRoot, [{
|
|
@@ -8,8 +9,7 @@ async function postBuild(context) {
|
|
|
8
9
|
}]);
|
|
9
10
|
await assertResuxServerManifest(context.appRoot);
|
|
10
11
|
await assertRuntimeClientAsset(path.join(context.appRoot, ".output", "public"));
|
|
11
|
-
|
|
12
|
-
if (!await pathExists(serverEntry)) throw new Error("Resux node deployment output is missing .output/server/index.mjs.");
|
|
12
|
+
if (!await pathExists(path.join(context.appRoot, ".output", "server", "index.mjs"))) throw new Error("Resux node deployment output is missing .output/server/index.mjs.");
|
|
13
13
|
}
|
|
14
14
|
const nodeDeployModule = {
|
|
15
15
|
target: "node",
|
|
@@ -23,7 +23,7 @@ const nodeDeployModule = {
|
|
|
23
23
|
inferPreset: () => "node-server",
|
|
24
24
|
postBuild
|
|
25
25
|
};
|
|
26
|
+
|
|
26
27
|
//#endregion
|
|
27
28
|
export { nodeDeployModule };
|
|
28
|
-
|
|
29
29
|
//# sourceMappingURL=node.js.map
|
package/dist/deploy/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","names":[],"sources":["../../src/deploy/node.ts"],"sourcesContent":["import path from \"node:path\";\nimport {\n assertResuxServerManifest,\n assertRuntimeClientAsset,\n ensureResuxClientAssets,\n pathExists,\n} from \"./common.js\";\nimport type { DeployBuildContext, DeployTargetModule } from \"./types.js\";\n\nasync function postBuild(context: DeployBuildContext): Promise<void> {\n await ensureResuxClientAssets(context.appRoot, [\n {\n root: path.join(context.appRoot, \".output\"),\n target: path.join(context.appRoot, \".output\", \"public\", \"__resux\"),\n },\n ]);\n\n await assertResuxServerManifest(context.appRoot);\n await assertRuntimeClientAsset(path.join(context.appRoot, \".output\", \"public\"));\n const serverEntry = path.join(context.appRoot, \".output\", \"server\", \"index.mjs\");\n if (!(await pathExists(serverEntry))) {\n throw new Error(\"Resux node deployment output is missing .output/server/index.mjs.\");\n }\n}\n\nexport const nodeDeployModule: DeployTargetModule = {\n target: \"node\",\n presetAliases: [\"node-server\", \"node\", \"node_cluster\", \"node-cluster\"],\n outputLabel: \".output\",\n inferPreset: () => \"node-server\",\n postBuild,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.js","names":[],"sources":["../../src/deploy/node.ts"],"sourcesContent":["import path from \"node:path\";\nimport {\n assertResuxServerManifest,\n assertRuntimeClientAsset,\n ensureResuxClientAssets,\n pathExists,\n} from \"./common.js\";\nimport type { DeployBuildContext, DeployTargetModule } from \"./types.js\";\n\nasync function postBuild(context: DeployBuildContext): Promise<void> {\n await ensureResuxClientAssets(context.appRoot, [\n {\n root: path.join(context.appRoot, \".output\"),\n target: path.join(context.appRoot, \".output\", \"public\", \"__resux\"),\n },\n ]);\n\n await assertResuxServerManifest(context.appRoot);\n await assertRuntimeClientAsset(path.join(context.appRoot, \".output\", \"public\"));\n const serverEntry = path.join(context.appRoot, \".output\", \"server\", \"index.mjs\");\n if (!(await pathExists(serverEntry))) {\n throw new Error(\"Resux node deployment output is missing .output/server/index.mjs.\");\n }\n}\n\nexport const nodeDeployModule: DeployTargetModule = {\n target: \"node\",\n presetAliases: [\"node-server\", \"node\", \"node_cluster\", \"node-cluster\"],\n outputLabel: \".output\",\n inferPreset: () => \"node-server\",\n postBuild,\n};\n"],"mappings":";;;;AASA,eAAe,UAAU,SAA4C;AACnE,OAAM,wBAAwB,QAAQ,SAAS,CAC7C;EACE,MAAM,KAAK,KAAK,QAAQ,SAAS,UAAU;EAC3C,QAAQ,KAAK,KAAK,QAAQ,SAAS,WAAW,UAAU,UAAU;EACnE,CACF,CAAC;AAEF,OAAM,0BAA0B,QAAQ,QAAQ;AAChD,OAAM,yBAAyB,KAAK,KAAK,QAAQ,SAAS,WAAW,SAAS,CAAC;AAE/E,KAAI,CAAE,MAAM,WADQ,KAAK,KAAK,QAAQ,SAAS,WAAW,UAAU,YAAY,CAC7C,CACjC,OAAM,IAAI,MAAM,oEAAoE;;AAIxF,MAAa,mBAAuC;CAClD,QAAQ;CACR,eAAe;EAAC;EAAe;EAAQ;EAAgB;EAAe;CACtE,aAAa;CACb,mBAAmB;CACnB;CACD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/deploy/production-report.d.ts
|
|
2
|
-
|
|
2
|
+
declare function ensureResuxProductionReport(appRoot: string, runtimeRoots: string[]): Promise<void>;
|
|
3
3
|
//#endregion
|
|
4
|
+
export { ensureResuxProductionReport };
|
|
4
5
|
//# sourceMappingURL=production-report.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pathExists } from "./common.js";
|
|
2
2
|
import { cp, mkdir } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
|
|
4
5
|
//#region src/deploy/production-report.ts
|
|
5
6
|
const REPORT_FILENAME = "halal-report.json";
|
|
6
7
|
async function ensureResuxProductionReport(appRoot, runtimeRoots) {
|
|
@@ -13,7 +14,7 @@ async function ensureResuxProductionReport(appRoot, runtimeRoots) {
|
|
|
13
14
|
await cp(source, target, { force: true });
|
|
14
15
|
}
|
|
15
16
|
}
|
|
17
|
+
|
|
16
18
|
//#endregion
|
|
17
19
|
export { ensureResuxProductionReport };
|
|
18
|
-
|
|
19
20
|
//# sourceMappingURL=production-report.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"production-report.js","names":[],"sources":["../../src/deploy/production-report.ts"],"sourcesContent":["import { cp, mkdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathExists } from \"./common.js\";\n\nconst REPORT_FILENAME = \"halal-report.json\";\n\nexport async function ensureResuxProductionReport(\n appRoot: string,\n runtimeRoots: string[],\n): Promise<void> {\n if (!runtimeRoots.length) {\n return;\n }\n\n const source = path.join(appRoot, \".resux\", REPORT_FILENAME);\n if (!(await pathExists(source))) {\n throw new Error(\n \"Resux deployment is missing .resux/halal-report.json. Run `resux build` with RESUX_HALAL_REPORT_SIGNING_SECRET configured and retry.\",\n );\n }\n\n for (const runtimeRoot of runtimeRoots) {\n const target = path.join(runtimeRoot, \".resux\", REPORT_FILENAME);\n await mkdir(path.dirname(target), { recursive: true });\n await cp(source, target, { force: true });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"production-report.js","names":[],"sources":["../../src/deploy/production-report.ts"],"sourcesContent":["import { cp, mkdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathExists } from \"./common.js\";\n\nconst REPORT_FILENAME = \"halal-report.json\";\n\nexport async function ensureResuxProductionReport(\n appRoot: string,\n runtimeRoots: string[],\n): Promise<void> {\n if (!runtimeRoots.length) {\n return;\n }\n\n const source = path.join(appRoot, \".resux\", REPORT_FILENAME);\n if (!(await pathExists(source))) {\n throw new Error(\n \"Resux deployment is missing .resux/halal-report.json. Run `resux build` with RESUX_HALAL_REPORT_SIGNING_SECRET configured and retry.\",\n );\n }\n\n for (const runtimeRoot of runtimeRoots) {\n const target = path.join(runtimeRoot, \".resux\", REPORT_FILENAME);\n await mkdir(path.dirname(target), { recursive: true });\n await cp(source, target, { force: true });\n }\n}\n"],"mappings":";;;;;AAIA,MAAM,kBAAkB;AAExB,eAAsB,4BACpB,SACA,cACe;AACf,KAAI,CAAC,aAAa,OAChB;CAGF,MAAM,SAAS,KAAK,KAAK,SAAS,UAAU,gBAAgB;AAC5D,KAAI,CAAE,MAAM,WAAW,OAAO,CAC5B,OAAM,IAAI,MACR,uIACD;AAGH,MAAK,MAAM,eAAe,cAAc;EACtC,MAAM,SAAS,KAAK,KAAK,aAAa,UAAU,gBAAgB;AAChE,QAAM,MAAM,KAAK,QAAQ,OAAO,EAAE,EAAE,WAAW,MAAM,CAAC;AACtD,QAAM,GAAG,QAAQ,QAAQ,EAAE,OAAO,MAAM,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
//#region src/deploy/runtime-dependencies.d.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
declare function collectServerRuntimeDependencyNames(serverRoot: string): Promise<string[]>;
|
|
3
|
+
declare function copyRuntimeDependencyTree(appRoot: string, runtimeRoot: string, rootDependency: string, consumerLabel: string): Promise<void>;
|
|
4
|
+
declare function ensureRuntimeDependencyTrees(appRoot: string, runtimeRoots: string[], rootDependency: string, consumerLabel: string): Promise<void>;
|
|
5
|
+
declare function ensureServerRuntimeDependencyTrees(appRoot: string, serverRoot: string, runtimeRoots: string[], consumerLabel: string): Promise<string[]>;
|
|
6
6
|
//#endregion
|
|
7
|
+
export { collectServerRuntimeDependencyNames, copyRuntimeDependencyTree, ensureRuntimeDependencyTrees, ensureServerRuntimeDependencyTrees };
|
|
7
8
|
//# sourceMappingURL=runtime-dependencies.d.ts.map
|
|
@@ -3,6 +3,7 @@ import { builtinModules, createRequire } from "node:module";
|
|
|
3
3
|
import { cp, mkdir, readFile, readdir, rm } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import ts from "typescript";
|
|
6
|
+
|
|
6
7
|
//#region src/deploy/runtime-dependencies.ts
|
|
7
8
|
const nodeBuiltins = new Set(builtinModules.flatMap((name) => [name, name.startsWith("node:") ? name.slice(5) : `node:${name}`]));
|
|
8
9
|
function isRecord(value) {
|
|
@@ -171,8 +172,7 @@ async function copyRuntimeDependencyTree(appRoot, runtimeRoot, rootDependency, c
|
|
|
171
172
|
});
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
-
if (!await pathExists(requiredDependencyPath)) throw new Error(`${consumerLabel} could not prepare "${rootDependency}" for ${runtimeRoot}.`);
|
|
175
|
+
if (!await pathExists(path.join(dependencyTargetPath(runtimeRoot, rootDependency), "package.json"))) throw new Error(`${consumerLabel} could not prepare "${rootDependency}" for ${runtimeRoot}.`);
|
|
176
176
|
}
|
|
177
177
|
async function ensureRuntimeDependencyTrees(appRoot, runtimeRoots, rootDependency, consumerLabel) {
|
|
178
178
|
for (const runtimeRoot of runtimeRoots) await copyRuntimeDependencyTree(appRoot, runtimeRoot, rootDependency, consumerLabel);
|
|
@@ -182,7 +182,7 @@ async function ensureServerRuntimeDependencyTrees(appRoot, serverRoot, runtimeRo
|
|
|
182
182
|
for (const dependency of dependencies) await ensureRuntimeDependencyTrees(appRoot, runtimeRoots, dependency, `${consumerLabel} server runtime`);
|
|
183
183
|
return dependencies;
|
|
184
184
|
}
|
|
185
|
+
|
|
185
186
|
//#endregion
|
|
186
187
|
export { collectServerRuntimeDependencyNames, copyRuntimeDependencyTree, ensureRuntimeDependencyTrees, ensureServerRuntimeDependencyTrees };
|
|
187
|
-
|
|
188
188
|
//# sourceMappingURL=runtime-dependencies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-dependencies.js","names":[],"sources":["../../src/deploy/runtime-dependencies.ts"],"sourcesContent":["import { cp, mkdir, readFile, readdir, rm } from \"node:fs/promises\";\nimport { builtinModules, createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport ts from \"typescript\";\nimport { pathExists, readJsonRecord } from \"./common.js\";\n\ninterface PackageRecord extends Record<string, unknown> {\n name?: unknown;\n dependencies?: unknown;\n optionalDependencies?: unknown;\n peerDependencies?: unknown;\n peerDependenciesMeta?: unknown;\n}\n\nconst nodeBuiltins = new Set(\n builtinModules.flatMap((name) => [\n name,\n name.startsWith(\"node:\") ? name.slice(5) : `node:${name}`,\n ]),\n);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction runtimeDependencyNames(value: unknown): string[] {\n if (!isRecord(value)) {\n return [];\n }\n return Object.keys(value).filter((name) => name.trim().length > 0);\n}\n\nfunction dependencyTargetPath(runtimeRoot: string, packageName: string): string {\n return path.join(runtimeRoot, \"node_modules\", ...packageName.split(\"/\"));\n}\n\nfunction packageNameFromSpecifier(specifier: string): string | null {\n if (\n !specifier\n || specifier.startsWith(\".\")\n || specifier.startsWith(\"/\")\n || specifier.startsWith(\"#\")\n || specifier.startsWith(\"data:\")\n || specifier.startsWith(\"file:\")\n || nodeBuiltins.has(specifier)\n ) {\n return null;\n }\n\n if (specifier.startsWith(\"@\")) {\n const [scope, name] = specifier.split(\"/\");\n return scope && name ? `${scope}/${name}` : null;\n }\n\n const packageName = specifier.split(\"/\")[0] ?? \"\";\n return packageName && !nodeBuiltins.has(packageName) ? packageName : null;\n}\n\nasync function walkRuntimeModuleFiles(directory: string): Promise<string[]> {\n const entries = await readdir(directory, { withFileTypes: true }).catch(() => []);\n const files: string[] = [];\n\n for (const entry of entries) {\n const fullPath = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n files.push(...(await walkRuntimeModuleFiles(fullPath)));\n continue;\n }\n if (entry.isFile() && /\\.(?:mjs|cjs|js)$/.test(entry.name)) {\n files.push(fullPath);\n }\n }\n\n return files;\n}\n\nfunction collectModuleSpecifiers(sourceFile: ts.SourceFile): string[] {\n const specifiers: string[] = [];\n\n function visit(node: ts.Node): void {\n if (\n (ts.isImportDeclaration(node) || ts.isExportDeclaration(node))\n && node.moduleSpecifier\n && ts.isStringLiteralLike(node.moduleSpecifier)\n ) {\n specifiers.push(node.moduleSpecifier.text);\n } else if (\n ts.isCallExpression(node)\n && node.expression.kind === ts.SyntaxKind.ImportKeyword\n && node.arguments.length === 1\n && ts.isStringLiteralLike(node.arguments[0])\n ) {\n specifiers.push(node.arguments[0].text);\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return specifiers;\n}\n\nexport async function collectServerRuntimeDependencyNames(\n serverRoot: string,\n): Promise<string[]> {\n if (!(await pathExists(serverRoot))) {\n return [];\n }\n\n const dependencyNames = new Set<string>();\n\n for (const file of await walkRuntimeModuleFiles(serverRoot)) {\n const source = await readFile(file, \"utf8\");\n const sourceFile = ts.createSourceFile(\n file,\n source,\n ts.ScriptTarget.Latest,\n false,\n ts.ScriptKind.JS,\n );\n\n for (const specifier of collectModuleSpecifiers(sourceFile)) {\n const packageName = packageNameFromSpecifier(specifier);\n if (packageName && packageName !== \"resuxjs\" && packageName !== \"resux\") {\n dependencyNames.add(packageName);\n }\n }\n }\n\n return [...dependencyNames].sort();\n}\n\nfunction resolveResuxPackageRequire(\n appRequire: ReturnType<typeof createRequire>,\n): ReturnType<typeof createRequire> | null {\n for (const packageName of [\"resuxjs\", \"resux\"]) {\n try {\n return createRequire(appRequire.resolve(packageName));\n } catch {\n try {\n return createRequire(appRequire.resolve(`${packageName}/package.json`));\n } catch {\n // Keep trying known package names.\n }\n }\n }\n return null;\n}\n\nfunction formatResolutionError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nasync function findPackageJsonFromEntry(\n dependency: string,\n entryPath: string,\n): Promise<string | null> {\n let currentDirectory = path.dirname(entryPath);\n\n while (true) {\n const candidate = path.join(currentDirectory, \"package.json\");\n const packageJson = (await readJsonRecord(candidate)) as PackageRecord | null;\n if (packageJson?.name === dependency) {\n return candidate;\n }\n\n const parentDirectory = path.dirname(currentDirectory);\n if (parentDirectory === currentDirectory) {\n return null;\n }\n currentDirectory = parentDirectory;\n }\n}\n\nasync function findPackageJsonFromSearchPaths(\n dependency: string,\n resolver: ReturnType<typeof createRequire>,\n): Promise<string | null> {\n const searchPaths = resolver.resolve.paths(dependency) ?? [];\n for (const nodeModulesRoot of searchPaths) {\n const candidate = path.join(\n nodeModulesRoot,\n ...dependency.split(\"/\"),\n \"package.json\",\n );\n const packageJson = (await readJsonRecord(candidate)) as PackageRecord | null;\n if (packageJson?.name === dependency) {\n return candidate;\n }\n }\n return null;\n}\n\nasync function resolveDependencyPackageJsonPath(\n dependency: string,\n resolver: ReturnType<typeof createRequire>,\n resolutionErrors?: string[],\n): Promise<string | null> {\n let entryResolutionError: unknown = null;\n try {\n const entryPath = resolver.resolve(dependency);\n const packageJsonPath = await findPackageJsonFromEntry(dependency, entryPath);\n if (packageJsonPath) {\n return packageJsonPath;\n }\n entryResolutionError = new Error(\n `Resolved \"${dependency}\" to ${entryPath}, but its package root could not be located.`,\n );\n } catch (error) {\n entryResolutionError = error;\n }\n\n // Native packages such as @img/sharp-linux-x64 intentionally expose only\n // specific subpaths, so neither the package root nor ./package.json is\n // necessarily resolvable through exports. Node still exposes the node_modules\n // lookup roots; inspect those roots directly without bypassing package identity.\n const searchPathPackageJson = await findPackageJsonFromSearchPaths(dependency, resolver);\n if (searchPathPackageJson) {\n return searchPathPackageJson;\n }\n\n // Preserve compatibility with packages that explicitly export package.json.\n try {\n return resolver.resolve(`${dependency}/package.json`);\n } catch (packageJsonError) {\n resolutionErrors?.push(\n `${formatResolutionError(entryResolutionError)} | ${formatResolutionError(packageJsonError)}`,\n );\n return null;\n }\n}\n\nexport async function copyRuntimeDependencyTree(\n appRoot: string,\n runtimeRoot: string,\n rootDependency: string,\n consumerLabel: string,\n): Promise<void> {\n const appRequire = createRequire(path.join(appRoot, \"package.json\"));\n const resuxPackageRequire = resolveResuxPackageRequire(appRequire);\n const rootResolvers = [appRequire, ...(resuxPackageRequire ? [resuxPackageRequire] : [])];\n const resolutionErrors: string[] = [];\n let rootDependencyPackageJsonPath: string | null = null;\n\n for (const resolver of rootResolvers) {\n rootDependencyPackageJsonPath = await resolveDependencyPackageJsonPath(\n rootDependency,\n resolver,\n resolutionErrors,\n );\n if (rootDependencyPackageJsonPath) {\n break;\n }\n }\n\n if (!rootDependencyPackageJsonPath) {\n throw new Error(\n `${consumerLabel} requires \"${rootDependency}\" but it could not be resolved from app or framework dependencies. (${resolutionErrors.join(\" | \")})`,\n );\n }\n\n const pending = [{\n dependency: rootDependency,\n packageJsonPath: rootDependencyPackageJsonPath,\n }];\n const copied = new Set<string>();\n\n while (pending.length > 0) {\n const next = pending.shift();\n if (!next || copied.has(next.dependency)) {\n continue;\n }\n copied.add(next.dependency);\n\n const sourcePackageJsonPath = next.packageJsonPath;\n const sourcePackageRoot = path.dirname(sourcePackageJsonPath);\n const targetPackageRoot = dependencyTargetPath(runtimeRoot, next.dependency);\n\n await rm(targetPackageRoot, { recursive: true, force: true });\n await mkdir(path.dirname(targetPackageRoot), { recursive: true });\n await cp(sourcePackageRoot, targetPackageRoot, {\n recursive: true,\n force: true,\n dereference: true,\n });\n\n const packageJson = (await readJsonRecord(sourcePackageJsonPath)) as PackageRecord | null;\n if (!packageJson) {\n continue;\n }\n\n const dependencyResolver = createRequire(sourcePackageJsonPath);\n for (const dependency of runtimeDependencyNames(packageJson.dependencies)) {\n const dependencyPackageJsonPath = await resolveDependencyPackageJsonPath(\n dependency,\n dependencyResolver,\n );\n if (!dependencyPackageJsonPath) {\n throw new Error(\n `${consumerLabel} dependency \"${next.dependency}\" is missing required package \"${dependency}\".`,\n );\n }\n pending.push({ dependency, packageJsonPath: dependencyPackageJsonPath });\n }\n\n for (const dependency of runtimeDependencyNames(packageJson.optionalDependencies)) {\n const dependencyPackageJsonPath = await resolveDependencyPackageJsonPath(\n dependency,\n dependencyResolver,\n );\n if (!dependencyPackageJsonPath) {\n continue;\n }\n pending.push({ dependency, packageJsonPath: dependencyPackageJsonPath });\n }\n\n // Peer dependencies are runtime requirements supplied by the consuming app\n // rather than nested package dependencies. Include installed peers in the\n // serverless closure, but do not fail packaging when an optional/uninstalled\n // peer is intentionally absent. This mirrors Node's runtime resolution model\n // without treating peer declarations as unconditional npm package imports.\n for (const dependency of runtimeDependencyNames(packageJson.peerDependencies)) {\n const dependencyPackageJsonPath = await resolveDependencyPackageJsonPath(\n dependency,\n dependencyResolver,\n );\n if (!dependencyPackageJsonPath) {\n continue;\n }\n pending.push({ dependency, packageJsonPath: dependencyPackageJsonPath });\n }\n }\n\n const requiredDependencyPath = path.join(\n dependencyTargetPath(runtimeRoot, rootDependency),\n \"package.json\",\n );\n if (!(await pathExists(requiredDependencyPath))) {\n throw new Error(\n `${consumerLabel} could not prepare \"${rootDependency}\" for ${runtimeRoot}.`,\n );\n }\n}\n\nexport async function ensureRuntimeDependencyTrees(\n appRoot: string,\n runtimeRoots: string[],\n rootDependency: string,\n consumerLabel: string,\n): Promise<void> {\n for (const runtimeRoot of runtimeRoots) {\n await copyRuntimeDependencyTree(\n appRoot,\n runtimeRoot,\n rootDependency,\n consumerLabel,\n );\n }\n}\n\nexport async function ensureServerRuntimeDependencyTrees(\n appRoot: string,\n serverRoot: string,\n runtimeRoots: string[],\n consumerLabel: string,\n): Promise<string[]> {\n const dependencies = await collectServerRuntimeDependencyNames(serverRoot);\n for (const dependency of dependencies) {\n await ensureRuntimeDependencyTrees(\n appRoot,\n runtimeRoots,\n dependency,\n `${consumerLabel} server runtime`,\n );\n }\n return dependencies;\n}"],"mappings":";;;;;;AAcA,MAAM,eAAe,IAAI,IACvB,eAAe,SAAS,SAAS,CAC/B,MACA,KAAK,WAAW,OAAO,IAAI,KAAK,MAAM,CAAC,IAAI,QAAQ,MACrD,CAAC,CACH;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,uBAAuB,OAA0B;CACxD,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO,CAAC;CAEV,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,SAAS,KAAK,KAAK,CAAC,CAAC,SAAS,CAAC;AACnE;AAEA,SAAS,qBAAqB,aAAqB,aAA6B;CAC9E,OAAO,KAAK,KAAK,aAAa,gBAAgB,GAAG,YAAY,MAAM,GAAG,CAAC;AACzE;AAEA,SAAS,yBAAyB,WAAkC;CAClE,IACE,CAAC,aACE,UAAU,WAAW,GAAG,KACxB,UAAU,WAAW,GAAG,KACxB,UAAU,WAAW,GAAG,KACxB,UAAU,WAAW,OAAO,KAC5B,UAAU,WAAW,OAAO,KAC5B,aAAa,IAAI,SAAS,GAE7B,OAAO;CAGT,IAAI,UAAU,WAAW,GAAG,GAAG;EAC7B,MAAM,CAAC,OAAO,QAAQ,UAAU,MAAM,GAAG;EACzC,OAAO,SAAS,OAAO,GAAG,MAAM,GAAG,SAAS;CAC9C;CAEA,M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ACA,aACA,gBACA,aACF;AAEJ;AAEA,eAAsB,mCACpB,SACA,YACA,cACA,eACmB;CACnB,MAAM,eAAe,MAAM,oCAAoC,UAAU;CACzE,KAAK,MAAM,cAAc,cACvB,MAAM,6BACJ,SACA,cACA,YACA,GAAG,cAAc,gBACnB;CAEF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"runtime-dependencies.js","names":[],"sources":["../../src/deploy/runtime-dependencies.ts"],"sourcesContent":["import { cp, mkdir, readFile, readdir, rm } from \"node:fs/promises\";\nimport { builtinModules, createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport ts from \"typescript\";\nimport { pathExists, readJsonRecord } from \"./common.js\";\n\ninterface PackageRecord extends Record<string, unknown> {\n name?: unknown;\n dependencies?: unknown;\n optionalDependencies?: unknown;\n peerDependencies?: unknown;\n peerDependenciesMeta?: unknown;\n}\n\nconst nodeBuiltins = new Set(\n builtinModules.flatMap((name) => [\n name,\n name.startsWith(\"node:\") ? name.slice(5) : `node:${name}`,\n ]),\n);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction runtimeDependencyNames(value: unknown): string[] {\n if (!isRecord(value)) {\n return [];\n }\n return Object.keys(value).filter((name) => name.trim().length > 0);\n}\n\nfunction dependencyTargetPath(runtimeRoot: string, packageName: string): string {\n return path.join(runtimeRoot, \"node_modules\", ...packageName.split(\"/\"));\n}\n\nfunction packageNameFromSpecifier(specifier: string): string | null {\n if (\n !specifier\n || specifier.startsWith(\".\")\n || specifier.startsWith(\"/\")\n || specifier.startsWith(\"#\")\n || specifier.startsWith(\"data:\")\n || specifier.startsWith(\"file:\")\n || nodeBuiltins.has(specifier)\n ) {\n return null;\n }\n\n if (specifier.startsWith(\"@\")) {\n const [scope, name] = specifier.split(\"/\");\n return scope && name ? `${scope}/${name}` : null;\n }\n\n const packageName = specifier.split(\"/\")[0] ?? \"\";\n return packageName && !nodeBuiltins.has(packageName) ? packageName : null;\n}\n\nasync function walkRuntimeModuleFiles(directory: string): Promise<string[]> {\n const entries = await readdir(directory, { withFileTypes: true }).catch(() => []);\n const files: string[] = [];\n\n for (const entry of entries) {\n const fullPath = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n files.push(...(await walkRuntimeModuleFiles(fullPath)));\n continue;\n }\n if (entry.isFile() && /\\.(?:mjs|cjs|js)$/.test(entry.name)) {\n files.push(fullPath);\n }\n }\n\n return files;\n}\n\nfunction collectModuleSpecifiers(sourceFile: ts.SourceFile): string[] {\n const specifiers: string[] = [];\n\n function visit(node: ts.Node): void {\n if (\n (ts.isImportDeclaration(node) || ts.isExportDeclaration(node))\n && node.moduleSpecifier\n && ts.isStringLiteralLike(node.moduleSpecifier)\n ) {\n specifiers.push(node.moduleSpecifier.text);\n } else if (\n ts.isCallExpression(node)\n && node.expression.kind === ts.SyntaxKind.ImportKeyword\n && node.arguments.length === 1\n && ts.isStringLiteralLike(node.arguments[0])\n ) {\n specifiers.push(node.arguments[0].text);\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return specifiers;\n}\n\nexport async function collectServerRuntimeDependencyNames(\n serverRoot: string,\n): Promise<string[]> {\n if (!(await pathExists(serverRoot))) {\n return [];\n }\n\n const dependencyNames = new Set<string>();\n\n for (const file of await walkRuntimeModuleFiles(serverRoot)) {\n const source = await readFile(file, \"utf8\");\n const sourceFile = ts.createSourceFile(\n file,\n source,\n ts.ScriptTarget.Latest,\n false,\n ts.ScriptKind.JS,\n );\n\n for (const specifier of collectModuleSpecifiers(sourceFile)) {\n const packageName = packageNameFromSpecifier(specifier);\n if (packageName && packageName !== \"resuxjs\" && packageName !== \"resux\") {\n dependencyNames.add(packageName);\n }\n }\n }\n\n return [...dependencyNames].sort();\n}\n\nfunction resolveResuxPackageRequire(\n appRequire: ReturnType<typeof createRequire>,\n): ReturnType<typeof createRequire> | null {\n for (const packageName of [\"resuxjs\", \"resux\"]) {\n try {\n return createRequire(appRequire.resolve(packageName));\n } catch {\n try {\n return createRequire(appRequire.resolve(`${packageName}/package.json`));\n } catch {\n // Keep trying known package names.\n }\n }\n }\n return null;\n}\n\nfunction formatResolutionError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nasync function findPackageJsonFromEntry(\n dependency: string,\n entryPath: string,\n): Promise<string | null> {\n let currentDirectory = path.dirname(entryPath);\n\n while (true) {\n const candidate = path.join(currentDirectory, \"package.json\");\n const packageJson = (await readJsonRecord(candidate)) as PackageRecord | null;\n if (packageJson?.name === dependency) {\n return candidate;\n }\n\n const parentDirectory = path.dirname(currentDirectory);\n if (parentDirectory === currentDirectory) {\n return null;\n }\n currentDirectory = parentDirectory;\n }\n}\n\nasync function findPackageJsonFromSearchPaths(\n dependency: string,\n resolver: ReturnType<typeof createRequire>,\n): Promise<string | null> {\n const searchPaths = resolver.resolve.paths(dependency) ?? [];\n for (const nodeModulesRoot of searchPaths) {\n const candidate = path.join(\n nodeModulesRoot,\n ...dependency.split(\"/\"),\n \"package.json\",\n );\n const packageJson = (await readJsonRecord(candidate)) as PackageRecord | null;\n if (packageJson?.name === dependency) {\n return candidate;\n }\n }\n return null;\n}\n\nasync function resolveDependencyPackageJsonPath(\n dependency: string,\n resolver: ReturnType<typeof createRequire>,\n resolutionErrors?: string[],\n): Promise<string | null> {\n let entryResolutionError: unknown = null;\n try {\n const entryPath = resolver.resolve(dependency);\n const packageJsonPath = await findPackageJsonFromEntry(dependency, entryPath);\n if (packageJsonPath) {\n return packageJsonPath;\n }\n entryResolutionError = new Error(\n `Resolved \"${dependency}\" to ${entryPath}, but its package root could not be located.`,\n );\n } catch (error) {\n entryResolutionError = error;\n }\n\n // Native packages such as @img/sharp-linux-x64 intentionally expose only\n // specific subpaths, so neither the package root nor ./package.json is\n // necessarily resolvable through exports. Node still exposes the node_modules\n // lookup roots; inspect those roots directly without bypassing package identity.\n const searchPathPackageJson = await findPackageJsonFromSearchPaths(dependency, resolver);\n if (searchPathPackageJson) {\n return searchPathPackageJson;\n }\n\n // Preserve compatibility with packages that explicitly export package.json.\n try {\n return resolver.resolve(`${dependency}/package.json`);\n } catch (packageJsonError) {\n resolutionErrors?.push(\n `${formatResolutionError(entryResolutionError)} | ${formatResolutionError(packageJsonError)}`,\n );\n return null;\n }\n}\n\nexport async function copyRuntimeDependencyTree(\n appRoot: string,\n runtimeRoot: string,\n rootDependency: string,\n consumerLabel: string,\n): Promise<void> {\n const appRequire = createRequire(path.join(appRoot, \"package.json\"));\n const resuxPackageRequire = resolveResuxPackageRequire(appRequire);\n const rootResolvers = [appRequire, ...(resuxPackageRequire ? [resuxPackageRequire] : [])];\n const resolutionErrors: string[] = [];\n let rootDependencyPackageJsonPath: string | null = null;\n\n for (const resolver of rootResolvers) {\n rootDependencyPackageJsonPath = await resolveDependencyPackageJsonPath(\n rootDependency,\n resolver,\n resolutionErrors,\n );\n if (rootDependencyPackageJsonPath) {\n break;\n }\n }\n\n if (!rootDependencyPackageJsonPath) {\n throw new Error(\n `${consumerLabel} requires \"${rootDependency}\" but it could not be resolved from app or framework dependencies. (${resolutionErrors.join(\" | \")})`,\n );\n }\n\n const pending = [{\n dependency: rootDependency,\n packageJsonPath: rootDependencyPackageJsonPath,\n }];\n const copied = new Set<string>();\n\n while (pending.length > 0) {\n const next = pending.shift();\n if (!next || copied.has(next.dependency)) {\n continue;\n }\n copied.add(next.dependency);\n\n const sourcePackageJsonPath = next.packageJsonPath;\n const sourcePackageRoot = path.dirname(sourcePackageJsonPath);\n const targetPackageRoot = dependencyTargetPath(runtimeRoot, next.dependency);\n\n await rm(targetPackageRoot, { recursive: true, force: true });\n await mkdir(path.dirname(targetPackageRoot), { recursive: true });\n await cp(sourcePackageRoot, targetPackageRoot, {\n recursive: true,\n force: true,\n dereference: true,\n });\n\n const packageJson = (await readJsonRecord(sourcePackageJsonPath)) as PackageRecord | null;\n if (!packageJson) {\n continue;\n }\n\n const dependencyResolver = createRequire(sourcePackageJsonPath);\n for (const dependency of runtimeDependencyNames(packageJson.dependencies)) {\n const dependencyPackageJsonPath = await resolveDependencyPackageJsonPath(\n dependency,\n dependencyResolver,\n );\n if (!dependencyPackageJsonPath) {\n throw new Error(\n `${consumerLabel} dependency \"${next.dependency}\" is missing required package \"${dependency}\".`,\n );\n }\n pending.push({ dependency, packageJsonPath: dependencyPackageJsonPath });\n }\n\n for (const dependency of runtimeDependencyNames(packageJson.optionalDependencies)) {\n const dependencyPackageJsonPath = await resolveDependencyPackageJsonPath(\n dependency,\n dependencyResolver,\n );\n if (!dependencyPackageJsonPath) {\n continue;\n }\n pending.push({ dependency, packageJsonPath: dependencyPackageJsonPath });\n }\n\n // Peer dependencies are runtime requirements supplied by the consuming app\n // rather than nested package dependencies. Include installed peers in the\n // serverless closure, but do not fail packaging when an optional/uninstalled\n // peer is intentionally absent. This mirrors Node's runtime resolution model\n // without treating peer declarations as unconditional npm package imports.\n for (const dependency of runtimeDependencyNames(packageJson.peerDependencies)) {\n const dependencyPackageJsonPath = await resolveDependencyPackageJsonPath(\n dependency,\n dependencyResolver,\n );\n if (!dependencyPackageJsonPath) {\n continue;\n }\n pending.push({ dependency, packageJsonPath: dependencyPackageJsonPath });\n }\n }\n\n const requiredDependencyPath = path.join(\n dependencyTargetPath(runtimeRoot, rootDependency),\n \"package.json\",\n );\n if (!(await pathExists(requiredDependencyPath))) {\n throw new Error(\n `${consumerLabel} could not prepare \"${rootDependency}\" for ${runtimeRoot}.`,\n );\n }\n}\n\nexport async function ensureRuntimeDependencyTrees(\n appRoot: string,\n runtimeRoots: string[],\n rootDependency: string,\n consumerLabel: string,\n): Promise<void> {\n for (const runtimeRoot of runtimeRoots) {\n await copyRuntimeDependencyTree(\n appRoot,\n runtimeRoot,\n rootDependency,\n consumerLabel,\n );\n }\n}\n\nexport async function ensureServerRuntimeDependencyTrees(\n appRoot: string,\n serverRoot: string,\n runtimeRoots: string[],\n consumerLabel: string,\n): Promise<string[]> {\n const dependencies = await collectServerRuntimeDependencyNames(serverRoot);\n for (const dependency of dependencies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,4BAA4B,MAAM,iCACtC,YACA,mBACD;AACD,OAAI,CAAC,0BACH,OAAM,IAAI,MACR,GAAG,cAAc,eAAe,KAAK,WAAW,iCAAiC,WAAW,IAC7F;AAEH,WAAQ,KAAK;IAAE;IAAY,iBAAiB;IAA2B,CAAC;;AAG1E,OAAK,MAAM,cAAc,uBAAuB,YAAY,qBAAqB,EAAE;GACjF,MAAM,4BAA4B,MAAM,iCACtC,YACA,mBACD;AACD,OAAI,CAAC,0BACH;AAEF,WAAQ,KAAK;IAAE;IAAY,iBAAiB;IAA2B,CAAC;;AAQ1E,OAAK,MAAM,cAAc,uBAAuB,YAAY,iBAAiB,EAAE;GAC7E,MAAM,4BAA4B,MAAM,iCACtC,YACA,mBACD;AACD,OAAI,CAAC,0BACH;AAEF,WAAQ,KAAK;IAAE;IAAY,iBAAiB;IAA2B,CAAC;;;AAQ5E,KAAI,CAAE,MAAM,WAJmB,KAAK,KAClC,qBAAqB,aAAa,eAAe,EACjD,eACD,CAC6C,CAC5C,OAAM,IAAI,MACR,GAAG,cAAc,sBAAsB,eAAe,QAAQ,YAAY,GAC3E;;AAIL,eAAsB,6BACpB,SACA,cACA,gBACA,eACe;AACf,MAAK,MAAM,eAAe,aACxB,OAAM,0BACJ,SACA,aACA,gBACA,cACD;;AAIL,eAAsB,mCACpB,SACA,YACA,cACA,eACmB;CACnB,MAAM,eAAe,MAAM,oCAAoC,WAAW;AAC1E,MAAK,MAAM,cAAc,aACvB,OAAM,6BACJ,SACA,cACA,YACA,GAAG,cAAc,iBAClB;AAEH,QAAO"}
|
package/dist/deploy/static.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DeployTargetModule } from "./types.js";
|
|
2
|
+
|
|
2
3
|
//#region src/deploy/static.d.ts
|
|
3
|
-
|
|
4
|
+
declare const staticDeployModule: DeployTargetModule;
|
|
4
5
|
//#endregion
|
|
6
|
+
export { staticDeployModule };
|
|
5
7
|
//# sourceMappingURL=static.d.ts.map
|
package/dist/deploy/static.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertRuntimeClientAsset, ensureResuxClientAssets } from "./common.js";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
|
|
3
4
|
//#region src/deploy/static.ts
|
|
4
5
|
async function postBuild(context) {
|
|
5
6
|
await ensureResuxClientAssets(context.appRoot, [{
|
|
@@ -15,7 +16,7 @@ const staticDeployModule = {
|
|
|
15
16
|
inferPreset: () => "static",
|
|
16
17
|
postBuild
|
|
17
18
|
};
|
|
19
|
+
|
|
18
20
|
//#endregion
|
|
19
21
|
export { staticDeployModule };
|
|
20
|
-
|
|
21
22
|
//# sourceMappingURL=static.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.js","names":[],"sources":["../../src/deploy/static.ts"],"sourcesContent":["import path from \"node:path\";\nimport { assertRuntimeClientAsset, ensureResuxClientAssets } from \"./common.js\";\nimport type { DeployBuildContext, DeployTargetModule } from \"./types.js\";\n\nasync function postBuild(context: DeployBuildContext): Promise<void> {\n await ensureResuxClientAssets(context.appRoot, [\n {\n root: path.join(context.appRoot, \".output\"),\n target: path.join(context.appRoot, \".output\", \"public\", \"__resux\"),\n },\n ]);\n\n await assertRuntimeClientAsset(path.join(context.appRoot, \".output\", \"public\"));\n}\n\nexport const staticDeployModule: DeployTargetModule = {\n target: \"static\",\n presetAliases: [\"static\", \"_static\"],\n outputLabel: \".output/public\",\n inferPreset: () => \"static\",\n postBuild,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"static.js","names":[],"sources":["../../src/deploy/static.ts"],"sourcesContent":["import path from \"node:path\";\nimport { assertRuntimeClientAsset, ensureResuxClientAssets } from \"./common.js\";\nimport type { DeployBuildContext, DeployTargetModule } from \"./types.js\";\n\nasync function postBuild(context: DeployBuildContext): Promise<void> {\n await ensureResuxClientAssets(context.appRoot, [\n {\n root: path.join(context.appRoot, \".output\"),\n target: path.join(context.appRoot, \".output\", \"public\", \"__resux\"),\n },\n ]);\n\n await assertRuntimeClientAsset(path.join(context.appRoot, \".output\", \"public\"));\n}\n\nexport const staticDeployModule: DeployTargetModule = {\n target: \"static\",\n presetAliases: [\"static\", \"_static\"],\n outputLabel: \".output/public\",\n inferPreset: () => \"static\",\n postBuild,\n};\n"],"mappings":";;;;AAIA,eAAe,UAAU,SAA4C;AACnE,OAAM,wBAAwB,QAAQ,SAAS,CAC7C;EACE,MAAM,KAAK,KAAK,QAAQ,SAAS,UAAU;EAC3C,QAAQ,KAAK,KAAK,QAAQ,SAAS,WAAW,UAAU,UAAU;EACnE,CACF,CAAC;AAEF,OAAM,yBAAyB,KAAK,KAAK,QAAQ,SAAS,WAAW,SAAS,CAAC;;AAGjF,MAAa,qBAAyC;CACpD,QAAQ;CACR,eAAe,CAAC,UAAU,UAAU;CACpC,aAAa;CACb,mBAAmB;CACnB;CACD"}
|
package/dist/deploy/types.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
//#region src/deploy/types.d.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type ResuxDeployTarget = "auto" | "node" | "vercel" | "netlify" | "cloudflare" | "static";
|
|
3
|
+
type ResuxResolvedDeployTarget = Exclude<ResuxDeployTarget, "auto">;
|
|
4
|
+
interface ResuxDeployConfig {
|
|
5
5
|
target?: ResuxDeployTarget;
|
|
6
6
|
nitroPreset?: string;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
interface DeployBuildContext {
|
|
9
9
|
appRoot: string;
|
|
10
10
|
outDir: string;
|
|
11
11
|
env: NodeJS.ProcessEnv;
|
|
12
12
|
nitroPreset: string | null;
|
|
13
13
|
target: ResuxResolvedDeployTarget;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
interface DeployDetectionContext {
|
|
16
16
|
appRoot: string;
|
|
17
17
|
outDir: string;
|
|
18
18
|
env: NodeJS.ProcessEnv;
|
|
19
19
|
explicitNitroPreset: string | null;
|
|
20
20
|
deployConfig: ResuxDeployConfig;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
interface DeployTargetModule {
|
|
23
23
|
target: ResuxResolvedDeployTarget;
|
|
24
24
|
presetAliases: string[];
|
|
25
25
|
outputLabel: string;
|
|
@@ -27,11 +27,12 @@ export interface DeployTargetModule {
|
|
|
27
27
|
inferPreset?(context: DeployDetectionContext): string | null;
|
|
28
28
|
postBuild?(context: DeployBuildContext): Promise<void>;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
interface DeploymentResolution {
|
|
31
31
|
target: ResuxResolvedDeployTarget;
|
|
32
32
|
nitroPreset: string | null;
|
|
33
33
|
outputLabel: string;
|
|
34
34
|
reason: string;
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
|
+
export { DeployBuildContext, DeployDetectionContext, DeployTargetModule, DeploymentResolution, ResuxDeployConfig, ResuxDeployTarget, ResuxResolvedDeployTarget };
|
|
37
38
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/deploy/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { };
|
package/dist/deploy/vercel.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DeployTargetModule } from "./types.js";
|
|
2
|
+
|
|
2
3
|
//#region src/deploy/vercel.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
declare function resolveVercelNodeRuntime(nodeVersion?: string): string;
|
|
5
|
+
declare const vercelDeployModule: DeployTargetModule;
|
|
5
6
|
//#endregion
|
|
7
|
+
export { resolveVercelNodeRuntime, vercelDeployModule };
|
|
6
8
|
//# sourceMappingURL=vercel.d.ts.map
|
package/dist/deploy/vercel.js
CHANGED
|
@@ -5,6 +5,7 @@ import { ensureRuntimeDependencyTrees, ensureServerRuntimeDependencyTrees } from
|
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { cp, lstat, mkdir, readdir, realpath, rm, stat, writeFile } from "node:fs/promises";
|
|
7
7
|
import path from "node:path";
|
|
8
|
+
|
|
8
9
|
//#region src/deploy/vercel.ts
|
|
9
10
|
const SUPPORTED_NODE_VERSIONS = [
|
|
10
11
|
18,
|
|
@@ -163,7 +164,7 @@ const vercelDeployModule = {
|
|
|
163
164
|
inferPreset: () => "vercel",
|
|
164
165
|
postBuild
|
|
165
166
|
};
|
|
167
|
+
|
|
166
168
|
//#endregion
|
|
167
169
|
export { resolveVercelNodeRuntime, vercelDeployModule };
|
|
168
|
-
|
|
169
170
|
//# sourceMappingURL=vercel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel.js","names":[],"sources":["../../src/deploy/vercel.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { cp, lstat, mkdir, readdir, realpath, rm, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n assertRuntimeClientAsset,\n ensureResuxClientAssets,\n ensureResuxServerPayload,\n pathExists,\n readJsonRecord,\n writeJson,\n} from \"./common.js\";\nimport { ensureResuxFrameworkRuntime } from \"./framework-runtime.js\";\nimport { ensureResuxProductionReport } from \"./production-report.js\";\nimport {\n ensureRuntimeDependencyTrees,\n ensureServerRuntimeDependencyTrees,\n} from \"./runtime-dependencies.js\";\nimport type {\n DeployBuildContext,\n DeployDetectionContext,\n DeployTargetModule,\n} from \"./types.js\";\n\nconst SUPPORTED_NODE_VERSIONS = [18, 20, 22] as const;\n\ntype BuildOutputRoute = Record<string, unknown>;\n\ninterface BuildOutputConfig extends Record<string, unknown> {\n version?: unknown;\n routes?: unknown;\n}\n\nfunction parseMajorNodeVersion(version: string): number {\n const major = Number.parseInt(version.split(\".\")[0] ?? \"\", 10);\n return Number.isNaN(major) ? 22 : major;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function resolveVercelNodeRuntime(nodeVersion = process.versions.node): string {\n const systemNodeVersion = parseMajorNodeVersion(nodeVersion);\n const runtimeVersion =\n SUPPORTED_NODE_VERSIONS.find((version) => version >= systemNodeVersion)\n ?? SUPPORTED_NODE_VERSIONS[SUPPORTED_NODE_VERSIONS.length - 1];\n return `nodejs${runtimeVersion}.x`;\n}\n\nfunction resolveFallbackFunctionName(functionNames: string[]): string | null {\n if (functionNames.includes(\"__fallback.func\")) {\n return \"__fallback\";\n }\n if (functionNames.includes(\"[...].func\")) {\n return \"[...]\";\n }\n const fallback = functionNames.find((name) => name.endsWith(\".func\"));\n return fallback ? fallback.slice(0, -5) : null;\n}\n\nfunction isCatchAllRouteSrc(src: unknown): boolean {\n if (typeof src !== \"string\") {\n return false;\n }\n\n return src === \"/(.*)\" || src === \"/(?:.*)\" || /^\\/\\((?:\\?:)?\\.\\*\\)$/.test(src);\n}\n\nfunction routeDestIncludesFunctionName(route: Record<string, unknown>, functionName: string): boolean {\n if (typeof route.dest !== \"string\" || !functionName) {\n return false;\n }\n\n const normalizedDest = route.dest.startsWith(\"/\") ? route.dest.slice(1) : route.dest;\n return normalizedDest === functionName;\n}\n\nfunction normalizeBuildOutputConfig(value: unknown): BuildOutputConfig {\n if (!isRecord(value)) {\n return {};\n }\n return value;\n}\n\nfunction isHeaderOnlyRoute(route: BuildOutputRoute): boolean {\n if (!isRecord(route)) {\n return false;\n }\n\n return (\n typeof route.src === \"string\"\n && isRecord(route.headers)\n && route.continue !== true\n && route.dest === undefined\n && route.handle === undefined\n && route.status === undefined\n && route.check === undefined\n && route.middlewarePath === undefined\n );\n}\n\nfunction normalizeRoute(route: BuildOutputRoute): BuildOutputRoute {\n if (isHeaderOnlyRoute(route)) {\n return { ...route, continue: true };\n }\n return route;\n}\n\nfunction isRunningInsideVercelContainer(appRoot: string): boolean {\n const normalizedRoot = appRoot.replace(/\\\\/g, \"/\");\n if (normalizedRoot.startsWith(\"/vercel/path\")) {\n return true;\n }\n\n return (\n existsSync(\"/vercel\")\n || existsSync(\"/vercel/path\")\n || existsSync(\"/vercel/path0\")\n || existsSync(\"/vercel/output\")\n );\n}\n\nasync function detect(context: DeployDetectionContext): Promise<boolean> {\n if (isRunningInsideVercelContainer(context.appRoot)) {\n return true;\n }\n\n if (context.env.NOW_BUILDER || context.env.VERCEL || context.env.VERCEL_ENV) {\n return true;\n }\n return false;\n}\n\nasync function materializeLinkedFunctions(functionsDir: string): Promise<void> {\n const entries = await readdir(functionsDir, { withFileTypes: true }).catch(() => []);\n\n for (const entry of entries) {\n if (!entry.name.endsWith(\".func\")) {\n continue;\n }\n\n const functionPath = path.join(functionsDir, entry.name);\n const stats = await lstat(functionPath).catch(() => null);\n if (!stats?.isSymbolicLink()) {\n continue;\n }\n\n const resolvedTarget = await realpath(functionPath).catch(() => null);\n if (!resolvedTarget) {\n continue;\n }\n\n await rm(functionPath, { recursive: true, force: true });\n await cp(resolvedTarget, functionPath, {\n recursive: true,\n force: true,\n });\n }\n}\n\nasync function listFunctionDirectories(functionsDir: string): Promise<string[]> {\n const entries = await readdir(functionsDir, { withFileTypes: true }).catch(() => []);\n const functionNames: string[] = [];\n\n for (const entry of entries) {\n if (!entry.name.endsWith(\".func\")) {\n continue;\n }\n\n const functionPath = path.join(functionsDir, entry.name);\n if (entry.isDirectory()) {\n functionNames.push(entry.name);\n continue;\n }\n\n if (!entry.isSymbolicLink()) {\n continue;\n }\n\n const linkedStats = await stat(functionPath).catch(() => null);\n if (linkedStats?.isDirectory()) {\n functionNames.push(entry.name);\n }\n }\n\n return functionNames;\n}\n\nasync function postBuild(context: DeployBuildContext): Promise<void> {\n await ensureResuxClientAssets(context.appRoot, [\n {\n root: path.join(context.appRoot, \".output\"),\n target: path.join(context.appRoot, \".output\", \"public\", \"__resux\"),\n },\n {\n root: path.join(context.appRoot, \".vercel\", \"output\"),\n target: path.join(context.appRoot, \".vercel\", \"output\", \"static\", \"__resux\"),\n },\n ]);\n await assertRuntimeClientAsset(path.join(context.appRoot, \".vercel\", \"output\", \"static\"));\n\n const outputDir = path.join(context.appRoot, \".vercel\", \"output\");\n const functionsDir = path.join(outputDir, \"functions\");\n await materializeLinkedFunctions(functionsDir);\n\n const functionNames = await listFunctionDirectories(functionsDir);\n if (!functionNames.length) {\n throw new Error(\n \"Resux vercel deployment output is missing function directories under .vercel/output/functions.\",\n );\n }\n\n const functionRoots = functionNames.map((functionName) =>\n path.join(functionsDir, functionName)\n );\n await ensureResuxServerPayload(\n context.appRoot,\n functionRoots.map((root) => path.join(root, \".resux\", \"server\")),\n );\n await ensureResuxClientAssets(\n context.appRoot,\n functionRoots.map((root) => ({\n root,\n target: path.join(root, \".resux\", \"client\"),\n })),\n );\n await ensureResuxProductionReport(context.appRoot, functionRoots);\n await ensureResuxFrameworkRuntime(context.appRoot, functionRoots);\n await ensureServerRuntimeDependencyTrees(\n context.appRoot,\n path.join(context.appRoot, \".resux\", \"server\"),\n functionRoots,\n \"Resux Vercel\",\n );\n await ensureRuntimeDependencyTrees(\n context.appRoot,\n functionRoots,\n \"sharp\",\n \"Resux Vercel image optimizer\",\n );\n for (const functionRoot of functionRoots) {\n const manifestPath = path.join(functionRoot, \".resux\", \"server\", \"manifest.mjs\");\n if (!(await pathExists(manifestPath))) {\n const chunkManifestPath = path.join(functionRoot, \"chunks\", \"raw\", \"manifest.mjs\");\n const hasChunkManifest = await pathExists(chunkManifestPath);\n throw new Error(\n hasChunkManifest\n ? `Resux vercel deployment output is missing ${manifestPath}. Found ${chunkManifestPath} but not the copied Resux server payload. Stop concurrent dev/watch processes, clean .vercel/output, and rerun build.`\n : `Resux vercel deployment output is missing ${manifestPath}.`,\n );\n }\n }\n\n const defaultFunctionConfig = {\n runtime: resolveVercelNodeRuntime(),\n handler: \"index.mjs\",\n launcherType: \"Nodejs\",\n shouldAddHelpers: false,\n supportsResponseStreaming: true,\n };\n\n for (const functionRoot of functionRoots) {\n const functionConfigPath = path.join(functionRoot, \".vc-config.json\");\n if (!(await pathExists(functionConfigPath))) {\n await writeFile(\n functionConfigPath,\n JSON.stringify(defaultFunctionConfig, null, 2),\n \"utf8\",\n );\n }\n }\n\n const outputConfigPath = path.join(outputDir, \"config.json\");\n const parsedOutputConfig = await readJsonRecord(outputConfigPath);\n const safeOutputConfig = normalizeBuildOutputConfig(parsedOutputConfig ?? {});\n const routes = Array.isArray(safeOutputConfig.routes)\n ? (safeOutputConfig.routes as BuildOutputRoute[]).map(normalizeRoute)\n : [];\n const hasFilesystemRoute = routes.some((route) => route?.handle === \"filesystem\");\n if (!hasFilesystemRoute) {\n routes.push({ handle: \"filesystem\" });\n }\n\n const fallbackFunctionName = resolveFallbackFunctionName(functionNames);\n const hasNativeCatchAllFunction = functionNames.includes(\"[...].func\");\n const hasCatchAllRoute =\n hasNativeCatchAllFunction || routes.some((route) => isCatchAllRouteSrc(route?.src));\n const hasFallbackDest = fallbackFunctionName\n ? routes.some((route) => routeDestIncludesFunctionName(route ?? {}, fallbackFunctionName))\n : false;\n if (fallbackFunctionName && !hasCatchAllRoute && !hasFallbackDest) {\n routes.push({ src: \"/(.*)\", dest: `/${fallbackFunctionName}` });\n }\n\n const outputConfig: BuildOutputConfig = {\n ...safeOutputConfig,\n version: 3,\n routes,\n };\n await mkdir(path.dirname(outputConfigPath), { recursive: true });\n await writeJson(outputConfigPath, outputConfig);\n}\n\nexport const vercelDeployModule: DeployTargetModule = {\n target: \"vercel\",\n presetAliases: [\"vercel\", \"vercel-edge\"],\n outputLabel: \".vercel/output\",\n detect,\n inferPreset: () => \"vercel\",\n postBuild,\n};\n"],"mappings":";;;;;;;;AAuBA,MAAM,0BAA0B;CAAC;CAAI;CAAI;AAAE;AAS3C,SAAS,sBAAsB,SAAyB;CACtD,MAAM,QAAQ,OAAO,SAAS,QAAQ,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,EAAE;CAC7D,OAAO,OAAO,MAAM,KAAK,IAAI,KAAK;AACpC;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAgB,yBAAyB,cAA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CAGhE,MAAM,eAAkC;EACtC,GAAG;EACH,SAAS;EACT;CACF;CACA,MAAM,MAAM,KAAK,QAAQ,gBAAgB,GAAG,EAAE,WAAW,KAAK,CAAC;CAC/D,MAAM,UAAU,kBAAkB,YAAY;AAChD;AAEA,MAAa,qBAAyC;CACpD,QAAQ;CACR,eAAe,CAAC,UAAU,aAAa;CACvC,aAAa;CACb;CACA,mBAAmB;CACnB;AACF"}
|
|
1
|
+
{"version":3,"file":"vercel.js","names":[],"sources":["../../src/deploy/vercel.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { cp, lstat, mkdir, readdir, realpath, rm, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n assertRuntimeClientAsset,\n ensureResuxClientAssets,\n ensureResuxServerPayload,\n pathExists,\n readJsonRecord,\n writeJson,\n} from \"./common.js\";\nimport { ensureResuxFrameworkRuntime } from \"./framework-runtime.js\";\nimport { ensureResuxProductionReport } from \"./production-report.js\";\nimport {\n ensureRuntimeDependencyTrees,\n ensureServerRuntimeDependencyTrees,\n} from \"./runtime-dependencies.js\";\nimport type {\n DeployBuildContext,\n DeployDetectionContext,\n DeployTargetModule,\n} from \"./types.js\";\n\nconst SUPPORTED_NODE_VERSIONS = [18, 20, 22] as const;\n\ntype BuildOutputRoute = Record<string, unknown>;\n\ninterface BuildOutputConfig extends Record<string, unknown> {\n version?: unknown;\n routes?: unknown;\n}\n\nfunction parseMajorNodeVersion(version: string): number {\n const major = Number.parseInt(version.split(\".\")[0] ?? \"\", 10);\n return Number.isNaN(major) ? 22 : major;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function resolveVercelNodeRuntime(nodeVersion = process.versions.node): string {\n const systemNodeVersion = parseMajorNodeVersion(nodeVersion);\n const runtimeVersion =\n SUPPORTED_NODE_VERSIONS.find((version) => version >= systemNodeVersion)\n ?? SUPPORTED_NODE_VERSIONS[SUPPORTED_NODE_VERSIONS.length - 1];\n return `nodejs${runtimeVersion}.x`;\n}\n\nfunction resolveFallbackFunctionName(functionNames: string[]): string | null {\n if (functionNames.includes(\"__fallback.func\")) {\n return \"__fallback\";\n }\n if (functionNames.includes(\"[...].func\")) {\n return \"[...]\";\n }\n const fallback = functionNames.find((name) => name.endsWith(\".func\"));\n return fallback ? fallback.slice(0, -5) : null;\n}\n\nfunction isCatchAllRouteSrc(src: unknown): boolean {\n if (typeof src !== \"string\") {\n return false;\n }\n\n return src === \"/(.*)\" || src === \"/(?:.*)\" || /^\\/\\((?:\\?:)?\\.\\*\\)$/.test(src);\n}\n\nfunction routeDestIncludesFunctionName(route: Record<string, unknown>, functionName: string): boolean {\n if (typeof route.dest !== \"string\" || !functionName) {\n return false;\n }\n\n const normalizedDest = route.dest.startsWith(\"/\") ? route.dest.slice(1) : route.dest;\n return normalizedDest === functionName;\n}\n\nfunction normalizeBuildOutputConfig(value: unknown): BuildOutputConfig {\n if (!isRecord(value)) {\n return {};\n }\n return value;\n}\n\nfunction isHeaderOnlyRoute(route: BuildOutputRoute): boolean {\n if (!isRecord(route)) {\n return false;\n }\n\n return (\n typeof route.src === \"string\"\n && isRecord(route.headers)\n && route.continue !== true\n && route.dest === undefined\n && route.handle === undefined\n && route.status === undefined\n && route.check === undefined\n && route.middlewarePath === undefined\n );\n}\n\nfunction normalizeRoute(route: BuildOutputRoute): BuildOutputRoute {\n if (isHeaderOnlyRoute(route)) {\n return { ...route, continue: true };\n }\n return route;\n}\n\nfunction isRunningInsideVercelContainer(appRoot: string): boolean {\n const normalizedRoot = appRoot.replace(/\\\\/g, \"/\");\n if (normalizedRoot.startsWith(\"/vercel/path\")) {\n return true;\n }\n\n return (\n existsSync(\"/vercel\")\n || existsSync(\"/vercel/path\")\n || existsSync(\"/vercel/path0\")\n || existsSync(\"/vercel/output\")\n );\n}\n\nasync function detect(context: DeployDetectionContext): Promise<boolean> {\n if (isRunningInsideVercelContainer(context.appRoot)) {\n return true;\n }\n\n if (context.env.NOW_BUILDER || context.env.VERCEL || context.env.VERCEL_ENV) {\n return true;\n }\n return false;\n}\n\nasync function materializeLinkedFunctions(functionsDir: string): Promise<void> {\n const entries = await readdir(functionsDir, { withFileTypes: true }).catch(() => []);\n\n for (const entry of entries) {\n if (!entry.name.endsWith(\".func\")) {\n continue;\n }\n\n const functionPath = path.join(functionsDir, entry.name);\n const stats = await lstat(functionPath).catch(() => null);\n if (!stats?.isSymbolicLink()) {\n continue;\n }\n\n const resolvedTarget = await realpath(functionPath).catch(() => null);\n if (!resolvedTarget) {\n continue;\n }\n\n await rm(functionPath, { recursive: true, force: true });\n await cp(resolvedTarget, functionPath, {\n recursive: true,\n force: true,\n });\n }\n}\n\nasync function listFunctionDirectories(functionsDir: string): Promise<string[]> {\n const entries = await readdir(functionsDir, { withFileTypes: true }).catch(() => []);\n const functionNames: string[] = [];\n\n for (const entry of entries) {\n if (!entry.name.endsWith(\".func\")) {\n continue;\n }\n\n const functionPath = path.join(functionsDir, entry.name);\n if (entry.isDirectory()) {\n functionNames.push(entry.name);\n continue;\n }\n\n if (!entry.isSymbolicLink()) {\n continue;\n }\n\n const linkedStats = await stat(functionPath).catch(() => null);\n if (linkedStats?.isDirectory()) {\n functionNames.push(entry.name);\n }\n }\n\n return functionNames;\n}\n\nasync function postBuild(context: DeployBuildContext): Promise<void> {\n await ensureResuxClientAssets(context.appRoot, [\n {\n root: path.join(context.appRoot, \".output\"),\n target: path.join(context.appRoot, \".output\", \"public\", \"__resux\"),\n },\n {\n root: path.join(context.appRoot, \".vercel\", \"output\"),\n target: path.join(context.appRoot, \".vercel\", \"output\", \"static\", \"__resux\"),\n },\n ]);\n await assertRuntimeClientAsset(path.join(context.appRoot, \".vercel\", \"output\", \"static\"));\n\n const outputDir = path.join(context.appRoot, \".vercel\", \"output\");\n const functionsDir = path.join(outputDir, \"functions\");\n await materializeLinkedFunctions(functionsDir);\n\n const functionNames = await listFunctionDirectories(functionsDir);\n if (!functionNames.length) {\n throw new Error(\n \"Resux vercel deployment output is missing function directories under .vercel/output/functions.\",\n );\n }\n\n const functionRoots = functionNames.map((functionName) =>\n path.join(functionsDir, functionName)\n );\n await ensureResuxServerPayload(\n context.appRoot,\n functionRoots.map((root) => path.join(root, \".resux\", \"server\")),\n );\n await ensureResuxClientAssets(\n context.appRoot,\n functionRoots.map((root) => ({\n root,\n target: path.join(root, \".resux\", \"client\"),\n })),\n );\n await ensureResuxProductionReport(context.appRoot, functionRoots);\n await ensureResuxFrameworkRuntime(context.appRoot, functionRoots);\n await ensureServerRuntimeDependencyTrees(\n context.appRoot,\n path.join(context.appRoot, \".resux\", \"server\"),\n functionRoots,\n \"Resux Vercel\",\n );\n await ensureRuntimeDependencyTrees(\n context.appRoot,\n functionRoots,\n \"sharp\",\n \"Resux Vercel image optimizer\",\n );\n for (const functionRoot of functionRoots) {\n const manifestPath = path.join(functionRoot, \".resux\", \"server\", \"manifest.mjs\");\n if (!(await pathExists(manifestPath))) {\n const chunkManifestPath = path.join(functionRoot, \"chunks\", \"raw\", \"manifest.mjs\");\n const hasChunkManifest = await pathExists(chunkManifestPath);\n throw new Error(\n hasChunkManifest\n ? `Resux vercel deployment output is missing ${manifestPath}. Found ${chunkManifestPath} but not the copied Resux server payload. Stop concurrent dev/watch processes, clean .vercel/output, and rerun build.`\n : `Resux vercel deployment output is missing ${manifestPath}.`,\n );\n }\n }\n\n const defaultFunctionConfig = {\n runtime: resolveVercelNodeRuntime(),\n handler: \"index.mjs\",\n launcherType: \"Nodejs\",\n shouldAddHelpers: false,\n supportsResponseStreaming: true,\n };\n\n for (const functionRoot of functionRoots) {\n const functionConfigPath = path.join(functionRoot, \".vc-config.json\");\n if (!(await pathExists(functionConfigPath))) {\n await writeFile(\n functionConfigPath,\n JSON.stringify(defaultFunctionConfig, null, 2),\n \"utf8\",\n );\n }\n }\n\n const outputConfigPath = path.join(outputDir, \"config.json\");\n const parsedOutputConfig = await readJsonRecord(outputConfigPath);\n const safeOutputConfig = normalizeBuildOutputConfig(parsedOutputConfig ?? {});\n const routes = Array.isArray(safeOutputConfig.routes)\n ? (safeOutputConfig.routes as BuildOutputRoute[]).map(normalizeRoute)\n : [];\n const hasFilesystemRoute = routes.some((route) => route?.handle === \"filesystem\");\n if (!hasFilesystemRoute) {\n routes.push({ handle: \"filesystem\" });\n }\n\n const fallbackFunctionName = resolveFallbackFunctionName(functionNames);\n const hasNativeCatchAllFunction = functionNames.includes(\"[...].func\");\n const hasCatchAllRoute =\n hasNativeCatchAllFunction || routes.some((route) => isCatchAllRouteSrc(route?.src));\n const hasFallbackDest = fallbackFunctionName\n ? routes.some((route) => routeDestIncludesFunctionName(route ?? {}, fallbackFunctionName))\n : false;\n if (fallbackFunctionName && !hasCatchAllRoute && !hasFallbackDest) {\n routes.push({ src: \"/(.*)\", dest: `/${fallbackFunctionName}` });\n }\n\n const outputConfig: BuildOutputConfig = {\n ...safeOutputConfig,\n version: 3,\n routes,\n };\n await mkdir(path.dirname(outputConfigPath), { recursive: true });\n await writeJson(outputConfigPath, outputConfig);\n}\n\nexport const vercelDeployModule: DeployTargetModule = {\n target: \"vercel\",\n presetAliases: [\"vercel\", \"vercel-edge\"],\n outputLabel: \".vercel/output\",\n detect,\n inferPreset: () => \"vercel\",\n postBuild,\n};\n"],"mappings":";;;;;;;;;AAuBA,MAAM,0BAA0B;CAAC;CAAI;CAAI;CAAG;AAS5C,SAAS,sBAAsB,SAAyB;CACtD,MAAM,QAAQ,OAAO,SAAS,QAAQ,MAAM,IAAI,CAAC,MAAM,IAAI,GAAG;AAC9D,QAAO,OAAO,MAAM,MAAM,GAAG,KAAK;;AAGpC,SAAS,SAAS,OAAkD;AAClE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;AAG7E,SAAgB,yBAAyB,cAAc,QAAQ,SAAS,MAAc;CACpF,MAAM,oBAAoB,sBAAsB,YAAY;AAI5D,QAAO,SAFL,wBAAwB,MAAM,YAAY,WAAW,kBAAk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;CACD"}
|
package/dist/fonts/index.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { ResuxModuleDefinition } from "../kit/index.js";
|
|
2
|
+
|
|
2
3
|
//#region src/fonts/index.d.ts
|
|
3
|
-
|
|
4
|
+
interface ResuxFontFamilyInput {
|
|
4
5
|
name: string;
|
|
5
6
|
weights?: Array<number | string>;
|
|
6
7
|
display?: "auto" | "block" | "swap" | "fallback" | "optional";
|
|
7
8
|
strategy?: "eager" | "preload" | "lazy";
|
|
8
9
|
deferUntilPageLoad?: boolean;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
interface ResuxFontsModuleOptions {
|
|
11
12
|
google?: ResuxFontFamilyInput[];
|
|
12
13
|
preconnect?: boolean;
|
|
13
14
|
strategy?: "eager" | "preload" | "lazy";
|
|
14
15
|
deferUntilPageLoad?: boolean;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
declare function googleFont(input: ResuxFontFamilyInput): ResuxFontFamilyInput;
|
|
17
18
|
declare const _default: ResuxModuleDefinition<ResuxFontsModuleOptions>;
|
|
18
19
|
//#endregion
|
|
19
|
-
export { _default as default };
|
|
20
|
+
export { ResuxFontFamilyInput, ResuxFontsModuleOptions, _default as default, googleFont };
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/fonts/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineResuxModule } from "../kit/index.js";
|
|
2
|
+
|
|
2
3
|
//#region src/fonts/index.ts
|
|
3
|
-
const VALID_DISPLAYS =
|
|
4
|
+
const VALID_DISPLAYS = new Set([
|
|
4
5
|
"auto",
|
|
5
6
|
"block",
|
|
6
7
|
"swap",
|
|
@@ -128,7 +129,7 @@ var fonts_default = defineResuxModule({
|
|
|
128
129
|
} } });
|
|
129
130
|
}
|
|
130
131
|
});
|
|
132
|
+
|
|
131
133
|
//#endregion
|
|
132
134
|
export { fonts_default as default, googleFont };
|
|
133
|
-
|
|
134
135
|
//# sourceMappingURL=index.js.map
|
package/dist/fonts/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/fonts/index.ts"],"sourcesContent":["import { defineResuxModule } from \"../kit/index.js\";\n\nexport interface ResuxFontFamilyInput {\n name: string;\n weights?: Array<number | string>;\n display?: \"auto\" | \"block\" | \"swap\" | \"fallback\" | \"optional\";\n strategy?: \"eager\" | \"preload\" | \"lazy\";\n deferUntilPageLoad?: boolean;\n}\n\nexport interface ResuxFontsModuleOptions {\n google?: ResuxFontFamilyInput[];\n preconnect?: boolean;\n strategy?: \"eager\" | \"preload\" | \"lazy\";\n deferUntilPageLoad?: boolean;\n}\n\nconst VALID_DISPLAYS = new Set([\"auto\", \"block\", \"swap\", \"fallback\", \"optional\"]);\n\nfunction normalizeFamily(input: ResuxFontFamilyInput): string | null {\n const name = String(input.name || \"\").trim().replace(/[\\u0000-\\u001f\\u007f]/g, \"\");\n if (!name) {\n return null;\n }\n const encodedName = encodeURIComponent(name)\n .replaceAll(\"%20\", \"+\")\n .replaceAll(\"'\", \"%27\");\n const weights = Array.isArray(input.weights)\n ? input.weights\n .map(normalizeWeight)\n .filter((weight): weight is string => Boolean(weight))\n : [];\n if (!weights.length) {\n return encodedName;\n }\n const normalizedWeights = [...new Set(weights)].sort(compareNormalizedWeights);\n return `${encodedName}:wght@${normalizedWeights.join(\";\")}`;\n}\n\nfunction normalizeWeight(value: number | string): string | null {\n const normalized = String(value).trim();\n const match = /^(\\d{1,4})(?:\\.\\.(\\d{1,4}))?$/.exec(normalized);\n if (!match) {\n return null;\n }\n const start = Number(match[1]);\n const end = match[2] ? Number(match[2]) : undefined;\n if (start < 1 || start > 1000 || (end !== undefined && (end < start || end > 1000))) {\n return null;\n }\n return end === undefined ? String(start) : `${start}..${end}`;\n}\n\nfunction compareNormalizedWeights(left: string, right: string): number {\n const leftRange = readWeightRange(left);\n const rightRange = readWeightRange(right);\n return leftRange.start - rightRange.start\n || leftRange.end - rightRange.end\n || compareCodeUnits(left, right);\n}\n\nfunction readWeightRange(value: string): { start: number; end: number } {\n const separator = value.indexOf(\"..\");\n const start = Number(separator < 0 ? value : value.slice(0, separator));\n const end = separator < 0 ? start : Number(value.slice(separator + 2));\n return { start, end };\n}\n\nfunction compareCodeUnits(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\nfunction normalizeDisplay(value: unknown): string {\n return typeof value === \"string\" && VALID_DISPLAYS.has(value) ? value : \"swap\";\n}\n\nfunction buildGoogleFontsHref(families: string[], display: unknown): string {\n const familyQuery = families.map((family) => `family=${family}`).join(\"&\");\n return `https://fonts.googleapis.com/css2?${familyQuery}&display=${normalizeDisplay(display)}`;\n}\n\nexport function googleFont(input: ResuxFontFamilyInput): ResuxFontFamilyInput {\n return input;\n}\n\nfunction isLazyFamily(input: ResuxFontFamilyInput, options: ResuxFontsModuleOptions): boolean {\n if (typeof input.deferUntilPageLoad === \"boolean\") {\n if (input.deferUntilPageLoad) {\n return true;\n }\n return input.strategy === \"lazy\";\n }\n if (input.strategy) {\n return input.strategy === \"lazy\";\n }\n return options.strategy === \"lazy\" || options.deferUntilPageLoad === true;\n}\n\nexport default defineResuxModule<ResuxFontsModuleOptions>({\n defaults: {\n google: [],\n preconnect: true,\n strategy: \"eager\",\n deferUntilPageLoad: false,\n },\n setup(options, resux) {\n const googleFamilies = Array.isArray(options.google) ? options.google : [];\n if (!googleFamilies.length) {\n return;\n }\n\n const eagerGroup: ResuxFontFamilyInput[] = [];\n const lazyGroup: ResuxFontFamilyInput[] = [];\n\n for (const family of googleFamilies) {\n if (isLazyFamily(family, options)) {\n lazyGroup.push(family);\n } else {\n eagerGroup.push(family);\n }\n }\n\n const headLinks: Array<{ rel: string; href: string; as?: string; crossorigin?: string }> = [];\n const headScripts: Array<{ innerHTML: string }> = [];\n\n const hasAnyFonts = eagerGroup.length > 0 || lazyGroup.length > 0;\n if (options.preconnect !== false && hasAnyFonts) {\n headLinks.push(\n { rel: \"preconnect\", href: \"https://fonts.googleapis.com\" },\n { rel: \"preconnect\", href: \"https://fonts.gstatic.com\", crossorigin: \"\" },\n );\n }\n\n if (eagerGroup.length > 0) {\n const eagerNormalized = eagerGroup\n .map((family) => normalizeFamily(family))\n .filter((family): family is string => Boolean(family));\n if (eagerNormalized.length > 0) {\n const href = buildGoogleFontsHref(\n eagerNormalized,\n eagerGroup.find((family) => family.display)?.display,\n );\n const isPreload = eagerGroup.some((family) => family.strategy === \"preload\")\n || options.strategy === \"preload\";\n if (isPreload) {\n headLinks.push({ rel: \"preload\", as: \"style\", href });\n }\n headLinks.push({ rel: \"stylesheet\", href });\n }\n }\n\n if (lazyGroup.length > 0) {\n const lazyNormalized = lazyGroup\n .map((family) => normalizeFamily(family))\n .filter((family): family is string => Boolean(family));\n if (lazyNormalized.length > 0) {\n const href = buildGoogleFontsHref(\n lazyNormalized,\n lazyGroup.find((family) => family.display)?.display,\n );\n headLinks.push({ rel: \"preload\", as: \"style\", href });\n headScripts.push({\n innerHTML: `(function(){function loadFonts(){var l=document.createElement('link');l.rel='stylesheet';l.href=${JSON.stringify(href)};document.head.appendChild(l);}if(document.readyState==='complete'){loadFonts();}else{window.addEventListener('load',loadFonts);}})();`,\n });\n }\n }\n\n if (headLinks.length > 0 || headScripts.length > 0) {\n resux.addHead({\n link: headLinks,\n ...(headScripts.length > 0 ? { script: headScripts } : {}),\n });\n }\n\n resux.extendRuntimeConfig({\n public: {\n fonts: {\n provider: \"google\",\n families: googleFamilies.map((family) => family.name),\n familyConfigs: googleFamilies.map((family) => ({\n name: family.name,\n strategy: family.strategy || options.strategy || \"eager\",\n deferUntilPageLoad: isLazyFamily(family, options),\n })),\n strategy: options.strategy || \"eager\",\n deferUntilPageLoad: options.deferUntilPageLoad ?? false,\n },\n },\n });\n },\n});\n"],"mappings":";;AAiBA,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAQ;CAAY;AAAU,CAAC;AAEhF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K,YAAY;IAC7C,MAAM,OAAO;IACb,UAAU,OAAO,YAAY,QAAQ,YAAY;IACjD,oBAAoB,aAAa,QAAQ,OAAO;GAClD,EAAE;GACF,UAAU,QAAQ,YAAY;GAC9B,oBAAoB,QAAQ,sBAAsB;EACpD,EACF,EACF,CAAC;CACH;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/fonts/index.ts"],"sourcesContent":["import { defineResuxModule } from \"../kit/index.js\";\n\nexport interface ResuxFontFamilyInput {\n name: string;\n weights?: Array<number | string>;\n display?: \"auto\" | \"block\" | \"swap\" | \"fallback\" | \"optional\";\n strategy?: \"eager\" | \"preload\" | \"lazy\";\n deferUntilPageLoad?: boolean;\n}\n\nexport interface ResuxFontsModuleOptions {\n google?: ResuxFontFamilyInput[];\n preconnect?: boolean;\n strategy?: \"eager\" | \"preload\" | \"lazy\";\n deferUntilPageLoad?: boolean;\n}\n\nconst VALID_DISPLAYS = new Set([\"auto\", \"block\", \"swap\", \"fallback\", \"optional\"]);\n\nfunction normalizeFamily(input: ResuxFontFamilyInput): string | null {\n const name = String(input.name || \"\").trim().replace(/[\\u0000-\\u001f\\u007f]/g, \"\");\n if (!name) {\n return null;\n }\n const encodedName = encodeURIComponent(name)\n .replaceAll(\"%20\", \"+\")\n .replaceAll(\"'\", \"%27\");\n const weights = Array.isArray(input.weights)\n ? input.weights\n .map(normalizeWeight)\n .filter((weight): weight is string => Boolean(weight))\n : [];\n if (!weights.length) {\n return encodedName;\n }\n const normalizedWeights = [...new Set(weights)].sort(compareNormalizedWeights);\n return `${encodedName}:wght@${normalizedWeights.join(\";\")}`;\n}\n\nfunction normalizeWeight(value: number | string): string | null {\n const normalized = String(value).trim();\n const match = /^(\\d{1,4})(?:\\.\\.(\\d{1,4}))?$/.exec(normalized);\n if (!match) {\n return null;\n }\n const start = Number(match[1]);\n const end = match[2] ? Number(match[2]) : undefined;\n if (start < 1 || start > 1000 || (end !== undefined && (end < start || end > 1000))) {\n return null;\n }\n return end === undefined ? String(start) : `${start}..${end}`;\n}\n\nfunction compareNormalizedWeights(left: string, right: string): number {\n const leftRange = readWeightRange(left);\n const rightRange = readWeightRange(right);\n return leftRange.start - rightRange.start\n || leftRange.end - rightRange.end\n || compareCodeUnits(left, right);\n}\n\nfunction readWeightRange(value: string): { start: number; end: number } {\n const separator = value.indexOf(\"..\");\n const start = Number(separator < 0 ? value : value.slice(0, separator));\n const end = separator < 0 ? start : Number(value.slice(separator + 2));\n return { start, end };\n}\n\nfunction compareCodeUnits(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\nfunction normalizeDisplay(value: unknown): string {\n return typeof value === \"string\" && VALID_DISPLAYS.has(value) ? value : \"swap\";\n}\n\nfunction buildGoogleFontsHref(families: string[], display: unknown): string {\n const familyQuery = families.map((family) => `family=${family}`).join(\"&\");\n return `https://fonts.googleapis.com/css2?${familyQuery}&display=${normalizeDisplay(display)}`;\n}\n\nexport function googleFont(input: ResuxFontFamilyInput): ResuxFontFamilyInput {\n return input;\n}\n\nfunction isLazyFamily(input: ResuxFontFamilyInput, options: ResuxFontsModuleOptions): boolean {\n if (typeof input.deferUntilPageLoad === \"boolean\") {\n if (input.deferUntilPageLoad) {\n return true;\n }\n return input.strategy === \"lazy\";\n }\n if (input.strategy) {\n return input.strategy === \"lazy\";\n }\n return options.strategy === \"lazy\" || options.deferUntilPageLoad === true;\n}\n\nexport default defineResuxModule<ResuxFontsModuleOptions>({\n defaults: {\n google: [],\n preconnect: true,\n strategy: \"eager\",\n deferUntilPageLoad: false,\n },\n setup(options, resux) {\n const googleFamilies = Array.isArray(options.google) ? options.google : [];\n if (!googleFamilies.length) {\n return;\n }\n\n const eagerGroup: ResuxFontFamilyInput[] = [];\n const lazyGroup: ResuxFontFamilyInput[] = [];\n\n for (const family of googleFamilies) {\n if (isLazyFamily(family, options)) {\n lazyGroup.push(family);\n } else {\n eagerGroup.push(family);\n }\n }\n\n const headLinks: Array<{ rel: string; href: string; as?: string; crossorigin?: string }> = [];\n const headScripts: Array<{ innerHTML: string }> = [];\n\n const hasAnyFonts = eagerGroup.length > 0 || lazyGroup.length > 0;\n if (options.preconnect !== false && hasAnyFonts) {\n headLinks.push(\n { rel: \"preconnect\", href: \"https://fonts.googleapis.com\" },\n { rel: \"preconnect\", href: \"https://fonts.gstatic.com\", crossorigin: \"\" },\n );\n }\n\n if (eagerGroup.length > 0) {\n const eagerNormalized = eagerGroup\n .map((family) => normalizeFamily(family))\n .filter((family): family is string => Boolean(family));\n if (eagerNormalized.length > 0) {\n const href = buildGoogleFontsHref(\n eagerNormalized,\n eagerGroup.find((family) => family.display)?.display,\n );\n const isPreload = eagerGroup.some((family) => family.strategy === \"preload\")\n || options.strategy === \"preload\";\n if (isPreload) {\n headLinks.push({ rel: \"preload\", as: \"style\", href });\n }\n headLinks.push({ rel: \"stylesheet\", href });\n }\n }\n\n if (lazyGroup.length > 0) {\n const lazyNormalized = lazyGroup\n .map((family) => normalizeFamily(family))\n .filter((family): family is string => Boolean(family));\n if (lazyNormalized.length > 0) {\n const href = buildGoogleFontsHref(\n lazyNormalized,\n lazyGroup.find((family) => family.display)?.display,\n );\n headLinks.push({ rel: \"preload\", as: \"style\", href });\n headScripts.push({\n innerHTML: `(function(){function loadFonts(){var l=document.createElement('link');l.rel='stylesheet';l.href=${JSON.stringify(href)};document.head.appendChild(l);}if(document.readyState==='complete'){loadFonts();}else{window.addEventListener('load',loadFonts);}})();`,\n });\n }\n }\n\n if (headLinks.length > 0 || headScripts.length > 0) {\n resux.addHead({\n link: headLinks,\n ...(headScripts.length > 0 ? { script: headScripts } : {}),\n });\n }\n\n resux.extendRuntimeConfig({\n public: {\n fonts: {\n provider: \"google\",\n families: googleFamilies.map((family) => family.name),\n familyConfigs: googleFamilies.map((family) => ({\n name: family.name,\n strategy: family.strategy || options.strategy || \"eager\",\n deferUntilPageLoad: isLazyFamily(family, options),\n })),\n strategy: options.strategy || \"eager\",\n deferUntilPageLoad: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