@ahmedrowaihi/pdf-forge-preview 1.0.0-canary.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 (351) hide show
  1. package/.next/BUILD_ID +1 -0
  2. package/.next/app-path-routes-manifest.json +7 -0
  3. package/.next/build/chunks/[root-of-the-server]__12fb5caf._.js +233 -0
  4. package/.next/build/chunks/[root-of-the-server]__12fb5caf._.js.map +8 -0
  5. package/.next/build/chunks/[root-of-the-server]__242deb00._.js +500 -0
  6. package/.next/build/chunks/[root-of-the-server]__242deb00._.js.map +11 -0
  7. package/.next/build/chunks/[turbopack-node]_transforms_postcss_ts_ad9a1eec._.js +13 -0
  8. package/.next/build/chunks/[turbopack-node]_transforms_postcss_ts_ad9a1eec._.js.map +5 -0
  9. package/.next/build/chunks/[turbopack]_runtime.js +795 -0
  10. package/.next/build/chunks/[turbopack]_runtime.js.map +10 -0
  11. package/.next/build/chunks/node_modules__pnpm_806d01c0._.js +6758 -0
  12. package/.next/build/chunks/node_modules__pnpm_806d01c0._.js.map +47 -0
  13. package/.next/build/package.json +1 -0
  14. package/.next/build/postcss.js +6 -0
  15. package/.next/build/postcss.js.map +5 -0
  16. package/.next/build-manifest.json +20 -0
  17. package/.next/diagnostics/build-diagnostics.json +6 -0
  18. package/.next/diagnostics/framework.json +1 -0
  19. package/.next/export-marker.json +6 -0
  20. package/.next/fallback-build-manifest.json +12 -0
  21. package/.next/images-manifest.json +66 -0
  22. package/.next/next-minimal-server.js.nft.json +1 -0
  23. package/.next/next-server.js.nft.json +1 -0
  24. package/.next/package.json +1 -0
  25. package/.next/prerender-manifest.json +65 -0
  26. package/.next/required-server-files.js +163 -0
  27. package/.next/required-server-files.json +163 -0
  28. package/.next/routes-manifest.json +77 -0
  29. package/.next/server/app/_global-error/page/app-paths-manifest.json +3 -0
  30. package/.next/server/app/_global-error/page/build-manifest.json +17 -0
  31. package/.next/server/app/_global-error/page/next-font-manifest.json +6 -0
  32. package/.next/server/app/_global-error/page/react-loadable-manifest.json +1 -0
  33. package/.next/server/app/_global-error/page/server-reference-manifest.json +4 -0
  34. package/.next/server/app/_global-error/page.js +11 -0
  35. package/.next/server/app/_global-error/page.js.map +5 -0
  36. package/.next/server/app/_global-error/page.js.nft.json +1 -0
  37. package/.next/server/app/_global-error/page_client-reference-manifest.js +2 -0
  38. package/.next/server/app/_global-error.html +2 -0
  39. package/.next/server/app/_global-error.meta +15 -0
  40. package/.next/server/app/_global-error.rsc +13 -0
  41. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +5 -0
  42. package/.next/server/app/_global-error.segments/_full.segment.rsc +13 -0
  43. package/.next/server/app/_global-error.segments/_head.segment.rsc +6 -0
  44. package/.next/server/app/_global-error.segments/_index.segment.rsc +4 -0
  45. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
  46. package/.next/server/app/_not-found/page/app-paths-manifest.json +3 -0
  47. package/.next/server/app/_not-found/page/build-manifest.json +17 -0
  48. package/.next/server/app/_not-found/page/next-font-manifest.json +16 -0
  49. package/.next/server/app/_not-found/page/react-loadable-manifest.json +1 -0
  50. package/.next/server/app/_not-found/page/server-reference-manifest.json +20 -0
  51. package/.next/server/app/_not-found/page.js +14 -0
  52. package/.next/server/app/_not-found/page.js.map +5 -0
  53. package/.next/server/app/_not-found/page.js.nft.json +1 -0
  54. package/.next/server/app/_not-found/page_client-reference-manifest.js +2 -0
  55. package/.next/server/app/favicon.ico/route/app-paths-manifest.json +3 -0
  56. package/.next/server/app/favicon.ico/route/build-manifest.json +11 -0
  57. package/.next/server/app/favicon.ico/route.js +6 -0
  58. package/.next/server/app/favicon.ico/route.js.map +5 -0
  59. package/.next/server/app/favicon.ico/route.js.nft.json +1 -0
  60. package/.next/server/app/favicon.ico.body +0 -0
  61. package/.next/server/app/favicon.ico.meta +1 -0
  62. package/.next/server/app/page/app-paths-manifest.json +3 -0
  63. package/.next/server/app/page/build-manifest.json +17 -0
  64. package/.next/server/app/page/next-font-manifest.json +16 -0
  65. package/.next/server/app/page/react-loadable-manifest.json +1 -0
  66. package/.next/server/app/page/server-reference-manifest.json +20 -0
  67. package/.next/server/app/page.js +17 -0
  68. package/.next/server/app/page.js.map +5 -0
  69. package/.next/server/app/page.js.nft.json +1 -0
  70. package/.next/server/app/page_client-reference-manifest.js +2 -0
  71. package/.next/server/app/preview/[...slug]/page/app-paths-manifest.json +3 -0
  72. package/.next/server/app/preview/[...slug]/page/build-manifest.json +17 -0
  73. package/.next/server/app/preview/[...slug]/page/next-font-manifest.json +16 -0
  74. package/.next/server/app/preview/[...slug]/page/react-loadable-manifest.json +1 -0
  75. package/.next/server/app/preview/[...slug]/page/server-reference-manifest.json +65 -0
  76. package/.next/server/app/preview/[...slug]/page.js +19 -0
  77. package/.next/server/app/preview/[...slug]/page.js.map +5 -0
  78. package/.next/server/app/preview/[...slug]/page.js.nft.json +1 -0
  79. package/.next/server/app/preview/[...slug]/page_client-reference-manifest.js +2 -0
  80. package/.next/server/app-paths-manifest.json +7 -0
  81. package/.next/server/chunks/730ea_preview-server__next-internal_server_app_favicon_ico_route_actions_a71a8ae7.js +3 -0
  82. package/.next/server/chunks/730ea_preview-server__next-internal_server_app_favicon_ico_route_actions_a71a8ae7.js.map +1 -0
  83. package/.next/server/chunks/[externals]_next_dist_a6d89067._.js +3 -0
  84. package/.next/server/chunks/[externals]_next_dist_a6d89067._.js.map +1 -0
  85. package/.next/server/chunks/[root-of-the-server]__a62cd78d._.js +21 -0
  86. package/.next/server/chunks/[root-of-the-server]__a62cd78d._.js.map +1 -0
  87. package/.next/server/chunks/[turbopack]_runtime.js +795 -0
  88. package/.next/server/chunks/[turbopack]_runtime.js.map +10 -0
  89. package/.next/server/chunks/ssr/730ea_preview-server__next-internal_server_app__global-error_page_actions_986e2de5.js +3 -0
  90. package/.next/server/chunks/ssr/730ea_preview-server__next-internal_server_app__global-error_page_actions_986e2de5.js.map +1 -0
  91. package/.next/server/chunks/ssr/[root-of-the-server]__025eaae9._.js +3 -0
  92. package/.next/server/chunks/ssr/[root-of-the-server]__025eaae9._.js.map +1 -0
  93. package/.next/server/chunks/ssr/[root-of-the-server]__1536282c._.js +4 -0
  94. package/.next/server/chunks/ssr/[root-of-the-server]__1536282c._.js.map +1 -0
  95. package/.next/server/chunks/ssr/[root-of-the-server]__15cf9d36._.js +3 -0
  96. package/.next/server/chunks/ssr/[root-of-the-server]__15cf9d36._.js.map +1 -0
  97. package/.next/server/chunks/ssr/[root-of-the-server]__450f653e._.js +3 -0
  98. package/.next/server/chunks/ssr/[root-of-the-server]__450f653e._.js.map +1 -0
  99. package/.next/server/chunks/ssr/[root-of-the-server]__4874d0d7._.js +3 -0
  100. package/.next/server/chunks/ssr/[root-of-the-server]__4874d0d7._.js.map +1 -0
  101. package/.next/server/chunks/ssr/[root-of-the-server]__49771cdc._.js +3 -0
  102. package/.next/server/chunks/ssr/[root-of-the-server]__49771cdc._.js.map +1 -0
  103. package/.next/server/chunks/ssr/[root-of-the-server]__9ff74047._.js +3 -0
  104. package/.next/server/chunks/ssr/[root-of-the-server]__9ff74047._.js.map +1 -0
  105. package/.next/server/chunks/ssr/[root-of-the-server]__a9be37b1._.js +3 -0
  106. package/.next/server/chunks/ssr/[root-of-the-server]__a9be37b1._.js.map +1 -0
  107. package/.next/server/chunks/ssr/[root-of-the-server]__aeefe74e._.js +3 -0
  108. package/.next/server/chunks/ssr/[root-of-the-server]__aeefe74e._.js.map +1 -0
  109. package/.next/server/chunks/ssr/[root-of-the-server]__b13738d2._.js +3 -0
  110. package/.next/server/chunks/ssr/[root-of-the-server]__b13738d2._.js.map +1 -0
  111. package/.next/server/chunks/ssr/[root-of-the-server]__bb428c83._.js +4 -0
  112. package/.next/server/chunks/ssr/[root-of-the-server]__bb428c83._.js.map +1 -0
  113. package/.next/server/chunks/ssr/[root-of-the-server]__c61333e3._.js +10 -0
  114. package/.next/server/chunks/ssr/[root-of-the-server]__c61333e3._.js.map +1 -0
  115. package/.next/server/chunks/ssr/[root-of-the-server]__cb0c7b1a._.js +4 -0
  116. package/.next/server/chunks/ssr/[root-of-the-server]__cb0c7b1a._.js.map +1 -0
  117. package/.next/server/chunks/ssr/[root-of-the-server]__dafcae4c._.js +3 -0
  118. package/.next/server/chunks/ssr/[root-of-the-server]__dafcae4c._.js.map +1 -0
  119. package/.next/server/chunks/ssr/[root-of-the-server]__e47d0c07._.js +3 -0
  120. package/.next/server/chunks/ssr/[root-of-the-server]__e47d0c07._.js.map +1 -0
  121. package/.next/server/chunks/ssr/[root-of-the-server]__ecac8617._.js +31 -0
  122. package/.next/server/chunks/ssr/[root-of-the-server]__ecac8617._.js.map +1 -0
  123. package/.next/server/chunks/ssr/[root-of-the-server]__fd4bda25._.js +3 -0
  124. package/.next/server/chunks/ssr/[root-of-the-server]__fd4bda25._.js.map +1 -0
  125. package/.next/server/chunks/ssr/[turbopack]_runtime.js +795 -0
  126. package/.next/server/chunks/ssr/[turbopack]_runtime.js.map +10 -0
  127. package/.next/server/chunks/ssr/_19494208._.js +19 -0
  128. package/.next/server/chunks/ssr/_19494208._.js.map +1 -0
  129. package/.next/server/chunks/ssr/_810f54e9._.js +4 -0
  130. package/.next/server/chunks/ssr/_810f54e9._.js.map +1 -0
  131. package/.next/server/chunks/ssr/_aa01e67e._.js +4 -0
  132. package/.next/server/chunks/ssr/_aa01e67e._.js.map +1 -0
  133. package/.next/server/chunks/ssr/_bf10718b._.js +4 -0
  134. package/.next/server/chunks/ssr/_bf10718b._.js.map +1 -0
  135. package/.next/server/chunks/ssr/_c57c12df._.js +4 -0
  136. package/.next/server/chunks/ssr/_c57c12df._.js.map +1 -0
  137. package/.next/server/chunks/ssr/_d9b57cb8._.js +5 -0
  138. package/.next/server/chunks/ssr/_d9b57cb8._.js.map +1 -0
  139. package/.next/server/chunks/ssr/_e2a766a8._.js +3 -0
  140. package/.next/server/chunks/ssr/_e2a766a8._.js.map +1 -0
  141. package/.next/server/chunks/ssr/_e2b86512._.js +8 -0
  142. package/.next/server/chunks/ssr/_e2b86512._.js.map +1 -0
  143. package/.next/server/chunks/ssr/_ee8ea3aa._.js +19 -0
  144. package/.next/server/chunks/ssr/_ee8ea3aa._.js.map +1 -0
  145. package/.next/server/chunks/ssr/e8449_next_dist_5870db32._.js +3 -0
  146. package/.next/server/chunks/ssr/e8449_next_dist_5870db32._.js.map +1 -0
  147. package/.next/server/chunks/ssr/e8449_next_dist_client_components_builtin_forbidden_5542069c.js +3 -0
  148. package/.next/server/chunks/ssr/e8449_next_dist_client_components_builtin_forbidden_5542069c.js.map +1 -0
  149. package/.next/server/chunks/ssr/e8449_next_dist_client_components_builtin_global-error_d0870f3a.js +3 -0
  150. package/.next/server/chunks/ssr/e8449_next_dist_client_components_builtin_global-error_d0870f3a.js.map +1 -0
  151. package/.next/server/chunks/ssr/e8449_next_dist_client_components_builtin_unauthorized_4c01c8d5.js +3 -0
  152. package/.next/server/chunks/ssr/e8449_next_dist_client_components_builtin_unauthorized_4c01c8d5.js.map +1 -0
  153. package/.next/server/chunks/ssr/e8449_next_dist_client_components_d90ace34._.js +3 -0
  154. package/.next/server/chunks/ssr/e8449_next_dist_client_components_d90ace34._.js.map +1 -0
  155. package/.next/server/chunks/ssr/e8449_next_dist_esm_af7aafb8._.js +6 -0
  156. package/.next/server/chunks/ssr/e8449_next_dist_esm_af7aafb8._.js.map +1 -0
  157. package/.next/server/chunks/ssr/e8449_next_dist_esm_build_templates_app-page_f16f0848.js +4 -0
  158. package/.next/server/chunks/ssr/e8449_next_dist_esm_build_templates_app-page_f16f0848.js.map +1 -0
  159. package/.next/server/chunks/ssr/e8449_next_dist_f0d8a2cc._.js +4 -0
  160. package/.next/server/chunks/ssr/e8449_next_dist_f0d8a2cc._.js.map +1 -0
  161. package/.next/server/chunks/ssr/node_modules__pnpm_37510d96._.js +5 -0
  162. package/.next/server/chunks/ssr/node_modules__pnpm_37510d96._.js.map +1 -0
  163. package/.next/server/chunks/ssr/packages_preview-server_src_app_897ecf1c._.js +3 -0
  164. package/.next/server/chunks/ssr/packages_preview-server_src_app_897ecf1c._.js.map +1 -0
  165. package/.next/server/chunks/ssr/packages_preview-server_src_e17a2a9b._.js +3 -0
  166. package/.next/server/chunks/ssr/packages_preview-server_src_e17a2a9b._.js.map +1 -0
  167. package/.next/server/functions-config-manifest.json +4 -0
  168. package/.next/server/interception-route-rewrite-manifest.js +1 -0
  169. package/.next/server/middleware-build-manifest.js +21 -0
  170. package/.next/server/middleware-manifest.json +6 -0
  171. package/.next/server/next-font-manifest.js +1 -0
  172. package/.next/server/next-font-manifest.json +34 -0
  173. package/.next/server/pages/500.html +2 -0
  174. package/.next/server/pages-manifest.json +3 -0
  175. package/.next/server/server-reference-manifest.js +1 -0
  176. package/.next/server/server-reference-manifest.json +80 -0
  177. package/.next/static/cdYIhKFtJ0GB-yJK5ywz_/_buildManifest.js +11 -0
  178. package/.next/static/cdYIhKFtJ0GB-yJK5ywz_/_clientMiddlewareManifest.json +1 -0
  179. package/.next/static/cdYIhKFtJ0GB-yJK5ywz_/_ssgManifest.js +1 -0
  180. package/.next/static/chunks/0464c7ff175ee6ff.js +1 -0
  181. package/.next/static/chunks/10468413db24762a.js +14 -0
  182. package/.next/static/chunks/2de338262e51ef94.js +3 -0
  183. package/.next/static/chunks/37adc260f85da877.js +1 -0
  184. package/.next/static/chunks/521eee9903bc4d1f.js +5 -0
  185. package/.next/static/chunks/6051bd38272cb442.js +14 -0
  186. package/.next/static/chunks/8d433d4b9d701456.js +1 -0
  187. package/.next/static/chunks/92ba72595aad9df6.js +1 -0
  188. package/.next/static/chunks/959ed978a6e89a66.js +1 -0
  189. package/.next/static/chunks/a6dad97d9634a72d.js +1 -0
  190. package/.next/static/chunks/a6dad97d9634a72d.js.map +1 -0
  191. package/.next/static/chunks/a6db6456c5b75734.js +1 -0
  192. package/.next/static/chunks/c3ece0a7e3e07076.js +1 -0
  193. package/.next/static/chunks/d1b29a74f6814a03.css +3 -0
  194. package/.next/static/chunks/f7ec22614fe1c1fe.js +1 -0
  195. package/.next/static/chunks/turbopack-e062a8e6d6034eb0.js +4 -0
  196. package/.next/static/media/1bffadaabf893a1e-s.7cd81963.woff2 +0 -0
  197. package/.next/static/media/2bbe8d2671613f1f-s.76dcb0b2.woff2 +0 -0
  198. package/.next/static/media/2c55a0e60120577a-s.2a48534a.woff2 +0 -0
  199. package/.next/static/media/5476f68d60460930-s.c995e352.woff2 +0 -0
  200. package/.next/static/media/83afe278b6a6bb3c-s.p.3a6ba036.woff2 +0 -0
  201. package/.next/static/media/9c72aa0f40e4eef8-s.18a48cbc.woff2 +0 -0
  202. package/.next/static/media/SFMonoBold-s.p.b90ec775.otf +0 -0
  203. package/.next/static/media/SFMonoHeavy-s.p.545fe93b.otf +0 -0
  204. package/.next/static/media/SFMonoLight-s.p.7c5363a6.otf +0 -0
  205. package/.next/static/media/SFMonoMedium-s.p.a4fc9904.otf +0 -0
  206. package/.next/static/media/SFMonoRegular-s.p.04ea7bf3.otf +0 -0
  207. package/.next/static/media/SFMonoSemibold-s.p.2d2ddb43.otf +0 -0
  208. package/.next/static/media/ad66f9afd8947f86-s.7a40eb73.woff2 +0 -0
  209. package/.next/static/media/favicon.678eb597.ico +0 -0
  210. package/.next/static/media/logo.22a370b0.png +0 -0
  211. package/.next/trace +1 -0
  212. package/.next/trace-build +1 -0
  213. package/.next/turbopack +0 -0
  214. package/.next/types/routes.d.ts +58 -0
  215. package/.next/types/validator.ts +70 -0
  216. package/CHANGELOG.md +12 -0
  217. package/LICENSE.md +8 -0
  218. package/index.mjs +17 -0
  219. package/jsx-runtime/jsx-dev-runtime.js +26 -0
  220. package/module-punycode.d.ts +3 -0
  221. package/next-env.d.ts +6 -0
  222. package/next.config.mjs +15 -0
  223. package/package.json +78 -0
  224. package/postcss.config.js +5 -0
  225. package/readme.md +33 -0
  226. package/scripts/build-preview-server.mts +25 -0
  227. package/scripts/dev.mts +57 -0
  228. package/scripts/seed.mts +36 -0
  229. package/src/actions/export-single-template.ts +74 -0
  230. package/src/actions/get-template-path-from-slug.ts +32 -0
  231. package/src/actions/get-templates-directory-metadata-action.ts +19 -0
  232. package/src/actions/render-template-by-path.tsx +313 -0
  233. package/src/actions/safe-action.ts +15 -0
  234. package/src/animated-icons-data/help.json +1082 -0
  235. package/src/animated-icons-data/link.json +1309 -0
  236. package/src/animated-icons-data/load.json +443 -0
  237. package/src/animated-icons-data/mail.json +1320 -0
  238. package/src/app/env.ts +14 -0
  239. package/src/app/favicon.ico +0 -0
  240. package/src/app/fonts/SFMono/SFMonoBold.otf +0 -0
  241. package/src/app/fonts/SFMono/SFMonoBoldItalic.otf +0 -0
  242. package/src/app/fonts/SFMono/SFMonoHeavy.otf +0 -0
  243. package/src/app/fonts/SFMono/SFMonoHeavyItalic.otf +0 -0
  244. package/src/app/fonts/SFMono/SFMonoLight.otf +0 -0
  245. package/src/app/fonts/SFMono/SFMonoLightItalic.otf +0 -0
  246. package/src/app/fonts/SFMono/SFMonoMedium.otf +0 -0
  247. package/src/app/fonts/SFMono/SFMonoMediumItalic.otf +0 -0
  248. package/src/app/fonts/SFMono/SFMonoRegular.otf +0 -0
  249. package/src/app/fonts/SFMono/SFMonoRegularItalic.otf +0 -0
  250. package/src/app/fonts/SFMono/SFMonoSemibold.otf +0 -0
  251. package/src/app/fonts/SFMono/SFMonoSemiboldItalic.otf +0 -0
  252. package/src/app/fonts.ts +39 -0
  253. package/src/app/globals.css +136 -0
  254. package/src/app/layout.tsx +46 -0
  255. package/src/app/logo.png +0 -0
  256. package/src/app/page.tsx +52 -0
  257. package/src/app/preview/[...slug]/download-button.tsx +138 -0
  258. package/src/app/preview/[...slug]/error-overlay.tsx +58 -0
  259. package/src/app/preview/[...slug]/page.tsx +90 -0
  260. package/src/app/preview/[...slug]/preview.tsx +249 -0
  261. package/src/app/preview/[...slug]/template-frame.tsx +68 -0
  262. package/src/components/button.tsx +101 -0
  263. package/src/components/code-container.tsx +169 -0
  264. package/src/components/code-snippet.tsx +9 -0
  265. package/src/components/code.tsx +185 -0
  266. package/src/components/heading.tsx +113 -0
  267. package/src/components/icons/icon-arrow-down.tsx +16 -0
  268. package/src/components/icons/icon-base.tsx +26 -0
  269. package/src/components/icons/icon-bug.tsx +19 -0
  270. package/src/components/icons/icon-button.tsx +23 -0
  271. package/src/components/icons/icon-check.tsx +19 -0
  272. package/src/components/icons/icon-clipboard.tsx +40 -0
  273. package/src/components/icons/icon-cloud-alert.tsx +18 -0
  274. package/src/components/icons/icon-cloud-check.tsx +17 -0
  275. package/src/components/icons/icon-download.tsx +19 -0
  276. package/src/components/icons/icon-file.tsx +19 -0
  277. package/src/components/icons/icon-folder-open.tsx +19 -0
  278. package/src/components/icons/icon-folder.tsx +18 -0
  279. package/src/components/icons/icon-hide-sidebar.tsx +23 -0
  280. package/src/components/icons/icon-image.tsx +19 -0
  281. package/src/components/icons/icon-info.tsx +18 -0
  282. package/src/components/icons/icon-link.tsx +14 -0
  283. package/src/components/icons/icon-loader.tsx +16 -0
  284. package/src/components/icons/icon-monitor.tsx +19 -0
  285. package/src/components/icons/icon-moon.tsx +16 -0
  286. package/src/components/icons/icon-phone.tsx +26 -0
  287. package/src/components/icons/icon-reload.tsx +18 -0
  288. package/src/components/icons/icon-source.tsx +19 -0
  289. package/src/components/icons/icon-stamp.tsx +14 -0
  290. package/src/components/icons/icon-sun.tsx +74 -0
  291. package/src/components/icons/icon-warning.tsx +31 -0
  292. package/src/components/index.ts +7 -0
  293. package/src/components/logo.tsx +41 -0
  294. package/src/components/resizable-wrapper.tsx +269 -0
  295. package/src/components/shell.tsx +95 -0
  296. package/src/components/sidebar/file-tree-directory-children.tsx +142 -0
  297. package/src/components/sidebar/file-tree-directory.tsx +92 -0
  298. package/src/components/sidebar/file-tree.tsx +31 -0
  299. package/src/components/sidebar/index.ts +1 -0
  300. package/src/components/sidebar/sidebar.tsx +46 -0
  301. package/src/components/text.tsx +99 -0
  302. package/src/components/toolbar/checking-results.tsx +150 -0
  303. package/src/components/toolbar/code-preview-line-link.tsx +39 -0
  304. package/src/components/toolbar/results-table.tsx +0 -0
  305. package/src/components/toolbar/results.tsx +52 -0
  306. package/src/components/toolbar/toolbar-button.tsx +52 -0
  307. package/src/components/toolbar/use-cached-state.ts +36 -0
  308. package/src/components/toolbar.tsx +182 -0
  309. package/src/components/tooltip-content.tsx +31 -0
  310. package/src/components/tooltip.tsx +19 -0
  311. package/src/components/topbar/active-view-toggle-group.tsx +86 -0
  312. package/src/components/topbar/emulated-dark-mode-toggle.tsx +58 -0
  313. package/src/components/topbar/view-size-controls.tsx +173 -0
  314. package/src/components/topbar.tsx +59 -0
  315. package/src/contexts/preview.tsx +91 -0
  316. package/src/contexts/templates.tsx +57 -0
  317. package/src/contexts/toolbar.tsx +22 -0
  318. package/src/hooks/use-clamped-state.ts +24 -0
  319. package/src/hooks/use-fragment-identifier.ts +14 -0
  320. package/src/hooks/use-hot-reload.ts +31 -0
  321. package/src/hooks/use-rendering-metadata.ts +37 -0
  322. package/src/hooks/use-template-rendering-result.ts +58 -0
  323. package/src/utils/cn.ts +6 -0
  324. package/src/utils/constants.ts +8 -0
  325. package/src/utils/contains-template.ts +52 -0
  326. package/src/utils/convert-stack-with-sourcemap.ts +79 -0
  327. package/src/utils/copy-text-to-clipboard.ts +7 -0
  328. package/src/utils/create-jsx-runtime.ts +47 -0
  329. package/src/utils/esbuild/escape-string-for-regex.ts +3 -0
  330. package/src/utils/esbuild/renderring-utilities-exporter.ts +64 -0
  331. package/src/utils/get-line-and-column-from-offset.ts +11 -0
  332. package/src/utils/get-template-component.ts +158 -0
  333. package/src/utils/get-templates-directory-metadata.ts +195 -0
  334. package/src/utils/index.ts +6 -0
  335. package/src/utils/language-map.ts +7 -0
  336. package/src/utils/load-stream.ts +15 -0
  337. package/src/utils/register-spinner-autostopping.ts +28 -0
  338. package/src/utils/result.ts +49 -0
  339. package/src/utils/run-bundled-code.ts +86 -0
  340. package/src/utils/sanitize.ts +6 -0
  341. package/src/utils/sleep.ts +3 -0
  342. package/src/utils/snake-to-camel.ts +5 -0
  343. package/src/utils/static-node-modules-for-vm.ts +93 -0
  344. package/src/utils/style-text.ts +11 -0
  345. package/src/utils/types/as.ts +26 -0
  346. package/src/utils/types/error-object.ts +11 -0
  347. package/src/utils/types/hot-reload-change.ts +13 -0
  348. package/src/utils/types/template.ts +8 -0
  349. package/src/utils/unreachable.ts +8 -0
  350. package/templates/.gitkeep +0 -0
  351. package/tsconfig.json +47 -0
