eddev 2.0.0-beta.22 → 2.0.0-beta.221

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 (459) 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 +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 +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 +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 +137 -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 +4 -0
  213. package/dist/app/lib/routing/index.d.ts.map +1 -0
  214. package/dist/app/lib/routing/index.js +3 -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 +61 -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 +32 -3
  246. package/dist/app/server/render-ssr-page.d.ts.map +1 -0
  247. package/dist/app/server/render-ssr-page.js +240 -10
  248. package/dist/app/server/rpc.d.ts +52 -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 +50 -7
  252. package/dist/app/server/server-context.d.ts.map +1 -0
  253. package/dist/app/server/server-context.js +352 -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 +122 -8
  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 +4 -1
  346. package/dist/node/compiler/dev-server.d.ts.map +1 -0
  347. package/dist/node/compiler/dev-server.js +34 -11
  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 +176 -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 +165 -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 +372 -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 +55 -1
  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 +10 -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 +6 -1
  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 +7 -6
  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 +40 -24
  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.env.d.ts +3 -0
  454. package/types.meta.d.ts +449 -136
  455. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  456. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  457. package/dist/app/lib/hooks/apiConfig.js +0 -4
  458. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  459. 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,38 @@ 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
+ static main;
20
31
  constructor(conf) {
21
32
  this.dev = conf.dev;
22
33
  this.origin = conf.origin;
23
- this.getManifest = conf.getManifest;
34
+ this.rpcBases = conf.rpcBases ?? [];
35
+ this.config = conf.config;
24
36
  if (conf.replaceUrls) {
25
- this.replaceUrls = createUrlReplacer(conf.replaceUrls);
37
+ this._urlReplacer = createUrlReplacer(conf.replaceUrls);
26
38
  }
39
+ ServerContext.main = this;
40
+ }
41
+ replaceUrls(text, origin) {
42
+ if (this._urlReplacer) {
43
+ return this._urlReplacer(text, origin);
44
+ }
45
+ return text;
46
+ }
47
+ get runtime() {
48
+ return runtime;
49
+ }
50
+ static setRuntime(rt) {
51
+ runtime = rt;
27
52
  }
28
53
  getOriginUrl(url) {
29
54
  const parsed = parseURL(url);
@@ -34,13 +59,11 @@ export class ServerContext {
34
59
  }
35
60
  async fetchOrigin(url, opts) {
36
61
  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
- },
62
+ const fetchOps = { ...opts };
63
+ delete fetchOps.replaceUrls;
64
+ delete fetchOps.newOrigin;
65
+ const response = await fetchWP(url, {
66
+ ...fetchOps,
44
67
  });
45
68
  if (!response.ok) {
46
69
  return response;
@@ -52,8 +75,8 @@ export class ServerContext {
52
75
  }
53
76
  });
54
77
  let text = await response.text();
