eddev 2.0.0-beta.17 → 2.0.0-beta.170

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