eddev 2.0.0-beta.21 → 2.0.0-beta.211

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 (458) hide show
  1. package/css/editor-styles.css +4 -0
  2. package/dist/app/entry/HydrationOverlay.d.ts +2 -0
  3. package/dist/app/entry/HydrationOverlay.d.ts.map +1 -0
  4. package/dist/app/entry/HydrationOverlay.js +2 -0
  5. package/dist/app/entry/MetaTags.d.ts +8 -0
  6. package/dist/app/entry/MetaTags.d.ts.map +1 -0
  7. package/dist/app/entry/MetaTags.js +30 -0
  8. package/dist/app/entry/boot-admin.d.ts +1 -0
  9. package/dist/app/entry/boot-admin.d.ts.map +1 -0
  10. package/dist/app/entry/boot-admin.js +7 -3
  11. package/dist/app/entry/hydration-script.d.ts +2 -0
  12. package/dist/app/entry/hydration-script.d.ts.map +1 -0
  13. package/dist/app/entry/hydration-script.js +18 -0
  14. package/dist/app/entry/spa-root.d.ts +1 -0
  15. package/dist/app/entry/spa-root.d.ts.map +1 -0
  16. package/dist/app/entry/spa-root.js +3 -5
  17. package/dist/app/entry/ssr-root-client.d.ts +4 -1
  18. package/dist/app/entry/ssr-root-client.d.ts.map +1 -0
  19. package/dist/app/entry/ssr-root-client.js +18 -6
  20. package/dist/app/entry/ssr-root.d.ts +6 -4
  21. package/dist/app/entry/ssr-root.d.ts.map +1 -0
  22. package/dist/app/entry/ssr-root.js +20 -19
  23. package/dist/app/lib/admin/defineField.d.ts +1 -0
  24. package/dist/app/lib/admin/defineField.d.ts.map +1 -0
  25. package/dist/app/lib/admin/defineWidget.d.ts +1 -0
  26. package/dist/app/lib/admin/defineWidget.d.ts.map +1 -0
  27. package/dist/app/lib/admin/index.d.ts +1 -0
  28. package/dist/app/lib/admin/index.d.ts.map +1 -0
  29. package/dist/app/lib/admin/installFieldTypes.d.ts +1 -0
  30. package/dist/app/lib/admin/installFieldTypes.d.ts.map +1 -0
  31. package/dist/app/lib/admin/installFieldTypes.js +2 -0
  32. package/dist/app/lib/admin/runWidgets.d.ts +1 -0
  33. package/dist/app/lib/admin/runWidgets.d.ts.map +1 -0
  34. package/dist/app/lib/admin/runWidgets.js +7 -2
  35. package/dist/app/lib/blocks/ContentBlocks.d.ts +7 -4
  36. package/dist/app/lib/blocks/ContentBlocks.d.ts.map +1 -0
  37. package/dist/app/lib/blocks/ContentBlocks.js +16 -3
  38. package/dist/app/lib/blocks/EditableText.d.ts +30 -5
  39. package/dist/app/lib/blocks/EditableText.d.ts.map +1 -0
  40. package/dist/app/lib/blocks/EditableText.js +34 -5
  41. package/dist/app/lib/blocks/InnerBlocks.d.ts +21 -6
  42. package/dist/app/lib/blocks/InnerBlocks.d.ts.map +1 -0
  43. package/dist/app/lib/blocks/InnerBlocks.js +73 -25
  44. package/dist/app/lib/blocks/SlotBlocks.d.ts +8 -0
  45. package/dist/app/lib/blocks/SlotBlocks.d.ts.map +1 -0
  46. package/dist/app/lib/blocks/SlotBlocks.js +46 -0
  47. package/dist/app/lib/blocks/block-utils.d.ts +2 -1
  48. package/dist/app/lib/blocks/block-utils.d.ts.map +1 -0
  49. package/dist/app/lib/blocks/block-utils.js +3 -1
  50. package/dist/app/lib/blocks/builtin-blocks.d.ts +2 -0
  51. package/dist/app/lib/blocks/builtin-blocks.d.ts.map +1 -0
  52. package/dist/app/lib/blocks/builtin-blocks.js +55 -0
  53. package/dist/app/lib/blocks/defineBlock.d.ts +4 -0
  54. package/dist/app/lib/blocks/defineBlock.d.ts.map +1 -0
  55. package/dist/app/lib/blocks/defineBlock.js +9 -0
  56. package/dist/app/lib/blocks/editor/EditorHighlights.d.ts +8 -0
  57. package/dist/app/lib/blocks/editor/EditorHighlights.d.ts.map +1 -0
  58. package/dist/app/lib/blocks/editor/EditorHighlights.js +164 -0
  59. package/dist/app/lib/blocks/editor/EditorSupport.d.ts +1 -0
  60. package/dist/app/lib/blocks/editor/EditorSupport.d.ts.map +1 -0
  61. package/dist/app/lib/blocks/editor/EditorSupport.js +17 -10
  62. package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +2 -1
  63. package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts.map +1 -0
  64. package/dist/app/lib/blocks/editor/block-templates.d.ts +8 -1
  65. package/dist/app/lib/blocks/editor/block-templates.d.ts.map +1 -0
  66. package/dist/app/lib/blocks/editor/block-templates.js +71 -2
  67. package/dist/app/lib/blocks/editor/blocks-by-tag.d.ts +1 -0
  68. package/dist/app/lib/blocks/editor/blocks-by-tag.d.ts.map +1 -0
  69. package/dist/app/lib/blocks/editor/controls.d.ts +1 -0
  70. package/dist/app/lib/blocks/editor/controls.d.ts.map +1 -0
  71. package/dist/app/lib/blocks/editor/create-block.d.ts +10 -0
  72. package/dist/app/lib/blocks/editor/create-block.d.ts.map +1 -0
  73. package/dist/app/lib/blocks/editor/create-block.js +13 -0
  74. package/dist/app/lib/blocks/editor/editor-config.d.ts +77 -8
  75. package/dist/app/lib/blocks/editor/editor-config.d.ts.map +1 -0
  76. package/dist/app/lib/blocks/editor/editor-config.js +29 -62
  77. package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts +4 -0
  78. package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts.map +1 -0
  79. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +126 -21
  80. package/dist/app/lib/blocks/editor/root-blocks.d.ts +7 -0
  81. package/dist/app/lib/blocks/editor/root-blocks.d.ts.map +1 -0
  82. package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
  83. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +12 -1
  84. package/dist/app/lib/blocks/editor/usePostEditor.d.ts.map +1 -0
  85. package/dist/app/lib/blocks/editor/usePostEditor.js +28 -13
  86. package/dist/app/lib/blocks/index.d.ts +8 -5
  87. package/dist/app/lib/blocks/index.d.ts.map +1 -0
  88. package/dist/app/lib/blocks/index.js +7 -5
  89. package/dist/app/lib/blocks/inline-editing.d.ts +10 -0
  90. package/dist/app/lib/blocks/inline-editing.d.ts.map +1 -0
  91. package/dist/app/lib/blocks/inline-editing.js +12 -2
  92. package/dist/app/lib/devtools/components/BreakpointIndicator.d.ts +1 -0
  93. package/dist/app/lib/devtools/components/BreakpointIndicator.d.ts.map +1 -0
  94. package/dist/app/lib/devtools/components/BreakpointIndicator.js +2 -2
  95. package/dist/app/lib/devtools/components/DevUI.d.ts +1 -0
  96. package/dist/app/lib/devtools/components/DevUI.d.ts.map +1 -0
  97. package/dist/app/lib/devtools/components/DevUI.js +3 -2
  98. package/dist/app/lib/devtools/components/GridIndicator.d.ts +2 -0
  99. package/dist/app/lib/devtools/components/GridIndicator.d.ts.map +1 -0
  100. package/dist/app/lib/devtools/components/GridIndicator.js +29 -0
  101. package/dist/app/lib/devtools/dev-tools-store.d.ts +1 -0
  102. package/dist/app/lib/devtools/dev-tools-store.d.ts.map +1 -0
  103. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +2 -1
  104. package/dist/app/lib/devtools/hooks/usePersistState.d.ts.map +1 -0
  105. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  106. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +77 -76
  107. package/dist/app/lib/devtools/hooks/useTailwind.d.ts.map +1 -0
  108. package/dist/app/lib/devtools/index.d.ts +1 -0
  109. package/dist/app/lib/devtools/index.d.ts.map +1 -0
  110. package/dist/app/lib/devtools/loader.d.ts +1 -0
  111. package/dist/app/lib/devtools/loader.d.ts.map +1 -0
  112. package/dist/app/lib/devtools/loader.js +6 -5
  113. package/dist/app/lib/devtools/tailwind.config.d.ts +1 -0
  114. package/dist/app/lib/devtools/tailwind.config.d.ts.map +1 -0
  115. package/dist/app/lib/devtools/useQueryDebug.d.ts +8 -1
  116. package/dist/app/lib/devtools/useQueryDebug.d.ts.map +1 -0
  117. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  118. package/dist/app/lib/dynamic/dynamic.d.ts +2 -1
  119. package/dist/app/lib/dynamic/dynamic.d.ts.map +1 -0
  120. package/dist/app/lib/dynamic/dynamic.js +5 -1
  121. package/dist/app/lib/dynamic/index.d.ts +1 -0
  122. package/dist/app/lib/dynamic/index.d.ts.map +1 -0
  123. package/dist/app/lib/hooks/index.d.ts +3 -3
  124. package/dist/app/lib/hooks/index.d.ts.map +1 -0
  125. package/dist/app/lib/hooks/index.js +2 -3
  126. package/dist/app/lib/hooks/{queryUtils.d.ts → query-hooks.d.ts} +42 -3
  127. package/dist/app/lib/hooks/query-hooks.d.ts.map +1 -0
  128. package/dist/app/lib/hooks/{queryUtils.js → query-hooks.js} +90 -28
  129. package/dist/app/lib/hooks/useAppData.d.ts +1 -0
  130. package/dist/app/lib/hooks/useAppData.d.ts.map +1 -0
  131. package/dist/app/lib/hooks/useAppData.js +11 -0
  132. package/dist/app/lib/hooks/useRPC.d.ts +1 -4
  133. package/dist/app/lib/hooks/useRPC.d.ts.map +1 -0
  134. package/dist/app/lib/hooks/useRPC.js +0 -8
  135. package/dist/app/lib/integrations/gravityforms/index.d.ts +3 -0
  136. package/dist/app/lib/integrations/gravityforms/index.d.ts.map +1 -0
  137. package/dist/app/lib/integrations/gravityforms/index.js +2 -0
  138. package/dist/app/lib/integrations/gravityforms/types.d.ts +145 -0
  139. package/dist/app/lib/integrations/gravityforms/types.d.ts.map +1 -0
  140. package/dist/app/lib/integrations/gravityforms/types.js +1 -0
  141. package/dist/app/lib/integrations/gravityforms/useGravityForm.d.ts +31 -0
  142. package/dist/app/lib/integrations/gravityforms/useGravityForm.d.ts.map +1 -0
  143. package/dist/app/lib/integrations/gravityforms/useGravityForm.js +295 -0
  144. package/dist/app/lib/internal/finalize-rpc.d.ts +18 -0
  145. package/dist/app/lib/internal/finalize-rpc.d.ts.map +1 -0
  146. package/dist/app/lib/internal/finalize-rpc.js +3 -0
  147. package/dist/app/lib/internal/index.d.ts +2 -0
  148. package/dist/app/lib/internal/index.d.ts.map +1 -0
  149. package/dist/app/lib/internal/index.js +1 -0
  150. package/dist/app/lib/internal/internal-store.d.ts +1 -0
  151. package/dist/app/lib/internal/internal-store.d.ts.map +1 -0
  152. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -0
  153. package/dist/app/lib/internal/read-admin-manifest.d.ts.map +1 -0
  154. package/dist/app/lib/internal/read-block-manifest.d.ts +2 -0
  155. package/dist/app/lib/internal/read-block-manifest.d.ts.map +1 -0
  156. package/dist/app/lib/internal/read-block-manifest.js +7 -0
  157. package/dist/app/lib/internal/read-view-manifest.d.ts +7 -4
  158. package/dist/app/lib/internal/read-view-manifest.d.ts.map +1 -0
  159. package/dist/app/lib/internal/read-view-manifest.js +18 -0
  160. package/dist/app/lib/legacy-stitches/createStitches.d.ts +510 -1
  161. package/dist/app/lib/legacy-stitches/createStitches.d.ts.map +1 -0
  162. package/dist/app/lib/legacy-stitches/index.d.ts +1 -0
  163. package/dist/app/lib/legacy-stitches/index.d.ts.map +1 -0
  164. package/dist/app/lib/routing/components/BackButton.d.ts +50 -0
  165. package/dist/app/lib/routing/components/BackButton.d.ts.map +1 -0
  166. package/dist/app/lib/routing/components/BackButton.js +47 -0
  167. package/dist/app/lib/routing/components/BrowserRouter.d.ts +10 -1
  168. package/dist/app/lib/routing/components/BrowserRouter.d.ts.map +1 -0
  169. package/dist/app/lib/routing/components/BrowserRouter.js +136 -21
  170. package/dist/app/lib/routing/components/ClientOnly.d.ts +2 -1
  171. package/dist/app/lib/routing/components/ClientOnly.d.ts.map +1 -0
  172. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  173. package/dist/app/lib/routing/components/Link.d.ts +19 -2
  174. package/dist/app/lib/routing/components/Link.d.ts.map +1 -0
  175. package/dist/app/lib/routing/components/Link.js +43 -23
  176. package/dist/app/lib/routing/components/NativeLinkHandler.d.ts +10 -0
  177. package/dist/app/lib/routing/components/NativeLinkHandler.d.ts.map +1 -0
  178. package/dist/app/lib/routing/components/NativeLinkHandler.js +23 -0
  179. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -0
  180. package/dist/app/lib/routing/components/RouteRenderer.d.ts.map +1 -0
  181. package/dist/app/lib/routing/components/RouteRenderer.js +17 -3
  182. package/dist/app/lib/routing/components/SSRRouter.d.ts +3 -0
  183. package/dist/app/lib/routing/components/SSRRouter.d.ts.map +1 -0
  184. package/dist/app/lib/routing/components/SSRRouter.js +3 -2
  185. package/dist/app/lib/routing/components/ScrollRestoration.d.ts +1 -0
  186. package/dist/app/lib/routing/components/ScrollRestoration.d.ts.map +1 -0
  187. package/dist/app/lib/routing/components/ScrollRestoration.js +4 -1
  188. package/dist/app/lib/routing/context.d.ts +9 -5
  189. package/dist/app/lib/routing/context.d.ts.map +1 -0
  190. package/dist/app/lib/routing/context.js +12 -95
  191. package/dist/app/lib/routing/hooks/useIsSSR.d.ts +1 -0
  192. package/dist/app/lib/routing/hooks/useIsSSR.d.ts.map +1 -0
  193. package/dist/app/lib/routing/hooks/useRestorableState.d.ts +3 -1
  194. package/dist/app/lib/routing/hooks/useRestorableState.d.ts.map +1 -0
  195. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -0
  196. package/dist/app/lib/routing/hooks/useRoute.d.ts.map +1 -0
  197. package/dist/app/lib/routing/hooks/useRoute.js +21 -0
  198. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +6 -0
  199. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts.map +1 -0
  200. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  201. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -0
  202. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts.map +1 -0
  203. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -0
  204. package/dist/app/lib/routing/hooks/useRouter.d.ts.map +1 -0
  205. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -0
  206. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts.map +1 -0
  207. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -0
  208. package/dist/app/lib/routing/hooks/useRouterState.d.ts.map +1 -0
  209. package/dist/app/lib/routing/hooks/useSearchParams.d.ts +78 -6
  210. package/dist/app/lib/routing/hooks/useSearchParams.d.ts.map +1 -0
  211. package/dist/app/lib/routing/hooks/useSearchParams.js +75 -15
  212. package/dist/app/lib/routing/index.d.ts +3 -0
  213. package/dist/app/lib/routing/index.d.ts.map +1 -0
  214. package/dist/app/lib/routing/index.js +2 -0
  215. package/dist/app/lib/routing/loader.d.ts +1 -0
  216. package/dist/app/lib/routing/loader.d.ts.map +1 -0
  217. package/dist/app/lib/routing/loader.js +19 -10
  218. package/dist/app/lib/routing/types.d.ts +60 -12
  219. package/dist/app/lib/routing/types.d.ts.map +1 -0
  220. package/dist/app/lib/routing/utils.d.ts +7 -2
  221. package/dist/app/lib/routing/utils.d.ts.map +1 -0
  222. package/dist/app/lib/routing/utils.js +41 -4
  223. package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +11 -2
  224. package/dist/app/lib/runtime/apiConfig.d.ts.map +1 -0
  225. package/dist/app/lib/runtime/apiConfig.js +6 -0
  226. package/dist/app/lib/runtime/errorHandling.d.ts +40 -0
  227. package/dist/app/lib/runtime/errorHandling.d.ts.map +1 -0
  228. package/dist/app/lib/runtime/errorHandling.js +6 -0
  229. package/dist/app/lib/runtime/index.d.ts +3 -0
  230. package/dist/app/lib/runtime/index.d.ts.map +1 -0
  231. package/dist/app/lib/runtime/index.js +2 -0
  232. package/dist/app/lib/views/defineView.d.ts +2 -1
  233. package/dist/app/lib/views/defineView.d.ts.map +1 -0
  234. package/dist/app/lib/views/index.d.ts +1 -0
  235. package/dist/app/lib/views/index.d.ts.map +1 -0
  236. package/dist/app/server/index.d.ts +4 -1
  237. package/dist/app/server/index.d.ts.map +1 -0
  238. package/dist/app/server/index.js +3 -1
  239. package/dist/app/server/proxy-wp-admin.d.ts +2 -2
  240. package/dist/app/server/proxy-wp-admin.d.ts.map +1 -0
  241. package/dist/app/server/proxy-wp-admin.js +46 -13
  242. package/dist/app/server/render-ai-page.d.ts +13 -0
  243. package/dist/app/server/render-ai-page.d.ts.map +1 -0
  244. package/dist/app/server/render-ai-page.js +100 -0
  245. package/dist/app/server/render-ssr-page.d.ts +31 -3
  246. package/dist/app/server/render-ssr-page.d.ts.map +1 -0
  247. package/dist/app/server/render-ssr-page.js +226 -10
  248. package/dist/app/server/rpc.d.ts +60 -0
  249. package/dist/app/server/rpc.d.ts.map +1 -0
  250. package/dist/app/server/rpc.js +18 -0
  251. package/dist/app/server/server-context.d.ts +44 -6
  252. package/dist/app/server/server-context.d.ts.map +1 -0
  253. package/dist/app/server/server-context.js +334 -37
  254. package/dist/app/server/server-custom-config.d.ts +3 -0
  255. package/dist/app/server/server-custom-config.d.ts.map +1 -0
  256. package/dist/app/server/server-custom-config.js +1 -0
  257. package/dist/app/server/utils/content-security.d.ts +26 -0
  258. package/dist/app/server/utils/content-security.d.ts.map +1 -0
  259. package/dist/app/server/utils/content-security.js +124 -0
  260. package/dist/app/server/utils/headers.d.ts +1 -0
  261. package/dist/app/server/utils/headers.d.ts.map +1 -0
  262. package/dist/app/server/utils/replace-host.d.ts +2 -1
  263. package/dist/app/server/utils/replace-host.d.ts.map +1 -0
  264. package/dist/app/server/utils/replace-host.js +10 -2
  265. package/dist/app/server/utils/swr-cache.d.ts +5 -0
  266. package/dist/app/server/utils/swr-cache.d.ts.map +1 -0
  267. package/dist/app/server/utils/swr-cache.js +31 -0
  268. package/dist/app/utils/APIProvider.d.ts +3 -0
  269. package/dist/app/utils/APIProvider.d.ts.map +1 -0
  270. package/dist/app/utils/APIProvider.js +5 -0
  271. package/dist/app/utils/BlockErrorBoundary.d.ts +20 -0
  272. package/dist/app/utils/BlockErrorBoundary.d.ts.map +1 -0
  273. package/dist/app/utils/BlockErrorBoundary.js +38 -0
  274. package/dist/app/utils/ErrorMessage.d.ts +6 -0
  275. package/dist/app/utils/ErrorMessage.d.ts.map +1 -0
  276. package/dist/app/utils/ErrorMessage.js +14 -0
  277. package/dist/app/utils/RouteErrorBoundary.d.ts +20 -0
  278. package/dist/app/utils/RouteErrorBoundary.d.ts.map +1 -0
  279. package/dist/app/utils/RouteErrorBoundary.js +41 -0
  280. package/dist/app/utils/asset-capture.d.ts +3 -0
  281. package/dist/app/utils/asset-capture.d.ts.map +1 -0
  282. package/dist/app/utils/asset-capture.js +5 -0
  283. package/dist/app/utils/hydration-debugger.d.ts +14 -0
  284. package/dist/app/utils/hydration-debugger.d.ts.map +1 -0
  285. package/dist/app/utils/hydration-debugger.js +11 -0
  286. package/dist/app/utils/query-client.d.ts +3 -0
  287. package/dist/app/utils/query-client.d.ts.map +1 -0
  288. package/dist/app/utils/query-client.js +5 -1
  289. package/dist/app/utils/query-monitor.d.ts +27 -0
  290. package/dist/app/utils/query-monitor.d.ts.map +1 -0
  291. package/dist/app/utils/query-monitor.js +7 -0
  292. package/dist/app/utils/trpc-client.d.ts +3 -0
  293. package/dist/app/utils/trpc-client.d.ts.map +1 -0
  294. package/dist/app/utils/trpc-client.js +39 -0
  295. package/dist/app/utils/wp.d.ts +11 -10
  296. package/dist/app/utils/wp.d.ts.map +1 -0
  297. package/dist/node/cli/cli-mode.d.ts +1 -0
  298. package/dist/node/cli/cli-mode.d.ts.map +1 -0
  299. package/dist/node/cli/cli-worker.d.ts +1 -0
  300. package/dist/node/cli/cli-worker.d.ts.map +1 -0
  301. package/dist/node/cli/cli-worker.js +7 -3
  302. package/dist/node/cli/cli.d.ts +1 -0
  303. package/dist/node/cli/cli.d.ts.map +1 -0
  304. package/dist/node/cli/cli.js +120 -7
  305. package/dist/node/cli/display/CLIApp.d.ts +1 -0
  306. package/dist/node/cli/display/CLIApp.d.ts.map +1 -0
  307. package/dist/node/cli/display/CLIApp.js +1 -1
  308. package/dist/node/cli/display/boot-cli-app.d.ts +1 -0
  309. package/dist/node/cli/display/boot-cli-app.d.ts.map +1 -0
  310. package/dist/node/cli/display/boot-cli-app.js +1 -1
  311. package/dist/node/cli/display/components/Fullscreen.d.ts +1 -0
  312. package/dist/node/cli/display/components/Fullscreen.d.ts.map +1 -0
  313. package/dist/node/cli/display/components/LogEntries.d.ts +1 -0
  314. package/dist/node/cli/display/components/LogEntries.d.ts.map +1 -0
  315. package/dist/node/cli/display/components/MenuItem.d.ts +1 -0
  316. package/dist/node/cli/display/components/MenuItem.d.ts.map +1 -0
  317. package/dist/node/cli/display/components/TextInput.d.ts +1 -0
  318. package/dist/node/cli/display/components/TextInput.d.ts.map +1 -0
  319. package/dist/node/cli/display/hooks/useManifest.d.ts +1 -0
  320. package/dist/node/cli/display/hooks/useManifest.d.ts.map +1 -0
  321. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -0
  322. package/dist/node/cli/display/hooks/useStatefulLog.d.ts.map +1 -0
  323. package/dist/node/cli/display/tools/BlockList.d.ts +1 -0
  324. package/dist/node/cli/display/tools/BlockList.d.ts.map +1 -0
  325. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -0
  326. package/dist/node/cli/display/tools/CreateBlock.d.ts.map +1 -0
  327. package/dist/node/cli/display/tools/cli-tool-list.d.ts +1 -0
  328. package/dist/node/cli/display/tools/cli-tool-list.d.ts.map +1 -0
  329. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -0
  330. package/dist/node/cli/display/tools/cli-tools.d.ts.map +1 -0
  331. package/dist/node/cli/display/util/colors.d.ts +1 -0
  332. package/dist/node/cli/display/util/colors.d.ts.map +1 -0
  333. package/dist/node/cli/version.d.ts +2 -1
  334. package/dist/node/cli/version.d.ts.map +1 -0
  335. package/dist/node/cli/version.js +1 -1
  336. package/dist/node/compiler/build-vinxi.d.ts +1 -0
  337. package/dist/node/compiler/build-vinxi.d.ts.map +1 -0
  338. package/dist/node/compiler/build-vinxi.js +2 -1
  339. package/dist/node/compiler/bundler.admin.d.ts +1 -0
  340. package/dist/node/compiler/bundler.admin.d.ts.map +1 -0
  341. package/dist/node/compiler/bundler.admin.js +1 -0
  342. package/dist/node/compiler/bundler.frontend.d.ts +2 -0
  343. package/dist/node/compiler/bundler.frontend.d.ts.map +1 -0
  344. package/dist/node/compiler/bundler.frontend.js +26 -11
  345. package/dist/node/compiler/dev-server.d.ts +1 -0
  346. package/dist/node/compiler/dev-server.d.ts.map +1 -0
  347. package/dist/node/compiler/dev-server.js +17 -1
  348. package/dist/node/compiler/get-vite-config.d.ts +12 -1
  349. package/dist/node/compiler/get-vite-config.d.ts.map +1 -0
  350. package/dist/node/compiler/get-vite-config.js +173 -42
  351. package/dist/node/compiler/vinxi-app.d.ts +13 -0
  352. package/dist/node/compiler/vinxi-app.d.ts.map +1 -0
  353. package/dist/node/compiler/vinxi-app.js +142 -32
  354. package/dist/node/compiler/vinxi-codegen.d.ts +1 -0
  355. package/dist/node/compiler/vinxi-codegen.d.ts.map +1 -0
  356. package/dist/node/compiler/vinxi-codegen.js +371 -108
  357. package/dist/node/graphql/graphql-codegen.d.ts +12 -1
  358. package/dist/node/graphql/graphql-codegen.d.ts.map +1 -0
  359. package/dist/node/graphql/graphql-codegen.js +239 -37
  360. package/dist/node/graphql/graphql-schema-loader.d.ts +3 -1
  361. package/dist/node/graphql/graphql-schema-loader.d.ts.map +1 -0
  362. package/dist/node/graphql/graphql-schema-loader.js +5 -16
  363. package/dist/node/graphql/plugins/gql-plugin-files.d.ts +3 -1
  364. package/dist/node/graphql/plugins/gql-plugin-files.d.ts.map +1 -0
  365. package/dist/node/graphql/plugins/gql-plugin-files.js +3 -2
  366. package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts +1 -0
  367. package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts.map +1 -0
  368. package/dist/node/graphql/plugins/gql-plugin-queries.d.ts +1 -0
  369. package/dist/node/graphql/plugins/gql-plugin-queries.d.ts.map +1 -0
  370. package/dist/node/graphql/plugins/gql-plugin-queries.js +2 -2
  371. package/dist/node/graphql/query-files-loader.d.ts +4 -0
  372. package/dist/node/graphql/query-files-loader.d.ts.map +1 -0
  373. package/dist/node/graphql/query-files-loader.js +5 -0
  374. package/dist/node/graphql/wp-info-query.d.ts +1 -0
  375. package/dist/node/graphql/wp-info-query.d.ts.map +1 -0
  376. package/dist/node/project/config.d.ts +207 -73
  377. package/dist/node/project/config.d.ts.map +1 -0
  378. package/dist/node/project/config.js +94 -20
  379. package/dist/node/project/eddev-build-file.d.ts +1 -0
  380. package/dist/node/project/eddev-build-file.d.ts.map +1 -0
  381. package/dist/node/project/eddev-build-file.js +4 -2
  382. package/dist/node/project/env.d.ts +5 -0
  383. package/dist/node/project/env.d.ts.map +1 -0
  384. package/dist/node/project/env.js +1 -0
  385. package/dist/node/project/favicons.d.ts +1 -1
  386. package/dist/node/project/favicons.d.ts.map +1 -0
  387. package/dist/node/project/favicons.js +1 -1
  388. package/dist/node/project/manifest/block-manifest.d.ts +1 -0
  389. package/dist/node/project/manifest/block-manifest.d.ts.map +1 -0
  390. package/dist/node/project/manifest/block-manifest.js +6 -2
  391. package/dist/node/project/manifest/field-manifest.d.ts +1 -0
  392. package/dist/node/project/manifest/field-manifest.d.ts.map +1 -0
  393. package/dist/node/project/manifest/manifest.d.ts +2 -0
  394. package/dist/node/project/manifest/manifest.d.ts.map +1 -0
  395. package/dist/node/project/manifest/manifest.js +14 -10
  396. package/dist/node/project/manifest/routes-manifest.d.ts +21 -0
  397. package/dist/node/project/manifest/routes-manifest.d.ts.map +1 -0
  398. package/dist/node/project/manifest/routes-manifest.js +74 -0
  399. package/dist/node/project/manifest/view-manifest.d.ts +1 -0
  400. package/dist/node/project/manifest/view-manifest.d.ts.map +1 -0
  401. package/dist/node/project/manifest/widget-manifest.d.ts +1 -0
  402. package/dist/node/project/manifest/widget-manifest.d.ts.map +1 -0
  403. package/dist/node/project/project.d.ts +12 -0
  404. package/dist/node/project/project.d.ts.map +1 -0
  405. package/dist/node/project/project.js +57 -3
  406. package/dist/node/project/wp-info.d.ts +3 -0
  407. package/dist/node/project/wp-info.d.ts.map +1 -0
  408. package/dist/node/project/wp-info.js +13 -1
  409. package/dist/node/storybook/index.d.ts +3 -0
  410. package/dist/node/storybook/index.d.ts.map +1 -0
  411. package/dist/node/storybook/index.js +13 -0
  412. package/dist/node/types/block-type.d.ts +57 -25
  413. package/dist/node/types/block-type.d.ts.map +1 -0
  414. package/dist/node/types/block-type.js +4 -1
  415. package/dist/node/types/view-type.d.ts +8 -7
  416. package/dist/node/types/view-type.d.ts.map +1 -0
  417. package/dist/node/utils/fetch-wp.d.ts +2 -0
  418. package/dist/node/utils/fetch-wp.d.ts.map +1 -0
  419. package/dist/node/utils/fetch-wp.js +28 -0
  420. package/dist/node/utils/format-zod-error.d.ts +1 -0
  421. package/dist/node/utils/format-zod-error.d.ts.map +1 -0
  422. package/dist/node/utils/fs-codegen.d.ts +4 -0
  423. package/dist/node/utils/fs-codegen.d.ts.map +1 -0
  424. package/dist/node/utils/fs-codegen.js +10 -2
  425. package/dist/node/utils/fs.d.ts +5 -0
  426. package/dist/node/utils/fs.d.ts.map +1 -0
  427. package/dist/node/utils/get-repo-info.d.ts +1 -0
  428. package/dist/node/utils/get-repo-info.d.ts.map +1 -0
  429. package/dist/node/utils/helpers.d.ts +1 -0
  430. package/dist/node/utils/helpers.d.ts.map +1 -0
  431. package/dist/node/utils/highlight-code.d.ts +1 -0
  432. package/dist/node/utils/highlight-code.d.ts.map +1 -0
  433. package/dist/node/utils/is-deploying.d.ts +1 -0
  434. package/dist/node/utils/is-deploying.d.ts.map +1 -0
  435. package/dist/node/utils/is-deploying.js +1 -1
  436. package/dist/node/utils/report-builder.d.ts +1 -0
  437. package/dist/node/utils/report-builder.d.ts.map +1 -0
  438. package/dist/node/utils/self-signed-cert.d.ts +5 -0
  439. package/dist/node/utils/self-signed-cert.d.ts.map +1 -0
  440. package/dist/node/utils/self-signed-cert.js +28 -4
  441. package/dist/node/utils/stateful-log.d.ts +1 -0
  442. package/dist/node/utils/stateful-log.d.ts.map +1 -0
  443. package/dist/node/utils/stateful-log.js +2 -0
  444. package/dist/node/utils/ts-export-extractor.d.ts +1 -0
  445. package/dist/node/utils/ts-export-extractor.d.ts.map +1 -0
  446. package/dist/node/utils/watch-file-tree.d.ts +18 -3
  447. package/dist/node/utils/watch-file-tree.d.ts.map +1 -0
  448. package/dist/node/utils/watch-file-tree.js +12 -5
  449. package/package.json +42 -25
  450. package/tsconfig.app.json +10 -5
  451. package/tsconfig.node.json +3 -2
  452. package/types.app.d.ts +2 -0
  453. package/types.meta.d.ts +449 -136
  454. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  455. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  456. package/dist/app/lib/hooks/apiConfig.js +0 -4
  457. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  458. package/dist/app/lib/hooks/usePageLoad.js +0 -5
