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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRef, MaybeRefOrGetter, ReactiveEffectOptions, ReactiveEffectRunner, Ref, WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from "../reactivity/types.js";
|
|
2
|
+
import { isRef, ref, toRef, toRefs, unref } from "../reactivity/ref.js";
|
|
3
|
+
import { isReactive, isReadonly, reactive, readonly } from "../reactivity/reactive.js";
|
|
4
|
+
import { computed, isComputed } from "../reactivity/computed.js";
|
|
5
|
+
import { watch, watchEffect } from "../reactivity/watch.js";
|
|
6
|
+
import { nextTick } from "../reactivity/scheduler.js";
|
|
7
|
+
export { type ComputedRef, type MaybeRef, type MaybeRefOrGetter, type ReactiveEffectOptions, type ReactiveEffectRunner, type Ref, type WatchCallback, type WatchOptions, type WatchSource, type WatchStopHandle, computed, isComputed, isReactive, isReadonly, isRef, nextTick, reactive, readonly, ref, toRef, toRefs, unref, watch, watchEffect };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { isReactive, isReadonly, reactive, readonly } from "../reactivity/reactive.js";
|
|
2
|
+
import { isRef, ref, toRef, toRefs, unref } from "../reactivity/ref.js";
|
|
3
|
+
import { computed, isComputed } from "../reactivity/computed.js";
|
|
4
|
+
import { nextTick } from "../reactivity/scheduler.js";
|
|
5
|
+
import { watch, watchEffect } from "../reactivity/watch.js";
|
|
6
|
+
export { computed, isComputed, isReactive, isReadonly, isRef, nextTick, reactive, readonly, ref, toRef, toRefs, unref, watch, watchEffect };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//#region src/runtime/resume.d.ts
|
|
2
|
+
export type ResuxResumeHandler = (...args: unknown[]) => unknown | Promise<unknown>;
|
|
3
|
+
export type ResuxResumeModule = Record<string, unknown>;
|
|
4
|
+
export interface ResuxResumeLoadContext {
|
|
5
|
+
/** Aborted when the configured handler-load deadline expires. */
|
|
6
|
+
signal: AbortSignal;
|
|
7
|
+
}
|
|
8
|
+
export type ResuxResumeModuleLoader = (context?: ResuxResumeLoadContext) => Promise<ResuxResumeModule>;
|
|
9
|
+
export interface ResuxResumeManifestEntry {
|
|
10
|
+
id: string;
|
|
11
|
+
module: string;
|
|
12
|
+
exportName: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ResuxResumeRegistration extends ResuxResumeManifestEntry {
|
|
15
|
+
load: ResuxResumeModuleLoader;
|
|
16
|
+
}
|
|
17
|
+
export interface ResuxResumeRegistryOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Maximum time to wait for one lazy handler module. Set to 0 to disable the
|
|
20
|
+
* deadline. Defaults to 30 seconds so a broken chunk request cannot leave an
|
|
21
|
+
* interaction pending forever.
|
|
22
|
+
*/
|
|
23
|
+
loadTimeoutMs?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare class ResuxResumeLoadTimeoutError extends Error {
|
|
26
|
+
readonly handlerId: string;
|
|
27
|
+
readonly timeoutMs: number;
|
|
28
|
+
constructor(handlerId: string, timeoutMs: number);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Lazily resolves resumable handlers from manifest-style registrations.
|
|
32
|
+
* Resolved handlers are cached, concurrent loads are deduplicated, and replacing
|
|
33
|
+
* a registration invalidates both cached and in-flight state for that handler id.
|
|
34
|
+
* Handler loads are deadline-bound by default so one failed chunk cannot leave an
|
|
35
|
+
* interaction pending forever.
|
|
36
|
+
*/
|
|
37
|
+
export declare class ResuxResumeHandlerRegistry {
|
|
38
|
+
#private;
|
|
39
|
+
constructor(options?: ResuxResumeRegistryOptions);
|
|
40
|
+
/** Registers or replaces one resumable handler definition. */
|
|
41
|
+
register(entry: ResuxResumeRegistration): void;
|
|
42
|
+
/** Registers multiple resumable handler definitions in order. */
|
|
43
|
+
registerMany(entries: ResuxResumeRegistration[]): void;
|
|
44
|
+
/** Returns whether the registry knows about a handler id. */
|
|
45
|
+
has(id: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Resolves one handler lazily, reusing cached handlers and deduplicating active loads.
|
|
48
|
+
* A load that started before a replacement may still resolve for its original caller,
|
|
49
|
+
* but it cannot overwrite the newer registration or its cache. Timed-out loads follow
|
|
50
|
+
* the same rule: a late underlying module resolution cannot populate the handler cache.
|
|
51
|
+
*/
|
|
52
|
+
load(id: string): Promise<ResuxResumeHandler>;
|
|
53
|
+
/** Loads and executes one resumable handler with the provided arguments. */
|
|
54
|
+
run(id: string, ...args: unknown[]): Promise<unknown>;
|
|
55
|
+
/** Loads and caches one handler without executing it. */
|
|
56
|
+
preload(id: string): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/** Creates a registry and seeds it with optional manifest registrations. */
|
|
59
|
+
export declare function createResumeHandlerRegistry(entries?: ResuxResumeRegistration[], options?: ResuxResumeRegistryOptions): ResuxResumeHandlerRegistry;
|
|
60
|
+
export declare const RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAMES = 32;
|
|
61
|
+
export declare const RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAME_LENGTH = 64;
|
|
62
|
+
export interface ResuxResumeBootstrapOptions {
|
|
63
|
+
eventNames: string[];
|
|
64
|
+
runtimeSrc?: string;
|
|
65
|
+
deferEnhancements?: boolean;
|
|
66
|
+
deferVueIslands?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Generates the tiny browser bootstrap used by Resume-First documents.
|
|
70
|
+
*
|
|
71
|
+
* It registers only the event types present in the server HTML, preserves
|
|
72
|
+
* synchronous prevent/stop modifiers while the runtime is absent, imports the
|
|
73
|
+
* full client runtime once on first interaction, then hands the original event
|
|
74
|
+
* to the runtime's resumable-event dispatcher. Normal links are intentionally
|
|
75
|
+
* left to the browser until Resux has a reason to resume.
|
|
76
|
+
*/
|
|
77
|
+
export declare function getResumeBootstrapSource(options: ResuxResumeBootstrapOptions): string;
|
|
78
|
+
//#endregion
|
|
79
|
+
//# sourceMappingURL=resume.d.ts.map
|
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
//#region src/runtime/resume.ts
|
|
2
|
+
const DEFAULT_RESUME_LOAD_TIMEOUT_MS = 3e4;
|
|
3
|
+
const MAX_RESUME_LOAD_TIMEOUT_MS = 2147483647;
|
|
4
|
+
var ResuxResumeLoadTimeoutError = class extends Error {
|
|
5
|
+
handlerId;
|
|
6
|
+
timeoutMs;
|
|
7
|
+
constructor(handlerId, timeoutMs) {
|
|
8
|
+
super(`Timed out loading resumable handler ${handlerId} after ${timeoutMs}ms.`);
|
|
9
|
+
this.name = "ResuxResumeLoadTimeoutError";
|
|
10
|
+
this.handlerId = handlerId;
|
|
11
|
+
this.timeoutMs = timeoutMs;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function normalizeLoadTimeout(value) {
|
|
15
|
+
const timeoutMs = value ?? DEFAULT_RESUME_LOAD_TIMEOUT_MS;
|
|
16
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < 0 || timeoutMs > MAX_RESUME_LOAD_TIMEOUT_MS) throw new RangeError(`loadTimeoutMs must be a finite non-negative number no greater than ${MAX_RESUME_LOAD_TIMEOUT_MS}.`);
|
|
17
|
+
return timeoutMs;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Lazily resolves resumable handlers from manifest-style registrations.
|
|
21
|
+
* Resolved handlers are cached, concurrent loads are deduplicated, and replacing
|
|
22
|
+
* a registration invalidates both cached and in-flight state for that handler id.
|
|
23
|
+
* Handler loads are deadline-bound by default so one failed chunk cannot leave an
|
|
24
|
+
* interaction pending forever.
|
|
25
|
+
*/
|
|
26
|
+
var ResuxResumeHandlerRegistry = class {
|
|
27
|
+
#entries = /* @__PURE__ */ new Map();
|
|
28
|
+
#generations = /* @__PURE__ */ new Map();
|
|
29
|
+
#handlers = /* @__PURE__ */ new Map();
|
|
30
|
+
#pending = /* @__PURE__ */ new Map();
|
|
31
|
+
#loadTimeoutMs;
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
this.#loadTimeoutMs = normalizeLoadTimeout(options.loadTimeoutMs);
|
|
34
|
+
}
|
|
35
|
+
/** Registers or replaces one resumable handler definition. */
|
|
36
|
+
register(entry) {
|
|
37
|
+
if (!entry.id) throw new Error("Resume handler id must not be empty.");
|
|
38
|
+
if (!entry.exportName) throw new Error(`Resume handler ${entry.id} must declare an export name.`);
|
|
39
|
+
const storedEntry = {
|
|
40
|
+
id: entry.id,
|
|
41
|
+
module: entry.module,
|
|
42
|
+
exportName: entry.exportName,
|
|
43
|
+
load: entry.load
|
|
44
|
+
};
|
|
45
|
+
this.#entries.set(storedEntry.id, storedEntry);
|
|
46
|
+
this.#generations.set(storedEntry.id, (this.#generations.get(storedEntry.id) ?? 0) + 1);
|
|
47
|
+
this.#handlers.delete(storedEntry.id);
|
|
48
|
+
this.#pending.delete(storedEntry.id);
|
|
49
|
+
}
|
|
50
|
+
/** Registers multiple resumable handler definitions in order. */
|
|
51
|
+
registerMany(entries) {
|
|
52
|
+
for (const entry of entries) this.register(entry);
|
|
53
|
+
}
|
|
54
|
+
/** Returns whether the registry knows about a handler id. */
|
|
55
|
+
has(id) {
|
|
56
|
+
return this.#entries.has(id);
|
|
57
|
+
}
|
|
58
|
+
/** Loads one module with a deadline and exposes cancellation to cooperative loaders. */
|
|
59
|
+
async #loadModule(id, entry) {
|
|
60
|
+
const controller = new AbortController();
|
|
61
|
+
let timeout;
|
|
62
|
+
const modulePromise = new Promise((resolve) => {
|
|
63
|
+
resolve(entry.load({ signal: controller.signal }));
|
|
64
|
+
});
|
|
65
|
+
if (this.#loadTimeoutMs === 0) return await modulePromise;
|
|
66
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
67
|
+
timeout = setTimeout(() => {
|
|
68
|
+
const error = new ResuxResumeLoadTimeoutError(id, this.#loadTimeoutMs);
|
|
69
|
+
reject(error);
|
|
70
|
+
controller.abort(error);
|
|
71
|
+
}, this.#loadTimeoutMs);
|
|
72
|
+
});
|
|
73
|
+
try {
|
|
74
|
+
return await Promise.race([modulePromise, timeoutPromise]);
|
|
75
|
+
} finally {
|
|
76
|
+
if (timeout !== void 0) clearTimeout(timeout);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolves one handler lazily, reusing cached handlers and deduplicating active loads.
|
|
81
|
+
* A load that started before a replacement may still resolve for its original caller,
|
|
82
|
+
* but it cannot overwrite the newer registration or its cache. Timed-out loads follow
|
|
83
|
+
* the same rule: a late underlying module resolution cannot populate the handler cache.
|
|
84
|
+
*/
|
|
85
|
+
async load(id) {
|
|
86
|
+
const cached = this.#handlers.get(id);
|
|
87
|
+
if (cached) return cached;
|
|
88
|
+
const active = this.#pending.get(id);
|
|
89
|
+
if (active) return active;
|
|
90
|
+
const entry = this.#entries.get(id);
|
|
91
|
+
if (!entry) throw new Error(`Unknown resumable handler ${id}.`);
|
|
92
|
+
const generation = this.#generations.get(id);
|
|
93
|
+
const pending = this.#loadModule(id, entry).then((module) => {
|
|
94
|
+
const handler = Object.hasOwn(module, entry.exportName) ? module[entry.exportName] : void 0;
|
|
95
|
+
if (typeof handler !== "function") throw new Error(`Resumable handler ${id} expected function export ${entry.exportName} from ${entry.module}.`);
|
|
96
|
+
const resolved = handler;
|
|
97
|
+
if (this.#generations.get(id) === generation) this.#handlers.set(id, resolved);
|
|
98
|
+
return resolved;
|
|
99
|
+
});
|
|
100
|
+
if (this.#generations.get(id) === generation) this.#pending.set(id, pending);
|
|
101
|
+
try {
|
|
102
|
+
return await pending;
|
|
103
|
+
} finally {
|
|
104
|
+
if (this.#pending.get(id) === pending) this.#pending.delete(id);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** Loads and executes one resumable handler with the provided arguments. */
|
|
108
|
+
async run(id, ...args) {
|
|
109
|
+
return (await this.load(id))(...args);
|
|
110
|
+
}
|
|
111
|
+
/** Loads and caches one handler without executing it. */
|
|
112
|
+
preload(id) {
|
|
113
|
+
return this.load(id).then(() => void 0);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/** Creates a registry and seeds it with optional manifest registrations. */
|
|
117
|
+
function createResumeHandlerRegistry(entries = [], options = {}) {
|
|
118
|
+
const registry = new ResuxResumeHandlerRegistry(options);
|
|
119
|
+
registry.registerMany(entries);
|
|
120
|
+
return registry;
|
|
121
|
+
}
|
|
122
|
+
const RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAMES = 32;
|
|
123
|
+
const RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAME_LENGTH = 64;
|
|
124
|
+
/**
|
|
125
|
+
* Generates the tiny browser bootstrap used by Resume-First documents.
|
|
126
|
+
*
|
|
127
|
+
* It registers only the event types present in the server HTML, preserves
|
|
128
|
+
* synchronous prevent/stop modifiers while the runtime is absent, imports the
|
|
129
|
+
* full client runtime once on first interaction, then hands the original event
|
|
130
|
+
* to the runtime's resumable-event dispatcher. Normal links are intentionally
|
|
131
|
+
* left to the browser until Resux has a reason to resume.
|
|
132
|
+
*/
|
|
133
|
+
function getResumeBootstrapSource(options) {
|
|
134
|
+
const eventNames = [...new Set(options.eventNames.map((name) => String(name || "").trim()).filter((name) => /^[\w:-]+$/.test(name)))];
|
|
135
|
+
if (eventNames.length > 32) throw new RangeError(`Resume bootstrap supports at most 32 distinct event types.`);
|
|
136
|
+
if (eventNames.find((name) => name.length > 64)) throw new RangeError(`Resume bootstrap event names must be at most 64 characters.`);
|
|
137
|
+
const runtimeSrc = options.runtimeSrc?.trim() || "/__resux/runtime-client.mjs";
|
|
138
|
+
return `const __rxEvents=${JSON.stringify(eventNames)};
|
|
139
|
+
const __rxRuntime=${JSON.stringify(runtimeSrc)};
|
|
140
|
+
const __rxDeferEnhancements=${options.deferEnhancements === true};
|
|
141
|
+
const __rxDeferVueIslands=${options.deferVueIslands === true};
|
|
142
|
+
const __rxCleanups=[];
|
|
143
|
+
let __rxActive=true;
|
|
144
|
+
let __rxRuntimePromise;
|
|
145
|
+
let __rxRuntimeAttempt=0;
|
|
146
|
+
function __rxFindTarget(start,attr){
|
|
147
|
+
let node=start && start.nodeType===1 ? start : start && start.parentElement;
|
|
148
|
+
while(node){
|
|
149
|
+
if(typeof node.hasAttribute==="function" && node.hasAttribute(attr)) return node;
|
|
150
|
+
node=node.parentElement;
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
function __rxMods(target,name){
|
|
155
|
+
const raw=target && target.getAttribute ? target.getAttribute("data-rx-mod-"+name) : "";
|
|
156
|
+
return raw ? raw.split(",").map((value)=>value.trim()).filter(Boolean) : [];
|
|
157
|
+
}
|
|
158
|
+
function __rxMouseMatches(event,mods){
|
|
159
|
+
const buttons=mods.filter((mod)=>mod==="left" || mod==="middle" || mod==="right");
|
|
160
|
+
if(!buttons.length) return true;
|
|
161
|
+
return buttons.some((mod)=>mod==="left" ? event.button===0 : mod==="middle" ? event.button===1 : event.button===2);
|
|
162
|
+
}
|
|
163
|
+
function __rxKeyMatches(event,mods){
|
|
164
|
+
const aliases={enter:"Enter",tab:"Tab",delete:["Delete","Backspace"],esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"};
|
|
165
|
+
const keys=mods.filter((mod)=>Object.prototype.hasOwnProperty.call(aliases,mod));
|
|
166
|
+
if(!keys.length) return true;
|
|
167
|
+
return keys.some((mod)=>{
|
|
168
|
+
const expected=aliases[mod];
|
|
169
|
+
return Array.isArray(expected) ? expected.includes(event.key) : event.key===expected;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function __rxMatches(event,mods,name,target){
|
|
173
|
+
if(mods.includes("self") && event.target!==target) return false;
|
|
174
|
+
if(mods.includes("ctrl") && !event.ctrlKey) return false;
|
|
175
|
+
if(mods.includes("shift") && !event.shiftKey) return false;
|
|
176
|
+
if(mods.includes("alt") && !event.altKey) return false;
|
|
177
|
+
if(mods.includes("meta") && !event.metaKey) return false;
|
|
178
|
+
if(mods.includes("exact")){
|
|
179
|
+
const expected=new Set(mods.filter((mod)=>mod==="ctrl" || mod==="shift" || mod==="alt" || mod==="meta"));
|
|
180
|
+
if(event.ctrlKey!==expected.has("ctrl")) return false;
|
|
181
|
+
if(event.shiftKey!==expected.has("shift")) return false;
|
|
182
|
+
if(event.altKey!==expected.has("alt")) return false;
|
|
183
|
+
if(event.metaKey!==expected.has("meta")) return false;
|
|
184
|
+
}
|
|
185
|
+
if((name==="click" || name==="mousedown" || name==="mouseup") && !__rxMouseMatches(event,mods)) return false;
|
|
186
|
+
if(name.startsWith("key") && !__rxKeyMatches(event,mods)) return false;
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
function __rxCleanup(){
|
|
190
|
+
if(!__rxActive) return;
|
|
191
|
+
__rxActive=false;
|
|
192
|
+
while(__rxCleanups.length) __rxCleanups.pop()();
|
|
193
|
+
}
|
|
194
|
+
function __rxRuntimeRequest(){
|
|
195
|
+
if(__rxRuntimeAttempt===0) return __rxRuntime;
|
|
196
|
+
const separator=__rxRuntime.includes("?") ? "&" : "?";
|
|
197
|
+
return __rxRuntime+separator+"rx_retry="+__rxRuntimeAttempt;
|
|
198
|
+
}
|
|
199
|
+
function __rxLoad(){
|
|
200
|
+
if(!__rxRuntimePromise){
|
|
201
|
+
const request=__rxRuntimeRequest();
|
|
202
|
+
__rxRuntimePromise=import(request).catch((error)=>{
|
|
203
|
+
__rxRuntimePromise=undefined;
|
|
204
|
+
__rxRuntimeAttempt+=1;
|
|
205
|
+
throw error;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return __rxRuntimePromise;
|
|
209
|
+
}
|
|
210
|
+
function __rxCapture(name){
|
|
211
|
+
return name==="focus"
|
|
212
|
+
|| name==="blur"
|
|
213
|
+
|| name==="mouseenter"
|
|
214
|
+
|| name==="mouseleave"
|
|
215
|
+
|| name==="pointerenter"
|
|
216
|
+
|| name==="pointerleave"
|
|
217
|
+
|| name==="load"
|
|
218
|
+
|| name==="error"
|
|
219
|
+
|| name==="loadstart"
|
|
220
|
+
|| name==="loadedmetadata"
|
|
221
|
+
|| name==="loadeddata"
|
|
222
|
+
|| name==="canplay"
|
|
223
|
+
|| name==="lazy-load-start"
|
|
224
|
+
|| name==="lazy-load-complete"
|
|
225
|
+
|| name==="invalid";
|
|
226
|
+
}
|
|
227
|
+
function __rxNormalizeTrigger(value,fallback){
|
|
228
|
+
const trigger=String(value || "").trim();
|
|
229
|
+
return trigger==="visible" || trigger==="interaction" || trigger==="idle" || trigger==="immediate" || trigger==="manual" || trigger==="page-load"
|
|
230
|
+
? trigger
|
|
231
|
+
: fallback;
|
|
232
|
+
}
|
|
233
|
+
function __rxActivateTarget(target){
|
|
234
|
+
const activate=globalThis.__RESUX_ACTIVATE_DEFERRED_TARGET__;
|
|
235
|
+
return typeof activate==="function" ? Promise.resolve(activate(target)) : Promise.resolve(false);
|
|
236
|
+
}
|
|
237
|
+
async function __rxActivateManual(targetOrSelector){
|
|
238
|
+
const target=typeof targetOrSelector==="string" ? document.querySelector(targetOrSelector) : targetOrSelector;
|
|
239
|
+
if(!target) return false;
|
|
240
|
+
await __rxLoad();
|
|
241
|
+
const activated=await __rxActivateTarget(target);
|
|
242
|
+
__rxCleanup();
|
|
243
|
+
return activated;
|
|
244
|
+
}
|
|
245
|
+
globalThis.__RESUX_ACTIVATE_DEFERRED__=__rxActivateManual;
|
|
246
|
+
__rxCleanups.push(()=>{
|
|
247
|
+
if(globalThis.__RESUX_ACTIVATE_DEFERRED__===__rxActivateManual){
|
|
248
|
+
delete globalThis.__RESUX_ACTIVATE_DEFERRED__;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
function __rxInteractionPath(boundary,eventTarget){
|
|
252
|
+
const path=[];
|
|
253
|
+
let node=eventTarget && eventTarget.nodeType===1 ? eventTarget : boundary;
|
|
254
|
+
while(node && node!==boundary){
|
|
255
|
+
const parent=node.parentElement;
|
|
256
|
+
if(!parent) return [];
|
|
257
|
+
const index=Array.prototype.indexOf.call(parent.children,node);
|
|
258
|
+
if(index<0) return [];
|
|
259
|
+
path.push(index);
|
|
260
|
+
node=parent;
|
|
261
|
+
}
|
|
262
|
+
return node===boundary ? path.reverse() : [];
|
|
263
|
+
}
|
|
264
|
+
function __rxCaptureInteraction(boundary,event){
|
|
265
|
+
if(!event) return null;
|
|
266
|
+
if(event.type==="click" && event.cancelable){
|
|
267
|
+
event.preventDefault();
|
|
268
|
+
event.stopImmediatePropagation();
|
|
269
|
+
}else if(event.type==="focusin" || event.type==="keydown"){
|
|
270
|
+
event.stopPropagation();
|
|
271
|
+
}
|
|
272
|
+
return {event,path:__rxInteractionPath(boundary,event.target)};
|
|
273
|
+
}
|
|
274
|
+
function __rxResolveInteractionTarget(boundary,interaction){
|
|
275
|
+
let node=boundary;
|
|
276
|
+
for(const index of interaction.path){
|
|
277
|
+
const child=node.children && node.children[index];
|
|
278
|
+
if(!child) return boundary;
|
|
279
|
+
node=child;
|
|
280
|
+
}
|
|
281
|
+
return node;
|
|
282
|
+
}
|
|
283
|
+
function __rxReplayInteraction(boundary,interaction){
|
|
284
|
+
if(!interaction) return;
|
|
285
|
+
const replayTarget=__rxResolveInteractionTarget(boundary,interaction);
|
|
286
|
+
if(!replayTarget || !replayTarget.isConnected) return;
|
|
287
|
+
if(interaction.event.type==="click" && typeof replayTarget.click==="function"){
|
|
288
|
+
replayTarget.click();
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if(
|
|
292
|
+
interaction.event.type==="focusin"
|
|
293
|
+
&& typeof replayTarget.focus==="function"
|
|
294
|
+
&& document.activeElement!==replayTarget
|
|
295
|
+
){
|
|
296
|
+
replayTarget.focus();
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
let replay;
|
|
300
|
+
try{
|
|
301
|
+
replay=new interaction.event.constructor(interaction.event.type,interaction.event);
|
|
302
|
+
}catch{
|
|
303
|
+
replay=new Event(interaction.event.type,{
|
|
304
|
+
bubbles:interaction.event.bubbles,
|
|
305
|
+
cancelable:interaction.event.cancelable,
|
|
306
|
+
composed:interaction.event.composed
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
replayTarget.dispatchEvent(replay);
|
|
310
|
+
}
|
|
311
|
+
function __rxFindInteractionBoundary(start){
|
|
312
|
+
let current=start && start.nodeType===1 ? start : start && start.parentElement;
|
|
313
|
+
while(current){
|
|
314
|
+
if(
|
|
315
|
+
current.hasAttribute
|
|
316
|
+
&& current.hasAttribute("data-rx-vue-island")
|
|
317
|
+
&& __rxNormalizeTrigger(current.getAttribute("data-rx-vue-trigger"),"immediate")==="interaction"
|
|
318
|
+
){
|
|
319
|
+
return current;
|
|
320
|
+
}
|
|
321
|
+
if(current.matches && current.matches("[data-resux-enhancement], [use-client-enhancement]")){
|
|
322
|
+
const trigger=__rxNormalizeTrigger(
|
|
323
|
+
current.getAttribute("data-resux-trigger") || current.getAttribute("data-trigger") || current.getAttribute("trigger"),
|
|
324
|
+
"visible"
|
|
325
|
+
);
|
|
326
|
+
if(trigger==="interaction") return current;
|
|
327
|
+
}
|
|
328
|
+
current=current.parentElement;
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
function __rxScheduleTarget(target,trigger){
|
|
333
|
+
if(!target || trigger==="manual") return;
|
|
334
|
+
let disposed=false;
|
|
335
|
+
let activating=false;
|
|
336
|
+
let interactions=[];
|
|
337
|
+
let cancel=()=>{};
|
|
338
|
+
const setCancel=(next)=>{
|
|
339
|
+
cancel();
|
|
340
|
+
cancel=typeof next==="function" ? next : ()=>{};
|
|
341
|
+
};
|
|
342
|
+
const fire=(interaction)=>{
|
|
343
|
+
if(interaction) interactions.push(interaction);
|
|
344
|
+
if(disposed || !__rxActive || !target.isConnected || activating) return;
|
|
345
|
+
activating=true;
|
|
346
|
+
if(!interaction) setCancel();
|
|
347
|
+
void __rxLoad()
|
|
348
|
+
.then(async()=>{
|
|
349
|
+
await __rxActivateTarget(target);
|
|
350
|
+
const queuedInteractions=interactions;
|
|
351
|
+
interactions=[];
|
|
352
|
+
setCancel();
|
|
353
|
+
for(const queuedInteraction of queuedInteractions){
|
|
354
|
+
__rxReplayInteraction(target,queuedInteraction);
|
|
355
|
+
}
|
|
356
|
+
__rxCleanup();
|
|
357
|
+
})
|
|
358
|
+
.catch(()=>{
|
|
359
|
+
activating=false;
|
|
360
|
+
interactions=[];
|
|
361
|
+
if(disposed || !__rxActive || !target.isConnected) return;
|
|
362
|
+
const retryId=window.setTimeout(()=>{
|
|
363
|
+
if(!disposed && __rxActive && target.isConnected) arm();
|
|
364
|
+
},250);
|
|
365
|
+
setCancel(()=>window.clearTimeout(retryId));
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
const scheduleTimeout=(delay=0)=>{
|
|
369
|
+
const id=window.setTimeout(()=>fire(),delay);
|
|
370
|
+
setCancel(()=>window.clearTimeout(id));
|
|
371
|
+
};
|
|
372
|
+
const arm=()=>{
|
|
373
|
+
if(disposed || !__rxActive || !target.isConnected) return;
|
|
374
|
+
if(trigger==="immediate"){
|
|
375
|
+
scheduleTimeout();
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if(trigger==="page-load"){
|
|
379
|
+
if(document.readyState==="complete"){
|
|
380
|
+
scheduleTimeout();
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const onLoad=()=>fire();
|
|
384
|
+
window.addEventListener("load",onLoad,{once:true});
|
|
385
|
+
setCancel(()=>window.removeEventListener("load",onLoad));
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if(trigger==="idle"){
|
|
389
|
+
if(typeof window.requestIdleCallback==="function"){
|
|
390
|
+
const id=window.requestIdleCallback(()=>fire());
|
|
391
|
+
setCancel(()=>window.cancelIdleCallback && window.cancelIdleCallback(id));
|
|
392
|
+
}else{
|
|
393
|
+
scheduleTimeout(32);
|
|
394
|
+
}
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if(trigger==="interaction"){
|
|
398
|
+
const events=["click","focusin","keydown"];
|
|
399
|
+
const onInteraction=(event)=>{
|
|
400
|
+
fire(__rxCaptureInteraction(target,event));
|
|
401
|
+
};
|
|
402
|
+
for(const eventName of events){
|
|
403
|
+
target.addEventListener(eventName,onInteraction,{capture:true});
|
|
404
|
+
}
|
|
405
|
+
setCancel(()=>{
|
|
406
|
+
for(const eventName of events){
|
|
407
|
+
target.removeEventListener(eventName,onInteraction,true);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if(trigger==="visible"){
|
|
413
|
+
if(typeof IntersectionObserver!=="function"){
|
|
414
|
+
scheduleTimeout();
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const observer=new IntersectionObserver((entries)=>{
|
|
418
|
+
if(entries.some((entry)=>entry.isIntersecting)){
|
|
419
|
+
observer.disconnect();
|
|
420
|
+
fire();
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
observer.observe(target);
|
|
424
|
+
setCancel(()=>observer.disconnect());
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
arm();
|
|
428
|
+
__rxCleanups.push(()=>{
|
|
429
|
+
disposed=true;
|
|
430
|
+
cancel();
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
function __rxScheduleDeferredTargets(){
|
|
434
|
+
if(__rxDeferEnhancements){
|
|
435
|
+
for(const target of document.querySelectorAll("[data-resux-enhancement], [use-client-enhancement]")){
|
|
436
|
+
const trigger=__rxNormalizeTrigger(
|
|
437
|
+
target.getAttribute("data-resux-trigger") || target.getAttribute("data-trigger") || target.getAttribute("trigger"),
|
|
438
|
+
"visible"
|
|
439
|
+
);
|
|
440
|
+
__rxScheduleTarget(target,trigger);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if(__rxDeferVueIslands){
|
|
444
|
+
for(const target of document.querySelectorAll("[data-rx-vue-island]")){
|
|
445
|
+
const trigger=__rxNormalizeTrigger(target.getAttribute("data-rx-vue-trigger"),"immediate");
|
|
446
|
+
__rxScheduleTarget(target,trigger);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
for(const name of __rxEvents){
|
|
451
|
+
const listener=(event)=>{
|
|
452
|
+
if(!__rxActive) return;
|
|
453
|
+
if(
|
|
454
|
+
(name==="click" || name==="focusin" || name==="keydown")
|
|
455
|
+
&& __rxFindInteractionBoundary(event.target)
|
|
456
|
+
) return;
|
|
457
|
+
const target=__rxFindTarget(event.target,"data-rx-on-"+name);
|
|
458
|
+
if(!target) return;
|
|
459
|
+
const mods=__rxMods(target,name);
|
|
460
|
+
if(!__rxMatches(event,mods,name,target)) return;
|
|
461
|
+
if((name==="submit" || mods.includes("prevent")) && !mods.includes("passive") && event.cancelable){
|
|
462
|
+
event.preventDefault();
|
|
463
|
+
}
|
|
464
|
+
if(mods.includes("stop")) event.stopPropagation();
|
|
465
|
+
void __rxLoad().then(()=>{
|
|
466
|
+
const dispatch=globalThis.__RESUX_DISPATCH_RESUMED_EVENT__;
|
|
467
|
+
const result=typeof dispatch==="function" ? dispatch(name,event) : undefined;
|
|
468
|
+
__rxCleanup();
|
|
469
|
+
return result;
|
|
470
|
+
}).catch(()=>{});
|
|
471
|
+
};
|
|
472
|
+
const useCapture=__rxCapture(name);
|
|
473
|
+
document.addEventListener(name,listener,useCapture);
|
|
474
|
+
__rxCleanups.push(()=>document.removeEventListener(name,listener,useCapture));
|
|
475
|
+
}
|
|
476
|
+
__rxScheduleDeferredTargets();
|
|
477
|
+
`;
|
|
478
|
+
}
|
|
479
|
+
//#endregion
|
|
480
|
+
export { RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAMES, RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAME_LENGTH, ResuxResumeHandlerRegistry, ResuxResumeLoadTimeoutError, createResumeHandlerRegistry, getResumeBootstrapSource };
|
|
481
|
+
|
|
482
|
+
//# sourceMappingURL=resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.js","names":[],"sources":["../../src/runtime/resume.ts"],"sourcesContent":["export type ResuxResumeHandler = (...args: unknown[]) => unknown | Promise<unknown>;\nexport type ResuxResumeModule = Record<string, unknown>;\n\nexport interface ResuxResumeLoadContext {\n /** Aborted when the configured handler-load deadline expires. */\n signal: AbortSignal;\n}\n\nexport type ResuxResumeModuleLoader = (\n context?: ResuxResumeLoadContext,\n) => Promise<ResuxResumeModule>;\n\nexport interface ResuxResumeManifestEntry {\n id: string;\n module: string;\n exportName: string;\n}\n\nexport interface ResuxResumeRegistration extends ResuxResumeManifestEntry {\n load: ResuxResumeModuleLoader;\n}\n\nexport interface ResuxResumeRegistryOptions {\n /**\n * Maximum time to wait for one lazy handler module. Set to 0 to disable the\n * deadline. Defaults to 30 seconds so a broken chunk request cannot leave an\n * interaction pending forever.\n */\n loadTimeoutMs?: number;\n}\n\nconst DEFAULT_RESUME_LOAD_TIMEOUT_MS = 30_000;\nconst MAX_RESUME_LOAD_TIMEOUT_MS = 2_147_483_647;\n\nexport class ResuxResumeLoadTimeoutError extends Error {\n readonly handlerId: string;\n readonly timeoutMs: number;\n\n constructor(handlerId: string, timeoutMs: number) {\n super(`Timed out loading resumable handler ${handlerId} after ${timeoutMs}ms.`);\n this.name = \"ResuxResumeLoadTimeoutError\";\n this.handlerId = handlerId;\n this.timeoutMs = timeoutMs;\n }\n}\n\nfunction normalizeLoadTimeout(value: number | undefined): number {\n const timeoutMs = value ?? DEFAULT_RESUME_LOAD_TIMEOUT_MS;\n if (!Number.isFinite(timeoutMs) || timeoutMs < 0 || timeoutMs > MAX_RESUME_LOAD_TIMEOUT_MS) {\n throw new RangeError(\n `loadTimeoutMs must be a finite non-negative number no greater than ${MAX_RESUME_LOAD_TIMEOUT_MS}.`,\n );\n }\n return timeoutMs;\n}\n\n/**\n * Lazily resolves resumable handlers from manifest-style registrations.\n * Resolved handlers are cached, concurrent loads are deduplicated, and replacing\n * a registration invalidates both cached and in-flight state for that handler id.\n * Handler loads are deadline-bound by default so one failed chunk cannot leave an\n * interaction pending forever.\n */\nexport class ResuxResumeHandlerRegistry {\n readonly #entries = new Map<string, ResuxResumeRegistration>();\n readonly #generations = new Map<string, number>();\n readonly #handlers = new Map<string, ResuxResumeHandler>();\n readonly #pending = new Map<string, Promise<ResuxResumeHandler>>();\n readonly #loadTimeoutMs: number;\n\n constructor(options: ResuxResumeRegistryOptions = {}) {\n this.#loadTimeoutMs = normalizeLoadTimeout(options.loadTimeoutMs);\n }\n\n /** Registers or replaces one resumable handler definition. */\n register(entry: ResuxResumeRegistration): void {\n if (!entry.id) throw new Error(\"Resume handler id must not be empty.\");\n if (!entry.exportName) throw new Error(`Resume handler ${entry.id} must declare an export name.`);\n\n const storedEntry: ResuxResumeRegistration = {\n id: entry.id,\n module: entry.module,\n exportName: entry.exportName,\n load: entry.load,\n };\n\n this.#entries.set(storedEntry.id, storedEntry);\n this.#generations.set(storedEntry.id, (this.#generations.get(storedEntry.id) ?? 0) + 1);\n this.#handlers.delete(storedEntry.id);\n this.#pending.delete(storedEntry.id);\n }\n\n /** Registers multiple resumable handler definitions in order. */\n registerMany(entries: ResuxResumeRegistration[]): void {\n for (const entry of entries) this.register(entry);\n }\n\n /** Returns whether the registry knows about a handler id. */\n has(id: string): boolean {\n return this.#entries.has(id);\n }\n\n /** Loads one module with a deadline and exposes cancellation to cooperative loaders. */\n async #loadModule(id: string, entry: ResuxResumeRegistration): Promise<ResuxResumeModule> {\n const controller = new AbortController();\n let timeout: ReturnType<typeof setTimeout> | undefined;\n\n // Promise executors run synchronously. Resolving with the loader's returned\n // promise adopts its eventual state, while a synchronous loader throw is\n // converted into a rejection by the Promise constructor itself.\n const modulePromise = new Promise<ResuxResumeModule>((resolve) => {\n resolve(entry.load({ signal: controller.signal }));\n });\n\n if (this.#loadTimeoutMs === 0) return await modulePromise;\n\n const timeoutPromise = new Promise<never>((_resolve, reject) => {\n timeout = setTimeout(() => {\n const error = new ResuxResumeLoadTimeoutError(id, this.#loadTimeoutMs);\n // Reject the registry deadline first so a cooperative loader cannot replace\n // the stable timeout error with its own abort error in the Promise race.\n reject(error);\n controller.abort(error);\n }, this.#loadTimeoutMs);\n });\n\n try {\n return await Promise.race([modulePromise, timeoutPromise]);\n } finally {\n if (timeout !== undefined) clearTimeout(timeout);\n }\n }\n\n /**\n * Resolves one handler lazily, reusing cached handlers and deduplicating active loads.\n * A load that started before a replacement may still resolve for its original caller,\n * but it cannot overwrite the newer registration or its cache. Timed-out loads follow\n * the same rule: a late underlying module resolution cannot populate the handler cache.\n */\n async load(id: string): Promise<ResuxResumeHandler> {\n const cached = this.#handlers.get(id);\n if (cached) return cached;\n\n const active = this.#pending.get(id);\n if (active) return active;\n\n const entry = this.#entries.get(id);\n if (!entry) throw new Error(`Unknown resumable handler ${id}.`);\n const generation = this.#generations.get(id);\n\n const pending = this.#loadModule(id, entry).then((module) => {\n const hasExport = Object.hasOwn(module, entry.exportName);\n const handler = hasExport ? module[entry.exportName] : undefined;\n if (typeof handler !== \"function\") {\n throw new Error(\n `Resumable handler ${id} expected function export ${entry.exportName} from ${entry.module}.`,\n );\n }\n\n const resolved = handler as ResuxResumeHandler;\n if (this.#generations.get(id) === generation) {\n this.#handlers.set(id, resolved);\n }\n return resolved;\n });\n\n if (this.#generations.get(id) === generation) {\n this.#pending.set(id, pending);\n }\n try {\n return await pending;\n } finally {\n if (this.#pending.get(id) === pending) {\n this.#pending.delete(id);\n }\n }\n }\n\n /** Loads and executes one resumable handler with the provided arguments. */\n async run(id: string, ...args: unknown[]): Promise<unknown> {\n const handler = await this.load(id);\n return handler(...args);\n }\n\n /** Loads and caches one handler without executing it. */\n preload(id: string): Promise<void> {\n return this.load(id).then(() => undefined);\n }\n}\n\n/** Creates a registry and seeds it with optional manifest registrations. */\nexport function createResumeHandlerRegistry(\n entries: ResuxResumeRegistration[] = [],\n options: ResuxResumeRegistryOptions = {},\n): ResuxResumeHandlerRegistry {\n const registry = new ResuxResumeHandlerRegistry(options);\n registry.registerMany(entries);\n return registry;\n}\n\n\nexport const RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAMES = 32;\nexport const RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAME_LENGTH = 64;\n\nexport interface ResuxResumeBootstrapOptions {\n eventNames: string[];\n runtimeSrc?: string;\n deferEnhancements?: boolean;\n deferVueIslands?: boolean;\n}\n\n/**\n * Generates the tiny browser bootstrap used by Resume-First documents.\n *\n * It registers only the event types present in the server HTML, preserves\n * synchronous prevent/stop modifiers while the runtime is absent, imports the\n * full client runtime once on first interaction, then hands the original event\n * to the runtime's resumable-event dispatcher. Normal links are intentionally\n * left to the browser until Resux has a reason to resume.\n */\nexport function getResumeBootstrapSource(options: ResuxResumeBootstrapOptions): string {\n const eventNames = [...new Set(\n options.eventNames\n .map((name) => String(name || \"\").trim())\n .filter((name) => /^[\\w:-]+$/.test(name)),\n )];\n if (eventNames.length > RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAMES) {\n throw new RangeError(\n `Resume bootstrap supports at most ${RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAMES} distinct event types.`,\n );\n }\n const oversizedEventName = eventNames.find(\n (name) => name.length > RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAME_LENGTH,\n );\n if (oversizedEventName) {\n throw new RangeError(\n `Resume bootstrap event names must be at most ${RESUX_RESUME_BOOTSTRAP_MAX_EVENT_NAME_LENGTH} characters.`,\n );\n }\n const runtimeSrc = options.runtimeSrc?.trim() || \"/__resux/runtime-client.mjs\";\n\n return `const __rxEvents=${JSON.stringify(eventNames)};\nconst __rxRuntime=${JSON.stringify(runtimeSrc)};\nconst __rxDeferEnhancements=${options.deferEnhancements === true};\nconst __rxDeferVueIslands=${options.deferVueIslands === true};\nconst __rxCleanups=[];\nlet __rxActive=true;\nlet __rxRuntimePromise;\nlet __rxRuntimeAttempt=0;\nfunction __rxFindTarget(start,attr){\n let node=start && start.nodeType===1 ? start : start && start.parentElement;\n while(node){\n if(typeof node.hasAttribute===\"function\" && node.hasAttribute(attr)) return node;\n node=node.parentElement;\n }\n return null;\n}\nfunction __rxMods(target,name){\n const raw=target && target.getAttribute ? target.getAttribute(\"data-rx-mod-\"+name) : \"\";\n return raw ? raw.split(\",\").map((value)=>value.trim()).filter(Boolean) : [];\n}\nfunction __rxMouseMatches(event,mods){\n const buttons=mods.filter((mod)=>mod===\"left\" || mod===\"middle\" || mod===\"right\");\n if(!buttons.length) return true;\n return buttons.some((mod)=>mod===\"left\" ? event.button===0 : mod===\"middle\" ? event.button===1 : event.button===2);\n}\nfunction __rxKeyMatches(event,mods){\n const aliases={enter:\"Enter\",tab:\"Tab\",delete:[\"Delete\",\"Backspace\"],esc:\"Escape\",escape:\"Escape\",space:\" \",up:\"ArrowUp\",down:\"ArrowDown\",left:\"ArrowLeft\",right:\"ArrowRight\"};\n const keys=mods.filter((mod)=>Object.prototype.hasOwnProperty.call(aliases,mod));\n if(!keys.length) return true;\n return keys.some((mod)=>{\n const expected=aliases[mod];\n return Array.isArray(expected) ? expected.includes(event.key) : event.key===expected;\n });\n}\nfunction __rxMatches(event,mods,name,target){\n if(mods.includes(\"self\") && event.target!==target) return false;\n if(mods.includes(\"ctrl\") && !event.ctrlKey) return false;\n if(mods.includes(\"shift\") && !event.shiftKey) return false;\n if(mods.includes(\"alt\") && !event.altKey) return false;\n if(mods.includes(\"meta\") && !event.metaKey) return false;\n if(mods.includes(\"exact\")){\n const expected=new Set(mods.filter((mod)=>mod===\"ctrl\" || mod===\"shift\" || mod===\"alt\" || mod===\"meta\"));\n if(event.ctrlKey!==expected.has(\"ctrl\")) return false;\n if(event.shiftKey!==expected.has(\"shift\")) return false;\n if(event.altKey!==expected.has(\"alt\")) return false;\n if(event.metaKey!==expected.has(\"meta\")) return false;\n }\n if((name===\"click\" || name===\"mousedown\" || name===\"mouseup\") && !__rxMouseMatches(event,mods)) return false;\n if(name.startsWith(\"key\") && !__rxKeyMatches(event,mods)) return false;\n return true;\n}\nfunction __rxCleanup(){\n if(!__rxActive) return;\n __rxActive=false;\n while(__rxCleanups.length) __rxCleanups.pop()();\n}\nfunction __rxRuntimeRequest(){\n if(__rxRuntimeAttempt===0) return __rxRuntime;\n const separator=__rxRuntime.includes(\"?\") ? \"&\" : \"?\";\n return __rxRuntime+separator+\"rx_retry=\"+__rxRuntimeAttempt;\n}\nfunction __rxLoad(){\n if(!__rxRuntimePromise){\n const request=__rxRuntimeRequest();\n __rxRuntimePromise=import(request).catch((error)=>{\n __rxRuntimePromise=undefined;\n __rxRuntimeAttempt+=1;\n throw error;\n });\n }\n return __rxRuntimePromise;\n}\nfunction __rxCapture(name){\n return name===\"focus\"\n || name===\"blur\"\n || name===\"mouseenter\"\n || name===\"mouseleave\"\n || name===\"pointerenter\"\n || name===\"pointerleave\"\n || name===\"load\"\n || name===\"error\"\n || name===\"loadstart\"\n || name===\"loadedmetadata\"\n || name===\"loadeddata\"\n || name===\"canplay\"\n || name===\"lazy-load-start\"\n || name===\"lazy-load-complete\"\n || name===\"invalid\";\n}\nfunction __rxNormalizeTrigger(value,fallback){\n const trigger=String(value || \"\").trim();\n return trigger===\"visible\" || trigger===\"interaction\" || trigger===\"idle\" || trigger===\"immediate\" || trigger===\"manual\" || trigger===\"page-load\"\n ? trigger\n : fallback;\n}\nfunction __rxActivateTarget(target){\n const activate=globalThis.__RESUX_ACTIVATE_DEFERRED_TARGET__;\n return typeof activate===\"function\" ? Promise.resolve(activate(target)) : Promise.resolve(false);\n}\nasync function __rxActivateManual(targetOrSelector){\n const target=typeof targetOrSelector===\"string\" ? document.querySelector(targetOrSelector) : targetOrSelector;\n if(!target) return false;\n await __rxLoad();\n const activated=await __rxActivateTarget(target);\n __rxCleanup();\n return activated;\n}\nglobalThis.__RESUX_ACTIVATE_DEFERRED__=__rxActivateManual;\n__rxCleanups.push(()=>{\n if(globalThis.__RESUX_ACTIVATE_DEFERRED__===__rxActivateManual){\n delete globalThis.__RESUX_ACTIVATE_DEFERRED__;\n }\n});\nfunction __rxInteractionPath(boundary,eventTarget){\n const path=[];\n let node=eventTarget && eventTarget.nodeType===1 ? eventTarget : boundary;\n while(node && node!==boundary){\n const parent=node.parentElement;\n if(!parent) return [];\n const index=Array.prototype.indexOf.call(parent.children,node);\n if(index<0) return [];\n path.push(index);\n node=parent;\n }\n return node===boundary ? path.reverse() : [];\n}\nfunction __rxCaptureInteraction(boundary,event){\n if(!event) return null;\n if(event.type===\"click\" && event.cancelable){\n event.preventDefault();\n event.stopImmediatePropagation();\n }else if(event.type===\"focusin\" || event.type===\"keydown\"){\n event.stopPropagation();\n }\n return {event,path:__rxInteractionPath(boundary,event.target)};\n}\nfunction __rxResolveInteractionTarget(boundary,interaction){\n let node=boundary;\n for(const index of interaction.path){\n const child=node.children && node.children[index];\n if(!child) return boundary;\n node=child;\n }\n return node;\n}\nfunction __rxReplayInteraction(boundary,interaction){\n if(!interaction) return;\n const replayTarget=__rxResolveInteractionTarget(boundary,interaction);\n if(!replayTarget || !replayTarget.isConnected) return;\n if(interaction.event.type===\"click\" && typeof replayTarget.click===\"function\"){\n replayTarget.click();\n return;\n }\n if(\n interaction.event.type===\"focusin\"\n && typeof replayTarget.focus===\"function\"\n && document.activeElement!==replayTarget\n ){\n replayTarget.focus();\n return;\n }\n let replay;\n try{\n replay=new interaction.event.constructor(interaction.event.type,interaction.event);\n }catch{\n replay=new Event(interaction.event.type,{\n bubbles:interaction.event.bubbles,\n cancelable:interaction.event.cancelable,\n composed:interaction.event.composed\n });\n }\n replayTarget.dispatchEvent(replay);\n}\nfunction __rxFindInteractionBoundary(start){\n let current=start && start.nodeType===1 ? start : start && start.parentElement;\n while(current){\n if(\n current.hasAttribute\n && current.hasAttribute(\"data-rx-vue-island\")\n && __rxNormalizeTrigger(current.getAttribute(\"data-rx-vue-trigger\"),\"immediate\")===\"interaction\"\n ){\n return current;\n }\n if(current.matches && current.matches(\"[data-resux-enhancement], [use-client-enhancement]\")){\n const trigger=__rxNormalizeTrigger(\n current.getAttribute(\"data-resux-trigger\") || current.getAttribute(\"data-trigger\") || current.getAttribute(\"trigger\"),\n \"visible\"\n );\n if(trigger===\"interaction\") return current;\n }\n current=current.parentElement;\n }\n return null;\n}\nfunction __rxScheduleTarget(target,trigger){\n if(!target || trigger===\"manual\") return;\n let disposed=false;\n let activating=false;\n let interactions=[];\n let cancel=()=>{};\n const setCancel=(next)=>{\n cancel();\n cancel=typeof next===\"function\" ? next : ()=>{};\n };\n const fire=(interaction)=>{\n if(interaction) interactions.push(interaction);\n if(disposed || !__rxActive || !target.isConnected || activating) return;\n activating=true;\n if(!interaction) setCancel();\n void __rxLoad()\n .then(async()=>{\n await __rxActivateTarget(target);\n const queuedInteractions=interactions;\n interactions=[];\n setCancel();\n for(const queuedInteraction of queuedInteractions){\n __rxReplayInteraction(target,queuedInteraction);\n }\n __rxCleanup();\n })\n .catch(()=>{\n activating=false;\n interactions=[];\n if(disposed || !__rxActive || !target.isConnected) return;\n const retryId=window.setTimeout(()=>{\n if(!disposed && __rxActive && target.isConnected) arm();\n },250);\n setCancel(()=>window.clearTimeout(retryId));\n });\n };\n const scheduleTimeout=(delay=0)=>{\n const id=window.setTimeout(()=>fire(),delay);\n setCancel(()=>window.clearTimeout(id));\n };\n const arm=()=>{\n if(disposed || !__rxActive || !target.isConnected) return;\n if(trigger===\"immediate\"){\n scheduleTimeout();\n return;\n }\n if(trigger===\"page-load\"){\n if(document.readyState===\"complete\"){\n scheduleTimeout();\n return;\n }\n const onLoad=()=>fire();\n window.addEventListener(\"load\",onLoad,{once:true});\n setCancel(()=>window.removeEventListener(\"load\",onLoad));\n return;\n }\n if(trigger===\"idle\"){\n if(typeof window.requestIdleCallback===\"function\"){\n const id=window.requestIdleCallback(()=>fire());\n setCancel(()=>window.cancelIdleCallback && window.cancelIdleCallback(id));\n }else{\n scheduleTimeout(32);\n }\n return;\n }\n if(trigger===\"interaction\"){\n const events=[\"click\",\"focusin\",\"keydown\"];\n const onInteraction=(event)=>{\n fire(__rxCaptureInteraction(target,event));\n };\n for(const eventName of events){\n target.addEventListener(eventName,onInteraction,{capture:true});\n }\n setCancel(()=>{\n for(const eventName of events){\n target.removeEventListener(eventName,onInteraction,true);\n }\n });\n return;\n }\n if(trigger===\"visible\"){\n if(typeof IntersectionObserver!==\"function\"){\n scheduleTimeout();\n return;\n }\n const observer=new IntersectionObserver((entries)=>{\n if(entries.some((entry)=>entry.isIntersecting)){\n observer.disconnect();\n fire();\n }\n });\n observer.observe(target);\n setCancel(()=>observer.disconnect());\n }\n };\n arm();\n __rxCleanups.push(()=>{\n disposed=true;\n cancel();\n });\n}\nfunction __rxScheduleDeferredTargets(){\n if(__rxDeferEnhancements){\n for(const target of document.querySelectorAll(\"[data-resux-enhancement], [use-client-enhancement]\")){\n const trigger=__rxNormalizeTrigger(\n target.getAttribute(\"data-resux-trigger\") || target.getAttribute(\"data-trigger\") || target.getAttribute(\"trigger\"),\n \"visible\"\n );\n __rxScheduleTarget(target,trigger);\n }\n }\n if(__rxDeferVueIslands){\n for(const target of document.querySelectorAll(\"[data-rx-vue-island]\")){\n const trigger=__rxNormalizeTrigger(target.getAttribute(\"data-rx-vue-trigger\"),\"immediate\");\n __rxScheduleTarget(target,trigger);\n }\n }\n}\nfor(const name of __rxEvents){\n const listener=(event)=>{\n if(!__rxActive) return;\n if(\n (name===\"click\" || name===\"focusin\" || name===\"keydown\")\n && __rxFindInteractionBoundary(event.target)\n ) return;\n const target=__rxFindTarget(event.target,\"data-rx-on-\"+name);\n if(!target) return;\n const mods=__rxMods(target,name);\n if(!__rxMatches(event,mods,name,target)) return;\n if((name===\"submit\" || mods.includes(\"prevent\")) && !mods.includes(\"passive\") && event.cancelable){\n event.preventDefault();\n }\n if(mods.includes(\"stop\")) event.stopPropagation();\n void __rxLoad().then(()=>{\n const dispatch=globalThis.__RESUX_DISPATCH_RESUMED_EVENT__;\n const result=typeof dispatch===\"function\" ? dispatch(name,event) : undefined;\n __rxCleanup();\n return result;\n }).catch(()=>{});\n };\n const useCapture=__rxCapture(name);\n document.addEventListener(name,listener,useCapture);\n __rxCleanups.push(()=>document.removeEventListener(name,listener,useCapture));\n}\n__rxScheduleDeferredTargets();\n`;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/runtime/router.d.ts
|
|
2
|
+
export interface ResuxClientNavigationOptions {
|
|
3
|
+
replace?: boolean;
|
|
4
|
+
state?: unknown;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Returns whether a target is a same-origin HTTP(S) application navigation.
|
|
8
|
+
* Non-HTTP schemes and protocol-relative targets stay out of SPA history routing.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isLocalClientNavigation(to: string, base?: string): boolean;
|
|
11
|
+
/** Resolves a client target against its current URL and returns path, query, and hash. */
|
|
12
|
+
export declare function normalizeClientPath(to: string, base?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Performs lightweight client navigation for local targets and full-page
|
|
15
|
+
* navigation for external HTTP(S) targets while honoring replace-history semantics.
|
|
16
|
+
* Unsupported schemes such as `javascript:` and `data:` are ignored.
|
|
17
|
+
*/
|
|
18
|
+
export declare function navigateClient(to: string, options?: ResuxClientNavigationOptions): void;
|
|
19
|
+
//#endregion
|
|
20
|
+
//# sourceMappingURL=router.d.ts.map
|