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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (458) hide show
  1. package/css/editor-styles.css +4 -0
  2. package/dist/app/entry/HydrationOverlay.d.ts +2 -0
  3. package/dist/app/entry/HydrationOverlay.d.ts.map +1 -0
  4. package/dist/app/entry/HydrationOverlay.js +2 -0
  5. package/dist/app/entry/MetaTags.d.ts +8 -0
  6. package/dist/app/entry/MetaTags.d.ts.map +1 -0
  7. package/dist/app/entry/MetaTags.js +30 -0
  8. package/dist/app/entry/boot-admin.d.ts +1 -0
  9. package/dist/app/entry/boot-admin.d.ts.map +1 -0
  10. package/dist/app/entry/boot-admin.js +7 -3
  11. package/dist/app/entry/hydration-script.d.ts +2 -0
  12. package/dist/app/entry/hydration-script.d.ts.map +1 -0
  13. package/dist/app/entry/hydration-script.js +18 -0
  14. package/dist/app/entry/spa-root.d.ts +1 -0
  15. package/dist/app/entry/spa-root.d.ts.map +1 -0
  16. package/dist/app/entry/spa-root.js +3 -5
  17. package/dist/app/entry/ssr-root-client.d.ts +4 -1
  18. package/dist/app/entry/ssr-root-client.d.ts.map +1 -0
  19. package/dist/app/entry/ssr-root-client.js +18 -6
  20. package/dist/app/entry/ssr-root.d.ts +6 -4
  21. package/dist/app/entry/ssr-root.d.ts.map +1 -0
  22. package/dist/app/entry/ssr-root.js +20 -19
  23. package/dist/app/lib/admin/defineField.d.ts +1 -0
  24. package/dist/app/lib/admin/defineField.d.ts.map +1 -0
  25. package/dist/app/lib/admin/defineWidget.d.ts +1 -0
  26. package/dist/app/lib/admin/defineWidget.d.ts.map +1 -0
  27. package/dist/app/lib/admin/index.d.ts +1 -0
  28. package/dist/app/lib/admin/index.d.ts.map +1 -0
  29. package/dist/app/lib/admin/installFieldTypes.d.ts +1 -0
  30. package/dist/app/lib/admin/installFieldTypes.d.ts.map +1 -0
  31. package/dist/app/lib/admin/installFieldTypes.js +2 -0
  32. package/dist/app/lib/admin/runWidgets.d.ts +1 -0
  33. package/dist/app/lib/admin/runWidgets.d.ts.map +1 -0
  34. package/dist/app/lib/admin/runWidgets.js +7 -2
  35. package/dist/app/lib/blocks/ContentBlocks.d.ts +7 -4
  36. package/dist/app/lib/blocks/ContentBlocks.d.ts.map +1 -0
  37. package/dist/app/lib/blocks/ContentBlocks.js +16 -3
  38. package/dist/app/lib/blocks/EditableText.d.ts +30 -5
  39. package/dist/app/lib/blocks/EditableText.d.ts.map +1 -0
  40. package/dist/app/lib/blocks/EditableText.js +34 -5
  41. package/dist/app/lib/blocks/InnerBlocks.d.ts +21 -6
  42. package/dist/app/lib/blocks/InnerBlocks.d.ts.map +1 -0
  43. package/dist/app/lib/blocks/InnerBlocks.js +73 -25
  44. package/dist/app/lib/blocks/SlotBlocks.d.ts +8 -0
  45. package/dist/app/lib/blocks/SlotBlocks.d.ts.map +1 -0
  46. package/dist/app/lib/blocks/SlotBlocks.js +46 -0
  47. package/dist/app/lib/blocks/block-utils.d.ts +2 -1
  48. package/dist/app/lib/blocks/block-utils.d.ts.map +1 -0
  49. package/dist/app/lib/blocks/block-utils.js +3 -1
  50. package/dist/app/lib/blocks/builtin-blocks.d.ts +2 -0
  51. package/dist/app/lib/blocks/builtin-blocks.d.ts.map +1 -0
  52. package/dist/app/lib/blocks/builtin-blocks.js +55 -0
  53. package/dist/app/lib/blocks/defineBlock.d.ts +4 -0
  54. package/dist/app/lib/blocks/defineBlock.d.ts.map +1 -0
  55. package/dist/app/lib/blocks/defineBlock.js +9 -0
  56. package/dist/app/lib/blocks/editor/EditorHighlights.d.ts +8 -0
  57. package/dist/app/lib/blocks/editor/EditorHighlights.d.ts.map +1 -0
  58. package/dist/app/lib/blocks/editor/EditorHighlights.js +164 -0
  59. package/dist/app/lib/blocks/editor/EditorSupport.d.ts +1 -0
  60. package/dist/app/lib/blocks/editor/EditorSupport.d.ts.map +1 -0
  61. package/dist/app/lib/blocks/editor/EditorSupport.js +17 -10
  62. package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +2 -1
  63. package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts.map +1 -0
  64. package/dist/app/lib/blocks/editor/block-templates.d.ts +8 -1
  65. package/dist/app/lib/blocks/editor/block-templates.d.ts.map +1 -0
  66. package/dist/app/lib/blocks/editor/block-templates.js +71 -2
  67. package/dist/app/lib/blocks/editor/blocks-by-tag.d.ts +1 -0
  68. package/dist/app/lib/blocks/editor/blocks-by-tag.d.ts.map +1 -0
  69. package/dist/app/lib/blocks/editor/controls.d.ts +1 -0
  70. package/dist/app/lib/blocks/editor/controls.d.ts.map +1 -0
  71. package/dist/app/lib/blocks/editor/create-block.d.ts +10 -0
  72. package/dist/app/lib/blocks/editor/create-block.d.ts.map +1 -0
  73. package/dist/app/lib/blocks/editor/create-block.js +13 -0
  74. package/dist/app/lib/blocks/editor/editor-config.d.ts +77 -8
  75. package/dist/app/lib/blocks/editor/editor-config.d.ts.map +1 -0
  76. package/dist/app/lib/blocks/editor/editor-config.js +29 -62
  77. package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts +4 -0
  78. package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts.map +1 -0
  79. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +126 -21
  80. package/dist/app/lib/blocks/editor/root-blocks.d.ts +7 -0
  81. package/dist/app/lib/blocks/editor/root-blocks.d.ts.map +1 -0
  82. package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
  83. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +12 -1
  84. package/dist/app/lib/blocks/editor/usePostEditor.d.ts.map +1 -0
  85. package/dist/app/lib/blocks/editor/usePostEditor.js +28 -13
  86. package/dist/app/lib/blocks/index.d.ts +8 -5
  87. package/dist/app/lib/blocks/index.d.ts.map +1 -0
  88. package/dist/app/lib/blocks/index.js +7 -5
  89. package/dist/app/lib/blocks/inline-editing.d.ts +10 -0
  90. package/dist/app/lib/blocks/inline-editing.d.ts.map +1 -0
  91. package/dist/app/lib/blocks/inline-editing.js +12 -2
  92. package/dist/app/lib/devtools/components/BreakpointIndicator.d.ts +1 -0
  93. package/dist/app/lib/devtools/components/BreakpointIndicator.d.ts.map +1 -0
  94. package/dist/app/lib/devtools/components/BreakpointIndicator.js +2 -2
  95. package/dist/app/lib/devtools/components/DevUI.d.ts +1 -0
  96. package/dist/app/lib/devtools/components/DevUI.d.ts.map +1 -0
  97. package/dist/app/lib/devtools/components/DevUI.js +3 -2
  98. package/dist/app/lib/devtools/components/GridIndicator.d.ts +2 -0
  99. package/dist/app/lib/devtools/components/GridIndicator.d.ts.map +1 -0
  100. package/dist/app/lib/devtools/components/GridIndicator.js +29 -0
  101. package/dist/app/lib/devtools/dev-tools-store.d.ts +1 -0
  102. package/dist/app/lib/devtools/dev-tools-store.d.ts.map +1 -0
  103. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +2 -1
  104. package/dist/app/lib/devtools/hooks/usePersistState.d.ts.map +1 -0
  105. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  106. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +77 -76
  107. package/dist/app/lib/devtools/hooks/useTailwind.d.ts.map +1 -0
  108. package/dist/app/lib/devtools/index.d.ts +1 -0
  109. package/dist/app/lib/devtools/index.d.ts.map +1 -0
  110. package/dist/app/lib/devtools/loader.d.ts +1 -0
  111. package/dist/app/lib/devtools/loader.d.ts.map +1 -0
  112. package/dist/app/lib/devtools/loader.js +6 -5
  113. package/dist/app/lib/devtools/tailwind.config.d.ts +1 -0
  114. package/dist/app/lib/devtools/tailwind.config.d.ts.map +1 -0
  115. package/dist/app/lib/devtools/useQueryDebug.d.ts +8 -1
  116. package/dist/app/lib/devtools/useQueryDebug.d.ts.map +1 -0
  117. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  118. package/dist/app/lib/dynamic/dynamic.d.ts +2 -1
  119. package/dist/app/lib/dynamic/dynamic.d.ts.map +1 -0
  120. package/dist/app/lib/dynamic/dynamic.js +5 -1
  121. package/dist/app/lib/dynamic/index.d.ts +1 -0
  122. package/dist/app/lib/dynamic/index.d.ts.map +1 -0
  123. package/dist/app/lib/hooks/index.d.ts +3 -3
  124. package/dist/app/lib/hooks/index.d.ts.map +1 -0
  125. package/dist/app/lib/hooks/index.js +2 -3
  126. package/dist/app/lib/hooks/{queryUtils.d.ts → query-hooks.d.ts} +42 -3
  127. package/dist/app/lib/hooks/query-hooks.d.ts.map +1 -0
  128. package/dist/app/lib/hooks/{queryUtils.js → query-hooks.js} +90 -28
  129. package/dist/app/lib/hooks/useAppData.d.ts +1 -0
  130. package/dist/app/lib/hooks/useAppData.d.ts.map +1 -0
  131. package/dist/app/lib/hooks/useAppData.js +11 -0
  132. package/dist/app/lib/hooks/useRPC.d.ts +1 -4
  133. package/dist/app/lib/hooks/useRPC.d.ts.map +1 -0
  134. package/dist/app/lib/hooks/useRPC.js +0 -8
  135. package/dist/app/lib/integrations/gravityforms/index.d.ts +3 -0
  136. package/dist/app/lib/integrations/gravityforms/index.d.ts.map +1 -0
  137. package/dist/app/lib/integrations/gravityforms/index.js +2 -0
  138. package/dist/app/lib/integrations/gravityforms/types.d.ts +145 -0
  139. package/dist/app/lib/integrations/gravityforms/types.d.ts.map +1 -0
  140. package/dist/app/lib/integrations/gravityforms/types.js +1 -0
  141. package/dist/app/lib/integrations/gravityforms/useGravityForm.d.ts +31 -0
  142. package/dist/app/lib/integrations/gravityforms/useGravityForm.d.ts.map +1 -0
  143. package/dist/app/lib/integrations/gravityforms/useGravityForm.js +295 -0
  144. package/dist/app/lib/internal/finalize-rpc.d.ts +18 -0
  145. package/dist/app/lib/internal/finalize-rpc.d.ts.map +1 -0
  146. package/dist/app/lib/internal/finalize-rpc.js +3 -0
  147. package/dist/app/lib/internal/index.d.ts +2 -0
  148. package/dist/app/lib/internal/index.d.ts.map +1 -0
  149. package/dist/app/lib/internal/index.js +1 -0
  150. package/dist/app/lib/internal/internal-store.d.ts +1 -0
  151. package/dist/app/lib/internal/internal-store.d.ts.map +1 -0
  152. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -0
  153. package/dist/app/lib/internal/read-admin-manifest.d.ts.map +1 -0
  154. package/dist/app/lib/internal/read-block-manifest.d.ts +2 -0
  155. package/dist/app/lib/internal/read-block-manifest.d.ts.map +1 -0
  156. package/dist/app/lib/internal/read-block-manifest.js +7 -0
  157. package/dist/app/lib/internal/read-view-manifest.d.ts +7 -4
  158. package/dist/app/lib/internal/read-view-manifest.d.ts.map +1 -0
  159. package/dist/app/lib/internal/read-view-manifest.js +18 -0
  160. package/dist/app/lib/legacy-stitches/createStitches.d.ts +510 -1
  161. package/dist/app/lib/legacy-stitches/createStitches.d.ts.map +1 -0
  162. package/dist/app/lib/legacy-stitches/index.d.ts +1 -0
  163. package/dist/app/lib/legacy-stitches/index.d.ts.map +1 -0
  164. package/dist/app/lib/routing/components/BackButton.d.ts +50 -0
  165. package/dist/app/lib/routing/components/BackButton.d.ts.map +1 -0
  166. package/dist/app/lib/routing/components/BackButton.js +47 -0
  167. package/dist/app/lib/routing/components/BrowserRouter.d.ts +10 -1
  168. package/dist/app/lib/routing/components/BrowserRouter.d.ts.map +1 -0
  169. package/dist/app/lib/routing/components/BrowserRouter.js +136 -21
  170. package/dist/app/lib/routing/components/ClientOnly.d.ts +2 -1
  171. package/dist/app/lib/routing/components/ClientOnly.d.ts.map +1 -0
  172. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  173. package/dist/app/lib/routing/components/Link.d.ts +19 -2
  174. package/dist/app/lib/routing/components/Link.d.ts.map +1 -0
  175. package/dist/app/lib/routing/components/Link.js +43 -23
  176. package/dist/app/lib/routing/components/NativeLinkHandler.d.ts +10 -0
  177. package/dist/app/lib/routing/components/NativeLinkHandler.d.ts.map +1 -0
  178. package/dist/app/lib/routing/components/NativeLinkHandler.js +23 -0
  179. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -0
  180. package/dist/app/lib/routing/components/RouteRenderer.d.ts.map +1 -0
  181. package/dist/app/lib/routing/components/RouteRenderer.js +17 -3
  182. package/dist/app/lib/routing/components/SSRRouter.d.ts +3 -0
  183. package/dist/app/lib/routing/components/SSRRouter.d.ts.map +1 -0
  184. package/dist/app/lib/routing/components/SSRRouter.js +3 -2
  185. package/dist/app/lib/routing/components/ScrollRestoration.d.ts +1 -0
  186. package/dist/app/lib/routing/components/ScrollRestoration.d.ts.map +1 -0
  187. package/dist/app/lib/routing/components/ScrollRestoration.js +4 -1
  188. package/dist/app/lib/routing/context.d.ts +9 -5
  189. package/dist/app/lib/routing/context.d.ts.map +1 -0
  190. package/dist/app/lib/routing/context.js +12 -95
  191. package/dist/app/lib/routing/hooks/useIsSSR.d.ts +1 -0
  192. package/dist/app/lib/routing/hooks/useIsSSR.d.ts.map +1 -0
  193. package/dist/app/lib/routing/hooks/useRestorableState.d.ts +3 -1
  194. package/dist/app/lib/routing/hooks/useRestorableState.d.ts.map +1 -0
  195. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -0
  196. package/dist/app/lib/routing/hooks/useRoute.d.ts.map +1 -0
  197. package/dist/app/lib/routing/hooks/useRoute.js +21 -0
  198. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +6 -0
  199. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts.map +1 -0
  200. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  201. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -0
  202. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts.map +1 -0
  203. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -0
  204. package/dist/app/lib/routing/hooks/useRouter.d.ts.map +1 -0
  205. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -0
  206. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts.map +1 -0
  207. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -0
  208. package/dist/app/lib/routing/hooks/useRouterState.d.ts.map +1 -0
  209. package/dist/app/lib/routing/hooks/useSearchParams.d.ts +78 -6
  210. package/dist/app/lib/routing/hooks/useSearchParams.d.ts.map +1 -0
  211. package/dist/app/lib/routing/hooks/useSearchParams.js +75 -15
  212. package/dist/app/lib/routing/index.d.ts +3 -0
  213. package/dist/app/lib/routing/index.d.ts.map +1 -0
  214. package/dist/app/lib/routing/index.js +2 -0
  215. package/dist/app/lib/routing/loader.d.ts +1 -0
  216. package/dist/app/lib/routing/loader.d.ts.map +1 -0
  217. package/dist/app/lib/routing/loader.js +19 -10
  218. package/dist/app/lib/routing/types.d.ts +60 -12
  219. package/dist/app/lib/routing/types.d.ts.map +1 -0
  220. package/dist/app/lib/routing/utils.d.ts +7 -2
  221. package/dist/app/lib/routing/utils.d.ts.map +1 -0
  222. package/dist/app/lib/routing/utils.js +41 -4
  223. package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +11 -2
  224. package/dist/app/lib/runtime/apiConfig.d.ts.map +1 -0
  225. package/dist/app/lib/runtime/apiConfig.js +6 -0
  226. package/dist/app/lib/runtime/errorHandling.d.ts +40 -0
  227. package/dist/app/lib/runtime/errorHandling.d.ts.map +1 -0
  228. package/dist/app/lib/runtime/errorHandling.js +6 -0
  229. package/dist/app/lib/runtime/index.d.ts +3 -0
  230. package/dist/app/lib/runtime/index.d.ts.map +1 -0
  231. package/dist/app/lib/runtime/index.js +2 -0
  232. package/dist/app/lib/views/defineView.d.ts +2 -1
  233. package/dist/app/lib/views/defineView.d.ts.map +1 -0
  234. package/dist/app/lib/views/index.d.ts +1 -0
  235. package/dist/app/lib/views/index.d.ts.map +1 -0
  236. package/dist/app/server/index.d.ts +4 -1
  237. package/dist/app/server/index.d.ts.map +1 -0
  238. package/dist/app/server/index.js +3 -1
  239. package/dist/app/server/proxy-wp-admin.d.ts +2 -2
  240. package/dist/app/server/proxy-wp-admin.d.ts.map +1 -0
  241. package/dist/app/server/proxy-wp-admin.js +46 -13
  242. package/dist/app/server/render-ai-page.d.ts +13 -0
  243. package/dist/app/server/render-ai-page.d.ts.map +1 -0
  244. package/dist/app/server/render-ai-page.js +100 -0
  245. package/dist/app/server/render-ssr-page.d.ts +31 -3
  246. package/dist/app/server/render-ssr-page.d.ts.map +1 -0
  247. package/dist/app/server/render-ssr-page.js +226 -10
  248. package/dist/app/server/rpc.d.ts +60 -0
  249. package/dist/app/server/rpc.d.ts.map +1 -0
  250. package/dist/app/server/rpc.js +18 -0
  251. package/dist/app/server/server-context.d.ts +44 -6
  252. package/dist/app/server/server-context.d.ts.map +1 -0
  253. package/dist/app/server/server-context.js +334 -37
  254. package/dist/app/server/server-custom-config.d.ts +3 -0
  255. package/dist/app/server/server-custom-config.d.ts.map +1 -0
  256. package/dist/app/server/server-custom-config.js +1 -0
  257. package/dist/app/server/utils/content-security.d.ts +26 -0
  258. package/dist/app/server/utils/content-security.d.ts.map +1 -0
  259. package/dist/app/server/utils/content-security.js +124 -0
  260. package/dist/app/server/utils/headers.d.ts +1 -0
  261. package/dist/app/server/utils/headers.d.ts.map +1 -0
  262. package/dist/app/server/utils/replace-host.d.ts +2 -1
  263. package/dist/app/server/utils/replace-host.d.ts.map +1 -0
  264. package/dist/app/server/utils/replace-host.js +10 -2
  265. package/dist/app/server/utils/swr-cache.d.ts +5 -0
  266. package/dist/app/server/utils/swr-cache.d.ts.map +1 -0
  267. package/dist/app/server/utils/swr-cache.js +31 -0
  268. package/dist/app/utils/APIProvider.d.ts +3 -0
  269. package/dist/app/utils/APIProvider.d.ts.map +1 -0
  270. package/dist/app/utils/APIProvider.js +5 -0
  271. package/dist/app/utils/BlockErrorBoundary.d.ts +20 -0
  272. package/dist/app/utils/BlockErrorBoundary.d.ts.map +1 -0
  273. package/dist/app/utils/BlockErrorBoundary.js +38 -0
  274. package/dist/app/utils/ErrorMessage.d.ts +6 -0
  275. package/dist/app/utils/ErrorMessage.d.ts.map +1 -0
  276. package/dist/app/utils/ErrorMessage.js +14 -0
  277. package/dist/app/utils/RouteErrorBoundary.d.ts +20 -0
  278. package/dist/app/utils/RouteErrorBoundary.d.ts.map +1 -0
  279. package/dist/app/utils/RouteErrorBoundary.js +41 -0
  280. package/dist/app/utils/asset-capture.d.ts +3 -0
  281. package/dist/app/utils/asset-capture.d.ts.map +1 -0
  282. package/dist/app/utils/asset-capture.js +5 -0
  283. package/dist/app/utils/hydration-debugger.d.ts +14 -0
  284. package/dist/app/utils/hydration-debugger.d.ts.map +1 -0
  285. package/dist/app/utils/hydration-debugger.js +11 -0
  286. package/dist/app/utils/query-client.d.ts +3 -0
  287. package/dist/app/utils/query-client.d.ts.map +1 -0
  288. package/dist/app/utils/query-client.js +5 -1
  289. package/dist/app/utils/query-monitor.d.ts +27 -0
  290. package/dist/app/utils/query-monitor.d.ts.map +1 -0
  291. package/dist/app/utils/query-monitor.js +7 -0
  292. package/dist/app/utils/trpc-client.d.ts +3 -0
  293. package/dist/app/utils/trpc-client.d.ts.map +1 -0
  294. package/dist/app/utils/trpc-client.js +39 -0
  295. package/dist/app/utils/wp.d.ts +11 -10
  296. package/dist/app/utils/wp.d.ts.map +1 -0
  297. package/dist/node/cli/cli-mode.d.ts +1 -0
  298. package/dist/node/cli/cli-mode.d.ts.map +1 -0
  299. package/dist/node/cli/cli-worker.d.ts +1 -0
  300. package/dist/node/cli/cli-worker.d.ts.map +1 -0
  301. package/dist/node/cli/cli-worker.js +7 -3
  302. package/dist/node/cli/cli.d.ts +1 -0
  303. package/dist/node/cli/cli.d.ts.map +1 -0
  304. package/dist/node/cli/cli.js +120 -7
  305. package/dist/node/cli/display/CLIApp.d.ts +1 -0
  306. package/dist/node/cli/display/CLIApp.d.ts.map +1 -0
  307. package/dist/node/cli/display/CLIApp.js +1 -1
  308. package/dist/node/cli/display/boot-cli-app.d.ts +1 -0
  309. package/dist/node/cli/display/boot-cli-app.d.ts.map +1 -0
  310. package/dist/node/cli/display/boot-cli-app.js +1 -1
  311. package/dist/node/cli/display/components/Fullscreen.d.ts +1 -0
  312. package/dist/node/cli/display/components/Fullscreen.d.ts.map +1 -0
  313. package/dist/node/cli/display/components/LogEntries.d.ts +1 -0
  314. package/dist/node/cli/display/components/LogEntries.d.ts.map +1 -0
  315. package/dist/node/cli/display/components/MenuItem.d.ts +1 -0
  316. package/dist/node/cli/display/components/MenuItem.d.ts.map +1 -0
  317. package/dist/node/cli/display/components/TextInput.d.ts +1 -0
  318. package/dist/node/cli/display/components/TextInput.d.ts.map +1 -0
  319. package/dist/node/cli/display/hooks/useManifest.d.ts +1 -0
  320. package/dist/node/cli/display/hooks/useManifest.d.ts.map +1 -0
  321. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -0
  322. package/dist/node/cli/display/hooks/useStatefulLog.d.ts.map +1 -0
  323. package/dist/node/cli/display/tools/BlockList.d.ts +1 -0
  324. package/dist/node/cli/display/tools/BlockList.d.ts.map +1 -0
  325. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -0
  326. package/dist/node/cli/display/tools/CreateBlock.d.ts.map +1 -0
  327. package/dist/node/cli/display/tools/cli-tool-list.d.ts +1 -0
  328. package/dist/node/cli/display/tools/cli-tool-list.d.ts.map +1 -0
  329. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -0
  330. package/dist/node/cli/display/tools/cli-tools.d.ts.map +1 -0
  331. package/dist/node/cli/display/util/colors.d.ts +1 -0
  332. package/dist/node/cli/display/util/colors.d.ts.map +1 -0
  333. package/dist/node/cli/version.d.ts +2 -1
  334. package/dist/node/cli/version.d.ts.map +1 -0
  335. package/dist/node/cli/version.js +1 -1
  336. package/dist/node/compiler/build-vinxi.d.ts +1 -0
  337. package/dist/node/compiler/build-vinxi.d.ts.map +1 -0
  338. package/dist/node/compiler/build-vinxi.js +2 -1
  339. package/dist/node/compiler/bundler.admin.d.ts +1 -0
  340. package/dist/node/compiler/bundler.admin.d.ts.map +1 -0
  341. package/dist/node/compiler/bundler.admin.js +1 -0
  342. package/dist/node/compiler/bundler.frontend.d.ts +2 -0
  343. package/dist/node/compiler/bundler.frontend.d.ts.map +1 -0
  344. package/dist/node/compiler/bundler.frontend.js +26 -11
  345. package/dist/node/compiler/dev-server.d.ts +1 -0
  346. package/dist/node/compiler/dev-server.d.ts.map +1 -0
  347. package/dist/node/compiler/dev-server.js +17 -1
  348. package/dist/node/compiler/get-vite-config.d.ts +12 -1
  349. package/dist/node/compiler/get-vite-config.d.ts.map +1 -0
  350. package/dist/node/compiler/get-vite-config.js +173 -42
  351. package/dist/node/compiler/vinxi-app.d.ts +13 -0
  352. package/dist/node/compiler/vinxi-app.d.ts.map +1 -0
  353. package/dist/node/compiler/vinxi-app.js +142 -32
  354. package/dist/node/compiler/vinxi-codegen.d.ts +1 -0
  355. package/dist/node/compiler/vinxi-codegen.d.ts.map +1 -0
  356. package/dist/node/compiler/vinxi-codegen.js +371 -108
  357. package/dist/node/graphql/graphql-codegen.d.ts +12 -1
  358. package/dist/node/graphql/graphql-codegen.d.ts.map +1 -0
  359. package/dist/node/graphql/graphql-codegen.js +239 -37
  360. package/dist/node/graphql/graphql-schema-loader.d.ts +3 -1
  361. package/dist/node/graphql/graphql-schema-loader.d.ts.map +1 -0
  362. package/dist/node/graphql/graphql-schema-loader.js +5 -16
  363. package/dist/node/graphql/plugins/gql-plugin-files.d.ts +3 -1
  364. package/dist/node/graphql/plugins/gql-plugin-files.d.ts.map +1 -0
  365. package/dist/node/graphql/plugins/gql-plugin-files.js +3 -2
  366. package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts +1 -0
  367. package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts.map +1 -0
  368. package/dist/node/graphql/plugins/gql-plugin-queries.d.ts +1 -0
  369. package/dist/node/graphql/plugins/gql-plugin-queries.d.ts.map +1 -0
  370. package/dist/node/graphql/plugins/gql-plugin-queries.js +2 -2
  371. package/dist/node/graphql/query-files-loader.d.ts +4 -0
  372. package/dist/node/graphql/query-files-loader.d.ts.map +1 -0
  373. package/dist/node/graphql/query-files-loader.js +5 -0
  374. package/dist/node/graphql/wp-info-query.d.ts +1 -0
  375. package/dist/node/graphql/wp-info-query.d.ts.map +1 -0
  376. package/dist/node/project/config.d.ts +207 -73
  377. package/dist/node/project/config.d.ts.map +1 -0
  378. package/dist/node/project/config.js +94 -20
  379. package/dist/node/project/eddev-build-file.d.ts +1 -0
  380. package/dist/node/project/eddev-build-file.d.ts.map +1 -0
  381. package/dist/node/project/eddev-build-file.js +4 -2
  382. package/dist/node/project/env.d.ts +5 -0
  383. package/dist/node/project/env.d.ts.map +1 -0
  384. package/dist/node/project/env.js +1 -0
  385. package/dist/node/project/favicons.d.ts +1 -1
  386. package/dist/node/project/favicons.d.ts.map +1 -0
  387. package/dist/node/project/favicons.js +1 -1
  388. package/dist/node/project/manifest/block-manifest.d.ts +1 -0
  389. package/dist/node/project/manifest/block-manifest.d.ts.map +1 -0
  390. package/dist/node/project/manifest/block-manifest.js +6 -2
  391. package/dist/node/project/manifest/field-manifest.d.ts +1 -0
  392. package/dist/node/project/manifest/field-manifest.d.ts.map +1 -0
  393. package/dist/node/project/manifest/manifest.d.ts +2 -0
  394. package/dist/node/project/manifest/manifest.d.ts.map +1 -0
  395. package/dist/node/project/manifest/manifest.js +14 -10
  396. package/dist/node/project/manifest/routes-manifest.d.ts +21 -0
  397. package/dist/node/project/manifest/routes-manifest.d.ts.map +1 -0
  398. package/dist/node/project/manifest/routes-manifest.js +74 -0
  399. package/dist/node/project/manifest/view-manifest.d.ts +1 -0
  400. package/dist/node/project/manifest/view-manifest.d.ts.map +1 -0
  401. package/dist/node/project/manifest/widget-manifest.d.ts +1 -0
  402. package/dist/node/project/manifest/widget-manifest.d.ts.map +1 -0
  403. package/dist/node/project/project.d.ts +12 -0
  404. package/dist/node/project/project.d.ts.map +1 -0
  405. package/dist/node/project/project.js +57 -3
  406. package/dist/node/project/wp-info.d.ts +3 -0
  407. package/dist/node/project/wp-info.d.ts.map +1 -0
  408. package/dist/node/project/wp-info.js +13 -1
  409. package/dist/node/storybook/index.d.ts +3 -0
  410. package/dist/node/storybook/index.d.ts.map +1 -0
  411. package/dist/node/storybook/index.js +13 -0
  412. package/dist/node/types/block-type.d.ts +57 -25
  413. package/dist/node/types/block-type.d.ts.map +1 -0
  414. package/dist/node/types/block-type.js +4 -1
  415. package/dist/node/types/view-type.d.ts +8 -7
  416. package/dist/node/types/view-type.d.ts.map +1 -0
  417. package/dist/node/utils/fetch-wp.d.ts +2 -0
  418. package/dist/node/utils/fetch-wp.d.ts.map +1 -0
  419. package/dist/node/utils/fetch-wp.js +28 -0
  420. package/dist/node/utils/format-zod-error.d.ts +1 -0
  421. package/dist/node/utils/format-zod-error.d.ts.map +1 -0
  422. package/dist/node/utils/fs-codegen.d.ts +4 -0
  423. package/dist/node/utils/fs-codegen.d.ts.map +1 -0
  424. package/dist/node/utils/fs-codegen.js +10 -2
  425. package/dist/node/utils/fs.d.ts +5 -0
  426. package/dist/node/utils/fs.d.ts.map +1 -0
  427. package/dist/node/utils/get-repo-info.d.ts +1 -0
  428. package/dist/node/utils/get-repo-info.d.ts.map +1 -0
  429. package/dist/node/utils/helpers.d.ts +1 -0
  430. package/dist/node/utils/helpers.d.ts.map +1 -0
  431. package/dist/node/utils/highlight-code.d.ts +1 -0
  432. package/dist/node/utils/highlight-code.d.ts.map +1 -0
  433. package/dist/node/utils/is-deploying.d.ts +1 -0
  434. package/dist/node/utils/is-deploying.d.ts.map +1 -0
  435. package/dist/node/utils/is-deploying.js +1 -1
  436. package/dist/node/utils/report-builder.d.ts +1 -0
  437. package/dist/node/utils/report-builder.d.ts.map +1 -0
  438. package/dist/node/utils/self-signed-cert.d.ts +5 -0
  439. package/dist/node/utils/self-signed-cert.d.ts.map +1 -0
  440. package/dist/node/utils/self-signed-cert.js +28 -4
  441. package/dist/node/utils/stateful-log.d.ts +1 -0
  442. package/dist/node/utils/stateful-log.d.ts.map +1 -0
  443. package/dist/node/utils/stateful-log.js +2 -0
  444. package/dist/node/utils/ts-export-extractor.d.ts +1 -0
  445. package/dist/node/utils/ts-export-extractor.d.ts.map +1 -0
  446. package/dist/node/utils/watch-file-tree.d.ts +18 -3
  447. package/dist/node/utils/watch-file-tree.d.ts.map +1 -0
  448. package/dist/node/utils/watch-file-tree.js +12 -5
  449. package/package.json +42 -25
  450. package/tsconfig.app.json +10 -5
  451. package/tsconfig.node.json +3 -2
  452. package/types.app.d.ts +2 -0
  453. package/types.meta.d.ts +449 -136
  454. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  455. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  456. package/dist/app/lib/hooks/apiConfig.js +0 -4
  457. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  458. package/dist/app/lib/hooks/usePageLoad.js +0 -5
