resuxjs 0.4.0-beta.2 → 0.4.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.d.ts +1 -1
- package/dist/bin.js +3 -2
- package/dist/bin.js.map +1 -1
- package/dist/build/index.d.ts +9 -8
- package/dist/build/index.js +2 -2
- package/dist/build/index.js.map +1 -1
- package/dist/cli.d.ts +5 -4
- package/dist/cli.js +115 -127
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapter.d.ts +6 -5
- package/dist/compiler/adapter.js +2 -1
- package/dist/compiler/adapter.js.map +1 -1
- package/dist/compiler/dev-warnings.d.ts +6 -5
- package/dist/compiler/dev-warnings.js +7 -6
- package/dist/compiler/dev-warnings.js.map +1 -1
- package/dist/compiler/directives.d.ts +4 -3
- package/dist/compiler/directives.js +2 -1
- package/dist/compiler/directives.js.map +1 -1
- package/dist/compiler/implementation.d.ts +21 -19
- package/dist/compiler/implementation.js +124 -133
- package/dist/compiler/index.d.ts +6 -5
- package/dist/compiler/index.js +2 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +7 -5
- package/dist/core/config.js +1 -1
- package/dist/core/config.js.map +1 -1
- package/dist/core/hooks.d.ts +7 -6
- package/dist/core/hooks.js +1 -1
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/module-container.d.ts +22 -20
- package/dist/core/module-container.js +3 -3
- package/dist/core/module-container.js.map +1 -1
- package/dist/core/resux.d.ts +5 -3
- package/dist/core/resux.js +2 -1
- package/dist/core/resux.js.map +1 -1
- package/dist/create-bin.d.ts +1 -1
- package/dist/create-bin.js +3 -2
- package/dist/create-bin.js.map +1 -1
- package/dist/create.d.ts +3 -2
- package/dist/create.js +7 -10
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +3 -1
- package/dist/deploy/cloudflare.js +2 -1
- package/dist/deploy/cloudflare.js.map +1 -1
- package/dist/deploy/common.d.ts +13 -11
- package/dist/deploy/common.js +2 -1
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/framework-runtime.d.ts +2 -1
- package/dist/deploy/framework-runtime.js +5 -1
- package/dist/deploy/framework-runtime.js.map +1 -1
- package/dist/deploy/index.d.ts +4 -2
- package/dist/deploy/index.js +4 -6
- package/dist/deploy/index.js.map +1 -1
- package/dist/deploy/netlify.d.ts +3 -1
- package/dist/deploy/netlify.js +3 -2
- package/dist/deploy/netlify.js.map +1 -1
- package/dist/deploy/node.d.ts +3 -1
- package/dist/deploy/node.js +3 -3
- package/dist/deploy/node.js.map +1 -1
- package/dist/deploy/production-report.d.ts +2 -1
- package/dist/deploy/production-report.js +2 -1
- package/dist/deploy/production-report.js.map +1 -1
- package/dist/deploy/runtime-dependencies.d.ts +5 -4
- package/dist/deploy/runtime-dependencies.js +3 -3
- package/dist/deploy/runtime-dependencies.js.map +1 -1
- package/dist/deploy/static.d.ts +3 -1
- package/dist/deploy/static.js +2 -1
- package/dist/deploy/static.js.map +1 -1
- package/dist/deploy/types.d.ts +8 -7
- package/dist/deploy/types.js +1 -1
- package/dist/deploy/vercel.d.ts +4 -2
- package/dist/deploy/vercel.js +3 -2
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/fonts/index.d.ts +5 -4
- package/dist/fonts/index.js +3 -2
- package/dist/fonts/index.js.map +1 -1
- package/dist/globals.d.ts +2 -2
- package/dist/globals.js +1 -1
- package/dist/halal-core/ai/classifyProject.d.ts +5 -3
- package/dist/halal-core/ai/classifyProject.js +2 -1
- package/dist/halal-core/ai/classifyProject.js.map +1 -1
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +3 -1
- package/dist/halal-core/ai/classifyRuntimeContent.js +2 -1
- package/dist/halal-core/ai/classifyRuntimeContent.js.map +1 -1
- package/dist/halal-core/ai/createProjectSummary.d.ts +2 -1
- package/dist/halal-core/ai/createProjectSummary.js +2 -1
- package/dist/halal-core/ai/createProjectSummary.js.map +1 -1
- package/dist/halal-core/ai/halalClassifierPrompt.d.ts +2 -1
- package/dist/halal-core/ai/halalClassifierPrompt.js +1 -1
- package/dist/halal-core/ai/redactSensitiveData.d.ts +2 -1
- package/dist/halal-core/ai/redactSensitiveData.js +1 -1
- package/dist/halal-core/ai/redactSensitiveData.js.map +1 -1
- package/dist/halal-core/ai/validateAiResponse.d.ts +3 -1
- package/dist/halal-core/ai/validateAiResponse.js +3 -3
- package/dist/halal-core/ai/validateAiResponse.js.map +1 -1
- package/dist/halal-core/cli/check.d.ts +2 -1
- package/dist/halal-core/cli/check.js +3 -3
- package/dist/halal-core/cli/check.js.map +1 -1
- package/dist/halal-core/cli/explain.d.ts +2 -1
- package/dist/halal-core/cli/explain.js +3 -3
- package/dist/halal-core/cli/explain.js.map +1 -1
- package/dist/halal-core/cli/report.d.ts +2 -1
- package/dist/halal-core/cli/report.js +3 -3
- package/dist/halal-core/cli/report.js.map +1 -1
- package/dist/halal-core/cli/submitReview.d.ts +2 -1
- package/dist/halal-core/cli/submitReview.js +3 -3
- package/dist/halal-core/cli/submitReview.js.map +1 -1
- package/dist/halal-core/cli/verifyReview.d.ts +2 -1
- package/dist/halal-core/cli/verifyReview.js +3 -4
- package/dist/halal-core/cli/verifyReview.js.map +1 -1
- package/dist/halal-core/config.d.ts +9 -8
- package/dist/halal-core/config.js +2 -1
- package/dist/halal-core/config.js.map +1 -1
- package/dist/halal-core/crypto/integrity.d.ts +6 -5
- package/dist/halal-core/crypto/integrity.js +2 -1
- package/dist/halal-core/crypto/integrity.js.map +1 -1
- package/dist/halal-core/enforce.d.ts +6 -5
- package/dist/halal-core/enforce.js +13 -15
- package/dist/halal-core/enforce.js.map +1 -1
- package/dist/halal-core/index.js +2 -1
- package/dist/halal-core/lifecycle.d.ts +2 -1
- package/dist/halal-core/lifecycle.js +2 -1
- package/dist/halal-core/lifecycle.js.map +1 -1
- package/dist/halal-core/policy.d.ts +3 -1
- package/dist/halal-core/policy.js +2 -1
- package/dist/halal-core/policy.js.map +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.d.ts +3 -1
- package/dist/halal-core/report/formatBrowserOverlay.js +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.js.map +1 -1
- package/dist/halal-core/report/formatTerminalReport.d.ts +3 -1
- package/dist/halal-core/report/formatTerminalReport.js +1 -1
- package/dist/halal-core/report/formatTerminalReport.js.map +1 -1
- package/dist/halal-core/report/generateHalalReport.d.ts +4 -2
- package/dist/halal-core/report/generateHalalReport.js +5 -7
- package/dist/halal-core/report/generateHalalReport.js.map +1 -1
- package/dist/halal-core/report/signReport.d.ts +4 -2
- package/dist/halal-core/report/signReport.js +2 -1
- package/dist/halal-core/report/signReport.js.map +1 -1
- package/dist/halal-core/report/verifyReport.d.ts +5 -3
- package/dist/halal-core/report/verifyReport.js +4 -3
- package/dist/halal-core/report/verifyReport.js.map +1 -1
- package/dist/halal-core/review/createReviewRequest.d.ts +3 -1
- package/dist/halal-core/review/createReviewRequest.js +3 -3
- package/dist/halal-core/review/createReviewRequest.js.map +1 -1
- package/dist/halal-core/review/reviewPolicy.d.ts +4 -3
- package/dist/halal-core/review/reviewPolicy.js +1 -1
- package/dist/halal-core/review/reviewPolicy.js.map +1 -1
- package/dist/halal-core/review/signedReviewFile.d.ts +6 -4
- package/dist/halal-core/review/signedReviewFile.js +2 -1
- package/dist/halal-core/review/signedReviewFile.js.map +1 -1
- package/dist/halal-core/review/verifyReviewApproval.d.ts +3 -2
- package/dist/halal-core/review/verifyReviewApproval.js +2 -1
- package/dist/halal-core/review/verifyReviewApproval.js.map +1 -1
- package/dist/halal-core/rules/adultContentRules.d.ts +3 -2
- package/dist/halal-core/rules/adultContentRules.js +1 -1
- package/dist/halal-core/rules/adultContentRules.js.map +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +3 -2
- package/dist/halal-core/rules/alcoholDrugVapeRules.js +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.js.map +1 -1
- package/dist/halal-core/rules/childSafetyRules.d.ts +3 -2
- package/dist/halal-core/rules/childSafetyRules.js +1 -1
- package/dist/halal-core/rules/childSafetyRules.js.map +1 -1
- package/dist/halal-core/rules/coreCategories.d.ts +3 -2
- package/dist/halal-core/rules/coreCategories.js +1 -1
- package/dist/halal-core/rules/coreCategories.js.map +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.d.ts +3 -2
- package/dist/halal-core/rules/cyberAbuseRules.js +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/defaultBlockedRules.d.ts +3 -1
- package/dist/halal-core/rules/defaultBlockedRules.js +9 -11
- package/dist/halal-core/rules/defaultBlockedRules.js.map +1 -1
- package/dist/halal-core/rules/dependencyRules.d.ts +3 -2
- package/dist/halal-core/rules/dependencyRules.js +1 -1
- package/dist/halal-core/rules/dependencyRules.js.map +1 -1
- package/dist/halal-core/rules/endpointRules.d.ts +3 -2
- package/dist/halal-core/rules/endpointRules.js +1 -1
- package/dist/halal-core/rules/endpointRules.js.map +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/environmentalHarmRules.js +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/financeRibaRules.d.ts +3 -2
- package/dist/halal-core/rules/financeRibaRules.js +1 -1
- package/dist/halal-core/rules/financeRibaRules.js.map +1 -1
- package/dist/halal-core/rules/gamblingRules.d.ts +3 -2
- package/dist/halal-core/rules/gamblingRules.js +1 -1
- package/dist/halal-core/rules/gamblingRules.js.map +1 -1
- package/dist/halal-core/rules/generalHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/generalHarmRules.js +1 -1
- package/dist/halal-core/rules/generalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/healthHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/healthHarmRules.js +1 -1
- package/dist/halal-core/rules/healthHarmRules.js.map +1 -1
- package/dist/halal-core/rules/keywordRules.d.ts +2 -1
- package/dist/halal-core/rules/keywordRules.js +1 -1
- package/dist/halal-core/rules/keywordRules.js.map +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.d.ts +3 -2
- package/dist/halal-core/rules/privacyAbuseRules.js +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/scamFraudRules.d.ts +3 -2
- package/dist/halal-core/rules/scamFraudRules.js +1 -1
- package/dist/halal-core/rules/scamFraudRules.js.map +1 -1
- package/dist/halal-core/rules/selfHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/selfHarmRules.js +1 -1
- package/dist/halal-core/rules/selfHarmRules.js.map +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.d.ts +3 -2
- package/dist/halal-core/rules/violenceExtremismRules.js +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.js.map +1 -1
- package/dist/halal-core/runtime/guard.d.ts +5 -3
- package/dist/halal-core/runtime/guard.js +2 -1
- package/dist/halal-core/runtime/guard.js.map +1 -1
- package/dist/halal-core/runtime/index.js +2 -1
- package/dist/halal-core/runtime/reviewedMemory.d.ts +6 -4
- package/dist/halal-core/runtime/reviewedMemory.js +3 -2
- package/dist/halal-core/runtime/reviewedMemory.js.map +1 -1
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +7 -5
- package/dist/halal-core/runtime/serializeRuntimeContent.js +4 -3
- package/dist/halal-core/runtime/serializeRuntimeContent.js.map +1 -1
- package/dist/halal-core/runtime/types.d.ts +11 -9
- package/dist/halal-core/runtime/types.js +1 -1
- package/dist/halal-core/scanner/scanApiRoutes.d.ts +2 -1
- package/dist/halal-core/scanner/scanApiRoutes.js +2 -1
- package/dist/halal-core/scanner/scanApiRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanComponents.d.ts +2 -1
- package/dist/halal-core/scanner/scanComponents.js +2 -1
- package/dist/halal-core/scanner/scanComponents.js.map +1 -1
- package/dist/halal-core/scanner/scanContent.d.ts +3 -2
- package/dist/halal-core/scanner/scanContent.js +4 -3
- package/dist/halal-core/scanner/scanContent.js.map +1 -1
- package/dist/halal-core/scanner/scanDependencies.d.ts +2 -1
- package/dist/halal-core/scanner/scanDependencies.js +2 -1
- package/dist/halal-core/scanner/scanDependencies.js.map +1 -1
- package/dist/halal-core/scanner/scanDomains.d.ts +2 -1
- package/dist/halal-core/scanner/scanDomains.js +1 -1
- package/dist/halal-core/scanner/scanDomains.js.map +1 -1
- package/dist/halal-core/scanner/scanEnvNames.d.ts +2 -1
- package/dist/halal-core/scanner/scanEnvNames.js +2 -1
- package/dist/halal-core/scanner/scanEnvNames.js.map +1 -1
- package/dist/halal-core/scanner/scanMetadata.d.ts +3 -2
- package/dist/halal-core/scanner/scanMetadata.js +2 -1
- package/dist/halal-core/scanner/scanMetadata.js.map +1 -1
- package/dist/halal-core/scanner/scanPages.d.ts +2 -1
- package/dist/halal-core/scanner/scanPages.js +2 -1
- package/dist/halal-core/scanner/scanPages.js.map +1 -1
- package/dist/halal-core/scanner/scanProject.d.ts +4 -2
- package/dist/halal-core/scanner/scanProject.js +2 -1
- package/dist/halal-core/scanner/scanProject.js.map +1 -1
- package/dist/halal-core/scanner/scanRoutes.d.ts +2 -1
- package/dist/halal-core/scanner/scanRoutes.js +2 -1
- package/dist/halal-core/scanner/scanRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanTranslations.d.ts +2 -1
- package/dist/halal-core/scanner/scanTranslations.js +2 -1
- package/dist/halal-core/scanner/scanTranslations.js.map +1 -1
- package/dist/halal-core/status.d.ts +3 -2
- package/dist/halal-core/status.js +1 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +2 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.js +2 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.js.map +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +2 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.js +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.js.map +1 -1
- package/dist/halal-core/tamper/verifyReportSignature.d.ts +3 -1
- package/dist/halal-core/tamper/verifyReportSignature.js +3 -3
- package/dist/halal-core/tamper/verifyReportSignature.js.map +1 -1
- package/dist/halal.js +2 -1
- package/dist/i18n/index.d.ts +12 -11
- package/dist/i18n/index.js +5 -6
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.d.ts +15 -14
- package/dist/i18n/shared.js +4 -4
- package/dist/i18n/shared.js.map +1 -1
- package/dist/icons/index.d.ts +18 -16
- package/dist/icons/index.js +5 -4
- package/dist/icons/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/kit/index.d.ts +23 -21
- package/dist/kit/index.js +2 -1
- package/dist/kit/index.js.map +1 -1
- package/dist/nitro-server/index.d.ts +3 -2
- package/dist/nitro-server/index.js +1 -1
- package/dist/nitro-server/index.js.map +1 -1
- package/dist/node.d.ts +4 -2
- package/dist/node.js +7 -6
- package/dist/node.js.map +1 -1
- package/dist/reactivity/computed.d.ts +5 -3
- package/dist/reactivity/computed.js +3 -3
- package/dist/reactivity/computed.js.map +1 -1
- package/dist/reactivity/effect.d.ts +15 -13
- package/dist/reactivity/effect.js +9 -10
- package/dist/reactivity/effect.js.map +1 -1
- package/dist/reactivity/index.js +2 -1
- package/dist/reactivity/reactive.d.ts +6 -5
- package/dist/reactivity/reactive.js +5 -4
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/readonly.js +2 -1
- package/dist/reactivity/ref.d.ts +9 -7
- package/dist/reactivity/ref.js +2 -4
- package/dist/reactivity/ref.js.map +1 -1
- package/dist/reactivity/scheduler.d.ts +5 -4
- package/dist/reactivity/scheduler.js +1 -1
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/reactivity/types.d.ts +12 -11
- package/dist/reactivity/types.js +1 -1
- package/dist/reactivity/utils.d.ts +10 -9
- package/dist/reactivity/utils.js +1 -1
- package/dist/reactivity/utils.js.map +1 -1
- package/dist/reactivity/watch.d.ts +4 -2
- package/dist/reactivity/watch.js +4 -5
- package/dist/reactivity/watch.js.map +1 -1
- package/dist/runtime/core.d.ts +5 -4
- package/dist/runtime/core.js +9 -10
- package/dist/runtime/core.js.map +1 -1
- package/dist/runtime/index.d.ts +123 -122
- package/dist/runtime/index.js +45 -58
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/reactivity.js +2 -1
- package/dist/runtime/resume.d.ts +15 -14
- package/dist/runtime/resume.js +3 -3
- package/dist/runtime/resume.js.map +1 -1
- package/dist/runtime/router.d.ts +5 -4
- package/dist/runtime/router.js +1 -1
- package/dist/runtime/router.js.map +1 -1
- package/dist/runtime/streaming.d.ts +7 -6
- package/dist/runtime/streaming.js +3 -3
- package/dist/runtime/streaming.js.map +1 -1
- package/dist/security/media-fetch.d.ts +11 -10
- package/dist/security/media-fetch.js +5 -4
- package/dist/security/media-fetch.js.map +1 -1
- package/dist/security/path-boundary.d.ts +5 -4
- package/dist/security/path-boundary.js +2 -1
- package/dist/security/path-boundary.js.map +1 -1
- package/dist/ui/index.d.ts +195 -193
- package/dist/ui/index.js +7 -8
- package/dist/ui/index.js.map +1 -1
- package/dist/vite-builder/index.d.ts +3 -2
- package/dist/vite-builder/index.js +1 -1
- package/dist/vite-builder/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
|
|
3
4
|
//#region src/halal-core/scanner/scanPages.ts
|
|
4
5
|
function scanPages(appRoot) {
|
|
5
6
|
const pages = [];
|
|
@@ -10,7 +11,7 @@ function scanPages(appRoot) {
|
|
|
10
11
|
} catch {}
|
|
11
12
|
return pages;
|
|
12
13
|
}
|
|
14
|
+
|
|
13
15
|
//#endregion
|
|
14
16
|
export { scanPages };
|
|
15
|
-
|
|
16
17
|
//# sourceMappingURL=scanPages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanPages.js","names":[],"sources":["../../../src/halal-core/scanner/scanPages.ts"],"sourcesContent":["import { existsSync, readdirSync } from \"node:fs\";\nimport path from \"node:path\";\n\nexport function scanPages(appRoot: string): string[] {\n const pages: string[] = [];\n const dirs = [path.join(appRoot, \"pages\"), path.join(appRoot, \"layouts\")];\n\n for (const dir of dirs) {\n if (existsSync(dir)) {\n try {\n const files = readdirSync(dir);\n pages.push(...files.map(f => f.toLowerCase()));\n } catch {\n // Ignore\n }\n }\n }\n\n return pages;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"scanPages.js","names":[],"sources":["../../../src/halal-core/scanner/scanPages.ts"],"sourcesContent":["import { existsSync, readdirSync } from \"node:fs\";\nimport path from \"node:path\";\n\nexport function scanPages(appRoot: string): string[] {\n const pages: string[] = [];\n const dirs = [path.join(appRoot, \"pages\"), path.join(appRoot, \"layouts\")];\n\n for (const dir of dirs) {\n if (existsSync(dir)) {\n try {\n const files = readdirSync(dir);\n pages.push(...files.map(f => f.toLowerCase()));\n } catch {\n // Ignore\n }\n }\n }\n\n return pages;\n}\n"],"mappings":";;;;AAGA,SAAgB,UAAU,SAA2B;CACnD,MAAM,QAAkB,EAAE;CAC1B,MAAM,OAAO,CAAC,KAAK,KAAK,SAAS,QAAQ,EAAE,KAAK,KAAK,SAAS,UAAU,CAAC;AAEzE,MAAK,MAAM,OAAO,KAChB,KAAI,WAAW,IAAI,CACjB,KAAI;EACF,MAAM,QAAQ,YAAY,IAAI;AAC9B,QAAM,KAAK,GAAG,MAAM,KAAI,MAAK,EAAE,aAAa,CAAC,CAAC;SACxC;AAMZ,QAAO"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ScanMetadataResult } from "./scanMetadata.js";
|
|
2
2
|
import { ScanResult } from "./scanContent.js";
|
|
3
|
+
|
|
3
4
|
//#region src/halal-core/scanner/scanProject.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
declare function getGitignoredPaths(appRoot: string): Set<string>;
|
|
6
|
+
declare function scanProject(appRoot: string): {
|
|
6
7
|
routes: string[];
|
|
7
8
|
pages: string[];
|
|
8
9
|
components: string[];
|
|
@@ -15,4 +16,5 @@ export declare function scanProject(appRoot: string): {
|
|
|
15
16
|
endpoints: string[];
|
|
16
17
|
};
|
|
17
18
|
//#endregion
|
|
19
|
+
export { getGitignoredPaths, scanProject };
|
|
18
20
|
//# sourceMappingURL=scanProject.d.ts.map
|
|
@@ -10,6 +10,7 @@ import { scanContentFiles } from "./scanContent.js";
|
|
|
10
10
|
import { scanDomains } from "./scanDomains.js";
|
|
11
11
|
import { existsSync, readFileSync } from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
13
|
+
|
|
13
14
|
//#region src/halal-core/scanner/scanProject.ts
|
|
14
15
|
function getGitignoredPaths(appRoot) {
|
|
15
16
|
const ignored = /* @__PURE__ */ new Set();
|
|
@@ -50,7 +51,7 @@ function scanProject(appRoot) {
|
|
|
50
51
|
endpoints: scanDomains(contentTexts)
|
|
51
52
|
};
|
|
52
53
|
}
|
|
54
|
+
|
|
53
55
|
//#endregion
|
|
54
56
|
export { getGitignoredPaths, scanProject };
|
|
55
|
-
|
|
56
57
|
//# sourceMappingURL=scanProject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanProject.js","names":[],"sources":["../../../src/halal-core/scanner/scanProject.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { scanRoutes } from \"./scanRoutes.js\";\nimport { scanPages } from \"./scanPages.js\";\nimport { scanComponents } from \"./scanComponents.js\";\nimport { scanApiRoutes } from \"./scanApiRoutes.js\";\nimport { scanMetadata } from \"./scanMetadata.js\";\nimport { scanEnvNames } from \"./scanEnvNames.js\";\nimport { scanDependencies } from \"./scanDependencies.js\";\nimport { scanTranslations } from \"./scanTranslations.js\";\nimport { scanContentFiles } from \"./scanContent.js\";\nimport { scanDomains } from \"./scanDomains.js\";\n\nexport function getGitignoredPaths(appRoot: string): Set<string> {\n const ignored = new Set<string>();\n const gitignorePath = path.join(appRoot, \".gitignore\");\n \n if (existsSync(gitignorePath)) {\n try {\n const content = readFileSync(gitignorePath, \"utf8\");\n const lines = content.split(/\\r?\\n/);\n for (const line of lines) {\n const trimmed = line.trim();\n if (trimmed && !trimmed.startsWith(\"#\")) {\n // Preserve a leading slash so root-anchored gitignore rules stay anchored.\n const cleaned = trimmed.replace(/\\/$/, \"\");\n if (cleaned) {\n ignored.add(cleaned);\n }\n }\n }\n } catch {\n // Ignore errors\n }\n }\n \n return ignored;\n}\n\nexport function scanProject(appRoot: string) {\n const ignored = getGitignoredPaths(appRoot);\n \n const routes = scanRoutes(appRoot);\n const pages = scanPages(appRoot);\n const components = scanComponents(appRoot);\n const apiRoutes = scanApiRoutes(appRoot);\n const metadata = scanMetadata(appRoot);\n const envNames = scanEnvNames(appRoot);\n const dependencies = scanDependencies(appRoot);\n const i18nWords = scanTranslations(appRoot);\n \n const contentTexts = scanContentFiles(appRoot, appRoot, ignored);\n const endpoints = scanDomains(contentTexts);\n \n return {\n routes,\n pages,\n components,\n apiRoutes,\n metadata,\n envNames,\n dependencies,\n i18nWords,\n contentTexts,\n endpoints\n };\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"scanProject.js","names":[],"sources":["../../../src/halal-core/scanner/scanProject.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { scanRoutes } from \"./scanRoutes.js\";\nimport { scanPages } from \"./scanPages.js\";\nimport { scanComponents } from \"./scanComponents.js\";\nimport { scanApiRoutes } from \"./scanApiRoutes.js\";\nimport { scanMetadata } from \"./scanMetadata.js\";\nimport { scanEnvNames } from \"./scanEnvNames.js\";\nimport { scanDependencies } from \"./scanDependencies.js\";\nimport { scanTranslations } from \"./scanTranslations.js\";\nimport { scanContentFiles } from \"./scanContent.js\";\nimport { scanDomains } from \"./scanDomains.js\";\n\nexport function getGitignoredPaths(appRoot: string): Set<string> {\n const ignored = new Set<string>();\n const gitignorePath = path.join(appRoot, \".gitignore\");\n \n if (existsSync(gitignorePath)) {\n try {\n const content = readFileSync(gitignorePath, \"utf8\");\n const lines = content.split(/\\r?\\n/);\n for (const line of lines) {\n const trimmed = line.trim();\n if (trimmed && !trimmed.startsWith(\"#\")) {\n // Preserve a leading slash so root-anchored gitignore rules stay anchored.\n const cleaned = trimmed.replace(/\\/$/, \"\");\n if (cleaned) {\n ignored.add(cleaned);\n }\n }\n }\n } catch {\n // Ignore errors\n }\n }\n \n return ignored;\n}\n\nexport function scanProject(appRoot: string) {\n const ignored = getGitignoredPaths(appRoot);\n \n const routes = scanRoutes(appRoot);\n const pages = scanPages(appRoot);\n const components = scanComponents(appRoot);\n const apiRoutes = scanApiRoutes(appRoot);\n const metadata = scanMetadata(appRoot);\n const envNames = scanEnvNames(appRoot);\n const dependencies = scanDependencies(appRoot);\n const i18nWords = scanTranslations(appRoot);\n \n const contentTexts = scanContentFiles(appRoot, appRoot, ignored);\n const endpoints = scanDomains(contentTexts);\n \n return {\n routes,\n pages,\n components,\n apiRoutes,\n metadata,\n envNames,\n dependencies,\n i18nWords,\n contentTexts,\n endpoints\n };\n}"],"mappings":";;;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,SAA8B;CAC/D,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,gBAAgB,KAAK,KAAK,SAAS,aAAa;AAEtD,KAAI,WAAW,cAAc,CAC3B,KAAI;EAEF,MAAM,QADU,aAAa,eAAe,OAAO,CAC7B,MAAM,QAAQ;AACpC,OAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,UAAU,KAAK,MAAM;AAC3B,OAAI,WAAW,CAAC,QAAQ,WAAW,IAAI,EAAE;IAEvC,MAAM,UAAU,QAAQ,QAAQ,OAAO,GAAG;AAC1C,QAAI,QACF,SAAQ,IAAI,QAAQ;;;SAIpB;AAKV,QAAO;;AAGT,SAAgB,YAAY,SAAiB;CAC3C,MAAM,UAAU,mBAAmB,QAAQ;CAE3C,MAAM,SAAS,WAAW,QAAQ;CAClC,MAAM,QAAQ,UAAU,QAAQ;CAChC,MAAM,aAAa,eAAe,QAAQ;CAC1C,MAAM,YAAY,cAAc,QAAQ;CACxC,MAAM,WAAW,aAAa,QAAQ;CACtC,MAAM,WAAW,aAAa,QAAQ;CACtC,MAAM,eAAe,iBAAiB,QAAQ;CAC9C,MAAM,YAAY,iBAAiB,QAAQ;CAE3C,MAAM,eAAe,iBAAiB,SAAS,SAAS,QAAQ;AAGhE,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAZgB,YAAY,aAAa;EAa1C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
|
|
3
4
|
//#region src/halal-core/scanner/scanRoutes.ts
|
|
4
5
|
function scanRoutes(appRoot) {
|
|
5
6
|
const routes = [];
|
|
@@ -30,7 +31,7 @@ function scanRoutes(appRoot) {
|
|
|
30
31
|
traverse(pagesDir);
|
|
31
32
|
return routes;
|
|
32
33
|
}
|
|
34
|
+
|
|
33
35
|
//#endregion
|
|
34
36
|
export { scanRoutes };
|
|
35
|
-
|
|
36
37
|
//# sourceMappingURL=scanRoutes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanRoutes.js","names":[],"sources":["../../../src/halal-core/scanner/scanRoutes.ts"],"sourcesContent":["import { existsSync, readdirSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\n\nexport function scanRoutes(appRoot: string): string[] {\n const routes: string[] = [];\n const pagesDir = path.join(appRoot, \"pages\");\n\n if (!existsSync(pagesDir)) {\n return routes;\n }\n\n function traverse(dir: string) {\n let files: string[] = [];\n try {\n files = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const file of files) {\n const fullPath = path.join(dir, file);\n let stats;\n try {\n stats = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stats.isDirectory()) {\n traverse(fullPath);\n } else if (stats.isFile()) {\n const relative = path.relative(pagesDir, fullPath).replace(/\\\\/g, \"/\");\n // Convert page file path to route name\n const routeName = relative\n .replace(/\\.(vue|ts|js|jsx|tsx)$/, \"\")\n .replace(/\\/index$/, \"\")\n .replace(/^index$/, \"/\");\n routes.push(routeName);\n }\n }\n }\n\n traverse(pagesDir);\n return routes;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"scanRoutes.js","names":[],"sources":["../../../src/halal-core/scanner/scanRoutes.ts"],"sourcesContent":["import { existsSync, readdirSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\n\nexport function scanRoutes(appRoot: string): string[] {\n const routes: string[] = [];\n const pagesDir = path.join(appRoot, \"pages\");\n\n if (!existsSync(pagesDir)) {\n return routes;\n }\n\n function traverse(dir: string) {\n let files: string[] = [];\n try {\n files = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const file of files) {\n const fullPath = path.join(dir, file);\n let stats;\n try {\n stats = statSync(fullPath);\n } catch {\n continue;\n }\n\n if (stats.isDirectory()) {\n traverse(fullPath);\n } else if (stats.isFile()) {\n const relative = path.relative(pagesDir, fullPath).replace(/\\\\/g, \"/\");\n // Convert page file path to route name\n const routeName = relative\n .replace(/\\.(vue|ts|js|jsx|tsx)$/, \"\")\n .replace(/\\/index$/, \"\")\n .replace(/^index$/, \"/\");\n routes.push(routeName);\n }\n }\n }\n\n traverse(pagesDir);\n return routes;\n}\n"],"mappings":";;;;AAGA,SAAgB,WAAW,SAA2B;CACpD,MAAM,SAAmB,EAAE;CAC3B,MAAM,WAAW,KAAK,KAAK,SAAS,QAAQ;AAE5C,KAAI,CAAC,WAAW,SAAS,CACvB,QAAO;CAGT,SAAS,SAAS,KAAa;EAC7B,IAAI,QAAkB,EAAE;AACxB,MAAI;AACF,WAAQ,YAAY,IAAI;UAClB;AACN;;AAGF,OAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,WAAW,KAAK,KAAK,KAAK,KAAK;GACrC,IAAI;AACJ,OAAI;AACF,YAAQ,SAAS,SAAS;WACpB;AACN;;AAGF,OAAI,MAAM,aAAa,CACrB,UAAS,SAAS;YACT,MAAM,QAAQ,EAAE;IAGzB,MAAM,YAFW,KAAK,SAAS,UAAU,SAAS,CAAC,QAAQ,OAAO,IAAI,CAGnE,QAAQ,0BAA0B,GAAG,CACrC,QAAQ,YAAY,GAAG,CACvB,QAAQ,WAAW,IAAI;AAC1B,WAAO,KAAK,UAAU;;;;AAK5B,UAAS,SAAS;AAClB,QAAO"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/halal-core/scanner/scanTranslations.d.ts
|
|
2
|
-
|
|
2
|
+
declare function scanTranslations(appRoot: string): string[];
|
|
3
3
|
//#endregion
|
|
4
|
+
export { scanTranslations };
|
|
4
5
|
//# sourceMappingURL=scanTranslations.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
|
|
3
4
|
//#region src/halal-core/scanner/scanTranslations.ts
|
|
4
5
|
function scanTranslations(appRoot) {
|
|
5
6
|
const words = [];
|
|
@@ -18,7 +19,7 @@ function scanTranslations(appRoot) {
|
|
|
18
19
|
} catch {}
|
|
19
20
|
return words;
|
|
20
21
|
}
|
|
22
|
+
|
|
21
23
|
//#endregion
|
|
22
24
|
export { scanTranslations };
|
|
23
|
-
|
|
24
25
|
//# sourceMappingURL=scanTranslations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanTranslations.js","names":[],"sources":["../../../src/halal-core/scanner/scanTranslations.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nexport function scanTranslations(appRoot: string): string[] {\n const words: string[] = [];\n const i18nDir = path.join(appRoot, \"i18n\");\n\n if (existsSync(i18nDir)) {\n try {\n const files = readdirSync(i18nDir).filter(f => f.endsWith(\".json\"));\n for (const file of files) {\n const content = readFileSync(path.join(i18nDir, file), \"utf8\");\n // Simple search for raw translation strings\n const json = JSON.parse(content);\n const extractStrings = (obj: any) => {\n if (typeof obj === \"string\") {\n words.push(obj);\n } else if (typeof obj === \"object\" && obj !== null) {\n for (const key of Object.keys(obj)) {\n extractStrings(obj[key]);\n }\n }\n };\n extractStrings(json);\n }\n } catch {\n // Ignore\n }\n }\n\n return words;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"scanTranslations.js","names":[],"sources":["../../../src/halal-core/scanner/scanTranslations.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nexport function scanTranslations(appRoot: string): string[] {\n const words: string[] = [];\n const i18nDir = path.join(appRoot, \"i18n\");\n\n if (existsSync(i18nDir)) {\n try {\n const files = readdirSync(i18nDir).filter(f => f.endsWith(\".json\"));\n for (const file of files) {\n const content = readFileSync(path.join(i18nDir, file), \"utf8\");\n // Simple search for raw translation strings\n const json = JSON.parse(content);\n const extractStrings = (obj: any) => {\n if (typeof obj === \"string\") {\n words.push(obj);\n } else if (typeof obj === \"object\" && obj !== null) {\n for (const key of Object.keys(obj)) {\n extractStrings(obj[key]);\n }\n }\n };\n extractStrings(json);\n }\n } catch {\n // Ignore\n }\n }\n\n return words;\n}\n"],"mappings":";;;;AAGA,SAAgB,iBAAiB,SAA2B;CAC1D,MAAM,QAAkB,EAAE;CAC1B,MAAM,UAAU,KAAK,KAAK,SAAS,OAAO;AAE1C,KAAI,WAAW,QAAQ,CACrB,KAAI;EACF,MAAM,QAAQ,YAAY,QAAQ,CAAC,QAAO,MAAK,EAAE,SAAS,QAAQ,CAAC;AACnE,OAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,UAAU,aAAa,KAAK,KAAK,SAAS,KAAK,EAAE,OAAO;GAE9D,MAAM,OAAO,KAAK,MAAM,QAAQ;GAChC,MAAM,kBAAkB,QAAa;AACnC,QAAI,OAAO,QAAQ,SACjB,OAAM,KAAK,IAAI;aACN,OAAO,QAAQ,YAAY,QAAQ,KAC5C,MAAK,MAAM,OAAO,OAAO,KAAK,IAAI,CAChC,gBAAe,IAAI,KAAK;;AAI9B,kBAAe,KAAK;;SAEhB;AAKV,QAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/halal-core/status.d.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type HalalGuardStatus = "allowed" | "warning" | "review_required" | "blocked";
|
|
3
|
+
interface HalalCheckResult {
|
|
4
4
|
status: HalalGuardStatus;
|
|
5
5
|
riskLevel: "low" | "medium" | "high" | "critical";
|
|
6
6
|
categories: string[];
|
|
@@ -14,4 +14,5 @@ export interface HalalCheckResult {
|
|
|
14
14
|
createdDate?: string;
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|
|
17
|
+
export { HalalCheckResult, HalalGuardStatus };
|
|
17
18
|
//# sourceMappingURL=status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/halal-core/tamper/verifyCoreIntegrity.d.ts
|
|
2
|
-
|
|
2
|
+
declare function verifyCoreIntegrity(appRoot: string): boolean;
|
|
3
3
|
//#endregion
|
|
4
|
+
export { verifyCoreIntegrity };
|
|
4
5
|
//# sourceMappingURL=verifyCoreIntegrity.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
|
|
3
4
|
//#region src/halal-core/tamper/verifyCoreIntegrity.ts
|
|
4
5
|
function verifyCoreIntegrity(appRoot) {
|
|
5
6
|
const criticalFiles = [
|
|
@@ -24,7 +25,7 @@ function verifyCoreIntegrity(appRoot) {
|
|
|
24
25
|
}
|
|
25
26
|
return true;
|
|
26
27
|
}
|
|
28
|
+
|
|
27
29
|
//#endregion
|
|
28
30
|
export { verifyCoreIntegrity };
|
|
29
|
-
|
|
30
31
|
//# sourceMappingURL=verifyCoreIntegrity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyCoreIntegrity.js","names":[],"sources":["../../../src/halal-core/tamper/verifyCoreIntegrity.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nexport function verifyCoreIntegrity(appRoot: string): boolean {\n // Check that core files are present in the framework source tree\n const criticalFiles = [\n \"index\",\n \"enforce\",\n \"config\",\n \"policy\",\n \"rules/defaultBlockedRules\",\n \"rules/coreCategories\",\n \"report/signReport\"\n ];\n\n // We find the framework dir by locating halal-core\n const pathname = decodeURIComponent(new URL(import.meta.url).pathname);\n const cleanPath = pathname.startsWith(\"/\") && pathname[2] === \":\" ? pathname.substring(1) : pathname;\n const normalizedDir = path.dirname(cleanPath);\n\n for (const file of criticalFiles) {\n const tsPath = path.join(normalizedDir, \"..\", `${file}.ts`);\n const jsPath = path.join(normalizedDir, \"..\", `${file}.js`);\n if (!existsSync(tsPath) && !existsSync(jsPath)) {\n console.error(`[resux-halal-core] Critical framework security file missing: ${file}`);\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"verifyCoreIntegrity.js","names":[],"sources":["../../../src/halal-core/tamper/verifyCoreIntegrity.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nexport function verifyCoreIntegrity(appRoot: string): boolean {\n // Check that core files are present in the framework source tree\n const criticalFiles = [\n \"index\",\n \"enforce\",\n \"config\",\n \"policy\",\n \"rules/defaultBlockedRules\",\n \"rules/coreCategories\",\n \"report/signReport\"\n ];\n\n // We find the framework dir by locating halal-core\n const pathname = decodeURIComponent(new URL(import.meta.url).pathname);\n const cleanPath = pathname.startsWith(\"/\") && pathname[2] === \":\" ? pathname.substring(1) : pathname;\n const normalizedDir = path.dirname(cleanPath);\n\n for (const file of criticalFiles) {\n const tsPath = path.join(normalizedDir, \"..\", `${file}.ts`);\n const jsPath = path.join(normalizedDir, \"..\", `${file}.js`);\n if (!existsSync(tsPath) && !existsSync(jsPath)) {\n console.error(`[resux-halal-core] Critical framework security file missing: ${file}`);\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;;;AAGA,SAAgB,oBAAoB,SAA0B;CAE5D,MAAM,gBAAgB;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CAGD,MAAM,WAAW,mBAAmB,IAAI,IAAI,OAAO,KAAK,IAAI,CAAC,SAAS;CACtE,MAAM,YAAY,SAAS,WAAW,IAAI,IAAI,SAAS,OAAO,MAAM,SAAS,UAAU,EAAE,GAAG;CAC5F,MAAM,gBAAgB,KAAK,QAAQ,UAAU;AAE7C,MAAK,MAAM,QAAQ,eAAe;EAChC,MAAM,SAAS,KAAK,KAAK,eAAe,MAAM,GAAG,KAAK,KAAK;EAC3D,MAAM,SAAS,KAAK,KAAK,eAAe,MAAM,GAAG,KAAK,KAAK;AAC3D,MAAI,CAAC,WAAW,OAAO,IAAI,CAAC,WAAW,OAAO,EAAE;AAC9C,WAAQ,MAAM,gEAAgE,OAAO;AACrF,UAAO;;;AAIX,QAAO"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/halal-core/tamper/verifyLifecycleHooks.d.ts
|
|
2
|
-
|
|
2
|
+
declare function verifyLifecycleHooksRegistered(hooks: any): boolean;
|
|
3
3
|
//#endregion
|
|
4
|
+
export { verifyLifecycleHooksRegistered };
|
|
4
5
|
//# sourceMappingURL=verifyLifecycleHooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyLifecycleHooks.js","names":[],"sources":["../../../src/halal-core/tamper/verifyLifecycleHooks.ts"],"sourcesContent":["export function verifyLifecycleHooksRegistered(hooks: any): boolean {\n if (!hooks) {\n return false;\n }\n\n // Ensure our safety check hooks are present in the hook register\n const hasBuildStartHook = typeof hooks.hook === \"function\" || hooks._hooks?.[\"build:before\"];\n const hasDevHook = typeof hooks.hook === \"function\" || hooks._hooks?.[\"dev:before\"];\n\n if (!hasBuildStartHook && !hasDevHook) {\n console.error(\"[resux-halal-core] Safety lifecycle hooks have been bypassed or altered.\");\n return false;\n }\n\n return true;\n}\n"],"mappings":";AAAA,SAAgB,+BAA+B,OAAqB;
|
|
1
|
+
{"version":3,"file":"verifyLifecycleHooks.js","names":[],"sources":["../../../src/halal-core/tamper/verifyLifecycleHooks.ts"],"sourcesContent":["export function verifyLifecycleHooksRegistered(hooks: any): boolean {\n if (!hooks) {\n return false;\n }\n\n // Ensure our safety check hooks are present in the hook register\n const hasBuildStartHook = typeof hooks.hook === \"function\" || hooks._hooks?.[\"build:before\"];\n const hasDevHook = typeof hooks.hook === \"function\" || hooks._hooks?.[\"dev:before\"];\n\n if (!hasBuildStartHook && !hasDevHook) {\n console.error(\"[resux-halal-core] Safety lifecycle hooks have been bypassed or altered.\");\n return false;\n }\n\n return true;\n}\n"],"mappings":";AAAA,SAAgB,+BAA+B,OAAqB;AAClE,KAAI,CAAC,MACH,QAAO;CAIT,MAAM,oBAAoB,OAAO,MAAM,SAAS,cAAc,MAAM,SAAS;CAC7E,MAAM,aAAa,OAAO,MAAM,SAAS,cAAc,MAAM,SAAS;AAEtE,KAAI,CAAC,qBAAqB,CAAC,YAAY;AACrC,UAAQ,MAAM,2EAA2E;AACzF,SAAO;;AAGT,QAAO"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ReportVerificationOptions } from "../report/verifyReport.js";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/tamper/verifyReportSignature.d.ts
|
|
3
|
-
|
|
4
|
+
declare function checkOnDiskReportSignature(outDir: string, options?: ReportVerificationOptions): {
|
|
4
5
|
valid: boolean;
|
|
5
6
|
reason?: string;
|
|
6
7
|
};
|
|
7
8
|
//#endregion
|
|
9
|
+
export { checkOnDiskReportSignature };
|
|
8
10
|
//# sourceMappingURL=verifyReportSignature.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isReportValid } from "../report/verifyReport.js";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
|
|
4
5
|
//#region src/halal-core/tamper/verifyReportSignature.ts
|
|
5
6
|
function checkOnDiskReportSignature(outDir, options = {}) {
|
|
6
7
|
const reportPath = path.join(outDir, "halal-report.json");
|
|
@@ -9,8 +10,7 @@ function checkOnDiskReportSignature(outDir, options = {}) {
|
|
|
9
10
|
reason: "Halal Core report file is missing."
|
|
10
11
|
};
|
|
11
12
|
try {
|
|
12
|
-
|
|
13
|
-
return isReportValid(content, options);
|
|
13
|
+
return isReportValid(JSON.parse(readFileSync(reportPath, "utf8")), options);
|
|
14
14
|
} catch (error) {
|
|
15
15
|
return {
|
|
16
16
|
valid: false,
|
|
@@ -18,7 +18,7 @@ function checkOnDiskReportSignature(outDir, options = {}) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
|
|
21
22
|
//#endregion
|
|
22
23
|
export { checkOnDiskReportSignature };
|
|
23
|
-
|
|
24
24
|
//# sourceMappingURL=verifyReportSignature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyReportSignature.js","names":[],"sources":["../../../src/halal-core/tamper/verifyReportSignature.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport {\n isReportValid,\n type ReportVerificationOptions,\n} from \"../report/verifyReport.js\";\n\nexport function checkOnDiskReportSignature(\n outDir: string,\n options: ReportVerificationOptions = {},\n): { valid: boolean; reason?: string } {\n const reportPath = path.join(outDir, \"halal-report.json\");\n if (!existsSync(reportPath)) {\n return { valid: false, reason: \"Halal Core report file is missing.\" };\n }\n\n try {\n const content = JSON.parse(readFileSync(reportPath, \"utf8\"));\n return isReportValid(content, options);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return { valid: false, reason: `Failed to read or parse Halal Core report: ${message}` };\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"verifyReportSignature.js","names":[],"sources":["../../../src/halal-core/tamper/verifyReportSignature.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport {\n isReportValid,\n type ReportVerificationOptions,\n} from \"../report/verifyReport.js\";\n\nexport function checkOnDiskReportSignature(\n outDir: string,\n options: ReportVerificationOptions = {},\n): { valid: boolean; reason?: string } {\n const reportPath = path.join(outDir, \"halal-report.json\");\n if (!existsSync(reportPath)) {\n return { valid: false, reason: \"Halal Core report file is missing.\" };\n }\n\n try {\n const content = JSON.parse(readFileSync(reportPath, \"utf8\"));\n return isReportValid(content, options);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return { valid: false, reason: `Failed to read or parse Halal Core report: ${message}` };\n }\n}\n"],"mappings":";;;;;AAOA,SAAgB,2BACd,QACA,UAAqC,EAAE,EACF;CACrC,MAAM,aAAa,KAAK,KAAK,QAAQ,oBAAoB;AACzD,KAAI,CAAC,WAAW,WAAW,CACzB,QAAO;EAAE,OAAO;EAAO,QAAQ;EAAsC;AAGvE,KAAI;AAEF,SAAO,cADS,KAAK,MAAM,aAAa,YAAY,OAAO,CAAC,EAC9B,QAAQ;UAC/B,OAAO;AAEd,SAAO;GAAE,OAAO;GAAO,QAAQ,8CADf,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;GACkB"}
|
package/dist/halal.js
CHANGED
|
@@ -15,4 +15,5 @@ import { runHalalExplain } from "./halal-core/cli/explain.js";
|
|
|
15
15
|
import { runHalalSubmitReview } from "./halal-core/cli/submitReview.js";
|
|
16
16
|
import { runHalalVerifyReview } from "./halal-core/cli/verifyReview.js";
|
|
17
17
|
import { formatBrowserOverlayScript } from "./halal-core/report/formatBrowserOverlay.js";
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
export { HalalRuntimeBlockedError, classifyRuntimeContentWithAi, createHalalRuntimeGuard, createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, defineResuxHalalPolicy, enforceBuildGuard, enforceDeploymentGuard, enforceDevGuard, enforcePreviewGuard, enforceProductionServerGuard, evaluateHalalRuntimeContent, evaluateRules, findReviewedRuntimeDecision, formatBrowserOverlayScript, loadMainResuxConfig, loadProjectPolicy, prepareRuntimeContent, registerHalalCoreHooks, runHalalCheck, runHalalExplain, runHalalReport, runHalalSubmitReview, runHalalVerifyReview, scanProject, serializeRuntimeContent, serializeRuntimeContentCanonical, validatePolicyConfig, verifyCoreIntegrity, verifySignedHalalRuntimeDecision };
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { computed } from "../reactivity/computed.js";
|
|
2
2
|
import { ResuxModule } from "../runtime/index.js";
|
|
3
3
|
import { ResuxI18nLocale, ResuxI18nStrategy, ResuxI18nTranslationParams } from "./shared.js";
|
|
4
|
+
|
|
4
5
|
//#region src/i18n/index.d.ts
|
|
5
6
|
type MessageRecord = Record<string, unknown>;
|
|
6
|
-
|
|
7
|
+
interface ResuxI18nLocaleInput {
|
|
7
8
|
code: string;
|
|
8
9
|
name?: string;
|
|
9
10
|
dir?: "ltr" | "rtl";
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
type ResuxI18nMessageSource = MessageRecord | string | (() => unknown | Promise<unknown>);
|
|
13
|
+
interface ResuxI18nConfigInput {
|
|
13
14
|
defaultLocale: string;
|
|
14
15
|
fallbackLocale?: string;
|
|
15
16
|
strategy?: ResuxI18nStrategy;
|
|
@@ -19,8 +20,8 @@ export interface ResuxI18nConfigInput {
|
|
|
19
20
|
hreflang?: boolean;
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
interface ResuxI18nModuleOptions extends Partial<ResuxI18nConfigInput> {}
|
|
24
|
+
interface UseI18nResult {
|
|
24
25
|
locale: ReturnType<typeof computed<string>>;
|
|
25
26
|
dir: ReturnType<typeof computed<"ltr" | "rtl">>;
|
|
26
27
|
locales: ResuxI18nLocale[];
|
|
@@ -34,15 +35,15 @@ export interface UseI18nResult {
|
|
|
34
35
|
switchLocalePath: (localeCode: string, to?: string) => string;
|
|
35
36
|
setLocale: (localeCode: string, to?: string) => Promise<void> | void;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
declare function useI18n(): UseI18nResult;
|
|
39
|
+
declare function useLocalePath(): (to: string, localeCode?: string) => string;
|
|
40
|
+
declare function useSwitchLocalePath(): (localeCode: string, to?: string) => string;
|
|
41
|
+
declare function defineI18nConfig<T extends ResuxI18nConfigInput>(config: T): T;
|
|
42
|
+
declare function createI18nHeadEntry(routePath: string, routeOrigin?: string): {
|
|
42
43
|
htmlAttrs: Record<string, string>;
|
|
43
44
|
link: Array<Record<string, string>>;
|
|
44
45
|
};
|
|
45
46
|
declare const _default: ResuxModule<ResuxI18nModuleOptions>;
|
|
46
47
|
//#endregion
|
|
47
|
-
export { _default as default };
|
|
48
|
+
export { ResuxI18nConfigInput, ResuxI18nLocaleInput, ResuxI18nMessageSource, ResuxI18nModuleOptions, UseI18nResult, createI18nHeadEntry, _default as default, defineI18nConfig, useI18n, useLocalePath, useSwitchLocalePath };
|
|
48
49
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/i18n/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { defineResuxModule, useResuxApp } from "../runtime/index.js";
|
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
+
|
|
8
9
|
//#region src/i18n/index.ts
|
|
9
10
|
function isRecord(value) {
|
|
10
11
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
@@ -110,20 +111,18 @@ async function buildRuntimeI18nConfig(context, inlineOptions) {
|
|
|
110
111
|
})).filter((locale) => locale.code.length > 0);
|
|
111
112
|
if (!locales.length) return null;
|
|
112
113
|
const firstLocale = locales[0].code;
|
|
113
|
-
|
|
114
|
+
return normalizeI18nRuntimeConfig({
|
|
114
115
|
defaultLocale: typeof merged.defaultLocale === "string" ? merged.defaultLocale.toLowerCase() : firstLocale,
|
|
115
116
|
fallbackLocale: typeof merged.fallbackLocale === "string" ? merged.fallbackLocale.toLowerCase() : void 0,
|
|
116
117
|
strategy: normalizeI18nStrategy(merged.strategy),
|
|
117
118
|
locales,
|
|
118
119
|
messages: await resolveMessages(context.rootDir, locales, merged.messages),
|
|
119
120
|
seo: { hreflang: !isRecord(merged.seo) || merged.seo.hreflang !== false }
|
|
120
|
-
};
|
|
121
|
-
return normalizeI18nRuntimeConfig(rawConfig);
|
|
121
|
+
});
|
|
122
122
|
}
|
|
123
123
|
function readRuntimeI18nConfig() {
|
|
124
124
|
const runtimeConfig = useResuxApp().$config;
|
|
125
|
-
|
|
126
|
-
return normalizeI18nRuntimeConfig(publicConfig.i18n);
|
|
125
|
+
return normalizeI18nRuntimeConfig((isRecord(runtimeConfig.public) ? runtimeConfig.public : {}).i18n);
|
|
127
126
|
}
|
|
128
127
|
const I18N_LOCALE_STATE_KEY = "__resux_i18n_locale_state";
|
|
129
128
|
function resolveConfiguredLocale(config, localeCode) {
|
|
@@ -248,7 +247,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
248
247
|
globalThis.__RESUX_USE_LOCALE_PATH__ ??= useLocalePath;
|
|
249
248
|
globalThis.__RESUX_USE_SWITCH_LOCALE_PATH__ ??= useSwitchLocalePath;
|
|
250
249
|
}
|
|
250
|
+
|
|
251
251
|
//#endregion
|
|
252
252
|
export { createI18nHeadEntry, i18n_default as default, defineI18nConfig, useI18n, useLocalePath, useSwitchLocalePath };
|
|
253
|
-
|
|
254
253
|
//# sourceMappingURL=index.js.map
|
package/dist/i18n/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/i18n/index.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport {\n computed,\n ref,\n defineResuxModule,\n type ResuxModuleContext,\n type Ref,\n useResuxApp,\n type ResuxRouter,\n type RuntimeConfig\n} from \"../runtime/index.js\";\nimport {\n buildLocalePath,\n createI18nHead,\n normalizeI18nRuntimeConfig,\n normalizeI18nStrategy,\n resolveI18nRoute,\n resolveLocaleDirection,\n resolveLocalizedValue,\n translateRaw,\n translateText,\n type ResuxI18nLocale,\n type ResuxI18nRuntimeConfig,\n type ResuxI18nStrategy,\n type ResuxI18nTranslationParams\n} from \"./shared.js\";\n\ntype MessageRecord = Record<string, unknown>;\n\nexport interface ResuxI18nLocaleInput {\n code: string;\n name?: string;\n dir?: \"ltr\" | \"rtl\";\n}\n\nexport type ResuxI18nMessageSource =\n | MessageRecord\n | string\n | (() => unknown | Promise<unknown>);\n\nexport interface ResuxI18nConfigInput {\n defaultLocale: string;\n fallbackLocale?: string;\n strategy?: ResuxI18nStrategy;\n locales: ResuxI18nLocaleInput[];\n messages?: Record<string, ResuxI18nMessageSource>;\n seo?: {\n hreflang?: boolean;\n };\n}\n\nexport interface ResuxI18nModuleOptions extends Partial<ResuxI18nConfigInput> {}\n\nexport interface UseI18nResult {\n locale: ReturnType<typeof computed<string>>;\n dir: ReturnType<typeof computed<\"ltr\" | \"rtl\">>;\n locales: ResuxI18nLocale[];\n defaultLocale: string;\n fallbackLocale: string;\n strategy: ResuxI18nStrategy;\n t: (key: string, params?: ResuxI18nTranslationParams) => string;\n tm: (key: string) => unknown;\n resolveLocalized: (value: unknown) => string | null;\n localePath: (to: string, localeCode?: string) => string;\n switchLocalePath: (localeCode: string, to?: string) => string;\n setLocale: (localeCode: string, to?: string) => Promise<void> | void;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n\nfunction readCurrentRoutePath(): string {\n if (typeof window !== \"undefined\" && typeof location !== \"undefined\") {\n return `${location.pathname}${location.search}${location.hash}`;\n }\n\n const app = useResuxApp();\n const currentRoute = app.route;\n if (currentRoute && typeof currentRoute.path === \"string\" && currentRoute.path.trim()) {\n return currentRoute.path;\n }\n\n return \"/\";\n}\n\nfunction readClientRouter(): ResuxRouter | null {\n const maybeRouter = (globalThis as { __RESUX_ROUTER__?: unknown }).__RESUX_ROUTER__;\n if (!isRecord(maybeRouter)) {\n return null;\n }\n const push = maybeRouter.push;\n const replace = maybeRouter.replace;\n const back = maybeRouter.back;\n const forward = maybeRouter.forward;\n const go = maybeRouter.go;\n if (\n typeof push !== \"function\"\n || typeof replace !== \"function\"\n || typeof back !== \"function\"\n || typeof forward !== \"function\"\n || typeof go !== \"function\"\n ) {\n return null;\n }\n return maybeRouter as unknown as ResuxRouter;\n}\n\nfunction extractDynamicImportPath(fn: () => unknown): string | null {\n const source = String(fn);\n const match = source.match(/import\\(([\"'`])(.+?)\\1\\)/);\n if (!match) {\n return null;\n }\n return match[2] ?? null;\n}\n\nfunction normalizeMessageModule(value: unknown): MessageRecord {\n if (isRecord(value) && isRecord(value.default)) {\n return value.default;\n }\n return isRecord(value) ? value : {};\n}\n\nasync function loadMessageFromPath(rootDir: string, filePath: string): Promise<MessageRecord> {\n let absolute = filePath;\n if (filePath.startsWith(\"file://\")) {\n try {\n absolute = fileURLToPath(filePath);\n } catch {\n absolute = filePath;\n }\n } else if (!path.isAbsolute(filePath)) {\n absolute = path.resolve(rootDir, filePath);\n }\n\n const cleanPath = absolute.split(\"?\")[0].split(\"#\")[0];\n if (cleanPath.toLowerCase().endsWith(\".json\")) {\n try {\n return JSON.parse(await readFile(cleanPath, \"utf8\")) as MessageRecord;\n } catch {\n return {};\n }\n }\n try {\n const imported = await import(filePath.startsWith(\"file://\") ? filePath : pathToFileURL(absolute).href);\n return normalizeMessageModule(imported.default ?? imported);\n } catch {\n return {};\n }\n}\n\nasync function resolveMessageSource(rootDir: string, source: ResuxI18nMessageSource | undefined): Promise<MessageRecord> {\n if (!source) {\n return {};\n }\n\n if (typeof source === \"string\") {\n return loadMessageFromPath(rootDir, source);\n }\n\n if (typeof source === \"function\") {\n const dynamicPath = extractDynamicImportPath(source);\n if (dynamicPath) {\n const absolute = path.isAbsolute(dynamicPath) ? dynamicPath : path.resolve(rootDir, dynamicPath);\n if (absolute.toLowerCase().endsWith(\".json\")) {\n return loadMessageFromPath(rootDir, absolute);\n }\n }\n try {\n const loaded = await source();\n return normalizeMessageModule(loaded);\n } catch {\n if (dynamicPath) {\n return loadMessageFromPath(rootDir, dynamicPath);\n }\n return {};\n }\n }\n\n return normalizeMessageModule(source);\n}\n\nasync function resolveMessages(\n rootDir: string,\n locales: ResuxI18nLocaleInput[],\n messages: Record<string, ResuxI18nMessageSource> | undefined\n): Promise<Record<string, MessageRecord>> {\n const resolved: Record<string, MessageRecord> = {};\n for (const locale of locales) {\n const code = String(locale.code || \"\").trim().toLowerCase();\n if (!code) {\n continue;\n }\n resolved[code] = await resolveMessageSource(rootDir, messages?.[code]);\n }\n return resolved;\n}\n\nasync function buildRuntimeI18nConfig(\n context: ResuxModuleContext,\n inlineOptions: ResuxI18nModuleOptions\n): Promise<ResuxI18nRuntimeConfig | null> {\n const configFromResux = isRecord(context.options.i18n) ? context.options.i18n : {};\n const inline = isRecord(inlineOptions) ? inlineOptions : {};\n const rawLocales = Array.isArray(inline.locales)\n ? inline.locales\n : Array.isArray(configFromResux.locales)\n ? configFromResux.locales\n : [];\n const mergedMessages = {\n ...(isRecord(configFromResux.messages) ? configFromResux.messages : {}),\n ...(isRecord(inline.messages) ? inline.messages : {})\n };\n const mergedSeo = {\n ...(isRecord(configFromResux.seo) ? configFromResux.seo : {}),\n ...(isRecord(inline.seo) ? inline.seo : {})\n };\n const merged = {\n ...configFromResux,\n ...inline,\n locales: rawLocales,\n messages: mergedMessages,\n seo: mergedSeo\n } as ResuxI18nConfigInput;\n\n if (!Array.isArray(merged.locales) || !merged.locales.length) {\n return null;\n }\n\n const locales: ResuxI18nLocaleInput[] = merged.locales\n .filter((locale) => isRecord(locale))\n .map((locale) => ({\n code: String(locale.code ?? \"\").trim().toLowerCase(),\n name: typeof locale.name === \"string\" ? locale.name : undefined,\n dir: locale.dir === \"rtl\" ? \"rtl\" as const : \"ltr\" as const\n }))\n .filter((locale) => locale.code.length > 0);\n\n if (!locales.length) {\n return null;\n }\n\n const firstLocale = locales[0].code;\n const rawConfig: Record<string, unknown> = {\n defaultLocale: typeof merged.defaultLocale === \"string\" ? merged.defaultLocale.toLowerCase() : firstLocale,\n fallbackLocale: typeof merged.fallbackLocale === \"string\" ? merged.fallbackLocale.toLowerCase() : undefined,\n strategy: normalizeI18nStrategy(merged.strategy),\n locales,\n messages: await resolveMessages(context.rootDir, locales, merged.messages),\n seo: {\n hreflang: !isRecord(merged.seo) || merged.seo.hreflang !== false\n }\n };\n\n return normalizeI18nRuntimeConfig(rawConfig);\n}\n\nfunction readRuntimeI18nConfig(): ResuxI18nRuntimeConfig | null {\n const runtimeConfig = useResuxApp().$config as RuntimeConfig;\n const publicConfig = isRecord(runtimeConfig.public) ? runtimeConfig.public : {};\n return normalizeI18nRuntimeConfig(publicConfig.i18n);\n}\n\nconst I18N_LOCALE_STATE_KEY = \"__resux_i18n_locale_state\";\n\nfunction resolveConfiguredLocale(config: ResuxI18nRuntimeConfig, localeCode: string): ResuxI18nLocale | null {\n const normalized = String(localeCode || \"\").trim().toLowerCase();\n return config.locales.find((locale) => locale.code === normalized) ?? null;\n}\n\nfunction useI18nLocaleState(config: ResuxI18nRuntimeConfig): Ref<string> {\n const app = useResuxApp();\n const existing = app.provides[I18N_LOCALE_STATE_KEY];\n if (isRecord(existing) && typeof existing.value === \"string\") {\n return existing as unknown as Ref<string>;\n }\n\n const initialLocale = resolveI18nRoute(readCurrentRoutePath(), config).locale.code;\n const state = ref(initialLocale);\n app.provide(I18N_LOCALE_STATE_KEY, state);\n return state;\n}\n\nfunction applyNoPrefixDocumentLocale(config: ResuxI18nRuntimeConfig, localeCode: string): void {\n if (typeof document === \"undefined\") {\n return;\n }\n const html = document.documentElement;\n if (!html) {\n return;\n }\n html.setAttribute(\"lang\", localeCode);\n html.setAttribute(\"dir\", resolveLocaleDirection(config, localeCode));\n}\n\nfunction fallbackI18nConfig(): ResuxI18nRuntimeConfig {\n return {\n defaultLocale: \"en\",\n fallbackLocale: \"en\",\n strategy: \"prefix_except_default\",\n locales: [{ code: \"en\", dir: \"ltr\", name: \"English\" }],\n messages: { en: {} }\n };\n}\n\nexport function useI18n(): UseI18nResult {\n const runtimeI18n = readRuntimeI18nConfig() ?? fallbackI18nConfig();\n const localeState = useI18nLocaleState(runtimeI18n);\n const locale = computed(() => runtimeI18n.strategy === \"no_prefix\"\n ? localeState.value\n : resolveI18nRoute(readCurrentRoutePath(), runtimeI18n).locale.code);\n const dir = computed(() => resolveLocaleDirection(runtimeI18n, locale.value));\n\n return {\n locale,\n dir,\n locales: runtimeI18n.locales,\n defaultLocale: runtimeI18n.defaultLocale,\n fallbackLocale: runtimeI18n.fallbackLocale,\n strategy: runtimeI18n.strategy,\n t(key: string, params: ResuxI18nTranslationParams = {}): string {\n return translateText(runtimeI18n, locale.value, key, params);\n },\n tm(key: string): unknown {\n return translateRaw(runtimeI18n, locale.value, key);\n },\n resolveLocalized(value: unknown): string | null {\n return resolveLocalizedValue(value, locale.value, runtimeI18n.fallbackLocale);\n },\n localePath(to: string, localeCode?: string): string {\n return buildLocalePath(to, localeCode ?? locale.value, runtimeI18n);\n },\n switchLocalePath(localeCode: string, to?: string): string {\n return buildLocalePath(to ?? readCurrentRoutePath(), localeCode, runtimeI18n);\n },\n setLocale(localeCode: string, to?: string): Promise<void> | void {\n const targetLocale = resolveConfiguredLocale(runtimeI18n, localeCode);\n if (!targetLocale) {\n return;\n }\n if (runtimeI18n.strategy === \"no_prefix\") {\n localeState.value = targetLocale.code;\n applyNoPrefixDocumentLocale(runtimeI18n, targetLocale.code);\n return;\n }\n\n const target = buildLocalePath(to ?? readCurrentRoutePath(), targetLocale.code, runtimeI18n);\n const router = readClientRouter();\n if (router) {\n return router.push(target);\n }\n if (typeof window !== \"undefined\" && typeof location !== \"undefined\") {\n location.assign(target);\n }\n }\n };\n}\n\nexport function useLocalePath(): (to: string, localeCode?: string) => string {\n const { localePath } = useI18n();\n return localePath;\n}\n\nexport function useSwitchLocalePath(): (localeCode: string, to?: string) => string {\n const { switchLocalePath } = useI18n();\n return switchLocalePath;\n}\n\nexport function defineI18nConfig<T extends ResuxI18nConfigInput>(config: T): T {\n return config;\n}\n\nexport function createI18nHeadEntry(routePath: string, routeOrigin?: string): { htmlAttrs: Record<string, string>; link: Array<Record<string, string>> } {\n const runtimeI18n = readRuntimeI18nConfig();\n if (!runtimeI18n) {\n return { htmlAttrs: { lang: \"en\", dir: \"ltr\" }, link: [] };\n }\n return createI18nHead(routePath, routeOrigin, runtimeI18n);\n}\n\nexport default defineResuxModule<ResuxI18nModuleOptions>({\n defaults: {\n strategy: \"prefix_except_default\"\n },\n async setup(options, context) {\n const runtimeI18n = await buildRuntimeI18nConfig(context, options ?? {});\n if (!runtimeI18n) {\n return;\n }\n\n const sourceI18n = isRecord((context.options as Record<string, unknown>).i18n)\n ? (context.options as Record<string, unknown>).i18n as Record<string, unknown>\n : {};\n const sourceSeo = isRecord(sourceI18n.seo) ? sourceI18n.seo : {};\n const inlineSeoSource = isRecord(options) ? options : {};\n const inlineSeo = isRecord(inlineSeoSource.seo) ? inlineSeoSource.seo : {};\n const hreflangEnabled = sourceSeo.hreflang !== false;\n const hreflangInline = inlineSeo.hreflang !== false;\n\n context.extendRuntimeConfig({\n public: {\n i18n: {\n ...runtimeI18n,\n seo: {\n hreflang: hreflangEnabled && hreflangInline\n }\n }\n }\n });\n\n // Under the \"prefix\" strategy every locale is prefixed, so the bare root\n // path has no matching page. Redirect it to the default locale instead of\n // 404ing.\n if (runtimeI18n.strategy === \"prefix\") {\n context.addRouteRule(\"/\", {\n redirect: { to: `/${runtimeI18n.defaultLocale}`, statusCode: 302 }\n });\n }\n }\n});\n\nif (typeof globalThis !== \"undefined\") {\n (globalThis as any).__RESUX_USE_I18N__ ??= useI18n;\n (globalThis as any).__RESUX_USE_LOCALE_PATH__ ??= useLocalePath;\n (globalThis as any).__RESUX_USE_SWITCH_LOCALE_PATH__ ??= useSwitchLocalePath;\n}\n"],"mappings":";;;;;;;;AAsEA,SAAS,SAAS,OAAkD;CAClE,OAAO,QAAQ,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,CAAC;AAC5E;AAEA,SAAS,uBAA+B;CACtC,IAAI,OAAO,WAAW,eAAe,OAAO,aAAa,aACvD,OAAO,GAAG,SAAS,WAAW,SAAS,SAAS,SAAS;CAI3D,MAAM,eADM,YACW,CAAC,CAAC;CACzB,IAAI,gBAAgB,OAAO,aAAa,SAAS,YAAY,aAAa,KAAK,KAAK,GAClF,OAAO,aAAa;CAGtB,OAAO;AACT;AAEA,SAAS,mBAAuC;CAC9C,MAAM,cAAe,WAA8C;CACnE,IAAI,CAAC,SAAS,WAAW,GACvB,OAAO;CAET,MAAM,OAAO,YAAY;CACzB,MAAM,UAAU,YAAY;CAC5B,MAAM,OAAO,YAAY;CACzB,MAAM,UAAU,YAAY;CAC5B,MAAM,KAAK,YAAY;CACvB,IACE,OAAO,SAAS,cACb,OAAO,YAAY,cACnB,OAAO,SAAS,cAChB,OAAO,YAAY,cACnB,OAAO,OAAO,YAEjB,OAAO;CAET,OAAO;AACT;AAEA,SAAS,yBAAyB,IAAkC;CAElE,MAAM,QADS,OAAO,EACH,CAAC,CAAC,MAAM,0BAA0B;CACrD,IAAI,CAAC,OACH,OAAO;CAET,OAAO,MAAM,MAAM;AACrB;AAEA,SAAS,uBAAuB,OAA+B;CAC7D,IAAI,SAAS,KAAK,KAAK,SAAS,MAAM,OAAO,GAC3C,OAAO,MAAM;CAEf,OAAO,SAAS,KAAK,IAAI,QAAQ,CAAC;AACpC;AAEA,eAAe,oBAAoB,SAAiB,UAA0C;CAC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AAiB,YAAY;EAAI,EACnE,CAAC;CAEL;AACF,CAAC;AAED,IAAI,OAAO,eAAe,aAAa;CACrC,WAAoB,uBAAuB;CAC3C,WAAoB,8BAA8B;CAClD,WAAoB,qCAAqC;AAC3D"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/i18n/index.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport {\n computed,\n ref,\n defineResuxModule,\n type ResuxModuleContext,\n type Ref,\n useResuxApp,\n type ResuxRouter,\n type RuntimeConfig\n} from \"../runtime/index.js\";\nimport {\n buildLocalePath,\n createI18nHead,\n normalizeI18nRuntimeConfig,\n normalizeI18nStrategy,\n resolveI18nRoute,\n resolveLocaleDirection,\n resolveLocalizedValue,\n translateRaw,\n translateText,\n type ResuxI18nLocale,\n type ResuxI18nRuntimeConfig,\n type ResuxI18nStrategy,\n type ResuxI18nTranslationParams\n} from \"./shared.js\";\n\ntype MessageRecord = Record<string, unknown>;\n\nexport interface ResuxI18nLocaleInput {\n code: string;\n name?: string;\n dir?: \"ltr\" | \"rtl\";\n}\n\nexport type ResuxI18nMessageSource =\n | MessageRecord\n | string\n | (() => unknown | Promise<unknown>);\n\nexport interface ResuxI18nConfigInput {\n defaultLocale: string;\n fallbackLocale?: string;\n strategy?: ResuxI18nStrategy;\n locales: ResuxI18nLocaleInput[];\n messages?: Record<string, ResuxI18nMessageSource>;\n seo?: {\n hreflang?: boolean;\n };\n}\n\nexport interface ResuxI18nModuleOptions extends Partial<ResuxI18nConfigInput> {}\n\nexport interface UseI18nResult {\n locale: ReturnType<typeof computed<string>>;\n dir: ReturnType<typeof computed<\"ltr\" | \"rtl\">>;\n locales: ResuxI18nLocale[];\n defaultLocale: string;\n fallbackLocale: string;\n strategy: ResuxI18nStrategy;\n t: (key: string, params?: ResuxI18nTranslationParams) => string;\n tm: (key: string) => unknown;\n resolveLocalized: (value: unknown) => string | null;\n localePath: (to: string, localeCode?: string) => string;\n switchLocalePath: (localeCode: string, to?: string) => string;\n setLocale: (localeCode: string, to?: string) => Promise<void> | void;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n\nfunction readCurrentRoutePath(): string {\n if (typeof window !== \"undefined\" && typeof location !== \"undefined\") {\n return `${location.pathname}${location.search}${location.hash}`;\n }\n\n const app = useResuxApp();\n const currentRoute = app.route;\n if (currentRoute && typeof currentRoute.path === \"string\" && currentRoute.path.trim()) {\n return currentRoute.path;\n }\n\n return \"/\";\n}\n\nfunction readClientRouter(): ResuxRouter | null {\n const maybeRouter = (globalThis as { __RESUX_ROUTER__?: unknown }).__RESUX_ROUTER__;\n if (!isRecord(maybeRouter)) {\n return null;\n }\n const push = maybeRouter.push;\n const replace = maybeRouter.replace;\n const back = maybeRouter.back;\n const forward = maybeRouter.forward;\n const go = maybeRouter.go;\n if (\n typeof push !== \"function\"\n || typeof replace !== \"function\"\n || typeof back !== \"function\"\n || typeof forward !== \"function\"\n || typeof go !== \"function\"\n ) {\n return null;\n }\n return maybeRouter as unknown as ResuxRouter;\n}\n\nfunction extractDynamicImportPath(fn: () => unknown): string | null {\n const source = String(fn);\n const match = source.match(/import\\(([\"'`])(.+?)\\1\\)/);\n if (!match) {\n return null;\n }\n return match[2] ?? null;\n}\n\nfunction normalizeMessageModule(value: unknown): MessageRecord {\n if (isRecord(value) && isRecord(value.default)) {\n return value.default;\n }\n return isRecord(value) ? value : {};\n}\n\nasync function loadMessageFromPath(rootDir: string, filePath: string): Promise<MessageRecord> {\n let absolute = filePath;\n if (filePath.startsWith(\"file://\")) {\n try {\n absolute = fileURLToPath(filePath);\n } catch {\n absolute = filePath;\n }\n } else if (!path.isAbsolute(filePath)) {\n absolute = path.resolve(rootDir, filePath);\n }\n\n const cleanPath = absolute.split(\"?\")[0].split(\"#\")[0];\n if (cleanPath.toLowerCase().endsWith(\".json\")) {\n try {\n return JSON.parse(await readFile(cleanPath, \"utf8\")) as MessageRecord;\n } catch {\n return {};\n }\n }\n try {\n const imported = await import(filePath.startsWith(\"file://\") ? filePath : pathToFileURL(absolute).href);\n return normalizeMessageModule(imported.default ?? imported);\n } catch {\n return {};\n }\n}\n\nasync function resolveMessageSource(rootDir: string, source: ResuxI18nMessageSource | undefined): Promise<MessageRecord> {\n if (!source) {\n return {};\n }\n\n if (typeof source === \"string\") {\n return loadMessageFromPath(rootDir, source);\n }\n\n if (typeof source === \"function\") {\n const dynamicPath = extractDynamicImportPath(source);\n if (dynamicPath) {\n const absolute = path.isAbsolute(dynamicPath) ? dynamicPath : path.resolve(rootDir, dynamicPath);\n if (absolute.toLowerCase().endsWith(\".json\")) {\n return loadMessageFromPath(rootDir, absolute);\n }\n }\n try {\n const loaded = await source();\n return normalizeMessageModule(loaded);\n } catch {\n if (dynamicPath) {\n return loadMessageFromPath(rootDir, dynamicPath);\n }\n return {};\n }\n }\n\n return normalizeMessageModule(source);\n}\n\nasync function resolveMessages(\n rootDir: string,\n locales: ResuxI18nLocaleInput[],\n messages: Record<string, ResuxI18nMessageSource> | undefined\n): Promise<Record<string, MessageRecord>> {\n const resolved: Record<string, MessageRecord> = {};\n for (const locale of locales) {\n const code = String(locale.code || \"\").trim().toLowerCase();\n if (!code) {\n continue;\n }\n resolved[code] = await resolveMessageSource(rootDir, messages?.[code]);\n }\n return resolved;\n}\n\nasync function buildRuntimeI18nConfig(\n context: ResuxModuleContext,\n inlineOptions: ResuxI18nModuleOptions\n): Promise<ResuxI18nRuntimeConfig | null> {\n const configFromResux = isRecord(context.options.i18n) ? context.options.i18n : {};\n const inline = isRecord(inlineOptions) ? inlineOptions : {};\n const rawLocales = Array.isArray(inline.locales)\n ? inline.locales\n : Array.isArray(configFromResux.locales)\n ? configFromResux.locales\n : [];\n const mergedMessages = {\n ...(isRecord(configFromResux.messages) ? configFromResux.messages : {}),\n ...(isRecord(inline.messages) ? inline.messages : {})\n };\n const mergedSeo = {\n ...(isRecord(configFromResux.seo) ? configFromResux.seo : {}),\n ...(isRecord(inline.seo) ? inline.seo : {})\n };\n const merged = {\n ...configFromResux,\n ...inline,\n locales: rawLocales,\n messages: mergedMessages,\n seo: mergedSeo\n } as ResuxI18nConfigInput;\n\n if (!Array.isArray(merged.locales) || !merged.locales.length) {\n return null;\n }\n\n const locales: ResuxI18nLocaleInput[] = merged.locales\n .filter((locale) => isRecord(locale))\n .map((locale) => ({\n code: String(locale.code ?? \"\").trim().toLowerCase(),\n name: typeof locale.name === \"string\" ? locale.name : undefined,\n dir: locale.dir === \"rtl\" ? \"rtl\" as const : \"ltr\" as const\n }))\n .filter((locale) => locale.code.length > 0);\n\n if (!locales.length) {\n return null;\n }\n\n const firstLocale = locales[0].code;\n const rawConfig: Record<string, unknown> = {\n defaultLocale: typeof merged.defaultLocale === \"string\" ? merged.defaultLocale.toLowerCase() : firstLocale,\n fallbackLocale: typeof merged.fallbackLocale === \"string\" ? merged.fallbackLocale.toLowerCase() : undefined,\n strategy: normalizeI18nStrategy(merged.strategy),\n locales,\n messages: await resolveMessages(context.rootDir, locales, merged.messages),\n seo: {\n hreflang: !isRecord(merged.seo) || merged.seo.hreflang !== false\n }\n };\n\n return normalizeI18nRuntimeConfig(rawConfig);\n}\n\nfunction readRuntimeI18nConfig(): ResuxI18nRuntimeConfig | null {\n const runtimeConfig = useResuxApp().$config as RuntimeConfig;\n const publicConfig = isRecord(runtimeConfig.public) ? runtimeConfig.public : {};\n return normalizeI18nRuntimeConfig(publicConfig.i18n);\n}\n\nconst I18N_LOCALE_STATE_KEY = \"__resux_i18n_locale_state\";\n\nfunction resolveConfiguredLocale(config: ResuxI18nRuntimeConfig, localeCode: string): ResuxI18nLocale | null {\n const normalized = String(localeCode || \"\").trim().toLowerCase();\n return config.locales.find((locale) => locale.code === normalized) ?? null;\n}\n\nfunction useI18nLocaleState(config: ResuxI18nRuntimeConfig): Ref<string> {\n const app = useResuxApp();\n const existing = app.provides[I18N_LOCALE_STATE_KEY];\n if (isRecord(existing) && typeof existing.value === \"string\") {\n return existing as unknown as Ref<string>;\n }\n\n const initialLocale = resolveI18nRoute(readCurrentRoutePath(), config).locale.code;\n const state = ref(initialLocale);\n app.provide(I18N_LOCALE_STATE_KEY, state);\n return state;\n}\n\nfunction applyNoPrefixDocumentLocale(config: ResuxI18nRuntimeConfig, localeCode: string): void {\n if (typeof document === \"undefined\") {\n return;\n }\n const html = document.documentElement;\n if (!html) {\n return;\n }\n html.setAttribute(\"lang\", localeCode);\n html.setAttribute(\"dir\", resolveLocaleDirection(config, localeCode));\n}\n\nfunction fallbackI18nConfig(): ResuxI18nRuntimeConfig {\n return {\n defaultLocale: \"en\",\n fallbackLocale: \"en\",\n strategy: \"prefix_except_default\",\n locales: [{ code: \"en\", dir: \"ltr\", name: \"English\" }],\n messages: { en: {} }\n };\n}\n\nexport function useI18n(): UseI18nResult {\n const runtimeI18n = readRuntimeI18nConfig() ?? fallbackI18nConfig();\n const localeState = useI18nLocaleState(runtimeI18n);\n const locale = computed(() => runtimeI18n.strategy === \"no_prefix\"\n ? localeState.value\n : resolveI18nRoute(readCurrentRoutePath(), runtimeI18n).locale.code);\n const dir = computed(() => resolveLocaleDirection(runtimeI18n, locale.value));\n\n return {\n locale,\n dir,\n locales: runtimeI18n.locales,\n defaultLocale: runtimeI18n.defaultLocale,\n fallbackLocale: runtimeI18n.fallbackLocale,\n strategy: runtimeI18n.strategy,\n t(key: string, params: ResuxI18nTranslationParams = {}): string {\n return translateText(runtimeI18n, locale.value, key, params);\n },\n tm(key: string): unknown {\n return translateRaw(runtimeI18n, locale.value, key);\n },\n resolveLocalized(value: unknown): string | null {\n return resolveLocalizedValue(value, locale.value, runtimeI18n.fallbackLocale);\n },\n localePath(to: string, localeCode?: string): string {\n return buildLocalePath(to, localeCode ?? locale.value, runtimeI18n);\n },\n switchLocalePath(localeCode: string, to?: string): string {\n return buildLocalePath(to ?? readCurrentRoutePath(), localeCode, runtimeI18n);\n },\n setLocale(localeCode: string, to?: string): Promise<void> | void {\n const targetLocale = resolveConfiguredLocale(runtimeI18n, localeCode);\n if (!targetLocale) {\n return;\n }\n if (runtimeI18n.strategy === \"no_prefix\") {\n localeState.value = targetLocale.code;\n applyNoPrefixDocumentLocale(runtimeI18n, targetLocale.code);\n return;\n }\n\n const target = buildLocalePath(to ?? readCurrentRoutePath(), targetLocale.code, runtimeI18n);\n const router = readClientRouter();\n if (router) {\n return router.push(target);\n }\n if (typeof window !== \"undefined\" && typeof location !== \"undefined\") {\n location.assign(target);\n }\n }\n };\n}\n\nexport function useLocalePath(): (to: string, localeCode?: string) => string {\n const { localePath } = useI18n();\n return localePath;\n}\n\nexport function useSwitchLocalePath(): (localeCode: string, to?: string) => string {\n const { switchLocalePath } = useI18n();\n return switchLocalePath;\n}\n\nexport function defineI18nConfig<T extends ResuxI18nConfigInput>(config: T): T {\n return config;\n}\n\nexport function createI18nHeadEntry(routePath: string, routeOrigin?: string): { htmlAttrs: Record<string, string>; link: Array<Record<string, string>> } {\n const runtimeI18n = readRuntimeI18nConfig();\n if (!runtimeI18n) {\n return { htmlAttrs: { lang: \"en\", dir: \"ltr\" }, link: [] };\n }\n return createI18nHead(routePath, routeOrigin, runtimeI18n);\n}\n\nexport default defineResuxModule<ResuxI18nModuleOptions>({\n defaults: {\n strategy: \"prefix_except_default\"\n },\n async setup(options, context) {\n const runtimeI18n = await buildRuntimeI18nConfig(context, options ?? {});\n if (!runtimeI18n) {\n return;\n }\n\n const sourceI18n = isRecord((context.options as Record<string, unknown>).i18n)\n ? (context.options as Record<string, unknown>).i18n as Record<string, unknown>\n : {};\n const sourceSeo = isRecord(sourceI18n.seo) ? sourceI18n.seo : {};\n const inlineSeoSource = isRecord(options) ? options : {};\n const inlineSeo = isRecord(inlineSeoSource.seo) ? inlineSeoSource.seo : {};\n const hreflangEnabled = sourceSeo.hreflang !== false;\n const hreflangInline = inlineSeo.hreflang !== false;\n\n context.extendRuntimeConfig({\n public: {\n i18n: {\n ...runtimeI18n,\n seo: {\n hreflang: hreflangEnabled && hreflangInline\n }\n }\n }\n });\n\n // Under the \"prefix\" strategy every locale is prefixed, so the bare root\n // path has no matching page. Redirect it to the default locale instead of\n // 404ing.\n if (runtimeI18n.strategy === \"prefix\") {\n context.addRouteRule(\"/\", {\n redirect: { to: `/${runtimeI18n.defaultLocale}`, statusCode: 302 }\n });\n }\n }\n});\n\nif (typeof globalThis !== \"undefined\") {\n (globalThis as any).__RESUX_USE_I18N__ ??= useI18n;\n (globalThis as any).__RESUX_USE_LOCALE_PATH__ ??= useLocalePath;\n (globalThis as any).__RESUX_USE_SWITCH_LOCALE_PATH__ ??= useSwitchLocalePath;\n}\n"],"mappings":";;;;;;;;;AAsEA,SAAS,SAAS,OAAkD;AAClE,QAAO,QAAQ,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM,CAAC;;AAG7E,SAAS,uBAA+B;AACtC,KAAI,OAAO,WAAW,eAAe,OAAO,aAAa,YACvD,QAAO,GAAG,SAAS,WAAW,SAAS,SAAS,SAAS;CAI3D,MAAM,eADM,aAAa,CACA;AACzB,KAAI,gBAAgB,OAAO,aAAa,SAAS,YAAY,aAAa,KAAK,MAAM,CACnF,QAAO,aAAa;AAGtB,QAAO;;AAGT,SAAS,mBAAuC;CAC9C,MAAM,cAAe,WAA8C;AACnE,KAAI,CAAC,SAAS,YAAY,CACxB,QAAO;CAET,MAAM,OAAO,YAAY;CACzB,MAAM,UAAU,YAAY;CAC5B,MAAM,OAAO,YAAY;CACzB,MAAM,UAAU,YAAY;CAC5B,MAAM,KAAK,YAAY;AACvB,KACE,OAAO,SAAS,cACb,OAAO,YAAY,cACnB,OAAO,SAAS,cAChB,OAAO,YAAY,cACnB,OAAO,OAAO,WAEjB,QAAO;AAET,QAAO;;AAGT,SAAS,yBAAyB,IAAkC;CAElE,MAAM,QADS,OAAO,GAAG,CACJ,MAAM,2BAA2B;AACtD,KAAI,CAAC,MACH,QAAO;AAET,QAAO,MAAM,MAA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D,CAAC,WAAmB,qCAAqC"}
|
package/dist/i18n/shared.d.ts
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
//#region src/i18n/shared.d.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type ResuxI18nStrategy = "prefix_except_default" | "prefix" | "no_prefix";
|
|
3
|
+
interface ResuxI18nLocale {
|
|
4
4
|
code: string;
|
|
5
5
|
name?: string;
|
|
6
6
|
dir?: "ltr" | "rtl";
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
interface ResuxI18nRuntimeConfig {
|
|
9
9
|
defaultLocale: string;
|
|
10
10
|
fallbackLocale: string;
|
|
11
11
|
strategy: ResuxI18nStrategy;
|
|
12
12
|
locales: ResuxI18nLocale[];
|
|
13
13
|
messages: Record<string, Record<string, unknown>>;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
interface ResuxI18nResolvedRoute {
|
|
16
16
|
locale: ResuxI18nLocale;
|
|
17
17
|
basePath: string;
|
|
18
18
|
localizedPath: string;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
interface ResuxI18nTranslationParams {
|
|
21
21
|
[key: string]: string | number | boolean | null | undefined;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
declare function normalizeI18nStrategy(value: unknown): ResuxI18nStrategy;
|
|
24
|
+
declare function normalizeI18nRuntimeConfig(value: unknown): ResuxI18nRuntimeConfig | null;
|
|
25
|
+
declare function resolveI18nRoute(pathname: string, config: ResuxI18nRuntimeConfig): ResuxI18nResolvedRoute;
|
|
26
|
+
declare function buildLocalePath(path: string, localeCode: string, config: ResuxI18nRuntimeConfig): string;
|
|
27
|
+
declare function resolveLocaleDirection(config: ResuxI18nRuntimeConfig, localeCode: string): "ltr" | "rtl";
|
|
28
|
+
declare function resolveLocalizedValue(value: unknown, localeCode: string, fallbackLocale: string): string | null;
|
|
29
|
+
declare function translateRaw(config: ResuxI18nRuntimeConfig, localeCode: string, key: string): unknown;
|
|
30
|
+
declare function translateText(config: ResuxI18nRuntimeConfig, localeCode: string, key: string, params?: ResuxI18nTranslationParams): string;
|
|
31
|
+
declare function createI18nHead(routePath: string, routeOrigin: string | undefined, config: ResuxI18nRuntimeConfig, options?: {
|
|
32
32
|
includeHreflang?: boolean;
|
|
33
33
|
}): {
|
|
34
34
|
htmlAttrs: Record<string, string>;
|
|
35
35
|
link: Array<Record<string, string>>;
|
|
36
36
|
};
|
|
37
37
|
//#endregion
|
|
38
|
+
export { ResuxI18nLocale, ResuxI18nResolvedRoute, ResuxI18nRuntimeConfig, ResuxI18nStrategy, ResuxI18nTranslationParams, buildLocalePath, createI18nHead, normalizeI18nRuntimeConfig, normalizeI18nStrategy, resolveI18nRoute, resolveLocaleDirection, resolveLocalizedValue, translateRaw, translateText };
|
|
38
39
|
//# sourceMappingURL=shared.d.ts.map
|
package/dist/i18n/shared.js
CHANGED
|
@@ -39,7 +39,7 @@ function isLocalePrefixedForStrategy(strategy, localeCode, defaultLocale) {
|
|
|
39
39
|
function resolveLocaleByCode(locales, code) {
|
|
40
40
|
return locales.find((locale) => locale.code === code) ?? null;
|
|
41
41
|
}
|
|
42
|
-
const FORBIDDEN_MESSAGE_KEYS =
|
|
42
|
+
const FORBIDDEN_MESSAGE_KEYS = new Set([
|
|
43
43
|
"__proto__",
|
|
44
44
|
"prototype",
|
|
45
45
|
"constructor"
|
|
@@ -140,8 +140,8 @@ function resolveI18nRoute(pathname, config) {
|
|
|
140
140
|
function buildLocalePath(path, localeCode, config) {
|
|
141
141
|
const fallbackLocale = config.locales[0];
|
|
142
142
|
if (!fallbackLocale) {
|
|
143
|
-
const { pathname, suffix } = splitPathSuffix(path);
|
|
144
|
-
return `${normalizePathname(pathname)}${suffix}`;
|
|
143
|
+
const { pathname: pathname$1, suffix: suffix$1 } = splitPathSuffix(path);
|
|
144
|
+
return `${normalizePathname(pathname$1)}${suffix$1}`;
|
|
145
145
|
}
|
|
146
146
|
const targetLocale = resolveLocaleByCode(config.locales, normalizeLocaleCode(localeCode) ?? config.defaultLocale) ?? resolveLocaleByCode(config.locales, config.defaultLocale) ?? fallbackLocale;
|
|
147
147
|
const { pathname, suffix } = splitPathSuffix(path);
|
|
@@ -216,7 +216,7 @@ function createI18nHead(routePath, routeOrigin, config, options = {}) {
|
|
|
216
216
|
link
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
|
+
|
|
219
220
|
//#endregion
|
|
220
221
|
export { buildLocalePath, createI18nHead, normalizeI18nRuntimeConfig, normalizeI18nStrategy, resolveI18nRoute, resolveLocaleDirection, resolveLocalizedValue, translateRaw, translateText };
|
|
221
|
-
|
|
222
222
|
//# sourceMappingURL=shared.js.map
|