astro 6.3.7 → 6.4.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 (57) hide show
  1. package/components/Code.astro +1 -1
  2. package/dist/assets/fonts/config.d.ts +4 -4
  3. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  4. package/dist/content/content-layer.js +16 -10
  5. package/dist/content/data-store.d.ts +1 -1
  6. package/dist/content/runtime-assets.d.ts +2 -2
  7. package/dist/content/runtime.d.ts +1 -1
  8. package/dist/content/runtime.js +3 -1
  9. package/dist/content/utils.d.ts +1 -1
  10. package/dist/content/utils.js +1 -1
  11. package/dist/core/app/entrypoints/node.d.ts +1 -1
  12. package/dist/core/app/entrypoints/node.js +2 -0
  13. package/dist/core/app/node.d.ts +16 -0
  14. package/dist/core/app/node.js +56 -13
  15. package/dist/core/base-pipeline.js +2 -1
  16. package/dist/core/build/internal.d.ts +7 -0
  17. package/dist/core/build/plugins/plugin-chunk-imports.d.ts +6 -0
  18. package/dist/core/build/plugins/plugin-chunk-imports.js +16 -17
  19. package/dist/core/build/plugins/plugin-css.js +33 -0
  20. package/dist/core/build/static-build.js +13 -8
  21. package/dist/core/config/merge.js +4 -0
  22. package/dist/core/config/schemas/base.d.ts +16 -10
  23. package/dist/core/config/schemas/base.js +23 -3
  24. package/dist/core/config/schemas/relative.d.ts +60 -42
  25. package/dist/core/config/validate.js +52 -0
  26. package/dist/core/constants.js +1 -1
  27. package/dist/core/dev/dev.js +1 -1
  28. package/dist/core/errors/errors-data.d.ts +8 -3
  29. package/dist/core/errors/errors-data.js +8 -2
  30. package/dist/core/fetch/fetch-state.js +49 -0
  31. package/dist/core/messages/runtime.js +1 -1
  32. package/dist/core/preview/index.js +6 -5
  33. package/dist/core/preview/static-preview-server.js +2 -1
  34. package/dist/core/render/params-and-props.js +1 -1
  35. package/dist/core/render/route-cache.d.ts +1 -1
  36. package/dist/core/render/route-cache.js +2 -2
  37. package/dist/core/routing/create-manifest.js +10 -0
  38. package/dist/core/routing/validation.js +1 -1
  39. package/dist/core/server-islands/vite-plugin-server-islands.d.ts +6 -1
  40. package/dist/core/server-islands/vite-plugin-server-islands.js +13 -3
  41. package/dist/core/session/config.d.ts +1 -1
  42. package/dist/markdown/index.d.ts +4 -0
  43. package/dist/markdown/index.js +14 -0
  44. package/dist/prerender/utils.js +5 -1
  45. package/dist/runtime/server/render/component.js +5 -3
  46. package/dist/types/public/config.d.ts +33 -2
  47. package/dist/types/public/content.d.ts +1 -1
  48. package/dist/types/public/index.d.ts +1 -1
  49. package/dist/types/public/integrations.d.ts +8 -0
  50. package/dist/vite-plugin-app/app.js +2 -9
  51. package/dist/vite-plugin-integrations-container/index.js +15 -6
  52. package/dist/vite-plugin-markdown/content-entry-type.js +7 -4
  53. package/dist/vite-plugin-markdown/images.js +9 -11
  54. package/dist/vite-plugin-markdown/index.js +12 -11
  55. package/package.json +5 -7
  56. package/dist/jsx/rehype.d.ts +0 -5
  57. package/dist/jsx/rehype.js +0 -241
