resuxjs 0.4.0-beta.7 → 0.4.0

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 (185) hide show
  1. package/README.md +4 -2
  2. package/dist/_virtual/_rolldown/runtime.js +4 -0
  3. package/dist/build/index.d.ts +1 -2
  4. package/dist/cli.d.ts +3 -3
  5. package/dist/cli.js +125 -31
  6. package/dist/cli.js.map +1 -1
  7. package/dist/compiler/adapter.d.ts +2 -3
  8. package/dist/compiler/adapter.js +2 -2
  9. package/dist/compiler/dev-warnings.d.ts +1 -2
  10. package/dist/compiler/directives.d.ts +1 -2
  11. package/dist/compiler/directives.js +7 -3
  12. package/dist/compiler/directives.js.map +1 -1
  13. package/dist/compiler/implementation.d.ts +4 -2
  14. package/dist/compiler/implementation.js +101 -43
  15. package/dist/compiler/index.d.ts +2 -3
  16. package/dist/compiler/index.js +2 -2
  17. package/dist/compiler/index.js.map +1 -1
  18. package/dist/core/config.d.ts +1 -2
  19. package/dist/core/hooks.d.ts +10 -2
  20. package/dist/core/hooks.js.map +1 -1
  21. package/dist/core/index.d.ts +2 -2
  22. package/dist/core/module-container.d.ts +1 -2
  23. package/dist/core/module-container.js +2 -1
  24. package/dist/core/module-container.js.map +1 -1
  25. package/dist/core/resux.d.ts +1 -2
  26. package/dist/create.d.ts +1 -2
  27. package/dist/create.js +110 -33
  28. package/dist/create.js.map +1 -1
  29. package/dist/deploy/cloudflare.d.ts +1 -2
  30. package/dist/deploy/common.d.ts +1 -2
  31. package/dist/deploy/common.js +19 -3
  32. package/dist/deploy/common.js.map +1 -1
  33. package/dist/deploy/framework-runtime.d.ts +1 -2
  34. package/dist/deploy/index.d.ts +1 -2
  35. package/dist/deploy/netlify.d.ts +1 -2
  36. package/dist/deploy/node.d.ts +1 -2
  37. package/dist/deploy/production-report.d.ts +1 -2
  38. package/dist/deploy/runtime-dependencies.d.ts +1 -2
  39. package/dist/deploy/static.d.ts +1 -2
  40. package/dist/deploy/types.d.ts +1 -2
  41. package/dist/deploy/vercel.d.ts +1 -2
  42. package/dist/deploy/vercel.js +3 -3
  43. package/dist/deploy/vercel.js.map +1 -1
  44. package/dist/fonts/index.d.ts +1 -2
  45. package/dist/fonts/index.js.map +1 -1
  46. package/dist/globals.d.ts +1 -2
  47. package/dist/halal-core/ai/classifyProject.d.ts +1 -2
  48. package/dist/halal-core/ai/classifyRuntimeContent.d.ts +1 -2
  49. package/dist/halal-core/ai/createProjectSummary.d.ts +1 -2
  50. package/dist/halal-core/ai/halalClassifierPrompt.d.ts +1 -2
  51. package/dist/halal-core/ai/redactSensitiveData.d.ts +1 -2
  52. package/dist/halal-core/ai/validateAiResponse.d.ts +1 -2
  53. package/dist/halal-core/cli/check.d.ts +1 -2
  54. package/dist/halal-core/cli/explain.d.ts +1 -2
  55. package/dist/halal-core/cli/report.d.ts +1 -2
  56. package/dist/halal-core/cli/submitReview.d.ts +1 -2
  57. package/dist/halal-core/cli/verifyReview.d.ts +1 -2
  58. package/dist/halal-core/config.d.ts +2 -2
  59. package/dist/halal-core/config.js.map +1 -1
  60. package/dist/halal-core/crypto/integrity.d.ts +1 -2
  61. package/dist/halal-core/crypto/integrity.js +1 -1
  62. package/dist/halal-core/crypto/integrity.js.map +1 -1
  63. package/dist/halal-core/enforce.d.ts +4 -3
  64. package/dist/halal-core/enforce.js +31 -4
  65. package/dist/halal-core/enforce.js.map +1 -1
  66. package/dist/halal-core/lifecycle.d.ts +1 -2
  67. package/dist/halal-core/policy.d.ts +1 -2
  68. package/dist/halal-core/report/formatBrowserOverlay.d.ts +1 -2
  69. package/dist/halal-core/report/formatTerminalReport.d.ts +1 -2
  70. package/dist/halal-core/report/generateHalalReport.d.ts +1 -2
  71. package/dist/halal-core/report/signReport.d.ts +1 -2
  72. package/dist/halal-core/report/verifyReport.d.ts +1 -2
  73. package/dist/halal-core/review/createReviewRequest.d.ts +1 -2
  74. package/dist/halal-core/review/reviewPolicy.d.ts +1 -2
  75. package/dist/halal-core/review/signedReviewFile.d.ts +1 -2
  76. package/dist/halal-core/review/verifyReviewApproval.d.ts +1 -2
  77. package/dist/halal-core/rules/adultContentRules.d.ts +1 -2
  78. package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +1 -2
  79. package/dist/halal-core/rules/childSafetyRules.d.ts +1 -2
  80. package/dist/halal-core/rules/coreCategories.d.ts +1 -2
  81. package/dist/halal-core/rules/cyberAbuseRules.d.ts +1 -2
  82. package/dist/halal-core/rules/defaultBlockedRules.d.ts +1 -2
  83. package/dist/halal-core/rules/dependencyRules.d.ts +1 -2
  84. package/dist/halal-core/rules/endpointRules.d.ts +1 -2
  85. package/dist/halal-core/rules/environmentalHarmRules.d.ts +1 -2
  86. package/dist/halal-core/rules/financeRibaRules.d.ts +1 -2
  87. package/dist/halal-core/rules/gamblingRules.d.ts +1 -2
  88. package/dist/halal-core/rules/generalHarmRules.d.ts +1 -2
  89. package/dist/halal-core/rules/healthHarmRules.d.ts +1 -2
  90. package/dist/halal-core/rules/keywordRules.d.ts +1 -2
  91. package/dist/halal-core/rules/privacyAbuseRules.d.ts +1 -2
  92. package/dist/halal-core/rules/scamFraudRules.d.ts +1 -2
  93. package/dist/halal-core/rules/selfHarmRules.d.ts +1 -2
  94. package/dist/halal-core/rules/violenceExtremismRules.d.ts +1 -2
  95. package/dist/halal-core/runtime/guard.d.ts +1 -2
  96. package/dist/halal-core/runtime/guard.js.map +1 -1
  97. package/dist/halal-core/runtime/reviewedMemory.d.ts +1 -2
  98. package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +1 -2
  99. package/dist/halal-core/runtime/types.d.ts +1 -2
  100. package/dist/halal-core/scanner/scanApiRoutes.d.ts +1 -2
  101. package/dist/halal-core/scanner/scanComponents.d.ts +1 -2
  102. package/dist/halal-core/scanner/scanContent.d.ts +1 -2
  103. package/dist/halal-core/scanner/scanDependencies.d.ts +1 -2
  104. package/dist/halal-core/scanner/scanDomains.d.ts +1 -2
  105. package/dist/halal-core/scanner/scanEnvNames.d.ts +1 -2
  106. package/dist/halal-core/scanner/scanMetadata.d.ts +1 -2
  107. package/dist/halal-core/scanner/scanPages.d.ts +1 -2
  108. package/dist/halal-core/scanner/scanProject.d.ts +1 -2
  109. package/dist/halal-core/scanner/scanRoutes.d.ts +1 -2
  110. package/dist/halal-core/scanner/scanTranslations.d.ts +1 -2
  111. package/dist/halal-core/status.d.ts +1 -2
  112. package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +1 -2
  113. package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +1 -2
  114. package/dist/halal-core/tamper/verifyReportSignature.d.ts +1 -2
  115. package/dist/head/utils.d.ts +15 -0
  116. package/dist/head/utils.js +52 -0
  117. package/dist/head/utils.js.map +1 -0
  118. package/dist/i18n/index.d.ts +1 -2
  119. package/dist/i18n/index.js.map +1 -1
  120. package/dist/i18n/shared.d.ts +1 -2
  121. package/dist/icons/api-fetcher.d.ts +1 -2
  122. package/dist/icons/cache.d.ts +1 -2
  123. package/dist/icons/cache.js.map +1 -1
  124. package/dist/icons/component.d.ts +7 -8
  125. package/dist/icons/constants.d.ts +1 -2
  126. package/dist/icons/css-mode.d.ts +1 -2
  127. package/dist/icons/index.d.ts +1 -2
  128. package/dist/icons/index.js.map +1 -1
  129. package/dist/icons/local-svg.d.ts +1 -2
  130. package/dist/icons/normalize.d.ts +1 -2
  131. package/dist/icons/offline-loader.d.ts +1 -2
  132. package/dist/icons/parser.d.ts +1 -2
  133. package/dist/icons/registry.d.ts +1 -2
  134. package/dist/icons/resolver.d.ts +1 -2
  135. package/dist/icons/svg-mode.d.ts +1 -2
  136. package/dist/icons/transform.d.ts +1 -2
  137. package/dist/icons/types.d.ts +1 -2
  138. package/dist/index.d.ts +2 -2
  139. package/dist/index.js +2 -2
  140. package/dist/kit/index.d.ts +1 -2
  141. package/dist/nitro-server/index.d.ts +1 -2
  142. package/dist/node.d.ts +1 -2
  143. package/dist/reactivity/computed.d.ts +1 -2
  144. package/dist/reactivity/computed.js.map +1 -1
  145. package/dist/reactivity/effect.d.ts +3 -3
  146. package/dist/reactivity/effect.js +8 -3
  147. package/dist/reactivity/effect.js.map +1 -1
  148. package/dist/reactivity/reactive.d.ts +1 -2
  149. package/dist/reactivity/reactive.js +221 -11
  150. package/dist/reactivity/reactive.js.map +1 -1
  151. package/dist/reactivity/ref.d.ts +1 -2
  152. package/dist/reactivity/ref.js.map +1 -1
  153. package/dist/reactivity/scheduler.d.ts +1 -2
  154. package/dist/reactivity/scheduler.js +2 -0
  155. package/dist/reactivity/scheduler.js.map +1 -1
  156. package/dist/reactivity/types.d.ts +1 -2
  157. package/dist/reactivity/utils.d.ts +1 -2
  158. package/dist/reactivity/watch.d.ts +1 -2
  159. package/dist/reactivity/watch.js.map +1 -1
  160. package/dist/runtime/core.d.ts +1 -2
  161. package/dist/runtime/core.js.map +1 -1
  162. package/dist/runtime/index.d.ts +19 -2
  163. package/dist/runtime/index.js +921 -170
  164. package/dist/runtime/index.js.map +1 -1
  165. package/dist/runtime/resume.d.ts +1 -2
  166. package/dist/runtime/resume.js.map +1 -1
  167. package/dist/runtime/router.d.ts +1 -2
  168. package/dist/runtime/router.js.map +1 -1
  169. package/dist/runtime/streaming.d.ts +1 -2
  170. package/dist/runtime/streaming.js.map +1 -1
  171. package/dist/runtime/view-transitions/detect.d.ts +1 -2
  172. package/dist/runtime/view-transitions/transition.d.ts +1 -2
  173. package/dist/runtime/view-transitions/types.d.ts +1 -2
  174. package/dist/security/media-fetch.d.ts +1 -2
  175. package/dist/security/media-fetch.js.map +1 -1
  176. package/dist/security/path-boundary.d.ts +1 -2
  177. package/dist/security/path-boundary.js +10 -4
  178. package/dist/security/path-boundary.js.map +1 -1
  179. package/dist/ui/index.d.ts +41 -42
  180. package/dist/ui/verification-code.d.ts +9 -10
  181. package/dist/ui/verification-code.js.map +1 -1
  182. package/dist/vite-builder/index.d.ts +1 -2
  183. package/package.json +2 -2
  184. package/templates/default/.env.example +3 -0
  185. package/templates/default/nitro.config.ts +16 -4