@@ -0,0 +1,158 @@
1
+ import path from 'node:path';
2
+ import type { render } from '@ahmedrowaihi/pdf-forge-components';
3
+ import { type BuildFailure, build, type OutputFile } from 'esbuild';
4
+ import type React from 'react';
5
+ import type { RawSourceMap } from 'source-map-js';
6
+ import { z } from 'zod';
7
+ import { convertStackWithSourceMap } from './convert-stack-with-sourcemap';
8
+ import { renderingUtilitiesExporter } from './esbuild/renderring-utilities-exporter';
9
+ import { isErr } from './result';
10
+ import { createContext, runBundledCode } from './run-bundled-code';
11
+ import type { ErrorObject } from './types/error-object';
12
+ import type { Template as TemplateComponent } from './types/template';
13
+
14
+ const TemplateComponentModule = z.object({
15
+ default: z.any(),
16
+ render: z.function(),
17
+ reactPDFCreateReactElement: z.function(),
18
+ });
19
+
20
+ export const getTemplateComponent = async (
21
+ templatePath: string,
22
+ jsxRuntimePath: string,
23
+ ): Promise<
24
+ | {
25
+ templateComponent: TemplateComponent;
26
+
27
+ createElement: typeof React.createElement;
28
+
29
+ /**
30
+ * Renders the HTML with `data-source-file`/`data-source-line` attributes that should only be
31
+ * used internally in the preview server and never shown to the user.
32
+ */
33
+ renderWithReferences: typeof render;
34
+ render: typeof render;
35
+
36
+ sourceMapToOriginalFile: RawSourceMap;
37
+ }
38
+ | { error: ErrorObject }
39
+ > => {
40
+ let outputFiles: OutputFile[];
41
+ try {
42
+ const buildData = await build({
43
+ bundle: true,
44
+ entryPoints: [templatePath],
45
+ plugins: [renderingUtilitiesExporter([templatePath])],
46
+ platform: 'node',
47
+ write: false,
48
+
49
+ jsxDev: true,
50
+ jsxImportSource: jsxRuntimePath,
51
+
52
+ format: 'cjs',
53
+ jsx: 'automatic',
54
+ logLevel: 'silent',
55
+ // allows for using jsx on a .js file
56
+ loader: {
57
+ '.js': 'jsx',
58
+ },
59
+ outdir: 'stdout', // just a stub for esbuild, it won't actually write to this folder
60
+ sourcemap: 'external',
61
+ });
62
+ outputFiles = buildData.outputFiles;
63
+ } catch (exception) {
64
+ const buildFailure = exception as BuildFailure;
65
+ return {
66
+ error: {
67
+ message: buildFailure.message,
68
+ stack: buildFailure.stack,
69
+ name: buildFailure.name,
70
+ cause: buildFailure.cause,
71
+ },
72
+ };
73
+ }
74
+
75
+ const sourceMapFile = outputFiles[0]!;
76
+ const bundledTemplateFile = outputFiles[1]!;
77
+ const builtTemplateCode = bundledTemplateFile.text;
78
+
79
+ const sourceMapToTemplate = JSON.parse(sourceMapFile.text) as RawSourceMap;
80
+ // because it will have a path like <tsconfigLocation>/stdout/template.js.map
81
+ sourceMapToTemplate.sourceRoot = path.resolve(sourceMapFile.path, '../..');
82
+ sourceMapToTemplate.sources = sourceMapToTemplate.sources.map((source) =>
83
+ path.resolve(sourceMapFile.path, '..', source),
84
+ );
85
+
86
+ const context = createContext(templatePath);
87
+ context.shouldIncludeSourceReference = false;
88
+ const runningResult = runBundledCode(
89
+ builtTemplateCode,
90
+ templatePath,
91
+ context,
92
+ );
93
+
94
+ if (isErr(runningResult)) {
95
+ const { error } = runningResult;
96
+ if (error instanceof Error) {
97
+ error.stack &&= error.stack.split('at Script.runInContext (node:vm')[0];
98
+
99
+ return {
100
+ error: {
101
+ name: error.name,
102
+ message: error.message,
103
+ stack: convertStackWithSourceMap(
104
+ error.stack,
105
+ templatePath,
106
+ sourceMapToTemplate,
107
+ ),
108
+ cause: error.cause,
109
+ },
110
+ };
111
+ }
112
+
113
+ throw error;
114
+ }
115
+
116
+ const parseResult = TemplateComponentModule.safeParse(runningResult.value);
117
+
118
+ if (parseResult.error) {
119
+ return {
120
+ error: {
121
+ name: 'Error',
122
+ message: `The template component at ${templatePath} does not contain the expected exports`,
123
+ stack: new Error().stack,
124
+ cause: parseResult.error,
125
+ },
126
+ };
127
+ }
128
+
129
+ if (typeof parseResult.data.default !== 'function') {
130
+ return {
131
+ error: {
132
+ name: 'Error',
133
+ message: `The template component at ${templatePath} does not contain a default exported function`,
134
+ stack: new Error().stack,
135
+ cause: parseResult.error,
136
+ },
137
+ };
138
+ }
139
+
140
+ const { data: componentModule } = parseResult;
141
+
142
+ const typedRender = componentModule.render as typeof render;
143
+
144
+ return {
145
+ templateComponent: componentModule.default as TemplateComponent,
146
+ renderWithReferences: (async (...args: Parameters<typeof render>) => {
147
+ context.shouldIncludeSourceReference = true;
148
+ const renderingResult = await typedRender(...args);
149
+ context.shouldIncludeSourceReference = false;
150
+ return renderingResult;
151
+ }) as typeof render,
152
+ render: typedRender,
153
+ createElement:
154
+ componentModule.reactPDFCreateReactElement as typeof React.createElement,
155
+
156
+ sourceMapToOriginalFile: sourceMapToTemplate,
157
+ };
158
+ };
@@ -0,0 +1,195 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ const isFileATemplate = async (fullPath: string): Promise<boolean> => {
5
+ let fileHandle: fs.promises.FileHandle;
6
+ try {
7
+ fileHandle = await fs.promises.open(fullPath, 'r');
8
+ } catch (exception) {
9
+ console.warn(exception);
10
+ return false;
11
+ }
12
+ const stat = await fileHandle.stat();
13
+
14
+ if (stat.isDirectory()) {
15
+ await fileHandle.close();
16
+ return false;
17
+ }
18
+
19
+ const { ext } = path.parse(fullPath);
20
+
21
+ if (!['.js', '.tsx', '.jsx'].includes(ext)) {
22
+ await fileHandle.close();
23
+ return false;
24
+ }
25
+
26
+ const fileContents = await fileHandle.readFile('utf8');
27
+
28
+ await fileHandle.close();
29
+
30
+ const hasES6DefaultExport = /\bexport\s+default\b/gm.test(fileContents);
31
+
32
+ const hasCommonJSExport = /\bmodule\.exports\s*=/gm.test(fileContents);
33
+
34
+ const hasNamedExport = /\bexport\s+\{[^}]*\bdefault\b[^}]*\}/gm.test(
35
+ fileContents,
36
+ );
37
+
38
+ return hasES6DefaultExport || hasCommonJSExport || hasNamedExport;
39
+ };
40
+
41
+ export interface TemplatesDirectory {
42
+ absolutePath: string;
43
+ relativePath: string;
44
+ directoryName: string;
45
+ templateFilenames: string[];
46
+ subDirectories: TemplatesDirectory[];
47
+ }
48
+
49
+ const directoryContainsTemplates = async (
50
+ directoryPath: string,
51
+ ): Promise<boolean> => {
52
+ try {
53
+ const dirents = await fs.promises.readdir(directoryPath, {
54
+ withFileTypes: true,
55
+ });
56
+
57
+ const visibleDirents = dirents.filter(
58
+ (dirent) => !dirent.name.startsWith('.'),
59
+ );
60
+
61
+ const fileTemplateChecks = await Promise.all(
62
+ visibleDirents
63
+ .filter((dirent) => dirent.isFile())
64
+ .map((dirent) =>
65
+ isFileATemplate(path.join(directoryPath, dirent.name)),
66
+ ),
67
+ );
68
+
69
+ if (fileTemplateChecks.some((isTemplate) => isTemplate)) {
70
+ return true;
71
+ }
72
+
73
+ const subDirectoryChecks = await Promise.all(
74
+ visibleDirents
75
+ .filter(
76
+ (dirent) =>
77
+ dirent.isDirectory() &&
78
+ !dirent.name.startsWith('_') &&
79
+ dirent.name !== 'static',
80
+ )
81
+ .map((dirent) =>
82
+ directoryContainsTemplates(path.join(directoryPath, dirent.name)),
83
+ ),
84
+ );
85
+
86
+ return subDirectoryChecks.some((hasTemplates) => hasTemplates);
87
+ } catch {
88
+ return false;
89
+ }
90
+ };
91
+
92
+ const mergeDirectoriesWithSubDirectories = (
93
+ templatesDirectoryMetadata: TemplatesDirectory,
94
+ ): TemplatesDirectory => {
95
+ let currentResultingMergedDirectory: TemplatesDirectory =
96
+ templatesDirectoryMetadata;
97
+
98
+ while (
99
+ currentResultingMergedDirectory.templateFilenames.length === 0 &&
100
+ currentResultingMergedDirectory.subDirectories.length === 1
101
+ ) {
102
+ const onlySubDirectory = currentResultingMergedDirectory.subDirectories[0]!;
103
+ currentResultingMergedDirectory = {
104
+ ...onlySubDirectory,
105
+ directoryName: path.join(
106
+ currentResultingMergedDirectory.directoryName,
107
+ onlySubDirectory.directoryName,
108
+ ),
109
+ };
110
+ }
111
+
112
+ return currentResultingMergedDirectory;
113
+ };
114
+
115
+ export const getTemplatesDirectoryMetadata = async (
116
+ absolutePathToTemplatesDirectory: string,
117
+ keepFileExtensions = false,
118
+ isSubDirectory = false,
119
+
120
+ baseDirectoryPath = absolutePathToTemplatesDirectory,
121
+ ): Promise<TemplatesDirectory | undefined> => {
122
+ if (!fs.existsSync(absolutePathToTemplatesDirectory)) return;
123
+
124
+ const dirents = await fs.promises.readdir(absolutePathToTemplatesDirectory, {
125
+ withFileTypes: true,
126
+ });
127
+
128
+ const visibleDirents = dirents.filter(
129
+ (dirent) => !dirent.name.startsWith('.'),
130
+ );
131
+
132
+ const isTemplatePredicates = await Promise.all(
133
+ visibleDirents.map((dirent) =>
134
+ isFileATemplate(path.join(absolutePathToTemplatesDirectory, dirent.name)),
135
+ ),
136
+ );
137
+ const templateFilenames = visibleDirents
138
+ .filter((_, i) => isTemplatePredicates[i])
139
+ .map((dirent) =>
140
+ keepFileExtensions
141
+ ? dirent.name
142
+ : dirent.name.replace(path.extname(dirent.name), ''),
143
+ );
144
+
145
+ const directoryCandidates = visibleDirents.filter(
146
+ (dirent) =>
147
+ dirent.isDirectory() &&
148
+ !dirent.name.startsWith('_') &&
149
+ dirent.name !== 'static',
150
+ );
151
+
152
+ const directoriesWithTemplates = await Promise.all(
153
+ directoryCandidates.map(async (dirent) => {
154
+ const direntAbsolutePath = path.join(
155
+ absolutePathToTemplatesDirectory,
156
+ dirent.name,
157
+ );
158
+ const hasTemplates = await directoryContainsTemplates(direntAbsolutePath);
159
+ return { dirent, hasTemplates };
160
+ }),
161
+ );
162
+
163
+ const subDirectories = await Promise.all(
164
+ directoriesWithTemplates
165
+ .filter(({ hasTemplates }) => hasTemplates)
166
+ .map(({ dirent }) => {
167
+ const direntAbsolutePath = path.join(
168
+ absolutePathToTemplatesDirectory,
169
+ dirent.name,
170
+ );
171
+
172
+ return getTemplatesDirectoryMetadata(
173
+ direntAbsolutePath,
174
+ keepFileExtensions,
175
+ true,
176
+ baseDirectoryPath,
177
+ ) as Promise<TemplatesDirectory>;
178
+ }),
179
+ );
180
+
181
+ const templatesMetadata = {
182
+ absolutePath: absolutePathToTemplatesDirectory,
183
+ relativePath: path.relative(
184
+ baseDirectoryPath,
185
+ absolutePathToTemplatesDirectory,
186
+ ),
187
+ directoryName: absolutePathToTemplatesDirectory.split(path.sep).pop()!,
188
+ templateFilenames,
189
+ subDirectories,
190
+ } satisfies TemplatesDirectory;
191
+
192
+ return isSubDirectory
193
+ ? mergeDirectoriesWithSubDirectories(templatesMetadata)
194
+ : templatesMetadata;
195
+ };
@@ -0,0 +1,6 @@
1
+ export * from './cn';
2
+ export * from './copy-text-to-clipboard';
3
+ export * from './language-map';
4
+ export * from './sanitize';
5
+ export * from './types/as';
6
+ export * from './unreachable';
@@ -0,0 +1,7 @@
1
+ const languageMap = {
2
+ tsx: 'React',
3
+ html: 'HTML',
4
+ markdown: 'Plain Text',
5
+ };
6
+
7
+ export default languageMap;
@@ -0,0 +1,15 @@
1
+ export async function* loadStream<T>(stream: ReadableStream<T>) {
2
+ const reader = stream.getReader();
3
+ try {
4
+ while (true) {
5
+ const { value, done } = await reader.read();
6
+ if (done) {
7
+ break;
8
+ }
9
+
10
+ yield value;
11
+ }
12
+ } finally {
13
+ reader.releaseLock();
14
+ }
15
+ }
@@ -0,0 +1,28 @@
1
+ import logSymbols from 'log-symbols';
2
+ import type { Ora } from 'ora';
3
+
4
+ const spinners = new Set<Ora>();
5
+
6
+ process.on('SIGINT', () => {
7
+ spinners.forEach((spinner) => {
8
+ if (spinner.isSpinning) {
9
+ spinner.stop();
10
+ }
11
+ });
12
+ });
13
+
14
+ process.on('exit', (code) => {
15
+ if (code !== 0) {
16
+ spinners.forEach((spinner) => {
17
+ if (spinner.isSpinning) {
18
+ spinner.stopAndPersist({
19
+ symbol: logSymbols.error,
20
+ });
21
+ }
22
+ });
23
+ }
24
+ });
25
+
26
+ export const registerSpinnerAutostopping = (spinner: Ora) => {
27
+ spinners.add(spinner);
28
+ };
@@ -0,0 +1,49 @@
1
+ type Ok<T, _E> = {
2
+ value: T;
3
+ };
4
+ type Error<_T, E> = {
5
+ error: E;
6
+ };
7
+
8
+ /**
9
+ * Do not destructure this object, it is meant to have all fields together
10
+ * in the same object
11
+ */
12
+ export type Result<T, E> = Ok<T, E> | Error<T, E>;
13
+
14
+ export function isErr<T, E>(result: Result<T, E>): result is Error<T, E> {
15
+ return 'error' in result;
16
+ }
17
+
18
+ export function isOk<T, E>(result: Result<T, E>): result is Ok<T, E> {
19
+ return 'value' in result && !('error' in result);
20
+ }
21
+
22
+ export function mapResult<T, E, B>(
23
+ result: Result<T, E>,
24
+ callback: (value: T) => B,
25
+ ): Result<B, E> {
26
+ if (isOk(result)) {
27
+ return ok(callback(result.value));
28
+ }
29
+
30
+ return result;
31
+ }
32
+
33
+ export function ok<T, E>(value: NoInfer<T>): Ok<T, E>;
34
+ // biome-ignore lint/suspicious/noConfusingVoidType: This is required for void return types on functions that can still error
35
+ export function ok<_T extends void = void, E = never>(value: void): Ok<void, E>;
36
+ export function ok<T, E>(value: NoInfer<T>): Ok<T, E> {
37
+ return {
38
+ value,
39
+ };
40
+ }
41
+
42
+ export function err<T, E>(error: NoInfer<E>): Error<T, E>;
43
+ // biome-ignore lint/suspicious/noConfusingVoidType: This is required for void return types on functions that can still error
44
+ export function err<T, _E extends void = void>(error: void): Error<T, void>;
45
+ export function err<T, E>(error: NoInfer<E>): Error<T, E> {
46
+ return {
47
+ error,
48
+ };
49
+ }
@@ -0,0 +1,86 @@
1
+ import path from 'node:path';
2
+ import vm from 'node:vm';
3
+ import { err, ok, type Result } from './result';
4
+ import { staticNodeModulesForVM } from './static-node-modules-for-vm';
5
+
6
+ export const createContext = (filename: string): vm.Context => {
7
+ return new Proxy(
8
+ {
9
+ module: {
10
+ exports: {},
11
+ },
12
+ __filename: filename,
13
+ __dirname: path.dirname(filename),
14
+ require: (specifiedModule: string) => {
15
+ let m = specifiedModule;
16
+ if (specifiedModule.startsWith('node:')) {
17
+ m = m.split(':')[1]!;
18
+ }
19
+
20
+ if (m in staticNodeModulesForVM) {
21
+ return staticNodeModulesForVM[m];
22
+ }
23
+
24
+ return require(`${specifiedModule}`) as unknown;
25
+ // this string templating was necessary to not have
26
+ // webpack warnings like:
27
+ //
28
+ // Import trace for requested module:
29
+ // ./src/utils/get-template-component.tsx
30
+ // ./src/app/page.tsx
31
+ // ⚠ ./src/utils/get-template-component.tsx
32
+ // Critical dependency: the request of a dependency is an expression
33
+ },
34
+ },
35
+ {
36
+ get(target, property: string) {
37
+ if (property in target) {
38
+ return target[property];
39
+ }
40
+
41
+ return globalThis[property as keyof typeof globalThis];
42
+ },
43
+ has(target, property: string) {
44
+ return property in target || property in globalThis;
45
+ },
46
+ set(target, property, value) {
47
+ target[property] = value;
48
+ return true;
49
+ },
50
+ getOwnPropertyDescriptor(target, property) {
51
+ return (
52
+ Object.getOwnPropertyDescriptor(target, property) ??
53
+ Object.getOwnPropertyDescriptor(globalThis, property)
54
+ );
55
+ },
56
+ ownKeys(target) {
57
+ const keys = new Set([
58
+ ...Reflect.ownKeys(globalThis),
59
+ ...Reflect.ownKeys(target),
60
+ ]);
61
+ return Array.from(keys);
62
+ },
63
+ defineProperty(target, property, descriptor) {
64
+ Object.defineProperty(target, property, descriptor);
65
+ return true;
66
+ },
67
+ deleteProperty(target, property) {
68
+ return delete target[property];
69
+ },
70
+ },
71
+ );
72
+ };
73
+
74
+ export const runBundledCode = (
75
+ code: string,
76
+ filename: string,
77
+ fakeContext: vm.Context = createContext(filename),
78
+ ): Result<unknown, unknown> => {
79
+ try {
80
+ vm.runInNewContext(code, fakeContext, { filename });
81
+ } catch (exception) {
82
+ return err(exception);
83
+ }
84
+
85
+ return ok(fakeContext.module.exports as unknown);
86
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Sanitizes text by replacing underscores and hyphens with spaces
3
+ */
4
+ export const sanitize = (text: string): string => {
5
+ return text.replace(/[_-]/g, ' ');
6
+ };
@@ -0,0 +1,3 @@
1
+ export function sleep(ms: number) {
2
+ return new Promise((resolve) => setTimeout(resolve, ms));
3
+ }
@@ -0,0 +1,5 @@
1
+ export function snakeToCamel(snakeStr: string) {
2
+ return snakeStr
3
+ .toLowerCase()
4
+ .replace(/-+([a-z])/g, (_match, letter) => letter.toUpperCase());
5
+ }
@@ -0,0 +1,93 @@
1
+ import assert from 'node:assert';
2
+ import asyncHooks from 'node:async_hooks';
3
+ import buffer from 'node:buffer';
4
+ import childProcess from 'node:child_process';
5
+ import cluster from 'node:cluster';
6
+ import console from 'node:console';
7
+ import constants from 'node:constants';
8
+ import crypto from 'node:crypto';
9
+ import dgram from 'node:dgram';
10
+ import diagnosticsChannel from 'node:diagnostics_channel';
11
+ import dns from 'node:dns';
12
+ import domain from 'node:domain';
13
+ import events from 'node:events';
14
+ import fs from 'node:fs';
15
+ import fsPromises from 'node:fs/promises';
16
+ import http from 'node:http';
17
+ import http2 from 'node:http2';
18
+ import https from 'node:https';
19
+ import inspector from 'node:inspector';
20
+ import module from 'node:module';
21
+ import net from 'node:net';
22
+ import os from 'node:os';
23
+ import path from 'node:path';
24
+ import perfHooks from 'node:perf_hooks';
25
+ import process from 'node:process';
26
+ import querystring from 'node:querystring';
27
+ import readline from 'node:readline';
28
+ import repl from 'node:repl';
29
+ import stream from 'node:stream';
30
+ import stringDecoder from 'node:string_decoder';
31
+ import timers from 'node:timers';
32
+ import timersPromises from 'node:timers/promises';
33
+ import tls from 'node:tls';
34
+ import tty from 'node:tty';
35
+ import url from 'node:url';
36
+ import util from 'node:util';
37
+ import utilTypes from 'node:util/types';
38
+ import v8 from 'node:v8';
39
+ import vm from 'node:vm';
40
+ import workerThreads from 'node:worker_threads';
41
+ import zlib from 'node:zlib';
42
+ // Static node modules for VM context
43
+ import punycode from 'module-punycode';
44
+
45
+ /**
46
+ * A map of the name of the modules (including `node:` prefixed ones)
47
+ * provided by Node because dynamic requires of them, even on the server
48
+ * will not be resolved properly
49
+ */
50
+ export const staticNodeModulesForVM = {
51
+ assert,
52
+ async_hooks: asyncHooks,
53
+ buffer,
54
+ child_process: childProcess,
55
+ cluster,
56
+ console,
57
+ constants,
58
+ crypto,
59
+ dgram,
60
+ diagnostics_channel: diagnosticsChannel,
61
+ dns,
62
+ domain,
63
+ events,
64
+ fs,
65
+ 'fs/promises': fsPromises,
66
+ http,
67
+ http2,
68
+ https,
69
+ inspector,
70
+ module,
71
+ net,
72
+ os,
73
+ path,
74
+ perf_hooks: perfHooks,
75
+ process,
76
+ punycode,
77
+ querystring,
78
+ readline,
79
+ repl,
80
+ stream,
81
+ string_decoder: stringDecoder,
82
+ timers,
83
+ 'timers/promises': timersPromises,
84
+ tls,
85
+ tty,
86
+ url,
87
+ util,
88
+ 'util/types': utilTypes,
89
+ v8,
90
+ vm,
91
+ worker_threads: workerThreads,
92
+ zlib,
93
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Centralized fallback for Node versions (<20.12.0) without util.styleText.
3
+ * Returns the original text when styleText is unavailable.
4
+ */
5
+ import * as nodeUtil from 'node:util';
6
+
7
+ type StyleTextFunction = (style: string, text: string) => string;
8
+
9
+ export const styleText: StyleTextFunction = (nodeUtil as any).styleText
10
+ ? (nodeUtil as any).styleText
11
+ : (_: string, text: string) => text;
@@ -0,0 +1,26 @@
1
+ export type As<
2
+ DefaultTag extends React.ElementType,
3
+ T1 extends React.ElementType,
4
+ T2 extends React.ElementType = T1,
5
+ T3 extends React.ElementType = T1,
6
+ T4 extends React.ElementType = T1,
7
+ T5 extends React.ElementType = T1,
8
+ > =
9
+ | (React.ComponentPropsWithRef<DefaultTag> & {
10
+ as?: DefaultTag;
11
+ })
12
+ | (React.ComponentPropsWithRef<T1> & {
13
+ as: T1;
14
+ })
15
+ | (React.ComponentPropsWithRef<T2> & {
16
+ as: T2;
17
+ })
18
+ | (React.ComponentPropsWithRef<T3> & {
19
+ as: T3;
20
+ })
21
+ | (React.ComponentPropsWithRef<T4> & {
22
+ as: T4;
23
+ })
24
+ | (React.ComponentPropsWithRef<T5> & {
25
+ as: T5;
26
+ });