eddev 2.0.0-beta.23 → 2.0.0-beta.231

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 (463) 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 +8 -5
  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 +33 -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 +1378 -333
  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 +8 -7
  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 +170 -25
  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 +3 -3
  173. package/dist/app/lib/routing/components/Link.d.ts +22 -2
  174. package/dist/app/lib/routing/components/Link.d.ts.map +1 -0
  175. package/dist/app/lib/routing/components/Link.js +53 -25
  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 → useHydrating.d.ts} +7 -0
  192. package/dist/app/lib/routing/hooks/useHydrating.d.ts.map +1 -0
  193. package/dist/app/lib/routing/hooks/{useIsSSR.js → useHydrating.js} +9 -1
  194. package/dist/app/lib/routing/hooks/useRestorableState.d.ts +3 -1
  195. package/dist/app/lib/routing/hooks/useRestorableState.d.ts.map +1 -0
  196. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -0
  197. package/dist/app/lib/routing/hooks/useRoute.d.ts.map +1 -0
  198. package/dist/app/lib/routing/hooks/useRoute.js +21 -0
  199. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +6 -0
  200. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts.map +1 -0
  201. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  202. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -0
  203. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts.map +1 -0
  204. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -0
  205. package/dist/app/lib/routing/hooks/useRouter.d.ts.map +1 -0
  206. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -0
  207. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts.map +1 -0
  208. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -0
  209. package/dist/app/lib/routing/hooks/useRouterState.d.ts.map +1 -0
  210. package/dist/app/lib/routing/hooks/useSearchParams.d.ts +78 -6
  211. package/dist/app/lib/routing/hooks/useSearchParams.d.ts.map +1 -0
  212. package/dist/app/lib/routing/hooks/useSearchParams.js +75 -15
  213. package/dist/app/lib/routing/index.d.ts +5 -1
  214. package/dist/app/lib/routing/index.d.ts.map +1 -0
  215. package/dist/app/lib/routing/index.js +4 -1
  216. package/dist/app/lib/routing/loader.d.ts +1 -0
  217. package/dist/app/lib/routing/loader.d.ts.map +1 -0
  218. package/dist/app/lib/routing/loader.js +19 -10
  219. package/dist/app/lib/routing/types.d.ts +73 -13
  220. package/dist/app/lib/routing/types.d.ts.map +1 -0
  221. package/dist/app/lib/routing/utils.d.ts +7 -2
  222. package/dist/app/lib/routing/utils.d.ts.map +1 -0
  223. package/dist/app/lib/routing/utils.js +41 -4
  224. package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +11 -2
  225. package/dist/app/lib/runtime/apiConfig.d.ts.map +1 -0
  226. package/dist/app/lib/runtime/apiConfig.js +6 -0
  227. package/dist/app/lib/runtime/errorHandling.d.ts +40 -0
  228. package/dist/app/lib/runtime/errorHandling.d.ts.map +1 -0
  229. package/dist/app/lib/runtime/errorHandling.js +6 -0
  230. package/dist/app/lib/runtime/index.d.ts +3 -0
  231. package/dist/app/lib/runtime/index.d.ts.map +1 -0
  232. package/dist/app/lib/runtime/index.js +2 -0
  233. package/dist/app/lib/views/defineView.d.ts +2 -1
  234. package/dist/app/lib/views/defineView.d.ts.map +1 -0
  235. package/dist/app/lib/views/index.d.ts +1 -0
  236. package/dist/app/lib/views/index.d.ts.map +1 -0
  237. package/dist/app/server/index.d.ts +4 -1
  238. package/dist/app/server/index.d.ts.map +1 -0
  239. package/dist/app/server/index.js +3 -1
  240. package/dist/app/server/proxy-wp-admin.d.ts +2 -2
  241. package/dist/app/server/proxy-wp-admin.d.ts.map +1 -0
  242. package/dist/app/server/proxy-wp-admin.js +46 -13
  243. package/dist/app/server/render-ai-page.d.ts +13 -0
  244. package/dist/app/server/render-ai-page.d.ts.map +1 -0
  245. package/dist/app/server/render-ai-page.js +102 -0
  246. package/dist/app/server/render-ssr-page.d.ts +32 -3
  247. package/dist/app/server/render-ssr-page.d.ts.map +1 -0
  248. package/dist/app/server/render-ssr-page.js +237 -10
  249. package/dist/app/server/rpc.d.ts +52 -0
  250. package/dist/app/server/rpc.d.ts.map +1 -0
  251. package/dist/app/server/rpc.js +18 -0
  252. package/dist/app/server/server-context.d.ts +53 -7
  253. package/dist/app/server/server-context.d.ts.map +1 -0
  254. package/dist/app/server/server-context.js +375 -37
  255. package/dist/app/server/server-custom-config.d.ts +3 -0
  256. package/dist/app/server/server-custom-config.d.ts.map +1 -0
  257. package/dist/app/server/server-custom-config.js +1 -0
  258. package/dist/app/server/utils/content-security.d.ts +26 -0
  259. package/dist/app/server/utils/content-security.d.ts.map +1 -0
  260. package/dist/app/server/utils/content-security.js +124 -0
  261. package/dist/app/server/utils/headers.d.ts +1 -0
  262. package/dist/app/server/utils/headers.d.ts.map +1 -0
  263. package/dist/app/server/utils/replace-host.d.ts +2 -1
  264. package/dist/app/server/utils/replace-host.d.ts.map +1 -0
  265. package/dist/app/server/utils/replace-host.js +10 -2
  266. package/dist/app/server/utils/swr-cache.d.ts +5 -0
  267. package/dist/app/server/utils/swr-cache.d.ts.map +1 -0
  268. package/dist/app/server/utils/swr-cache.js +31 -0
  269. package/dist/app/utils/APIProvider.d.ts +3 -0
  270. package/dist/app/utils/APIProvider.d.ts.map +1 -0
  271. package/dist/app/utils/APIProvider.js +5 -0
  272. package/dist/app/utils/BlockErrorBoundary.d.ts +20 -0
  273. package/dist/app/utils/BlockErrorBoundary.d.ts.map +1 -0
  274. package/dist/app/utils/BlockErrorBoundary.js +38 -0
  275. package/dist/app/utils/ErrorMessage.d.ts +6 -0
  276. package/dist/app/utils/ErrorMessage.d.ts.map +1 -0
  277. package/dist/app/utils/ErrorMessage.js +14 -0
  278. package/dist/app/utils/RouteErrorBoundary.d.ts +20 -0
  279. package/dist/app/utils/RouteErrorBoundary.d.ts.map +1 -0
  280. package/dist/app/utils/RouteErrorBoundary.js +41 -0
  281. package/dist/app/utils/asset-capture.d.ts +3 -0
  282. package/dist/app/utils/asset-capture.d.ts.map +1 -0
  283. package/dist/app/utils/asset-capture.js +5 -0
  284. package/dist/app/utils/hydration-debugger.d.ts +14 -0
  285. package/dist/app/utils/hydration-debugger.d.ts.map +1 -0
  286. package/dist/app/utils/hydration-debugger.js +11 -0
  287. package/dist/app/utils/query-client.d.ts +3 -0
  288. package/dist/app/utils/query-client.d.ts.map +1 -0
  289. package/dist/app/utils/query-client.js +5 -1
  290. package/dist/app/utils/query-monitor.d.ts +27 -0
  291. package/dist/app/utils/query-monitor.d.ts.map +1 -0
  292. package/dist/app/utils/query-monitor.js +7 -0
  293. package/dist/app/utils/trpc-client.d.ts +3 -0
  294. package/dist/app/utils/trpc-client.d.ts.map +1 -0
  295. package/dist/app/utils/trpc-client.js +39 -0
  296. package/dist/app/utils/wp.d.ts +11 -10
  297. package/dist/app/utils/wp.d.ts.map +1 -0
  298. package/dist/node/cli/cli-mode.d.ts +1 -0
  299. package/dist/node/cli/cli-mode.d.ts.map +1 -0
  300. package/dist/node/cli/cli-worker.d.ts +1 -0
  301. package/dist/node/cli/cli-worker.d.ts.map +1 -0
  302. package/dist/node/cli/cli-worker.js +7 -3
  303. package/dist/node/cli/cli.d.ts +1 -0
  304. package/dist/node/cli/cli.d.ts.map +1 -0
  305. package/dist/node/cli/cli.js +120 -7
  306. package/dist/node/cli/display/CLIApp.d.ts +1 -0
  307. package/dist/node/cli/display/CLIApp.d.ts.map +1 -0
  308. package/dist/node/cli/display/CLIApp.js +1 -1
  309. package/dist/node/cli/display/boot-cli-app.d.ts +1 -0
  310. package/dist/node/cli/display/boot-cli-app.d.ts.map +1 -0
  311. package/dist/node/cli/display/boot-cli-app.js +1 -1
  312. package/dist/node/cli/display/components/Fullscreen.d.ts +1 -0
  313. package/dist/node/cli/display/components/Fullscreen.d.ts.map +1 -0
  314. package/dist/node/cli/display/components/LogEntries.d.ts +1 -0
  315. package/dist/node/cli/display/components/LogEntries.d.ts.map +1 -0
  316. package/dist/node/cli/display/components/MenuItem.d.ts +1 -0
  317. package/dist/node/cli/display/components/MenuItem.d.ts.map +1 -0
  318. package/dist/node/cli/display/components/TextInput.d.ts +1 -0
  319. package/dist/node/cli/display/components/TextInput.d.ts.map +1 -0
  320. package/dist/node/cli/display/hooks/useManifest.d.ts +1 -0
  321. package/dist/node/cli/display/hooks/useManifest.d.ts.map +1 -0
  322. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -0
  323. package/dist/node/cli/display/hooks/useStatefulLog.d.ts.map +1 -0
  324. package/dist/node/cli/display/tools/BlockList.d.ts +1 -0
  325. package/dist/node/cli/display/tools/BlockList.d.ts.map +1 -0
  326. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -0
  327. package/dist/node/cli/display/tools/CreateBlock.d.ts.map +1 -0
  328. package/dist/node/cli/display/tools/cli-tool-list.d.ts +1 -0
  329. package/dist/node/cli/display/tools/cli-tool-list.d.ts.map +1 -0
  330. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -0
  331. package/dist/node/cli/display/tools/cli-tools.d.ts.map +1 -0
  332. package/dist/node/cli/display/util/colors.d.ts +1 -0
  333. package/dist/node/cli/display/util/colors.d.ts.map +1 -0
  334. package/dist/node/cli/version.d.ts +2 -1
  335. package/dist/node/cli/version.d.ts.map +1 -0
  336. package/dist/node/cli/version.js +1 -1
  337. package/dist/node/compiler/build-vinxi.d.ts +1 -0
  338. package/dist/node/compiler/build-vinxi.d.ts.map +1 -0
  339. package/dist/node/compiler/build-vinxi.js +2 -1
  340. package/dist/node/compiler/bundler.admin.d.ts +1 -0
  341. package/dist/node/compiler/bundler.admin.d.ts.map +1 -0
  342. package/dist/node/compiler/bundler.admin.js +1 -0
  343. package/dist/node/compiler/bundler.frontend.d.ts +2 -0
  344. package/dist/node/compiler/bundler.frontend.d.ts.map +1 -0
  345. package/dist/node/compiler/bundler.frontend.js +26 -11
  346. package/dist/node/compiler/cache-config.d.ts +3 -0
  347. package/dist/node/compiler/cache-config.d.ts.map +1 -0
  348. package/dist/node/compiler/cache-config.js +16 -0
  349. package/dist/node/compiler/dev-server.d.ts +4 -1
  350. package/dist/node/compiler/dev-server.d.ts.map +1 -0
  351. package/dist/node/compiler/dev-server.js +34 -11
  352. package/dist/node/compiler/get-vite-config.d.ts +12 -1
  353. package/dist/node/compiler/get-vite-config.d.ts.map +1 -0
  354. package/dist/node/compiler/get-vite-config.js +176 -42
  355. package/dist/node/compiler/vinxi-app.d.ts +13 -0
  356. package/dist/node/compiler/vinxi-app.d.ts.map +1 -0
  357. package/dist/node/compiler/vinxi-app.js +151 -32
  358. package/dist/node/compiler/vinxi-codegen.d.ts +1 -0
  359. package/dist/node/compiler/vinxi-codegen.d.ts.map +1 -0
  360. package/dist/node/compiler/vinxi-codegen.js +394 -108
  361. package/dist/node/graphql/graphql-codegen.d.ts +12 -1
  362. package/dist/node/graphql/graphql-codegen.d.ts.map +1 -0
  363. package/dist/node/graphql/graphql-codegen.js +239 -37
  364. package/dist/node/graphql/graphql-schema-loader.d.ts +3 -1
  365. package/dist/node/graphql/graphql-schema-loader.d.ts.map +1 -0
  366. package/dist/node/graphql/graphql-schema-loader.js +5 -16
  367. package/dist/node/graphql/plugins/gql-plugin-files.d.ts +3 -1
  368. package/dist/node/graphql/plugins/gql-plugin-files.d.ts.map +1 -0
  369. package/dist/node/graphql/plugins/gql-plugin-files.js +3 -2
  370. package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts +1 -0
  371. package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts.map +1 -0
  372. package/dist/node/graphql/plugins/gql-plugin-queries.d.ts +1 -0
  373. package/dist/node/graphql/plugins/gql-plugin-queries.d.ts.map +1 -0
  374. package/dist/node/graphql/plugins/gql-plugin-queries.js +2 -2
  375. package/dist/node/graphql/query-files-loader.d.ts +4 -0
  376. package/dist/node/graphql/query-files-loader.d.ts.map +1 -0
  377. package/dist/node/graphql/query-files-loader.js +5 -0
  378. package/dist/node/graphql/wp-info-query.d.ts +1 -0
  379. package/dist/node/graphql/wp-info-query.d.ts.map +1 -0
  380. package/dist/node/project/config.d.ts +260 -69
  381. package/dist/node/project/config.d.ts.map +1 -0
  382. package/dist/node/project/config.js +100 -21
  383. package/dist/node/project/eddev-build-file.d.ts +1 -0
  384. package/dist/node/project/eddev-build-file.d.ts.map +1 -0
  385. package/dist/node/project/eddev-build-file.js +4 -2
  386. package/dist/node/project/env.d.ts +5 -0
  387. package/dist/node/project/env.d.ts.map +1 -0
  388. package/dist/node/project/env.js +1 -0
  389. package/dist/node/project/favicons.d.ts +1 -1
  390. package/dist/node/project/favicons.d.ts.map +1 -0
  391. package/dist/node/project/favicons.js +1 -1
  392. package/dist/node/project/manifest/block-manifest.d.ts +1 -0
  393. package/dist/node/project/manifest/block-manifest.d.ts.map +1 -0
  394. package/dist/node/project/manifest/block-manifest.js +6 -2
  395. package/dist/node/project/manifest/field-manifest.d.ts +1 -0
  396. package/dist/node/project/manifest/field-manifest.d.ts.map +1 -0
  397. package/dist/node/project/manifest/manifest.d.ts +2 -0
  398. package/dist/node/project/manifest/manifest.d.ts.map +1 -0
  399. package/dist/node/project/manifest/manifest.js +14 -10
  400. package/dist/node/project/manifest/routes-manifest.d.ts +21 -0
  401. package/dist/node/project/manifest/routes-manifest.d.ts.map +1 -0
  402. package/dist/node/project/manifest/routes-manifest.js +74 -0
  403. package/dist/node/project/manifest/view-manifest.d.ts +1 -0
  404. package/dist/node/project/manifest/view-manifest.d.ts.map +1 -0
  405. package/dist/node/project/manifest/widget-manifest.d.ts +1 -0
  406. package/dist/node/project/manifest/widget-manifest.d.ts.map +1 -0
  407. package/dist/node/project/project.d.ts +12 -0
  408. package/dist/node/project/project.d.ts.map +1 -0
  409. package/dist/node/project/project.js +55 -1
  410. package/dist/node/project/wp-info.d.ts +3 -0
  411. package/dist/node/project/wp-info.d.ts.map +1 -0
  412. package/dist/node/project/wp-info.js +10 -1
  413. package/dist/node/storybook/index.d.ts +3 -0
  414. package/dist/node/storybook/index.d.ts.map +1 -0
  415. package/dist/node/storybook/index.js +13 -0
  416. package/dist/node/types/block-type.d.ts +37 -5
  417. package/dist/node/types/block-type.d.ts.map +1 -0
  418. package/dist/node/types/block-type.js +4 -1
  419. package/dist/node/types/view-type.d.ts +1 -0
  420. package/dist/node/types/view-type.d.ts.map +1 -0
  421. package/dist/node/utils/fetch-wp.d.ts +2 -0
  422. package/dist/node/utils/fetch-wp.d.ts.map +1 -0
  423. package/dist/node/utils/fetch-wp.js +28 -0
  424. package/dist/node/utils/format-zod-error.d.ts +1 -0
  425. package/dist/node/utils/format-zod-error.d.ts.map +1 -0
  426. package/dist/node/utils/fs-codegen.d.ts +4 -0
  427. package/dist/node/utils/fs-codegen.d.ts.map +1 -0
  428. package/dist/node/utils/fs-codegen.js +10 -2
  429. package/dist/node/utils/fs.d.ts +6 -1
  430. package/dist/node/utils/fs.d.ts.map +1 -0
  431. package/dist/node/utils/get-repo-info.d.ts +1 -0
  432. package/dist/node/utils/get-repo-info.d.ts.map +1 -0
  433. package/dist/node/utils/helpers.d.ts +1 -0
  434. package/dist/node/utils/helpers.d.ts.map +1 -0
  435. package/dist/node/utils/highlight-code.d.ts +1 -0
  436. package/dist/node/utils/highlight-code.d.ts.map +1 -0
  437. package/dist/node/utils/is-deploying.d.ts +1 -0
  438. package/dist/node/utils/is-deploying.d.ts.map +1 -0
  439. package/dist/node/utils/is-deploying.js +1 -1
  440. package/dist/node/utils/report-builder.d.ts +7 -6
  441. package/dist/node/utils/report-builder.d.ts.map +1 -0
  442. package/dist/node/utils/self-signed-cert.d.ts +5 -0
  443. package/dist/node/utils/self-signed-cert.d.ts.map +1 -0
  444. package/dist/node/utils/self-signed-cert.js +28 -4
  445. package/dist/node/utils/stateful-log.d.ts +1 -0
  446. package/dist/node/utils/stateful-log.d.ts.map +1 -0
  447. package/dist/node/utils/stateful-log.js +2 -0
  448. package/dist/node/utils/ts-export-extractor.d.ts +1 -0
  449. package/dist/node/utils/ts-export-extractor.d.ts.map +1 -0
  450. package/dist/node/utils/watch-file-tree.d.ts +18 -3
  451. package/dist/node/utils/watch-file-tree.d.ts.map +1 -0
  452. package/dist/node/utils/watch-file-tree.js +12 -5
  453. package/package.json +40 -24
  454. package/tsconfig.app.json +10 -5
  455. package/tsconfig.node.json +3 -2
  456. package/types.app.d.ts +2 -0
  457. package/types.env.d.ts +3 -0
  458. package/types.meta.d.ts +449 -136
  459. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  460. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  461. package/dist/app/lib/hooks/apiConfig.js +0 -4
  462. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  463. package/dist/app/lib/hooks/usePageLoad.js +0 -5
