resuxjs 0.4.0-beta.2 → 0.4.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/dist/bin.d.ts +1 -1
  2. package/dist/bin.js +3 -2
  3. package/dist/bin.js.map +1 -1
  4. package/dist/build/index.d.ts +9 -8
  5. package/dist/build/index.js +2 -2
  6. package/dist/build/index.js.map +1 -1
  7. package/dist/cli.d.ts +5 -4
  8. package/dist/cli.js +115 -127
  9. package/dist/cli.js.map +1 -1
  10. package/dist/compiler/adapter.d.ts +6 -5
  11. package/dist/compiler/adapter.js +2 -1
  12. package/dist/compiler/adapter.js.map +1 -1
  13. package/dist/compiler/dev-warnings.d.ts +6 -5
  14. package/dist/compiler/dev-warnings.js +7 -6
  15. package/dist/compiler/dev-warnings.js.map +1 -1
  16. package/dist/compiler/directives.d.ts +4 -3
  17. package/dist/compiler/directives.js +2 -1
  18. package/dist/compiler/directives.js.map +1 -1
  19. package/dist/compiler/implementation.d.ts +21 -19
  20. package/dist/compiler/implementation.js +124 -133
  21. package/dist/compiler/index.d.ts +6 -5
  22. package/dist/compiler/index.js +2 -1
  23. package/dist/compiler/index.js.map +1 -1
  24. package/dist/core/config.d.ts +7 -5
  25. package/dist/core/config.js +1 -1
  26. package/dist/core/config.js.map +1 -1
  27. package/dist/core/hooks.d.ts +7 -6
  28. package/dist/core/hooks.js +1 -1
  29. package/dist/core/hooks.js.map +1 -1
  30. package/dist/core/index.js +2 -1
  31. package/dist/core/module-container.d.ts +22 -20
  32. package/dist/core/module-container.js +3 -3
  33. package/dist/core/module-container.js.map +1 -1
  34. package/dist/core/resux.d.ts +5 -3
  35. package/dist/core/resux.js +2 -1
  36. package/dist/core/resux.js.map +1 -1
  37. package/dist/create-bin.d.ts +1 -1
  38. package/dist/create-bin.js +3 -2
  39. package/dist/create-bin.js.map +1 -1
  40. package/dist/create.d.ts +3 -2
  41. package/dist/create.js +7 -10
  42. package/dist/create.js.map +1 -1
  43. package/dist/deploy/cloudflare.d.ts +3 -1
  44. package/dist/deploy/cloudflare.js +2 -1
  45. package/dist/deploy/cloudflare.js.map +1 -1
  46. package/dist/deploy/common.d.ts +13 -11
  47. package/dist/deploy/common.js +2 -1
  48. package/dist/deploy/common.js.map +1 -1
  49. package/dist/deploy/framework-runtime.d.ts +2 -1
  50. package/dist/deploy/framework-runtime.js +2 -1
  51. package/dist/deploy/framework-runtime.js.map +1 -1
  52. package/dist/deploy/index.d.ts +4 -2
  53. package/dist/deploy/index.js +4 -6
  54. package/dist/deploy/index.js.map +1 -1
  55. package/dist/deploy/netlify.d.ts +3 -1
  56. package/dist/deploy/netlify.js +2 -1
  57. package/dist/deploy/netlify.js.map +1 -1
  58. package/dist/deploy/node.d.ts +3 -1
  59. package/dist/deploy/node.js +3 -3
  60. package/dist/deploy/node.js.map +1 -1
  61. package/dist/deploy/production-report.d.ts +2 -1
  62. package/dist/deploy/production-report.js +2 -1
  63. package/dist/deploy/production-report.js.map +1 -1
  64. package/dist/deploy/runtime-dependencies.d.ts +5 -4
  65. package/dist/deploy/runtime-dependencies.js +3 -3
  66. package/dist/deploy/runtime-dependencies.js.map +1 -1
  67. package/dist/deploy/static.d.ts +3 -1
  68. package/dist/deploy/static.js +2 -1
  69. package/dist/deploy/static.js.map +1 -1
  70. package/dist/deploy/types.d.ts +8 -7
  71. package/dist/deploy/types.js +1 -1
  72. package/dist/deploy/vercel.d.ts +4 -2
  73. package/dist/deploy/vercel.js +2 -1
  74. package/dist/deploy/vercel.js.map +1 -1
  75. package/dist/fonts/index.d.ts +5 -4
  76. package/dist/fonts/index.js +3 -2
  77. package/dist/fonts/index.js.map +1 -1
  78. package/dist/globals.d.ts +2 -2
  79. package/dist/globals.js +1 -1
  80. package/dist/halal-core/ai/classifyProject.d.ts +5 -3
  81. package/dist/halal-core/ai/classifyProject.js +2 -1
  82. package/dist/halal-core/ai/classifyProject.js.map +1 -1
  83. package/dist/halal-core/ai/classifyRuntimeContent.d.ts +3 -1
  84. package/dist/halal-core/ai/classifyRuntimeContent.js +2 -1
  85. package/dist/halal-core/ai/classifyRuntimeContent.js.map +1 -1
  86. package/dist/halal-core/ai/createProjectSummary.d.ts +2 -1
  87. package/dist/halal-core/ai/createProjectSummary.js +2 -1
  88. package/dist/halal-core/ai/createProjectSummary.js.map +1 -1
  89. package/dist/halal-core/ai/halalClassifierPrompt.d.ts +2 -1
  90. package/dist/halal-core/ai/halalClassifierPrompt.js +1 -1
  91. package/dist/halal-core/ai/redactSensitiveData.d.ts +2 -1
  92. package/dist/halal-core/ai/redactSensitiveData.js +1 -1
  93. package/dist/halal-core/ai/redactSensitiveData.js.map +1 -1
  94. package/dist/halal-core/ai/validateAiResponse.d.ts +3 -1
  95. package/dist/halal-core/ai/validateAiResponse.js +3 -3
  96. package/dist/halal-core/ai/validateAiResponse.js.map +1 -1
  97. package/dist/halal-core/cli/check.d.ts +2 -1
  98. package/dist/halal-core/cli/check.js +3 -3
  99. package/dist/halal-core/cli/check.js.map +1 -1
  100. package/dist/halal-core/cli/explain.d.ts +2 -1
  101. package/dist/halal-core/cli/explain.js +3 -3
  102. package/dist/halal-core/cli/explain.js.map +1 -1
  103. package/dist/halal-core/cli/report.d.ts +2 -1
  104. package/dist/halal-core/cli/report.js +3 -3
  105. package/dist/halal-core/cli/report.js.map +1 -1
  106. package/dist/halal-core/cli/submitReview.d.ts +2 -1
  107. package/dist/halal-core/cli/submitReview.js +3 -3
  108. package/dist/halal-core/cli/submitReview.js.map +1 -1
  109. package/dist/halal-core/cli/verifyReview.d.ts +2 -1
  110. package/dist/halal-core/cli/verifyReview.js +3 -4
  111. package/dist/halal-core/cli/verifyReview.js.map +1 -1
  112. package/dist/halal-core/config.d.ts +9 -8
  113. package/dist/halal-core/config.js +2 -1
  114. package/dist/halal-core/config.js.map +1 -1
  115. package/dist/halal-core/crypto/integrity.d.ts +6 -5
  116. package/dist/halal-core/crypto/integrity.js +2 -1
  117. package/dist/halal-core/crypto/integrity.js.map +1 -1
  118. package/dist/halal-core/enforce.d.ts +6 -5
  119. package/dist/halal-core/enforce.js +13 -15
  120. package/dist/halal-core/enforce.js.map +1 -1
  121. package/dist/halal-core/index.js +2 -1
  122. package/dist/halal-core/lifecycle.d.ts +2 -1
  123. package/dist/halal-core/lifecycle.js +2 -1
  124. package/dist/halal-core/lifecycle.js.map +1 -1
  125. package/dist/halal-core/policy.d.ts +3 -1
  126. package/dist/halal-core/policy.js +2 -1
  127. package/dist/halal-core/policy.js.map +1 -1
  128. package/dist/halal-core/report/formatBrowserOverlay.d.ts +3 -1
  129. package/dist/halal-core/report/formatBrowserOverlay.js +1 -1
  130. package/dist/halal-core/report/formatBrowserOverlay.js.map +1 -1
  131. package/dist/halal-core/report/formatTerminalReport.d.ts +3 -1
  132. package/dist/halal-core/report/formatTerminalReport.js +1 -1
  133. package/dist/halal-core/report/formatTerminalReport.js.map +1 -1
  134. package/dist/halal-core/report/generateHalalReport.d.ts +4 -2
  135. package/dist/halal-core/report/generateHalalReport.js +5 -7
  136. package/dist/halal-core/report/generateHalalReport.js.map +1 -1
  137. package/dist/halal-core/report/signReport.d.ts +4 -2
  138. package/dist/halal-core/report/signReport.js +2 -1
  139. package/dist/halal-core/report/signReport.js.map +1 -1
  140. package/dist/halal-core/report/verifyReport.d.ts +5 -3
  141. package/dist/halal-core/report/verifyReport.js +4 -3
  142. package/dist/halal-core/report/verifyReport.js.map +1 -1
  143. package/dist/halal-core/review/createReviewRequest.d.ts +3 -1
  144. package/dist/halal-core/review/createReviewRequest.js +3 -3
  145. package/dist/halal-core/review/createReviewRequest.js.map +1 -1
  146. package/dist/halal-core/review/reviewPolicy.d.ts +4 -3
  147. package/dist/halal-core/review/reviewPolicy.js +1 -1
  148. package/dist/halal-core/review/reviewPolicy.js.map +1 -1
  149. package/dist/halal-core/review/signedReviewFile.d.ts +6 -4
  150. package/dist/halal-core/review/signedReviewFile.js +2 -1
  151. package/dist/halal-core/review/signedReviewFile.js.map +1 -1
  152. package/dist/halal-core/review/verifyReviewApproval.d.ts +3 -2
  153. package/dist/halal-core/review/verifyReviewApproval.js +2 -1
  154. package/dist/halal-core/review/verifyReviewApproval.js.map +1 -1
  155. package/dist/halal-core/rules/adultContentRules.d.ts +3 -2
  156. package/dist/halal-core/rules/adultContentRules.js +1 -1
  157. package/dist/halal-core/rules/adultContentRules.js.map +1 -1
  158. package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +3 -2
  159. package/dist/halal-core/rules/alcoholDrugVapeRules.js +1 -1
  160. package/dist/halal-core/rules/alcoholDrugVapeRules.js.map +1 -1
  161. package/dist/halal-core/rules/childSafetyRules.d.ts +3 -2
  162. package/dist/halal-core/rules/childSafetyRules.js +1 -1
  163. package/dist/halal-core/rules/childSafetyRules.js.map +1 -1
  164. package/dist/halal-core/rules/coreCategories.d.ts +3 -2
  165. package/dist/halal-core/rules/coreCategories.js +1 -1
  166. package/dist/halal-core/rules/coreCategories.js.map +1 -1
  167. package/dist/halal-core/rules/cyberAbuseRules.d.ts +3 -2
  168. package/dist/halal-core/rules/cyberAbuseRules.js +1 -1
  169. package/dist/halal-core/rules/cyberAbuseRules.js.map +1 -1
  170. package/dist/halal-core/rules/defaultBlockedRules.d.ts +3 -1
  171. package/dist/halal-core/rules/defaultBlockedRules.js +9 -11
  172. package/dist/halal-core/rules/defaultBlockedRules.js.map +1 -1
  173. package/dist/halal-core/rules/dependencyRules.d.ts +3 -2
  174. package/dist/halal-core/rules/dependencyRules.js +1 -1
  175. package/dist/halal-core/rules/dependencyRules.js.map +1 -1
  176. package/dist/halal-core/rules/endpointRules.d.ts +3 -2
  177. package/dist/halal-core/rules/endpointRules.js +1 -1
  178. package/dist/halal-core/rules/endpointRules.js.map +1 -1
  179. package/dist/halal-core/rules/environmentalHarmRules.d.ts +3 -2
  180. package/dist/halal-core/rules/environmentalHarmRules.js +1 -1
  181. package/dist/halal-core/rules/environmentalHarmRules.js.map +1 -1
  182. package/dist/halal-core/rules/financeRibaRules.d.ts +3 -2
  183. package/dist/halal-core/rules/financeRibaRules.js +1 -1
  184. package/dist/halal-core/rules/financeRibaRules.js.map +1 -1
  185. package/dist/halal-core/rules/gamblingRules.d.ts +3 -2
  186. package/dist/halal-core/rules/gamblingRules.js +1 -1
  187. package/dist/halal-core/rules/gamblingRules.js.map +1 -1
  188. package/dist/halal-core/rules/generalHarmRules.d.ts +3 -2
  189. package/dist/halal-core/rules/generalHarmRules.js +1 -1
  190. package/dist/halal-core/rules/generalHarmRules.js.map +1 -1
  191. package/dist/halal-core/rules/healthHarmRules.d.ts +3 -2
  192. package/dist/halal-core/rules/healthHarmRules.js +1 -1
  193. package/dist/halal-core/rules/healthHarmRules.js.map +1 -1
  194. package/dist/halal-core/rules/keywordRules.d.ts +2 -1
  195. package/dist/halal-core/rules/keywordRules.js +1 -1
  196. package/dist/halal-core/rules/keywordRules.js.map +1 -1
  197. package/dist/halal-core/rules/privacyAbuseRules.d.ts +3 -2
  198. package/dist/halal-core/rules/privacyAbuseRules.js +1 -1
  199. package/dist/halal-core/rules/privacyAbuseRules.js.map +1 -1
  200. package/dist/halal-core/rules/scamFraudRules.d.ts +3 -2
  201. package/dist/halal-core/rules/scamFraudRules.js +1 -1
  202. package/dist/halal-core/rules/scamFraudRules.js.map +1 -1
  203. package/dist/halal-core/rules/selfHarmRules.d.ts +3 -2
  204. package/dist/halal-core/rules/selfHarmRules.js +1 -1
  205. package/dist/halal-core/rules/selfHarmRules.js.map +1 -1
  206. package/dist/halal-core/rules/violenceExtremismRules.d.ts +3 -2
  207. package/dist/halal-core/rules/violenceExtremismRules.js +1 -1
  208. package/dist/halal-core/rules/violenceExtremismRules.js.map +1 -1
  209. package/dist/halal-core/runtime/guard.d.ts +5 -3
  210. package/dist/halal-core/runtime/guard.js +2 -1
  211. package/dist/halal-core/runtime/guard.js.map +1 -1
  212. package/dist/halal-core/runtime/index.js +2 -1
  213. package/dist/halal-core/runtime/reviewedMemory.d.ts +6 -4
  214. package/dist/halal-core/runtime/reviewedMemory.js +3 -2
  215. package/dist/halal-core/runtime/reviewedMemory.js.map +1 -1
  216. package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +7 -5
  217. package/dist/halal-core/runtime/serializeRuntimeContent.js +4 -3
  218. package/dist/halal-core/runtime/serializeRuntimeContent.js.map +1 -1
  219. package/dist/halal-core/runtime/types.d.ts +11 -9
  220. package/dist/halal-core/runtime/types.js +1 -1
  221. package/dist/halal-core/scanner/scanApiRoutes.d.ts +2 -1
  222. package/dist/halal-core/scanner/scanApiRoutes.js +2 -1
  223. package/dist/halal-core/scanner/scanApiRoutes.js.map +1 -1
  224. package/dist/halal-core/scanner/scanComponents.d.ts +2 -1
  225. package/dist/halal-core/scanner/scanComponents.js +2 -1
  226. package/dist/halal-core/scanner/scanComponents.js.map +1 -1
  227. package/dist/halal-core/scanner/scanContent.d.ts +3 -2
  228. package/dist/halal-core/scanner/scanContent.js +4 -3
  229. package/dist/halal-core/scanner/scanContent.js.map +1 -1
  230. package/dist/halal-core/scanner/scanDependencies.d.ts +2 -1
  231. package/dist/halal-core/scanner/scanDependencies.js +2 -1
  232. package/dist/halal-core/scanner/scanDependencies.js.map +1 -1
  233. package/dist/halal-core/scanner/scanDomains.d.ts +2 -1
  234. package/dist/halal-core/scanner/scanDomains.js +1 -1
  235. package/dist/halal-core/scanner/scanDomains.js.map +1 -1
  236. package/dist/halal-core/scanner/scanEnvNames.d.ts +2 -1
  237. package/dist/halal-core/scanner/scanEnvNames.js +2 -1
  238. package/dist/halal-core/scanner/scanEnvNames.js.map +1 -1
  239. package/dist/halal-core/scanner/scanMetadata.d.ts +3 -2
  240. package/dist/halal-core/scanner/scanMetadata.js +2 -1
  241. package/dist/halal-core/scanner/scanMetadata.js.map +1 -1
  242. package/dist/halal-core/scanner/scanPages.d.ts +2 -1
  243. package/dist/halal-core/scanner/scanPages.js +2 -1
  244. package/dist/halal-core/scanner/scanPages.js.map +1 -1
  245. package/dist/halal-core/scanner/scanProject.d.ts +4 -2
  246. package/dist/halal-core/scanner/scanProject.js +2 -1
  247. package/dist/halal-core/scanner/scanProject.js.map +1 -1
  248. package/dist/halal-core/scanner/scanRoutes.d.ts +2 -1
  249. package/dist/halal-core/scanner/scanRoutes.js +2 -1
  250. package/dist/halal-core/scanner/scanRoutes.js.map +1 -1
  251. package/dist/halal-core/scanner/scanTranslations.d.ts +2 -1
  252. package/dist/halal-core/scanner/scanTranslations.js +2 -1
  253. package/dist/halal-core/scanner/scanTranslations.js.map +1 -1
  254. package/dist/halal-core/status.d.ts +3 -2
  255. package/dist/halal-core/status.js +1 -1
  256. package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +2 -1
  257. package/dist/halal-core/tamper/verifyCoreIntegrity.js +2 -1
  258. package/dist/halal-core/tamper/verifyCoreIntegrity.js.map +1 -1
  259. package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +2 -1
  260. package/dist/halal-core/tamper/verifyLifecycleHooks.js +1 -1
  261. package/dist/halal-core/tamper/verifyLifecycleHooks.js.map +1 -1
  262. package/dist/halal-core/tamper/verifyReportSignature.d.ts +3 -1
  263. package/dist/halal-core/tamper/verifyReportSignature.js +3 -3
  264. package/dist/halal-core/tamper/verifyReportSignature.js.map +1 -1
  265. package/dist/halal.js +2 -1
  266. package/dist/i18n/index.d.ts +12 -11
  267. package/dist/i18n/index.js +5 -6
  268. package/dist/i18n/index.js.map +1 -1
  269. package/dist/i18n/shared.d.ts +15 -14
  270. package/dist/i18n/shared.js +4 -4
  271. package/dist/i18n/shared.js.map +1 -1
  272. package/dist/icons/index.d.ts +20 -18
  273. package/dist/icons/index.js +5 -4
  274. package/dist/icons/index.js.map +1 -1
  275. package/dist/index.d.ts +1 -1
  276. package/dist/index.js +2 -1
  277. package/dist/kit/index.d.ts +23 -21
  278. package/dist/kit/index.js +2 -1
  279. package/dist/kit/index.js.map +1 -1
  280. package/dist/nitro-server/index.d.ts +3 -2
  281. package/dist/nitro-server/index.js +1 -1
  282. package/dist/nitro-server/index.js.map +1 -1
  283. package/dist/node.d.ts +4 -2
  284. package/dist/node.js +7 -6
  285. package/dist/node.js.map +1 -1
  286. package/dist/reactivity/computed.d.ts +5 -3
  287. package/dist/reactivity/computed.js +3 -3
  288. package/dist/reactivity/computed.js.map +1 -1
  289. package/dist/reactivity/effect.d.ts +15 -13
  290. package/dist/reactivity/effect.js +9 -10
  291. package/dist/reactivity/effect.js.map +1 -1
  292. package/dist/reactivity/index.js +2 -1
  293. package/dist/reactivity/reactive.d.ts +6 -5
  294. package/dist/reactivity/reactive.js +5 -4
  295. package/dist/reactivity/reactive.js.map +1 -1
  296. package/dist/reactivity/readonly.js +2 -1
  297. package/dist/reactivity/ref.d.ts +9 -7
  298. package/dist/reactivity/ref.js +2 -4
  299. package/dist/reactivity/ref.js.map +1 -1
  300. package/dist/reactivity/scheduler.d.ts +5 -4
  301. package/dist/reactivity/scheduler.js +1 -1
  302. package/dist/reactivity/scheduler.js.map +1 -1
  303. package/dist/reactivity/types.d.ts +12 -11
  304. package/dist/reactivity/types.js +1 -1
  305. package/dist/reactivity/utils.d.ts +10 -9
  306. package/dist/reactivity/utils.js +1 -1
  307. package/dist/reactivity/utils.js.map +1 -1
  308. package/dist/reactivity/watch.d.ts +4 -2
  309. package/dist/reactivity/watch.js +4 -5
  310. package/dist/reactivity/watch.js.map +1 -1
  311. package/dist/runtime/core.d.ts +5 -4
  312. package/dist/runtime/core.js +9 -10
  313. package/dist/runtime/core.js.map +1 -1
  314. package/dist/runtime/index.d.ts +123 -122
  315. package/dist/runtime/index.js +45 -58
  316. package/dist/runtime/index.js.map +1 -1
  317. package/dist/runtime/reactivity.js +2 -1
  318. package/dist/runtime/resume.d.ts +15 -14
  319. package/dist/runtime/resume.js +3 -3
  320. package/dist/runtime/resume.js.map +1 -1
  321. package/dist/runtime/router.d.ts +5 -4
  322. package/dist/runtime/router.js +1 -1
  323. package/dist/runtime/router.js.map +1 -1
  324. package/dist/runtime/streaming.d.ts +7 -6
  325. package/dist/runtime/streaming.js +3 -3
  326. package/dist/runtime/streaming.js.map +1 -1
  327. package/dist/security/media-fetch.d.ts +11 -10
  328. package/dist/security/media-fetch.js +5 -4
  329. package/dist/security/media-fetch.js.map +1 -1
  330. package/dist/security/path-boundary.d.ts +5 -4
  331. package/dist/security/path-boundary.js +2 -1
  332. package/dist/security/path-boundary.js.map +1 -1
  333. package/dist/ui/index.d.ts +195 -193
  334. package/dist/ui/index.js +7 -8
  335. package/dist/ui/index.js.map +1 -1
  336. package/dist/vite-builder/index.d.ts +3 -2
  337. package/dist/vite-builder/index.js +1 -1
  338. package/dist/vite-builder/index.js.map +1 -1
  339. package/package.json +2 -2