55
- if (opts?.replaceUrls && this.replaceUrls) {
56
- text = this.replaceUrls(text);
78
+ if (opts?.replaceUrls) {
79
+ text = this.replaceUrls(text, opts.newOrigin);
57
80
  }
58
81
  return new Response(text, {
59
82
  status: response.status,
@@ -61,22 +84,213 @@ export class ServerContext {
61
84
  headers,
62
85
  });
63
86
  }
87
+ debugLogQueryMonitor(kind, uri, monitor) {
88
+ if (!QueryMonitor.hasLogEntries(monitor))
89
+ return;
90
+ let indentLevel = 2;
91
+ const finalOutput = [];
92
+ let label = "";
93
+ if (kind === "props") {
94
+ label = "While fetching props for route '" + uri + "'";
95
+ }
96
+ else if (kind === "query") {
97
+ label = "While querying " + uri + " via REST API";
98
+ }
99
+ else if (kind === "mutation") {
100
+ label = "While mutating " + uri + " via REST API";
101
+ }
102
+ else if (kind === "app") {
103
+ label = "While fetching app data";
104
+ }
105
+ finalOutput.push(chalk.whiteBright("➜ " + label));
106
+ function printEntry(entry) {
107
+ finalOutput.push(indent(indentLevel, chalk.whiteBright("➜ " + entry.file) + " " + chalk.gray(entry.label ? `(${entry.label})` : "")));
108
+ indentLevel += 2;
109
+ if (entry.log && entry.log.length) {
110
+ for (let item of entry.log) {
111
+ let output = "";
112
+ let prefix = "";
113
+ let message = item.message;
114
+ let stack = [];
115
+ if (item.type === "php_error") {
116
+ prefix = chalk.red("PHP Error:");
117
+ }
118
+ else if (item.type === "php_warning") {
119
+ prefix = chalk.yellow("PHP Warning:");
120
+ }
121
+ else if (item.type === "php_notice") {
122
+ prefix = chalk.yellow("PHP Notice:");
123
+ }
124
+ else if (item.type === "GRAPHQL_DEBUG") {
125
+ prefix = chalk.cyan("debug:");
126
+ }
127
+ else if (item.type === "error" && item.extensions?.category === "user") {
128
+ prefix = chalk.red("UserError:");
129
+ }
130
+ else {
131
+ prefix = chalk.gray((item.type || "Log") + ":");
132
+ }
133
+ if (typeof message !== "string") {
134
+ message = inspect(message, { depth: 4 });
135
+ }
136
+ if (item.debugMessage) {
137
+ message += "\n" + chalk.gray(item.debugMessage);
138
+ }
139
+ output += prefix + " " + message;
140
+ if (item.path) {
141
+ stack.push(chalk.gray(" at path " + JSON.stringify(item.path)));
142
+ }
143
+ if (item.file) {
144
+ stack.push(chalk.gray(`at ${chalk.white(item.file)} line ${item.line || "??"}`));
145
+ }
146
+ if (item.stack?.length) {
147
+ stack.push(item.stack
148
+ .filter((line) => {
149
+ return line !== item.file + ":" + item.line;
150
+ })
151
+ .slice(0, 4)
152
+ .map((line) => " " + chalk.gray(line))
153
+ .join("\n"));
154
+ }
155
+ if (stack.length > 0) {
156
+ output += indent(2, "\n" + stack.join("\n"));
157
+ }
158
+ finalOutput.push(indent(indentLevel, "➜ " + output));
159
+ }
160
+ }
161
+ for (let child of entry.children ?? []) {
162
+ printEntry(child);
163
+ }
164
+ indentLevel -= 2;
165
+ }
166
+ for (let entry of monitor) {
167
+ printEntry(entry);
168
+ }
169
+ }
64
170
  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,
171
+ /**
172
+ * Calculcate the cache key.
173
+ * For route data, the cache key is the pathname.
174
+ * TODO: Potential support for Vercel draft mode.
175
+ */
176
+ let cacheKey = "fetchRouteData:" + req.pathname;
177
+ const result = await swr({
178
+ key: cacheKey,
179
+ cache: pageCache,
180
+ forceFresh: this.dev || req.bypass,
181
+ getFreshValue: async (ctx) => {
182
+ const fetchUrl = withQuery(withTrailingSlash(req.pathname), {
183
+ _props: "1",
184
+ _ssr: "1",
185
+ _debug: this.dev ? "1" : undefined,
186
+ });
187
+ const result = await this.fetchOrigin(fetchUrl, {
188
+ cache: "no-cache",
189
+ replaceUrls: true,
190
+ newOrigin: req.newOrigin,
191
+ headers: {
192
+ "Content-Type": "application/json",
193
+ Accept: "application/json",
194
+ },
195
+ redirect: "manual",
196
+ });
197
+ const preferredCacheDuration = parseInt(result.headers.get("x-ed-cache-duration") ?? "");
198
+ if (isFinite(preferredCacheDuration)) {
199
+ ctx.metadata.ttl = preferredCacheDuration * 1000;
200
+ }
201
+ let resultStatus = result.status;
202
+ let resultHeaders = new Headers(result.headers);
203
+ let resultData = {};
204
+ // Special case for redirects
205
+ if (result.headers.has("location")) {
206
+ let location = result.headers.get("location");
207
+ let status = result.status;
208
+ if (this.replaceUrls) {
209
+ location = this.replaceUrls(location);
210
+ }
211
+ return {
212
+ status: 200,
213
+ headers: new Headers({
214
+ "Content-Type": "application/json",
215
+ }),
216
+ data: JSON.stringify({ redirect: location, status: status }),
217
+ };
218
+ }
219
+ try {
220
+ resultData = await result.json();
221
+ }
222
+ catch (err) {
223
+ console.error(`Invalid JSON response from '${fetchUrl}'. An error page will be displayed.`);
224
+ ctx.metadata.ttl = 0;
225
+ return {
226
+ status: 500,
227
+ headers: resultHeaders,
228
+ data: JSON.stringify({
229
+ view: "_error",
230
+ viewData: {
231
+ data: {
232
+ statusCode: 500,
233
+ title: "Internal Server Error",
234
+ userMessage: "An internal server error occurred.",
235
+ report: {
236
+ details: "A JSON parsing error occurred while fetching route data.",
237
+ message: err.message,
238
+ },
239
+ },
240
+ },
241
+ }),
242
+ };
243
+ }
244
+ if (resultData && typeof resultData === "object") {
245
+ resultData.__generated = new Date().toISOString();
246
+ }
247
+ if (resultData.queryMonitor) {
248
+ this.debugLogQueryMonitor("props", req.pathname, resultData.queryMonitor);
249
+ }
250
+ // if (isFinite(preferredCacheDuration)) {
251
+ // const maxAge = isFinite(preferredCacheDuration) ? preferredCacheDuration * 1000 : undefined
252
+ // resultHeaders.set("Cache-Control", `max-age=0, s-maxage=${maxAge}, stale-while-revalidate`)
253
+ // }
254
+ resultHeaders.set("X-Ed-Fetched-At", new Date().toUTCString());
255
+ return {
256
+ status: resultStatus,
257
+ headers: resultHeaders,
258
+ data: JSON.stringify(resultData),
259
+ };
260
+ },
70
261
  });
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),
262
+ return new Response(result.data, {
263
+ status: result.status,
264
+ headers: result.headers,
265
+ });
266
+ }
267
+ async fetchAppData(args) {
268
+ const data = await swr({
269
+ key: "fetchAppData",
270
+ cache: pageCache || args.bypass,
271
+ getFreshValue: async (ctx) => {
272
+ const response = await this.fetchOrigin("/_appdata", {
273
+ cache: "no-cache",
274
+ replaceUrls: true,
275
+ headers: {
276
+ "Content-Type": "application/json",
277
+ Accept: "application/json",
278
+ },
279
+ });
280
+ const result = await response.json();
281
+ const preferredCacheDuration = parseInt(response.headers.get("x-ed-cache-duration") ?? "");
282
+ if (isFinite(preferredCacheDuration)) {
283
+ ctx.metadata.ttl = preferredCacheDuration * 1000;
284
+ }
285
+ if (result.queryMonitor) {
286
+ this.debugLogQueryMonitor("app", "", result.queryMonitor);
287
+ }
288
+ result.__generated = new Date().toISOString();
289
+ return result;
78
290
  },
291
+ forceFresh: this.dev,
79
292
  });
293
+ return data;
80
294
  }
