@askrjs/askr 0.0.35 → 0.0.36

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 (146) hide show
  1. package/dist/bench/components/benchmark-row.js.map +1 -1
  2. package/dist/bench/components/benchmark-table.js.map +1 -1
  3. package/dist/benchmark.js +2 -2
  4. package/dist/benchmark.js.map +1 -1
  5. package/dist/bin/askr-ssg.js.map +1 -1
  6. package/dist/boot/index.d.ts.map +1 -1
  7. package/dist/boot/index.js +9 -29
  8. package/dist/boot/index.js.map +1 -1
  9. package/dist/common/control.js.map +1 -1
  10. package/dist/common/env.js.map +1 -1
  11. package/dist/common/ssr-errors.js.map +1 -1
  12. package/dist/common/vnode.js.map +1 -1
  13. package/dist/components/error-boundary.js.map +1 -1
  14. package/dist/components/link.js.map +1 -1
  15. package/dist/control/case.js.map +1 -1
  16. package/dist/control/for.js.map +1 -1
  17. package/dist/control/shared.js.map +1 -1
  18. package/dist/control/show.js.map +1 -1
  19. package/dist/data/index.d.ts.map +1 -1
  20. package/dist/data/index.js +165 -23
  21. package/dist/data/index.js.map +1 -1
  22. package/dist/dev/invariant.js.map +1 -1
  23. package/dist/dev/logger.js.map +1 -1
  24. package/dist/foundations/icon/icon.js.map +1 -1
  25. package/dist/foundations/interactions/dismissable.js.map +1 -1
  26. package/dist/foundations/interactions/focusable.js.map +1 -1
  27. package/dist/foundations/interactions/hoverable.js.map +1 -1
  28. package/dist/foundations/interactions/interaction-policy.js.map +1 -1
  29. package/dist/foundations/interactions/pressable.js.map +1 -1
  30. package/dist/foundations/interactions/roving-focus.js.map +1 -1
  31. package/dist/foundations/state/controllable.js.map +1 -1
  32. package/dist/foundations/structures/collection.js.map +1 -1
  33. package/dist/foundations/structures/layer.js.map +1 -1
  34. package/dist/foundations/structures/layout.js.map +1 -1
  35. package/dist/foundations/structures/portal.js.map +1 -1
  36. package/dist/foundations/structures/presence.js.map +1 -1
  37. package/dist/foundations/structures/slot.js.map +1 -1
  38. package/dist/foundations/utilities/aria.js.map +1 -1
  39. package/dist/foundations/utilities/compose-handlers.js.map +1 -1
  40. package/dist/foundations/utilities/compose-ref.js.map +1 -1
  41. package/dist/foundations/utilities/merge-props.js.map +1 -1
  42. package/dist/foundations/utilities/use-id.js.map +1 -1
  43. package/dist/fx/fx.js.map +1 -1
  44. package/dist/fx/timing.js.map +1 -1
  45. package/dist/index.d.ts +2 -2
  46. package/dist/index.js +2 -2
  47. package/dist/index.js.map +1 -1
  48. package/dist/jsx/utils.js.map +1 -1
  49. package/dist/jsx-dev-runtime.js.map +1 -1
  50. package/dist/jsx-runtime.js.map +1 -1
  51. package/dist/renderer/children.js.map +1 -1
  52. package/dist/renderer/cleanup.js.map +1 -1
  53. package/dist/renderer/dom.js +128 -53
  54. package/dist/renderer/dom.js.map +1 -1
  55. package/dist/renderer/evaluate.js +7 -0
  56. package/dist/renderer/evaluate.js.map +1 -1
  57. package/dist/renderer/fastpath.js.map +1 -1
  58. package/dist/renderer/index.js.map +1 -1
  59. package/dist/renderer/keyed.js +1 -1
  60. package/dist/renderer/keyed.js.map +1 -1
  61. package/dist/renderer/reconcile.js.map +1 -1
  62. package/dist/renderer/utils.js.map +1 -1
  63. package/dist/router/index.d.ts +2 -2
  64. package/dist/router/index.js +2 -2
  65. package/dist/router/match.js.map +1 -1
  66. package/dist/router/navigate.d.ts.map +1 -1
  67. package/dist/router/navigate.js +4 -2
  68. package/dist/router/navigate.js.map +1 -1
  69. package/dist/router/policy.js.map +1 -1
  70. package/dist/router/route-context.js.map +1 -1
  71. package/dist/router/route.d.ts +1 -1
  72. package/dist/router/route.d.ts.map +1 -1
  73. package/dist/router/route.js +3 -34
  74. package/dist/router/route.js.map +1 -1
  75. package/dist/runtime/child-scope.d.ts +1 -0
  76. package/dist/runtime/child-scope.d.ts.map +1 -1
  77. package/dist/runtime/child-scope.js +2 -0
  78. package/dist/runtime/child-scope.js.map +1 -1
  79. package/dist/runtime/component.js +1 -1
  80. package/dist/runtime/component.js.map +1 -1
  81. package/dist/runtime/context.js.map +1 -1
  82. package/dist/runtime/control.js.map +1 -1
  83. package/dist/runtime/derive.d.ts +2 -1
  84. package/dist/runtime/derive.d.ts.map +1 -1
  85. package/dist/runtime/derive.js +15 -10
  86. package/dist/runtime/derive.js.map +1 -1
  87. package/dist/runtime/dev-namespace.js.map +1 -1
  88. package/dist/runtime/effect.d.ts.map +1 -1
  89. package/dist/runtime/effect.js +34 -9
  90. package/dist/runtime/effect.js.map +1 -1
  91. package/dist/runtime/events.js.map +1 -1
  92. package/dist/runtime/execution-model.js.map +1 -1
  93. package/dist/runtime/fastlane.js.map +1 -1
  94. package/dist/runtime/for-bench.d.ts +1 -1
  95. package/dist/runtime/for-bench.d.ts.map +1 -1
  96. package/dist/runtime/for-bench.js +15 -14
  97. package/dist/runtime/for-bench.js.map +1 -1
  98. package/dist/runtime/for.d.ts +1 -0
  99. package/dist/runtime/for.d.ts.map +1 -1
  100. package/dist/runtime/for.js +63 -16
  101. package/dist/runtime/for.js.map +1 -1
  102. package/dist/runtime/operations.d.ts.map +1 -1
  103. package/dist/runtime/operations.js +9 -7
  104. package/dist/runtime/operations.js.map +1 -1
  105. package/dist/runtime/perf-metrics.js +8 -2
  106. package/dist/runtime/perf-metrics.js.map +1 -1
  107. package/dist/runtime/readable.js.map +1 -1
  108. package/dist/runtime/resource-cell.js +3 -2
  109. package/dist/runtime/resource-cell.js.map +1 -1
  110. package/dist/runtime/scheduler.d.ts +0 -1
  111. package/dist/runtime/scheduler.d.ts.map +1 -1
  112. package/dist/runtime/scheduler.js +6 -19
  113. package/dist/runtime/scheduler.js.map +1 -1
  114. package/dist/runtime/selector.d.ts.map +1 -1
  115. package/dist/runtime/selector.js +6 -4
  116. package/dist/runtime/selector.js.map +1 -1
  117. package/dist/runtime/snapshot-source.d.ts +10 -0
  118. package/dist/runtime/snapshot-source.d.ts.map +1 -0
  119. package/dist/runtime/snapshot-source.js +17 -0
  120. package/dist/runtime/snapshot-source.js.map +1 -0
  121. package/dist/runtime/ssr-bridge.js.map +1 -1
  122. package/dist/runtime/state.d.ts.map +1 -1
  123. package/dist/runtime/state.js +1 -5
  124. package/dist/runtime/state.js.map +1 -1
  125. package/dist/ssg/batch-render.js.map +1 -1
  126. package/dist/ssg/create-static-gen.js.map +1 -1
  127. package/dist/ssg/generate-metadata.js.map +1 -1
  128. package/dist/ssg/incremental-manifest.js.map +1 -1
  129. package/dist/ssg/resolve-ssg-data.js.map +1 -1
  130. package/dist/ssg/route-utils.js.map +1 -1
  131. package/dist/ssg/write-static-files.js.map +1 -1
  132. package/dist/ssr/attrs.js.map +1 -1
  133. package/dist/ssr/context.d.ts +1 -0
  134. package/dist/ssr/context.d.ts.map +1 -1
  135. package/dist/ssr/context.js +3 -0
  136. package/dist/ssr/context.js.map +1 -1
  137. package/dist/ssr/escape.js +56 -16
  138. package/dist/ssr/escape.js.map +1 -1
  139. package/dist/ssr/index.d.ts.map +1 -1
  140. package/dist/ssr/index.js +15 -3
  141. package/dist/ssr/index.js.map +1 -1
  142. package/dist/ssr/render-keys.js.map +1 -1
  143. package/dist/ssr/sink.js.map +1 -1
  144. package/dist/ssr/stream-render.js +14 -2
  145. package/dist/ssr/stream-render.js.map +1 -1
  146. package/package.json +8 -6
