resuxjs 0.3.11 → 0.4.0-beta.2
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/README.md +23 -1
- package/dist/bin.d.ts +1 -2
- package/dist/bin.js +4 -0
- package/dist/bin.js.map +1 -1
- package/dist/build/index.d.ts +28 -0
- package/dist/build/index.js +51 -0
- package/dist/build/index.js.map +1 -0
- package/dist/cli.d.ts +15 -5
- package/dist/cli.js +2648 -3671
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapter.d.ts +14 -11
- package/dist/compiler/adapter.js +68 -93
- package/dist/compiler/adapter.js.map +1 -1
- package/dist/compiler/dev-warnings.d.ts +8 -5
- package/dist/compiler/dev-warnings.js +248 -321
- package/dist/compiler/dev-warnings.js.map +1 -1
- package/dist/compiler/directives.d.ts +3 -0
- package/dist/compiler/directives.js +124 -150
- package/dist/compiler/directives.js.map +1 -1
- package/dist/compiler/implementation.d.ts +96 -93
- package/dist/compiler/implementation.js +2967 -3430
- package/dist/compiler/index.d.ts +14 -11
- package/dist/compiler/index.js +68 -93
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +12 -5
- package/dist/core/config.js +42 -25
- package/dist/core/config.js.map +1 -1
- package/dist/core/hooks.d.ts +127 -126
- package/dist/core/hooks.js +45 -55
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.d.ts +5 -4
- package/dist/core/index.js +5 -5
- package/dist/core/module-container.d.ts +76 -74
- package/dist/core/module-container.js +181 -186
- package/dist/core/module-container.js.map +1 -1
- package/dist/core/resux.d.ts +15 -12
- package/dist/core/resux.js +17 -13
- package/dist/core/resux.js.map +1 -1
- package/dist/create-bin.d.ts +1 -2
- package/dist/create-bin.js +4 -0
- package/dist/create-bin.js.map +1 -1
- package/dist/create.d.ts +3 -0
- package/dist/create.js +499 -638
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +4 -1
- package/dist/deploy/cloudflare.js +30 -34
- package/dist/deploy/cloudflare.js.map +1 -1
- package/dist/deploy/common.d.ts +6 -4
- package/dist/deploy/common.js +118 -188
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/framework-runtime.d.ts +3 -0
- package/dist/deploy/framework-runtime.js +43 -48
- package/dist/deploy/framework-runtime.js.map +1 -1
- package/dist/deploy/index.d.ts +4 -1
- package/dist/deploy/index.js +58 -80
- package/dist/deploy/index.js.map +1 -1
- package/dist/deploy/netlify.d.ts +4 -1
- package/dist/deploy/netlify.js +40 -41
- package/dist/deploy/netlify.js.map +1 -1
- package/dist/deploy/node.d.ts +4 -1
- package/dist/deploy/node.js +24 -19
- package/dist/deploy/node.js.map +1 -1
- package/dist/deploy/production-report.d.ts +3 -0
- package/dist/deploy/production-report.js +14 -14
- package/dist/deploy/production-report.js.map +1 -1
- package/dist/deploy/runtime-dependencies.d.ts +3 -0
- package/dist/deploy/runtime-dependencies.js +158 -220
- package/dist/deploy/runtime-dependencies.js.map +1 -1
- package/dist/deploy/static.d.ts +4 -1
- package/dist/deploy/static.js +16 -14
- package/dist/deploy/static.js.map +1 -1
- package/dist/deploy/types.d.ts +25 -22
- package/dist/deploy/types.js +0 -1
- package/dist/deploy/vercel.d.ts +4 -1
- package/dist/deploy/vercel.js +137 -188
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/fonts/index.d.ts +15 -11
- package/dist/fonts/index.js +114 -134
- package/dist/fonts/index.js.map +1 -1
- package/dist/globals.d.ts +79 -78
- package/dist/globals.js +0 -1
- package/dist/halal-core/ai/classifyProject.d.ts +4 -1
- package/dist/halal-core/ai/classifyProject.js +81 -95
- package/dist/halal-core/ai/classifyProject.js.map +1 -1
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +5 -2
- package/dist/halal-core/ai/classifyRuntimeContent.js +77 -95
- package/dist/halal-core/ai/classifyRuntimeContent.js.map +1 -1
- package/dist/halal-core/ai/createProjectSummary.d.ts +38 -35
- package/dist/halal-core/ai/createProjectSummary.js +38 -39
- package/dist/halal-core/ai/createProjectSummary.js.map +1 -1
- package/dist/halal-core/ai/halalClassifierPrompt.d.ts +3 -0
- package/dist/halal-core/ai/halalClassifierPrompt.js +5 -1
- package/dist/halal-core/ai/halalClassifierPrompt.js.map +1 -1
- package/dist/halal-core/ai/redactSensitiveData.d.ts +3 -0
- package/dist/halal-core/ai/redactSensitiveData.js +82 -110
- package/dist/halal-core/ai/redactSensitiveData.js.map +1 -1
- package/dist/halal-core/ai/validateAiResponse.d.ts +4 -1
- package/dist/halal-core/ai/validateAiResponse.js +58 -85
- package/dist/halal-core/ai/validateAiResponse.js.map +1 -1
- package/dist/halal-core/cli/check.d.ts +3 -0
- package/dist/halal-core/cli/check.js +28 -30
- package/dist/halal-core/cli/check.js.map +1 -1
- package/dist/halal-core/cli/explain.d.ts +3 -0
- package/dist/halal-core/cli/explain.js +27 -31
- package/dist/halal-core/cli/explain.js.map +1 -1
- package/dist/halal-core/cli/report.d.ts +3 -0
- package/dist/halal-core/cli/report.js +14 -10
- package/dist/halal-core/cli/report.js.map +1 -1
- package/dist/halal-core/cli/submitReview.d.ts +3 -0
- package/dist/halal-core/cli/submitReview.js +13 -9
- package/dist/halal-core/cli/submitReview.js.map +1 -1
- package/dist/halal-core/cli/verifyReview.d.ts +3 -0
- package/dist/halal-core/cli/verifyReview.js +18 -15
- package/dist/halal-core/cli/verifyReview.js.map +1 -1
- package/dist/halal-core/config.d.ts +30 -27
- package/dist/halal-core/config.js +76 -118
- package/dist/halal-core/config.js.map +1 -1
- package/dist/halal-core/crypto/integrity.d.ts +6 -3
- package/dist/halal-core/crypto/integrity.js +64 -87
- package/dist/halal-core/crypto/integrity.js.map +1 -1
- package/dist/halal-core/enforce.d.ts +3 -0
- package/dist/halal-core/enforce.js +92 -105
- package/dist/halal-core/enforce.js.map +1 -1
- package/dist/halal-core/index.d.ts +20 -16
- package/dist/halal-core/index.js +18 -19
- package/dist/halal-core/lifecycle.d.ts +3 -0
- package/dist/halal-core/lifecycle.js +15 -13
- package/dist/halal-core/lifecycle.js.map +1 -1
- package/dist/halal-core/policy.d.ts +4 -1
- package/dist/halal-core/policy.js +6 -2
- package/dist/halal-core/policy.js.map +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.d.ts +4 -1
- package/dist/halal-core/report/formatBrowserOverlay.js +10 -8
- package/dist/halal-core/report/formatBrowserOverlay.js.map +1 -1
- package/dist/halal-core/report/formatTerminalReport.d.ts +4 -1
- package/dist/halal-core/report/formatTerminalReport.js +27 -37
- package/dist/halal-core/report/formatTerminalReport.js.map +1 -1
- package/dist/halal-core/report/generateHalalReport.d.ts +7 -4
- package/dist/halal-core/report/generateHalalReport.js +26 -26
- package/dist/halal-core/report/generateHalalReport.js.map +1 -1
- package/dist/halal-core/report/signReport.d.ts +4 -1
- package/dist/halal-core/report/signReport.js +16 -12
- package/dist/halal-core/report/signReport.js.map +1 -1
- package/dist/halal-core/report/verifyReport.d.ts +9 -6
- package/dist/halal-core/report/verifyReport.js +51 -41
- package/dist/halal-core/report/verifyReport.js.map +1 -1
- package/dist/halal-core/review/createReviewRequest.d.ts +4 -1
- package/dist/halal-core/review/createReviewRequest.js +21 -17
- package/dist/halal-core/review/createReviewRequest.js.map +1 -1
- package/dist/halal-core/review/reviewPolicy.d.ts +3 -0
- package/dist/halal-core/review/reviewPolicy.js +19 -17
- package/dist/halal-core/review/reviewPolicy.js.map +1 -1
- package/dist/halal-core/review/signedReviewFile.d.ts +11 -8
- package/dist/halal-core/review/signedReviewFile.js +24 -22
- package/dist/halal-core/review/signedReviewFile.js.map +1 -1
- package/dist/halal-core/review/verifyReviewApproval.d.ts +9 -6
- package/dist/halal-core/review/verifyReviewApproval.js +68 -62
- package/dist/halal-core/review/verifyReviewApproval.js.map +1 -1
- package/dist/halal-core/rules/adultContentRules.d.ts +3 -0
- package/dist/halal-core/rules/adultContentRules.js +23 -23
- package/dist/halal-core/rules/adultContentRules.js.map +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +3 -0
- package/dist/halal-core/rules/alcoholDrugVapeRules.js +22 -22
- package/dist/halal-core/rules/alcoholDrugVapeRules.js.map +1 -1
- package/dist/halal-core/rules/childSafetyRules.d.ts +3 -0
- package/dist/halal-core/rules/childSafetyRules.js +19 -19
- package/dist/halal-core/rules/childSafetyRules.js.map +1 -1
- package/dist/halal-core/rules/coreCategories.d.ts +7 -4
- package/dist/halal-core/rules/coreCategories.js +237 -110
- package/dist/halal-core/rules/coreCategories.js.map +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.d.ts +3 -0
- package/dist/halal-core/rules/cyberAbuseRules.js +27 -27
- package/dist/halal-core/rules/cyberAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/defaultBlockedRules.d.ts +21 -18
- package/dist/halal-core/rules/defaultBlockedRules.js +158 -199
- package/dist/halal-core/rules/defaultBlockedRules.js.map +1 -1
- package/dist/halal-core/rules/dependencyRules.d.ts +8 -5
- package/dist/halal-core/rules/dependencyRules.js +50 -56
- package/dist/halal-core/rules/dependencyRules.js.map +1 -1
- package/dist/halal-core/rules/endpointRules.d.ts +6 -3
- package/dist/halal-core/rules/endpointRules.js +21 -23
- package/dist/halal-core/rules/endpointRules.js.map +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.d.ts +3 -0
- package/dist/halal-core/rules/environmentalHarmRules.js +17 -17
- package/dist/halal-core/rules/environmentalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/financeRibaRules.d.ts +3 -0
- package/dist/halal-core/rules/financeRibaRules.js +20 -20
- package/dist/halal-core/rules/financeRibaRules.js.map +1 -1
- package/dist/halal-core/rules/gamblingRules.d.ts +3 -0
- package/dist/halal-core/rules/gamblingRules.js +22 -22
- package/dist/halal-core/rules/gamblingRules.js.map +1 -1
- package/dist/halal-core/rules/generalHarmRules.d.ts +3 -0
- package/dist/halal-core/rules/generalHarmRules.js +15 -15
- package/dist/halal-core/rules/generalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/healthHarmRules.d.ts +3 -0
- package/dist/halal-core/rules/healthHarmRules.js +19 -19
- package/dist/halal-core/rules/healthHarmRules.js.map +1 -1
- package/dist/halal-core/rules/keywordRules.d.ts +11 -8
- package/dist/halal-core/rules/keywordRules.js +90 -39
- package/dist/halal-core/rules/keywordRules.js.map +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.d.ts +3 -0
- package/dist/halal-core/rules/privacyAbuseRules.js +21 -21
- package/dist/halal-core/rules/privacyAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/scamFraudRules.d.ts +3 -0
- package/dist/halal-core/rules/scamFraudRules.js +29 -29
- package/dist/halal-core/rules/scamFraudRules.js.map +1 -1
- package/dist/halal-core/rules/selfHarmRules.d.ts +3 -0
- package/dist/halal-core/rules/selfHarmRules.js +17 -17
- package/dist/halal-core/rules/selfHarmRules.js.map +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.d.ts +3 -0
- package/dist/halal-core/rules/violenceExtremismRules.js +30 -30
- package/dist/halal-core/rules/violenceExtremismRules.js.map +1 -1
- package/dist/halal-core/runtime/guard.d.ts +17 -14
- package/dist/halal-core/runtime/guard.js +162 -183
- package/dist/halal-core/runtime/guard.js.map +1 -1
- package/dist/halal-core/runtime/index.d.ts +5 -4
- package/dist/halal-core/runtime/index.js +4 -5
- package/dist/halal-core/runtime/reviewedMemory.d.ts +4 -1
- package/dist/halal-core/runtime/reviewedMemory.js +74 -110
- package/dist/halal-core/runtime/reviewedMemory.js.map +1 -1
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +10 -7
- package/dist/halal-core/runtime/serializeRuntimeContent.js +132 -156
- package/dist/halal-core/runtime/serializeRuntimeContent.js.map +1 -1
- package/dist/halal-core/runtime/types.d.ts +44 -41
- package/dist/halal-core/runtime/types.js +0 -1
- package/dist/halal-core/scanner/scanApiRoutes.d.ts +3 -0
- package/dist/halal-core/scanner/scanApiRoutes.js +32 -36
- package/dist/halal-core/scanner/scanApiRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanComponents.d.ts +3 -0
- package/dist/halal-core/scanner/scanComponents.js +12 -13
- package/dist/halal-core/scanner/scanComponents.js.map +1 -1
- package/dist/halal-core/scanner/scanContent.d.ts +5 -2
- package/dist/halal-core/scanner/scanContent.js +193 -263
- package/dist/halal-core/scanner/scanContent.js.map +1 -1
- package/dist/halal-core/scanner/scanDependencies.d.ts +3 -0
- package/dist/halal-core/scanner/scanDependencies.js +16 -15
- package/dist/halal-core/scanner/scanDependencies.js.map +1 -1
- package/dist/halal-core/scanner/scanDomains.d.ts +5 -2
- package/dist/halal-core/scanner/scanDomains.js +12 -12
- package/dist/halal-core/scanner/scanDomains.js.map +1 -1
- package/dist/halal-core/scanner/scanEnvNames.d.ts +3 -0
- package/dist/halal-core/scanner/scanEnvNames.js +23 -26
- package/dist/halal-core/scanner/scanEnvNames.js.map +1 -1
- package/dist/halal-core/scanner/scanMetadata.d.ts +6 -3
- package/dist/halal-core/scanner/scanMetadata.js +20 -29
- package/dist/halal-core/scanner/scanMetadata.js.map +1 -1
- package/dist/halal-core/scanner/scanPages.d.ts +3 -0
- package/dist/halal-core/scanner/scanPages.js +12 -15
- package/dist/halal-core/scanner/scanPages.js.map +1 -1
- package/dist/halal-core/scanner/scanProject.d.ts +15 -10
- package/dist/halal-core/scanner/scanProject.js +43 -49
- package/dist/halal-core/scanner/scanProject.js.map +1 -1
- package/dist/halal-core/scanner/scanRoutes.d.ts +3 -0
- package/dist/halal-core/scanner/scanRoutes.js +32 -39
- package/dist/halal-core/scanner/scanRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanTranslations.d.ts +3 -0
- package/dist/halal-core/scanner/scanTranslations.js +21 -29
- package/dist/halal-core/scanner/scanTranslations.js.map +1 -1
- package/dist/halal-core/status.d.ts +14 -11
- package/dist/halal-core/status.js +0 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +3 -0
- package/dist/halal-core/tamper/verifyCoreIntegrity.js +26 -24
- package/dist/halal-core/tamper/verifyCoreIntegrity.js.map +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +3 -0
- package/dist/halal-core/tamper/verifyLifecycleHooks.js +13 -12
- package/dist/halal-core/tamper/verifyLifecycleHooks.js.map +1 -1
- package/dist/halal-core/tamper/verifyReportSignature.d.ts +6 -3
- package/dist/halal-core/tamper/verifyReportSignature.js +20 -14
- package/dist/halal-core/tamper/verifyReportSignature.js.map +1 -1
- package/dist/halal.d.ts +20 -1
- package/dist/halal.js +18 -2
- package/dist/i18n/index.d.ts +34 -31
- package/dist/i18n/index.js +219 -288
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.d.ts +18 -15
- package/dist/i18n/shared.js +204 -266
- package/dist/i18n/shared.js.map +1 -1
- package/dist/icons/index.d.ts +143 -139
- package/dist/icons/index.js +322 -273
- package/dist/icons/index.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +7 -2
- package/dist/kit/index.d.ts +9 -6
- package/dist/kit/index.js +45 -43
- package/dist/kit/index.js.map +1 -1
- package/dist/nitro-server/index.d.ts +7 -4
- package/dist/nitro-server/index.js +6 -2
- package/dist/nitro-server/index.js.map +1 -1
- package/dist/node.d.ts +6 -3
- package/dist/node.js +88 -116
- package/dist/node.js.map +1 -1
- package/dist/reactivity/computed.d.ts +6 -3
- package/dist/reactivity/computed.js +46 -53
- package/dist/reactivity/computed.js.map +1 -1
- package/dist/reactivity/effect.d.ts +8 -5
- package/dist/reactivity/effect.js +105 -146
- package/dist/reactivity/effect.js.map +1 -1
- package/dist/reactivity/index.d.ts +8 -8
- package/dist/reactivity/index.js +7 -8
- package/dist/reactivity/reactive.d.ts +3 -0
- package/dist/reactivity/reactive.js +93 -133
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/readonly.d.ts +2 -1
- package/dist/reactivity/readonly.js +2 -2
- package/dist/reactivity/ref.d.ts +15 -15
- package/dist/reactivity/ref.js +73 -81
- package/dist/reactivity/ref.js.map +1 -1
- package/dist/reactivity/scheduler.d.ts +3 -1
- package/dist/reactivity/scheduler.js +67 -69
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/reactivity/types.d.ts +17 -14
- package/dist/reactivity/types.js +0 -1
- package/dist/reactivity/utils.d.ts +7 -4
- package/dist/reactivity/utils.js +25 -24
- package/dist/reactivity/utils.js.map +1 -1
- package/dist/reactivity/watch.d.ts +4 -2
- package/dist/reactivity/watch.js +75 -103
- package/dist/reactivity/watch.js.map +1 -1
- package/dist/runtime/core.d.ts +31 -0
- package/dist/runtime/core.js +156 -0
- package/dist/runtime/core.js.map +1 -0
- package/dist/runtime/index.d.ts +487 -461
- package/dist/runtime/index.js +4129 -5254
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/reactivity.d.ts +7 -0
- package/dist/runtime/reactivity.js +6 -0
- package/dist/runtime/resume.d.ts +79 -0
- package/dist/runtime/resume.js +482 -0
- package/dist/runtime/resume.js.map +1 -0
- package/dist/runtime/router.d.ts +20 -0
- package/dist/runtime/router.js +60 -0
- package/dist/runtime/router.js.map +1 -0
- package/dist/runtime/streaming.d.ts +24 -0
- package/dist/runtime/streaming.js +200 -0
- package/dist/runtime/streaming.js.map +1 -0
- package/dist/security/media-fetch.d.ts +32 -0
- package/dist/security/media-fetch.js +301 -0
- package/dist/security/media-fetch.js.map +1 -0
- package/dist/security/path-boundary.d.ts +7 -0
- package/dist/security/path-boundary.js +70 -0
- package/dist/security/path-boundary.js.map +1 -0
- package/dist/ui/index.d.ts +1580 -1576
- package/dist/ui/index.js +975 -674
- package/dist/ui/index.js.map +1 -1
- package/dist/vite-builder/index.d.ts +6 -3
- package/dist/vite-builder/index.js +6 -2
- package/dist/vite-builder/index.js.map +1 -1
- package/package.json +46 -86
- package/dist/compiler/implementation.js.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/deploy/types.js.map +0 -1
- package/dist/globals.js.map +0 -1
- package/dist/halal-core/index.js.map +0 -1
- package/dist/halal-core/runtime/index.js.map +0 -1
- package/dist/halal-core/runtime/types.js.map +0 -1
- package/dist/halal-core/status.js.map +0 -1
- package/dist/halal.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/reactivity/index.js.map +0 -1
- package/dist/reactivity/readonly.js.map +0 -1
- package/dist/reactivity/types.js.map +0 -1
|
@@ -1,250 +1,188 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pathExists, readJsonRecord } from "./common.js";
|
|
2
2
|
import { builtinModules, createRequire } from "node:module";
|
|
3
|
+
import { cp, mkdir, readFile, readdir, rm } from "node:fs/promises";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import ts from "typescript";
|
|
5
|
-
|
|
6
|
-
const nodeBuiltins = new Set(builtinModules.flatMap((name) => [
|
|
7
|
-
name,
|
|
8
|
-
name.startsWith("node:") ? name.slice(5) : `node:${name}`,
|
|
9
|
-
]));
|
|
6
|
+
//#region src/deploy/runtime-dependencies.ts
|
|
7
|
+
const nodeBuiltins = new Set(builtinModules.flatMap((name) => [name, name.startsWith("node:") ? name.slice(5) : `node:${name}`]));
|
|
10
8
|
function isRecord(value) {
|
|
11
|
-
|
|
9
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
10
|
}
|
|
13
11
|
function runtimeDependencyNames(value) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return Object.keys(value).filter((name) => name.trim().length > 0);
|
|
12
|
+
if (!isRecord(value)) return [];
|
|
13
|
+
return Object.keys(value).filter((name) => name.trim().length > 0);
|
|
18
14
|
}
|
|
19
15
|
function dependencyTargetPath(runtimeRoot, packageName) {
|
|
20
|
-
|
|
16
|
+
return path.join(runtimeRoot, "node_modules", ...packageName.split("/"));
|
|
21
17
|
}
|
|
22
18
|
function packageNameFromSpecifier(specifier) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
if (specifier.startsWith("@")) {
|
|
33
|
-
const [scope, name] = specifier.split("/");
|
|
34
|
-
return scope && name ? `${scope}/${name}` : null;
|
|
35
|
-
}
|
|
36
|
-
const packageName = specifier.split("/")[0] ?? "";
|
|
37
|
-
return packageName && !nodeBuiltins.has(packageName) ? packageName : null;
|
|
19
|
+
if (!specifier || specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("#") || specifier.startsWith("data:") || specifier.startsWith("file:") || nodeBuiltins.has(specifier)) return null;
|
|
20
|
+
if (specifier.startsWith("@")) {
|
|
21
|
+
const [scope, name] = specifier.split("/");
|
|
22
|
+
return scope && name ? `${scope}/${name}` : null;
|
|
23
|
+
}
|
|
24
|
+
const packageName = specifier.split("/")[0] ?? "";
|
|
25
|
+
return packageName && !nodeBuiltins.has(packageName) ? packageName : null;
|
|
38
26
|
}
|
|
39
27
|
async function walkRuntimeModuleFiles(directory) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
return files;
|
|
28
|
+
const entries = await readdir(directory, { withFileTypes: true }).catch(() => []);
|
|
29
|
+
const files = [];
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
const fullPath = path.join(directory, entry.name);
|
|
32
|
+
if (entry.isDirectory()) {
|
|
33
|
+
files.push(...await walkRuntimeModuleFiles(fullPath));
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (entry.isFile() && /\.(?:mjs|cjs|js)$/.test(entry.name)) files.push(fullPath);
|
|
37
|
+
}
|
|
38
|
+
return files;
|
|
53
39
|
}
|
|
54
40
|
function collectModuleSpecifiers(sourceFile) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
&& node.expression.kind === ts.SyntaxKind.ImportKeyword
|
|
64
|
-
&& node.arguments.length === 1
|
|
65
|
-
&& ts.isStringLiteralLike(node.arguments[0])) {
|
|
66
|
-
specifiers.push(node.arguments[0].text);
|
|
67
|
-
}
|
|
68
|
-
ts.forEachChild(node, visit);
|
|
69
|
-
}
|
|
70
|
-
visit(sourceFile);
|
|
71
|
-
return specifiers;
|
|
41
|
+
const specifiers = [];
|
|
42
|
+
function visit(node) {
|
|
43
|
+
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier)) specifiers.push(node.moduleSpecifier.text);
|
|
44
|
+
else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) specifiers.push(node.arguments[0].text);
|
|
45
|
+
ts.forEachChild(node, visit);
|
|
46
|
+
}
|
|
47
|
+
visit(sourceFile);
|
|
48
|
+
return specifiers;
|
|
72
49
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return [...dependencyNames].sort();
|
|
50
|
+
async function collectServerRuntimeDependencyNames(serverRoot) {
|
|
51
|
+
if (!await pathExists(serverRoot)) return [];
|
|
52
|
+
const dependencyNames = /* @__PURE__ */ new Set();
|
|
53
|
+
for (const file of await walkRuntimeModuleFiles(serverRoot)) {
|
|
54
|
+
const source = await readFile(file, "utf8");
|
|
55
|
+
const sourceFile = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, false, ts.ScriptKind.JS);
|
|
56
|
+
for (const specifier of collectModuleSpecifiers(sourceFile)) {
|
|
57
|
+
const packageName = packageNameFromSpecifier(specifier);
|
|
58
|
+
if (packageName && packageName !== "resuxjs" && packageName !== "resux") dependencyNames.add(packageName);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return [...dependencyNames].sort();
|
|
89
62
|
}
|
|
90
63
|
function resolveResuxPackageRequire(appRequire) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
catch {
|
|
100
|
-
// Keep trying known package names.
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return null;
|
|
64
|
+
for (const packageName of ["resuxjs", "resux"]) try {
|
|
65
|
+
return createRequire(appRequire.resolve(packageName));
|
|
66
|
+
} catch {
|
|
67
|
+
try {
|
|
68
|
+
return createRequire(appRequire.resolve(`${packageName}/package.json`));
|
|
69
|
+
} catch {}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
105
72
|
}
|
|
106
73
|
function formatResolutionError(error) {
|
|
107
|
-
|
|
74
|
+
return error instanceof Error ? error.message : String(error);
|
|
108
75
|
}
|
|
109
76
|
async function findPackageJsonFromEntry(dependency, entryPath) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (parentDirectory === currentDirectory) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
currentDirectory = parentDirectory;
|
|
122
|
-
}
|
|
77
|
+
let currentDirectory = path.dirname(entryPath);
|
|
78
|
+
while (true) {
|
|
79
|
+
const candidate = path.join(currentDirectory, "package.json");
|
|
80
|
+
if ((await readJsonRecord(candidate))?.name === dependency) return candidate;
|
|
81
|
+
const parentDirectory = path.dirname(currentDirectory);
|
|
82
|
+
if (parentDirectory === currentDirectory) return null;
|
|
83
|
+
currentDirectory = parentDirectory;
|
|
84
|
+
}
|
|
123
85
|
}
|
|
124
86
|
async function findPackageJsonFromSearchPaths(dependency, resolver) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
87
|
+
const searchPaths = resolver.resolve.paths(dependency) ?? [];
|
|
88
|
+
for (const nodeModulesRoot of searchPaths) {
|
|
89
|
+
const candidate = path.join(nodeModulesRoot, ...dependency.split("/"), "package.json");
|
|
90
|
+
if ((await readJsonRecord(candidate))?.name === dependency) return candidate;
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
134
93
|
}
|
|
135
94
|
async function resolveDependencyPackageJsonPath(dependency, resolver, resolutionErrors) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (searchPathPackageJson) {
|
|
154
|
-
return searchPathPackageJson;
|
|
155
|
-
}
|
|
156
|
-
// Preserve compatibility with packages that explicitly export package.json.
|
|
157
|
-
try {
|
|
158
|
-
return resolver.resolve(`${dependency}/package.json`);
|
|
159
|
-
}
|
|
160
|
-
catch (packageJsonError) {
|
|
161
|
-
resolutionErrors?.push(`${formatResolutionError(entryResolutionError)} | ${formatResolutionError(packageJsonError)}`);
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
95
|
+
let entryResolutionError = null;
|
|
96
|
+
try {
|
|
97
|
+
const entryPath = resolver.resolve(dependency);
|
|
98
|
+
const packageJsonPath = await findPackageJsonFromEntry(dependency, entryPath);
|
|
99
|
+
if (packageJsonPath) return packageJsonPath;
|
|
100
|
+
entryResolutionError = /* @__PURE__ */ new Error(`Resolved "${dependency}" to ${entryPath}, but its package root could not be located.`);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
entryResolutionError = error;
|
|
103
|
+
}
|
|
104
|
+
const searchPathPackageJson = await findPackageJsonFromSearchPaths(dependency, resolver);
|
|
105
|
+
if (searchPathPackageJson) return searchPathPackageJson;
|
|
106
|
+
try {
|
|
107
|
+
return resolver.resolve(`${dependency}/package.json`);
|
|
108
|
+
} catch (packageJsonError) {
|
|
109
|
+
resolutionErrors?.push(`${formatResolutionError(entryResolutionError)} | ${formatResolutionError(packageJsonError)}`);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
164
112
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
pending.push({ dependency, packageJsonPath: dependencyPackageJsonPath });
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
const requiredDependencyPath = path.join(dependencyTargetPath(runtimeRoot, rootDependency), "package.json");
|
|
234
|
-
if (!(await pathExists(requiredDependencyPath))) {
|
|
235
|
-
throw new Error(`${consumerLabel} could not prepare "${rootDependency}" for ${runtimeRoot}.`);
|
|
236
|
-
}
|
|
113
|
+
async function copyRuntimeDependencyTree(appRoot, runtimeRoot, rootDependency, consumerLabel) {
|
|
114
|
+
const appRequire = createRequire(path.join(appRoot, "package.json"));
|
|
115
|
+
const resuxPackageRequire = resolveResuxPackageRequire(appRequire);
|
|
116
|
+
const rootResolvers = [appRequire, ...resuxPackageRequire ? [resuxPackageRequire] : []];
|
|
117
|
+
const resolutionErrors = [];
|
|
118
|
+
let rootDependencyPackageJsonPath = null;
|
|
119
|
+
for (const resolver of rootResolvers) {
|
|
120
|
+
rootDependencyPackageJsonPath = await resolveDependencyPackageJsonPath(rootDependency, resolver, resolutionErrors);
|
|
121
|
+
if (rootDependencyPackageJsonPath) break;
|
|
122
|
+
}
|
|
123
|
+
if (!rootDependencyPackageJsonPath) throw new Error(`${consumerLabel} requires "${rootDependency}" but it could not be resolved from app or framework dependencies. (${resolutionErrors.join(" | ")})`);
|
|
124
|
+
const pending = [{
|
|
125
|
+
dependency: rootDependency,
|
|
126
|
+
packageJsonPath: rootDependencyPackageJsonPath
|
|
127
|
+
}];
|
|
128
|
+
const copied = /* @__PURE__ */ new Set();
|
|
129
|
+
while (pending.length > 0) {
|
|
130
|
+
const next = pending.shift();
|
|
131
|
+
if (!next || copied.has(next.dependency)) continue;
|
|
132
|
+
copied.add(next.dependency);
|
|
133
|
+
const sourcePackageJsonPath = next.packageJsonPath;
|
|
134
|
+
const sourcePackageRoot = path.dirname(sourcePackageJsonPath);
|
|
135
|
+
const targetPackageRoot = dependencyTargetPath(runtimeRoot, next.dependency);
|
|
136
|
+
await rm(targetPackageRoot, {
|
|
137
|
+
recursive: true,
|
|
138
|
+
force: true
|
|
139
|
+
});
|
|
140
|
+
await mkdir(path.dirname(targetPackageRoot), { recursive: true });
|
|
141
|
+
await cp(sourcePackageRoot, targetPackageRoot, {
|
|
142
|
+
recursive: true,
|
|
143
|
+
force: true,
|
|
144
|
+
dereference: true
|
|
145
|
+
});
|
|
146
|
+
const packageJson = await readJsonRecord(sourcePackageJsonPath);
|
|
147
|
+
if (!packageJson) continue;
|
|
148
|
+
const dependencyResolver = createRequire(sourcePackageJsonPath);
|
|
149
|
+
for (const dependency of runtimeDependencyNames(packageJson.dependencies)) {
|
|
150
|
+
const dependencyPackageJsonPath = await resolveDependencyPackageJsonPath(dependency, dependencyResolver);
|
|
151
|
+
if (!dependencyPackageJsonPath) throw new Error(`${consumerLabel} dependency "${next.dependency}" is missing required package "${dependency}".`);
|
|
152
|
+
pending.push({
|
|
153
|
+
dependency,
|
|
154
|
+
packageJsonPath: dependencyPackageJsonPath
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
for (const dependency of runtimeDependencyNames(packageJson.optionalDependencies)) {
|
|
158
|
+
const dependencyPackageJsonPath = await resolveDependencyPackageJsonPath(dependency, dependencyResolver);
|
|
159
|
+
if (!dependencyPackageJsonPath) continue;
|
|
160
|
+
pending.push({
|
|
161
|
+
dependency,
|
|
162
|
+
packageJsonPath: dependencyPackageJsonPath
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
for (const dependency of runtimeDependencyNames(packageJson.peerDependencies)) {
|
|
166
|
+
const dependencyPackageJsonPath = await resolveDependencyPackageJsonPath(dependency, dependencyResolver);
|
|
167
|
+
if (!dependencyPackageJsonPath) continue;
|
|
168
|
+
pending.push({
|
|
169
|
+
dependency,
|
|
170
|
+
packageJsonPath: dependencyPackageJsonPath
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const requiredDependencyPath = path.join(dependencyTargetPath(runtimeRoot, rootDependency), "package.json");
|
|
175
|
+
if (!await pathExists(requiredDependencyPath)) throw new Error(`${consumerLabel} could not prepare "${rootDependency}" for ${runtimeRoot}.`);
|
|
237
176
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
await copyRuntimeDependencyTree(appRoot, runtimeRoot, rootDependency, consumerLabel);
|
|
241
|
-
}
|
|
177
|
+
async function ensureRuntimeDependencyTrees(appRoot, runtimeRoots, rootDependency, consumerLabel) {
|
|
178
|
+
for (const runtimeRoot of runtimeRoots) await copyRuntimeDependencyTree(appRoot, runtimeRoot, rootDependency, consumerLabel);
|
|
242
179
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
return dependencies;
|
|
180
|
+
async function ensureServerRuntimeDependencyTrees(appRoot, serverRoot, runtimeRoots, consumerLabel) {
|
|
181
|
+
const dependencies = await collectServerRuntimeDependencyNames(serverRoot);
|
|
182
|
+
for (const dependency of dependencies) await ensureRuntimeDependencyTrees(appRoot, runtimeRoots, dependency, `${consumerLabel} server runtime`);
|
|
183
|
+
return dependencies;
|
|
249
184
|
}
|
|
185
|
+
//#endregion
|
|
186
|
+
export { collectServerRuntimeDependencyNames, copyRuntimeDependencyTree, ensureRuntimeDependencyTrees, ensureServerRuntimeDependencyTrees };
|
|
187
|
+
|
|
250
188
|
//# sourceMappingURL=runtime-dependencies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-dependencies.js","sourceRoot":"","sources":["../../src/deploy/runtime-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAUzD,MAAM,YAAY,GAAG,IAAI,GAAG,CAC1B,cAAc,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAC/B,IAAI;IACJ,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,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IAAI,CAAC,yBAAyB,EAAE,CAAC;gBAC/B,SAAS;YACX,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,yBAAyB,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAED,MAAM,sBAAsB,GAAG,IAAI,CAAC,IAAI,CACtC,oBAAoB,CAAC,WAAW,EAAE,cAAc,CAAC,EACjD,cAAc,CACf,CAAC;IACF,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,sBAAsB,CAAC,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CACb,GAAG,aAAa,uBAAuB,cAAc,SAAS,WAAW,GAAG,CAC7E,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,OAAe,EACf,YAAsB,EACtB,cAAsB,EACtB,aAAqB;IAErB,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,yBAAyB,CAC7B,OAAO,EACP,WAAW,EACX,cAAc,EACd,aAAa,CACd,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,OAAe,EACf,UAAkB,EAClB,YAAsB,EACtB,aAAqB;IAErB,MAAM,YAAY,GAAG,MAAM,mCAAmC,CAAC,UAAU,CAAC,CAAC;IAC3E,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;QACtC,MAAM,4BAA4B,CAChC,OAAO,EACP,YAAY,EACZ,UAAU,EACV,GAAG,aAAa,iBAAiB,CAClC,CAAC;IACJ,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
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,K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B,GAAG;GACjF,MAAM,4BAA4B,MAAM,iCACtC,YACA,kBACF;GACA,IAAI,CAAC,2BACH;GAEF,QAAQ,KAAK;IAAE;IAAY,iBAAiB;GAA0B,CAAC;EACzE;EAOA,KAAK,MAAM,cAAc,uBAAuB,YAAY,gBAAgB,GAAG;GAC7E,MAAM,4BAA4B,MAAM,iCACtC,YACA,kBACF;GACA,IAAI,CAAC,2BACH;GAEF,QAAQ,KAAK;IAAE;IAAY,iBAAiB;GAA0B,CAAC;EACzE;CACF;CAEA,MAAM,yBAAyB,KAAK,KAClC,qBAAqB,aAAa,cAAc,GAChD,cACF;CACA,IAAI,CAAE,MAAM,WAAW,sBAAsB,GAC3C,MAAM,IAAI,MACR,GAAG,cAAc,sBAAsB,eAAe,QAAQ,YAAY,EAC5E;AAEJ;AAEA,eAAsB,6BACpB,SACA,cACA,gBACA,eACe;CACf,KAAK,MAAM,eAAe,cACxB,MAAM,0BACJ,SACA,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"}
|
package/dist/deploy/static.d.ts
CHANGED
package/dist/deploy/static.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
1
|
import { assertRuntimeClientAsset, ensureResuxClientAssets } from "./common.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
//#region src/deploy/static.ts
|
|
3
4
|
async function postBuild(context) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
]);
|
|
10
|
-
await assertRuntimeClientAsset(path.join(context.appRoot, ".output", "public"));
|
|
5
|
+
await ensureResuxClientAssets(context.appRoot, [{
|
|
6
|
+
root: path.join(context.appRoot, ".output"),
|
|
7
|
+
target: path.join(context.appRoot, ".output", "public", "__resux")
|
|
8
|
+
}]);
|
|
9
|
+
await assertRuntimeClientAsset(path.join(context.appRoot, ".output", "public"));
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const staticDeployModule = {
|
|
12
|
+
target: "static",
|
|
13
|
+
presetAliases: ["static", "_static"],
|
|
14
|
+
outputLabel: ".output/public",
|
|
15
|
+
inferPreset: () => "static",
|
|
16
|
+
postBuild
|
|
18
17
|
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { staticDeployModule };
|
|
20
|
+
|
|
19
21
|
//# sourceMappingURL=static.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.js","
|
|
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;CACnE,MAAM,wBAAwB,QAAQ,SAAS,CAC7C;EACE,MAAM,KAAK,KAAK,QAAQ,SAAS,SAAS;EAC1C,QAAQ,KAAK,KAAK,QAAQ,SAAS,WAAW,UAAU,SAAS;CACnE,CACF,CAAC;CAED,MAAM,yBAAyB,KAAK,KAAK,QAAQ,SAAS,WAAW,QAAQ,CAAC;AAChF;AAEA,MAAa,qBAAyC;CACpD,QAAQ;CACR,eAAe,CAAC,UAAU,SAAS;CACnC,aAAa;CACb,mBAAmB;CACnB;AACF"}
|
package/dist/deploy/types.d.ts
CHANGED
|
@@ -1,34 +1,37 @@
|
|
|
1
|
+
//#region src/deploy/types.d.ts
|
|
1
2
|
export type ResuxDeployTarget = "auto" | "node" | "vercel" | "netlify" | "cloudflare" | "static";
|
|
2
3
|
export type ResuxResolvedDeployTarget = Exclude<ResuxDeployTarget, "auto">;
|
|
3
4
|
export interface ResuxDeployConfig {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
target?: ResuxDeployTarget;
|
|
6
|
+
nitroPreset?: string;
|
|
6
7
|
}
|
|
7
8
|
export interface DeployBuildContext {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
appRoot: string;
|
|
10
|
+
outDir: string;
|
|
11
|
+
env: NodeJS.ProcessEnv;
|
|
12
|
+
nitroPreset: string | null;
|
|
13
|
+
target: ResuxResolvedDeployTarget;
|
|
13
14
|
}
|
|
14
15
|
export interface DeployDetectionContext {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
appRoot: string;
|
|
17
|
+
outDir: string;
|
|
18
|
+
env: NodeJS.ProcessEnv;
|
|
19
|
+
explicitNitroPreset: string | null;
|
|
20
|
+
deployConfig: ResuxDeployConfig;
|
|
20
21
|
}
|
|
21
22
|
export interface DeployTargetModule {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
target: ResuxResolvedDeployTarget;
|
|
24
|
+
presetAliases: string[];
|
|
25
|
+
outputLabel: string;
|
|
26
|
+
detect?(context: DeployDetectionContext): Promise<boolean>;
|
|
27
|
+
inferPreset?(context: DeployDetectionContext): string | null;
|
|
28
|
+
postBuild?(context: DeployBuildContext): Promise<void>;
|
|
28
29
|
}
|
|
29
30
|
export interface DeploymentResolution {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
target: ResuxResolvedDeployTarget;
|
|
32
|
+
nitroPreset: string | null;
|
|
33
|
+
outputLabel: string;
|
|
34
|
+
reason: string;
|
|
34
35
|
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/deploy/types.js
CHANGED
package/dist/deploy/vercel.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DeployTargetModule } from "./types.js";
|
|
2
|
+
//#region src/deploy/vercel.d.ts
|
|
2
3
|
export declare function resolveVercelNodeRuntime(nodeVersion?: string): string;
|
|
3
4
|
export declare const vercelDeployModule: DeployTargetModule;
|
|
5
|
+
//#endregion
|
|
6
|
+
//# sourceMappingURL=vercel.d.ts.map
|