81
295
  extractRequestHeaders(req) {
82
296
  const headers = {};
@@ -90,19 +304,57 @@ export class ServerContext {
90
304
  return headers;
91
305
  }
92
306
  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
- },
307
+ const url = `/wp-json/ed/v1/query/${req.name.replace(/^\//, "")}?params=${encodeURIComponent(JSON.stringify(req.params))}`;
308
+ const key = `fetchNamedQuery:${req.name}:${JSON.stringify(req.params)}`;
309
+ const fetch = async () => {
310
+ const result = await this.fetchOrigin(url, {
311
+ cache: "no-cache",
312
+ replaceUrls: true,
313
+ headers: {
314
+ ...this.extractRequestHeaders(req.headers),
315
+ "Content-Type": "application/json",
316
+ Accept: "application/json",
317
+ },
318
+ });
319
+ const preferredCacheDuration = parseInt(result.headers.get("x-ed-cache-duration") ?? "");
320
+ let resultStatus = result.status;
321
+ let resultHeaders = result.headers;
322
+ let resultData = await result.json();
323
+ if (resultData && typeof resultData === "object") {
324
+ resultData.__generated = new Date().toISOString();
325
+ }
326
+ if (resultData.queryMonitor) {
327
+ this.debugLogQueryMonitor("query", req.name, resultData.queryMonitor);
328
+ }
329
+ return {
330
+ status: resultStatus,
331
+ headers: resultHeaders,
332
+ data: JSON.stringify(resultData),
333
+ cacheTime: isFinite(preferredCacheDuration) ? preferredCacheDuration * 1000 : undefined,
334
+ };
335
+ };
336
+ // If headers like 'Authorization' are set, then we shouldn't cache.
337
+ const hasVariedHeaders = VARIES_HEADERS.some((key) => !!req.headers[key]);
338
+ // Get the result, either from cache or by fetching.
339
+ const result = hasVariedHeaders
340
+ ? await fetch()
341
+ : await swr({
342
+ key,
343
+ cache: queryCache,
344
+ forceFresh: this.dev || req.bypass,
345
+ getFreshValue: async (ctx) => {
346
+ const result = await fetch();
347
+ ctx.metadata.ttl = result.cacheTime;
348
+ return result;
349
+ },
350
+ });
351
+ return new Response(result.data, {
352
+ status: result.status,
353
+ headers: result.headers,
102
354
  });
103
355
  }