@@ -1,7 +1,12 @@
1
- import { parseURL, stringifyParsedURL, withQuery } from "ufo";
1
+ import { parseURL, stringifyParsedURL, withQuery, withTrailingSlash } from "ufo";
2
+ import { fetchWP } from "../../node/utils/fetch-wp.js";
2
3
  import { filterHeader } from "./utils/headers.js";
3
4
  import { createUrlReplacer } from "./utils/replace-host.js";
4
- const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control"];
5
+ import { pageCache, queryCache, swr } from "./utils/swr-cache.js";
6
+ import { QueryMonitor } from "../utils/query-monitor.js";
7
+ import chalk from "chalk";
8
+ import { inspect } from "node:util";
9
+ const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control", /woocommerce/, "location"];
5
10
  const PROXY_REQUEST_HEADERS = [
6
11
  "content-type",
7
12
  "accept",
@@ -11,19 +16,38 @@ const PROXY_REQUEST_HEADERS = [
11
16
  "referer",
12
17
  "user-agent",
13
18
  "authorization",
19
+ "woocommerce-session",
14
20
  ];
21
+ const VARIES_HEADERS = ["Authorization", "woocommerce-session"];
22
+ let runtime;
15
23
  export class ServerContext {
16
24
  dev;
17
25
  origin;
18
- getManifest;
19
- replaceUrls;
26
+ _urlReplacer;
27
+ rpcBases = [];
28
+ config;
29
+ static main;
20
30
  constructor(conf) {
21
31
  this.dev = conf.dev;
22
32
  this.origin = conf.origin;
23
- this.getManifest = conf.getManifest;
33
+ this.rpcBases = conf.rpcBases ?? [];
34
+ this.config = conf.config;
24
35
  if (conf.replaceUrls) {
25
- this.replaceUrls = createUrlReplacer(conf.replaceUrls);
36
+ this._urlReplacer = createUrlReplacer(conf.replaceUrls);
26
37
  }
38
+ ServerContext.main = this;
39
+ }
40
+ replaceUrls(text, origin) {
41
+ if (this._urlReplacer) {
42
+ return this._urlReplacer(text, origin);
43
+ }
44
+ return text;
45
+ }
46
+ get runtime() {
47
+ return runtime;
48
+ }
49
+ static setRuntime(rt) {
50
+ runtime = rt;
27
51
  }
28
52
  getOriginUrl(url) {
29
53
  const parsed = parseURL(url);
@@ -34,13 +58,11 @@ export class ServerContext {
34
58
  }
35
59
  async fetchOrigin(url, opts) {
36
60
  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
- },
61
+ const fetchOps = { ...opts };
62
+ delete fetchOps.replaceUrls;
63
+ delete fetchOps.newOrigin;
64
+ const response = await fetchWP(url, {
65
+ ...fetchOps,
44
66
  });
45
67
  if (!response.ok) {
46
68
  return response;
@@ -52,8 +74,8 @@ export class ServerContext {
52
74
  }
53
75
  });
54
76
  let text = await response.text();
55
- if (opts?.replaceUrls && this.replaceUrls) {
56
- text = this.replaceUrls(text);
77
+ if (opts?.replaceUrls) {
78
+ text = this.replaceUrls(text, opts.newOrigin);
57
79
  }
58
80
  return new Response(text, {
59
81
  status: response.status,
@@ -61,22 +83,209 @@ export class ServerContext {
61
83
  headers,
62
84
  });
63
85
  }
86
+ debugLogQueryMonitor(kind, uri, monitor) {
87
+ if (!QueryMonitor.hasLogEntries(monitor))
88
+ return;
89
+ let indentLevel = 2;
90
+ const finalOutput = [];
91
+ let label = "";
92
+ if (kind === "props") {
93
+ label = "While fetching props for route '" + uri + "'";
94
+ }
95
+ else if (kind === "query") {
96
+ label = "While querying " + uri + " via REST API";
97
+ }
98
+ else if (kind === "mutation") {
99
+ label = "While mutating " + uri + " via REST API";
100
+ }
101
+ else if (kind === "app") {
102
+ label = "While fetching app data";
103
+ }
104
+ finalOutput.push(chalk.whiteBright("➜ " + label));
105
+ function printEntry(entry) {
106
+ finalOutput.push(indent(indentLevel, chalk.whiteBright("➜ " + entry.file) + " " + chalk.gray(entry.label ? `(${entry.label})` : "")));
107
+ indentLevel += 2;
108
+ if (entry.log && entry.log.length) {
109
+ for (let item of entry.log) {
110
+ let output = "";
111
+ let prefix = "";
112
+ let message = item.message;
113
+ let stack = [];
114
+ if (item.type === "php_error") {
115
+ prefix = chalk.red("PHP Error:");
116
+ }
117
+ else if (item.type === "php_warning") {
118
+ prefix = chalk.yellow("PHP Warning:");
119
+ }
120
+ else if (item.type === "php_notice") {
121
+ prefix = chalk.yellow("PHP Notice:");
122
+ }
123
+ else if (item.type === "GRAPHQL_DEBUG") {
124
+ prefix = chalk.cyan("debug:");
125
+ }
126
+ else if (item.type === "error" && item.extensions?.category === "user") {
127
+ prefix = chalk.red("UserError:");
128
+ }
129
+ else {
130
+ prefix = chalk.gray((item.type || "Log") + ":");
131
+ }
132
+ if (typeof message !== "string") {
133
+ message = inspect(message, { depth: 4 });
134
+ }
135
+ if (item.debugMessage) {
136
+ message += "\n" + chalk.gray(item.debugMessage);
137
+ }
138
+ output += prefix + " " + message;
139
+ if (item.path) {
140
+ stack.push(chalk.gray(" at path " + JSON.stringify(item.path)));
141
+ }
142
+ if (item.file) {
143
+ stack.push(chalk.gray(`at ${chalk.white(item.file)} line ${item.line || "??"}`));
144
+ }
145
+ if (item.stack?.length) {
146
+ stack.push(item.stack
147
+ .filter((line) => {
148
+ return line !== item.file + ":" + item.line;
149
+ })
150
+ .slice(0, 4)
151
+ .map((line) => " " + chalk.gray(line))
152
+ .join("\n"));
153
+ }
154
+ if (stack.length > 0) {
155
+ output += indent(2, "\n" + stack.join("\n"));
156
+ }
157
+ finalOutput.push(indent(indentLevel, "➜ " + output));
158
+ }
159
+ }
160
+ for (let child of entry.children ?? []) {
161
+ printEntry(child);
162
+ }
163
+ indentLevel -= 2;
164
+ }
165
+ for (let entry of monitor) {
166
+ printEntry(entry);
167
+ }
168
+ }
64
169
  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,
170
+ /**
171
+ * Calculcate the cache key.
172
+ * For route data, the cache key is the pathname.
173
+ * TODO: Potential support for Vercel draft mode.
174
+ */
175
+ let cacheKey = "fetchRouteData:" + req.pathname;
176
+ const result = await swr({
177
+ key: cacheKey,
178
+ cache: pageCache,
179
+ forceFresh: this.dev,
180
+ getFreshValue: async (ctx) => {
181
+ ctx.metadata.createdTime;
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
+ return {
251
+ status: resultStatus,
252
+ headers: resultHeaders,
253
+ data: JSON.stringify(resultData),
254
+ };
255
+ },
70
256
  });
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),
257
+ return new Response(result.data, {
258
+ status: result.status,
259
+ headers: result.headers,
260
+ });
261
+ }
262
+ async fetchAppData() {
263
+ const data = await swr({
264
+ key: "fetchAppData",
265
+ cache: pageCache,
266
+ getFreshValue: async (ctx) => {
267
+ const response = await this.fetchOrigin("/_appdata", {
268
+ cache: "no-cache",
269
+ replaceUrls: true,
270
+ headers: {
271
+ "Content-Type": "application/json",
272
+ Accept: "application/json",
273
+ },
274
+ });
275
+ const result = await response.json();
276
+ const preferredCacheDuration = parseInt(response.headers.get("x-ed-cache-duration") ?? "");
277
+ if (isFinite(preferredCacheDuration)) {
278
+ ctx.metadata.ttl = preferredCacheDuration * 1000;
279
+ }
280
+ if (result.queryMonitor) {
281
+ this.debugLogQueryMonitor("app", "", result.queryMonitor);
282
+ }
283
+ result.__generated = new Date().toISOString();
284
+ return result;
78
285
  },
286
+ forceFresh: this.dev,
79
287
  });
288
+ return data;
80
289
  }
81
290
  extractRequestHeaders(req) {
82
291
  const headers = {};
@@ -90,19 +299,57 @@ export class ServerContext {
90
299
  return headers;
91
300
  }
92
301
  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
- },
302
+ const url = `/wp-json/ed/v1/query/${req.name.replace(/^\//, "")}?params=${encodeURIComponent(JSON.stringify(req.params))}`;
303
+ const key = `fetchNamedQuery:${req.name}:${JSON.stringify(req.params)}`;
304
+ const fetch = async () => {
305
+ const result = await this.fetchOrigin(url, {
306
+ cache: "no-cache",
307
+ replaceUrls: true,
308
+ headers: {
309
+ ...this.extractRequestHeaders(req.headers),
310
+ "Content-Type": "application/json",
311
+ Accept: "application/json",
312
+ },
313
+ });
314
+ const preferredCacheDuration = parseInt(result.headers.get("x-ed-cache-duration") ?? "");
315
+ let resultStatus = result.status;
316
+ let resultHeaders = result.headers;
317
+ let resultData = await result.json();
318
+ if (resultData && typeof resultData === "object") {
319
+ resultData.__generated = new Date().toISOString();
320
+ }
321
+ if (resultData.queryMonitor) {
322
+ this.debugLogQueryMonitor("query", req.name, resultData.queryMonitor);
323
+ }
324
+ return {
325
+ status: resultStatus,
326
+ headers: resultHeaders,
327
+ data: JSON.stringify(resultData),
328
+ cacheTime: isFinite(preferredCacheDuration) ? preferredCacheDuration * 1000 : undefined,
329
+ };
330
+ };
331
+ // If headers like 'Authorization' are set, then we shouldn't cache.
332
+ const hasVariedHeaders = VARIES_HEADERS.some((key) => !!req.headers[key]);
333
+ // Get the result, either from cache or by fetching.
334
+ const result = hasVariedHeaders
335
+ ? await fetch()
336
+ : await swr({
337
+ key,
338
+ cache: queryCache,
339
+ forceFresh: this.dev,
340
+ getFreshValue: async (ctx) => {
341
+ const result = await fetch();
342
+ ctx.metadata.ttl = result.cacheTime;
343
+ return result;
344
+ },
345
+ });
346
+ return new Response(result.data, {
347
+ status: result.status,
348
+ headers: result.headers,
102
349
  });
103
350
  }