@@ -1 +1 @@
1
- {"version":3,"file":"vercel.js","names":[],"sources":["../../src/deploy/vercel.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { cp, lstat, mkdir, readdir, realpath, rm, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n assertRuntimeClientAsset,\n ensureResuxClientAssets,\n ensureResuxServerPayload,\n pathExists,\n readJsonRecord,\n writeJson,\n} from \"./common.js\";\nimport { ensureResuxFrameworkRuntime } from \"./framework-runtime.js\";\nimport { ensureResuxProductionReport } from \"./production-report.js\";\nimport {\n ensureRuntimeDependencyTrees,\n ensureServerRuntimeDependencyTrees,\n} from \"./runtime-dependencies.js\";\nimport type {\n DeployBuildContext,\n DeployDetectionContext,\n DeployTargetModule,\n} from \"./types.js\";\n\nconst SUPPORTED_NODE_VERSIONS = [18, 20, 22] as const;\n\ntype BuildOutputRoute = Record<string, unknown>;\n\ninterface BuildOutputConfig extends Record<string, unknown> {\n version?: unknown;\n routes?: unknown;\n}\n\nfunction parseMajorNodeVersion(version: string): number {\n const major = Number.parseInt(version.split(\".\")[0] ?? \"\", 10);\n return Number.isNaN(major) ? 22 : major;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function resolveVercelNodeRuntime(nodeVersion = process.versions.node): string {\n const systemNodeVersion = parseMajorNodeVersion(nodeVersion);\n const runtimeVersion =\n SUPPORTED_NODE_VERSIONS.find((version) => version >= systemNodeVersion)\n ?? SUPPORTED_NODE_VERSIONS[SUPPORTED_NODE_VERSIONS.length - 1];\n return `nodejs${runtimeVersion}.x`;\n}\n\nfunction resolveFallbackFunctionName(functionNames: string[]): string | null {\n if (functionNames.includes(\"__fallback.func\")) {\n return \"__fallback\";\n }\n if (functionNames.includes(\"[...].func\")) {\n return \"[...]\";\n }\n const fallback = functionNames.find((name) => name.endsWith(\".func\"));\n return fallback ? fallback.slice(0, -5) : null;\n}\n\nfunction isCatchAllRouteSrc(src: unknown): boolean {\n if (typeof src !== \"string\") {\n return false;\n }\n\n return src === \"/(.*)\" || src === \"/(?:.*)\" || /^\\/\\((?:\\?:)?\\.\\*\\)$/.test(src);\n}\n\nfunction routeDestIncludesFunctionName(route: Record<string, unknown>, functionName: string): boolean {\n if (typeof route.dest !== \"string\" || !functionName) {\n return false;\n }\n\n const normalizedDest = route.dest.startsWith(\"/\") ? route.dest.slice(1) : route.dest;\n return normalizedDest === functionName;\n}\n\nfunction normalizeBuildOutputConfig(value: unknown): BuildOutputConfig {\n if (!isRecord(value)) {\n return {};\n }\n return value;\n}\n\nfunction isHeaderOnlyRoute(route: BuildOutputRoute): boolean {\n if (!isRecord(route)) {\n return false;\n }\n\n return (\n typeof route.src === \"string\"\n && isRecord(route.headers)\n && route.continue !== true\n && route.dest === undefined\n && route.handle === undefined\n && route.status === undefined\n && route.check === undefined\n && route.middlewarePath === undefined\n );\n}\n\nfunction normalizeRoute(route: BuildOutputRoute): BuildOutputRoute {\n if (isHeaderOnlyRoute(route)) {\n return { ...route, continue: true };\n }\n return route;\n}\n\nfunction isRunningInsideVercelContainer(appRoot: string): boolean {\n const normalizedRoot = appRoot.replace(/\\\\/g, \"/\");\n if (normalizedRoot.startsWith(\"/vercel/path\")) {\n return true;\n }\n\n return (\n existsSync(\"/vercel\")\n || existsSync(\"/vercel/path\")\n || existsSync(\"/vercel/path0\")\n || existsSync(\"/vercel/output\")\n );\n}\n\nasync function detect(context: DeployDetectionContext): Promise<boolean> {\n if (isRunningInsideVercelContainer(context.appRoot)) {\n return true;\n }\n\n if (context.env.NOW_BUILDER || context.env.VERCEL || context.env.VERCEL_ENV) {\n return true;\n }\n return false;\n}\n\nasync function materializeLinkedFunctions(functionsDir: string): Promise<void> {\n const entries = await readdir(functionsDir, { withFileTypes: true }).catch(() => []);\n\n for (const entry of entries) {\n if (!entry.name.endsWith(\".func\")) {\n continue;\n }\n\n const functionPath = path.join(functionsDir, entry.name);\n const stats = await lstat(functionPath).catch(() => null);\n if (!stats?.isSymbolicLink()) {\n continue;\n }\n\n const resolvedTarget = await realpath(functionPath).catch(() => null);\n if (!resolvedTarget) {\n continue;\n }\n\n await rm(functionPath, { recursive: true, force: true });\n await cp(resolvedTarget, functionPath, {\n recursive: true,\n force: true,\n });\n }\n}\n\nasync function listFunctionDirectories(functionsDir: string): Promise<string[]> {\n const entries = await readdir(functionsDir, { withFileTypes: true }).catch(() => []);\n const functionNames: string[] = [];\n\n for (const entry of entries) {\n if (!entry.name.endsWith(\".func\")) {\n continue;\n }\n\n const functionPath = path.join(functionsDir, entry.name);\n if (entry.isDirectory()) {\n functionNames.push(entry.name);\n continue;\n }\n\n if (!entry.isSymbolicLink()) {\n continue;\n }\n\n const linkedStats = await stat(functionPath).catch(() => null);\n if (linkedStats?.isDirectory()) {\n functionNames.push(entry.name);\n }\n }\n\n return functionNames;\n}\n\nasync function postBuild(context: DeployBuildContext): Promise<void> {\n await ensureResuxClientAssets(context.appRoot, [\n {\n root: path.join(context.appRoot, \".output\"),\n target: path.join(context.appRoot, \".output\", \"public\", \"__resux\"),\n },\n {\n root: path.join(context.appRoot, \".vercel\", \"output\"),\n target: path.join(context.appRoot, \".vercel\", \"output\", \"static\", \"__resux\"),\n },\n ]);\n await assertRuntimeClientAsset(path.join(context.appRoot, \".vercel\", \"output\", \"static\"));\n\n const appAssetsDir = path.join(context.appRoot, \"assets\");\n const vercelStaticAssetsDir = path.join(context.appRoot, \".vercel\", \"output\", \"static\", \"assets\");\n if (await pathExists(appAssetsDir)) {\n await mkdir(path.dirname(vercelStaticAssetsDir), { recursive: true });\n await cp(appAssetsDir, vercelStaticAssetsDir, {\n recursive: true,\n force: true,\n });\n }\n\n const outputDir = path.join(context.appRoot, \".vercel\", \"output\");\n const functionsDir = path.join(outputDir, \"functions\");\n await materializeLinkedFunctions(functionsDir);\n\n const functionNames = await listFunctionDirectories(functionsDir);\n if (!functionNames.length) {\n throw new Error(\n \"Resux vercel deployment output is missing function directories under .vercel/output/functions.\",\n );\n }\n\n const functionRoots = functionNames.map((functionName) =>\n path.join(functionsDir, functionName)\n );\n await ensureResuxServerPayload(\n context.appRoot,\n functionRoots.map((root) => path.join(root, \".resux\", \"server\")),\n );\n await ensureResuxClientAssets(\n context.appRoot,\n functionRoots.map((root) => ({\n root,\n target: path.join(root, \".resux\", \"client\"),\n })),\n );\n await ensureResuxProductionReport(context.appRoot, functionRoots);\n await ensureResuxFrameworkRuntime(context.appRoot, functionRoots);\n await ensureServerRuntimeDependencyTrees(\n context.appRoot,\n path.join(context.appRoot, \".resux\", \"server\"),\n functionRoots,\n \"Resux Vercel\",\n );\n await ensureRuntimeDependencyTrees(\n context.appRoot,\n functionRoots,\n \"sharp\",\n \"Resux Vercel image optimizer\",\n );\n for (const functionRoot of functionRoots) {\n const manifestPath = path.join(functionRoot, \".resux\", \"server\", \"manifest.mjs\");\n if (!(await pathExists(manifestPath))) {\n const chunkManifestPath = path.join(functionRoot, \"chunks\", \"raw\", \"manifest.mjs\");\n const hasChunkManifest = await pathExists(chunkManifestPath);\n throw new Error(\n hasChunkManifest\n ? `Resux vercel deployment output is missing ${manifestPath}. Found ${chunkManifestPath} but not the copied Resux server payload. Stop concurrent dev/watch processes, clean .vercel/output, and rerun build.`\n : `Resux vercel deployment output is missing ${manifestPath}.`,\n );\n }\n }\n\n const defaultFunctionConfig = {\n runtime: resolveVercelNodeRuntime(),\n handler: \"index.mjs\",\n launcherType: \"Nodejs\",\n shouldAddHelpers: false,\n supportsResponseStreaming: true,\n };\n\n for (const functionRoot of functionRoots) {\n const functionConfigPath = path.join(functionRoot, \".vc-config.json\");\n if (!(await pathExists(functionConfigPath))) {\n await writeFile(\n functionConfigPath,\n JSON.stringify(defaultFunctionConfig, null, 2),\n \"utf8\",\n );\n }\n }\n\n const outputConfigPath = path.join(outputDir, \"config.json\");\n const parsedOutputConfig = await readJsonRecord(outputConfigPath);\n const safeOutputConfig = normalizeBuildOutputConfig(parsedOutputConfig ?? {});\n const routes = Array.isArray(safeOutputConfig.routes)\n ? (safeOutputConfig.routes as BuildOutputRoute[]).map(normalizeRoute)\n : [];\n const hasFilesystemRoute = routes.some((route) => route?.handle === \"filesystem\");\n if (!hasFilesystemRoute) {\n routes.push({ handle: \"filesystem\" });\n }\n\n const fallbackFunctionName = resolveFallbackFunctionName(functionNames);\n const hasNativeCatchAllFunction = functionNames.includes(\"[...].func\");\n const hasCatchAllRoute =\n hasNativeCatchAllFunction || routes.some((route) => isCatchAllRouteSrc(route?.src));\n const hasFallbackDest = fallbackFunctionName\n ? routes.some((route) => routeDestIncludesFunctionName(route ?? {}, fallbackFunctionName))\n : false;\n if (fallbackFunctionName && !hasCatchAllRoute && !hasFallbackDest) {\n routes.push({ src: \"/(.*)\", dest: `/${fallbackFunctionName}` });\n }\n\n const outputConfig: BuildOutputConfig = {\n ...safeOutputConfig,\n version: 3,\n routes,\n };\n await mkdir(path.dirname(outputConfigPath), { recursive: true });\n await writeJson(outputConfigPath, outputConfig);\n}\n\nexport const vercelDeployModule: DeployTargetModule = {\n target: \"vercel\",\n presetAliases: [\"vercel\", \"vercel-edge\"],\n outputLabel: \".vercel/output\",\n detect,\n inferPreset: () => \"vercel\",\n postBuild,\n};\n"],"mappings":";;;;;;;;AAuBA,MAAM,0BAA0B;CAAC;CAAI;CAAI;AAAE;AAS3C,SAAS,sBAAsB,SAAyB;CACtD,MAAM,QAAQ,OAAO,SAAS,QAAQ,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,EAAE;CAC7D,OAAO,OAAO,MAAM,KAAK,IAAI,KAAK;AACpC;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAgB,yBAAyB,cAAc,QAAQ,SAAS,MAAc;CACpF,MAAM,oBAAoB,sBAAsB,WAAW;CAI3D,OAAO,SAFL,wBAAwB,MAAM,YAAY,WAAW,iBAAiB,KACnE,wBAAwB,wBAAwB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AAO,MAAM,UAAU,8BAA8B,SAAS,CAAC,GAAG,oBAAoB,CAAC,IACvF;CACJ,IAAI,wBAAwB,CAAC,oBAAoB,CAAC,iBAChD,OAAO,KAAK;EAAE,KAAK;EAAS,MAAM,IAAI;CAAuB,CAAC;CAGhE,MAAM,eAAkC;EACtC,GAAG;EACH,SAAS;EACT;CACF;CACA,MAAM,MAAM,KAAK,QAAQ,gBAAgB,GAAG,EAAE,WAAW,KAAK,CAAC;CAC/D,MAAM,UAAU,kBAAkB,YAAY;AAChD;AAEA,MAAa,qBAAyC;CACpD,QAAQ;CACR,eAAe,CAAC,UAAU,aAAa;CACvC,aAAa;CACb;CACA,mBAAmB;CACnB;AACF"}
1
+ {"version":3,"file":"vercel.js","names":[],"sources":["../../src/deploy/vercel.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { cp, lstat, mkdir, readdir, realpath, rm, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n assertRuntimeClientAsset,\n ensureResuxClientAssets,\n ensureResuxServerPayload,\n pathExists,\n readJsonRecord,\n writeJson,\n} from \"./common.js\";\nimport { ensureResuxFrameworkRuntime } from \"./framework-runtime.js\";\nimport { ensureResuxProductionReport } from \"./production-report.js\";\nimport {\n ensureRuntimeDependencyTrees,\n ensureServerRuntimeDependencyTrees,\n} from \"./runtime-dependencies.js\";\nimport type {\n DeployBuildContext,\n DeployDetectionContext,\n DeployTargetModule,\n} from \"./types.js\";\n\nconst SUPPORTED_NODE_VERSIONS = [22, 24, 26] as const;\n\ntype BuildOutputRoute = Record<string, unknown>;\n\ninterface BuildOutputConfig extends Record<string, unknown> {\n version?: unknown;\n routes?: unknown;\n}\n\nfunction parseMajorNodeVersion(version: string): number {\n const major = Number.parseInt(version.split(\".\")[0] ?? \"\", 10);\n return Number.isNaN(major) ? 22 : major;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function resolveVercelNodeRuntime(nodeVersion = process.versions.node): string {\n const systemNodeVersion = parseMajorNodeVersion(nodeVersion);\n const runtimeVersion =\n SUPPORTED_NODE_VERSIONS.find((version) => version >= systemNodeVersion)\n ?? SUPPORTED_NODE_VERSIONS[SUPPORTED_NODE_VERSIONS.length - 1];\n return `nodejs${runtimeVersion}.x`;\n}\n\nfunction resolveFallbackFunctionName(functionNames: string[]): string | null {\n if (functionNames.includes(\"__fallback.func\")) {\n return \"__fallback\";\n }\n if (functionNames.includes(\"[...].func\")) {\n return \"[...]\";\n }\n const fallback = functionNames.find((name) => name.endsWith(\".func\"));\n return fallback ? fallback.slice(0, -5) : null;\n}\n\nfunction isCatchAllRouteSrc(src: unknown): boolean {\n if (typeof src !== \"string\") {\n return false;\n }\n\n return src === \"/(.*)\" || src === \"/(?:.*)\" || /^\\/\\((?:\\?:)?\\.\\*\\)$/.test(src);\n}\n\nfunction routeDestIncludesFunctionName(route: Record<string, unknown>, functionName: string): boolean {\n if (typeof route.dest !== \"string\" || !functionName) {\n return false;\n }\n\n const normalizedDest = route.dest.startsWith(\"/\") ? route.dest.slice(1) : route.dest;\n return normalizedDest === functionName;\n}\n\nfunction normalizeBuildOutputConfig(value: unknown): BuildOutputConfig {\n if (!isRecord(value)) {\n return {};\n }\n return value;\n}\n\nfunction isHeaderOnlyRoute(route: BuildOutputRoute): boolean {\n if (!isRecord(route)) {\n return false;\n }\n\n return (\n typeof route.src === \"string\"\n && isRecord(route.headers)\n && route.continue !== true\n && route.dest === undefined\n && route.handle === undefined\n && route.status === undefined\n && route.check === undefined\n && route.middlewarePath === undefined\n );\n}\n\nfunction normalizeRoute(route: BuildOutputRoute): BuildOutputRoute {\n if (isHeaderOnlyRoute(route)) {\n return { ...route, continue: true };\n }\n return route;\n}\n\nfunction isRunningInsideVercelContainer(appRoot: string): boolean {\n const normalizedRoot = appRoot.replace(/\\\\/g, \"/\");\n if (normalizedRoot.startsWith(\"/vercel/path\")) {\n return true;\n }\n\n return (\n existsSync(\"/vercel\")\n || existsSync(\"/vercel/path\")\n || existsSync(\"/vercel/path0\")\n || existsSync(\"/vercel/output\")\n );\n}\n\nasync function detect(context: DeployDetectionContext): Promise<boolean> {\n if (isRunningInsideVercelContainer(context.appRoot)) {\n return true;\n }\n\n if (context.env.NOW_BUILDER || context.env.VERCEL || context.env.VERCEL_ENV) {\n return true;\n }\n return false;\n}\n\nasync function materializeLinkedFunctions(functionsDir: string): Promise<void> {\n const entries = await readdir(functionsDir, { withFileTypes: true }).catch(() => []);\n\n for (const entry of entries) {\n if (!entry.name.endsWith(\".func\")) {\n continue;\n }\n\n const functionPath = path.join(functionsDir, entry.name);\n const stats = await lstat(functionPath).catch(() => null);\n if (!stats?.isSymbolicLink()) {\n continue;\n }\n\n const resolvedTarget = await realpath(functionPath).catch(() => null);\n if (!resolvedTarget) {\n continue;\n }\n\n await rm(functionPath, { recursive: true, force: true });\n await cp(resolvedTarget, functionPath, {\n recursive: true,\n force: true,\n });\n }\n}\n\nasync function listFunctionDirectories(functionsDir: string): Promise<string[]> {\n const entries = await readdir(functionsDir, { withFileTypes: true }).catch(() => []);\n const functionNames: string[] = [];\n\n for (const entry of entries) {\n if (!entry.name.endsWith(\".func\")) {\n continue;\n }\n\n const functionPath = path.join(functionsDir, entry.name);\n if (entry.isDirectory()) {\n functionNames.push(entry.name);\n continue;\n }\n\n if (!entry.isSymbolicLink()) {\n continue;\n }\n\n const linkedStats = await stat(functionPath).catch(() => null);\n if (linkedStats?.isDirectory()) {\n functionNames.push(entry.name);\n }\n }\n\n return functionNames;\n}\n\nasync function postBuild(context: DeployBuildContext): Promise<void> {\n await ensureResuxClientAssets(context.appRoot, [\n {\n root: path.join(context.appRoot, \".output\"),\n target: path.join(context.appRoot, \".output\", \"public\", \"__resux\"),\n },\n {\n root: path.join(context.appRoot, \".vercel\", \"output\"),\n target: path.join(context.appRoot, \".vercel\", \"output\", \"static\", \"__resux\"),\n },\n ]);\n await assertRuntimeClientAsset(path.join(context.appRoot, \".vercel\", \"output\", \"static\"));\n\n const appAssetsDir = path.join(context.appRoot, \"assets\");\n const vercelStaticAssetsDir = path.join(context.appRoot, \".vercel\", \"output\", \"static\", \"assets\");\n if (await pathExists(appAssetsDir)) {\n await mkdir(path.dirname(vercelStaticAssetsDir), { recursive: true });\n await cp(appAssetsDir, vercelStaticAssetsDir, {\n recursive: true,\n force: true,\n });\n }\n\n const outputDir = path.join(context.appRoot, \".vercel\", \"output\");\n const functionsDir = path.join(outputDir, \"functions\");\n await materializeLinkedFunctions(functionsDir);\n\n const functionNames = await listFunctionDirectories(functionsDir);\n if (!functionNames.length) {\n throw new Error(\n \"Resux vercel deployment output is missing function directories under .vercel/output/functions.\",\n );\n }\n\n const functionRoots = functionNames.map((functionName) =>\n path.join(functionsDir, functionName)\n );\n await ensureResuxServerPayload(\n context.appRoot,\n functionRoots.map((root) => path.join(root, \".resux\", \"server\")),\n );\n await ensureResuxClientAssets(\n context.appRoot,\n functionRoots.map((root) => ({\n root,\n target: path.join(root, \".resux\", \"client\"),\n })),\n );\n await ensureResuxProductionReport(context.appRoot, functionRoots);\n await ensureResuxFrameworkRuntime(context.appRoot, functionRoots);\n await ensureServerRuntimeDependencyTrees(\n context.appRoot,\n path.join(context.appRoot, \".resux\", \"server\"),\n functionRoots,\n \"Resux Vercel\",\n );\n await ensureRuntimeDependencyTrees(\n context.appRoot,\n functionRoots,\n \"sharp\",\n \"Resux Vercel image optimizer\",\n );\n for (const functionRoot of functionRoots) {\n const manifestPath = path.join(functionRoot, \".resux\", \"server\", \"manifest.mjs\");\n if (!(await pathExists(manifestPath))) {\n const chunkManifestPath = path.join(functionRoot, \"chunks\", \"raw\", \"manifest.mjs\");\n const hasChunkManifest = await pathExists(chunkManifestPath);\n throw new Error(\n hasChunkManifest\n ? `Resux vercel deployment output is missing ${manifestPath}. Found ${chunkManifestPath} but not the copied Resux server payload. Stop concurrent dev/watch processes, clean .vercel/output, and rerun build.`\n : `Resux vercel deployment output is missing ${manifestPath}.`,\n );\n }\n }\n\n const defaultFunctionConfig = {\n runtime: resolveVercelNodeRuntime(),\n handler: \"index.mjs\",\n launcherType: \"Nodejs\",\n shouldAddHelpers: false,\n supportsResponseStreaming: true,\n };\n\n for (const functionRoot of functionRoots) {\n const functionConfigPath = path.join(functionRoot, \".vc-config.json\");\n if (!(await pathExists(functionConfigPath))) {\n await writeFile(\n functionConfigPath,\n JSON.stringify(defaultFunctionConfig, null, 2),\n \"utf8\",\n );\n }\n }\n\n const outputConfigPath = path.join(outputDir, \"config.json\");\n const parsedOutputConfig = await readJsonRecord(outputConfigPath);\n const safeOutputConfig = normalizeBuildOutputConfig(parsedOutputConfig ?? {});\n const routes = Array.isArray(safeOutputConfig.routes)\n ? (safeOutputConfig.routes as BuildOutputRoute[]).map(normalizeRoute)\n : [];\n const hasFilesystemRoute = routes.some((route) => route?.handle === \"filesystem\");\n if (!hasFilesystemRoute) {\n routes.push({ handle: \"filesystem\" });\n }\n\n const fallbackFunctionName = resolveFallbackFunctionName(functionNames);\n const hasNativeCatchAllFunction = functionNames.includes(\"[...].func\");\n const hasCatchAllRoute =\n hasNativeCatchAllFunction || routes.some((route) => isCatchAllRouteSrc(route?.src));\n const hasFallbackDest = fallbackFunctionName\n ? routes.some((route) => routeDestIncludesFunctionName(route ?? {}, fallbackFunctionName))\n : false;\n if (fallbackFunctionName && !hasCatchAllRoute && !hasFallbackDest) {\n routes.push({ src: \"/(.*)\", dest: `/${fallbackFunctionName}` });\n }\n\n const outputConfig: BuildOutputConfig = {\n ...safeOutputConfig,\n version: 3,\n routes,\n };\n await mkdir(path.dirname(outputConfigPath), { recursive: true });\n await writeJson(outputConfigPath, outputConfig);\n}\n\nexport const vercelDeployModule: DeployTargetModule = {\n target: \"vercel\",\n presetAliases: [\"vercel\", \"vercel-edge\"],\n outputLabel: \".vercel/output\",\n detect,\n inferPreset: () => \"vercel\",\n postBuild,\n};\n"],"mappings":";;;;;;;;AAuBA,MAAM,0BAA0B;CAAC;CAAI;CAAI;AAAE;A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CAE3D,MAAM,mBAAmB,2BAA2B,MADnB,eAAe,gBAAgB,KACU,CAAC,CAAC;CAC5E,MAAM,SAAS,MAAM,QAAQ,iBAAiB,MAAM,IAC/C,iBAAiB,OAA8B,IAAI,cAAc,IAClE,CAAC;CAEL,IAAI,CADuB,OAAO,MAAM,UAAU,OAAO,WAAW,YAC9C,GACpB,OAAO,KAAK,EAAE,QAAQ,aAAa,CAAC;CAGtC,MAAM,uBAAuB,4BAA4B,aAAa;CAEtE,MAAM,mBAD4B,cAAc,SAAS,YAE/B,KAAK,OAAO,MAAM,UAAU,mBAAmB,OAAO,GAAG,CAAC;CACpF,MAAM,kBAAkB,uBACpB,OAAO,MAAM,UAAU,8BAA8B,SAAS,CAAC,GAAG,oBAAoB,CAAC,IACvF;CACJ,IAAI,wBAAwB,CAAC,oBAAoB,CAAC,iBAChD,OAAO,KAAK;EAAE,KAAK;EAAS,MAAM,IAAI;CAAuB,CAAC;CAGhE,MAAM,eAAkC;EACtC,GAAG;EACH,SAAS;EACT;CACF;CACA,MAAM,MAAM,KAAK,QAAQ,gBAAgB,GAAG,EAAE,WAAW,KAAK,CAAC;CAC/D,MAAM,UAAU,kBAAkB,YAAY;AAChD;AAEA,MAAa,qBAAyC;CACpD,QAAQ;CACR,eAAe,CAAC,UAAU,aAAa;CACvC,aAAa;CACb;CACA,mBAAmB;CACnB;AACF"}
@@ -66,5 +66,4 @@ export interface ResuxFontsModuleOptions {
66
66
  export declare function googleFont(input: ResuxFontFamilyInput): ResuxFontFamilyInput;
67
67
  export declare function localFont(input: ResuxFontFamilyInput): ResuxFontFamilyInput;
68
68
  declare const _default: ResuxModuleDefinition<ResuxFontsModuleOptions>;
69
- export { _default as default };
70
- //# sourceMappingURL=index.d.ts.map
69
+ export { _default as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/fonts/index.ts"],"sourcesContent":["import { generateFontFace, getMetricsForFamily } from \"fontaine\";\nimport { fontless } from \"fontless\";\nimport { defineResuxModule } from \"../kit/index.js\";\n\nexport type ResuxFontStrategy = \"eager\" | \"preload\" | \"lazy\";\nexport type ResuxFontDisplay = \"auto\" | \"block\" | \"swap\" | \"fallback\" | \"optional\";\nexport type ResuxFontProvider = \"google\" | \"local\" | \"remote\";\n\nexport type ResuxFontWeightName =\n | \"thin\"\n | \"hairline\"\n | \"extralight\"\n | \"extra-light\"\n | \"ultralight\"\n | \"light\"\n | \"normal\"\n | \"regular\"\n | \"medium\"\n | \"semibold\"\n | \"semi-bold\"\n | \"demibold\"\n | \"bold\"\n | \"extrabold\"\n | \"extra-bold\"\n | \"ultrabold\"\n | \"black\"\n | \"heavy\";\n\nexport type ResuxFontWeight = number | ResuxFontWeightName | (string & {});\n\nexport interface ResuxFontSourceInput {\n url: string;\n format?: \"woff2\" | \"woff\" | \"truetype\" | \"opentype\" | \"embedded-opentype\";\n}\n\nexport interface ResuxFontFaceInput {\n src: string | ResuxFontSourceInput | Array<string | ResuxFontSourceInput>;\n weight?: ResuxFontWeight;\n style?: \"normal\" | \"italic\" | \"oblique\";\n display?: ResuxFontDisplay;\n unicodeRange?: string;\n preload?: boolean;\n axes?: Record<string, number | [number, number]>;\n}\n\nexport interface ResuxFontFamilyInput {\n name: string;\n provider?: ResuxFontProvider;\n weights?: ResuxFontWeight[];\n display?: ResuxFontDisplay;\n strategy?: ResuxFontStrategy;\n deferUntilPageLoad?: boolean;\n src?: string | ResuxFontSourceInput | Array<string | ResuxFontSourceInput>;\n faces?: ResuxFontFaceInput[];\n weight?: ResuxFontWeight;\n style?: \"normal\" | \"italic\" | \"oblique\";\n unicodeRange?: string;\n preload?: boolean;\n variable?: string;\n axes?: Record<string, number | [number, number]>;\n fallbacks?: string[];\n}\n\n\nexport interface ResuxFontsModuleOptions {\n /** Enable automatic CSS/template font scanning via fontless. Defaults to true. */\n autoScan?: boolean;\n\n /** Global font defaults across all resolved families */\n defaults?: {\n preload?: boolean;\n subsets?: string[];\n weights?: ResuxFontWeight[];\n styles?: Array<\"normal\" | \"italic\" | \"oblique\">;\n fallbacks?: string[];\n };\n\n /** Provider configurations (google, bunny, fontshare, fontsource, local) */\n providers?: {\n google?: boolean | Record<string, unknown>;\n bunny?: boolean | Record<string, unknown>;\n fontshare?: boolean | Record<string, unknown>;\n fontsource?: boolean | Record<string, unknown>;\n local?: boolean | Record<string, unknown>;\n };\n\n /** Devtools panel toggle during development (defaults to true) */\n devtools?: boolean;\n\n /** Backward-compatible Google Fonts declaration. */\n google?: ResuxFontFamilyInput[];\n /** Provider-aware families. Local/remote families can provide src/faces; Google families use weights. */\n families?: ResuxFontFamilyInput[];\n preconnect?: boolean;\n strategy?: ResuxFontStrategy;\n deferUntilPageLoad?: boolean;\n}\n\nconst VALID_DISPLAYS = new Set([\"auto\", \"block\", \"swap\", \"fallback\", \"optional\"]);\nconst VALID_STYLES = new Set([\"normal\", \"italic\", \"oblique\"]);\nconst VALID_FORMATS = new Set([\"woff2\", \"woff\", \"truetype\", \"opentype\", \"embedded-opentype\"]);\n\nfunction normalizeFamily(input: ResuxFontFamilyInput): string | null {\n const name = sanitizeFontFamilyName(input.name);\n if (!name) {\n return null;\n }\n const encodedName = encodeURIComponent(name)\n .replaceAll(\"%20\", \"+\")\n .replaceAll(\"'\", \"%27\");\n const weights = Array.isArray(input.weights)\n ? input.weights\n .map(normalizeWeight)\n .filter((weight): weight is string => Boolean(weight))\n : [];\n if (!weights.length) {\n return encodedName;\n }\n const normalizedWeights = [...new Set(weights)].sort(compareNormalizedWeights);\n return `${encodedName}:wght@${normalizedWeights.join(\";\")}`;\n}\n\nfunction sanitizeFontFamilyName(value: unknown): string {\n return String(value || \"\").trim().replace(/[\\u0000-\\u001f\\u007f]/g, \"\");\n}\n\nconst NAMED_WEIGHTS: Record<string, string> = {\n thin: \"100\",\n hairline: \"100\",\n extralight: \"200\",\n \"extra-light\": \"200\",\n ultralight: \"200\",\n light: \"300\",\n normal: \"400\",\n regular: \"400\",\n medium: \"500\",\n semibold: \"600\",\n \"semi-bold\": \"600\",\n demibold: \"600\",\n bold: \"700\",\n extrabold: \"800\",\n \"extra-bold\": \"800\",\n ultrabold: \"800\",\n black: \"900\",\n heavy: \"900\",\n};\n\nfunction normalizeWeight(value: number | string): string | null {\n const normalized = String(value).trim().toLowerCase();\n if (Object.hasOwn(NAMED_WEIGHTS, normalized)) return NAMED_WEIGHTS[normalized];\n const match = /^(\\d{1,4})(?:\\.\\.(\\d{1,4}))?$/.exec(normalized);\n if (!match) {\n return null;\n }\n const start = Number(match[1]);\n const end = match[2] ? Number(match[2]) : undefined;\n if (start < 1 || start > 1000 || (end !== undefined && (end < start || end > 1000))) {\n return null;\n }\n return end === undefined ? String(start) : `${start}..${end}`;\n}\n\nfunction normalizeCssWeight(value: number | string | undefined): string {\n const normalized = value === undefined ? null : normalizeWeight(value);\n if (!normalized) return \"400\";\n return normalized.replace(\"..\", \" \");\n}\n\nfunction compareNormalizedWeights(left: string, right: string): number {\n const leftRange = readWeightRange(left);\n const rightRange = readWeightRange(right);\n return leftRange.start - rightRange.start\n || leftRange.end - rightRange.end\n || compareCodeUnits(left, right);\n}\n\nfunction readWeightRange(value: string): { start: number; end: number } {\n const separator = value.indexOf(\"..\");\n const start = Number(separator < 0 ? value : value.slice(0, separator));\n const end = separator < 0 ? start : Number(value.slice(separator + 2));\n return { start, end };\n}\n\nfunction compareCodeUnits(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\nfunction normalizeDisplay(value: unknown): ResuxFontDisplay {\n return typeof value === \"string\" && VALID_DISPLAYS.has(value)\n ? value as ResuxFontDisplay\n : \"swap\";\n}\n\nfunction normalizeStyle(value: unknown): \"normal\" | \"italic\" | \"oblique\" {\n return typeof value === \"string\" && VALID_STYLES.has(value)\n ? value as \"normal\" | \"italic\" | \"oblique\"\n : \"normal\";\n}\n\nfunction buildGoogleFontsHref(families: string[], display: unknown): string {\n const familyQuery = families.map((family) => `family=${family}`).join(\"&\");\n return `https://fonts.googleapis.com/css2?${familyQuery}&display=${normalizeDisplay(display)}`;\n}\n\nexport function googleFont(input: ResuxFontFamilyInput): ResuxFontFamilyInput {\n return { ...input, provider: \"google\" };\n}\n\nexport function localFont(input: ResuxFontFamilyInput): ResuxFontFamilyInput {\n return { ...input, provider: \"local\" };\n}\n\nfunction resolveFamilyStrategy(\n input: ResuxFontFamilyInput,\n options: ResuxFontsModuleOptions,\n): ResuxFontStrategy {\n if (input.deferUntilPageLoad === true) {\n return \"lazy\";\n }\n if (input.deferUntilPageLoad === false) {\n if (input.strategy) {\n return input.strategy;\n }\n return options.strategy === \"lazy\" ? \"eager\" : (options.strategy ?? \"preload\");\n }\n if (input.strategy) {\n return input.strategy;\n }\n if (options.deferUntilPageLoad === true) {\n return \"lazy\";\n }\n return options.strategy ?? \"preload\";\n}\n\nfunction resolveProvider(input: ResuxFontFamilyInput): ResuxFontProvider {\n if (input.provider === \"local\" || input.provider === \"remote\" || input.provider === \"google\") {\n return input.provider;\n }\n const urls = fontFamilySourceUrls(input);\n if (urls.length > 0) {\n return urls.every((url) => /^https?:\\/\\//i.test(url.trim())) ? \"remote\" : \"local\";\n }\n return \"google\";\n}\n\nfunction fontFamilySourceUrls(input: ResuxFontFamilyInput): string[] {\n const faces = Array.isArray(input.faces) && input.faces.length > 0\n ? input.faces\n : input.src ? [{ src: input.src }] : [];\n const urls: string[] = [];\n for (const face of faces) {\n const entries = Array.isArray(face.src) ? face.src : [face.src];\n for (const entry of entries) {\n const url = typeof entry === \"string\" ? entry : entry?.url;\n if (typeof url === \"string\" && url.trim()) {\n urls.push(url.trim());\n }\n }\n }\n return urls;\n}\n\nfunction addGoogleFontGroup(\n families: ResuxFontFamilyInput[],\n strategy: ResuxFontStrategy,\n headLinks: Array<Record<string, string>>,\n headScripts: Array<Record<string, string>>,\n headNoscripts: Array<Record<string, unknown>>,\n): void {\n const normalized = families\n .map((family) => normalizeFamily(family))\n .filter((family): family is string => Boolean(family));\n if (!normalized.length) {\n return;\n }\n\n const href = buildGoogleFontsHref(\n normalized,\n families.find((family) => family.display)?.display,\n );\n\n if (strategy === \"eager\") {\n headLinks.push({ rel: \"stylesheet\", href });\n return;\n }\n\n headLinks.push({ rel: \"preload\", as: \"style\", href });\n headNoscripts.push({\n link: [{ rel: \"stylesheet\", href }],\n });\n\n if (strategy === \"preload\") {\n headLinks.push({\n rel: \"stylesheet\",\n href,\n media: \"print\",\n onload: \"this.media='all'\",\n \"data-resux-font-async\": \"true\",\n });\n return;\n }\n\n headLinks.push({\n rel: \"stylesheet\",\n href,\n media: \"print\",\n \"data-resux-font-lazy\": \"true\",\n });\n headScripts.push({\n \"data-resux-font-loader\": \"true\",\n innerHTML: \"(function(){function loadFonts(){document.querySelectorAll('link[data-resux-font-lazy=\\\"true\\\"]').forEach(function(link){link.media='all';});}if(document.readyState==='complete'){loadFonts();}else{window.addEventListener('load',loadFonts,{once:true});}})();\",\n });\n}\n\nfunction normalizeSourceUrl(value: unknown): string | null {\n const url = String(value || \"\").trim();\n if (!url || /[\\u0000-\\u001F\\u007F]/.test(url) || /^(?:javascript|vbscript):/i.test(url)) {\n return null;\n }\n if (\n url.startsWith(\"/\")\n || url.startsWith(\"./\")\n || url.startsWith(\"../\")\n || /^https?:\\/\\//i.test(url)\n || /^data:font\\//i.test(url)\n ) {\n return url.replace(/[\\r\\n\"'()\\\\]/g, (character) => encodeURIComponent(character));\n }\n return null;\n}\n\nfunction inferFontFormat(url: string): ResuxFontSourceInput[\"format\"] | undefined {\n const path = url.split(/[?#]/, 1)[0].toLowerCase();\n if (path.endsWith(\".woff2\")) return \"woff2\";\n if (path.endsWith(\".woff\")) return \"woff\";\n if (path.endsWith(\".ttf\")) return \"truetype\";\n if (path.endsWith(\".otf\")) return \"opentype\";\n if (path.endsWith(\".eot\")) return \"embedded-opentype\";\n return undefined;\n}\n\nfunction normalizeSources(\n input: string | ResuxFontSourceInput | Array<string | ResuxFontSourceInput>,\n): ResuxFontSourceInput[] {\n const entries = Array.isArray(input) ? input : [input];\n const sources: ResuxFontSourceInput[] = [];\n for (const entry of entries) {\n const source = typeof entry === \"string\" ? { url: entry } : entry;\n const url = normalizeSourceUrl(source?.url);\n if (!url) continue;\n const format = source?.format && VALID_FORMATS.has(source.format)\n ? source.format\n : inferFontFormat(url);\n sources.push({ url, ...(format ? { format } : {}) });\n }\n return sources.sort((left, right) => fontSourcePriority(left.format) - fontSourcePriority(right.format));\n}\n\nfunction fontSourcePriority(format: ResuxFontSourceInput[\"format\"]): number {\n if (format === \"woff2\") return 0;\n if (format === \"woff\") return 1;\n if (format === \"opentype\") return 2;\n if (format === \"truetype\") return 3;\n if (format === \"embedded-opentype\") return 4;\n return 5;\n}\n\nfunction normalizeFaces(family: ResuxFontFamilyInput): ResuxFontFaceInput[] {\n if (Array.isArray(family.faces) && family.faces.length > 0) {\n return family.faces.filter((face) => Boolean(face?.src));\n }\n if (!family.src) {\n return [];\n }\n return [{\n src: family.src,\n weight: family.weight,\n style: family.style,\n display: family.display,\n unicodeRange: family.unicodeRange,\n preload: family.preload,\n axes: family.axes,\n }];\n}\n\nfunction escapeCssString(value: string): string {\n return value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"');\n}\n\nfunction normalizeUnicodeRange(value: unknown): string | null {\n const range = String(value || \"\").trim();\n if (!range) return null;\n const tokens = range.split(\",\").map((token) => token.trim()).filter(Boolean);\n if (!tokens.length) return null;\n\n const normalized: string[] = [];\n for (const token of tokens) {\n const wildcard = /^U\\+([0-9A-F]{0,5})(\\?{1,6})$/i.exec(token);\n if (wildcard) {\n const prefix = wildcard[1];\n const wildcards = wildcard[2];\n if (prefix.length + wildcards.length > 6) return null;\n const min = Number.parseInt((prefix + \"0\".repeat(wildcards.length)) || \"0\", 16);\n const max = Number.parseInt((prefix + \"F\".repeat(wildcards.length)) || \"0\", 16);\n if (max > 0x10FFFF || min > max) return null;\n normalized.push(`U+${prefix.toUpperCase()}${wildcards}`);\n continue;\n }\n\n const explicit = /^U\\+([0-9A-F]{1,6})(?:-([0-9A-F]{1,6}))?$/i.exec(token);\n if (!explicit) return null;\n const start = Number.parseInt(explicit[1], 16);\n const end = explicit[2] ? Number.parseInt(explicit[2], 16) : start;\n if (start > 0x10FFFF || end > 0x10FFFF || start > end) return null;\n normalized.push(explicit[2]\n ? `U+${explicit[1].toUpperCase()}-${explicit[2].toUpperCase()}`\n : `U+${explicit[1].toUpperCase()}`);\n }\n return normalized.join(\", \");\n}\n\nfunction sourceCss(sources: ResuxFontSourceInput[]): string {\n return sources.map((source) => {\n const format = source.format ? ` format(\"${source.format}\")` : \"\";\n return `url(\"${escapeCssString(source.url)}\")${format}`;\n }).join(\", \");\n}\n\nfunction fontMimeType(format: ResuxFontSourceInput[\"format\"]): string | undefined {\n if (format === \"woff2\") return \"font/woff2\";\n if (format === \"woff\") return \"font/woff\";\n if (format === \"truetype\") return \"font/ttf\";\n if (format === \"opentype\") return \"font/otf\";\n if (format === \"embedded-opentype\") return \"application/vnd.ms-fontobject\";\n return undefined;\n}\n\nfunction normalizeCssVariable(value: unknown): string | null {\n const variable = typeof value === \"string\" ? value.trim() : \"\";\n if (!variable) return null;\n return /^--[A-Za-z_][\\w-]*$/.test(variable) ? variable : null;\n}\n\nfunction sanitizeAxisTag(value: unknown): string | null {\n const tag = typeof value === \"string\" ? value.trim() : \"\";\n if (/^\\w{4}$/.test(tag)) {\n return tag;\n }\n return null;\n}\n\nfunction formatVariationSettings(\n axes?: Record<string, unknown>,\n): string | null {\n if (!axes || typeof axes !== \"object\") return null;\n const settings: string[] = [];\n\n for (const [key, value] of Object.entries(axes)) {\n const tag = sanitizeAxisTag(key);\n if (!tag) continue;\n\n if (Array.isArray(value)) {\n if (\n value.length === 2 &&\n Number.isFinite(Number(value[0])) &&\n Number.isFinite(Number(value[1]))\n ) {\n settings.push(`\"${tag}\" ${Number(value[0])} ${Number(value[1])}`);\n }\n } else if (\n (typeof value === \"number\" || (typeof value === \"string\" && value.trim() !== \"\")) &&\n Number.isFinite(Number(value))\n ) {\n settings.push(`\"${tag}\" ${Number(value)}`);\n }\n }\n\n return settings.length ? settings.join(\", \") : null;\n}\n\nfunction buildCustomFontStyles(\n families: ResuxFontFamilyInput[],\n options: ResuxFontsModuleOptions,\n headLinks: Array<Record<string, string>>,\n): { initialCss: string; lazyCss: string } {\n const initialRules: string[] = [];\n const lazyRules: string[] = [];\n const variables: string[] = [];\n const preloaded = new Set<string>();\n\n for (const family of families) {\n const familyName = sanitizeFontFamilyName(family.name);\n if (!familyName) continue;\n const strategy = resolveFamilyStrategy(family, options);\n const familyDisplay = normalizeDisplay(family.display);\n const variable = normalizeCssVariable(family.variable);\n if (variable) {\n const fallbackNames = (family.fallbacks || [])\n .map((fallback) => sanitizeFontFamilyName(fallback))\n .filter(Boolean)\n .map((fallback) => {\n const alias = escapeCssString(`${familyName} fallback: ${fallback}`);\n return `\"${alias}\"`;\n });\n const stack = [`\"${escapeCssString(familyName)}\"`, ...fallbackNames];\n variables.push(`${variable}: ${stack.join(\", \")};`);\n }\n\n for (const face of normalizeFaces(family)) {\n const sources = normalizeSources(face.src);\n if (!sources.length) continue;\n const display = normalizeDisplay(face.display ?? familyDisplay);\n const weight = normalizeCssWeight(face.weight ?? family.weight);\n const style = normalizeStyle(face.style ?? family.style);\n const rawUnicodeRange = face.unicodeRange ?? family.unicodeRange;\n const unicodeRange = normalizeUnicodeRange(rawUnicodeRange);\n if (rawUnicodeRange != null && String(rawUnicodeRange).trim() && !unicodeRange) {\n continue;\n }\n const declarations = [\n `font-family: \"${escapeCssString(familyName)}\"`,\n `src: ${sourceCss(sources)}`,\n `font-weight: ${weight}`,\n `font-style: ${style}`,\n `font-display: ${display}`,\n ];\n if (unicodeRange) {\n declarations.push(`unicode-range: ${unicodeRange}`);\n }\n const variationSettings = formatVariationSettings(face.axes ?? family.axes);\n if (variationSettings) {\n declarations.push(`font-variation-settings: ${variationSettings}`);\n }\n const rule = `@font-face { ${declarations.join(\"; \")}; }`;\n (strategy === \"lazy\" ? lazyRules : initialRules).push(rule);\n\n const shouldPreload = face.preload ?? family.preload ?? strategy === \"preload\";\n if (!shouldPreload || strategy === \"lazy\") continue;\n const preferred = sources[0];\n if (!preferred || preloaded.has(preferred.url)) continue;\n preloaded.add(preferred.url);\n const type = fontMimeType(preferred.format);\n headLinks.push({\n rel: \"preload\",\n as: \"font\",\n href: preferred.url,\n crossorigin: \"\",\n ...(type ? { type } : {}),\n });\n }\n }\n\n if (variables.length > 0) {\n initialRules.push(`:root { ${variables.join(\" \")} }`);\n }\n return {\n initialCss: initialRules.join(\"\\n\"),\n lazyCss: lazyRules.join(\"\\n\"),\n };\n}\n\nfunction createLazyCustomFontLoader(css: string): string {\n const serializedCss = JSON.stringify(css);\n return `(function(){var css=${serializedCss};function load(){if(!css||document.querySelector('style[data-resux-font-lazy-runtime=\"true\"]'))return;var style=document.createElement('style');style.setAttribute('data-resux-font-lazy-runtime','true');style.textContent=css;document.head.appendChild(style);}if(document.readyState==='complete'){load();}else{window.addEventListener('load',load,{once:true});}})();`;\n}\n\nconst fontMetricsCache = new Map<string, Promise<Awaited<ReturnType<typeof getMetricsForFamily>>>>();\n\nfunction loadCachedFamilyMetrics(\n familyName: string,\n): Promise<Awaited<ReturnType<typeof getMetricsForFamily>>> {\n const cached = fontMetricsCache.get(familyName);\n if (cached) {\n return cached;\n }\n const lookup = Promise.resolve(getMetricsForFamily(familyName)).catch(() => null);\n fontMetricsCache.set(familyName, lookup);\n return lookup;\n}\n\nasync function resolveFallbackFontRules(\n families: ResuxFontFamilyInput[],\n): Promise<string[]> {\n const rules: string[] = [];\n const entries = families.filter(\n (family) => Array.isArray(family.fallbacks) && family.fallbacks.length > 0,\n );\n\n const familyResults = await Promise.all(\n entries.map(async (family) => {\n const familyName = sanitizeFontFamilyName(family.name);\n if (!familyName) {\n return [];\n }\n const metrics = await loadCachedFamilyMetrics(familyName);\n if (!metrics) {\n return [];\n }\n\n const rawFallbacks = (family.fallbacks || [])\n .map((fallback) => sanitizeFontFamilyName(fallback))\n .filter(Boolean);\n const uniqueFallbacks = [...new Set(rawFallbacks)];\n\n const fallbackRules = await Promise.all(\n uniqueFallbacks.map(async (fallbackName) => {\n try {\n const fallbackMetrics = await loadCachedFamilyMetrics(fallbackName);\n const rule = generateFontFace(metrics, {\n name: `${familyName} fallback: ${fallbackName}`,\n font: fallbackName,\n metrics: fallbackMetrics ?? undefined,\n });\n return rule ? rule.trim() : null;\n } catch {\n return null;\n }\n }),\n );\n\n return fallbackRules.filter((rule): rule is string => Boolean(rule));\n }),\n );\n\n for (const group of familyResults) {\n rules.push(...group);\n }\n\n return [...new Set(rules)];\n}\n\nfunction mapConfiguredFamilyToFontless(family: ResuxFontFamilyInput): any[] {\n const familyName = sanitizeFontFamilyName(family.name);\n if (!familyName) return [];\n\n const faces = normalizeFaces(family);\n if (faces.length > 0) {\n return faces.map((face) => {\n const sources = normalizeSources(face.src);\n const src = sources.length === 1 ? sources[0].url : sources.map((s) => s.url);\n return {\n name: familyName,\n src,\n ...(face.weight !== undefined || family.weight !== undefined ? { weight: face.weight ?? family.weight } : {}),\n ...(face.style !== undefined || family.style !== undefined ? { style: face.style ?? family.style } : {}),\n ...(face.display !== undefined || family.display !== undefined ? { display: face.display ?? family.display } : {}),\n ...(face.unicodeRange !== undefined || family.unicodeRange !== undefined ? { unicodeRange: face.unicodeRange ?? family.unicodeRange } : {}),\n ...(face.preload !== undefined || family.preload !== undefined ? { preload: face.preload ?? family.preload } : {}),\n ...(family.fallbacks ? { fallbacks: family.fallbacks } : {}),\n };\n });\n }\n\n const provider = resolveProvider(family);\n return [{\n name: familyName,\n ...(provider !== \"remote\" ? { provider } : {}),\n ...(family.weights ? { weights: family.weights } : {}),\n ...(family.display ? { display: family.display } : {}),\n ...(family.preload !== undefined ? { preload: family.preload } : {}),\n ...(family.fallbacks ? { fallbacks: family.fallbacks } : {}),\n }];\n}\n\nexport default defineResuxModule<ResuxFontsModuleOptions>({\n defaults: {\n google: [],\n families: [],\n preconnect: true,\n strategy: \"preload\",\n deferUntilPageLoad: false,\n autoScan: true,\n },\n setup(options, resux) {\n const legacyGoogleFamilies = Array.isArray(options.google) ? options.google : [];\n const configuredFamilies = Array.isArray(options.families) ? options.families : [];\n\n if (options.autoScan !== false && typeof (resux as any).addVitePlugin === \"function\") {\n const familiesToMap = [\n ...configuredFamilies,\n ...legacyGoogleFamilies.map((family) => ({ ...family, provider: \"google\" as const })),\n ];\n const mappedFamilies = familiesToMap.flatMap(mapConfiguredFamilyToFontless);\n const fontlessOptions: Record<string, unknown> = {};\n\n if (options.devtools !== undefined) {\n fontlessOptions.devtools = options.devtools;\n }\n if (options.defaults !== undefined) {\n fontlessOptions.defaults = options.defaults;\n }\n if (options.providers !== undefined) {\n const normalizedProviders: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(options.providers)) {\n if (key === \"local\") continue;\n if (typeof val === \"boolean\") {\n if (val === false) normalizedProviders[key] = false;\n } else if (typeof val === \"function\") {\n normalizedProviders[key] = val;\n } else if (val && typeof val === \"object\") {\n fontlessOptions[key] = val;\n }\n }\n if (Object.keys(normalizedProviders).length > 0) {\n fontlessOptions.providers = normalizedProviders;\n }\n }\n if (mappedFamilies.length > 0) {\n fontlessOptions.families = mappedFamilies;\n }\n\n const plugins = fontless(fontlessOptions as any);\n const pluginList = Array.isArray(plugins) ? plugins.flat() : [plugins];\n for (const plugin of pluginList) {\n if (plugin) {\n const originalTransform = (plugin as any).transform;\n if (typeof originalTransform === \"function\") {\n (plugin as any).transform = async function (code: string, id: string, ...rest: any[]) {\n if (id.endsWith(\".vue\") || id.includes(\"vue&type=style\")) {\n const styleBlocks = Array.from(\n code.matchAll(/<style\\b[^>]*>([\\s\\S]*?)<\\/style>/gi),\n (match) => match[1],\n ).filter(Boolean);\n await Promise.all(\n styleBlocks.map((styleContent) =>\n originalTransform.call(this, styleContent, `${id}.css`, ...rest),\n ),\n );\n }\n return originalTransform.call(this, code, id, ...rest);\n };\n }\n (resux as any).addVitePlugin(plugin);\n }\n }\n }\n\n const googleFamilies = [\n ...legacyGoogleFamilies,\n ...configuredFamilies.filter((family) => resolveProvider(family) === \"google\"),\n ];\n const customFamilies = configuredFamilies.filter((family) => resolveProvider(family) !== \"google\");\n\n if (!googleFamilies.length && !customFamilies.length) {\n return;\n }\n\n const allFamilies = [...legacyGoogleFamilies, ...configuredFamilies];\n const familiesWithFallbacks = allFamilies.filter(\n (family) => Array.isArray(family.fallbacks) && family.fallbacks.length > 0,\n );\n\n const applyModule = (fallbackRules: string[] = []) => {\n const groups: Record<ResuxFontStrategy, ResuxFontFamilyInput[]> = {\n eager: [],\n preload: [],\n lazy: [],\n };\n\n for (const family of googleFamilies) {\n groups[resolveFamilyStrategy(family, options)].push(family);\n }\n\n const headLinks: Array<Record<string, string>> = [];\n const headScripts: Array<Record<string, string>> = [];\n const headNoscripts: Array<Record<string, unknown>> = [];\n\n if (googleFamilies.length > 0 && options.preconnect !== false) {\n headLinks.push(\n { rel: \"preconnect\", href: \"https://fonts.googleapis.com\" },\n { rel: \"preconnect\", href: \"https://fonts.gstatic.com\", crossorigin: \"\" },\n );\n }\n\n addGoogleFontGroup(groups.eager, \"eager\", headLinks, headScripts, headNoscripts);\n addGoogleFontGroup(groups.preload, \"preload\", headLinks, headScripts, headNoscripts);\n addGoogleFontGroup(groups.lazy, \"lazy\", headLinks, headScripts, headNoscripts);\n\n const customStyles = buildCustomFontStyles(customFamilies, options, headLinks);\n if (customStyles.lazyCss) {\n headScripts.push({\n \"data-resux-font-lazy-custom-loader\": \"true\",\n innerHTML: createLazyCustomFontLoader(customStyles.lazyCss),\n });\n }\n\n const combinedInitialCss = [\n customStyles.initialCss,\n ...fallbackRules,\n ].filter(Boolean).join(\"\\n\");\n\n if (\n headLinks.length > 0\n || headScripts.length > 0\n || headNoscripts.length > 0\n || combinedInitialCss\n ) {\n resux.addHead({\n link: headLinks,\n ...(combinedInitialCss ? {\n style: [{\n id: \"resux-custom-font-faces\",\n css: combinedInitialCss,\n children: combinedInitialCss,\n \"data-resux-font-faces\": \"true\",\n }],\n } : {}),\n ...(headScripts.length > 0 ? { script: headScripts } : {}),\n ...(headNoscripts.length > 0 ? { noscript: headNoscripts } : {}),\n });\n }\n\n const providers = [...new Set(allFamilies.map((family) =>\n legacyGoogleFamilies.includes(family) ? \"google\" : resolveProvider(family)\n ))];\n\n resux.extendRuntimeConfig({\n public: {\n fonts: {\n provider: providers.length === 1 ? providers[0] : \"mixed\",\n providers,\n families: allFamilies.map((family) => family.name),\n familyConfigs: allFamilies.map((family) => ({\n name: family.name,\n strategy: resolveFamilyStrategy(family, options),\n deferUntilPageLoad: resolveFamilyStrategy(family, options) === \"lazy\",\n })),\n strategy: options.strategy || \"preload\",\n deferUntilPageLoad: options.deferUntilPageLoad ?? false,\n },\n },\n });\n };\n\n if (familiesWithFallbacks.length === 0) {\n applyModule();\n return;\n }\n\n return (async () => {\n const fallbackRules = await resolveFallbackFontRules(familiesWithFallbacks);\n applyModule(fallbackRules);\n })();\n },\n});\n"],"mappings":";;;;AAkGA,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAQ;CAAY;AAAU,CAAC;AAChF,MAAM,+BAAe,IAAI,IAAI;CAAC;CAAU;CAAU;AAAS,CAAC;AAC5D,MAAM,gCAAgB,IAAI,IAAI;CAAC;CAAS;CAAQ;CAAY;CAAY;AAAmB,CAAC;AAE5F,SAAS,gBAAgB,OAA4C;CACnE,MAAM,OAAO,uBAAuB,MAAM,IAAI;CAC9C,IAAI,CAAC,MACH,OAAO;CAET,MAAM,cAAc,mBAAmB,IAAI,CAAC,CACzC,WAAW,OAAO,GAAG,CAAC,CACtB,WAAW,KAAK,KAAK;CACxB,MAAM,UAAU,MAAM,QAAQ,MAAM,OAAO,IACvC,MAAM,QACL,IAAI,eAAe,CAAC,CACpB,QAAQ,WAA6B,QAAQ,MAAM,CAAC,IACrD,CAAC;CACL,IAAI,CAAC,QAAQ,QACX,OAAO;CAGT,OAAO,GAAG,YAAY,QADI,CAAC,GAAG,IAAI,IAAI,OAAO,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B,OAAO,CAAC;KACN,IAAI;KACJ,KAAK;KACL,UAAU;KACV,yBAAyB;IAC3B,CAAC,EACH,IAAI,CAAC;IACL,GAAI,YAAY,SAAS,IAAI,EAAE,QAAQ,YAAY,IAAI,CAAC;IACxD,GAAI,cAAc,SAAS,IAAI,EAAE,UAAU,cAAc,IAAI,CAAC;GAChE,CAAC;GAGH,MAAM,YAAY,CAAC,GAAG,IAAI,IAAI,YAAY,KAAK,WAC7C,qBAAqB,SAAS,MAAM,IAAI,WAAW,gBAAgB,MAAM,CAC3E,CAAC,CAAC;GAEF,MAAM,oBAAoB,EACxB,QAAQ,EACN,OAAO;IACL,UAAU,UAAU,WAAW,IAAI,UAAU,KAAK;IAClD;IACA,UAAU,YAAY,KAAK,WAAW,OAAO,IAAI;IACjD,eAAe,YAAY,KAAK,YAAY;KAC1C,MAAM,OAAO;KACb,UAAU,sBAAsB,QAAQ,OAAO;KAC/C,oBAAoB,sBAAsB,QAAQ,OAAO,MAAM;IACjE,EAAE;IACF,UAAU,QAAQ,YAAY;IAC9B,oBAAoB,QAAQ,sBAAsB;GACpD,EACF,EACF,CAAC;EACH;EAEA,IAAI,sBAAsB,WAAW,GAAG;GACtC,YAAY;GACZ;EACF;EAEA,QAAQ,YAAY;GAClB,MAAM,gBAAgB,MAAM,yBAAyB,qBAAqB;GAC1E,YAAY,aAAa;EAC3B,EAAA,CAAG;CACL;AACF,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/fonts/index.ts"],"sourcesContent":["import { generateFontFace, getMetricsForFamily } from \"fontaine\";\nimport { fontless } from \"fontless\";\nimport { defineResuxModule } from \"../kit/index.js\";\n\nexport type ResuxFontStrategy = \"eager\" | \"preload\" | \"lazy\";\nexport type ResuxFontDisplay = \"auto\" | \"block\" | \"swap\" | \"fallback\" | \"optional\";\nexport type ResuxFontProvider = \"google\" | \"local\" | \"remote\";\n\nexport type ResuxFontWeightName =\n | \"thin\"\n | \"hairline\"\n | \"extralight\"\n | \"extra-light\"\n | \"ultralight\"\n | \"light\"\n | \"normal\"\n | \"regular\"\n | \"medium\"\n | \"semibold\"\n | \"semi-bold\"\n | \"demibold\"\n | \"bold\"\n | \"extrabold\"\n | \"extra-bold\"\n | \"ultrabold\"\n | \"black\"\n | \"heavy\";\n\nexport type ResuxFontWeight = number | ResuxFontWeightName | (string & {});\n\nexport interface ResuxFontSourceInput {\n url: string;\n format?: \"woff2\" | \"woff\" | \"truetype\" | \"opentype\" | \"embedded-opentype\";\n}\n\nexport interface ResuxFontFaceInput {\n src: string | ResuxFontSourceInput | Array<string | ResuxFontSourceInput>;\n weight?: ResuxFontWeight;\n style?: \"normal\" | \"italic\" | \"oblique\";\n display?: ResuxFontDisplay;\n unicodeRange?: string;\n preload?: boolean;\n axes?: Record<string, number | [number, number]>;\n}\n\nexport interface ResuxFontFamilyInput {\n name: string;\n provider?: ResuxFontProvider;\n weights?: ResuxFontWeight[];\n display?: ResuxFontDisplay;\n strategy?: ResuxFontStrategy;\n deferUntilPageLoad?: boolean;\n src?: string | ResuxFontSourceInput | Array<string | ResuxFontSourceInput>;\n faces?: ResuxFontFaceInput[];\n weight?: ResuxFontWeight;\n style?: \"normal\" | \"italic\" | \"oblique\";\n unicodeRange?: string;\n preload?: boolean;\n variable?: string;\n axes?: Record<string, number | [number, number]>;\n fallbacks?: string[];\n}\n\n\nexport interface ResuxFontsModuleOptions {\n /** Enable automatic CSS/template font scanning via fontless. Defaults to true. */\n autoScan?: boolean;\n\n /** Global font defaults across all resolved families */\n defaults?: {\n preload?: boolean;\n subsets?: string[];\n weights?: ResuxFontWeight[];\n styles?: Array<\"normal\" | \"italic\" | \"oblique\">;\n fallbacks?: string[];\n };\n\n /** Provider configurations (google, bunny, fontshare, fontsource, local) */\n providers?: {\n google?: boolean | Record<string, unknown>;\n bunny?: boolean | Record<string, unknown>;\n fontshare?: boolean | Record<string, unknown>;\n fontsource?: boolean | Record<string, unknown>;\n local?: boolean | Record<string, unknown>;\n };\n\n /** Devtools panel toggle during development (defaults to true) */\n devtools?: boolean;\n\n /** Backward-compatible Google Fonts declaration. */\n google?: ResuxFontFamilyInput[];\n /** Provider-aware families. Local/remote families can provide src/faces; Google families use weights. */\n families?: ResuxFontFamilyInput[];\n preconnect?: boolean;\n strategy?: ResuxFontStrategy;\n deferUntilPageLoad?: boolean;\n}\n\nconst VALID_DISPLAYS = new Set([\"auto\", \"block\", \"swap\", \"fallback\", \"optional\"]);\nconst VALID_STYLES = new Set([\"normal\", \"italic\", \"oblique\"]);\nconst VALID_FORMATS = new Set([\"woff2\", \"woff\", \"truetype\", \"opentype\", \"embedded-opentype\"]);\n\nfunction normalizeFamily(input: ResuxFontFamilyInput): string | null {\n const name = sanitizeFontFamilyName(input.name);\n if (!name) {\n return null;\n }\n const encodedName = encodeURIComponent(name)\n .replaceAll(\"%20\", \"+\")\n .replaceAll(\"'\", \"%27\");\n const weights = Array.isArray(input.weights)\n ? input.weights\n .map(normalizeWeight)\n .filter((weight): weight is string => Boolean(weight))\n : [];\n if (!weights.length) {\n return encodedName;\n }\n const normalizedWeights = [...new Set(weights)].sort(compareNormalizedWeights);\n return `${encodedName}:wght@${normalizedWeights.join(\";\")}`;\n}\n\nfunction sanitizeFontFamilyName(value: unknown): string {\n return String(value || \"\").trim().replace(/[\\u0000-\\u001f\\u007f]/g, \"\");\n}\n\nconst NAMED_WEIGHTS: Record<string, string> = {\n thin: \"100\",\n hairline: \"100\",\n extralight: \"200\",\n \"extra-light\": \"200\",\n ultralight: \"200\",\n light: \"300\",\n normal: \"400\",\n regular: \"400\",\n medium: \"500\",\n semibold: \"600\",\n \"semi-bold\": \"600\",\n demibold: \"600\",\n bold: \"700\",\n extrabold: \"800\",\n \"extra-bold\": \"800\",\n ultrabold: \"800\",\n black: \"900\",\n heavy: \"900\",\n};\n\nfunction normalizeWeight(value: number | string): string | null {\n const normalized = String(value).trim().toLowerCase();\n if (Object.hasOwn(NAMED_WEIGHTS, normalized)) return NAMED_WEIGHTS[normalized];\n const match = /^(\\d{1,4})(?:\\.\\.(\\d{1,4}))?$/.exec(normalized);\n if (!match) {\n return null;\n }\n const start = Number(match[1]);\n const end = match[2] ? Number(match[2]) : undefined;\n if (start < 1 || start > 1000 || (end !== undefined && (end < start || end > 1000))) {\n return null;\n }\n return end === undefined ? String(start) : `${start}..${end}`;\n}\n\nfunction normalizeCssWeight(value: number | string | undefined): string {\n const normalized = value === undefined ? null : normalizeWeight(value);\n if (!normalized) return \"400\";\n return normalized.replace(\"..\", \" \");\n}\n\nfunction compareNormalizedWeights(left: string, right: string): number {\n const leftRange = readWeightRange(left);\n const rightRange = readWeightRange(right);\n return leftRange.start - rightRange.start\n || leftRange.end - rightRange.end\n || compareCodeUnits(left, right);\n}\n\nfunction readWeightRange(value: string): { start: number; end: number } {\n const separator = value.indexOf(\"..\");\n const start = Number(separator < 0 ? value : value.slice(0, separator));\n const end = separator < 0 ? start : Number(value.slice(separator + 2));\n return { start, end };\n}\n\nfunction compareCodeUnits(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\nfunction normalizeDisplay(value: unknown): ResuxFontDisplay {\n return typeof value === \"string\" && VALID_DISPLAYS.has(value)\n ? value as ResuxFontDisplay\n : \"swap\";\n}\n\nfunction normalizeStyle(value: unknown): \"normal\" | \"italic\" | \"oblique\" {\n return typeof value === \"string\" && VALID_STYLES.has(value)\n ? value as \"normal\" | \"italic\" | \"oblique\"\n : \"normal\";\n}\n\nfunction buildGoogleFontsHref(families: string[], display: unknown): string {\n const familyQuery = families.map((family) => `family=${family}`).join(\"&\");\n return `https://fonts.googleapis.com/css2?${familyQuery}&display=${normalizeDisplay(display)}`;\n}\n\nexport function googleFont(input: ResuxFontFamilyInput): ResuxFontFamilyInput {\n return { ...input, provider: \"google\" };\n}\n\nexport function localFont(input: ResuxFontFamilyInput): ResuxFontFamilyInput {\n return { ...input, provider: \"local\" };\n}\n\nfunction resolveFamilyStrategy(\n input: ResuxFontFamilyInput,\n options: ResuxFontsModuleOptions,\n): ResuxFontStrategy {\n if (input.deferUntilPageLoad === true) {\n return \"lazy\";\n }\n if (input.deferUntilPageLoad === false) {\n if (input.strategy) {\n return input.strategy;\n }\n return options.strategy === \"lazy\" ? \"eager\" : (options.strategy ?? \"preload\");\n }\n if (input.strategy) {\n return input.strategy;\n }\n if (options.deferUntilPageLoad === true) {\n return \"lazy\";\n }\n return options.strategy ?? \"preload\";\n}\n\nfunction resolveProvider(input: ResuxFontFamilyInput): ResuxFontProvider {\n if (input.provider === \"local\" || input.provider === \"remote\" || input.provider === \"google\") {\n return input.provider;\n }\n const urls = fontFamilySourceUrls(input);\n if (urls.length > 0) {\n return urls.every((url) => /^https?:\\/\\//i.test(url.trim())) ? \"remote\" : \"local\";\n }\n return \"google\";\n}\n\nfunction fontFamilySourceUrls(input: ResuxFontFamilyInput): string[] {\n const faces = Array.isArray(input.faces) && input.faces.length > 0\n ? input.faces\n : input.src ? [{ src: input.src }] : [];\n const urls: string[] = [];\n for (const face of faces) {\n const entries = Array.isArray(face.src) ? face.src : [face.src];\n for (const entry of entries) {\n const url = typeof entry === \"string\" ? entry : entry?.url;\n if (typeof url === \"string\" && url.trim()) {\n urls.push(url.trim());\n }\n }\n }\n return urls;\n}\n\nfunction addGoogleFontGroup(\n families: ResuxFontFamilyInput[],\n strategy: ResuxFontStrategy,\n headLinks: Array<Record<string, string>>,\n headScripts: Array<Record<string, string>>,\n headNoscripts: Array<Record<string, unknown>>,\n): void {\n const normalized = families\n .map((family) => normalizeFamily(family))\n .filter((family): family is string => Boolean(family));\n if (!normalized.length) {\n return;\n }\n\n const href = buildGoogleFontsHref(\n normalized,\n families.find((family) => family.display)?.display,\n );\n\n if (strategy === \"eager\") {\n headLinks.push({ rel: \"stylesheet\", href });\n return;\n }\n\n headLinks.push({ rel: \"preload\", as: \"style\", href });\n headNoscripts.push({\n link: [{ rel: \"stylesheet\", href }],\n });\n\n if (strategy === \"preload\") {\n headLinks.push({\n rel: \"stylesheet\",\n href,\n media: \"print\",\n onload: \"this.media='all'\",\n \"data-resux-font-async\": \"true\",\n });\n return;\n }\n\n headLinks.push({\n rel: \"stylesheet\",\n href,\n media: \"print\",\n \"data-resux-font-lazy\": \"true\",\n });\n headScripts.push({\n \"data-resux-font-loader\": \"true\",\n innerHTML: \"(function(){function loadFonts(){document.querySelectorAll('link[data-resux-font-lazy=\\\"true\\\"]').forEach(function(link){link.media='all';});}if(document.readyState==='complete'){loadFonts();}else{window.addEventListener('load',loadFonts,{once:true});}})();\",\n });\n}\n\nfunction normalizeSourceUrl(value: unknown): string | null {\n const url = String(value || \"\").trim();\n if (!url || /[\\u0000-\\u001F\\u007F]/.test(url) || /^(?:javascript|vbscript):/i.test(url)) {\n return null;\n }\n if (\n url.startsWith(\"/\")\n || url.startsWith(\"./\")\n || url.startsWith(\"../\")\n || /^https?:\\/\\//i.test(url)\n || /^data:font\\//i.test(url)\n ) {\n return url.replace(/[\\r\\n\"'()\\\\]/g, (character) => encodeURIComponent(character));\n }\n return null;\n}\n\nfunction inferFontFormat(url: string): ResuxFontSourceInput[\"format\"] | undefined {\n const path = url.split(/[?#]/, 1)[0].toLowerCase();\n if (path.endsWith(\".woff2\")) return \"woff2\";\n if (path.endsWith(\".woff\")) return \"woff\";\n if (path.endsWith(\".ttf\")) return \"truetype\";\n if (path.endsWith(\".otf\")) return \"opentype\";\n if (path.endsWith(\".eot\")) return \"embedded-opentype\";\n return undefined;\n}\n\nfunction normalizeSources(\n input: string | ResuxFontSourceInput | Array<string | ResuxFontSourceInput>,\n): ResuxFontSourceInput[] {\n const entries = Array.isArray(input) ? input : [input];\n const sources: ResuxFontSourceInput[] = [];\n for (const entry of entries) {\n const source = typeof entry === \"string\" ? { url: entry } : entry;\n const url = normalizeSourceUrl(source?.url);\n if (!url) continue;\n const format = source?.format && VALID_FORMATS.has(source.format)\n ? source.format\n : inferFontFormat(url);\n sources.push({ url, ...(format ? { format } : {}) });\n }\n return sources.sort((left, right) => fontSourcePriority(left.format) - fontSourcePriority(right.format));\n}\n\nfunction fontSourcePriority(format: ResuxFontSourceInput[\"format\"]): number {\n if (format === \"woff2\") return 0;\n if (format === \"woff\") return 1;\n if (format === \"opentype\") return 2;\n if (format === \"truetype\") return 3;\n if (format === \"embedded-opentype\") return 4;\n return 5;\n}\n\nfunction normalizeFaces(family: ResuxFontFamilyInput): ResuxFontFaceInput[] {\n if (Array.isArray(family.faces) && family.faces.length > 0) {\n return family.faces.filter((face) => Boolean(face?.src));\n }\n if (!family.src) {\n return [];\n }\n return [{\n src: family.src,\n weight: family.weight,\n style: family.style,\n display: family.display,\n unicodeRange: family.unicodeRange,\n preload: family.preload,\n axes: family.axes,\n }];\n}\n\nfunction escapeCssString(value: string): string {\n return value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"');\n}\n\nfunction normalizeUnicodeRange(value: unknown): string | null {\n const range = String(value || \"\").trim();\n if (!range) return null;\n const tokens = range.split(\",\").map((token) => token.trim()).filter(Boolean);\n if (!tokens.length) return null;\n\n const normalized: string[] = [];\n for (const token of tokens) {\n const wildcard = /^U\\+([0-9A-F]{0,5})(\\?{1,6})$/i.exec(token);\n if (wildcard) {\n const prefix = wildcard[1];\n const wildcards = wildcard[2];\n if (prefix.length + wildcards.length > 6) return null;\n const min = Number.parseInt((prefix + \"0\".repeat(wildcards.length)) || \"0\", 16);\n const max = Number.parseInt((prefix + \"F\".repeat(wildcards.length)) || \"0\", 16);\n if (max > 0x10FFFF || min > max) return null;\n normalized.push(`U+${prefix.toUpperCase()}${wildcards}`);\n continue;\n }\n\n const explicit = /^U\\+([0-9A-F]{1,6})(?:-([0-9A-F]{1,6}))?$/i.exec(token);\n if (!explicit) return null;\n const start = Number.parseInt(explicit[1], 16);\n const end = explicit[2] ? Number.parseInt(explicit[2], 16) : start;\n if (start > 0x10FFFF || end > 0x10FFFF || start > end) return null;\n normalized.push(explicit[2]\n ? `U+${explicit[1].toUpperCase()}-${explicit[2].toUpperCase()}`\n : `U+${explicit[1].toUpperCase()}`);\n }\n return normalized.join(\", \");\n}\n\nfunction sourceCss(sources: ResuxFontSourceInput[]): string {\n return sources.map((source) => {\n const format = source.format ? ` format(\"${source.format}\")` : \"\";\n return `url(\"${escapeCssString(source.url)}\")${format}`;\n }).join(\", \");\n}\n\nfunction fontMimeType(format: ResuxFontSourceInput[\"format\"]): string | undefined {\n if (format === \"woff2\") return \"font/woff2\";\n if (format === \"woff\") return \"font/woff\";\n if (format === \"truetype\") return \"font/ttf\";\n if (format === \"opentype\") return \"font/otf\";\n if (format === \"embedded-opentype\") return \"application/vnd.ms-fontobject\";\n return undefined;\n}\n\nfunction normalizeCssVariable(value: unknown): string | null {\n const variable = typeof value === \"string\" ? value.trim() : \"\";\n if (!variable) return null;\n return /^--[A-Za-z_][\\w-]*$/.test(variable) ? variable : null;\n}\n\nfunction sanitizeAxisTag(value: unknown): string | null {\n const tag = typeof value === \"string\" ? value.trim() : \"\";\n if (/^\\w{4}$/.test(tag)) {\n return tag;\n }\n return null;\n}\n\nfunction formatVariationSettings(\n axes?: Record<string, unknown>,\n): string | null {\n if (!axes || typeof axes !== \"object\") return null;\n const settings: string[] = [];\n\n for (const [key, value] of Object.entries(axes)) {\n const tag = sanitizeAxisTag(key);\n if (!tag) continue;\n\n if (Array.isArray(value)) {\n if (\n value.length === 2 &&\n Number.isFinite(Number(value[0])) &&\n Number.isFinite(Number(value[1]))\n ) {\n settings.push(`\"${tag}\" ${Number(value[0])} ${Number(value[1])}`);\n }\n } else if (\n (typeof value === \"number\" || (typeof value === \"string\" && value.trim() !== \"\")) &&\n Number.isFinite(Number(value))\n ) {\n settings.push(`\"${tag}\" ${Number(value)}`);\n }\n }\n\n return settings.length ? settings.join(\", \") : null;\n}\n\nfunction buildCustomFontStyles(\n families: ResuxFontFamilyInput[],\n options: ResuxFontsModuleOptions,\n headLinks: Array<Record<string, string>>,\n): { initialCss: string; lazyCss: string } {\n const initialRules: string[] = [];\n const lazyRules: string[] = [];\n const variables: string[] = [];\n const preloaded = new Set<string>();\n\n for (const family of families) {\n const familyName = sanitizeFontFamilyName(family.name);\n if (!familyName) continue;\n const strategy = resolveFamilyStrategy(family, options);\n const familyDisplay = normalizeDisplay(family.display);\n const variable = normalizeCssVariable(family.variable);\n if (variable) {\n const fallbackNames = (family.fallbacks || [])\n .map((fallback) => sanitizeFontFamilyName(fallback))\n .filter(Boolean)\n .map((fallback) => {\n const alias = escapeCssString(`${familyName} fallback: ${fallback}`);\n return `\"${alias}\"`;\n });\n const stack = [`\"${escapeCssString(familyName)}\"`, ...fallbackNames];\n variables.push(`${variable}: ${stack.join(\", \")};`);\n }\n\n for (const face of normalizeFaces(family)) {\n const sources = normalizeSources(face.src);\n if (!sources.length) continue;\n const display = normalizeDisplay(face.display ?? familyDisplay);\n const weight = normalizeCssWeight(face.weight ?? family.weight);\n const style = normalizeStyle(face.style ?? family.style);\n const rawUnicodeRange = face.unicodeRange ?? family.unicodeRange;\n const unicodeRange = normalizeUnicodeRange(rawUnicodeRange);\n if (rawUnicodeRange != null && String(rawUnicodeRange).trim() && !unicodeRange) {\n continue;\n }\n const declarations = [\n `font-family: \"${escapeCssString(familyName)}\"`,\n `src: ${sourceCss(sources)}`,\n `font-weight: ${weight}`,\n `font-style: ${style}`,\n `font-display: ${display}`,\n ];\n if (unicodeRange) {\n declarations.push(`unicode-range: ${unicodeRange}`);\n }\n const variationSettings = formatVariationSettings(face.axes ?? family.axes);\n if (variationSettings) {\n declarations.push(`font-variation-settings: ${variationSettings}`);\n }\n const rule = `@font-face { ${declarations.join(\"; \")}; }`;\n (strategy === \"lazy\" ? lazyRules : initialRules).push(rule);\n\n const shouldPreload = face.preload ?? family.preload ?? strategy === \"preload\";\n if (!shouldPreload || strategy === \"lazy\") continue;\n const preferred = sources[0];\n if (!preferred || preloaded.has(preferred.url)) continue;\n preloaded.add(preferred.url);\n const type = fontMimeType(preferred.format);\n headLinks.push({\n rel: \"preload\",\n as: \"font\",\n href: preferred.url,\n crossorigin: \"\",\n ...(type ? { type } : {}),\n });\n }\n }\n\n if (variables.length > 0) {\n initialRules.push(`:root { ${variables.join(\" \")} }`);\n }\n return {\n initialCss: initialRules.join(\"\\n\"),\n lazyCss: lazyRules.join(\"\\n\"),\n };\n}\n\nfunction createLazyCustomFontLoader(css: string): string {\n const serializedCss = JSON.stringify(css);\n return `(function(){var css=${serializedCss};function load(){if(!css||document.querySelector('style[data-resux-font-lazy-runtime=\"true\"]'))return;var style=document.createElement('style');style.setAttribute('data-resux-font-lazy-runtime','true');style.textContent=css;document.head.appendChild(style);}if(document.readyState==='complete'){load();}else{window.addEventListener('load',load,{once:true});}})();`;\n}\n\nconst fontMetricsCache = new Map<string, Promise<Awaited<ReturnType<typeof getMetricsForFamily>>>>();\n\nfunction loadCachedFamilyMetrics(\n familyName: string,\n): Promise<Awaited<ReturnType<typeof getMetricsForFamily>>> {\n const cached = fontMetricsCache.get(familyName);\n if (cached) {\n return cached;\n }\n const lookup = Promise.resolve(getMetricsForFamily(familyName)).catch(() => null);\n fontMetricsCache.set(familyName, lookup);\n return lookup;\n}\n\nasync function resolveFallbackFontRules(\n families: ResuxFontFamilyInput[],\n): Promise<string[]> {\n const rules: string[] = [];\n const entries = families.filter(\n (family) => Array.isArray(family.fallbacks) && family.fallbacks.length > 0,\n );\n\n const familyResults = await Promise.all(\n entries.map(async (family) => {\n const familyName = sanitizeFontFamilyName(family.name);\n if (!familyName) {\n return [];\n }\n const metrics = await loadCachedFamilyMetrics(familyName);\n if (!metrics) {\n return [];\n }\n\n const rawFallbacks = (family.fallbacks || [])\n .map((fallback) => sanitizeFontFamilyName(fallback))\n .filter(Boolean);\n const uniqueFallbacks = [...new Set(rawFallbacks)];\n\n const fallbackRules = await Promise.all(\n uniqueFallbacks.map(async (fallbackName) => {\n try {\n const fallbackMetrics = await loadCachedFamilyMetrics(fallbackName);\n const rule = generateFontFace(metrics, {\n name: `${familyName} fallback: ${fallbackName}`,\n font: fallbackName,\n metrics: fallbackMetrics ?? undefined,\n });\n return rule ? rule.trim() : null;\n } catch {\n return null;\n }\n }),\n );\n\n return fallbackRules.filter((rule): rule is string => Boolean(rule));\n }),\n );\n\n for (const group of familyResults) {\n rules.push(...group);\n }\n\n return [...new Set(rules)];\n}\n\nfunction mapConfiguredFamilyToFontless(family: ResuxFontFamilyInput): any[] {\n const familyName = sanitizeFontFamilyName(family.name);\n if (!familyName) return [];\n\n const faces = normalizeFaces(family);\n if (faces.length > 0) {\n return faces.map((face) => {\n const sources = normalizeSources(face.src);\n const src = sources.length === 1 ? sources[0].url : sources.map((s) => s.url);\n return {\n name: familyName,\n src,\n ...(face.weight !== undefined || family.weight !== undefined ? { weight: face.weight ?? family.weight } : {}),\n ...(face.style !== undefined || family.style !== undefined ? { style: face.style ?? family.style } : {}),\n ...(face.display !== undefined || family.display !== undefined ? { display: face.display ?? family.display } : {}),\n ...(face.unicodeRange !== undefined || family.unicodeRange !== undefined ? { unicodeRange: face.unicodeRange ?? family.unicodeRange } : {}),\n ...(face.preload !== undefined || family.preload !== undefined ? { preload: face.preload ?? family.preload } : {}),\n ...(family.fallbacks ? { fallbacks: family.fallbacks } : {}),\n };\n });\n }\n\n const provider = resolveProvider(family);\n return [{\n name: familyName,\n ...(provider !== \"remote\" ? { provider } : {}),\n ...(family.weights ? { weights: family.weights } : {}),\n ...(family.display ? { display: family.display } : {}),\n ...(family.preload !== undefined ? { preload: family.preload } : {}),\n ...(family.fallbacks ? { fallbacks: family.fallbacks } : {}),\n }];\n}\n\nexport default defineResuxModule<ResuxFontsModuleOptions>({\n defaults: {\n google: [],\n families: [],\n preconnect: true,\n strategy: \"preload\",\n deferUntilPageLoad: false,\n autoScan: true,\n },\n setup(options, resux) {\n const legacyGoogleFamilies = Array.isArray(options.google) ? options.google : [];\n const configuredFamilies = Array.isArray(options.families) ? options.families : [];\n\n if (options.autoScan !== false && typeof (resux as any).addVitePlugin === \"function\") {\n const familiesToMap = [\n ...configuredFamilies,\n ...legacyGoogleFamilies.map((family) => ({ ...family, provider: \"google\" as const })),\n ];\n const mappedFamilies = familiesToMap.flatMap(mapConfiguredFamilyToFontless);\n const fontlessOptions: Record<string, unknown> = {};\n\n if (options.devtools !== undefined) {\n fontlessOptions.devtools = options.devtools;\n }\n if (options.defaults !== undefined) {\n fontlessOptions.defaults = options.defaults;\n }\n if (options.providers !== undefined) {\n const normalizedProviders: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(options.providers)) {\n if (key === \"local\") continue;\n if (typeof val === \"boolean\") {\n if (val === false) normalizedProviders[key] = false;\n } else if (typeof val === \"function\") {\n normalizedProviders[key] = val;\n } else if (val && typeof val === \"object\") {\n fontlessOptions[key] = val;\n }\n }\n if (Object.keys(normalizedProviders).length > 0) {\n fontlessOptions.providers = normalizedProviders;\n }\n }\n if (mappedFamilies.length > 0) {\n fontlessOptions.families = mappedFamilies;\n }\n\n const plugins = fontless(fontlessOptions as any);\n const pluginList = Array.isArray(plugins) ? plugins.flat() : [plugins];\n for (const plugin of pluginList) {\n if (plugin) {\n const originalTransform = (plugin as any).transform;\n if (typeof originalTransform === \"function\") {\n (plugin as any).transform = async function (code: string, id: string, ...rest: any[]) {\n if (id.endsWith(\".vue\") || id.includes(\"vue&type=style\")) {\n const styleBlocks = Array.from(\n code.matchAll(/<style\\b[^>]*>([\\s\\S]*?)<\\/style>/gi),\n (match) => match[1],\n ).filter(Boolean);\n await Promise.all(\n styleBlocks.map((styleContent) =>\n originalTransform.call(this, styleContent, `${id}.css`, ...rest),\n ),\n );\n }\n return originalTransform.call(this, code, id, ...rest);\n };\n }\n (resux as any).addVitePlugin(plugin);\n }\n }\n }\n\n const googleFamilies = [\n ...legacyGoogleFamilies,\n ...configuredFamilies.filter((family) => resolveProvider(family) === \"google\"),\n ];\n const customFamilies = configuredFamilies.filter((family) => resolveProvider(family) !== \"google\");\n\n if (!googleFamilies.length && !customFamilies.length) {\n return;\n }\n\n const allFamilies = [...legacyGoogleFamilies, ...configuredFamilies];\n const familiesWithFallbacks = allFamilies.filter(\n (family) => Array.isArray(family.fallbacks) && family.fallbacks.length > 0,\n );\n\n const applyModule = (fallbackRules: string[] = []) => {\n const groups: Record<ResuxFontStrategy, ResuxFontFamilyInput[]> = {\n eager: [],\n preload: [],\n lazy: [],\n };\n\n for (const family of googleFamilies) {\n groups[resolveFamilyStrategy(family, options)].push(family);\n }\n\n const headLinks: Array<Record<string, string>> = [];\n const headScripts: Array<Record<string, string>> = [];\n const headNoscripts: Array<Record<string, unknown>> = [];\n\n if (googleFamilies.length > 0 && options.preconnect !== false) {\n headLinks.push(\n { rel: \"preconnect\", href: \"https://fonts.googleapis.com\" },\n { rel: \"preconnect\", href: \"https://fonts.gstatic.com\", crossorigin: \"\" },\n );\n }\n\n addGoogleFontGroup(groups.eager, \"eager\", headLinks, headScripts, headNoscripts);\n addGoogleFontGroup(groups.preload, \"preload\", headLinks, headScripts, headNoscripts);\n addGoogleFontGroup(groups.lazy, \"lazy\", headLinks, headScripts, headNoscripts);\n\n const customStyles = buildCustomFontStyles(customFamilies, options, headLinks);\n if (customStyles.lazyCss) {\n headScripts.push({\n \"data-resux-font-lazy-custom-loader\": \"true\",\n innerHTML: createLazyCustomFontLoader(customStyles.lazyCss),\n });\n }\n\n const combinedInitialCss = [\n customStyles.initialCss,\n ...fallbackRules,\n ].filter(Boolean).join(\"\\n\");\n\n if (\n headLinks.length > 0\n || headScripts.length > 0\n || headNoscripts.length > 0\n || combinedInitialCss\n ) {\n resux.addHead({\n link: headLinks,\n ...(combinedInitialCss ? {\n style: [{\n id: \"resux-custom-font-faces\",\n css: combinedInitialCss,\n children: combinedInitialCss,\n \"data-resux-font-faces\": \"true\",\n }],\n } : {}),\n ...(headScripts.length > 0 ? { script: headScripts } : {}),\n ...(headNoscripts.length > 0 ? { noscript: headNoscripts } : {}),\n });\n }\n\n const providers = [...new Set(allFamilies.map((family) =>\n legacyGoogleFamilies.includes(family) ? \"google\" : resolveProvider(family)\n ))];\n\n resux.extendRuntimeConfig({\n public: {\n fonts: {\n provider: providers.length === 1 ? providers[0] : \"mixed\",\n providers,\n families: allFamilies.map((family) => family.name),\n familyConfigs: allFamilies.map((family) => ({\n name: family.name,\n strategy: resolveFamilyStrategy(family, options),\n deferUntilPageLoad: resolveFamilyStrategy(family, options) === \"lazy\",\n })),\n strategy: options.strategy || \"preload\",\n deferUntilPageLoad: options.deferUntilPageLoad ?? false,\n },\n },\n });\n };\n\n if (familiesWithFallbacks.length === 0) {\n applyModule();\n return;\n }\n\n return (async () => {\n const fallbackRules = await resolveFallbackFontRules(familiesWithFallbacks);\n applyModule(fallbackRules);\n })();\n },\n});\n"],"mappings":";;;;AAkGA,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAQ;CAAY;AAAU,CAAC;AAChF,MAAM,+BAAe,IAAI,IAAI;CAAC;CAAU;CAAU;AAAS,CAAC;AAC5D,MAAM,gCAAgB,IAAI,IAAI;CAAC;CAAS;CAAQ;CAAY;CAAY;AAAmB,CAAC;AAE5F,SAAS,gBAAgB,OAA4C;CACnE,MAAM,OAAO,uBAAuB,MAAM,IAAI;CAC9C,IAAI,CAAC,MACH,OAAO;CAET,MAAM,cAAc,mBAAmB,IAAI,CAAC,CACzC,WAAW,OAAO,GAAG,CAAC,CACtB,WAAW,KAAK,KAAK;CACxB,MAAM,UAAU,MAAM,QAAQ,MAAM,OAAO,IACvC,MAAM,QACL,IAAI,eAAe,CAAC,CACpB,QAAQ,WAA6B,QAAQ,MAAM,CAAC,IACrD,CAAC;CACL,IAAI,CAAC,QAAQ,QACX,OAAO;CAGT,OAAO,GAAG,YAAY,QADI,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,wBACP,CAAC,CAAC,KAAK,GAAG;AAC1D;AAEA,SAAS,uBAAuB,OAAwB;CACtD,OAAO,OAAO,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,0BAA0B,EAAE;AACxE;AAEA,MAAM,gBAAwC;CAC5C,MAAM;CACN,UAAU;CACV,YAAY;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,YAAY,CAAC,GAAG,IAAI,IAAI,YAAY,KAAK,WAC7C,qBAAqB,SAAS,MAAM,IAAI,WAAW,gBAAgB,MAAM,CAC3E,CAAC,CAAC;GAEF,MAAM,oBAAoB,EACxB,QAAQ,EACN,OAAO;IACL,UAAU,UAAU,WAAW,IAAI,UAAU,KAAK;IAClD;IACA,UAAU,YAAY,KAAK,WAAW,OAAO,IAAI;IACjD,eAAe,YAAY,KAAK,YAAY;KAC1C,MAAM,OAAO;KACb,UAAU,sBAAsB,QAAQ,OAAO;KAC/C,oBAAoB,sBAAsB,QAAQ,OAAO,MAAM;IACjE,EAAE;IACF,UAAU,QAAQ,YAAY;IAC9B,oBAAoB,QAAQ,sBAAsB;GACpD,EACF,EACF,CAAC;EACH;EAEA,IAAI,sBAAsB,WAAW,GAAG;GACtC,YAAY;GACZ;EACF;EAEA,QAAQ,YAAY;GAClB,MAAM,gBAAgB,MAAM,yBAAyB,qBAAqB;GAC1E,YAAY,aAAa;EAC3B,EAAA,CAAG;CACL;AACF,CAAC"}
package/dist/globals.d.ts CHANGED
@@ -75,5 +75,4 @@ declare global {
75
75
  statusCode?: number;
76
76
  }) => RouteMiddlewareResult;