104
356
  async fetchMutation(req) {
105
- const url = `/wp-json/ed/v1/mutation/${req.name}`;
357
+ const url = `/wp-json/ed/v1/mutation/${req.name.replace(/^\//, "")}`;
106
358
  return this.fetchOrigin(url, {
107
359
  method: "POST",
108
360
  cache: "no-cache",
@@ -115,4 +367,67 @@ export class ServerContext {
115
367
  body: JSON.stringify(req.body),
116
368
  });
117
369
  }
370
+ get allowedCorsOrigins() {
371
+ let result = [];
372
+ if (this.config.serverless.endpoints) {
373
+ result.push(...Object.keys(this.config.serverless.endpoints));
374
+ result.push(...Object.values(this.config.serverless.endpoints));
375
+ result = result.filter((origin) => origin !== "*");
376
+ }
377
+ if (this.config.serverless.cors?.origins) {
378
+ result.push(...this.config.serverless.cors.origins.map((origin) => origin.replace(/(https?:\/\/|\/$)/, "")));
379
+ }
380
+ return result;
381
+ }
382
+ shouldBypass(event) {
383
+ const bypassToken = process.env.VERCEL_BYPASS_TOKEN;
384
+ if (!bypassToken)
385
+ return false;
386
+ const cookieName = "__prerender_bypass";
387
+ if (getCookie(event, cookieName) === bypassToken) {
388
+ return true;
389
+ }
390
+ if (getHeader(event, "x-prerender-revalidate") === bypassToken) {
391
+ return true;
392
+ }
393
+ return false;
394
+ }
395
+ getCorsOrigin(originHeader) {
396
+ const parsed = parseURL(originHeader);
397
+ if (this.allowedCorsOrigins.includes(parsed.host)) {
398
+ return originHeader;
399
+ }
400
+ if (this.allowedCorsOrigins.includes("*")) {
401
+ return "*";
402
+ }
403
+ }
404
+ getCorsHeaders(origin) {
405
+ if (!origin)
406
+ return {};
407
+ const allowedOrigin = this.getCorsOrigin(origin);
408
+ if (allowedOrigin) {
409
+ return {
410
+ "Access-Control-Allow-Methods": "OPTIONS,GET,HEAD,PUT,PATCH,POST,DELETE",
411
+ "Access-Control-Allow-Origin": allowedOrigin,
412
+ "Access-Control-Allow-Credentials": "true",
413
+ "Access-Control-Allow-Headers": "*",
414
+ "Access-Control-Expose-Headers": "*",
415
+ };
416
+ }
417
+ return {};
418
+ }
419
+ }
420
+ function indent(count, str) {
421
+ const indent = " ".repeat(count);
422
+ return str
423
+ .split("\n")
424
+ .map((line) => indent + line)
425
+ .join("\n");
426
+ }
427
+ function indentAllButFirst(count, str) {
428
+ const indent = " ".repeat(count);
429
+ return str
430
+ .split("\n")
431
+ .map((line, i) => (i === 0 ? line : indent + line))
432
+ .join("\n");
118
433
  }
@@ -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"}
@@ -2,7 +2,7 @@ export function createUrlReplacer(conf) {
2
2
  // Create a regular expression to match the URL
3
3
  // Note that that the regex doesn't necessarily match the entire URL
4
4
  const lookup = new RegExp(conf.from.replace(/https?[:\\\/]+/, "https?[:\\/\\\\]+") + "([a-z0-9\\-_/\\\\]+)", "ig");
5
- return (text) => {
5
+ return (text, newOrigin) => {
6
6
  return text.replace(lookup, (url) => {
7
7
  // Strip out the origin, to create a relative path
8
8
  const path = url.replace(/https?:[\/\\]+[^\/\\]+/, "");
@@ -18,10 +18,18 @@ export function createUrlReplacer(conf) {
18
18
  return url;
19
19
  }
20
20
  else {
21
- return path;
21
+ break;
22
22
  }
23
23
  }
24
24
  }
25
+ if (newOrigin) {
26
+ if (isEscaped) {
27
+ return newOrigin.replace(/\//g, "\\/") + path;
28
+ }
29
+ else {
30
+ return newOrigin + path;
31
+ }
32
+ }
25
33
  return path;
26
34
  // if (path.startsWith("/wp-content/uploads/")) {
27
35
  // if (!conf.ignoreUploads) {
@@ -0,0 +1,5 @@
1
+ import { Cache, CachifiedOptions } from "@epic-web/cachified";
2
+ export declare const pageCache: Cache<any>;
3
+ export declare const queryCache: Cache<any>;
4
+ export declare function swr<T>(args: CachifiedOptions<T>): Promise<T>;
5
+ //# sourceMappingURL=swr-cache.d.ts.map