@@ -1,9 +1,16 @@
1
1
  import { FunctionComponent } from "react";
2
2
  import type { RouteLoader } from "./loader.js";
3
3
  import { LinkHandlerMode, PointerOrMouseEvent } from "./utils.js";
4
- export type ParsedRouteTags = Record<"title" | "meta" | "script" | "style" | "link", {
5
- [key: string]: string;
6
- }[]>;
4
+ export type RouteMetaTag = {
5
+ tagName: string;
6
+ attributes: Record<string, string>;
7
+ inner?: string;
8
+ };
9
+ export type TrackerTags = {
10
+ head?: string;
11
+ body?: string;
12
+ footer?: string;
13
+ };
7
14
  export interface RouteData {
8
15
  view: string;
9
16
  editLink?: string;
@@ -13,10 +20,13 @@ export interface RouteData {
13
20
  redirect?: string;
14
21
  canonical?: string;
15
22
  meta?: {
16
- head: ParsedRouteTags;
17
- footer: ParsedRouteTags;
23
+ head: RouteMetaTag[];
24
+ footer: RouteMetaTag[];
18
25
  };
19
26
  }
27
+ export interface RouteDataWithTrackers extends RouteData {
28
+ trackers?: TrackerTags;
29
+ }
20
30
  export type RouteReturnState<T = {}> = {
21
31
  scrollTop: number;
22
32
  scrollLeft: number;
@@ -26,13 +36,12 @@ export type RouteLink = {
26
36
  query: Record<string, string | string[]>;
27
37
  hash: string;
28
38
  };
29
- export type RouterEvent = {
39
+ export type RouterEvent = ({
30
40
  type: "clicked";
31
41
  link: RouteLink;
32
42
  currentRoute: RouteState;
33
- href: string;
34
- mode: LinkHandlerMode;
35
- } | {
43
+ cancel: () => void;
44
+ } & LinkHandlerMode) | {
36
45
  type: "capture-restorable-state";
37
46
  state: RouteReturnState<Record<string, any>>;
38
47
  } | {
@@ -73,7 +82,12 @@ export type RouterEvent = {
73
82
  data: RouteData;
74
83
  } | {
75
84
  type: "error";
76
- critical: false;
85
+ critical: boolean;
86
+ url?: string;
87
+ shouldReload?: boolean;
88
+ error: Error;
89
+ } | {
90
+ type: "error:component-load-failed";
77
91
  error: Error;
78
92
  };
79
93
  export type RouterSubscriber = (event: RouterEvent) => void;
@@ -89,6 +103,7 @@ export type RouterAPIState = {
89
103
  blockers: Promise<void>[];
90
104
  };
91
105
  export type RouterAPI = {
106
+ hostname?: string;
92
107
  /** Preload a page and it's components */
93
108
  preload: (url: string) => Promise<void>;
94
109
  /** Prefetch the data for a page, but not it's components. */
@@ -99,14 +114,26 @@ export type RouterAPI = {
99
114
  replaceQuery: (search: Record<string, string | string[]>) => void;
100
115
  /** Replace the hash */
101
116
  replaceHash: (hash: string) => void;
102
- /** Handle link clicking events */
103
- handleClickEvent(e: PointerOrMouseEvent, href?: string): void;
117
+ /**
118
+ * Handle a click event, potentially triggering a route change.
119
+ *
120
+ * @param e A pointer or mouse event.
121
+ * @param href An optional URL. This must be provided if no `href` property exists on the clicked element
122
+ * @param preferBack If set, clicking this link will send the user 'back', when clicking a link to the previous history item.
123
+ */
124
+ handleClickEvent(e: PointerOrMouseEvent, href?: string, preferBack?: boolean | "exact"): void;
104
125
  /** A reference to the route loader (mostly for internal use) */
105
126
  loader: RouteLoader;
106
127
  /** Subscribe to events */
107
128
  subscribe: (subscribe: RouterSubscriber) => () => void;
108
129
  /** This function is used by the routing system automatically */
109
130
  emitEvent: (event: RouterEvent) => void;
131
+ /** Returns the current RouterAPIState */
132
+ getState: () => RouterAPIState | null;
133
+ /** Go back to a previous route in the history stack, or push it onto the stack if it isn't currently on the stack. */
134
+ restoreRoute: (route: RouteState) => void;
135
+ /** Indicates that this page render is for consumption by an LLM */
136
+ isAI?: boolean;
110
137
  };
111
138
  export type TypedRouteState<T, TProps> = {
112
139
  /** A unique ID, representing this history item. */
@@ -131,8 +158,29 @@ export type TypedRouteState<T, TProps> = {
131
158
  component: FunctionComponent<TProps>;
132
159
  /** The props for this route, to be passed to the component. */
133
160
  props: TProps;
161
+ /** Loaded metadata for this route */
162
+ meta: RouteMeta;
163
+ };
164
+ export type RouteMeta = {
165
+ title?: string;
166
+ tags?: RouteMetaTag[];
167
+ editLink?: string;
134
168
  };
135
169
  export type RouteState = {
136
170
  [K in keyof ViewProps]: TypedRouteState<K, ViewProps[K]>;
137
171
  }[keyof ViewProps];
138
172
  export type AnyRouteState = TypedRouteState<string, any>;
173
+ export type ErrorRouteProps = {
174
+ /** The HTTP status code for this error */
175
+ statusCode: number;
176
+ /** The title of the message (eg. Not Found) */
177
+ title?: string;
178
+ /** A message which can be shown to the user, specific to this error */
179
+ userMessage?: string;
180
+ /** Detailed error information, which can be displayed to developers or passed to monitoring services */
181
+ report?: {
182
+ message: string;
183
+ details: any;
184
+ };
185
+ };
186
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/app/lib/routing/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEjE,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,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AAE,GAAG,CAAC,CAAA;AAExD,MAAM,MAAM,eAAe,GAAG;IAC5B,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAA;IAClB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,wGAAwG;IACxG,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,GAAG,CAAA;KACb,CAAA;CACF,CAAA"}
@@ -1,15 +1,20 @@
1
1
  import { MouseEvent as ReactMouseEvent, PointerEvent as ReactPointerEvent } from "react";
2
- import { RouteLink, RouteState } from "./types.js";
2
+ import { RouteData, RouteLink, RouteMeta, RouteState } from "./types.js";
3
3
  export declare function isSameOrigin(url: string): boolean;
4
+ export declare function isSamePathname(a: string, b: string): boolean;
4
5
  export type PointerOrMouseEvent = MouseEvent | PointerEvent | ReactMouseEvent | ReactPointerEvent;
5
6
  export type LinkHandlerMode = {
6
7
  mode: "ignore" | "navigate" | "native";
7
8
  href?: string;
9
+ isSameUrl?: boolean;
8
10
  };
9
- export declare function getLinkHandlerMode(e?: PointerOrMouseEvent, href?: string): LinkHandlerMode;
11
+ export declare function getLinkHandlerMode(e?: PointerOrMouseEvent, href?: string, currentRoute?: RouteState): LinkHandlerMode;
10
12
  type Partialize<T, TKeys extends keyof T> = Partial<Pick<T, TKeys>> & Omit<T, TKeys>;
11
13
  export declare function normalizeRoute(route: Partialize<RouteState, "uri" | "returnState" | "key">): RouteState;
12
14
  export declare function stringifyRouteLink(route: RouteLink): string;
13
15
  export declare function parseQuery(query: string): Record<string, string | string[]>;
14
16
  export declare function stringifyQuery(query: any): string;
17
+ export declare function getRouteMeta(data: RouteData): RouteMeta;
18
+ export declare function addTrailingSlash(path?: string | null): string;
15
19
  export {};
20
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src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AAY,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAMvD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,UAKpD"}
@@ -1,5 +1,5 @@
1
- import { parseURL, resolveURL, stringifyParsedURL, withoutTrailingSlash } from "ufo";
2
- import { stringify as qsStringify, parse as qsParse } from "qs";
1
+ import { parse as qsParse, stringify as qsStringify } from "qs";
2
+ import { parseURL, resolveURL, stringifyParsedURL, withoutTrailingSlash, withTrailingSlash } from "ufo";
3
3
  export function isSameOrigin(url) {
4
4
  if (typeof document === "undefined") {
5
5
  return url.startsWith("/");
@@ -10,7 +10,12 @@ export function isSameOrigin(url) {
10
10
  return parsed.protocol === document.location.protocol && parsed.host === document.location.host;
11
11
  }
12
12
  }
13
- export function getLinkHandlerMode(e, href) {
13
+ export function isSamePathname(a, b) {
14
+ const left = parseURL(a).pathname.replace(/\/$/, "").toLocaleLowerCase();
15
+ const right = parseURL(b).pathname.replace(/\/$/, "").toLocaleLowerCase();
16
+ return left === right;
17
+ }
18
+ export function getLinkHandlerMode(e, href, currentRoute) {
14
19
  try {
15
20
  // Attempt to get the link element, if there is one
16
21
  let eventTarget = null;
@@ -30,8 +35,15 @@ export function getLinkHandlerMode(e, href) {
30
35
  href = eventTarget.href;
31
36
  if (!href)
32
37
  return { mode: "native", href };
38
+ if (href.match(/^(mailto|tel|callto|sms|maps):/)) {
39
+ return { mode: "native", href };
40
+ }
33
41
  // Resolve the URL and check if it's the same origin
34
- const resolved = href.startsWith("http") ? href : resolveURL(document.location.href, href);
42
+ const resolved = href.startsWith("http")
43
+ ? href
44
+ : href.startsWith("/")
45
+ ? resolveURL(document.location.origin, href)
46
+ : resolveURL(document.location.href, href);
35
47
  const parsed = parseURL(resolved);
36
48
  const isSameOrigin = parsed.host?.replace(/:.+/, "") === document.location.host.replace(/:.+/, "");
37
49
  // External links should be handled natively
@@ -52,6 +64,17 @@ export function getLinkHandlerMode(e, href) {
52
64
  // Starts with /wp-, use native (wp-content, wp-admin etc)
53
65
  if (parsed.pathname.startsWith("/wp-"))
54
66
  return { mode: "native", href };
67
+ // If pathname+query are identical, but the hash is different, then allow the browser to handle it
68
+ if (currentRoute &&
69
+ isSamePathname(currentRoute.pathname, parsed.pathname) &&
70
+ currentRoute.search === parsed.search) {
71
+ if (currentRoute.hash !== parsed.hash) {
72
+ return { mode: "native", href };
73
+ }
74
+ else {
75
+ return { mode: "ignore", href, isSameUrl: true };
76
+ }
77
+ }
55
78
  return { mode: "navigate", href };
56
79
  }
57
80
  catch (err) {
@@ -76,6 +99,7 @@ export function normalizeRoute(route) {
76
99
  export function stringifyRouteLink(route) {
77
100
  return stringifyParsedURL({
78
101
  ...route,
102
+ pathname: withTrailingSlash(route.pathname),
79
103
  search: stringifyQuery(route.query),
80
104
  });
81
105
  }
@@ -92,3 +116,16 @@ export function stringifyQuery(query) {
92
116
  arrayFormat: "brackets",
93
117
  });
94
118
  }
119
+ export function getRouteMeta(data) {
120
+ return {
121
+ title: data.meta?.head.find((tag) => tag.tagName === "title")?.inner,
122
+ tags: data.meta?.head ?? [],
123
+ editLink: data.editLink,
124
+ };
125
+ }
126
+ export function addTrailingSlash(path) {
127
+ if (path?.match(/\./)) {
128
+ return path;
129
+ }
130
+ return withTrailingSlash(path ?? undefined, true);
131
+ }
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Configuration options for manipulating how the client interacts with the GraphQL API
3
+ */
1
4
  export type APIConfigStore = {
2
5
  /**
3
6
  * Any value, which will be used as part of the cache key for each query.
@@ -11,8 +14,14 @@ export type APIConfigStore = {
11
14
  */
12
15
  customQueryFetchOptions?: (type: "query" | "mutation", queryName: string, queryArgs: any, url: string, opts: RequestInit) => RequestInit | Promise<RequestInit>;
13
16
  /**
14
- * Update aspects of the API client
17
+ * Allows you to hook into the response of a query or mutation.
15
18
  */
19
+ onResponse?: (response: Response, type: "query" | "mutation", queryName: string, queryArgs: any, url: string, opts: RequestInit) => void;
16
20
  set: (config: Partial<APIConfigStore>) => void;
21
+ /**
22
+ * WordPress API key, for use on the server only
23
+ **/
24
+ apiKey?: string;
17
25
  };
18
- export declare const useAPIConfig: import("zustand").UseBoundStore<import("zustand").StoreApi<APIConfigStore>>;
26
+ export declare const apiConfig: APIConfigStore;
27
+ //# sourceMappingURL=apiConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiConfig.d.ts","sourceRoot":"","sources":["../../../../src/app/lib/runtime/apiConfig.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;QAII;IACJ,cAAc,CAAC,EAAE,GAAG,CAAA;IACpB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,CACxB,IAAI,EAAE,OAAO,GAAG,UAAU,EAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,GAAG,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,KACd,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IACvC;;OAEG;IACH,UAAU,CAAC,EAAE,CACX,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,OAAO,GAAG,UAAU,EAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,GAAG,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,KACd,IAAI,CAAA;IACT,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,CAAA;IAE9C;;QAEI;IACJ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,SAAS,gBAIpB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { proxy } from "valtio";
2
+ export const apiConfig = proxy({
3
+ set: (config) => {
4
+ Object.assign(apiConfig, config);
5
+ },
6
+ });
@@ -0,0 +1,40 @@
1
+ import { ContentBlock } from "../blocks";
2
+ import { ReactNode } from "react";
3
+ import { RouteState } from "../routing";
4
+ export type ErrorEvent = {
5
+ /** The runtime error that occurred */
6
+ error: Error;
7
+ /** The Component stack (not available in renderBlockError) */
8
+ componentStack?: string;
9
+ } & ({
10
+ type: "block";
11
+ /** The block which had an error, including it's type information, props, content and children */
12
+ block: ContentBlock;
13
+ } | {
14
+ type: "route";
15
+ /** The route which had an error */
16
+ route: RouteState;
17
+ });
18
+ /**
19
+ * Configuration options for manipulating how the client interacts with the GraphQL API
20
+ */
21
+ export type ErrorHandlingConfig = {
22
+ /**
23
+ * Triggered when a runtime error occurs in a block
24
+ * @param event The error event, containing the error and block information
25
+ **/
26
+ onReactError?(event: ErrorEvent): void;
27
+ /**
28
+ * Triggered when a React rendering error occurs, and allows you to return some JSX to render as a fallback.
29
+ * If not provided, the block will be hidden from the user.
30
+ * @param error The error event, containing the error and contextual information
31
+ * @param defaultDisplay The default display for the block — in development, this will display the error message. In production, this will be `null`.
32
+ */
33
+ renderFallback?(event: ErrorEvent, defaultDisplay: ReactNode): ReactNode;
34
+ /**
35
+ * Update the error handling configuration all at once
36
+ */
37
+ set: (config: Partial<ErrorHandlingConfig>) => void;
38
+ };
39
+ export declare const errorHandling: ErrorHandlingConfig;
40
+ //# sourceMappingURL=errorHandling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorHandling.d.ts","sourceRoot":"","sources":["../../../../src/app/lib/runtime/errorHandling.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,MAAM,UAAU,GAAG;IACvB,sCAAsC;IACtC,KAAK,EAAE,KAAK,CAAA;IACZ,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,GAAG,CACA;IACE,IAAI,EAAE,OAAO,CAAA;IACb,iGAAiG;IACjG,KAAK,EAAE,YAAY,CAAA;CACpB,GACD;IACE,IAAI,EAAE,OAAO,CAAA;IACb,mCAAmC;IACnC,KAAK,EAAE,UAAU,CAAA;CAClB,CACJ,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;QAGI;IACJ,YAAY,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;IACtC;;;;;OAKG;IACH,cAAc,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,GAAG,SAAS,CAAA;IAExE;;OAEG;IACH,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAA;CACpD,CAAA;AAED,eAAO,MAAM,aAAa,qBAIxB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { proxy } from "valtio";
2
+ export const errorHandling = proxy({
3
+ set: (config) => {
4
+ Object.assign(errorHandling, config);
5
+ },
6
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./apiConfig";
2
+ export * from "./errorHandling";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/app/lib/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from "./apiConfig";
2
+ export * from "./errorHandling";
@@ -1,4 +1,5 @@
1
1
  import { ComponentType, PropsWithChildren, ReactNode } from "react";
2
- type ExtendedViewProps<TName extends keyof ViewProps> = TName extends "_app" ? PropsWithChildren<ViewProps[TName]> : ViewProps[TName];
2
+ type ExtendedViewProps<TName extends keyof ViewProps> = TName extends "_app" ? PropsWithChildren<ViewProps[TName]> : TName extends "_error" ? ViewProps[TName] : ViewProps[TName];
3
3
  export declare function defineView<Name extends keyof ViewProps>(name: Name, component: (props: ExtendedViewProps<Name>) => ReactNode): ComponentType<ExtendedViewProps<Name>>;
4
4
  export {};
5
+ //# sourceMappingURL=defineView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineView.d.ts","sourceRoot":"","sources":["../../../../src/app/lib/views/defineView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEnE,KAAK,iBAAiB,CAAC,KAAK,SAAS,MAAM,SAAS,IAAI,KAAK,SAAS,MAAM,GACxE,iBAAiB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GACnC,KAAK,SAAS,QAAQ,GACpB,SAAS,CAAC,KAAK,CAAC,GAChB,SAAS,CAAC,KAAK,CAAC,CAAA;AAEtB,wBAAgB,UAAU,CAAC,IAAI,SAAS,MAAM,SAAS,EACrD,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,SAAS,GACvD,aAAa,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAExC"}
@@ -1 +1,2 @@
1
1
  export * from "./defineView.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/app/lib/views/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
@@ -1,3 +1,6 @@
1
+ export * from "./proxy-wp-admin.js";
2
+ export * from "./render-ai-page.js";
1
3
  export * from "./render-ssr-page.js";
4
+ export * from "./rpc.js";
2
5
  export * from "./server-context.js";
3
- export * from "./proxy-wp-admin.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA"}
@@ -1,3 +1,5 @@
1
+ export * from "./proxy-wp-admin.js";
2
+ export * from "./render-ai-page.js";
1
3
  export * from "./render-ssr-page.js";
4
+ export * from "./rpc.js";
2
5
  export * from "./server-context.js";
3
- export * from "./proxy-wp-admin.js";
@@ -1,3 +1,3 @@
1
1
  import { EventHandlerRequest, H3Event } from "vinxi/http";
2
- import { ServerContext } from "./server-context.js";
3
- export declare function proxyWpAdmin(event: H3Event<EventHandlerRequest>, serverContext: ServerContext): Promise<Response>;
2
+ export declare function proxyWpAdmin(event: H3Event<EventHandlerRequest>): Promise<Response>;
3
+ //# sourceMappingURL=proxy-wp-admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy-wp-admin.d.ts","sourceRoot":"","sources":["../../../src/app/server/proxy-wp-admin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAwD,OAAO,EAAE,MAAM,YAAY,CAAA;AAI/G,wBAAsB,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,mBAAmB,CAAC,qBA+GrE"}
@@ -1,21 +1,48 @@
1
1
  /// <reference types="vinxi/types/server" />
2
2
  import { splitSetCookieString } from "cookie-es";
3
3
  import { getProxyRequestHeaders, getRequestURL, getWebRequest } from "vinxi/http";
4
- export async function proxyWpAdmin(event, serverContext) {
5
- const replaceUrls = serverContext.replaceUrls;
4
+ import { ServerContext } from "./server-context.js";
5
+ import { renderErrorPage } from "./render-ssr-page.js";
6
+ export async function proxyWpAdmin(event) {
7
+ const serverContext = ServerContext.main;
6
8
  const req = getWebRequest(event);
7
- const proxyUrl = serverContext.getOriginUrl(getRequestURL(event).href);
9
+ const reqUrl = getRequestURL(event);
10
+ const serverlessConfig = serverContext.config.serverless;
11
+ if (!serverContext.dev) {
12
+ if (reqUrl.pathname.toLowerCase().match(/\/+(graphql|xmlrpc|\.php|wp\-(admin|login|json|cron))/)) {
13
+ if (serverlessConfig.admin === "hide") {
14
+ //
15
+ return renderErrorPage({
16
+ statusCode: 404,
17
+ title: "Not found",
18
+ userMessage: "The requested resource could not be found.",
19
+ pathname: reqUrl.pathname,
20
+ });
21
+ }
22
+ }
23
+ }
24
+ const proxyUrl = serverContext.getOriginUrl(reqUrl.href);
8
25
  // Prepare request headers to be sent to the origin server
9
26
  const proxyHeaders = getProxyRequestHeaders(event);
10
27
  proxyHeaders["X-ED-Dev-Proxy"] = "true";
28
+ const followRedirects = !reqUrl.pathname.match(/\.[a-z0-9]$/) && !reqUrl.pathname.match(/(^\/wp-|\.php$)/);
11
29
  // Forward the request to the origin server
30
+ // console.log("Proxying request", proxyUrl, {
31
+ // method: req.method,
32
+ // referrer: req.referrer,
33
+ // referrerPolicy: req.referrerPolicy,
34
+ // headers: proxyHeaders,
35
+ // // body: req.method.match(/get|head|options/i) ? undefined : await req.blob(),
36
+ // redirect: followRedirects ? "follow" : "manual",
37
+ // cache: "no-cache",
38
+ // })
12
39
  const response = await fetch(proxyUrl, {
13
40
  method: req.method,
14
41
  referrer: req.referrer,
15
42
  referrerPolicy: req.referrerPolicy,
16
43
  headers: proxyHeaders,
17
44
  body: req.method.match(/get|head|options/i) ? undefined : await req.blob(),
18
- redirect: "manual",
45
+ redirect: followRedirects ? "follow" : "manual",
19
46
  cache: "no-cache",
20
47
  });
21
48
  const contentType = response.headers.get("content-type");
@@ -30,8 +57,8 @@ export async function proxyWpAdmin(event, serverContext) {
30
57
  cookies.push(...splitSetCookieString(value));
31
58
  return;
32
59
  }
33
- if (key === "location" && replaceUrls) {
34
- value = replaceUrls(value);
60
+ if (key === "location") {
61
+ value = serverContext.replaceUrls(value);
35
62
  }
36
63
  res.headers.set(key, value);
37
64
  });
@@ -45,22 +72,28 @@ export async function proxyWpAdmin(event, serverContext) {
45
72
  // Replace URLs pointing to the origin server from the response itself
46
73
  // This is only done for text-based content types, like application/json, text/plain, text/html etc
47
74
  if (contentType?.match(/(application|text)\//)) {
48
- if (replaceUrls) {
49
- body = replaceUrls((await response.text()) ?? "");
50
- }
75
+ body = serverContext.replaceUrls((await response.text()) ?? "", reqUrl.origin);
51
76
  // If the content type is text/html, inject the Vite assets into the response — assuming the placeholder comments are found
52
77
  if (contentType.startsWith("text/html")) {
53
- const clientManifest = serverContext.getManifest("admin");
78
+ const clientManifest = serverContext.runtime.getManifest("admin");
54
79
  const assets = await clientManifest.inputs[clientManifest.handler].assets();
55
- body = body.replace("<!---VITE_HEADER--->", () => assets.map((asset) => renderAsset(asset)).join("\n"));
56
- body = body.replace("<!---VITE_FOOTER--->", () => renderAsset({
80
+ const getViteHeader = () => assets.map((asset) => renderAsset(asset)).join("\n");
81
+ const getViteFooter = () => renderAsset({
57
82
  tag: "script",
58
83
  attrs: {
59
84
  type: "module",
60
85
  src: clientManifest.inputs[clientManifest.handler].output.path,
61
86
  },
62
87
  children: "",
63
- }));
88
+ });
89
+ const encodeForJSON = (str) => JSON.stringify(str).slice(1, -1).replaceAll("/", "\\/");
90
+ const viteHeader = getViteHeader();
91
+ const viteFooter = getViteFooter();
92
+ const baseDirective = `<base href="${reqUrl.origin}">`;
93
+ body = body.replaceAll("<!---VITE_HEADER--->", viteHeader);
94
+ body = body.replaceAll("<!---VITE_FOOTER--->", viteFooter);
95
+ body = body.replaceAll("<script id='vite-iframe-header'><\\/script>", encodeForJSON(baseDirective + viteHeader));
96
+ body = body.replaceAll("<script id='vite-iframe-footer'><\\/script>", encodeForJSON(viteFooter));
64
97
  }
65
98
  }
66
99
  else {
@@ -0,0 +1,13 @@
1
+ type RenderArgs = {
2
+ pathname: string;
3
+ statusCode?: number;
4
+ newOrigin?: string;
5
+ propData?: Record<string, any>;
6
+ };
7
+ export type IndexablePage = {
8
+ shouldIndex: boolean;
9
+ contents: string;
10
+ };
11
+ export declare function renderPageForIndexing(args: RenderArgs): Promise<IndexablePage>;
12
+ export {};
13
+ //# sourceMappingURL=render-ai-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-ai-page.d.ts","sourceRoot":"","sources":["../../../src/app/server/render-ai-page.tsx"],"names":[],"mappings":"AAmGA,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC/B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CA0CpF"}
@@ -0,0 +1,100 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Suspense } from "react";
3
+ import { renderToPipeableStream, renderToString } from "react-dom/server";
4
+ import { Writable } from "stream";
5
+ import { MetaTags } from "../entry/MetaTags.js";
6
+ import { SSRRoot } from "../entry/ssr-root.js";
7
+ import { RouteLoader } from "../lib/routing/loader.js";
8
+ import { ServerContext } from "./server-context.js";
9
+ import { parseHTML } from "linkedom";
10
+ async function getAiSsrStream(args) {
11
+ const jsx = (_jsx(Suspense, { children: _jsx(SSRRoot, { metaTags: args.initialData?.meta?.head || [], pathname: args.pathname, initialData: args.initialData, loader: new RouteLoader(), isAI: true }) }));
12
+ const stream = await new Promise(async (resolve, reject) => {
13
+ // console.log("Rendering to pipable")
14
+ const stream = renderToPipeableStream(jsx, {
15
+ identifierPrefix: "ed",
16
+ onShellReady() {
17
+ // console.log("Shell ready")
18
+ resolve(stream);
19
+ },
20
+ onShellError(err) {
21
+ console.log("onShellError", err);
22
+ reject(err);
23
+ },
24
+ onError(err, errInfo) {
25
+ console.log("Error occurred after shell ready", err, errInfo);
26
+ console.error(err);
27
+ },
28
+ });
29
+ });
30
+ const [initial, middle, end] = renderToString(_jsxs("html", { lang: "en", children: [_jsxs("head", { children: ["%%$%%", _jsx(MetaTags, { tags: args.initialData.meta?.head ?? [] })] }), _jsx("body", { children: _jsx("div", { id: "root", children: "%%$%%" }) })] })).split("%%$%%");
31
+ const inner = await new Promise((resolve, reject) => {
32
+ let buffer = [];
33
+ const writableStream = new Writable({
34
+ emitClose: true,
35
+ write(chunk, encoding, callback) {
36
+ buffer.push(new TextDecoder().decode(chunk));
37
+ callback();
38
+ },
39
+ final(callback) {
40
+ resolve(buffer.join("\n"));
41
+ callback();
42
+ },
43
+ });
44
+ stream.pipe(writableStream);
45
+ });
46
+ const renderedContent = initial + "\n" + middle + "\n" + inner + "\n" + end;
47
+ return processRenderedContent(renderedContent);
48
+ }
49
+ function processRenderedContent(content) {
50
+ const { document } = parseHTML(content);
51
+ // Immediately remove unnecessary tags
52
+ document.querySelectorAll("script, link, style, svg, img, video, [data-ai-hidden]").forEach((el) => {
53
+ el.remove();
54
+ });
55
+ document.querySelectorAll("*").forEach((el) => {
56
+ el.removeAttribute("style");
57
+ el.removeAttribute("class");
58
+ });
59
+ const pageContents = document.querySelectorAll("#ai-page-contents");
60
+ document.body.innerHTML = "";
61
+ document.body.append(...Array.from(pageContents));
62
+ return document.toString();
63
+ }
64
+ export async function renderPageForIndexing(args) {
65
+ const serverContext = ServerContext.main;
66
+ let responseInit = {};
67
+ const [{ appData }, response] = await Promise.all([
68
+ serverContext.fetchAppData(),
69
+ serverContext.fetchRouteData({
70
+ pathname: args.pathname,
71
+ newOrigin: args.newOrigin,
72
+ }),
73
+ ]);
74
+ let data = await response.json();
75
+ data.appData = appData;
76
+ if (args.propData) {
77
+ data = {
78
+ ...data,
79
+ ...args.propData,
80
+ };
81
+ }
82
+ responseInit.status = response.status;
83
+ if (data.redirect) {
84
+ return {
85
+ shouldIndex: false,
86
+ contents: "",
87
+ };
88
+ }
89
+ const headers = new Headers();
90
+ headers.set("Content-Type", "text/html; charset=utf-8");
91
+ responseInit.headers = headers;
92
+ const result = await getAiSsrStream({
93
+ ...args,
94
+ initialData: data,
95
+ });
96
+ return {
97
+ shouldIndex: true,
98
+ contents: result,
99
+ };
100
+ }