77
77
  const defineResuxModule: <TOptions = Record<string, unknown>>(module: ResuxModule<TOptions>) => ResuxModule<TOptions>;
78
- }
79
- //# sourceMappingURL=globals.d.ts.map
78
+ }
@@ -1,5 +1,4 @@
1
1
  import { HalalCheckResult } from "../status.js";
2
2
  export declare function classifyProject(scannedData: any, apiKey?: string, endpoint?: string): Promise<HalalCheckResult>;
3
3
  export declare function validateAiEndpoint(endpoint: string): URL;
4
- export declare function resolveAiTimeoutMs(value?: string | undefined): number;
5
- //# sourceMappingURL=classifyProject.d.ts.map
4
+ export declare function resolveAiTimeoutMs(value?: string | undefined): number;
@@ -1,4 +1,3 @@
1
1
  import { HalalCheckResult } from "../status.js";
2
2
  import { HalalRuntimeAiOptions, HalalRuntimeContent } from "../runtime/types.js";
3
- export declare function classifyRuntimeContentWithAi(content: HalalRuntimeContent, serializedContent: string, localResult: HalalCheckResult, options?: HalalRuntimeAiOptions): Promise<HalalCheckResult | null>;
4
- //# sourceMappingURL=classifyRuntimeContent.d.ts.map
3
+ export declare function classifyRuntimeContentWithAi(content: HalalRuntimeContent, serializedContent: string, localResult: HalalCheckResult, options?: HalalRuntimeAiOptions): Promise<HalalCheckResult | null>;
@@ -36,5 +36,4 @@ export declare function createProjectSummary(scannedData: {
36
36
  hasCrypto: boolean;
37
37
  snippet: string;
38
38
  }[];
39
- };
40
- //# sourceMappingURL=createProjectSummary.d.ts.map
39
+ };
@@ -1,2 +1 @@
1
- export declare const HALAL_CLASSIFIER_PROMPT = "\nYou are the Resux Halal Core AI Classifier. Your job is to classify a summarized ResuxJS project metadata bundle according to the safety and ethical policies of the framework.\n\nCRITICAL INSTRUCTIONS:\n1. You MUST NOT issue religious fatwas or claim to represent official Islamic jurisprudential authority. You are an engineering guardrail executing policy heuristics.\n2. If the project's purpose is ambiguous, educational, news reporting, cybersecurity training (defensive), or addiction recovery, you MUST classify it as \"review_required\" rather than \"blocked\".\n3. Only classify as \"blocked\" if the project clearly, unambiguously represents a prohibited case (e.g. real gambling client, real phishing page, real malware backdoor, real adult portal).\n4. You must return a strict JSON payload matching the requested schema. No conversational prefix or suffix.\n\nJSON SCHEMA:\n{\n \"status\": \"allowed\" | \"warning\" | \"review_required\" | \"blocked\",\n \"riskLevel\": \"low\" | \"medium\" | \"high\" | \"critical\",\n \"categories\": [\"phishing\" | \"gambling\" | \"adult\" | \"usury\" | \"malware\" | ...],\n \"confidence\": 0.0 to 1.0,\n \"reasons\": [\"Reason 1\", \"Reason 2\", ...],\n \"recommendedAction\": \"Action statement\"\n}\n";
2
- //# sourceMappingURL=halalClassifierPrompt.d.ts.map
1
+ export declare const HALAL_CLASSIFIER_PROMPT = "\nYou are the Resux Halal Core AI Classifier. Your job is to classify a summarized ResuxJS project metadata bundle according to the safety and ethical policies of the framework.\n\nCRITICAL INSTRUCTIONS:\n1. You MUST NOT issue religious fatwas or claim to represent official Islamic jurisprudential authority. You are an engineering guardrail executing policy heuristics.\n2. If the project's purpose is ambiguous, educational, news reporting, cybersecurity training (defensive), or addiction recovery, you MUST classify it as \"review_required\" rather than \"blocked\".\n3. Only classify as \"blocked\" if the project clearly, unambiguously represents a prohibited case (e.g. real gambling client, real phishing page, real malware backdoor, real adult portal).\n4. You must return a strict JSON payload matching the requested schema. No conversational prefix or suffix.\n\nJSON SCHEMA:\n{\n \"status\": \"allowed\" | \"warning\" | \"review_required\" | \"blocked\",\n \"riskLevel\": \"low\" | \"medium\" | \"high\" | \"critical\",\n \"categories\": [\"phishing\" | \"gambling\" | \"adult\" | \"usury\" | \"malware\" | ...],\n \"confidence\": 0.0 to 1.0,\n \"reasons\": [\"Reason 1\", \"Reason 2\", ...],\n \"recommendedAction\": \"Action statement\"\n}\n";
@@ -1,2 +1 @@
1
- export declare function redactSensitiveData(text: string): string;
2
- //# sourceMappingURL=redactSensitiveData.d.ts.map
1
+ export declare function redactSensitiveData(text: string): string;
@@ -1,3 +1,2 @@
1
1
  import { HalalCheckResult } from "../status.js";