@@ -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":";;;AAGA,SAAgB,WAAW,SAA2B;CACpD,MAAM,SAAmB,CAAC;CAC1B,MAAM,WAAW,KAAK,KAAK,SAAS,OAAO;CAE3C,IAAI,CAAC,WAAW,QAAQ,GACtB,OAAO;CAGT,SAAS,SAAS,KAAa;EAC7B,IAAI,QAAkB,CAAC;EACvB,IAAI;GACF,QAAQ,YAAY,GAAG;EACzB,QAAQ;GACN;EACF;EAEA,KAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,WAAW,KAAK,KAAK,KAAK,IAAI;GACpC,IAAI;GACJ,IAAI;IACF,QAAQ,SAAS,QAAQ;GAC3B,QAAQ;IACN;GACF;GAEA,IAAI,MAAM,YAAY,GACpB,SAAS,QAAQ;QACZ,IAAI,MAAM,OAAO,GAAG;IAGzB,MAAM,YAFW,KAAK,SAAS,UAAU,QAAQ,CAAC,CAAC,QAAQ,OAAO,GAEzC,CAAC,CACvB,QAAQ,0BAA0B,EAAE,CAAC,CACrC,QAAQ,YAAY,EAAE,CAAC,CACvB,QAAQ,WAAW,GAAG;IACzB,OAAO,KAAK,SAAS;GACvB;EACF;CACF;CAEA,SAAS,QAAQ;CACjB,OAAO;AACT"}
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
- export declare function scanTranslations(appRoot: string): string[];
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":";;;AAGA,SAAgB,iBAAiB,SAA2B;CAC1D,MAAM,QAAkB,CAAC;CACzB,MAAM,UAAU,KAAK,KAAK,SAAS,MAAM;CAEzC,IAAI,WAAW,OAAO,GACpB,IAAI;EACF,MAAM,QAAQ,YAAY,OAAO,CAAC,CAAC,QAAO,MAAK,EAAE,SAAS,OAAO,CAAC;EAClE,KAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,UAAU,aAAa,KAAK,KAAK,SAAS,IAAI,GAAG,MAAM;GAE7D,MAAM,OAAO,KAAK,MAAM,OAAO;GAC/B,MAAM,kBAAkB,QAAa;IACnC,IAAI,OAAO,QAAQ,UACjB,MAAM,KAAK,GAAG;SACT,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAC5C,KAAK,MAAM,OAAO,OAAO,KAAK,GAAG,GAC/B,eAAe,IAAI,IAAI;GAG7B;GACA,eAAe,IAAI;EACrB;CACF,QAAQ,CAER;CAGF,OAAO;AACT"}
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
- export type HalalGuardStatus = "allowed" | "warning" | "review_required" | "blocked";
3
- export interface HalalCheckResult {
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
- export declare function verifyCoreIntegrity(appRoot: string): boolean;
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":";;;AAGA,SAAgB,oBAAoB,SAA0B;CAE5D,MAAM,gBAAgB;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAGA,MAAM,WAAW,mBAAmB,IAAI,IAAI,YAAY,GAAG,CAAC,CAAC,QAAQ;CACrE,MAAM,YAAY,SAAS,WAAW,GAAG,KAAK,SAAS,OAAO,MAAM,SAAS,UAAU,CAAC,IAAI;CAC5F,MAAM,gBAAgB,KAAK,QAAQ,SAAS;CAE5C,KAAK,MAAM,QAAQ,eAAe;EAChC,MAAM,SAAS,KAAK,KAAK,eAAe,MAAM,GAAG,KAAK,IAAI;EAC1D,MAAM,SAAS,KAAK,KAAK,eAAe,MAAM,GAAG,KAAK,IAAI;EAC1D,IAAI,CAAC,WAAW,MAAM,KAAK,CAAC,WAAW,MAAM,GAAG;GAC9C,QAAQ,MAAM,gEAAgE,MAAM;GACpF,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
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
- export declare function verifyLifecycleHooksRegistered(hooks: any): boolean;
2
+ declare function verifyLifecycleHooksRegistered(hooks: any): boolean;
3
3
  //#endregion
4
+ export { verifyLifecycleHooksRegistered };
4
5
  //# sourceMappingURL=verifyLifecycleHooks.d.ts.map
@@ -9,7 +9,7 @@ function verifyLifecycleHooksRegistered(hooks) {
9
9
  }
10
10
  return true;
11
11
  }