@@ -1,7 +1,13 @@
1
- import { parseURL, stringifyParsedURL, withQuery } from "ufo";
1
+ import { parseURL, stringifyParsedURL, withQuery, withTrailingSlash } from "ufo";
2
+ import { getCookie, getHeader } from "vinxi/http";
3
+ import { fetchWP } from "../../node/utils/fetch-wp.js";
2
4
  import { filterHeader } from "./utils/headers.js";
3
5
  import { createUrlReplacer } from "./utils/replace-host.js";
4
- const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control"];
6
+ import { pageCache, queryCache, swr } from "./utils/swr-cache.js";
7
+ import { QueryMonitor } from "../utils/query-monitor.js";
8
+ import chalk from "chalk";
9
+ import { inspect } from "node:util";
10
+ const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control", /woocommerce/, "location"];
5
11
  const PROXY_REQUEST_HEADERS = [
6
12
  "content-type",
7
13
  "accept",
@@ -11,19 +17,40 @@ const PROXY_REQUEST_HEADERS = [
11
17
  "referer",
12
18
  "user-agent",
13
19
  "authorization",
20
+ "woocommerce-session",
14
21
  ];
22
+ const VARIES_HEADERS = ["Authorization", "woocommerce-session"];
23
+ let runtime;
15
24
  export class ServerContext {
16
25
  dev;
17
26
  origin;
18
- getManifest;
19
- replaceUrls;
27
+ _urlReplacer;
28
+ rpcBases = [];
29
+ config;
30
+ cacheConfig;
31
+ static main;
20
32
  constructor(conf) {
21
33
  this.dev = conf.dev;
22
34
  this.origin = conf.origin;
23
- this.getManifest = conf.getManifest;
35
+ this.rpcBases = conf.rpcBases ?? [];
36
+ this.config = conf.config;
37
+ this.cacheConfig = conf.cacheConfig;
24
38
  if (conf.replaceUrls) {
25
- this.replaceUrls = createUrlReplacer(conf.replaceUrls);
39
+ this._urlReplacer = createUrlReplacer(conf.replaceUrls);
26
40
  }
41
+ ServerContext.main = this;
42
+ }
43
+ replaceUrls(text, origin) {
44
+ if (this._urlReplacer) {
45
+ return this._urlReplacer(text, origin);
46
+ }
47
+ return text;
48
+ }
49
+ get runtime() {
50
+ return runtime;
51
+ }
52
+ static setRuntime(rt) {
53
+ runtime = rt;
27
54
  }
28
55
  getOriginUrl(url) {
29
56
  const parsed = parseURL(url);
@@ -34,13 +61,11 @@ export class ServerContext {
34
61
  }
35
62
  async fetchOrigin(url, opts) {
36
63
  url = this.getOriginUrl(url);
37
- const response = await fetch(url, {
38
- ...opts,
39
- headers: {
40
- "Content-Type": "application/json",
41
- Accept: "application/json",
42
- ...opts?.headers,
43
- },
64
+ const fetchOps = { ...opts };
65
+ delete fetchOps.replaceUrls;
66
+ delete fetchOps.newOrigin;
67
+ const response = await fetchWP(url, {
68
+ ...fetchOps,
44
69
  });
45
70
  if (!response.ok) {
46
71
  return response;
@@ -52,8 +77,8 @@ export class ServerContext {
52
77
  }
53
78
  });
54
79
  let text = await response.text();
55
- if (opts?.replaceUrls && this.replaceUrls) {
56
- text = this.replaceUrls(text);
80
+ if (opts?.replaceUrls) {
81
+ text = this.replaceUrls(text, opts.newOrigin);
57
82
  }
58
83
  return new Response(text, {
59
84
  status: response.status,
@@ -61,22 +86,226 @@ export class ServerContext {
61
86
  headers,
62
87
  });
63
88
  }
89
+ debugLogQueryMonitor(kind, uri, monitor) {
90
+ if (!QueryMonitor.hasLogEntries(monitor))
91
+ return;
92
+ let indentLevel = 2;
93
+ const finalOutput = [];
94
+ let label = "";
95
+ if (kind === "props") {
96
+ label = "While fetching props for route '" + uri + "'";
97
+ }
98
+ else if (kind === "query") {
99
+ label = "While querying " + uri + " via REST API";
100
+ }
101
+ else if (kind === "mutation") {
102
+ label = "While mutating " + uri + " via REST API";
103
+ }
104
+ else if (kind === "app") {
105
+ label = "While fetching app data";
106
+ }
107
+ finalOutput.push(chalk.whiteBright("➜ " + label));
108
+ function printEntry(entry) {
109
+ finalOutput.push(indent(indentLevel, chalk.whiteBright("➜ " + entry.file) + " " + chalk.gray(entry.label ? `(${entry.label})` : "")));
110
+ indentLevel += 2;
111
+ if (entry.log && entry.log.length) {
112
+ for (let item of entry.log) {
113
+ let output = "";
114
+ let prefix = "";
115
+ let message = item.message;
116
+ let stack = [];
117
+ if (item.type === "php_error") {
118
+ prefix = chalk.red("PHP Error:");
119
+ }
120
+ else if (item.type === "php_warning") {
121
+ prefix = chalk.yellow("PHP Warning:");
122
+ }
123
+ else if (item.type === "php_notice") {
124
+ prefix = chalk.yellow("PHP Notice:");
125
+ }
126
+ else if (item.type === "GRAPHQL_DEBUG") {
127
+ prefix = chalk.cyan("debug:");
128
+ }
129
+ else if (item.type === "error" && item.extensions?.category === "user") {
130
+ prefix = chalk.red("UserError:");
131
+ }
132
+ else {
133
+ prefix = chalk.gray((item.type || "Log") + ":");
134
+ }
135
+ if (typeof message !== "string") {
136
+ message = inspect(message, { depth: 4 });
137
+ }
138
+ if (item.debugMessage) {
139
+ message += "\n" + chalk.gray(item.debugMessage);
140
+ }
141
+ output += prefix + " " + message;
142
+ if (item.path) {
143
+ stack.push(chalk.gray(" at path " + JSON.stringify(item.path)));
144
+ }
145
+ if (item.file) {
146
+ stack.push(chalk.gray(`at ${chalk.white(item.file)} line ${item.line || "??"}`));
147
+ }
148
+ if (item.stack?.length) {
149
+ stack.push(item.stack
150
+ .filter((line) => {
151
+ return line !== item.file + ":" + item.line;
152
+ })
153
+ .slice(0, 4)
154
+ .map((line) => " " + chalk.gray(line))
155
+ .join("\n"));
156
+ }
157
+ if (stack.length > 0) {
158
+ output += indent(2, "\n" + stack.join("\n"));
159
+ }
160
+ finalOutput.push(indent(indentLevel, "➜ " + output));
161
+ }
162
+ }
163
+ for (let child of entry.children ?? []) {
164
+ printEntry(child);
165
+ }
166
+ indentLevel -= 2;
167
+ }
168
+ for (let entry of monitor) {
169
+ printEntry(entry);
170
+ }
171
+ }
64
172
  async fetchRouteData(req) {
65
- const fetchUrl = withQuery(req.pathname, {
66
- ...req.query,
67
- _props: req.withAppData ? "all" : "1",
68
- _ssr: "1",
69
- _debug: this.dev ? "1" : undefined,
173
+ /**
174
+ * Calculcate the cache key.
175
+ * For route data, the cache key is the pathname.
176
+ * TODO: Potential support for Vercel draft mode.
177
+ */
178
+ let cacheKey = "fetchRouteData:" + withTrailingSlash(req.pathname.toLowerCase());
179
+ const result = await swr({
180
+ key: cacheKey,
181
+ cache: pageCache,
182
+ forceFresh: this.dev || req.bypass,
183
+ staleWhileRevalidate: 10000,
184
+ getFreshValue: async (ctx) => {
185
+ const fetchUrl = withQuery(withTrailingSlash(req.pathname), {
186
+ _props: "1",
187
+ _ssr: "1",
188
+ _debug: this.dev ? "1" : undefined,
189
+ });
190
+ const result = await this.fetchOrigin(fetchUrl, {
191
+ cache: "no-cache",
192
+ replaceUrls: true,
193
+ newOrigin: req.newOrigin,
194
+ headers: {
195
+ "Content-Type": "application/json",
196
+ Accept: "application/json",
197
+ },
198
+ redirect: "manual",
199
+ });
200
+ const preferredCacheDuration = parseInt(result.headers.get("x-ed-cache-duration") ?? "");
201
+ if (this.cacheConfig.serverless.isr) {
202
+ ctx.metadata.ttl = 5000;
203
+ }
204
+ else if (isFinite(preferredCacheDuration)) {
205
+ ctx.metadata.ttl = preferredCacheDuration * 1000;
206
+ }
207
+ let resultStatus = result.status;
208
+ let resultHeaders = new Headers(result.headers);
209
+ let resultData = {};
210
+ // Special case for redirects
211
+ if (result.headers.has("location")) {
212
+ let location = result.headers.get("location");
213
+ let status = result.status;
214
+ if (this.replaceUrls) {
215
+ location = this.replaceUrls(location);
216
+ }
217
+ return {
218
+ status: 200,
219
+ headers: new Headers({
220
+ "Content-Type": "application/json",
221
+ }),
222
+ data: JSON.stringify({ redirect: location, status: status }),
223
+ };
224
+ }
225
+ try {
226
+ resultData = await result.json();
227
+ }
228
+ catch (err) {
229
+ console.error(`Invalid JSON response from '${fetchUrl}'. An error page will be displayed.`);
230
+ ctx.metadata.ttl = 0;
231
+ return {
232
+ status: 500,
233
+ headers: resultHeaders,
234
+ data: JSON.stringify({
235
+ view: "_error",
236
+ viewData: {
237
+ data: {
238
+ statusCode: 500,
239
+ title: "Internal Server Error",
240
+ userMessage: "An internal server error occurred.",
241
+ report: {
242
+ details: "A JSON parsing error occurred while fetching route data.",
243
+ message: err.message,
244
+ },
245
+ },
246
+ },
247
+ }),
248
+ };
249
+ }
250
+ if (resultData && typeof resultData === "object") {
251
+ resultData.__generated = new Date().toISOString();
252
+ }
253
+ if (resultData.queryMonitor) {
254
+ this.debugLogQueryMonitor("props", req.pathname, resultData.queryMonitor);
255
+ }
256
+ // if (isFinite(preferredCacheDuration)) {
257
+ // const maxAge = isFinite(preferredCacheDuration) ? preferredCacheDuration * 1000 : undefined
258
+ // resultHeaders.set("Cache-Control", `max-age=0, s-maxage=${maxAge}, stale-while-revalidate`)
259
+ // }
260
+ resultHeaders.set("X-Ed-Fetched-At", new Date().toUTCString());
261
+ return {
262
+ status: resultStatus,
263
+ headers: resultHeaders,
264
+ data: JSON.stringify(resultData),
265
+ };
266
+ },
70
267
  });
71
- return this.fetchOrigin(fetchUrl, {
72
- cache: "no-cache",
73
- replaceUrls: true,
74
- headers: {
75
- "Content-Type": "application/json",
76
- Accept: "application/json",
77
- ...this.extractRequestHeaders(req.headers),
268
+ if (this.cacheConfig.serverless.isr) {
269
+ result.headers.delete("cache-control");
270
+ }
271
+ return new Response(result.data, {
272
+ status: result.status,
273
+ headers: result.headers,
274
+ });
275
+ }
276
+ async fetchAppData(args) {
277
+ const data = await swr({
278
+ key: "fetchAppData",
279
+ cache: pageCache,
280
+ forceFresh: this.dev || args.bypass,
281
+ staleWhileRevalidate: 10000,
282
+ getFreshValue: async (ctx) => {
283
+ const response = await this.fetchOrigin("/_appdata", {
284
+ cache: "no-cache",
285
+ replaceUrls: true,
286
+ newOrigin: args.newOrigin,
287
+ headers: {
288
+ "Content-Type": "application/json",
289
+ Accept: "application/json",
290
+ },
291
+ });
292
+ const result = await response.json();
293
+ const preferredCacheDuration = parseInt(response.headers.get("x-ed-cache-duration") ?? "");
294
+ if (isFinite(preferredCacheDuration)) {
295
+ ctx.metadata.ttl = preferredCacheDuration * 1000;
296
+ }
297
+ // In ISR mode, set a super short TTL to avoid caching, but preventing constant revalidation
298
+ if (this.cacheConfig.serverless.isr) {
299
+ ctx.metadata.ttl = 5000;
300
+ }
301
+ if (result.queryMonitor) {
302
+ this.debugLogQueryMonitor("app", "", result.queryMonitor);
303
+ }
304
+ result.__generated = new Date().toISOString();
305
+ return result;
78
306
  },
79
307
  });
308
+ return data;
80
309
  }
81
310
  extractRequestHeaders(req) {
82
311
  const headers = {};
@@ -90,19 +319,65 @@ export class ServerContext {
90
319
  return headers;
91
320
  }
92
321
  async fetchNamedQuery(req) {
93
- const url = `/wp-json/ed/v1/query/${req.name}?params=${encodeURIComponent(JSON.stringify(req.params))}`;
94
- return this.fetchOrigin(url, {
95
- cache: "no-cache",
96
- replaceUrls: true,
97
- headers: {
98
- ...this.extractRequestHeaders(req.headers),
99
- "Content-Type": "application/json",
100
- Accept: "application/json",
101
- },
322
+ const url = `/wp-json/ed/v1/query/${req.name.replace(/^\//, "")}?params=${encodeURIComponent(JSON.stringify(req.params))}`;
323
+ const key = `fetchNamedQuery:${req.name}:${JSON.stringify(req.params)}`;
324
+ const fetch = async () => {
325
+ const result = await this.fetchOrigin(url, {
326
+ cache: "no-cache",
327
+ replaceUrls: true,
328
+ headers: {
329
+ ...this.extractRequestHeaders(req.headers),
330
+ "Content-Type": "application/json",
331
+ Accept: "application/json",
332
+ },
333
+ });
334
+ const preferredCacheDuration = parseInt(result.headers.get("x-ed-cache-duration") ?? "");
335
+ let resultStatus = result.status;
336
+ let resultHeaders = result.headers;
337
+ let resultData = await result.json();
338
+ if (resultData && typeof resultData === "object") {
339
+ resultData.__generated = new Date().toISOString();
340
+ }
341
+ resultHeaders.set("X-Ed-Rendered-At", new Date().toUTCString());
342
+ if (resultData.queryMonitor) {
343
+ this.debugLogQueryMonitor("query", req.name, resultData.queryMonitor);
344
+ }
345
+ return {
346
+ status: resultStatus,
347
+ headers: resultHeaders,
348
+ data: JSON.stringify(resultData),
349
+ cacheTime: isFinite(preferredCacheDuration) ? preferredCacheDuration * 1000 : undefined,
350
+ };
351
+ };
352
+ // If headers like 'Authorization' are set, then we shouldn't cache.
353
+ const hasVariedHeaders = VARIES_HEADERS.some((key) => !!req.headers[key]);
354
+ // Get the result, either from cache or by fetching.
355
+ const result = hasVariedHeaders
356
+ ? await fetch()
357
+ : await swr({
358
+ key,
359
+ cache: queryCache,
360
+ forceFresh: this.dev || req.bypass,
361
+ staleWhileRevalidate: 10000,
362
+ getFreshValue: async (ctx) => {
363
+ const result = await fetch();
364
+ ctx.metadata.ttl = result.cacheTime;
365
+ if (this.cacheConfig.serverless.isr) {
366
+ ctx.metadata.ttl = 5000;
367
+ }
368
+ return result;
369
+ },
370
+ });
371
+ if (this.cacheConfig.serverless.isr) {
372
+ result.headers.delete("cache-control");
373
+ }
374
+ return new Response(result.data, {
375
+ status: result.status,
376
+ headers: result.headers,
102
377
  });
103
378
  }
104
379
  async fetchMutation(req) {
105
- const url = `/wp-json/ed/v1/mutation/${req.name}`;
380
+ const url = `/wp-json/ed/v1/mutation/${req.name.replace(/^\//, "")}`;
106
381
  return this.fetchOrigin(url, {
107
382
  method: "POST",
108
383
  cache: "no-cache",
@@ -115,4 +390,67 @@ export class ServerContext {
115
390
  body: JSON.stringify(req.body),
116
391
  });
117
392
  }
393
+ get allowedCorsOrigins() {
394
+ let result = [];
395
+ if (this.config.serverless.endpoints) {
396
+ result.push(...Object.keys(this.config.serverless.endpoints));
397
+ result.push(...Object.values(this.config.serverless.endpoints));
398
+ result = result.filter((origin) => origin !== "*");
399
+ }
400
+ if (this.config.serverless.cors?.origins) {
401
+ result.push(...this.config.serverless.cors.origins.map((origin) => origin.replace(/(https?:\/\/|\/$)/, "")));
402
+ }
403
+ return result;
404
+ }
405
+ shouldBypass(event) {
406
+ const bypassToken = process.env.VERCEL_BYPASS_TOKEN;
407
+ if (!bypassToken)
408
+ return false;
409
+ const cookieName = "__prerender_bypass";
410
+ if (getCookie(event, cookieName) === bypassToken) {
411
+ return true;
412
+ }
413
+ if (getHeader(event, "x-prerender-revalidate") === bypassToken) {
414
+ return true;
415
+ }
416
+ return false;
417
+ }
418
+ getCorsOrigin(originHeader) {
419
+ const parsed = parseURL(originHeader);
420
+ if (this.allowedCorsOrigins.includes(parsed.host)) {
421
+ return originHeader;
422
+ }
423
+ if (this.allowedCorsOrigins.includes("*")) {
424
+ return "*";
425
+ }
426
+ }
427
+ getCorsHeaders(origin) {
428
+ if (!origin)
429
+ return {};
430
+ const allowedOrigin = this.getCorsOrigin(origin);
431
+ if (allowedOrigin) {
432
+ return {
433
+ "Access-Control-Allow-Methods": "OPTIONS,GET,HEAD,PUT,PATCH,POST,DELETE",
434
+ "Access-Control-Allow-Origin": allowedOrigin,
435
+ "Access-Control-Allow-Credentials": "true",
436
+ "Access-Control-Allow-Headers": "*",
437
+ "Access-Control-Expose-Headers": "*",
438
+ };
439
+ }
440
+ return {};
441
+ }
442
+ }
443
+ function indent(count, str) {
444
+ const indent = " ".repeat(count);
445
+ return str
446
+ .split("\n")
447
+ .map((line) => indent + line)
448
+ .join("\n");
449
+ }
450
+ function indentAllButFirst(count, str) {
451
+ const indent = " ".repeat(count);
452
+ return str
453
+ .split("\n")
454
+ .map((line, i) => (i === 0 ? line : indent + line))
455
+ .join("\n");
118
456
  }
@@ -0,0 +1,3 @@
1
+ export type ServerConfig = {};
2
+ export declare function defineServerConfig(): void;
3
+ //# sourceMappingURL=server-custom-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-custom-config.d.ts","sourceRoot":"","sources":["../../../src/app/server/server-custom-config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,EAAE,CAAA;AAE7B,wBAAgB,kBAAkB,SAAK"}
@@ -0,0 +1 @@
1
+ export function defineServerConfig() { }
@@ -0,0 +1,26 @@
1
+ import type { EDConfig } from "../../../node/project/config";
2
+ import { RouteMetaTag, TrackerTags } from "../../lib/routing";
3
+ declare const CSP_KEYS: readonly ["childSrc", "connectSrc", "defaultSrc", "fencedFrameSrc", "fontSrc", "frameSrc", "imgSrc", "manifestSrc", "mediaSrc", "objectSrc", "scriptSrc", "scriptSrcElem", "scriptSrcAttr", "styleSrc", "styleSrcElem", "styleSrcAttr", "workerSrc", "baseUri", "formAction", "frameAncestors", "reportTo", "requireTrustedTypesFor", "trustedTypes", "upgradeInsecureRequests"];
4
+ export type CSPKey = (typeof CSP_KEYS)[number];
5
+ export type CSPParams = Record<CSPKey, Set<string>>;
6
+ export type ContentSecurityPolicyRequestContext = {
7
+ url: string;
8
+ type: "page";
9
+ tags: RouteMetaTag[];
10
+ };
11
+ export declare class SecureHeaderBuilder {
12
+ protected csp: CSPParams;
13
+ protected headers: Headers;
14
+ private cspEnabled;
15
+ private autodetectCspOrigins;
16
+ private useNonce;
17
+ private commonCspOrigins;
18
+ readonly nonce: string | undefined;
19
+ constructor(config: EDConfig);
20
+ addTrackingTags(tags: TrackerTags): TrackerTags;
21
+ addMetaTags(tags: RouteMetaTag[]): RouteMetaTag[];
22
+ getHeaders(): Headers;
23
+ getCSPHeaderValue(): string | undefined;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=content-security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-security.d.ts","sourceRoot":"","sources":["../../../../src/app/server/utils/content-security.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAG7D,QAAA,MAAM,QAAQ,kXAyBJ,CAAA;AAEV,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAA;AAE9C,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AAEnD,MAAM,MAAM,mCAAmC,GAAG;IAChD,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,YAAY,EAAE,CAAA;CACrB,CAAA;AAED,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,GAAG,EAAE,SAAS,CAAA;IACxB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAgB;IAE1C,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,oBAAoB,CAAO;IACnC,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,gBAAgB,CAAe;IAEvC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;gBAEtB,MAAM,EAAE,QAAQ;IAgC5B,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;IAkB/C,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE;IAkBhC,UAAU,IAAI,OAAO;IAWrB,iBAAiB,IAAI,MAAM,GAAG,SAAS;CAexC"}
@@ -0,0 +1,124 @@
1
+ import buildCsp from "content-security-policy-builder";
2
+ const CSP_KEYS = [
3
+ "childSrc",
4
+ "connectSrc",
5
+ "defaultSrc",
6
+ "fencedFrameSrc",
7
+ "fontSrc",
8
+ "frameSrc",
9
+ "imgSrc",
10
+ "manifestSrc",
11
+ "mediaSrc",
12
+ "objectSrc",
13
+ "scriptSrc",
14
+ "scriptSrcElem",
15
+ "scriptSrcAttr",
16
+ "styleSrc",
17
+ "styleSrcElem",
18
+ "styleSrcAttr",
19
+ "workerSrc",
20
+ "baseUri",
21
+ "formAction",
22
+ "frameAncestors",
23
+ "reportTo",
24
+ "requireTrustedTypesFor",
25
+ "trustedTypes",
26
+ "upgradeInsecureRequests",
27
+ ];
28
+ export class SecureHeaderBuilder {
29
+ csp;
30
+ headers = new Headers();
31
+ cspEnabled = false;
32
+ autodetectCspOrigins = true;
33
+ useNonce = false;
34
+ commonCspOrigins = [];
35
+ nonce;
36
+ constructor(config) {
37
+ this.cspEnabled = config.serverless.csp.enabled;
38
+ this.autodetectCspOrigins = config.serverless.csp.autoDetect;
39
+ this.useNonce = config.serverless.csp.nonce;
40
+ this.commonCspOrigins = config.serverless.csp.commonOrigins ?? [];
41
+ if (this.useNonce) {
42
+ this.nonce = crypto.randomUUID();
43
+ }
44
+ // Default CSP header parameters
45
+ this.csp = {};
46
+ for (let key of CSP_KEYS) {
47
+ const defaults = [];
48
+ if (key.match(/Src$/i)) {
49
+ defaults.push("'self'");
50
+ if (this.commonCspOrigins.length) {
51
+ defaults.push(...this.commonCspOrigins);
52
+ }
53
+ if (config.serverless.csp.values) {
54
+ const value = config.serverless.csp.values[key];
55
+ if (value) {
56
+ defaults.push(...value);
57
+ }
58
+ }
59
+ if (this.useNonce && !defaults.includes("'unsafe-inline'")) {
60
+ defaults.push(`'nonce-${this.nonce}'`);
61
+ }
62
+ }
63
+ this.csp[key] = new Set(defaults);
64
+ }
65
+ }
66
+ addTrackingTags(tags) {
67
+ if (!this.autodetectCspOrigins || !this.cspEnabled)
68
+ return tags;
69
+ const handle = (value) => {
70
+ if (value) {
71
+ return value.replaceAll(/<(script|style)/g, (tag) => {
72
+ return tag + ` nonce="${this.nonce}"`;
73
+ });
74
+ }
75
+ };
76
+ return {
77
+ head: handle(tags.head),
78
+ body: handle(tags.body),
79
+ footer: handle(tags.footer),
80
+ };
81
+ }
82
+ addMetaTags(tags) {
83
+ if (!this.autodetectCspOrigins || !this.cspEnabled)
84
+ return tags;
85
+ return tags.map((tag) => {
86
+ if (this.nonce) {
87
+ if (tag.tagName === "script" || tag.tagName === "style") {
88
+ return {
89
+ ...tag,
90
+ attributes: {
91
+ ...tag.attributes,
92
+ nonce: this.nonce,
93
+ },
94
+ };
95
+ }
96
+ }
97
+ return tag;
98
+ });
99
+ }
100
+ getHeaders() {
101
+ const result = new Headers(this.headers);
102
+ const cspHeaderValue = this.getCSPHeaderValue();
103
+ if (cspHeaderValue) {
104
+ result.set("Content-Security-Policy", cspHeaderValue);
105
+ }
106
+ return result;
107
+ }
108
+ getCSPHeaderValue() {
109
+ if (!this.cspEnabled)
110
+ return undefined;
111
+ const directives = [];
112
+ for (let key of CSP_KEYS) {
113
+ if (this.csp[key].size > 0) {
114
+ directives.push([key, Array.from(this.csp[key])]);
115
+ }
116
+ }
117
+ if (directives.length) {
118
+ return buildCsp({
119
+ directives: Object.fromEntries(directives),
120
+ });
121
+ }
122
+ return undefined;
123
+ }
124
+ }
@@ -3,3 +3,4 @@ export declare const BRANDED_HEADERS: {
3
3
  "X-Powered-By": string;
4
4
  };
5
5
  export declare function extractHeaders(rawHeaders: Headers): Record<string, string>;
6
+ //# sourceMappingURL=headers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../../src/app/server/utils/headers.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,WAOrE;AAED,eAAO,MAAM,eAAe;;CAE3B,CAAA;AAYD,wBAAgB,cAAc,CAAC,UAAU,EAAE,OAAO,0BAOjD"}
@@ -7,4 +7,5 @@ export type UrlReplacerConf = {
7
7
  replace: boolean;
8
8
  }[];
9
9
  };
10
- export declare function createUrlReplacer(conf: UrlReplacerConf): (text: string) => string;
10
+ export declare function createUrlReplacer(conf: UrlReplacerConf): (text: string, newOrigin?: string) => string;
11
+ //# sourceMappingURL=replace-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace-host.d.ts","sourceRoot":"","sources":["../../../../src/app/server/utils/replace-host.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,0FAA0F;IAC1F,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;CACjD,CAAA;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,IAI7C,MAAM,MAAM,EAAE,YAAY,MAAM,YAiEzC"}