2
- export declare function validateAiResponse(responseStr: string): HalalCheckResult;
3
- //# sourceMappingURL=validateAiResponse.d.ts.map
2
+ export declare function validateAiResponse(responseStr: string): HalalCheckResult;
@@ -1,2 +1 @@
1
- export declare function runHalalCheck(appRoot: string, outDir: string): Promise<boolean>;
2
- //# sourceMappingURL=check.d.ts.map
1
+ export declare function runHalalCheck(appRoot: string, outDir: string): Promise<boolean>;
@@ -1,2 +1 @@
1
- export declare function runHalalExplain(appRoot: string): Promise<void>;
2
- //# sourceMappingURL=explain.d.ts.map
1
+ export declare function runHalalExplain(appRoot: string): Promise<void>;
@@ -1,2 +1 @@
1
- export declare function runHalalReport(appRoot: string, outDir: string): Promise<string>;
2
- //# sourceMappingURL=report.d.ts.map
1
+ export declare function runHalalReport(appRoot: string, outDir: string): Promise<string>;
@@ -1,2 +1 @@
1
- export declare function runHalalSubmitReview(appRoot: string, outDir: string): Promise<string>;
2
- //# sourceMappingURL=submitReview.d.ts.map
1
+ export declare function runHalalSubmitReview(appRoot: string, outDir: string): Promise<string>;
@@ -1,2 +1 @@
1
- export declare function runHalalVerifyReview(appRoot: string): Promise<boolean>;
2
- //# sourceMappingURL=verifyReview.d.ts.map
1
+ export declare function runHalalVerifyReview(appRoot: string): Promise<boolean>;
@@ -16,6 +16,7 @@ export interface HalalAIConfig {
16
16
  enabled?: boolean;
17
17
  strict?: boolean;
18
18
  blockProductionBuild?: boolean;
19
+ requireAuthenticated?: boolean;
19
20
  scanRoutes?: boolean;
20
21
  scanMeta?: boolean;
21
22
  scanContent?: boolean;
@@ -38,5 +39,4 @@ export interface ResuxHalalPolicy {
38
39
  export declare function validatePolicyConfig(config: Record<string, any>): ResuxHalalPolicy;
39
40
  export declare function loadProjectDotEnv(appRoot: string): void;
40
41
  export declare function loadMainResuxConfig(appRoot: string): Promise<Record<string, any>>;
41
- export declare function loadProjectPolicy(appRoot: string): Promise<ResuxHalalPolicy>;
42
- //# sourceMappingURL=config.d.ts.map
42
+ export declare function loadProjectPolicy(appRoot: string): Promise<ResuxHalalPolicy>;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../../src/halal-core/config.ts"],"sourcesContent":["import { existsSync, readFileSync, unlinkSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport ts from \"typescript\";\n\nexport interface ReviewContact {\n name: string;\n email: string;\n}\n\nexport interface ReviewEvidence {\n type: string;\n path: string;\n description: string;\n}\n\nexport interface StricterRules {\n blockAiChatWithoutModeration?: boolean;\n blockUnmoderatedUserUploads?: boolean;\n [key: string]: boolean | undefined;\n}\n\nexport interface HalalAIConfig {\n enabled?: boolean;\n strict?: boolean;\n blockProductionBuild?: boolean;\n scanRoutes?: boolean;\n scanMeta?: boolean;\n scanContent?: boolean;\n scanExternalLinks?: boolean;\n scanRuntimeConfig?: boolean;\n scanDependencies?: boolean;\n categories?: Record<string, \"block\" | \"warn\" | \"review\" | \"allow\">;\n}\n\nexport interface ResuxHalalPolicy {\n projectName?: string;\n projectType?: string;\n description?: string;\n reviewContact?: ReviewContact;\n stricterRules?: StricterRules;\n additionalBlockedCategories?: string[];\n evidence?: ReviewEvidence[];\n internalTeamNotes?: string;\n halalAI?: HalalAIConfig;\n}\n\nconst FORBIDDEN_FIELDS = [\n \"enabled\",\n \"mode\",\n \"ignoreCoreRules\",\n \"allowBlockedCategories\",\n \"disableHarmDetection\",\n \"removeDefaultRules\",\n \"halalGuard\",\n];\n\nexport function validatePolicyConfig(config: Record<string, any>): ResuxHalalPolicy {\n if (!config) {\n return {};\n }\n\n for (const field of FORBIDDEN_FIELDS) {\n if (field in config) {\n throw new Error(\n `[resux-halal-core] Invalid configuration field \"${field}\". You are not permitted to disable, bypass, or weaken the core safety and halal guidelines of ResuxJS.`\n );\n }\n }\n\n if (config.halalAI) {\n if (config.halalAI.enabled === false) {\n throw new Error(\n `[resux-halal-core] Invalid configuration: \"halalAI.enabled\" cannot be set to false. You are not permitted to disable, bypass, or weaken the core safety and halal guidelines of ResuxJS.`\n );\n }\n }\n\n // Basic validation of types\n if (config.projectName && typeof config.projectName !== \"string\") {\n throw new Error(\"[resux-halal-core] 'projectName' must be a string.\");\n }\n if (config.projectType && typeof config.projectType !== \"string\") {\n throw new Error(\"[resux-halal-core] 'projectType' must be a string.\");\n }\n if (config.description && typeof config.description !== \"string\") {\n throw new Error(\"[resux-halal-core] 'description' must be a string.\");\n }\n\n return config as ResuxHalalPolicy;\n}\n\nfunction stripUnquotedComment(value: string): string {\n let inSingle = false;\n let inDouble = false;\n for (let i = 0; i < value.length; i++) {\n const ch = value[i];\n if (ch === \"'\" && !inDouble) {\n inSingle = !inSingle;\n } else if (ch === '\"' && !inSingle && value[i - 1] !== \"\\\\\") {\n inDouble = !inDouble;\n } else if (ch === \"#\" && !inSingle && !inDouble) {\n return value.slice(0, i).trim();\n }\n }\n return value.trim();\n}\n\nfunction stripWrappingQuotes(value: string): string {\n const clean = stripUnquotedComment(value);\n const isDoubleQuoted = clean.startsWith('\"') && clean.endsWith('\"');\n const isSingleQuoted = clean.startsWith(\"'\") && clean.endsWith(\"'\");\n const unquoted = isDoubleQuoted || isSingleQuoted ? clean.slice(1, -1) : clean;\n return isSingleQuoted ? unquoted : unquoted.replaceAll(String.raw`\\$`, \"$\");\n}\n\nfunction applyDotEnvLine(line: string): void {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) {\n return;\n }\n const equalIndex = trimmed.indexOf(\"=\");\n if (equalIndex === -1) {\n return;\n }\n const rawKey = trimmed.slice(0, equalIndex).trim();\n const key = rawKey.startsWith(\"export \") ? rawKey.slice(7).trim() : rawKey;\n if (!key || key.startsWith(\"VITE_\") || process.env[key] !== undefined) {\n return;\n }\n const rawValue = trimmed.slice(equalIndex + 1).trim();\n process.env[key] = stripWrappingQuotes(rawValue);\n}\n\nexport function loadProjectDotEnv(appRoot: string): void {\n const envFiles = [\".env.local\", \".env\"];\n for (const file of envFiles) {\n const fullPath = path.join(appRoot, file);\n if (!existsSync(fullPath)) {\n continue;\n }\n try {\n const content = readFileSync(fullPath, \"utf8\");\n for (const line of content.split(/\\r?\\n/)) {\n applyDotEnvLine(line);\n }\n } catch {\n // Ignore unreadable .env files\n }\n }\n}\n\nexport async function loadMainResuxConfig(appRoot: string): Promise<Record<string, any>> {\n const possiblePaths = [\n path.join(appRoot, \"resux.config.ts\"),\n path.join(appRoot, \"resux.config.js\"),\n path.join(appRoot, \"resux.config.mjs\"),\n ];\n\n for (const configPath of possiblePaths) {\n if (existsSync(configPath)) {\n try {\n let compiledSource: string;\n if (configPath.endsWith(\".ts\")) {\n const source = readFileSync(configPath, \"utf8\");\n const normalized = source.replace(/\\bdefineResuxConfig\\s*\\(/g, \"(\");\n compiledSource = ts.transpileModule(normalized, {\n compilerOptions: {\n target: ts.ScriptTarget.ES2022,\n module: ts.ModuleKind.ES2022\n }\n }).outputText;\n } else {\n compiledSource = readFileSync(configPath, \"utf8\");\n }\n\n const tempPath = path.join(appRoot, `.resux-temp-config-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`);\n writeFileSync(tempPath, compiledSource, \"utf8\");\n\n try {\n const fileUrl = pathToFileURL(tempPath).href;\n const module = await import(fileUrl);\n const config = module.default || module;\n return config;\n } finally {\n try {\n unlinkSync(tempPath);\n } catch {\n // Ignore cleanup errors for temporary config file\n }\n }\n } catch (err: any) {\n console.warn(`[resux-halal-core] Warning: failed to load resux.config.ts for Halal AI check: ${err.message}`);\n }\n }\n }\n return {};\n}\n\nexport async function loadProjectPolicy(appRoot: string): Promise<ResuxHalalPolicy> {\n loadProjectDotEnv(appRoot);\n const policy: ResuxHalalPolicy = {};\n\n try {\n const mainConfig = await loadMainResuxConfig(appRoot);\n if (mainConfig.halalAI) {\n policy.halalAI = mainConfig.halalAI;\n }\n if (mainConfig.projectType) {\n policy.projectType = mainConfig.projectType;\n }\n } catch (err: any) {\n if (err.message.includes(\"not permitted to disable\")) {\n throw err;\n }\n }\n\n const possiblePaths = [\n path.join(appRoot, \"resux.halal.config.ts\"),\n path.join(appRoot, \"resux.halal.config.js\"),\n path.join(appRoot, \"resux.halal.config.mjs\"),\n ];\n\n for (const configPath of possiblePaths) {\n if (existsSync(configPath)) {\n try {\n const fileUrl = pathToFileURL(configPath).href;\n const module = await import(fileUrl);\n const config = module.default || module;\n const validated = validatePolicyConfig(config);\n Object.assign(policy, validated);\n break;\n } catch (err: any) {\n throw new Error(`[resux-halal-core] Failed to load halal configuration at ${configPath}: ${err.message}`);\n }\n }\n }\n\n return validatePolicyConfig(policy);\n}\n"],"mappings":";;;;;AA+CA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,qBAAqB,QAA+C;CAClF,IAAI,CAAC,QACH,OAAO,CAAC;CAGV,KAAK,MAAM,SAAS,kBAClB,IAAI,SAAS,QACX,MAAM,IAAI,MAC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AC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK;EACjH,cAAc,UAAU,gBAAgB,MAAM;EAE9C,IAAI;GAEF,MAAM,SAAS,MAAM,OADL,cAAc,QAAQ,CAAC,CAAC;GAGxC,OADe,OAAO,WAAW;EAEnC,UAAU;GACR,IAAI;IACF,WAAW,QAAQ;GACrB,QAAQ,CAER;EACF;CACF,SAAS,KAAU;EACjB,QAAQ,KAAK,kFAAkF,IAAI,SAAS;CAC9G;CAGJ,OAAO,CAAC;AACV;AAEA,eAAsB,kBAAkB,SAA4C;CAClF,kBAAkB,OAAO;CACzB,MAAM,SAA2B,CAAC;CAElC,IAAI;EACF,MAAM,aAAa,MAAM,oBAAoB,OAAO;EACpD,IAAI,WAAW,SACb,OAAO,UAAU,WAAW;EAE9B,IAAI,WAAW,aACb,OAAO,cAAc,WAAW;CAEpC,SAAS,KAAU;EACjB,IAAI,IAAI,QAAQ,SAAS,0BAA0B,GACjD,MAAM;CAEV;CAEA,MAAM,gBAAgB;EACpB,KAAK,KAAK,SAAS,uBAAuB;EAC1C,KAAK,KAAK,SAAS,uBAAuB;EAC1C,KAAK,KAAK,SAAS,wBAAwB;CAC7C;CAEA,KAAK,MAAM,cAAc,eACvB,IAAI,WAAW,UAAU,GACvB,IAAI;EAEF,MAAM,SAAS,MAAM,OADL,cAAc,UAAU,CAAC,CAAC;EAG1C,MAAM,YAAY,qBADH,OAAO,WAAW,MACY;EAC7C,OAAO,OAAO,QAAQ,SAAS;EAC/B;CACF,SAAS,KAAU;EACjB,MAAM,IAAI,MAAM,4DAA4D,WAAW,IAAI,IAAI,SAAS;CAC1G;CAIJ,OAAO,qBAAqB,MAAM;AACpC"}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../../src/halal-core/config.ts"],"sourcesContent":["import { existsSync, readFileSync, unlinkSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport ts from \"typescript\";\n\nexport interface ReviewContact {\n name: string;\n email: string;\n}\n\nexport interface ReviewEvidence {\n type: string;\n path: string;\n description: string;\n}\n\nexport interface StricterRules {\n blockAiChatWithoutModeration?: boolean;\n blockUnmoderatedUserUploads?: boolean;\n [key: string]: boolean | undefined;\n}\n\nexport interface HalalAIConfig {\n enabled?: boolean;\n strict?: boolean;\n blockProductionBuild?: boolean;\n requireAuthenticated?: boolean;\n scanRoutes?: boolean;\n scanMeta?: boolean;\n scanContent?: boolean;\n scanExternalLinks?: boolean;\n scanRuntimeConfig?: boolean;\n scanDependencies?: boolean;\n categories?: Record<string, \"block\" | \"warn\" | \"review\" | \"allow\">;\n}\n\nexport interface ResuxHalalPolicy {\n projectName?: string;\n projectType?: string;\n description?: string;\n reviewContact?: ReviewContact;\n stricterRules?: StricterRules;\n additionalBlockedCategories?: string[];\n evidence?: ReviewEvidence[];\n internalTeamNotes?: string;\n halalAI?: HalalAIConfig;\n}\n\nconst FORBIDDEN_FIELDS = [\n \"enabled\",\n \"mode\",\n \"ignoreCoreRules\",\n \"allowBlockedCategories\",\n \"disableHarmDetection\",\n \"removeDefaultRules\",\n \"halalGuard\",\n];\n\nexport function validatePolicyConfig(config: Record<string, any>): ResuxHalalPolicy {\n if (!config) {\n return {};\n }\n\n for (const field of FORBIDDEN_FIELDS) {\n if (field in config) {\n throw new Error(\n `[resux-halal-core] Invalid configuration field \"${field}\". You are not permitted to disable, bypass, or weaken the core safety and halal guidelines of ResuxJS.`\n );\n }\n }\n\n if (config.halalAI) {\n if (config.halalAI.enabled === false) {\n throw new Error(\n `[resux-halal-core] Invalid configuration: \"halalAI.enabled\" cannot be set to false. You are not permitted to disable, bypass, or weaken the core safety and halal guidelines of ResuxJS.`\n );\n }\n }\n\n // Basic validation of types\n if (config.projectName && typeof config.projectName !== \"string\") {\n throw new Error(\"[resux-halal-core] 'projectName' must be a string.\");\n }\n if (config.projectType && typeof config.projectType !== \"string\") {\n throw new Error(\"[resux-halal-core] 'projectType' must be a string.\");\n }\n if (config.description && typeof config.description !== \"string\") {\n throw new Error(\"[resux-halal-core] 'description' must be a string.\");\n }\n\n return config as ResuxHalalPolicy;\n}\n\nfunction stripUnquotedComment(value: string): string {\n let inSingle = false;\n let inDouble = false;\n for (let i = 0; i < value.length; i++) {\n const ch = value[i];\n if (ch === \"'\" && !inDouble) {\n inSingle = !inSingle;\n } else if (ch === '\"' && !inSingle && value[i - 1] !== \"\\\\\") {\n inDouble = !inDouble;\n } else if (ch === \"#\" && !inSingle && !inDouble) {\n return value.slice(0, i).trim();\n }\n }\n return value.trim();\n}\n\nfunction stripWrappingQuotes(value: string): string {\n const clean = stripUnquotedComment(value);\n const isDoubleQuoted = clean.startsWith('\"') && clean.endsWith('\"');\n const isSingleQuoted = clean.startsWith(\"'\") && clean.endsWith(\"'\");\n const unquoted = isDoubleQuoted || isSingleQuoted ? clean.slice(1, -1) : clean;\n return isSingleQuoted ? unquoted : unquoted.replaceAll(String.raw`\\$`, \"$\");\n}\n\nfunction applyDotEnvLine(line: string): void {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) {\n return;\n }\n const equalIndex = trimmed.indexOf(\"=\");\n if (equalIndex === -1) {\n return;\n }\n const rawKey = trimmed.slice(0, equalIndex).trim();\n const key = rawKey.startsWith(\"export \") ? rawKey.slice(7).trim() : rawKey;\n if (!key || key.startsWith(\"VITE_\") || process.env[key] !== undefined) {\n return;\n }\n const rawValue = trimmed.slice(equalIndex + 1).trim();\n process.env[key] = stripWrappingQuotes(rawValue);\n}\n\nexport function loadProjectDotEnv(appRoot: string): void {\n const envFiles = [\".env.local\", \".env\"];\n for (const file of envFiles) {\n const fullPath = path.join(appRoot, file);\n if (!existsSync(fullPath)) {\n continue;\n }\n try {\n const content = readFileSync(fullPath, \"utf8\");\n for (const line of content.split(/\\r?\\n/)) {\n applyDotEnvLine(line);\n }\n } catch {\n // Ignore unreadable .env files\n }\n }\n}\n\nexport async function loadMainResuxConfig(appRoot: string): Promise<Record<string, any>> {\n const possiblePaths = [\n path.join(appRoot, \"resux.config.ts\"),\n path.join(appRoot, \"resux.config.js\"),\n path.join(appRoot, \"resux.config.mjs\"),\n ];\n\n for (const configPath of possiblePaths) {\n if (existsSync(configPath)) {\n try {\n let compiledSource: string;\n if (configPath.endsWith(\".ts\")) {\n const source = readFileSync(configPath, \"utf8\");\n const normalized = source.replace(/\\bdefineResuxConfig\\s*\\(/g, \"(\");\n compiledSource = ts.transpileModule(normalized, {\n compilerOptions: {\n target: ts.ScriptTarget.ES2022,\n module: ts.ModuleKind.ES2022\n }\n }).outputText;\n } else {\n compiledSource = readFileSync(configPath, \"utf8\");\n }\n\n const tempPath = path.join(appRoot, `.resux-temp-config-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`);\n writeFileSync(tempPath, compiledSource, \"utf8\");\n\n try {\n const fileUrl = pathToFileURL(tempPath).href;\n const module = await import(fileUrl);\n const config = module.default || module;\n return config;\n } finally {\n try {\n unlinkSync(tempPath);\n } catch {\n // Ignore cleanup errors for temporary config file\n }\n }\n } catch (err: any) {\n console.warn(`[resux-halal-core] Warning: failed to load resux.config.ts for Halal AI check: ${err.message}`);\n }\n }\n }\n return {};\n}\n\nexport async function loadProjectPolicy(appRoot: string): Promise<ResuxHalalPolicy> {\n loadProjectDotEnv(appRoot);\n const policy: ResuxHalalPolicy = {};\n\n try {\n const mainConfig = await loadMainResuxConfig(appRoot);\n if (mainConfig.halalAI) {\n policy.halalAI = mainConfig.halalAI;\n }\n if (mainConfig.projectType) {\n policy.projectType = mainConfig.projectType;\n }\n } catch (err: any) {\n if (err.message.includes(\"not permitted to disable\")) {\n throw err;\n }\n }\n\n const possiblePaths = [\n path.join(appRoot, \"resux.halal.config.ts\"),\n path.join(appRoot, \"resux.halal.config.js\"),\n path.join(appRoot, \"resux.halal.config.mjs\"),\n ];\n\n for (const configPath of possiblePaths) {\n if (existsSync(configPath)) {\n try {\n const fileUrl = pathToFileURL(configPath).href;\n const module = await import(fileUrl);\n const config = module.default || module;\n const validated = validatePolicyConfig(config);\n Object.assign(policy, validated);\n break;\n } catch (err: any) {\n throw new Error(`[resux-halal-core] Failed to load halal configuration at ${configPath}: ${err.message}`);\n }\n }\n }\n\n return validatePolicyConfig(policy);\n}\n"],"mappings":";;;;;AAgDA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,qBAAqB,QAA+C;CAClF,IAAI,CAAC,QACH,OAAO,CAAC;CAGV,KAAK,MAAM,SAAS,kBAClB,IAAI,SAAS,QACX,MAAM,IAAI,MACR,mDAAmD,MAAM,wGAC3D;CAIJ,IAAI,OAAO,SACL;MAAA,OAAO,QAAQ,YAAY,OAC7B,MAAM,IAAI,MACR,0LACF;CAAA;CAKJ,IAAI,OAAO,eAAe,OAAO,OAAO,gBAAgB,UACtD,MAAM,IAAI,MAAM,oDAAoD;CAEtE,IAAI,OAAO,eAAe,OAAO,OAAO,gBAAgB,UACtD,MAAM,IAAI,MAAM,oDAAoD;CAEtE,IAAI,OAAO,eAAe,OAAO,OAAO,gBAAgB,UACtD,MAAM,IAAI,MAAM,oDAAoD;CAGtE,OAAO;AACT;AAEA,SAAS,qBAAqB,OAAuB;CACnD,IAAI,WAAW;CACf,IAAI,WAAW;CACf,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,KAAK,MAAM;EACjB,IAAI,OAAO,OAAO,CAAC,UACjB,WAAW,CAAC;OACP,IAAI,OAAO,QAAO,CAAC,YAAY,MAAM,IAAI,OAAO,MACrD,WAAW,CAAC;OACP,IAAI,OAAO,OAAO,CAAC,YAAY,CAAC,UACrC,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK;CAElC;CACA,OAAO,MAAM,KAAK;AACpB;AAEA,SAAS,oBAAoB,OAAuB;CAClD,MAAM,QAAQ,qBAAqB,KAAK;CACxC,MAAM,iBAAiB,MAAM,WAAW,IAAG,KAAK,MAAM,SAAS,IAAG;CAClE,MAAM,iBAA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;EAC7C,OAAO,OAAO,QAAQ,SAAS;EAC/B;CACF,SAAS,KAAU;EACjB,MAAM,IAAI,MAAM,4DAA4D,WAAW,IAAI,IAAI,SAAS;CAC1G;CAIJ,OAAO,qBAAqB,MAAM;AACpC"}
@@ -6,5 +6,4 @@ export interface IntegrityOptions {
6
6
  export declare function createIntegritySignature(value: unknown, options: IntegrityOptions): string;
7
7
  export declare function verifyIntegritySignature(value: unknown, signature: unknown, options: IntegrityOptions): boolean;
8
8
  export declare function isAuthenticatedIntegritySignature(signature: unknown): boolean;
9
- export declare function stableSerialize(value: unknown): string;
10
- //# sourceMappingURL=integrity.d.ts.map
9
+ export declare function stableSerialize(value: unknown): string;
@@ -38,7 +38,7 @@ function stableSerialize(value) {
38
38
  function resolveIntegritySecret(options) {
39
39
  const secret = options.secret ?? process.env[options.envName];
40
40
  if (secret === void 0 || secret === "") {
41
- if (options.requireSecret === true) throw new Error(`${options.envName} must be configured with at least 32 characters before creating authenticated signatures.`);
41
+ if (options.requireSecret === true) throw new Error(`${options.envName} must be configured with at least 32 characters before creating authenticated signatures. Add it to your .env or environment variables. See https://resux.dev/getting-started for details.`);
42
42
  return;
43
43
  }
44
44
  if (secret.length < 32) throw new Error(`${options.envName} must contain at least 32 characters.`);
@@ -1 +1 @@
1
- {"version":3,"file":"integrity.js","names":[],"sources":["../../../src/halal-core/crypto/integrity.ts"],"sourcesContent":["import { createHash, createHmac, timingSafeEqual } from \"node:crypto\";\n\nexport interface IntegrityOptions {\n envName: string;\n secret?: string;\n requireSecret?: boolean;\n}\n\nexport function createIntegritySignature(value: unknown, options: IntegrityOptions): string {\n const payload = stableSerialize(value);\n const secret = resolveIntegritySecret(options);\n\n if (secret) {\n const digest = createHmac(\"sha256\", secret).update(payload).digest(\"hex\");\n return `hmac-sha256:${digest}`;\n }\n\n const digest = createHash(\"sha256\").update(payload).digest(\"hex\");\n return `sha256:${digest}`;\n}\n\nexport function verifyIntegritySignature(\n value: unknown,\n signature: unknown,\n options: IntegrityOptions,\n): boolean {\n if (typeof signature !== \"string\") {\n return false;\n }\n\n const separator = signature.indexOf(\":\");\n if (separator <= 0) {\n return false;\n }\n\n const algorithm = signature.slice(0, separator);\n if (algorithm !== \"hmac-sha256\" && algorithm !== \"sha256\") {\n return false;\n }\n if (options.requireSecret === true && algorithm !== \"hmac-sha256\") {\n return false;\n }\n\n let expected: string;\n try {\n if (algorithm === \"hmac-sha256\") {\n expected = createIntegritySignature(value, { ...options, requireSecret: true });\n } else {\n expected = createIntegritySignature(value, { ...options, secret: \"\", requireSecret: false });\n }\n } catch {\n return false;\n }\n\n return constantTimeEqual(expected, signature);\n}\n\nexport function isAuthenticatedIntegritySignature(signature: unknown): boolean {\n return typeof signature === \"string\" && signature.startsWith(\"hmac-sha256:\");\n}\n\nexport function stableSerialize(value: unknown): string {\n return JSON.stringify(normalizeJsonValue(value));\n}\n\nfunction resolveIntegritySecret(options: IntegrityOptions): string | undefined {\n const secret = options.secret ?? process.env[options.envName];\n if (secret === undefined || secret === \"\") {\n if (options.requireSecret === true) {\n throw new Error(\n `${options.envName} must be configured with at least 32 characters before creating authenticated signatures.`,\n );\n }\n return undefined;\n }\n\n if (secret.length < 32) {\n throw new Error(`${options.envName} must contain at least 32 characters.`);\n }\n return secret;\n}\n\nfunction normalizeJsonValue(value: unknown): unknown {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") {\n return value;\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n throw new TypeError(\"Integrity payloads cannot contain non-finite numbers.\");\n }\n return value;\n }\n if (Array.isArray(value)) {\n return value.map((entry) => entry === undefined ? null : normalizeJsonValue(entry));\n }\n if (typeof value === \"object\") {\n // A null-prototype object preserves special JSON keys such as \"__proto__\"\n // instead of invoking the legacy Object.prototype setter and dropping them\n // from the canonical payload.\n const output: Record<string, unknown> = Object.create(null) as Record<string, unknown>;\n const keys = Object.keys(value as Record<string, unknown>).sort(compareCanonicalKeys);\n for (const key of keys) {\n const entry = (value as Record<string, unknown>)[key];\n if (entry !== undefined) {\n output[key] = normalizeJsonValue(entry);\n }\n }\n return output;\n }\n throw new TypeError(`Integrity payloads must be JSON-serializable; received ${typeof value}.`);\n}\n\nfunction compareCanonicalKeys(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\nfunction constantTimeEqual(left: string, right: string): boolean {\n const leftBuffer = Buffer.from(left, \"utf8\");\n const rightBuffer = Buffer.from(right, \"utf8\");\n return leftBuffer.length === rightBuffer.length && timingSafeEqual(leftBuffer, rightBuffer);\n}\n"],"mappings":";;AAQA,SAAgB,yBAAyB,OAAgB,SAAmC;CAC1F,MAAM,UAAU,gBAAgB,KAAK;CACrC,MAAM,SAAS,uBAAuB,OAAO;CAE7C,IAAI,QAEF,OAAO,eADQ,WAAW,UAAU,MAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KACxC;CAI7B,OAAO,UADQ,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KACrC;AACxB;AAEA,SAAgB,yBACd,OACA,WACA,SACS;CACT,IAAI,OAAO,cAAc,UACvB,OAAO;CAGT,MAAM,YAAY,UAAU,QAAQ,GAAG;CACvC,IAAI,aAAa,GACf,OAAO;CAGT,MAAM,YAAY,UAAU,MAAM,GAAG,SAAS;CAC9C,IAAI,cAAc,iBAAiB,cAAc,UAC/C,OAAO;CAET,IAAI,QAAQ,kBAAkB,QAAQ,cAAc,eAClD,OAAO;CAGT,IAAI;CACJ,IAAI;EACF,IAAI,cAAc,eAChB,WAAW,yBAAyB,OAAO;GAAE,GAAG;GAAS,eAAe;EAAK,CAAC;OAE9E,WAAW,yBAAyB,OAAO;GAAE,GAAG;GAAS,QAAQ;GAAI,eAAe;EAAM,CAAC;CAE/F,QAAQ;EACN,OAAO;CACT;CAEA,OAAO,kBAAkB,UAAU,SAAS;AAC9C;AAEA,SAAgB,kCAAkC,WAA6B;CAC7E,OAAO,OAAO,cAAc,YAAY,UA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M,MAAM;CAC3C,MAAM,cAAc,OAAO,KAAK,OAAO,MAAM;CAC7C,OAAO,WAAW,WAAW,YAAY,UAAU,gBAAgB,YAAY,WAAW;AAC5F"}
1
+ {"version":3,"file":"integrity.js","names":[],"sources":["../../../src/halal-core/crypto/integrity.ts"],"sourcesContent":["import { createHash, createHmac, timingSafeEqual } from \"node:crypto\";\n\nexport interface IntegrityOptions {\n envName: string;\n secret?: string;\n requireSecret?: boolean;\n}\n\nexport function createIntegritySignature(value: unknown, options: IntegrityOptions): string {\n const payload = stableSerialize(value);\n const secret = resolveIntegritySecret(options);\n\n if (secret) {\n const digest = createHmac(\"sha256\", secret).update(payload).digest(\"hex\");\n return `hmac-sha256:${digest}`;\n }\n\n const digest = createHash(\"sha256\").update(payload).digest(\"hex\");\n return `sha256:${digest}`;\n}\n\nexport function verifyIntegritySignature(\n value: unknown,\n signature: unknown,\n options: IntegrityOptions,\n): boolean {\n if (typeof signature !== \"string\") {\n return false;\n }\n\n const separator = signature.indexOf(\":\");\n if (separator <= 0) {\n return false;\n }\n\n const algorithm = signature.slice(0, separator);\n if (algorithm !== \"hmac-sha256\" && algorithm !== \"sha256\") {\n return false;\n }\n if (options.requireSecret === true && algorithm !== \"hmac-sha256\") {\n return false;\n }\n\n let expected: string;\n try {\n if (algorithm === \"hmac-sha256\") {\n expected = createIntegritySignature(value, { ...options, requireSecret: true });\n } else {\n expected = createIntegritySignature(value, { ...options, secret: \"\", requireSecret: false });\n }\n } catch {\n return false;\n }\n\n return constantTimeEqual(expected, signature);\n}\n\nexport function isAuthenticatedIntegritySignature(signature: unknown): boolean {\n return typeof signature === \"string\" && signature.startsWith(\"hmac-sha256:\");\n}\n\nexport function stableSerialize(value: unknown): string {\n return JSON.stringify(normalizeJsonValue(value));\n}\n\nfunction resolveIntegritySecret(options: IntegrityOptions): string | undefined {\n const secret = options.secret ?? process.env[options.envName];\n if (secret === undefined || secret === \"\") {\n if (options.requireSecret === true) {\n throw new Error(\n `${options.envName} must be configured with at least 32 characters before creating authenticated signatures. Add it to your .env or environment variables. See https://resux.dev/getting-started for details.`,\n );\n }\n return undefined;\n }\n\n if (secret.length < 32) {\n throw new Error(`${options.envName} must contain at least 32 characters.`);\n }\n return secret;\n}\n\nfunction normalizeJsonValue(value: unknown): unknown {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") {\n return value;\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n throw new TypeError(\"Integrity payloads cannot contain non-finite numbers.\");\n }\n return value;\n }\n if (Array.isArray(value)) {\n return value.map((entry) => entry === undefined ? null : normalizeJsonValue(entry));\n }\n if (typeof value === \"object\") {\n // A null-prototype object preserves special JSON keys such as \"__proto__\"\n // instead of invoking the legacy Object.prototype setter and dropping them\n // from the canonical payload.\n const output: Record<string, unknown> = Object.create(null) as Record<string, unknown>;\n const keys = Object.keys(value as Record<string, unknown>).sort(compareCanonicalKeys);\n for (const key of keys) {\n const entry = (value as Record<string, unknown>)[key];\n if (entry !== undefined) {\n output[key] = normalizeJsonValue(entry);\n }\n }\n return output;\n }\n throw new TypeError(`Integrity payloads must be JSON-serializable; received ${typeof value}.`);\n}\n\nfunction compareCanonicalKeys(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\nfunction constantTimeEqual(left: string, right: string): boolean {\n const leftBuffer = Buffer.from(left, \"utf8\");\n const rightBuffer = Buffer.from(right, \"utf8\");\n return leftBuffer.length === rightBuffer.length && timingSafeEqual(leftBuffer, rightBuffer);\n}\n"],"mappings":";;AAQA,SAAgB,yBAAyB,OAAgB,SAAmC;CAC1F,MAAM,UAAU,gBAAgB,KAAK;CACrC,MAAM,SAAS,uBAAuB,OAAO;CAE7C,IAAI,QAEF,OAAO,eADQ,WAAW,UAAU,MAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KACxC;CAI7B,OAAO,UADQ,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KACrC;A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QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,UAAU,UAAU,KAAA,IAAY,OAAO,mBAAmB,KAAK,CAAC;CAEpF,IAAI,OAAO,UAAU,UAAU;EAI7B,MAAM,SAAkC,OAAO,OAAO,IAAI;EAC1D,MAAM,OAAO,OAAO,KAAK,KAAgC,CAAC,CAAC,KAAK,oBAAoB;EACpF,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,QAAS,MAAkC;GACjD,IAAI,UAAU,KAAA,GACZ,OAAO,OAAO,mBAAmB,KAAK;EAE1C;EACA,OAAO;CACT;CACA,MAAM,IAAI,UAAU,0DAA0D,OAAO,MAAM,EAAE;AAC/F;AAEA,SAAS,qBAAqB,MAAc,OAAuB;CACjE,IAAI,OAAO,OAAO,OAAO;CACzB,IAAI,OAAO,OAAO,OAAO;CACzB,OAAO;AACT;AAEA,SAAS,kBAAkB,MAAc,OAAwB;CAC/D,MAAM,aAAa,OAAO,KAAK,MAAM,MAAM;CAC3C,MAAM,cAAc,OAAO,KAAK,OAAO,MAAM;CAC7C,OAAO,WAAW,WAAW,YAAY,UAAU,gBAAgB,YAAY,WAAW;AAC5F"}
@@ -1,6 +1,7 @@
1
1
  export declare function enforceDevGuard(appRoot: string, outDir: string): Promise<void>;
2
- export declare function enforceBuildGuard(appRoot: string, outDir: string): Promise<void>;
2
+ export declare function enforceBuildGuard(appRoot: string, outDir: string, options?: {
3
+ ignoreTestEnv?: boolean;
4
+ }): Promise<void>;
3
5
  export declare function enforcePreviewGuard(outDir: string): void;
4
6
  export declare function enforceProductionServerGuard(outDir: string): void;
5
- export declare function enforceDeploymentGuard(outDir: string): void;
6
- //# sourceMappingURL=enforce.d.ts.map
7
+ export declare function enforceDeploymentGuard(outDir: string): void;
@@ -7,6 +7,7 @@ import { createReviewEvidenceHash } from "./review/signedReviewFile.js";
7
7
  import { verifyReviewApproval } from "./review/verifyReviewApproval.js";
8
8
  import { checkOnDiskReportSignature } from "./tamper/verifyReportSignature.js";
9
9
  import { verifyCoreIntegrity } from "./tamper/verifyCoreIntegrity.js";
10
+ import { randomBytes } from "node:crypto";
10
11
  // src/halal-core/enforce.ts
11
12
  async function enforceDevGuard(appRoot, outDir) {
12
13
  if (process.env.VITEST || process.env.NODE_ENV === "test") return;
@@ -40,15 +41,33 @@ async function enforceDevGuard(appRoot, outDir) {
40
41
  }
41
42
  }
42
43
  }
43
- async function enforceBuildGuard(appRoot, outDir) {
44
- if (process.env.VITEST || process.env.NODE_ENV === "test") return;
44
+ async function enforceBuildGuard(appRoot, outDir, options = {}) {
45
+ if ((process.env.VITEST || process.env.NODE_ENV === "test") && !options.ignoreTestEnv) return;
45
46
  if (!verifyCoreIntegrity(appRoot)) {
46
47
  console.error("[resux-halal-core] Framework integrity compromised.");
47
48
  process.exit(1);
48
49
  }
49
50
  const policy = await loadProjectPolicy(appRoot);
50
51
  const scanned = scanProject(appRoot);
51
- const report = generateHalalReport(scanned, policy, outDir, { requireAuthenticated: true });
52
+ const requireAuthenticated = policy.halalAI?.requireAuthenticated === true || process.env.RESUX_HALAL_REPORT_REQUIRE_AUTHENTICATED === "true";
53
+ let signingSecret = process.env.RESUX_HALAL_REPORT_SIGNING_SECRET;
54
+ let requireAuth = requireAuthenticated || Boolean(signingSecret);
55
+ if (!signingSecret) {
56
+ if (requireAuthenticated) {
57
+ console.error("[resux-halal-core] Build failed: RESUX_HALAL_REPORT_SIGNING_SECRET must be configured with at least 32 characters when Halal report authentication is enabled (policy.halalAI.requireAuthenticated = true). Configure it in your .env or environment variables. See https://resux.dev/getting-started for details.");
58
+ process.exit(1);
59
+ } else {
60
+ const ephemeralSecret = randomBytes(32).toString("hex");
61
+ signingSecret = ephemeralSecret;
62
+ process.env.RESUX_HALAL_REPORT_SIGNING_SECRET = ephemeralSecret;
63
+ console.warn("\x1B[33m[resux-halal-core] Warning: RESUX_HALAL_REPORT_SIGNING_SECRET is not configured. Generated an ephemeral signing secret for this build. For production deployments requiring authenticated Halal reports, configure RESUX_HALAL_REPORT_SIGNING_SECRET (at least 32 characters) in your environment or .env file.\x1B[0m");
64
+ requireAuth = true;
65
+ }
66
+ }
67
+ const report = generateHalalReport(scanned, policy, outDir, {
68
+ requireAuthenticated: requireAuth,
69
+ signingSecret
70
+ });
52
71
  const blockProductionBuild = policy.halalAI?.blockProductionBuild !== false;
53
72
  const isStrict = policy.halalAI?.strict === true;
54
73
  if (report.status === "review_required") {
@@ -86,8 +105,16 @@ function enforcePreviewGuard(outDir) {
86
105
  }
87
106
  function enforceProductionServerGuard(outDir) {
88
107
  if (process.env.VITEST || process.env.NODE_ENV === "test") return;
89
- const check = checkOnDiskReportSignature(outDir, { requireAuthenticated: true });
108
+ const requireAuthenticated = process.env.RESUX_HALAL_REPORT_REQUIRE_AUTHENTICATED === "true" || Boolean(process.env.RESUX_HALAL_REPORT_SIGNING_SECRET);
109
+ const check = checkOnDiskReportSignature(outDir, {
110
+ requireAuthenticated,
111
+ secret: process.env.RESUX_HALAL_REPORT_SIGNING_SECRET
112
+ });
90
113
  if (!check.valid) {
114
+ if (!requireAuthenticated) {
115
+ console.warn("\x1B[33m[resux-halal-core] Warning: Starting server without authenticated Halal report signature.\x1B[0m");
116
+ return;
117
+ }
91
118
  console.error(`\x1b[31m[resux-halal-core] Production server startup rejected: ${check.reason}\x1b[0m`);
92
119
  process.exit(1);
93
120
  }