12
+
12
13
  //#endregion
13
14
  export { verifyLifecycleHooksRegistered };
14
-
15
15
  //# sourceMappingURL=verifyLifecycleHooks.js.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;CAClE,IAAI,CAAC,OACH,OAAO;CAIT,MAAM,oBAAoB,OAAO,MAAM,SAAS,cAAc,MAAM,SAAS;CAC7E,MAAM,aAAa,OAAO,MAAM,SAAS,cAAc,MAAM,SAAS;CAEtE,IAAI,CAAC,qBAAqB,CAAC,YAAY;EACrC,QAAQ,MAAM,0EAA0E;EACxF,OAAO;CACT;CAEA,OAAO;AACT"}
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
- export declare function checkOnDiskReportSignature(outDir: string, options?: ReportVerificationOptions): {
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
- const content = JSON.parse(readFileSync(reportPath, "utf8"));
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":";;;;AAOA,SAAgB,2BACd,QACA,UAAqC,CAAC,GACD;CACrC,MAAM,aAAa,KAAK,KAAK,QAAQ,mBAAmB;CACxD,IAAI,CAAC,WAAW,UAAU,GACxB,OAAO;EAAE,OAAO;EAAO,QAAQ;CAAqC;CAGtE,IAAI;EACF,MAAM,UAAU,KAAK,MAAM,aAAa,YAAY,MAAM,CAAC;EAC3D,OAAO,cAAc,SAAS,OAAO;CACvC,SAAS,OAAO;EAEd,OAAO;GAAE,OAAO;GAAO,QAAQ,8CADf,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACkB;CACzF;AACF"}
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
- 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 };
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 };
@@ -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
- export interface ResuxI18nLocaleInput {
7
+ interface ResuxI18nLocaleInput {
7
8
  code: string;
8
9
  name?: string;
9
10
  dir?: "ltr" | "rtl";
10
11
  }
11
- export type ResuxI18nMessageSource = MessageRecord | string | (() => unknown | Promise<unknown>);
12
- export interface ResuxI18nConfigInput {
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
- export interface ResuxI18nModuleOptions extends Partial<ResuxI18nConfigInput> {}
23
- export interface UseI18nResult {
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
- export declare function useI18n(): UseI18nResult;
38
- export declare function useLocalePath(): (to: string, localeCode?: string) => string;
39
- export declare function useSwitchLocalePath(): (localeCode: string, to?: string) => string;
40
- export declare function defineI18nConfig<T extends ResuxI18nConfigInput>(config: T): T;
41
- export declare function createI18nHeadEntry(routePath: string, routeOrigin?: string): {
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
@@ -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
- const rawConfig = {
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
- const publicConfig = isRecord(runtimeConfig.public) ? runtimeConfig.public : {};
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
@@ -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,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AAM;GAAM,KAAK;EAAM;EAAG,MAAM,CAAC;CAAE;CAE3D,OAAO,eAAe,WAAW,aAAa,WAAW;AAC3D;AAEA,IAAA,eAAe,kBAA0C;CACvD,UAAU,EACR,UAAU,wBACZ;CACA,MAAM,MAAM,SAAS,SAAS;EAC5B,MAAM,cAAc,MAAM,uBAAuB,SAAS,WAAW,CAAC,CAAC;EACvE,IAAI,CAAC,aACH;EAGF,MAAM,aAAa,SAAU,QAAQ,QAAoC,IAAI,IACxE,QAAQ,QAAoC,OAC7C,CAAC;EACL,MAAM,YAAY,SAAS,WAAW,GAAG,IAAI,WAAW,MAAM,CAAC;EAC/D,MAAM,kBAAkB,SAAS,OAAO,IAAI,UAAU,CAAC;EACvD,MAAM,YAAY,SAAS,gBAAgB,GAAG,IAAI,gBAAgB,MAAM,CAAC;EACzE,MAAM,kBAAkB,UAAU,aAAa;EAC/C,MAAM,iBAAiB,UAAU,aAAa;EAE9C,QAAQ,oBAAoB,EAC1B,QAAQ,EACN,MAAM;GACJ,GAAG;GACH,KAAK,EACH,UAAU,mBAAmB,eAC/B;EACF,EACF,EACF,CAAC;EAKD,IAAI,YAAY,aAAa,UAC3B,QAAQ,aAAa,KAAK,EACxB,UAAU;GAAE,IAAI,IAAI,YAAY;GAAiB,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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BACX;CACD,MAAM,MAAM,SAAS,SAAS;EAC5B,MAAM,cAAc,MAAM,uBAAuB,SAAS,WAAW,EAAE,CAAC;AACxE,MAAI,CAAC,YACH;EAGF,MAAM,aAAa,SAAU,QAAQ,QAAoC,KAAK,GACzE,QAAQ,QAAoC,OAC7C,EAAE;EACN,MAAM,YAAY,SAAS,WAAW,IAAI,GAAG,WAAW,MAAM,EAAE;EAChE,MAAM,kBAAkB,SAAS,QAAQ,GAAG,UAAU,EAAE;EACxD,MAAM,YAAY,SAAS,gBAAgB,IAAI,GAAG,gBAAgB,MAAM,EAAE;EAC1E,MAAM,kBAAkB,UAAU,aAAa;EAC/C,MAAM,iBAAiB,UAAU,aAAa;AAE9C,UAAQ,oBAAoB,EAC1B,QAAQ,EACN,MAAM;GACJ,GAAG;GACH,KAAK,EACH,UAAU,mBAAmB,gBAC9B;GACF,EACF,EACF,CAAC;AAKF,MAAI,YAAY,aAAa,SAC3B,SAAQ,aAAa,KAAK,EACxB,UAAU;GAAE,IAAI,IAAI,YAAY;GAAiB,YAAY;GAAK,EACnE,CAAC;;CAGP,CAAC;AAEF,IAAI,OAAO,eAAe,aAAa;AACrC,CAAC,WAAmB,uBAAuB;AAC3C,CAAC,WAAmB,8BAA8B;AAClD,CAAC,WAAmB,qCAAqC"}
@@ -1,38 +1,39 @@
1
1
  //#region src/i18n/shared.d.ts
2
- export type ResuxI18nStrategy = "prefix_except_default" | "prefix" | "no_prefix";
3
- export interface ResuxI18nLocale {
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
- export interface ResuxI18nRuntimeConfig {
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
- export interface ResuxI18nResolvedRoute {
15
+ interface ResuxI18nResolvedRoute {
16
16
  locale: ResuxI18nLocale;
17
17
  basePath: string;
18
18
  localizedPath: string;
19
19
  }
20
- export interface ResuxI18nTranslationParams {
20
+ interface ResuxI18nTranslationParams {
21
21
  [key: string]: string | number | boolean | null | undefined;
22
22
  }
23
- export declare function normalizeI18nStrategy(value: unknown): ResuxI18nStrategy;
24
- export declare function normalizeI18nRuntimeConfig(value: unknown): ResuxI18nRuntimeConfig | null;
25
- export declare function resolveI18nRoute(pathname: string, config: ResuxI18nRuntimeConfig): ResuxI18nResolvedRoute;
26
- export declare function buildLocalePath(path: string, localeCode: string, config: ResuxI18nRuntimeConfig): string;
27
- export declare function resolveLocaleDirection(config: ResuxI18nRuntimeConfig, localeCode: string): "ltr" | "rtl";
28
- export declare function resolveLocalizedValue(value: unknown, localeCode: string, fallbackLocale: string): string | null;
29
- export declare function translateRaw(config: ResuxI18nRuntimeConfig, localeCode: string, key: string): unknown;
30
- export declare function translateText(config: ResuxI18nRuntimeConfig, localeCode: string, key: string, params?: ResuxI18nTranslationParams): string;
31
- export declare function createI18nHead(routePath: string, routeOrigin: string | undefined, config: ResuxI18nRuntimeConfig, options?: {
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
@@ -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 = /* @__PURE__ */ new Set([
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
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","names":[],"sources":["../../src/i18n/shared.ts"],"sourcesContent":["export type ResuxI18nStrategy = \"prefix_except_default\" | \"prefix\" | \"no_prefix\";\n\nexport interface ResuxI18nLocale {\n code: string;\n name?: string;\n dir?: \"ltr\" | \"rtl\";\n}\n\nexport interface ResuxI18nRuntimeConfig {\n defaultLocale: string;\n fallbackLocale: string;\n strategy: ResuxI18nStrategy;\n locales: ResuxI18nLocale[];\n messages: Record<string, Record<string, unknown>>;\n}\n\nexport interface ResuxI18nResolvedRoute {\n locale: ResuxI18nLocale;\n basePath: string;\n localizedPath: string;\n}\n\nexport interface ResuxI18nTranslationParams {\n [key: string]: string | number | boolean | null | undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n\nfunction normalizeLocaleCode(value: unknown): string | null {\n if (typeof value !== \"string\") {\n return null;\n }\n const normalized = value.trim().toLowerCase();\n if (!/^[a-z0-9-]+$/.test(normalized)) {\n return null;\n }\n return normalized;\n}\n\nfunction normalizePathname(pathname: string): string {\n const source = String(pathname || \"\").trim();\n if (!source) {\n return \"/\";\n }\n const withSlash = source.startsWith(\"/\") ? source : `/${source}`;\n if (withSlash !== \"/\" && withSlash.endsWith(\"/\")) {\n return withSlash.replace(/\\/+$/g, \"\");\n }\n return withSlash;\n}\n\nfunction splitPathSuffix(input: string): { pathname: string; suffix: string } {\n const source = String(input || \"\");\n const hashIndex = source.indexOf(\"#\");\n const queryIndex = source.indexOf(\"?\");\n const splitIndex = [hashIndex, queryIndex]\n .filter((index) => index >= 0)\n .sort((left, right) => left - right)[0];\n if (splitIndex === undefined) {\n return { pathname: source, suffix: \"\" };\n }\n return {\n pathname: source.slice(0, splitIndex),\n suffix: source.slice(splitIndex)\n };\n}\n\nfunction joinLocalePath(localeCode: string, basePath: string): string {\n const normalizedBase = normalizePathname(basePath);\n return normalizedBase === \"/\" ? `/${localeCode}` : `/${localeCode}${normalizedBase}`;\n}\n\nfunction isLocalePrefixedForStrategy(strategy: ResuxI18nStrategy, localeCode: string, defaultLocale: string): boolean {\n if (strategy === \"prefix\") {\n return true;\n }\n if (strategy === \"prefix_except_default\") {\n return localeCode !== defaultLocale;\n }\n return false;\n}\n\nfunction resolveLocaleByCode(locales: ResuxI18nLocale[], code: string): ResuxI18nLocale | null {\n return locales.find((locale) => locale.code === code) ?? null;\n}\n\nconst FORBIDDEN_MESSAGE_KEYS = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\n\nfunction readNestedValue(source: Record<string, unknown>, key: string): unknown {\n if (!key) {\n return source;\n }\n const parts = key.split(\".\");\n let cursor: unknown = source;\n for (const part of parts) {\n if (\n FORBIDDEN_MESSAGE_KEYS.has(part)\n || !isRecord(cursor)\n || !Object.hasOwn(cursor, part)\n ) {\n return undefined;\n }\n cursor = cursor[part];\n }\n return cursor;\n}\n\nfunction interpolateMessage(template: string, params: ResuxI18nTranslationParams): string {\n return template.replace(/\\{([A-Za-z0-9_]+)\\}/g, (match, key: string) => {\n const value = params[key];\n if (value === undefined || value === null) {\n return match;\n }\n return String(value);\n });\n}\n\nexport function normalizeI18nStrategy(value: unknown): ResuxI18nStrategy {\n if (value === \"prefix\" || value === \"no_prefix\" || value === \"prefix_except_default\") {\n return value;\n }\n return \"prefix_except_default\";\n}\n\nexport function normalizeI18nRuntimeConfig(value: unknown): ResuxI18nRuntimeConfig | null {\n if (!isRecord(value)) {\n return null;\n }\n\n const localeEntries = Array.isArray(value.locales) ? value.locales : [];\n const locales: ResuxI18nLocale[] = [];\n for (const entry of localeEntries) {\n if (!isRecord(entry)) {\n continue;\n }\n const code = normalizeLocaleCode(entry.code);\n if (!code) {\n continue;\n }\n locales.push({\n code,\n ...(typeof entry.name === \"string\" ? { name: entry.name } : {}),\n dir: entry.dir === \"rtl\" ? \"rtl\" : \"ltr\"\n });\n }\n\n if (!locales.length) {\n return null;\n }\n\n const uniqueLocales: ResuxI18nLocale[] = [];\n const localeCodes = new Set<string>();\n for (const locale of locales) {\n if (localeCodes.has(locale.code)) {\n continue;\n }\n localeCodes.add(locale.code);\n uniqueLocales.push(locale);\n }\n\n const firstLocale = uniqueLocales[0];\n const defaultLocale = normalizeLocaleCode(value.defaultLocale) ?? firstLocale.code;\n const fallbackLocale = normalizeLocaleCode(value.fallbackLocale) ?? defaultLocale;\n const strategy = normalizeI18nStrategy(value.strategy);\n const messagesInput = isRecord(value.messages) ? value.messages : {};\n const messages: Record<string, Record<string, unknown>> = {};\n\n for (const locale of uniqueLocales) {\n const entry = messagesInput[locale.code];\n messages[locale.code] = isRecord(entry) ? entry : {};\n }\n\n const normalizedDefault = resolveLocaleByCode(uniqueLocales, defaultLocale)?.code ?? firstLocale.code;\n const normalizedFallback = resolveLocaleByCode(uniqueLocales, fallbackLocale)?.code ?? normalizedDefault;\n\n return {\n defaultLocale: normalizedDefault,\n fallbackLocale: normalizedFallback,\n strategy,\n locales: uniqueLocales,\n messages\n };\n}\n\nexport function resolveI18nRoute(pathname: string, config: ResuxI18nRuntimeConfig): ResuxI18nResolvedRoute {\n // Route identity is pathname-only. Query strings and hashes belong to\n // navigation state and must not be mistaken for a route segment or leak into\n // canonical/hreflang URLs.\n const { pathname: rawPathname } = splitPathSuffix(pathname);\n const normalizedPath = normalizePathname(rawPathname);\n const segments = normalizedPath === \"/\" ? [] : normalizedPath.slice(1).split(\"/\");\n const first = segments[0];\n const candidate = first ? resolveLocaleByCode(config.locales, first) : null;\n\n // For prefixed strategies, always consume a recognized locale segment. In\n // prefix_except_default the default-locale prefix is non-canonical, but it\n // still needs to be stripped so locale switching never produces paths such\n // as /fr/en/about.\n if (candidate && config.strategy !== \"no_prefix\") {\n const remainder = segments.slice(1);\n const basePath = remainder.length ? `/${remainder.join(\"/\")}` : \"/\";\n const localizedPath = isLocalePrefixedForStrategy(\n config.strategy,\n candidate.code,\n config.defaultLocale,\n )\n ? normalizedPath\n : basePath;\n return {\n locale: candidate,\n basePath,\n localizedPath\n };\n }\n\n const fallbackLocale = config.locales[0];\n if (!fallbackLocale) {\n return {\n locale: { code: \"en\", dir: \"ltr\" },\n basePath: normalizedPath,\n localizedPath: normalizedPath\n };\n }\n const defaultLocale = resolveLocaleByCode(config.locales, config.defaultLocale) ?? fallbackLocale;\n const defaultLocalizedPath = isLocalePrefixedForStrategy(config.strategy, defaultLocale.code, config.defaultLocale)\n ? joinLocalePath(defaultLocale.code, normalizedPath)\n : normalizedPath;\n return {\n locale: defaultLocale,\n basePath: normalizedPath,\n localizedPath: defaultLocalizedPath\n };\n}\n\nexport function buildLocalePath(path: string, localeCode: string, config: ResuxI18nRuntimeConfig): string {\n const fallbackLocale = config.locales[0];\n if (!fallbackLocale) {\n const { pathname, suffix } = splitPathSuffix(path);\n return `${normalizePathname(pathname)}${suffix}`;\n }\n const targetLocale = resolveLocaleByCode(config.locales, normalizeLocaleCode(localeCode) ?? config.defaultLocale)\n ?? resolveLocaleByCode(config.locales, config.defaultLocale)\n ?? fallbackLocale;\n const { pathname, suffix } = splitPathSuffix(path);\n const current = resolveI18nRoute(pathname, config);\n const basePath = normalizePathname(current.basePath);\n\n if (!isLocalePrefixedForStrategy(config.strategy, targetLocale.code, config.defaultLocale)) {\n return `${basePath}${suffix}`;\n }\n\n return `${joinLocalePath(targetLocale.code, basePath)}${suffix}`;\n}\n\nexport function resolveLocaleDirection(config: ResuxI18nRuntimeConfig, localeCode: string): \"ltr\" | \"rtl\" {\n return resolveLocaleByCode(config.locales, localeCode)?.dir === \"rtl\" ? \"rtl\" : \"ltr\";\n}\n\nexport function resolveLocalizedValue(\n value: unknown,\n localeCode: string,\n fallbackLocale: string\n): string | null {\n if (typeof value === \"string\") {\n return value;\n }\n if (!isRecord(value)) {\n return null;\n }\n const primary = value[localeCode];\n if (typeof primary === \"string\") {\n return primary;\n }\n const fallback = value[fallbackLocale];\n if (typeof fallback === \"string\") {\n return fallback;\n }\n return null;\n}\n\nexport function translateRaw(\n config: ResuxI18nRuntimeConfig,\n localeCode: string,\n key: string\n): unknown {\n const localeMessages = config.messages[localeCode];\n if (localeMessages) {\n const direct = readNestedValue(localeMessages, key);\n if (direct !== undefined) {\n return direct;\n }\n }\n\n const fallbackMessages = config.messages[config.fallbackLocale];\n if (fallbackMessages) {\n const fallback = readNestedValue(fallbackMessages, key);\n if (fallback !== undefined) {\n return fallback;\n }\n }\n\n return undefined;\n}\n\nexport function translateText(\n config: ResuxI18nRuntimeConfig,\n localeCode: string,\n key: string,\n params: ResuxI18nTranslationParams = {}\n): string {\n const raw = translateRaw(config, localeCode, key);\n if (typeof raw === \"string\") {\n return interpolateMessage(raw, params);\n }\n if (typeof raw === \"number\" || typeof raw === \"boolean\") {\n return String(raw);\n }\n return key;\n}\n\nexport function createI18nHead(\n routePath: string,\n routeOrigin: string | undefined,\n config: ResuxI18nRuntimeConfig,\n options: { includeHreflang?: boolean } = {}\n): { htmlAttrs: Record<string, string>; link: Array<Record<string, string>> } {\n const resolved = resolveI18nRoute(routePath, config);\n const includeHreflang = options.includeHreflang !== false;\n const htmlAttrs: Record<string, string> = {\n lang: resolved.locale.code,\n dir: resolveLocaleDirection(config, resolved.locale.code)\n };\n const link: Array<Record<string, string>> = [];\n\n const canonicalPath = buildLocalePath(resolved.basePath, resolved.locale.code, config);\n const canonicalHref = routeOrigin ? new URL(canonicalPath, routeOrigin).toString() : canonicalPath;\n link.push({\n rel: \"canonical\",\n href: canonicalHref\n });\n\n if (includeHreflang) {\n for (const locale of config.locales) {\n const hrefPath = buildLocalePath(resolved.basePath, locale.code, config);\n const href = routeOrigin ? new URL(hrefPath, routeOrigin).toString() : hrefPath;\n link.push({\n rel: \"alternate\",\n hreflang: locale.code,\n href\n });\n }\n\n const defaultHrefPath = buildLocalePath(resolved.basePath, config.defaultLocale, config);\n const defaultHref = routeOrigin ? new URL(defaultHrefPath, routeOrigin).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,MAAM,MAAM;GACvE,MAAM,OAAO,cAAc,IAAI,IAAI,UAAU,WAAW,CAAC,CAAC,SAAS,IAAI;GACvE,KAAK,KAAK;IACR,KAAK;IACL,UAAU,OAAO;IACjB;GACF,CAAC;EACH;EAEA,MAAM,kBAAkB,gBAAgB,SAAS,UAAU,OAAO,eAAe,MAAM;EACvF,MAAM,cAAc,cAAc,IAAI,IAAI,iBAAiB,WAAW,CAAC,CAAC,SAAS,IAAI;EACrF,KAAK,KAAK;GACR,KAAK;GACL,UAAU;GACV,MAAM;EACR,CAAC;CACH;CAEA,OAAO;EACL;EACA;CACF;AACF"}
1
+ {"version":3,"file":"shared.js","names":["pathname","suffix"],"sources":["../../src/i18n/shared.ts"],"sourcesContent":["export type ResuxI18nStrategy = \"prefix_except_default\" | \"prefix\" | \"no_prefix\";\n\nexport interface ResuxI18nLocale {\n code: string;\n name?: string;\n dir?: \"ltr\" | \"rtl\";\n}\n\nexport interface ResuxI18nRuntimeConfig {\n defaultLocale: string;\n fallbackLocale: string;\n strategy: ResuxI18nStrategy;\n locales: ResuxI18nLocale[];\n messages: Record<string, Record<string, unknown>>;\n}\n\nexport interface ResuxI18nResolvedRoute {\n locale: ResuxI18nLocale;\n basePath: string;\n localizedPath: string;\n}\n\nexport interface ResuxI18nTranslationParams {\n [key: string]: string | number | boolean | null | undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n\nfunction normalizeLocaleCode(value: unknown): string | null {\n if (typeof value !== \"string\") {\n return null;\n }\n const normalized = value.trim().toLowerCase();\n if (!/^[a-z0-9-]+$/.test(normalized)) {\n return null;\n }\n return normalized;\n}\n\nfunction normalizePathname(pathname: string): string {\n const source = String(pathname || \"\").trim();\n if (!source) {\n return \"/\";\n }\n const withSlash = source.startsWith(\"/\") ? source : `/${source}`;\n if (withSlash !== \"/\" && withSlash.endsWith(\"/\")) {\n return withSlash.replace(/\\/+$/g, \"\");\n }\n return withSlash;\n}\n\nfunction splitPathSuffix(input: string): { pathname: string; suffix: string } {\n const source = String(input || \"\");\n const hashIndex = source.indexOf(\"#\");\n const queryIndex = source.indexOf(\"?\");\n const splitIndex = [hashIndex, queryIndex]\n .filter((index) => index >= 0)\n .sort((left, right) => left - right)[0];\n if (splitIndex === undefined) {\n return { pathname: source, suffix: \"\" };\n }\n return {\n pathname: source.slice(0, splitIndex),\n suffix: source.slice(splitIndex)\n };\n}\n\nfunction joinLocalePath(localeCode: string, basePath: string): string {\n const normalizedBase = normalizePathname(basePath);\n return normalizedBase === \"/\" ? `/${localeCode}` : `/${localeCode}${normalizedBase}`;\n}\n\nfunction isLocalePrefixedForStrategy(strategy: ResuxI18nStrategy, localeCode: string, defaultLocale: string): boolean {\n if (strategy === \"prefix\") {\n return true;\n }\n if (strategy === \"prefix_except_default\") {\n return localeCode !== defaultLocale;\n }\n return false;\n}\n\nfunction resolveLocaleByCode(locales: ResuxI18nLocale[], code: string): ResuxI18nLocale | null {\n return locales.find((locale) => locale.code === code) ?? null;\n}\n\nconst FORBIDDEN_MESSAGE_KEYS = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\n\nfunction readNestedValue(source: Record<string, unknown>, key: string): unknown {\n if (!key) {\n return source;\n }\n const parts = key.split(\".\");\n let cursor: unknown = source;\n for (const part of parts) {\n if (\n FORBIDDEN_MESSAGE_KEYS.has(part)\n || !isRecord(cursor)\n || !Object.hasOwn(cursor, part)\n ) {\n return undefined;\n }\n cursor = cursor[part];\n }\n return cursor;\n}\n\nfunction interpolateMessage(template: string, params: ResuxI18nTranslationParams): string {\n return template.replace(/\\{([A-Za-z0-9_]+)\\}/g, (match, key: string) => {\n const value = params[key];\n if (value === undefined || value === null) {\n return match;\n }\n return String(value);\n });\n}\n\nexport function normalizeI18nStrategy(value: unknown): ResuxI18nStrategy {\n if (value === \"prefix\" || value === \"no_prefix\" || value === \"prefix_except_default\") {\n return value;\n }\n return \"prefix_except_default\";\n}\n\nexport function normalizeI18nRuntimeConfig(value: unknown): ResuxI18nRuntimeConfig | null {\n if (!isRecord(value)) {\n return null;\n }\n\n const localeEntries = Array.isArray(value.locales) ? value.locales : [];\n const locales: ResuxI18nLocale[] = [];\n for (const entry of localeEntries) {\n if (!isRecord(entry)) {\n continue;\n }\n const code = normalizeLocaleCode(entry.code);\n if (!code) {\n continue;\n }\n locales.push({\n code,\n ...(typeof entry.name === \"string\" ? { name: entry.name } : {}),\n dir: entry.dir === \"rtl\" ? \"rtl\" : \"ltr\"\n });\n }\n\n if (!locales.length) {\n return null;\n }\n\n const uniqueLocales: ResuxI18nLocale[] = [];\n const localeCodes = new Set<string>();\n for (const locale of locales) {\n if (localeCodes.has(locale.code)) {\n continue;\n }\n localeCodes.add(locale.code);\n uniqueLocales.push(locale);\n }\n\n const firstLocale = uniqueLocales[0];\n const defaultLocale = normalizeLocaleCode(value.defaultLocale) ?? firstLocale.code;\n const fallbackLocale = normalizeLocaleCode(value.fallbackLocale) ?? defaultLocale;\n const strategy = normalizeI18nStrategy(value.strategy);\n const messagesInput = isRecord(value.messages) ? value.messages : {};\n const messages: Record<string, Record<string, unknown>> = {};\n\n for (const locale of uniqueLocales) {\n const entry = messagesInput[locale.code];\n messages[locale.code] = isRecord(entry) ? entry : {};\n }\n\n const normalizedDefault = resolveLocaleByCode(uniqueLocales, defaultLocale)?.code ?? firstLocale.code;\n const normalizedFallback = resolveLocaleByCode(uniqueLocales, fallbackLocale)?.code ?? normalizedDefault;\n\n return {\n defaultLocale: normalizedDefault,\n fallbackLocale: normalizedFallback,\n strategy,\n locales: uniqueLocales,\n messages\n };\n}\n\nexport function resolveI18nRoute(pathname: string, config: ResuxI18nRuntimeConfig): ResuxI18nResolvedRoute {\n // Route identity is pathname-only. Query strings and hashes belong to\n // navigation state and must not be mistaken for a route segment or leak into\n // canonical/hreflang URLs.\n const { pathname: rawPathname } = splitPathSuffix(pathname);\n const normalizedPath = normalizePathname(rawPathname);\n const segments = normalizedPath === \"/\" ? [] : normalizedPath.slice(1).split(\"/\");\n const first = segments[0];\n const candidate = first ? resolveLocaleByCode(config.locales, first) : null;\n\n // For prefixed strategies, always consume a recognized locale segment. In\n // prefix_except_default the default-locale prefix is non-canonical, but it\n // still needs to be stripped so locale switching never produces paths such\n // as /fr/en/about.\n if (candidate && config.strategy !== \"no_prefix\") {\n const remainder = segments.slice(1);\n const basePath = remainder.length ? `/${remainder.join(\"/\")}` : \"/\";\n const localizedPath = isLocalePrefixedForStrategy(\n config.strategy,\n candidate.code,\n config.defaultLocale,\n )\n ? normalizedPath\n : basePath;\n return {\n locale: candidate,\n basePath,\n localizedPath\n };\n }\n\n const fallbackLocale = config.locales[0];\n if (!fallbackLocale) {\n return {\n locale: { code: \"en\", dir: \"ltr\" },\n basePath: normalizedPath,\n localizedPath: normalizedPath\n };\n }\n const defaultLocale = resolveLocaleByCode(config.locales, config.defaultLocale) ?? fallbackLocale;\n const defaultLocalizedPath = isLocalePrefixedForStrategy(config.strategy, defaultLocale.code, config.defaultLocale)\n ? joinLocalePath(defaultLocale.code, normalizedPath)\n : normalizedPath;\n return {\n locale: defaultLocale,\n basePath: normalizedPath,\n localizedPath: defaultLocalizedPath\n };\n}\n\nexport function buildLocalePath(path: string, localeCode: string, config: ResuxI18nRuntimeConfig): string {\n const fallbackLocale = config.locales[0];\n if (!fallbackLocale) {\n const { pathname, suffix } = splitPathSuffix(path);\n return `${normalizePathname(pathname)}${suffix}`;\n }\n const targetLocale = resolveLocaleByCode(config.locales, normalizeLocaleCode(localeCode) ?? config.defaultLocale)\n ?? resolveLocaleByCode(config.locales, config.defaultLocale)\n ?? fallbackLocale;\n const { pathname, suffix } = splitPathSuffix(path);\n const current = resolveI18nRoute(pathname, config);\n const basePath = normalizePathname(current.basePath);\n\n if (!isLocalePrefixedForStrategy(config.strategy, targetLocale.code, config.defaultLocale)) {\n return `${basePath}${suffix}`;\n }\n\n return `${joinLocalePath(targetLocale.code, basePath)}${suffix}`;\n}\n\nexport function resolveLocaleDirection(config: ResuxI18nRuntimeConfig, localeCode: string): \"ltr\" | \"rtl\" {\n return resolveLocaleByCode(config.locales, localeCode)?.dir === \"rtl\" ? \"rtl\" : \"ltr\";\n}\n\nexport function resolveLocalizedValue(\n value: unknown,\n localeCode: string,\n fallbackLocale: string\n): string | null {\n if (typeof value === \"string\") {\n return value;\n }\n if (!isRecord(value)) {\n return null;\n }\n const primary = value[localeCode];\n if (typeof primary === \"string\") {\n return primary;\n }\n const fallback = value[fallbackLocale];\n if (typeof fallback === \"string\") {\n return fallback;\n }\n return null;\n}\n\nexport function translateRaw(\n config: ResuxI18nRuntimeConfig,\n localeCode: string,\n key: string\n): unknown {\n const localeMessages = config.messages[localeCode];\n if (localeMessages) {\n const direct = readNestedValue(localeMessages, key);\n if (direct !== undefined) {\n return direct;\n }\n }\n\n const fallbackMessages = config.messages[config.fallbackLocale];\n if (fallbackMessages) {\n const fallback = readNestedValue(fallbackMessages, key);\n if (fallback !== undefined) {\n return fallback;\n }\n }\n\n return undefined;\n}\n\nexport function translateText(\n config: ResuxI18nRuntimeConfig,\n localeCode: string,\n key: string,\n params: ResuxI18nTranslationParams = {}\n): string {\n const raw = translateRaw(config, localeCode, key);\n if (typeof raw === \"string\") {\n return interpolateMessage(raw, params);\n }\n if (typeof raw === \"number\" || typeof raw === \"boolean\") {\n return String(raw);\n }\n return key;\n}\n\nexport function createI18nHead(\n routePath: string,\n routeOrigin: string | undefined,\n config: ResuxI18nRuntimeConfig,\n options: { includeHreflang?: boolean } = {}\n): { htmlAttrs: Record<string, string>; link: Array<Record<string, string>> } {\n const resolved = resolveI18nRoute(routePath, config);\n const includeHreflang = options.includeHreflang !== false;\n const htmlAttrs: Record<string, string> = {\n lang: resolved.locale.code,\n dir: resolveLocaleDirection(config, resolved.locale.code)\n };\n const link: Array<Record<string, string>> = [];\n\n const canonicalPath = buildLocalePath(resolved.basePath, resolved.locale.code, config);\n const canonicalHref = routeOrigin ? new URL(canonicalPath, routeOrigin).toString() : canonicalPath;\n link.push({\n rel: \"canonical\",\n href: canonicalHref\n });\n\n if (includeHreflang) {\n for (const locale of config.locales) {\n const hrefPath = buildLocalePath(resolved.basePath, locale.code, config);\n const href = routeOrigin ? new URL(hrefPath, routeOrigin).toString() : hrefPath;\n link.push({\n rel: \"alternate\",\n hreflang: locale.code,\n href\n });\n }\n\n const defaultHrefPath = buildLocalePath(resolved.basePath, config.defaultLocale, config);\n const defaultHref = routeOrigin ? new URL(defaultHrefPath, routeOrigin).toString() : defaultHrefPath;\n link.push({\n rel: \"alternate\",\n hreflang: \"x-default\",\n href: defaultHref\n });\n }\n\n return {\n htmlAttrs,\n link\n };\n}"],"mappings":";AA0BA,SAAS,SAAS,OAAkD;AAClE,QAAO,QAAQ,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM,CAAC;;AAG7E,SAAS,oBAAoB,OAA+B;AAC1D,KAAI,OAAO,UAAU,SACnB,QAAO;CAET,MAAM,aAAa,MAAM,MAAM,CAAC,aAAa;AAC7C,KAAI,CAAC,eAAe,KAAK,WAAW,CAClC,QAAO;AAET,QAAO;;AAGT,SAAS,kBAAkB,UAA0B;CACnD,MAAM,SAAS,OAAO,YAAY,GAAG,CAAC,MAAM;AAC5C,KAAI,CAAC,OACH,QAAO;CAET,MAAM,YAAY,OAAO,WAAW,IAAI,GAAG,SAAS,IAAI;AACxD,KAAI,cAAc,OAAO,UAAU,SAAS,IAAI,CAC9C,QAAO,UAAU,QAAQ,SAAS,GAAG;AAEvC,QAAO;;AAGT,SAAS,gBAAgB,OAAqD;CAC5E,MAAM,SAAS,OAAO,SAAS,GAAG;CAGlC,MAAM,aAAa,CAFD,OAAO,QAAQ,IAAI,EAClB,OAAO,QAAQ,IAAI,CACI,CACvC,QAAQ,UAAU,SAAS,EAAE,CAC7B,MAAM,MAAM,UAAU,OAAO,MAAM,CAAC;AACvC,KAAI,eAAe,OACjB,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAAI;AAEzC,QAAO;EACL,UAAU,O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