@@ -1 +1 @@
1
- {"version":3,"file":"route-utils.js","names":[],"sources":["../../src/ssg/route-utils.ts"],"sourcesContent":["import type { RouteConfig } from './types';\n\nexport interface ResolvedRouteDescriptor {\n route: RouteConfig;\n path: string;\n filePath: string;\n routeId: string;\n invalidationKeys: string[];\n}\n\nexport function getOutputFilePath(pathStr: string): string {\n if (pathStr === '/') {\n return 'index.html';\n }\n const normalized = pathStr.replace(/^\\/|\\/$/g, '');\n return `${normalized}/index.html`;\n}\n\nexport function interpolateRoutePath(\n routePath: string,\n params?: Record<string, string>\n): string {\n if (!params) return routePath;\n return routePath.replace(\n /\\{([^}]+)\\}/g,\n (_, key: string) => params[key] ?? ''\n );\n}\n\nexport function resolveRouteDescriptor(\n route: RouteConfig\n): ResolvedRouteDescriptor {\n const path = interpolateRoutePath(route.path, route.params);\n const filePath = getOutputFilePath(path);\n return {\n route,\n path,\n filePath,\n routeId: `${path}::${filePath}`,\n invalidationKeys: route.invalidationKeys?.slice() ?? [],\n };\n}\n"],"mappings":";AAUA,SAAgB,kBAAkB,SAAyB;AACzD,KAAI,YAAY,IACd,QAAO;AAGT,QAAO,GADY,QAAQ,QAAQ,YAAY,GACrC,CAAW;;AAGvB,SAAgB,qBACd,WACA,QACQ;AACR,KAAI,CAAC,OAAQ,QAAO;AACpB,QAAO,UAAU,QACf,iBACC,GAAG,QAAgB,OAAO,QAAQ,GACpC;;AAGH,SAAgB,uBACd,OACyB;CACzB,MAAM,OAAO,qBAAqB,MAAM,MAAM,MAAM,OAAO;CAC3D,MAAM,WAAW,kBAAkB,KAAK;AACxC,QAAO;EACL;EACA;EACA;EACA,SAAS,GAAG,KAAK,IAAI;EACrB,kBAAkB,MAAM,kBAAkB,OAAO,IAAI,EAAE;EACxD"}
1
+ {"version":3,"file":"route-utils.js","names":[],"sources":["../../src/ssg/route-utils.ts"],"sourcesContent":["import type { RouteConfig } from './types';\n\nexport interface ResolvedRouteDescriptor {\n route: RouteConfig;\n path: string;\n filePath: string;\n routeId: string;\n invalidationKeys: string[];\n}\n\nexport function getOutputFilePath(pathStr: string): string {\n if (pathStr === '/') {\n return 'index.html';\n }\n const normalized = pathStr.replace(/^\\/|\\/$/g, '');\n return `${normalized}/index.html`;\n}\n\nexport function interpolateRoutePath(\n routePath: string,\n params?: Record<string, string>\n): string {\n if (!params) return routePath;\n return routePath.replace(\n /\\{([^}]+)\\}/g,\n (_, key: string) => params[key] ?? ''\n );\n}\n\nexport function resolveRouteDescriptor(\n route: RouteConfig\n): ResolvedRouteDescriptor {\n const path = interpolateRoutePath(route.path, route.params);\n const filePath = getOutputFilePath(path);\n return {\n route,\n path,\n filePath,\n routeId: `${path}::${filePath}`,\n invalidationKeys: route.invalidationKeys?.slice() ?? [],\n };\n}\n"],"mappings":";AAUA,SAAgB,kBAAkB,SAAyB;CACzD,IAAI,YAAY,KACd,OAAO;CAGT,OAAO,GADY,QAAQ,QAAQ,YAAY,GACrC,CAAW;;AAGvB,SAAgB,qBACd,WACA,QACQ;CACR,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,UAAU,QACf,iBACC,GAAG,QAAgB,OAAO,QAAQ,GACpC;;AAGH,SAAgB,uBACd,OACyB;CACzB,MAAM,OAAO,qBAAqB,MAAM,MAAM,MAAM,OAAO;CAC3D,MAAM,WAAW,kBAAkB,KAAK;CACxC,OAAO;EACL;EACA;EACA;EACA,SAAS,GAAG,KAAK,IAAI;EACrB,kBAAkB,MAAM,kBAAkB,OAAO,IAAI,EAAE;EACxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"write-static-files.js","names":[],"sources":["../../src/ssg/write-static-files.ts"],"sourcesContent":["/**\n * File I/O for Static Site Generation\n *\n * Uses Node.js fs/path modules to write rendered HTML files to disk.\n * This module is Node-only and not intended for browser builds.\n */\n\nimport * as fs from 'node:fs/promises';\nimport * as fsSync from 'node:fs';\nimport * as pathModule from 'node:path';\nimport type { RouteRenderResult } from './types';\n\ninterface WriteStaticFilesOptions {\n concurrency?: number;\n}\n\n/**\n * Write rendered routes to disk\n * Creates outputDir/{route-path}/index.html structure\n */\nexport async function writeStaticFiles(\n results: RouteRenderResult[],\n outputDir: string,\n options: WriteStaticFilesOptions = {}\n): Promise<void> {\n await fs.mkdir(outputDir, { recursive: true });\n\n for (const result of results) {\n if (result.status !== 'removed') {\n continue;\n }\n\n const fullPath = pathModule.join(outputDir, result.filePath);\n if (fsSync.existsSync(fullPath)) {\n await fs.rm(fullPath, { force: true });\n await pruneEmptyDirs(pathModule.dirname(fullPath), outputDir);\n }\n }\n\n const pendingWrites: RouteRenderResult[] = [];\n for (let index = 0; index < results.length; index += 1) {\n const result = results[index];\n if (result.status === 'error') {\n console.warn(`Skipping failed route: ${result.path} - ${result.error}`);\n continue;\n }\n if (result.status === 'success' && result.written) {\n pendingWrites.push(result);\n }\n }\n\n const directories: string[] = [];\n const seenDirectories = new Set<string>();\n for (const result of pendingWrites) {\n const dir = pathModule.dirname(pathModule.join(outputDir, result.filePath));\n if (!seenDirectories.has(dir)) {\n seenDirectories.add(dir);\n directories.push(dir);\n }\n }\n\n for (const dir of directories) {\n await fs.mkdir(dir, { recursive: true });\n }\n\n const concurrency = Math.max(\n 1,\n Math.min(options.concurrency ?? 8, pendingWrites.length || 1)\n );\n let nextIndex = 0;\n\n const worker = async () => {\n while (true) {\n const current = nextIndex;\n nextIndex += 1;\n if (current >= pendingWrites.length) {\n return;\n }\n\n const result = pendingWrites[current];\n const fullPath = pathModule.join(outputDir, result.filePath);\n await fs.writeFile(fullPath, result.html, 'utf8');\n }\n };\n\n await Promise.all(Array.from({ length: concurrency }, () => worker()));\n}\n\n/**\n * Get the output file path for a route\n * E.g., \"/blog/post\" -> \"blog/post\" or \"/\" -> \"\"\n */\nexport { getOutputFilePath } from './route-utils';\n\nasync function pruneEmptyDirs(\n startDir: string,\n rootDir: string\n): Promise<void> {\n let current = startDir;\n const normalizedRoot = pathModule.resolve(rootDir);\n\n while (current.startsWith(normalizedRoot)) {\n if (!fsSync.existsSync(current)) {\n break;\n }\n\n if ((await fs.readdir(current)).length > 0) {\n break;\n }\n\n await fs.rmdir(current);\n if (pathModule.resolve(current) === normalizedRoot) {\n break;\n }\n current = pathModule.dirname(current);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,eAAsB,iBACpB,SACA,WACA,UAAmC,EAAE,EACtB;AACf,OAAM,GAAG,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;AAE9C,MAAK,MAAM,UAAU,SAAS;AAC5B,MAAI,OAAO,WAAW,UACpB;EAGF,MAAM,WAAW,WAAW,KAAK,WAAW,OAAO,SAAS;AAC5D,MAAI,OAAO,WAAW,SAAS,EAAE;AAC/B,SAAM,GAAG,GAAG,UAAU,EAAE,OAAO,MAAM,CA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AAO,WAAW,QAAQ,CAC7B;AAGF,OAAK,MAAM,GAAG,QAAQ,QAAQ,EAAE,SAAS,EACvC;AAGF,QAAM,GAAG,MAAM,QAAQ;AACvB,MAAI,WAAW,QAAQ,QAAQ,KAAK,eAClC;AAEF,YAAU,WAAW,QAAQ,QAAQ"}
1
+ {"version":3,"file":"write-static-files.js","names":[],"sources":["../../src/ssg/write-static-files.ts"],"sourcesContent":["/**\n * File I/O for Static Site Generation\n *\n * Uses Node.js fs/path modules to write rendered HTML files to disk.\n * This module is Node-only and not intended for browser builds.\n */\n\nimport * as fs from 'node:fs/promises';\nimport * as fsSync from 'node:fs';\nimport * as pathModule from 'node:path';\nimport type { RouteRenderResult } from './types';\n\ninterface WriteStaticFilesOptions {\n concurrency?: number;\n}\n\n/**\n * Write rendered routes to disk\n * Creates outputDir/{route-path}/index.html structure\n */\nexport async function writeStaticFiles(\n results: RouteRenderResult[],\n outputDir: string,\n options: WriteStaticFilesOptions = {}\n): Promise<void> {\n await fs.mkdir(outputDir, { recursive: true });\n\n for (const result of results) {\n if (result.status !== 'removed') {\n continue;\n }\n\n const fullPath = pathModule.join(outputDir, result.filePath);\n if (fsSync.existsSync(fullPath)) {\n await fs.rm(fullPath, { force: true });\n await pruneEmptyDirs(pathModule.dirname(fullPath), outputDir);\n }\n }\n\n const pendingWrites: RouteRenderResult[] = [];\n for (let index = 0; index < results.length; index += 1) {\n const result = results[index];\n if (result.status === 'error') {\n console.warn(`Skipping failed route: ${result.path} - ${result.error}`);\n continue;\n }\n if (result.status === 'success' && result.written) {\n pendingWrites.push(result);\n }\n }\n\n const directories: string[] = [];\n const seenDirectories = new Set<string>();\n for (const result of pendingWrites) {\n const dir = pathModule.dirname(pathModule.join(outputDir, result.filePath));\n if (!seenDirectories.has(dir)) {\n seenDirectories.add(dir);\n directories.push(dir);\n }\n }\n\n for (const dir of directories) {\n await fs.mkdir(dir, { recursive: true });\n }\n\n const concurrency = Math.max(\n 1,\n Math.min(options.concurrency ?? 8, pendingWrites.length || 1)\n );\n let nextIndex = 0;\n\n const worker = async () => {\n while (true) {\n const current = nextIndex;\n nextIndex += 1;\n if (current >= pendingWrites.length) {\n return;\n }\n\n const result = pendingWrites[current];\n const fullPath = pathModule.join(outputDir, result.filePath);\n await fs.writeFile(fullPath, result.html, 'utf8');\n }\n };\n\n await Promise.all(Array.from({ length: concurrency }, () => worker()));\n}\n\n/**\n * Get the output file path for a route\n * E.g., \"/blog/post\" -> \"blog/post\" or \"/\" -> \"\"\n */\nexport { getOutputFilePath } from './route-utils';\n\nasync function pruneEmptyDirs(\n startDir: string,\n rootDir: string\n): Promise<void> {\n let current = startDir;\n const normalizedRoot = pathModule.resolve(rootDir);\n\n while (current.startsWith(normalizedRoot)) {\n if (!fsSync.existsSync(current)) {\n break;\n }\n\n if ((await fs.readdir(current)).length > 0) {\n break;\n }\n\n await fs.rmdir(current);\n if (pathModule.resolve(current) === normalizedRoot) {\n break;\n }\n current = pathModule.dirname(current);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,eAAsB,iBACpB,SACA,WACA,UAAmC,EAAE,EACtB;CACf,MAAM,GAAG,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;CAE9C,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,OAAO,WAAW,WACpB;EAGF,MAAM,WAAW,WAAW,KAAK,WAAW,OAAO,SAAS;EAC5D,IAAI,OAAO,WAAW,SAAS,EAAE;GAC/B,MAAM,GAAG,GAAG,UAAU,EAAE,OAAO,MAAM,CAAC;GACtC,MAAM,eAAe,WAAW,QAAQ,SAAS,EAAE,UAAU;;;CAIjE,MAAM,gBAAqC,EAAE;CAC7C,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS,GAAG;EACtD,MAAM,SAAS,QAAQ;EACvB,IAAI,OAAO,WAAW,SAAS;GAC7B,QAAQ,KAAK,0BAA0B,OAAO,KAAK,KAAK,OAAO,QAAQ;GACvE;;EAEF,IAAI,OAAO,W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R\n */\n\nimport type { Props } from '../common/props';\nimport type { RenderSink } from './sink';\nimport { escapeAttr, needsEscapeAttr, styleObjToCss } from './escape';\n\n/** Result of renderAttrs including any raw HTML from dangerouslySetInnerHTML */\nexport type AttrsResult = {\n attrs: string;\n dangerousHtml?: string;\n};\n\nconst ESCAPED_ATTR_VALUE_CACHE_LIMIT = 512;\nconst escapedAttrValueCache = new Map<string, string>();\n\n// Fast check for event handler pattern (on + uppercase letter)\nfunction isEventHandler(key: string): boolean {\n return (\n key.length >= 3 &&\n key.charCodeAt(0) === 111 && // 'o'\n key.charCodeAt(1) === 110 && // 'n'\n key.charCodeAt(2) >= 65 &&\n key.charCodeAt(2) <= 90 // 'A'-'Z'\n );\n}\n\nfunction getEscapedAttrValue(value: string): string {\n if (value.length > 64) {\n return escapeAttr(value);\n }\n\n const cached = escapedAttrValueCache.get(value);\n if (cached !== undefined) {\n return cached;\n }\n\n const escaped = escapeAttr(value);\n // Skip caching strings that required no escaping — same reference returned,\n // no point occupying cache slots with identity entries.\n if (escaped === value) return value;\n if (escapedAttrValueCache.size >= ESCAPED_ATTR_VALUE_CACHE_LIMIT) {\n escapedAttrValueCache.clear();\n }\n escapedAttrValueCache.set(value, escaped);\n return escaped;\n}\n\n/**\n * Render attributes directly to a sink without intermediate string allocations.\n * This is the hot path for streaming SSR.\n */\nexport function renderAttrsDirect(\n props: Props | undefined,\n sink: Pick<RenderSink, 'write'>\n): void {\n if (!props || typeof props !== 'object') return;\n\n const propsObj = props as Record<string, unknown>;\n for (const key in propsObj) {\n const value = propsObj[key];\n\n // Skip special props\n if (\n key === 'children' ||\n key === 'key' ||\n key === 'ref' ||\n key === 'dangerouslySetInnerHTML'\n )\n continue;\n\n // Skip event handlers\n if (isEventHandler(key)) continue;\n\n // Skip internal props\n if (key.charCodeAt(0) === 95) continue; // '_'\n\n // Normalize class attribute\n const attrName = key === 'className' ? 'class' : key;\n\n // Handle style objects\n if (attrName === 'style') {\n const css = typeof value === 'string' ? value : styleObjToCss(value);\n if (!css) continue;\n sink.write(' style=\"');\n // Escape inline - most style values don't need escaping\n if (needsEscapeAttr(css)) {\n sink.write(getEscapedAttrValue(css));\n } else {\n sink.write(css);\n }\n sink.write('\"');\n continue;\n }\n\n // Boolean attributes\n if (value === true) {\n sink.write(' ');\n sink.write(attrName);\n continue;\n }\n\n if (value === false || value === null || value === undefined) continue;\n\n // Regular attributes\n const strValue = String(value);\n sink.write(' ');\n sink.write(attrName);\n sink.write('=\"');\n // escapeAttr returns the original string when nothing needs escaping,\n // so no separate needsEscapeAttr pre-scan is required.\n sink.write(getEscapedAttrValue(strValue));\n sink.write('\"');\n }\n}\n\n/**\n * Render attributes to HTML string, excluding event handlers\n * Optimized for minimal allocations using push-based approach\n *\n * Returns both the attribute string and any dangerouslySetInnerHTML content.\n */\nexport function renderAttrs(props?: Props): string;\nexport function renderAttrs(\n props: Props | undefined,\n opts: { returnDangerousHtml: true }\n): AttrsResult;\nexport function renderAttrs(\n props?: Props,\n opts?: { returnDangerousHtml?: boolean }\n): string | AttrsResult {\n if (!props || typeof props !== 'object') {\n return opts?.returnDangerousHtml ? { attrs: '' } : '';\n }\n\n const attrParts: string[] = [];\n let dangerousHtml: string | undefined;\n\n const propsObj = props as Record<string, unknown>;\n for (const key in propsObj) {\n const value = propsObj[key];\n\n // Skip children in attrs\n if (key === 'children') continue;\n\n // Skip internal identity refs (framework-only)\n if (key === 'key' || key === 'ref') continue;\n\n // Handle dangerouslySetInnerHTML\n if (key === 'dangerouslySetInnerHTML') {\n if (value && typeof value === 'object' && '__html' in (value as object)) {\n dangerousHtml = String((value as { __html: unknown }).__html);\n }\n continue;\n }\n\n // Skip event handlers\n if (isEventHandler(key)) continue;\n\n // Skip internal props\n if (key.charCodeAt(0) === 95) continue; // '_'\n\n // Normalize class attribute (`class` preferred, accept `className` for compatibility)\n const attrName = key === 'class' || key === 'className' ? 'class' : key;\n\n // Handle style objects\n if (attrName === 'style') {\n const css = typeof value === 'string' ? value : styleObjToCss(value);\n if (css === null || css === '') continue;\n attrParts.push(` style=\"${getEscapedAttrValue(css)}\"`);\n continue;\n }\n\n // Boolean attributes\n if (value === true) {\n attrParts.push(` ${attrName}`);\n } else if (value === false || value === null || value === undefined) {\n continue;\n } else {\n const strValue = String(value);\n attrParts.push(` ${attrName}=\"${getEscapedAttrValue(strValue)}\"`);\n }\n }\n\n const result = attrParts.join('');\n\n if (opts?.returnDangerousHtml) {\n return { attrs: result, dangerousHtml };\n }\n return result;\n}\n"],"mappings":";;AAcA,MAAM,iCAAiC;AACvC,MAAM,wCAAwB,IAAI,KAAqB;AAGvD,SAAS,eAAe,KAAsB;AAC5C,QACE,IAAI,UAAU,KACd,IAAI,WAAW,EAAE,KAAK,OACtB,IAAI,WAAW,EAAE,KAAK,OACtB,IAAI,WAAW,EAAE,IAAI,MACrB,IAAI,WAAW,EAAE,IAAI;;AAIzB,SAAS,oBAAoB,OAAuB;AAClD,KAAI,MAAM,SAAS,GACjB,QAAO,WAAW,MAAM;CAG1B,MAAM,SAAS,sBAAsB,IAAI,MAAM;AAC/C,KAAI,WAAW,OACb,QAAO;CAGT,MAAM,UAAU,WAAW,MAAM;AAGjC,KAAI,YAAY,MAAO,QAAO;AAC9B,KAAI,sBAAsB,QAAQ,+BAChC,uBAAsB,OAAO;AAE/B,uBAAsB,IAAI,OAAO,QAAQ;AACzC,QAAO;;;;;;AAOT,SAAgB,kBACd,OACA,MACM;AACN,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU;CAEzC,MAAM,WAAW;AACjB,MAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,QAAQ,SAAS;AAGvB,MACE,QAAQ,cACR,QAAQ,SACR,QAAQ,SACR,QAAQ,0BAER;AAGF,MAAI,eAAe,IAAI,CAAE;AAGzB,MAAI,IAAI,WAAW,EAAE,KAAK,GAAI;EAG9B,MAAM,WAAW,QAAQ,cAAc,UAAU;AAGjD,MAAI,aAAa,SAAS;GACxB,MAAM,MAAM,OAAO,UAAU,WAAW,QAA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K,IAAI,WAAW;WACrB,UAAU,SAAS,UAAU,QAAQ,UAAU,OACxD;OACK;GACL,MAAM,WAAW,OAAO,MAAM;AAC9B,aAAU,KAAK,IAAI,SAAS,IAAI,oBAAoB,SAAS,CAAC,GAAG;;;CAIrE,MAAM,SAAS,UAAU,KAAK,GAAG;AAEjC,KAAI,MAAM,oBACR,QAAO;EAAE,OAAO;EAAQ;EAAe;AAEzC,QAAO"}
1
+ {"version":3,"file":"attrs.js","names":[],"sources":["../../src/ssr/attrs.ts"],"sourcesContent":["/**\n * HTML attribute rendering for SSR\n */\n\nimport type { Props } from '../common/props';\nimport type { RenderSink } from './sink';\nimport { escapeAttr, needsEscapeAttr, styleObjToCss } from './escape';\n\n/** Result of renderAttrs including any raw HTML from dangerouslySetInnerHTML */\nexport type AttrsResult = {\n attrs: string;\n dangerousHtml?: string;\n};\n\nconst ESCAPED_ATTR_VALUE_CACHE_LIMIT = 512;\nconst escapedAttrValueCache = new Map<string, string>();\n\n// Fast check for event handler pattern (on + uppercase letter)\nfunction isEventHandler(key: string): boolean {\n return (\n key.length >= 3 &&\n key.charCodeAt(0) === 111 && // 'o'\n key.charCodeAt(1) === 110 && // 'n'\n key.charCodeAt(2) >= 65 &&\n key.charCodeAt(2) <= 90 // 'A'-'Z'\n );\n}\n\nfunction getEscapedAttrValue(value: string): string {\n if (value.length > 64) {\n return escapeAttr(value);\n }\n\n const cached = escapedAttrValueCache.get(value);\n if (cached !== undefined) {\n return cached;\n }\n\n const escaped = escapeAttr(value);\n // Skip caching strings that required no escaping — same reference returned,\n // no point occupying cache slots with identity entries.\n if (escaped === value) return value;\n if (escapedAttrValueCache.size >= ESCAPED_ATTR_VALUE_CACHE_LIMIT) {\n escapedAttrValueCache.clear();\n }\n escapedAttrValueCache.set(value, escaped);\n return escaped;\n}\n\n/**\n * Render attributes directly to a sink without intermediate string allocations.\n * This is the hot path for streaming SSR.\n */\nexport function renderAttrsDirect(\n props: Props | undefined,\n sink: Pick<RenderSink, 'write'>\n): void {\n if (!props || typeof props !== 'object') return;\n\n const propsObj = props as Record<string, unknown>;\n for (const key in propsObj) {\n const value = propsObj[key];\n\n // Skip special props\n if (\n key === 'children' ||\n key === 'key' ||\n key === 'ref' ||\n key === 'dangerouslySetInnerHTML'\n )\n continue;\n\n // Skip event handlers\n if (isEventHandler(key)) continue;\n\n // Skip internal props\n if (key.charCodeAt(0) === 95) continue; // '_'\n\n // Normalize class attribute\n const attrName = key === 'className' ? 'class' : key;\n\n // Handle style objects\n if (attrName === 'style') {\n const css = typeof value === 'string' ? value : styleObjToCss(value);\n if (!css) continue;\n sink.write(' style=\"');\n // Escape inline - most style values don't need escaping\n if (needsEscapeAttr(css)) {\n sink.write(getEscapedAttrValue(css));\n } else {\n sink.write(css);\n }\n sink.write('\"');\n continue;\n }\n\n // Boolean attributes\n if (value === true) {\n sink.write(' ');\n sink.write(attrName);\n continue;\n }\n\n if (value === false || value === null || value === undefined) continue;\n\n // Regular attributes\n const strValue = String(value);\n sink.write(' ');\n sink.write(attrName);\n sink.write('=\"');\n // escapeAttr returns the original string when nothing needs escaping,\n // so no separate needsEscapeAttr pre-scan is required.\n sink.write(getEscapedAttrValue(strValue));\n sink.write('\"');\n }\n}\n\n/**\n * Render attributes to HTML string, excluding event handlers\n * Optimized for minimal allocations using push-based approach\n *\n * Returns both the attribute string and any dangerouslySetInnerHTML content.\n */\nexport function renderAttrs(props?: Props): string;\nexport function renderAttrs(\n props: Props | undefined,\n opts: { returnDangerousHtml: true }\n): AttrsResult;\nexport function renderAttrs(\n props?: Props,\n opts?: { returnDangerousHtml?: boolean }\n): string | AttrsResult {\n if (!props || typeof props !== 'object') {\n return opts?.returnDangerousHtml ? { attrs: '' } : '';\n }\n\n const attrParts: string[] = [];\n let dangerousHtml: string | undefined;\n\n const propsObj = props as Record<string, unknown>;\n for (const key in propsObj) {\n const value = propsObj[key];\n\n // Skip children in attrs\n if (key === 'children') continue;\n\n // Skip internal identity refs (framework-only)\n if (key === 'key' || key === 'ref') continue;\n\n // Handle dangerouslySetInnerHTML\n if (key === 'dangerouslySetInnerHTML') {\n if (value && typeof value === 'object' && '__html' in (value as object)) {\n dangerousHtml = String((value as { __html: unknown }).__html);\n }\n continue;\n }\n\n // Skip event handlers\n if (isEventHandler(key)) continue;\n\n // Skip internal props\n if (key.charCodeAt(0) === 95) continue; // '_'\n\n // Normalize class attribute (`class` preferred, accept `className` for compatibility)\n const attrName = key === 'class' || key === 'className' ? 'class' : key;\n\n // Handle style objects\n if (attrName === 'style') {\n const css = typeof value === 'string' ? value : styleObjToCss(value);\n if (css === null || css === '') continue;\n attrParts.push(` style=\"${getEscapedAttrValue(css)}\"`);\n continue;\n }\n\n // Boolean attributes\n if (value === true) {\n attrParts.push(` ${attrName}`);\n } else if (value === false || value === null || value === undefined) {\n continue;\n } else {\n const strValue = String(value);\n attrParts.push(` ${attrName}=\"${getEscapedAttrValue(strValue)}\"`);\n }\n }\n\n const result = attrParts.join('');\n\n if (opts?.returnDangerousHtml) {\n return { attrs: result, dangerousHtml };\n }\n return result;\n}\n"],"mappings":";;AAcA,MAAM,iCAAiC;AACvC,MAAM,wCAAwB,IAAI,KAAqB;AAGvD,SAAS,eAAe,KAAsB;CAC5C,OACE,IAAI,UAAU,KACd,IAAI,WAAW,EAAE,KAAK,OACtB,IAAI,WAAW,EAAE,KAAK,OACtB,IAAI,WAAW,EAAE,IAAI,MACrB,IAAI,WAAW,EAAE,IAAI;;AAIzB,SAAS,oBAAoB,OAAuB;CAClD,IAAI,MAAM,SAAS,IACjB,OAAO,WAAW,MAAM;CAG1B,MAAM,SAAS,sBAAsB,IAAI,MAAM;CAC/C,IAAI,WAAW,QACb,OAAO;CAGT,MAAM,UAAU,WAAW,MAAM;CAGjC,IAAI,YAAY,OAAO,OAAO;CAC9B,IAAI,sBAAsB,QAAQ,gCAChC,sBAAsB,OAAO;CAE/B,sBAAsB,IAAI,OAAO,QAAQ;CACzC,OAAO;;;;;;AAOT,SAAgB,kBACd,OACA,MACM;CAC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,OAAO;GAE/D;;EAIF,IAAI,eAAe,IAAI,EAAE;EAGzB,IAAI,IAAI,WAAW,EAAE,KAAK,IAAI;EAG9B,MAAM,WAAW,QAAQ,WAAW,QAAQ,cAAc,UAAU;EAGpE,IAAI,aAAa,SAAS;GACxB,MAAM,MAAM,OAAO,UAAU,WAAW,QAAQ,cAAc,MAAM;GACpE,IAAI,QAAQ,QAAQ,QAAQ,IAAI;GAChC,UAAU,KAAK,WAAW,oBAAoB,IAAI,CAAC,GAAG;GACtD;;EAIF,IAAI,UAAU,MACZ,UAAU,KAAK,IAAI,WAAW;OACzB,IAAI,UAAU,SAAS,UAAU,QAAQ,UAAU,QACxD;OACK;GACL,MAAM,WAAW,OAAO,MAAM;GAC9B,UAAU,KAAK,IAAI,SAAS,IAAI,oBAAoB,SAAS,CAAC,GAAG;;;CAIrE,MAAM,SAAS,UAAU,KAAK,GAAG;CAEjC,IAAI,MAAM,qBACR,OAAO;EAAE,OAAO;EAAQ;EAAe;CAEzC,OAAO"}
@@ -10,6 +10,7 @@ interface RenderContext {
10
10
  routes?: readonly Route[];
11
11
  routeAuth?: RouteAuthOptions;
12
12
  signal?: AbortSignal;
13
+ queryCache?: Map<string, unknown>;
13
14
  keyCounter: number;
14
15
  renderData: Record<string, unknown> | null;
15
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","names":[],"sources":["../../src/ssr/context.ts"],"mappings":";;;;UAeiB,aAAA;EACf,GAAA;EACA,IAAA;EACA,IAAA,GAAO,OAAA;EACP,MAAA,GAAS,MAAA;EACT,MAAA,YAAkB,KAAA;EAClB,SAAA,GAAY,gBAAA;EACZ,MAAA,GAAS,WAAA;EAET,UAAA;EACA,UAAA,EAAY,MAAA;AAAA;AAAA,KAIF,UAAA,GAAa,aAAA;AAAA,iBA0BT,mBAAA,CACd,IAAA,WACA,IAAA;EACE,GAAA;EACA,IAAA,GAAO,OAAA;EACP,MAAA,GAAS,MAAA;EACT,MAAA,YAAkB,KAAA;EAClB,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,GAAI,CAAA;;;;;iBASvD,mBAAA,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { __require } from "../_virtual/_rolldown/runtime.js";
2
2
  import { SSRDataMissingError } from "../common/ssr-errors.js";
3
3
  import "./errors.js";
4
+ import { clearEscapeCache } from "./escape.js";
4
5
  //#region src/ssr/context.ts
5
6
  /**
6
7
  * SSR Context Management
@@ -16,6 +17,7 @@ try {
16
17
  } catch {}
17
18
  let fallbackStack = null;
18
19
  function createRenderContext(seed = 12345, opts = {}) {
20
+ clearEscapeCache();
19
21
  return {
20
22
  url: opts.url ?? "",
21
23
  seed,
@@ -24,6 +26,7 @@ function createRenderContext(seed = 12345, opts = {}) {
24
26
  routes: opts.routes,
25
27
  routeAuth: opts.routeAuth,
26
28
  signal: opts.signal,
29
+ queryCache: /* @__PURE__ */ new Map(),
27
30
  keyCounter: 0,
28
31
  renderData: null
29
32
  };
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../../src/ssr/context.ts"],"sourcesContent":["/**\n * SSR Context Management\n *\n * Provides concurrency-safe context for server-side rendering.\n * In Node.js, uses AsyncLocalStorage for isolation between concurrent requests.\n * Falls back to stack-based approach in non-Node environments.\n */\n\nimport { SSRDataMissingError } from './errors';\n\nexport type { SSRData } from '../common/ssr';\nimport type { SSRData } from '../common/ssr';\nimport type { Route, RouteAuthOptions } from '../common/router';\n\n// Unified per-render context combining SSRContext and RenderContext\nexport interface RenderContext {\n url: string;\n seed: number;\n data?: SSRData;\n params?: Record<string, string>;\n routes?: readonly Route[];\n routeAuth?: RouteAuthOptions;\n signal?: AbortSignal;\n // Per-render key state (moved from render-keys.ts globals)\n keyCounter: number;\n renderData: Record<string, unknown> | null;\n}\n\n// Legacy alias for compatibility\nexport type SSRContext = RenderContext;\n\n// AsyncLocalStorage for Node.js concurrency safety\ntype AsyncLocalStorageType<T> = {\n getStore(): T | undefined;\n run<R>(store: T, fn: () => R): R;\n};\n\nlet asyncLocalStorage: AsyncLocalStorageType<RenderContext> | null = null;\n\n// Try to load AsyncLocalStorage at module init (Node.js only)\ntry {\n // Dynamic require to avoid bundler issues in browser builds\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const asyncHooks = require('async_hooks');\n if (asyncHooks?.AsyncLocalStorage) {\n asyncLocalStorage =\n new asyncHooks.AsyncLocalStorage() as AsyncLocalStorageType<RenderContext>;\n }\n} catch {\n // Not in Node.js or async_hooks unavailable - use fallback\n}\n\n// Fallback stack for non-Node environments\nlet fallbackStack: RenderContext | null = null;\n\nexport function createRenderContext(\n seed = 12345,\n opts: {\n url?: string;\n data?: SSRData;\n params?: Record<string, string>;\n routes?: readonly Route[];\n routeAuth?: RouteAuthOptions;\n signal?: AbortSignal;\n } = {}\n): RenderContext {\n return {\n url: opts.url ?? '',\n seed,\n data: opts.data,\n params: opts.params,\n routes: opts.routes,\n routeAuth: opts.routeAuth,\n signal: opts.signal,\n keyCounter: 0,\n renderData: null,\n };\n}\n\n/**\n * Run a function with the given render context.\n * Concurrency-safe in Node.js via AsyncLocalStorage.\n */\nexport function withRenderContext<T>(ctx: RenderContext, fn: () => T): T {\n if (asyncLocalStorage) {\n return asyncLocalStorage.run(ctx, fn);\n }\n // Fallback: stack-based (not concurrency-safe)\n const prev = fallbackStack;\n fallbackStack = ctx;\n try {\n return fn();\n } finally {\n fallbackStack = prev;\n }\n}\n\n/**\n * Get the current render context.\n * Returns null if not inside a render.\n */\nexport function getRenderContext(): RenderContext | null {\n if (asyncLocalStorage) {\n return asyncLocalStorage.getStore() ?? null;\n }\n return fallbackStack;\n}\n\n// Legacy API aliases (deprecated, for backwards compatibility)\nexport const getSSRContext = getRenderContext;\nexport const withSSRContext = withRenderContext;\nexport const getCurrentSSRContext = getRenderContext;\n\nexport function runWithSSRContext<T>(ctx: RenderContext, fn: () => T): T {\n // This was a separate path for sync detection; now unified\n return withRenderContext(ctx, fn);\n}\n\n/**\n * Centralized SSR enforcement helper — throws a consistent error when async\n * data is encountered during synchronous SSR.\n */\nexport function throwSSRDataMissing(): never {\n throw new SSRDataMissingError();\n}\n\nexport { SSRDataMissingError };\n"],"mappings":";;;;;;;;;;;AAqCA,IAAI,oBAAiE;AAGrE,IAAI;CAGF,MAAM,aAAA,UAAqB,cAAc;AACzC,KAAI,YAAY,kBACd,qBACE,IAAI,WAAW,mBAAmB;QAEhC;AAKR,IAAI,gBAAsC;AAE1C,SAAgB,oBACd,OAAO,OACP,OAOI,EAAE,EACS;AACf,QAAO;EACL,KAAK,KAAK,OAAO;EACjB;EACA,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,QAAQ,KAAK;EACb,YAAY;EACZ,YAAY;EACb;;;;;;AAOH,SAAgB,kBAAqB,KAAoB,IAAgB;AACvE,KAAI,kBACF,QAAO,kBAAkB,IAAI,KAAK,GAAG;CAGvC,MAAM,OAAO;AACb,iBAAgB;AAChB,KAAI;AACF,SAAO,IAAI;WACH;AACR,kBAAgB;;;;;;;AAQpB,SAAgB,mBAAyC;AACvD,KAAI,kBACF,QAAO,kBAAkB,UAAU,IAAI;AAEzC,QAAO;;;;;;AAiBT,SAAgB,sBAA6B;AAC3C,OAAM,IAAI,qBAAqB"}
1
+ {"version":3,"file":"context.js","names":[],"sources":["../../src/ssr/context.ts"],"sourcesContent":["/**\n * SSR Context Management\n *\n * Provides concurrency-safe context for server-side rendering.\n * In Node.js, uses AsyncLocalStorage for isolation between concurrent requests.\n * Falls back to stack-based approach in non-Node environments.\n */\n\nimport { SSRDataMissingError } from './errors';\nimport { clearEscapeCache } from './escape';\n\nexport type { SSRData } from '../common/ssr';\nimport type { SSRData } from '../common/ssr';\nimport type { Route, RouteAuthOptions } from '../common/router';\n\n// Unified per-render context combining SSRContext and RenderContext\nexport interface RenderContext {\n url: string;\n seed: number;\n data?: SSRData;\n params?: Record<string, string>;\n routes?: readonly Route[];\n routeAuth?: RouteAuthOptions;\n signal?: AbortSignal;\n queryCache?: Map<string, unknown>;\n // Per-render key state (moved from render-keys.ts globals)\n keyCounter: number;\n renderData: Record<string, unknown> | null;\n}\n\n// Legacy alias for compatibility\nexport type SSRContext = RenderContext;\n\n// AsyncLocalStorage for Node.js concurrency safety\ntype AsyncLocalStorageType<T> = {\n getStore(): T | undefined;\n run<R>(store: T, fn: () => R): R;\n};\n\nlet asyncLocalStorage: AsyncLocalStorageType<RenderContext> | null = null;\n\n// Try to load AsyncLocalStorage at module init (Node.js only)\ntry {\n // Dynamic require to avoid bundler issues in browser builds\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const asyncHooks = require('async_hooks');\n if (asyncHooks?.AsyncLocalStorage) {\n asyncLocalStorage =\n new asyncHooks.AsyncLocalStorage() as AsyncLocalStorageType<RenderContext>;\n }\n} catch {\n // Not in Node.js or async_hooks unavailable - use fallback\n}\n\n// Fallback stack for non-Node environments\nlet fallbackStack: RenderContext | null = null;\n\nexport function createRenderContext(\n seed = 12345,\n opts: {\n url?: string;\n data?: SSRData;\n params?: Record<string, string>;\n routes?: readonly Route[];\n routeAuth?: RouteAuthOptions;\n signal?: AbortSignal;\n } = {}\n): RenderContext {\n clearEscapeCache();\n\n return {\n url: opts.url ?? '',\n seed,\n data: opts.data,\n params: opts.params,\n routes: opts.routes,\n routeAuth: opts.routeAuth,\n signal: opts.signal,\n queryCache: new Map<string, unknown>(),\n keyCounter: 0,\n renderData: null,\n };\n}\n\n/**\n * Run a function with the given render context.\n * Concurrency-safe in Node.js via AsyncLocalStorage.\n */\nexport function withRenderContext<T>(ctx: RenderContext, fn: () => T): T {\n if (asyncLocalStorage) {\n return asyncLocalStorage.run(ctx, fn);\n }\n // Fallback: stack-based (not concurrency-safe)\n const prev = fallbackStack;\n fallbackStack = ctx;\n try {\n return fn();\n } finally {\n fallbackStack = prev;\n }\n}\n\n/**\n * Get the current render context.\n * Returns null if not inside a render.\n */\nexport function getRenderContext(): RenderContext | null {\n if (asyncLocalStorage) {\n return asyncLocalStorage.getStore() ?? null;\n }\n return fallbackStack;\n}\n\n// Legacy API aliases (deprecated, for backwards compatibility)\nexport const getSSRContext = getRenderContext;\nexport const withSSRContext = withRenderContext;\nexport const getCurrentSSRContext = getRenderContext;\n\nexport function runWithSSRContext<T>(ctx: RenderContext, fn: () => T): T {\n // This was a separate path for sync detection; now unified\n return withRenderContext(ctx, fn);\n}\n\n/**\n * Centralized SSR enforcement helper — throws a consistent error when async\n * data is encountered during synchronous SSR.\n */\nexport function throwSSRDataMissing(): never {\n throw new SSRDataMissingError();\n}\n\nexport { SSRDataMissingError };\n"],"mappings":";;;;;;;;;;;;AAuCA,IAAI,oBAAiE;AAGrE,IAAI;CAGF,MAAM,aAAA,UAAqB,cAAc;CACzC,IAAI,YAAY,mBACd,oBACE,IAAI,WAAW,mBAAmB;QAEhC;AAKR,IAAI,gBAAsC;AAE1C,SAAgB,oBACd,OAAO,OACP,OAOI,EAAE,EACS;CACf,kBAAkB;CAElB,OAAO;EACL,KAAK,KAAK,OAAO;EACjB;EACA,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,QAAQ,KAAK;EACb,4BAAY,IAAI,KAAsB;EACtC,YAAY;EACZ,YAAY;EACb;;;;;;AAOH,SAAgB,kBAAqB,KAAoB,IAAgB;CACvE,IAAI,mBACF,OAAO,kBAAkB,IAAI,KAAK,GAAG;CAGvC,MAAM,OAAO;CACb,gBAAgB;CAChB,IAAI;EACF,OAAO,IAAI;WACH;EACR,gBAAgB;;;;;;;AAQpB,SAAgB,mBAAyC;CACvD,IAAI,mBACF,OAAO,kBAAkB,UAAU,IAAI;CAEzC,OAAO;;;;;;AAiBT,SAAgB,sBAA6B;CAC3C,MAAM,IAAI,qBAAqB"}
@@ -24,7 +24,50 @@ const VOID_ELEMENTS = new Set([
24
24
  const escapeCache = /* @__PURE__ */ new Map();
25
25
  const MAX_CACHE_SIZE = 256;
26
26
  const CSS_UNSAFE_RE = /[{}<>\\]/g;
27
- const CSS_DANGEROUS_FN_RE = /(?:url|expression|javascript)\s*\(/i;
27
+ const CSS_URI_SCHEME_RE = /(?:^|[\s(,])([a-z][a-z0-9+.-]*):/i;
28
+ const CSS_FUNCTION_NAME_RE = /([a-z-][a-z0-9-]*)\s*\(/gi;
29
+ const CSS_ALLOWED_FUNCTIONS = new Set([
30
+ "var",
31
+ "calc",
32
+ "min",
33
+ "max",
34
+ "clamp",
35
+ "rgb",
36
+ "rgba",
37
+ "hsl",
38
+ "hsla",
39
+ "lab",
40
+ "lch",
41
+ "oklab",
42
+ "oklch",
43
+ "color",
44
+ "color-mix",
45
+ "translate",
46
+ "translatex",
47
+ "translatey",
48
+ "translatez",
49
+ "scale",
50
+ "scalex",
51
+ "scaley",
52
+ "scalez",
53
+ "rotate",
54
+ "rotatex",
55
+ "rotatey",
56
+ "rotatez",
57
+ "skew",
58
+ "skewx",
59
+ "skewy",
60
+ "matrix",
61
+ "matrix3d",
62
+ "linear-gradient",
63
+ "radial-gradient",
64
+ "conic-gradient",
65
+ "repeating-linear-gradient",
66
+ "repeating-radial-gradient",
67
+ "repeating-conic-gradient",
68
+ "cubic-bezier",
69
+ "steps"
70
+ ]);
28
71
  const STYLE_PROP_CACHE = /* @__PURE__ */ new Map();
29
72
  const MAX_STYLE_PROP_CACHE_SIZE = 512;
30
73
  function toKebabCached(prop) {
@@ -35,6 +78,13 @@ function toKebabCached(prop) {
35
78
  return kebab;
36
79
  }
37
80
  /**
81
+ * Clear the escape cache. Call between SSR requests in long-running servers
82
+ * to prevent memory buildup from unique strings.
83
+ */
84
+ function clearEscapeCache() {
85
+ escapeCache.clear();
86
+ }
87
+ /**
38
88
  * Fast check if a string needs text escaping.
39
89
  * Used to skip the full escape call when not needed.
40
90
  */
@@ -114,21 +164,11 @@ function escapeAttr(value) {
114
164
  */
115
165
  function escapeCssValue(value) {
116
166
  const str = String(value);
117
- let hasUnsafeChars = false;
118
- let openParen = -1;
119
- for (let i = 0; i < str.length; i++) {
120
- const ch = str.charCodeAt(i);
121
- if (ch === 123 || ch === 125 || ch === 60 || ch === 62 || ch === 92) {
122
- hasUnsafeChars = true;
123
- if (openParen >= 0) break;
124
- } else if (ch === 40 && openParen < 0) {
125
- openParen = i;
126
- if (hasUnsafeChars) break;
127
- }
167
+ if (CSS_URI_SCHEME_RE.test(str)) return "";
168
+ if (str.includes("(")) {
169
+ for (const match of str.matchAll(CSS_FUNCTION_NAME_RE)) if (!CSS_ALLOWED_FUNCTIONS.has(match[1].toLowerCase())) return "";
128
170
  }
129
- if (!hasUnsafeChars && openParen === -1) return str;
130
- if (openParen !== -1 && CSS_DANGEROUS_FN_RE.test(str)) return "";
131
- return hasUnsafeChars ? str.replace(CSS_UNSAFE_RE, "") : str;
171
+ return str.replace(CSS_UNSAFE_RE, "");
132
172
  }
133
173
  /**
134
174
  * Convert style object to CSS string with value escaping
@@ -148,6 +188,6 @@ function styleObjToCss(value) {
148
188
  return result || null;
149
189
  }
150
190
  //#endregion
151
- export { VOID_ELEMENTS, escapeAttr, escapeText, needsEscapeAttr, styleObjToCss };
191
+ export { VOID_ELEMENTS, clearEscapeCache, escapeAttr, escapeText, needsEscapeAttr, styleObjToCss };
152
192
 
153
193
  //# sourceMappingURL=escape.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"escape.js","names":[],"sources":["../../src/ssr/escape.ts"],"sourcesContent":["/**\n * HTML escaping utilities for SSR\n *\n * Centralizes text and attribute escaping to avoid duplication\n * between sync and streaming SSR renderers.\n */\n\n// HTML5 void elements that don't have closing tags\nexport const VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\n// Escape cache for common values (bounded and clearable for long-running servers)\nconst escapeCache = new Map<string, string>();\nconst MAX_CACHE_SIZE = 256;\n\nconst _TEXT_ESCAPE_RE = /[&<>]/g;\n\nconst CSS_UNSAFE_RE = /[{}<>\\\\]/g;\nconst CSS_DANGEROUS_FN_RE = /(?:url|expression|javascript)\\s*\\(/i;\n\nconst STYLE_PROP_CACHE = new Map<string, string>();\nconst MAX_STYLE_PROP_CACHE_SIZE = 512;\n\n// Pre-compute escape map functions for faster replacement\nconst _textEscapeMap = (ch: string): string => {\n const code = ch.charCodeAt(0);\n if (code === 38) return '&amp;'; // &\n if (code === 60) return '&lt;'; // <\n if (code === 62) return '&gt;'; // >\n return ch;\n};\n\nfunction toKebabCached(prop: string): string {\n const cached = STYLE_PROP_CACHE.get(prop);\n if (cached !== undefined) return cached;\n const kebab = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n if (STYLE_PROP_CACHE.size < MAX_STYLE_PROP_CACHE_SIZE) {\n STYLE_PROP_CACHE.set(prop, kebab);\n }\n return kebab;\n}\n\n/**\n * Clear the escape cache. Call between SSR requests in long-running servers\n * to prevent memory buildup from unique strings.\n */\nexport function clearEscapeCache(): void {\n escapeCache.clear();\n}\n\n/**\n * Fast check if a string needs text escaping.\n * Used to skip the full escape call when not needed.\n */\nexport function needsEscapeText(text: string): boolean {\n for (let i = 0; i < text.length; i++) {\n const ch = text.charCodeAt(i);\n if (ch === 38 || ch === 60 || ch === 62) return true;\n }\n return false;\n}\n\n/**\n * Fast check if a string needs attribute escaping.\n * Checks for & \" ' < > characters.\n */\nexport function needsEscapeAttr(value: string): boolean {\n for (let i = 0; i < value.length; i++) {\n const ch = value.charCodeAt(i);\n // & \" ' < >\n if (ch === 38 || ch === 34 || ch === 39 || ch === 60 || ch === 62) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Escape HTML special characters in text content\n * Fast-path: cache first, then scan-then-escape for new strings\n */\nexport function escapeText(text: string): string {\n // Only use cache for short strings (likely to be repeated)\n const useCache = text.length <= 64;\n\n if (useCache) {\n const cached = escapeCache.get(text);\n if (cached !== undefined) return cached;\n }\n\n // Fast path: check if escaping needed\n if (!needsEscapeText(text)) {\n if (useCache && escapeCache.size < MAX_CACHE_SIZE) {\n escapeCache.set(text, text);\n }\n return text;\n }\n\n // Single-pass scan-and-build: avoids 3 separate regex passes\n let escaped = '';\n let lastIndex = 0;\n for (let i = 0; i < text.length; i++) {\n const ch = text.charCodeAt(i);\n let entity: string;\n if (ch === 38) entity = '&amp;';\n else if (ch === 60) entity = '&lt;';\n else if (ch === 62) entity = '&gt;';\n else continue;\n escaped += text.slice(lastIndex, i) + entity;\n lastIndex = i + 1;\n }\n const result = escaped + text.slice(lastIndex);\n\n if (useCache && escapeCache.size < MAX_CACHE_SIZE) {\n escapeCache.set(text, result);\n }\n return result;\n}\n\n/**\n * Escape HTML special characters in attribute values.\n * Single-pass scan: returns the original string unchanged when no special\n * characters are found, so callers can drop separate needsEscapeAttr checks.\n */\nexport function escapeAttr(value: string): string {\n let escaped = '';\n let lastIndex = 0;\n for (let i = 0; i < value.length; i++) {\n const ch = value.charCodeAt(i);\n let entity: string;\n if (ch === 38) entity = '&amp;';\n else if (ch === 34) entity = '&quot;';\n else if (ch === 39) entity = '&#x27;';\n else if (ch === 60) entity = '&lt;';\n else if (ch === 62) entity = '&gt;';\n else continue;\n escaped += value.slice(lastIndex, i) + entity;\n lastIndex = i + 1;\n }\n // Return original reference when nothing needed escaping (no allocation)\n return lastIndex === 0 ? value : escaped + value.slice(lastIndex);\n}\n\n/**\n * Escape CSS value to prevent injection attacks.\n * Removes characters that could break out of CSS context.\n */\nfunction escapeCssValue(value: string): string {\n const str = String(value);\n\n let hasUnsafeChars = false;\n let openParen = -1;\n\n // Single pass to check for unsafe chars and find first paren\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n // Check for { } < > \\\n if (ch === 123 || ch === 125 || ch === 60 || ch === 62 || ch === 92) {\n hasUnsafeChars = true;\n if (openParen >= 0) break;\n } else if (ch === 40 && openParen < 0) {\n // (\n openParen = i;\n if (hasUnsafeChars) break;\n }\n }\n\n // Fast path: most CSS values are simple\n if (!hasUnsafeChars && openParen === -1) return str;\n\n // Block dangerous CSS functions\n if (openParen !== -1 && CSS_DANGEROUS_FN_RE.test(str)) {\n return '';\n }\n\n // Remove characters that could break out of CSS value context\n return hasUnsafeChars ? str.replace(CSS_UNSAFE_RE, '') : str;\n}\n\n/**\n * Convert style object to CSS string with value escaping\n * Optimized to avoid Object.entries allocation\n */\nexport function styleObjToCss(value: unknown): string | null {\n if (!value || typeof value !== 'object') return null;\n\n const styleObj = value as Record<string, unknown>;\n let result = '';\n\n for (const k in styleObj) {\n const v = styleObj[k];\n if (v === null || v === undefined || v === false) continue;\n\n const prop = toKebabCached(k);\n const safeValue = escapeCssValue(String(v));\n if (safeValue) {\n result += `${prop}:${safeValue};`;\n }\n }\n\n return result || null;\n}\n"],"mappings":";;;;;;;AAQA,MAAa,gBAAgB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAGF,MAAM,8BAAc,IAAI,KAAqB;AAC7C,MAAM,iBAAiB;AAIvB,MAAM,gBAAgB;AACtB,MAAM,sBAAsB;AAE5B,MAAM,mCAAmB,IAAI,KAAqB;AAClD,MAAM,4BAA4B;AAWlC,SAAS,cAAc,MAAsB;CAC3C,MAAM,SAAS,iBAAiB,IAAI,KAAK;AACzC,KAAI,WAAW,OAAW,QAAO;CACjC,MAAM,QAAQ,KAAK,QAAQ,WAAW,MAAM,IAAI,EAAE,aAAa,GAAG;AAClE,KAAI,iBAAiB,OAAO,0BAC1B,kBAAiB,IAAI,MAAM,MAAM;AAEnC,QAAO;;;;;;AAeT,SAAgB,gBAAgB,MAAuB;AACrD,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,KAAK,KAAK,WAAW,EAAE;AAC7B,MAAI,OAAO,MAAM,OAAO,MAAM,OAAO,GAAI,QAAO;;AAElD,QAAO;;;;;;AAOT,SAAgB,gBAAgB,OAAwB;AACtD,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,KAAK,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C7C,MAAM,MAAM,OAAO,MAAM;CAEzB,IAAI,iBAAiB;CACrB,IAAI,YAAY;AAGhB,MAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;EACnC,MAAM,KAAK,IAAI,WAAW,EAAE;AAE5B,MAAI,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM,OAAO,MAAM,OAAO,IAAI;AACnE,oBAAiB;AACjB,OAAI,aAAa,EAAG;aACX,OAAO,MAAM,YAAY,GAAG;AAErC,eAAY;AACZ,OAAI,eAAgB;;;AAKxB,KAAI,CAAC,kBAAkB,cAAc,GAAI,QAAO;AAGhD,KAAI,cAAc,MAAM,oBAAoB,KAAK,IAAI,CACnD,QAAO;AAIT,QAAO,iBAAiB,IAAI,QAAQ,eAAe,GAAG,GAAG;;;;;;AAO3D,SAAgB,cAAc,OAA+B;AAC3D,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;CAEhD,MAAM,WAAW;CACjB,IAAI,SAAS;AAEb,MAAK,MAAM,KAAK,UAAU;EACxB,MAAM,IAAI,SAAS;AACnB,MAAI,MAAM,QAAQ,MAAM,UAAa,MAAM,MAAO;EAElD,MAAM,OAAO,cAAc,EAAE;EAC7B,MAAM,YAAY,eAAe,OAAO,EAAE,CAAC;AAC3C,MAAI,UACF,WAAU,GAAG,KAAK,GAAG,UAAU;;AAInC,QAAO,UAAU"}
1
+ {"version":3,"file":"escape.js","names":[],"sources":["../../src/ssr/escape.ts"],"sourcesContent":["/**\n * HTML escaping utilities for SSR\n *\n * Centralizes text and attribute escaping to avoid duplication\n * between sync and streaming SSR renderers.\n */\n\n// HTML5 void elements that don't have closing tags\nexport const VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\n// Escape cache for common values (bounded and clearable for long-running servers)\nconst escapeCache = new Map<string, string>();\nconst MAX_CACHE_SIZE = 256;\n\nconst _TEXT_ESCAPE_RE = /[&<>]/g;\n\nconst CSS_UNSAFE_RE = /[{}<>\\\\]/g;\nconst CSS_URI_SCHEME_RE = /(?:^|[\\s(,])([a-z][a-z0-9+.-]*):/i;\nconst CSS_FUNCTION_NAME_RE = /([a-z-][a-z0-9-]*)\\s*\\(/gi;\n\nconst CSS_ALLOWED_FUNCTIONS = new Set([\n 'var',\n 'calc',\n 'min',\n 'max',\n 'clamp',\n 'rgb',\n 'rgba',\n 'hsl',\n 'hsla',\n 'lab',\n 'lch',\n 'oklab',\n 'oklch',\n 'color',\n 'color-mix',\n 'translate',\n 'translatex',\n 'translatey',\n 'translatez',\n 'scale',\n 'scalex',\n 'scaley',\n 'scalez',\n 'rotate',\n 'rotatex',\n 'rotatey',\n 'rotatez',\n 'skew',\n 'skewx',\n 'skewy',\n 'matrix',\n 'matrix3d',\n 'linear-gradient',\n 'radial-gradient',\n 'conic-gradient',\n 'repeating-linear-gradient',\n 'repeating-radial-gradient',\n 'repeating-conic-gradient',\n 'cubic-bezier',\n 'steps',\n]);\n\nconst STYLE_PROP_CACHE = new Map<string, string>();\nconst MAX_STYLE_PROP_CACHE_SIZE = 512;\n\n// Pre-compute escape map functions for faster replacement\nconst _textEscapeMap = (ch: string): string => {\n const code = ch.charCodeAt(0);\n if (code === 38) return '&amp;'; // &\n if (code === 60) return '&lt;'; // <\n if (code === 62) return '&gt;'; // >\n return ch;\n};\n\nfunction toKebabCached(prop: string): string {\n const cached = STYLE_PROP_CACHE.get(prop);\n if (cached !== undefined) return cached;\n const kebab = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n if (STYLE_PROP_CACHE.size < MAX_STYLE_PROP_CACHE_SIZE) {\n STYLE_PROP_CACHE.set(prop, kebab);\n }\n return kebab;\n}\n\n/**\n * Clear the escape cache. Call between SSR requests in long-running servers\n * to prevent memory buildup from unique strings.\n */\nexport function clearEscapeCache(): void {\n escapeCache.clear();\n}\n\n/**\n * Fast check if a string needs text escaping.\n * Used to skip the full escape call when not needed.\n */\nexport function needsEscapeText(text: string): boolean {\n for (let i = 0; i < text.length; i++) {\n const ch = text.charCodeAt(i);\n if (ch === 38 || ch === 60 || ch === 62) return true;\n }\n return false;\n}\n\n/**\n * Fast check if a string needs attribute escaping.\n * Checks for & \" ' < > characters.\n */\nexport function needsEscapeAttr(value: string): boolean {\n for (let i = 0; i < value.length; i++) {\n const ch = value.charCodeAt(i);\n // & \" ' < >\n if (ch === 38 || ch === 34 || ch === 39 || ch === 60 || ch === 62) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Escape HTML special characters in text content\n * Fast-path: cache first, then scan-then-escape for new strings\n */\nexport function escapeText(text: string): string {\n // Only use cache for short strings (likely to be repeated)\n const useCache = text.length <= 64;\n\n if (useCache) {\n const cached = escapeCache.get(text);\n if (cached !== undefined) return cached;\n }\n\n // Fast path: check if escaping needed\n if (!needsEscapeText(text)) {\n if (useCache && escapeCache.size < MAX_CACHE_SIZE) {\n escapeCache.set(text, text);\n }\n return text;\n }\n\n // Single-pass scan-and-build: avoids 3 separate regex passes\n let escaped = '';\n let lastIndex = 0;\n for (let i = 0; i < text.length; i++) {\n const ch = text.charCodeAt(i);\n let entity: string;\n if (ch === 38) entity = '&amp;';\n else if (ch === 60) entity = '&lt;';\n else if (ch === 62) entity = '&gt;';\n else continue;\n escaped += text.slice(lastIndex, i) + entity;\n lastIndex = i + 1;\n }\n const result = escaped + text.slice(lastIndex);\n\n if (useCache && escapeCache.size < MAX_CACHE_SIZE) {\n escapeCache.set(text, result);\n }\n return result;\n}\n\n/**\n * Escape HTML special characters in attribute values.\n * Single-pass scan: returns the original string unchanged when no special\n * characters are found, so callers can drop separate needsEscapeAttr checks.\n */\nexport function escapeAttr(value: string): string {\n let escaped = '';\n let lastIndex = 0;\n for (let i = 0; i < value.length; i++) {\n const ch = value.charCodeAt(i);\n let entity: string;\n if (ch === 38) entity = '&amp;';\n else if (ch === 34) entity = '&quot;';\n else if (ch === 39) entity = '&#x27;';\n else if (ch === 60) entity = '&lt;';\n else if (ch === 62) entity = '&gt;';\n else continue;\n escaped += value.slice(lastIndex, i) + entity;\n lastIndex = i + 1;\n }\n // Return original reference when nothing needed escaping (no allocation)\n return lastIndex === 0 ? value : escaped + value.slice(lastIndex);\n}\n\n/**\n * Escape CSS value to prevent injection attacks.\n * Removes characters that could break out of CSS context.\n */\nfunction escapeCssValue(value: string): string {\n const str = String(value);\n\n if (CSS_URI_SCHEME_RE.test(str)) {\n return '';\n }\n\n if (str.includes('(')) {\n for (const match of str.matchAll(CSS_FUNCTION_NAME_RE)) {\n if (!CSS_ALLOWED_FUNCTIONS.has(match[1].toLowerCase())) {\n return '';\n }\n }\n }\n\n // Remove characters that could break out of CSS value context\n return str.replace(CSS_UNSAFE_RE, '');\n}\n\n/**\n * Convert style object to CSS string with value escaping\n * Optimized to avoid Object.entries allocation\n */\nexport function styleObjToCss(value: unknown): string | null {\n if (!value || typeof value !== 'object') return null;\n\n const styleObj = value as Record<string, unknown>;\n let result = '';\n\n for (const k in styleObj) {\n const v = styleObj[k];\n if (v === null || v === undefined || v === false) continue;\n\n const prop = toKebabCached(k);\n const safeValue = escapeCssValue(String(v));\n if (safeValue) {\n result += `${prop}:${safeValue};`;\n }\n }\n\n return result || null;\n}\n"],"mappings":";;;;;;;AAQA,MAAa,gBAAgB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAGF,MAAM,8BAAc,IAAI,KAAqB;AAC7C,MAAM,iBAAiB;AAIvB,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,uBAAuB;AAE7B,MAAM,wBAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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AAA;AAAA,IACP,OAAA,CAAQ,kBAAA;AAAA,iBAmCI,wBAAA,CAAyB,IAAA;EACvC,GAAA;EACA,MAAA,EAAQ,KAAA;IAAQ,IAAA;IAAc,OAAA,EAAS,YAAA;IAAc,SAAA;EAAA;EACrD,OAAA;IAAY,IAAA;IAAe,IAAA,GAAO,OAAA;EAAA;AAAA;AAAA,iBAqBpB,yBAAA,CAA0B,IAAA;EACxC,IAAA,EAAM,OAAA;EACN,GAAA;EACA,MAAA,EAAQ,KAAA;IAAQ,IAAA;IAAc,OAAA,EAAS,YAAA;IAAc,SAAA;EAAA;EACrD,OAAA;IAAY,IAAA;IAAe,IAAA,GAAO,OAAA;EAAA;AAAA;AAAA,KAkDxB,QAAA;EACV,IAAA;EACA,OAAA,EAAS,YAAA;EACT,SAAA;AAAA;AAAA,iBAGc,cAAA,CACd,SAAA,GACE,KAAA,GAAQ,MAAA,sBACL,KAAA,GAAQ,UAAA;AAAA,iBAEC,cAAA,CAAe,IAAA;EAC7B,GAAA;EACA,MAAA,EAAQ,QAAA;EACR,IAAA;EACA,IAAA,GAAO,OAAA;AAAA;AAAA,iBAuBO,cAAA,CAAe,IAAA;EAC7B,GAAA;EACA,MAAA,EAAQ,QAAA;EACR,IAAA;EACA,IAAA,GAAO,OAAA;EACP,OAAA,CAAQ,IAAA;EACR,UAAA;AAAA"}
package/dist/ssr/index.js CHANGED
@@ -7,12 +7,12 @@ import { evaluateForState } from "../runtime/for.js";
7
7
  import { evaluateCaseState, evaluateShowState } from "../runtime/control.js";
8
8
  import { installSSRBridge } from "../runtime/ssr-bridge.js";
9
9
  import { SSRDataMissingError } from "../common/ssr-errors.js";
10
+ import { VOID_ELEMENTS, escapeText, styleObjToCss } from "./escape.js";
10
11
  import { createRenderContext, getRenderContext, throwSSRDataMissing, withRenderContext } from "./context.js";
11
12
  import { resolveRouteFromRoutes, resolveRouteRequest } from "../router/route.js";
12
13
  import "../jsx/index.js";
13
14
  import { DefaultPortal } from "../foundations/structures/portal.js";
14
15
  import { collectResources, getCurrentRenderData, getNextKey, resolvePlan, resolveResources, startRenderPhase, stopRenderPhase } from "./render-keys.js";
15
- import { VOID_ELEMENTS, escapeText, styleObjToCss } from "./escape.js";
16
16
  import { renderAttrs, renderAttrsDirect } from "./attrs.js";
17
17
  import { StreamSink, StringSink } from "./sink.js";
18
18
  import { renderNodeToSink } from "./stream-render.js";
@@ -21,6 +21,18 @@ const __SSR_DEBUG = process.env.ASKR_SSR_DEBUG === "1" || process.env.ASKR_SSR_D
21
21
  function isSSRAttrEventHandler(key) {
22
22
  return key.length >= 3 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && key.charCodeAt(2) >= 65 && key.charCodeAt(2) <= 90;
23
23
  }
24
+ function inheritRenderableKey(source, result) {
25
+ const inheritedKey = source.key;
26
+ if (inheritedKey === void 0 || inheritedKey === null) return result;
27
+ if (!result || typeof result !== "object" || !("type" in result)) return result;
28
+ const resultVNode = result;
29
+ if (resultVNode.key === void 0 || resultVNode.key === null) resultVNode.key = inheritedKey;
30
+ if (typeof resultVNode.type === "string") {
31
+ if (!resultVNode.props) resultVNode.props = {};
32
+ if (resultVNode.props["data-key"] === void 0) resultVNode.props["data-key"] = String(inheritedKey);
33
+ }
34
+ return result;
35
+ }
24
36
  installSSRBridge({
25
37
  getCurrentSSRContext: getRenderContext,
26
38
  throwSSRDataMissing,
@@ -271,7 +283,7 @@ function renderNodeSync(node, ctx) {
271
283
  function renderNodeSyncToSink(node, sink, ctx) {
272
284
  const { type, props } = node;
273
285
  if (typeof type === "function") {
274
- renderNodeSyncToSink(executeComponentSync(type, props, ctx), sink, ctx);
286
+ renderNodeSyncToSink(inheritRenderableKey(node, executeComponentSync(type, props, ctx)), sink, ctx);
275
287
  return;
276
288
  }
277
289
  if (typeof type === "symbol") {
@@ -487,7 +499,7 @@ function verifyExpectedNode(node, state, ctx) {
487
499
  if (!node || typeof node !== "object" || !("type" in node)) return true;
488
500
  const vnode = node;
489
501
  const { type, props } = vnode;
490
- if (typeof type === "function") return verifyExpectedNode(executeComponentSync(type, props, ctx), state, ctx);
502
+ if (typeof type === "function") return verifyExpectedNode(inheritRenderableKey(vnode, executeComponentSync(type, props, ctx)), state, ctx);
491
503
  if (typeof type === "symbol") {
492
504
  if (type === __CONTROL_BOUNDARY__) {
493
505
  const children = evaluateControlBoundaryChildren(vnode);