@@ -1,241 +0,0 @@
1
- import { visit } from "unist-util-visit";
2
- import { AstroError } from "../core/errors/errors.js";
3
- import { AstroErrorData } from "../core/errors/index.js";
4
- import { resolvePath } from "../core/viteUtils.js";
5
- import { createDefaultAstroMetadata } from "../vite-plugin-astro/metadata.js";
6
- const ClientOnlyPlaceholder = "astro-client-only";
7
- const rehypeAnalyzeAstroMetadata = () => {
8
- return (tree, file) => {
9
- const metadata = createDefaultAstroMetadata();
10
- const imports = parseImports(tree.children);
11
- visit(tree, (node) => {
12
- if (node.type !== "mdxJsxFlowElement" && node.type !== "mdxJsxTextElement") return;
13
- const tagName = node.name;
14
- if (!tagName || !isComponent(tagName) || !(hasClientDirective(node) || hasServerDeferDirective(node)))
15
- return;
16
- const matchedImport = findMatchingImport(tagName, imports);
17
- if (!matchedImport) {
18
- throw new AstroError({
19
- ...AstroErrorData.NoMatchingImport,
20
- message: AstroErrorData.NoMatchingImport.message(node.name)
21
- });
22
- }
23
- if (matchedImport.path.endsWith(".astro")) {
24
- const clientAttribute = node.attributes.find(
25
- (attr) => attr.type === "mdxJsxAttribute" && attr.name.startsWith("client:")
26
- );
27
- if (clientAttribute) {
28
- console.warn(
29
- `You are attempting to render <${node.name} ${clientAttribute.name} />, but ${node.name} is an Astro component. Astro components do not render in the client and should not have a hydration directive. Please use a framework component for client rendering.`
30
- );
31
- }
32
- }
33
- const resolvedPath = resolvePath(matchedImport.path, file.path);
34
- if (hasClientOnlyDirective(node)) {
35
- metadata.clientOnlyComponents.push({
36
- exportName: matchedImport.name,
37
- localName: "",
38
- specifier: tagName,
39
- resolvedPath
40
- });
41
- addClientOnlyMetadata(node, matchedImport, resolvedPath);
42
- } else if (hasClientDirective(node)) {
43
- metadata.hydratedComponents.push({
44
- exportName: "*",
45
- localName: "",
46
- specifier: tagName,
47
- resolvedPath
48
- });
49
- addClientMetadata(node, matchedImport, resolvedPath);
50
- } else if (hasServerDeferDirective(node)) {
51
- metadata.serverComponents.push({
52
- exportName: matchedImport.name,
53
- localName: tagName,
54
- specifier: matchedImport.path,
55
- resolvedPath
56
- });
57
- addServerDeferMetadata(node, matchedImport, resolvedPath);
58
- }
59
- });
60
- file.data.__astroMetadata = metadata;
61
- };
62
- };
63
- function getAstroMetadata(file) {
64
- return file.data.__astroMetadata;
65
- }
66
- function parseImports(children) {
67
- const imports = /* @__PURE__ */ new Map();
68
- for (const child of children) {
69
- if (child.type !== "mdxjsEsm") continue;
70
- const body = child.data?.estree?.body;
71
- if (!body) continue;
72
- for (const ast of body) {
73
- if (ast.type !== "ImportDeclaration") continue;
74
- const source = ast.source.value;
75
- const specs = ast.specifiers.map((spec) => {
76
- switch (spec.type) {
77
- case "ImportDefaultSpecifier":
78
- return { local: spec.local.name, imported: "default" };
79
- case "ImportNamespaceSpecifier":
80
- return { local: spec.local.name, imported: "*" };
81
- case "ImportSpecifier": {
82
- return {
83
- local: spec.local.name,
84
- imported: spec.imported.type === "Identifier" ? spec.imported.name : String(spec.imported.value)
85
- };
86
- }
87
- default:
88
- throw new Error("Unknown import declaration specifier: " + spec);
89
- }
90
- });
91
- let specSet = imports.get(source);
92
- if (!specSet) {
93
- specSet = /* @__PURE__ */ new Set();
94
- imports.set(source, specSet);
95
- }
96
- for (const spec of specs) {
97
- specSet.add(spec);
98
- }
99
- }
100
- }
101
- return imports;
102
- }
103
- function isComponent(tagName) {
104
- return tagName[0] && tagName[0].toLowerCase() !== tagName[0] || tagName.includes(".") || /[^a-zA-Z]/.test(tagName[0]);
105
- }
106
- function hasClientDirective(node) {
107
- return node.attributes.some(
108
- (attr) => attr.type === "mdxJsxAttribute" && attr.name.startsWith("client:")
109
- );
110
- }
111
- function hasServerDeferDirective(node) {
112
- return node.attributes.some(
113
- (attr) => attr.type === "mdxJsxAttribute" && attr.name === "server:defer"
114
- );
115
- }
116
- function hasClientOnlyDirective(node) {
117
- return node.attributes.some(
118
- (attr) => attr.type === "mdxJsxAttribute" && attr.name === "client:only"
119
- );
120
- }
121
- function findMatchingImport(tagName, imports) {
122
- const tagSpecifier = tagName.split(".")[0];
123
- for (const [source, specs] of imports) {
124
- for (const { imported, local } of specs) {
125
- if (local === tagSpecifier) {
126
- if (tagSpecifier !== tagName) {
127
- switch (imported) {
128
- // Namespace import: "<buttons.Foo.Bar />" => name: "Foo.Bar"
129
- case "*": {
130
- const accessPath = tagName.slice(tagSpecifier.length + 1);
131
- return { name: accessPath, path: source };
132
- }
133
- // Default import: "<buttons.Foo.Bar />" => name: "default.Foo.Bar"
134
- case "default": {
135
- const accessPath = tagName.slice(tagSpecifier.length + 1);
136
- return { name: `default.${accessPath}`, path: source };
137
- }
138
- // Named import: "<buttons.Foo.Bar />" => name: "buttons.Foo.Bar"
139
- default: {
140
- return { name: tagName, path: source };
141
- }
142
- }
143
- }
144
- return { name: imported, path: source };
145
- }
146
- }
147
- }
148
- }
149
- function addClientMetadata(node, meta, resolvedPath) {
150
- const attributeNames = node.attributes.map((attr) => attr.type === "mdxJsxAttribute" ? attr.name : null).filter(Boolean);
151
- if (!attributeNames.includes("client:component-path")) {
152
- node.attributes.push({
153
- type: "mdxJsxAttribute",
154
- name: "client:component-path",
155
- value: resolvedPath
156
- });
157
- }
158
- if (!attributeNames.includes("client:component-export")) {
159
- if (meta.name === "*") {
160
- meta.name = node.name.split(".").slice(1).join(".");
161
- }
162
- node.attributes.push({
163
- type: "mdxJsxAttribute",
164
- name: "client:component-export",
165
- value: meta.name
166
- });
167
- }
168
- if (!attributeNames.includes("client:component-hydration")) {
169
- node.attributes.push({
170
- type: "mdxJsxAttribute",
171
- name: "client:component-hydration",
172
- value: null
173
- });
174
- }
175
- }
176
- function addClientOnlyMetadata(node, meta, resolvedPath) {
177
- const attributeNames = node.attributes.map((attr) => attr.type === "mdxJsxAttribute" ? attr.name : null).filter(Boolean);
178
- if (!attributeNames.includes("client:display-name")) {
179
- node.attributes.push({
180
- type: "mdxJsxAttribute",
181
- name: "client:display-name",
182
- value: node.name
183
- });
184
- }
185
- if (!attributeNames.includes("client:component-path")) {
186
- node.attributes.push({
187
- type: "mdxJsxAttribute",
188
- name: "client:component-path",
189
- value: resolvedPath
190
- });
191
- }
192
- if (!attributeNames.includes("client:component-export")) {
193
- if (meta.name === "*") {
194
- meta.name = node.name.split(".").slice(1).join(".");
195
- }
196
- node.attributes.push({
197
- type: "mdxJsxAttribute",
198
- name: "client:component-export",
199
- value: meta.name
200
- });
201
- }
202
- if (!attributeNames.includes("client:component-hydration")) {
203
- node.attributes.push({
204
- type: "mdxJsxAttribute",
205
- name: "client:component-hydration",
206
- value: null
207
- });
208
- }
209
- node.name = ClientOnlyPlaceholder;
210
- }
211
- function addServerDeferMetadata(node, meta, resolvedPath) {
212
- const attributeNames = node.attributes.map((attr) => attr.type === "mdxJsxAttribute" ? attr.name : null).filter(Boolean);
213
- if (!attributeNames.includes("server:component-directive")) {
214
- node.attributes.push({
215
- type: "mdxJsxAttribute",
216
- name: "server:component-directive",
217
- value: "server:defer"
218
- });
219
- }
220
- if (!attributeNames.includes("server:component-path")) {
221
- node.attributes.push({
222
- type: "mdxJsxAttribute",
223
- name: "server:component-path",
224
- value: resolvedPath
225
- });
226
- }
227
- if (!attributeNames.includes("server:component-export")) {
228
- if (meta.name === "*") {
229
- meta.name = node.name.split(".").slice(1).join(".");
230
- }
231
- node.attributes.push({
232
- type: "mdxJsxAttribute",
233
- name: "server:component-export",
234
- value: meta.name
235
- });
236
- }
237
- }
238
- export {
239
- getAstroMetadata,
240
- rehypeAnalyzeAstroMetadata
241
- };