astro 4.8.6 → 4.9.0

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 (42) hide show
  1. package/astro-jsx.d.ts +1 -1
  2. package/dist/@types/astro.d.ts +43 -96
  3. package/dist/actions/runtime/middleware.d.ts +1 -0
  4. package/dist/actions/runtime/middleware.js +44 -12
  5. package/dist/actions/runtime/route.js +1 -2
  6. package/dist/actions/runtime/utils.d.ts +6 -1
  7. package/dist/actions/runtime/utils.js +2 -1
  8. package/dist/actions/runtime/virtual/server.d.ts +4 -2
  9. package/dist/actions/runtime/virtual/server.js +9 -11
  10. package/dist/actions/utils.d.ts +2 -0
  11. package/dist/actions/utils.js +2 -1
  12. package/dist/container/index.d.ts +162 -0
  13. package/dist/container/index.js +234 -0
  14. package/dist/container/pipeline.d.ts +11 -0
  15. package/dist/container/pipeline.js +96 -0
  16. package/dist/core/app/node.js +4 -1
  17. package/dist/core/build/consts.d.ts +1 -0
  18. package/dist/core/build/consts.js +3 -1
  19. package/dist/core/build/generate.js +3 -3
  20. package/dist/core/build/index.js +2 -2
  21. package/dist/core/build/plugins/plugin-content.d.ts +1 -1
  22. package/dist/core/build/plugins/plugin-content.js +13 -2
  23. package/dist/core/build/plugins/plugin-manifest.js +2 -2
  24. package/dist/core/build/static-build.d.ts +2 -1
  25. package/dist/core/build/static-build.js +7 -6
  26. package/dist/core/config/schema.d.ts +92 -120
  27. package/dist/core/config/schema.js +18 -23
  28. package/dist/core/constants.js +1 -1
  29. package/dist/core/dev/dev.js +1 -1
  30. package/dist/core/messages.js +2 -2
  31. package/dist/core/render-context.d.ts +1 -1
  32. package/dist/core/render-context.js +6 -3
  33. package/dist/core/routing/manifest/create.d.ts +4 -1
  34. package/dist/core/routing/manifest/create.js +10 -8
  35. package/dist/i18n/utils.d.ts +1 -1
  36. package/dist/integrations/features-validation.js +1 -1
  37. package/dist/runtime/client/dev-toolbar/apps/utils/highlight.js +2 -0
  38. package/dist/runtime/server/jsx.js +1 -0
  39. package/dist/vite-plugin-astro-server/plugin.d.ts +0 -1
  40. package/dist/vite-plugin-astro-server/plugin.js +1 -1
  41. package/package.json +7 -3
  42. package/templates/actions.mjs +37 -12
@@ -50,6 +50,8 @@ function attachTooltipToHighlight(highlight, tooltip, originalElement) {
50
50
  }
51
51
  if (dialogRect.right > document.documentElement.clientWidth) {
52
52
  tooltip.style.right = "0px";
53
+ } else if (dialogRect.left < 0) {
54
+ tooltip.style.left = "0px";
53
55
  }
54
56
  });
55
57
  });