104
351
  async fetchMutation(req) {
105
- const url = `/wp-json/ed/v1/mutation/${req.name}`;
352
+ const url = `/wp-json/ed/v1/mutation/${req.name.replace(/^\//, "")}`;
106
353
  return this.fetchOrigin(url, {
107
354
  method: "POST",
108
355
  cache: "no-cache",
@@ -115,4 +362,54 @@ export class ServerContext {
115
362
  body: JSON.stringify(req.body),
116
363
  });
117
364
  }
365
+ get allowedCorsOrigins() {
366
+ let result = [];
367
+ if (this.config.serverless.endpoints) {
368
+ result.push(...Object.keys(this.config.serverless.endpoints));
369
+ result.push(...Object.values(this.config.serverless.endpoints));
370
+ result = result.filter((origin) => origin !== "*");
371
+ }
372
+ if (this.config.serverless.cors?.origins) {
373
+ result.push(...this.config.serverless.cors.origins.map((origin) => origin.replace(/(https?:\/\/|\/$)/, "")));
374
+ }
375
+ return result;
376
+ }
377
+ getCorsOrigin(originHeader) {
378
+ const parsed = parseURL(originHeader);
379
+ if (this.allowedCorsOrigins.includes(parsed.host)) {
380
+ return originHeader;
381
+ }
382
+ if (this.allowedCorsOrigins.includes("*")) {
383
+ return "*";
384
+ }
385
+ }
386
+ getCorsHeaders(origin) {
387
+ if (!origin)
388
+ return {};
389
+ const allowedOrigin = this.getCorsOrigin(origin);
390
+ if (allowedOrigin) {
391
+ return {
392
+ "Access-Control-Allow-Methods": "OPTIONS,GET,HEAD,PUT,PATCH,POST,DELETE",
393
+ "Access-Control-Allow-Origin": allowedOrigin,
394
+ "Access-Control-Allow-Credentials": "true",
395
+ "Access-Control-Allow-Headers": "*",
396
+ "Access-Control-Expose-Headers": "*",
397
+ };
398
+ }
399
+ return {};
400
+ }
401
+ }
402
+ function indent(count, str) {
403
+ const indent = " ".repeat(count);
404
+ return str
405
+ .split("\n")
406
+ .map((line) => indent + line)
407
+ .join("\n");
408
+ }
409
+ function indentAllButFirst(count, str) {
410
+ const indent = " ".repeat(count);
411
+ return str
412
+ .split("\n")
413
+ .map((line, i) => (i === 0 ? line : indent + line))
414
+ .join("\n");
118
415
  }
@@ -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,UAIvC,MAAM,cAAc,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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swr-cache.d.ts","sourceRoot":"","sources":["../../../../src/app/server/utils/swr-cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,EAAY,gBAAgB,EAAmB,MAAM,qBAAqB,CAAA;AAuB/G,eAAO,MAAM,SAAS,YAAgB,CAAA;AACtC,eAAO,MAAM,UAAU,YAAgB,CAAA;AAEvC,wBAAgB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,cAO/C"}