@@ -84,6 +84,7 @@ Did you forget to import the component or is it possible there is a typo?`);
84
84
  }
85
85
  if (typeof vnode.type === "function") {
86
86
  if (vnode.props[hasTriedRenderComponentSymbol]) {
87
+ delete vnode.props[hasTriedRenderComponentSymbol];
87
88
  const output2 = await vnode.type(vnode.props ?? {});
88
89
  if (output2?.[AstroJSX] || !output2) {
89
90
  return await renderJSXVNode(result, output2);
@@ -14,6 +14,5 @@ export default function createVitePluginAstroServer({ settings, logger, fs: fsMo
14
14
  *
15
15
  * Renderers needs to be pulled out from the page module emitted during the build.
16
16
  * @param settings
17
- * @param renderers
18
17
  */
19
18
  export declare function createDevelopmentManifest(settings: AstroSettings): SSRManifest;
@@ -113,7 +113,7 @@ function createDevelopmentManifest(settings) {
113
113
  componentMetadata: /* @__PURE__ */ new Map(),
114
114
  inlinedScripts: /* @__PURE__ */ new Map(),
115
115
  i18n: i18nManifest,
116
- checkOrigin: settings.config.experimental.security?.csrfProtection?.origin ?? false,
116
+ checkOrigin: settings.config.security?.checkOrigin ?? false,
117
117
  rewritingEnabled: settings.config.experimental.rewriting,
118
118
  middleware(_, next) {
119
119
  return next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.8.6",
3
+ "version": "4.9.0",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -48,6 +48,10 @@
48
48
  "types": "./config.d.ts",
49
49
  "default": "./config.mjs"
50
50
  },
51
+ "./container": {
52
+ "types": "./dist/container/index.d.ts",
53
+ "default": "./dist/container/index.js"
54
+ },
51
55
  "./app": "./dist/core/app/index.js",
52
56
  "./app/node": "./dist/core/app/node.js",
53
57
  "./client/*": "./dist/runtime/client/*",
@@ -166,8 +170,8 @@
166
170
  "zod": "^3.23.8",
167
171
  "zod-to-json-schema": "^3.23.0",
168
172
  "@astrojs/internal-helpers": "0.4.0",
169
- "@astrojs/markdown-remark": "5.1.0",
170
- "@astrojs/telemetry": "3.1.0"
173
+ "@astrojs/telemetry": "3.1.0",
174
+ "@astrojs/markdown-remark": "5.1.0"
171
175
  },
172
176
  "optionalDependencies": {
173
177
  "sharp": "^0.33.3"
@@ -7,11 +7,33 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '/_actions/') {
7
7
  return target[objKey];
8
8
  }
9
9
  const path = aggregatedPath + objKey.toString();
10
- const action = (clientParam) => actionHandler(clientParam, path);
10
+ const action = (param) => actionHandler(param, path);
11
11
  action.toString = () => path;
12
12
  action.safe = (input) => {
13
13
  return callSafely(() => action(input));
14
14
  };
15
+ action.safe.toString = () => path;
16
+
17
+ // Add progressive enhancement info for React.
18
+ action.$$FORM_ACTION = function () {
19
+ const data = new FormData();
20
+ data.set('_astroAction', action.toString());
21
+ return {
22
+ method: 'POST',
23
+ name: action.toString(),
24
+ data,
25
+ };
26
+ };
27
+ action.safe.$$FORM_ACTION = function () {
28
+ const data = new FormData();
29
+ data.set('_astroAction', action.toString());
30
+ data.set('_astroActionSafe', 'true');
31
+ return {
32
+ method: 'POST',
33
+ name: action.toString(),
34
+ data,
35
+ };
36
+ };
15
37
  // recurse to construct queries for nested object paths
16
38
  // ex. actions.user.admins.auth()
17
39
  return toActionProxy(action, path + '.');
@@ -20,24 +42,27 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '/_actions/') {
20
42
  }
21
43
 
22
44
  /**
23
- * @param {*} clientParam argument passed to the action when used on the client.
24
- * @param {string} path Built path to call action on the server.
25
- * Usage: `actions.[name](clientParam)`.
45
+ * @param {*} param argument passed to the action when called server or client-side.
46
+ * @param {string} path Built path to call action by path name.
47
+ * Usage: `actions.[name](param)`.
26
48
  */
27
- async function actionHandler(clientParam, path) {
49
+ async function actionHandler(param, path) {
50
+ // When running server-side, import the action and call it.
28
51
  if (import.meta.env.SSR) {
29
- throw new ActionError({
30
- code: 'BAD_REQUEST',
31
- message:
32
- 'Action unexpectedly called on the server. If this error is unexpected, share your feedback on our RFC discussion: https://github.com/withastro/roadmap/pull/912',
33
- });
52
+ const { getAction } = await import('astro/actions/runtime/utils.js');
53
+ const action = await getAction(path);
54
+ if (!action) throw new Error(`Action not found: ${path}`);
55
+
56
+ return action(param);
34
57
  }
58
+
59
+ // When running client-side, make a fetch request to the action path.
35
60
  const headers = new Headers();
36
61
  headers.set('Accept', 'application/json');
37
- let body = clientParam;
62
+ let body = param;
38
63
  if (!(body instanceof FormData)) {
39
64
  try {
40
- body = clientParam ? JSON.stringify(clientParam) : undefined;
65
+ body = param ? JSON.stringify(param) : undefined;
41
66
  } catch (e) {
42
67
  throw new ActionError({
43
68
  code: 'BAD_REQUEST',