astro 7.0.0-alpha.2 → 7.0.0-beta.4
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.
- package/dist/assets/build/generate.js +4 -3
- package/dist/assets/fonts/core/collect-font-data.js +1 -0
- package/dist/assets/fonts/types.d.ts +1 -0
- package/dist/cli/add/index.js +1 -44
- package/dist/cli/dev/background.js +1 -1
- package/dist/cli/dev/index.js +1 -1
- package/dist/cli/flags.js +4 -6
- package/dist/cli/help/index.js +1 -2
- package/dist/cli/index.js +1 -15
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/container/index.d.ts +3 -3
- package/dist/container/index.js +1 -4
- package/dist/content/content-layer.js +3 -3
- package/dist/content/runtime.d.ts +1 -1
- package/dist/content/runtime.js +1 -0
- package/dist/content/vite-plugin-content-virtual-mod.js +27 -0
- package/dist/core/app/base.d.ts +1 -1
- package/dist/core/app/base.js +14 -24
- package/dist/core/app/dev/pipeline.js +0 -9
- package/dist/core/app/manifest.d.ts +0 -2
- package/dist/core/app/manifest.js +0 -8
- package/dist/core/app/types.d.ts +1 -8
- package/dist/core/base-pipeline.d.ts +3 -9
- package/dist/core/base-pipeline.js +4 -23
- package/dist/core/build/app.d.ts +0 -2
- package/dist/core/build/app.js +0 -5
- package/dist/core/build/generate.js +0 -14
- package/dist/core/build/pipeline.js +0 -9
- package/dist/core/build/plugins/plugin-css.js +1 -0
- package/dist/core/build/plugins/plugin-manifest.js +4 -9
- package/dist/core/config/config.js +3 -2
- package/dist/core/config/schemas/base.d.ts +9 -22
- package/dist/core/config/schemas/base.js +11 -27
- package/dist/core/config/schemas/relative.d.ts +15 -36
- package/dist/core/config/validate.js +10 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/default-handler.js +21 -8
- package/dist/core/fetch/fetch-state.js +3 -16
- package/dist/core/fetch/types.d.ts +1 -1
- package/dist/core/fetch/vite-plugin.js +4 -6
- package/dist/core/hono/index.d.ts +1 -0
- package/dist/core/hono/index.js +1 -0
- package/dist/core/logger/impls/node.js +0 -1
- package/dist/core/logger/load.js +3 -2
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/index.js +8 -1
- package/dist/core/middleware/vite-plugin.d.ts +1 -0
- package/dist/core/middleware/vite-plugin.js +5 -1
- package/dist/core/util/normalized-url.js +2 -5
- package/dist/core/util/pathname.d.ts +13 -7
- package/dist/core/util/pathname.js +9 -6
- package/dist/i18n/index.js +6 -2
- package/dist/manifest/serialized.js +4 -5
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +4 -0
- package/dist/runtime/server/jsx.js +2 -1
- package/dist/runtime/server/render/astro/render-template.d.ts +1 -1
- package/dist/runtime/server/render/astro/render.d.ts +0 -4
- package/dist/runtime/server/render/astro/render.js +76 -68
- package/dist/runtime/server/render/head.js +2 -1
- package/dist/runtime/server/render/index.d.ts +1 -0
- package/dist/runtime/server/render/index.js +2 -0
- package/dist/runtime/server/render/page.js +9 -44
- package/dist/runtime/server/render/streaming.d.ts +23 -0
- package/dist/runtime/server/render/streaming.js +238 -0
- package/dist/runtime/server/render/util.js +5 -1
- package/dist/types/public/config.d.ts +115 -123
- package/dist/types/public/context.d.ts +1 -1
- package/dist/types/public/internal.d.ts +0 -15
- package/dist/vite-plugin-app/app.js +1 -1
- package/dist/vite-plugin-app/pipeline.js +0 -9
- package/dist/vite-plugin-hmr-reload/index.js +19 -6
- package/dist/vite-plugin-html/transform/slots.js +4 -1
- package/dist/vite-plugin-pages/pages.d.ts +11 -0
- package/dist/vite-plugin-pages/pages.js +1 -3
- package/package.json +13 -7
- package/dist/cli/db/index.d.ts +0 -4
- package/dist/cli/db/index.js +0 -25
- package/dist/jsx/rehype.d.ts +0 -5
- package/dist/jsx/rehype.js +0 -241
- package/dist/runtime/server/html-string-cache.d.ts +0 -48
- package/dist/runtime/server/html-string-cache.js +0 -119
- package/dist/runtime/server/render/queue/builder.d.ts +0 -14
- package/dist/runtime/server/render/queue/builder.js +0 -182
- package/dist/runtime/server/render/queue/jsx-builder.d.ts +0 -33
- package/dist/runtime/server/render/queue/jsx-builder.js +0 -146
- package/dist/runtime/server/render/queue/pool.d.ts +0 -123
- package/dist/runtime/server/render/queue/pool.js +0 -203
- package/dist/runtime/server/render/queue/renderer.d.ts +0 -12
- package/dist/runtime/server/render/queue/renderer.js +0 -103
- package/dist/runtime/server/render/queue/types.d.ts +0 -81
- package/dist/runtime/server/render/queue/types.js +0 -0
|
@@ -11,9 +11,6 @@ function getRoutesForEnvironment(routes, isPrerender) {
|
|
|
11
11
|
if (route.prerender === isPrerender) {
|
|
12
12
|
result.add(route);
|
|
13
13
|
}
|
|
14
|
-
if (route.redirectRoute) {
|
|
15
|
-
result.add(route.redirectRoute);
|
|
16
|
-
}
|
|
17
14
|
}
|
|
18
15
|
return result;
|
|
19
16
|
}
|
|
@@ -75,5 +72,6 @@ export { pageMap };`;
|
|
|
75
72
|
}
|
|
76
73
|
export {
|
|
77
74
|
VIRTUAL_PAGES_MODULE_ID,
|
|
75
|
+
getRoutesForEnvironment,
|
|
78
76
|
pluginPages
|
|
79
77
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-beta.4",
|
|
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",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"./astro-jsx": "./astro-jsx.d.ts",
|
|
40
40
|
"./tsconfigs/*.json": "./tsconfigs/*",
|
|
41
41
|
"./tsconfigs/*": "./tsconfigs/*.json",
|
|
42
|
-
"./jsx/rehype.js": "./dist/jsx/rehype.js",
|
|
43
42
|
"./jsx-runtime": {
|
|
44
43
|
"types": "./jsx-runtime.d.ts",
|
|
45
44
|
"default": "./dist/jsx-runtime/index.js"
|
|
@@ -167,12 +166,20 @@
|
|
|
167
166
|
"yargs-parser": "^22.0.0",
|
|
168
167
|
"zod": "^4.3.6",
|
|
169
168
|
"@astrojs/internal-helpers": "0.10.0",
|
|
170
|
-
"@astrojs/
|
|
171
|
-
"@astrojs/
|
|
169
|
+
"@astrojs/telemetry": "3.3.2",
|
|
170
|
+
"@astrojs/markdown-satteri": "0.3.1-beta.1"
|
|
172
171
|
},
|
|
173
172
|
"optionalDependencies": {
|
|
174
173
|
"sharp": "^0.34.0"
|
|
175
174
|
},
|
|
175
|
+
"peerDependencies": {
|
|
176
|
+
"@astrojs/markdown-remark": "7.2.0"
|
|
177
|
+
},
|
|
178
|
+
"peerDependenciesMeta": {
|
|
179
|
+
"@astrojs/markdown-remark": {
|
|
180
|
+
"optional": true
|
|
181
|
+
}
|
|
182
|
+
},
|
|
176
183
|
"devDependencies": {
|
|
177
184
|
"@playwright/test": "1.58.2",
|
|
178
185
|
"@types/aria-query": "^5.0.4",
|
|
@@ -189,8 +196,6 @@
|
|
|
189
196
|
"expect-type": "^1.3.0",
|
|
190
197
|
"fs-fixture": "^2.13.0",
|
|
191
198
|
"hono": "^4.12.14",
|
|
192
|
-
"mdast-util-mdx": "^3.0.0",
|
|
193
|
-
"mdast-util-mdx-jsx": "^3.2.0",
|
|
194
199
|
"node-mocks-http": "^1.17.2",
|
|
195
200
|
"parse-srcset": "^1.0.2",
|
|
196
201
|
"rehype-autolink-headings": "^7.1.0",
|
|
@@ -203,7 +208,8 @@
|
|
|
203
208
|
"unified": "^11.0.5",
|
|
204
209
|
"vitest": "^4.1.0",
|
|
205
210
|
"@astrojs/check": "0.9.9",
|
|
206
|
-
"astro-scripts": "0.0.14"
|
|
211
|
+
"astro-scripts": "0.0.14",
|
|
212
|
+
"@astrojs/markdown-remark": "7.2.0"
|
|
207
213
|
},
|
|
208
214
|
"engines": {
|
|
209
215
|
"node": ">=22.12.0",
|
package/dist/cli/db/index.d.ts
DELETED
package/dist/cli/db/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { resolveConfig } from "../../core/config/config.js";
|
|
2
|
-
import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
|
|
3
|
-
import { getPackage } from "../install-package.js";
|
|
4
|
-
async function db({ flags }) {
|
|
5
|
-
const logger = createLoggerFromFlags(flags);
|
|
6
|
-
const getPackageOpts = {
|
|
7
|
-
skipAsk: !!flags.yes || !!flags.y,
|
|
8
|
-
cwd: flags.root
|
|
9
|
-
};
|
|
10
|
-
const dbPackage = await getPackage("@astrojs/db", logger, getPackageOpts, []);
|
|
11
|
-
if (!dbPackage) {
|
|
12
|
-
logger.error(
|
|
13
|
-
"check",
|
|
14
|
-
"The `@astrojs/db` package is required for this command to work. Please manually install it in your project and try again."
|
|
15
|
-
);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const { cli } = dbPackage;
|
|
19
|
-
const inlineConfig = flagsToAstroInlineConfig(flags);
|
|
20
|
-
const { astroConfig } = await resolveConfig(inlineConfig, "build");
|
|
21
|
-
await cli({ flags, config: astroConfig });
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
db
|
|
25
|
-
};
|
package/dist/jsx/rehype.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { RehypePlugin } from '@astrojs/internal-helpers/markdown';
|
|
2
|
-
import type { VFile } from 'vfile';
|
|
3
|
-
import type { PluginMetadata } from '../vite-plugin-astro/types.js';
|
|
4
|
-
export declare const rehypeAnalyzeAstroMetadata: RehypePlugin;
|
|
5
|
-
export declare function getAstroMetadata(file: VFile): PluginMetadata["astro"] | undefined;
|
package/dist/jsx/rehype.js
DELETED
|
@@ -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
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { HTMLString } from './escape.js';
|
|
2
|
-
/**
|
|
3
|
-
* LRU (Least Recently Used) cache for HTMLString objects.
|
|
4
|
-
*
|
|
5
|
-
* This cache reduces memory allocations by reusing identical HTMLString objects
|
|
6
|
-
* across both recursive rendering (.astro files) and queue rendering (MDX files).
|
|
7
|
-
*
|
|
8
|
-
* When the cache reaches maxSize, the least recently used item is evicted.
|
|
9
|
-
* This keeps memory usage bounded while maintaining good cache hit rates.
|
|
10
|
-
*
|
|
11
|
-
* Example:
|
|
12
|
-
* - 10,000 identical `<li class="foo">` tags → single cached HTMLString object
|
|
13
|
-
* - Memory savings: ~30KB (10,000 objects) → ~3 bytes (1 object + Map overhead)
|
|
14
|
-
*/
|
|
15
|
-
export declare class HTMLStringCache {
|
|
16
|
-
private cache;
|
|
17
|
-
private readonly maxSize;
|
|
18
|
-
constructor(maxSize?: number);
|
|
19
|
-
/**
|
|
20
|
-
* Get or create an HTMLString for the given content.
|
|
21
|
-
* If cached, the existing object is returned and moved to end (most recently used).
|
|
22
|
-
* If not cached, a new HTMLString is created, cached, and returned.
|
|
23
|
-
*
|
|
24
|
-
* @param content - The HTML string content
|
|
25
|
-
* @returns HTMLString object (cached or newly created)
|
|
26
|
-
*/
|
|
27
|
-
getOrCreate(content: string): HTMLString;
|
|
28
|
-
/**
|
|
29
|
-
* Get current cache size
|
|
30
|
-
*/
|
|
31
|
-
size(): number;
|
|
32
|
-
/**
|
|
33
|
-
* Pre-warms the cache with common HTML patterns.
|
|
34
|
-
* This ensures first-render cache hits for frequently used tags.
|
|
35
|
-
*
|
|
36
|
-
* @param patterns - Array of HTML strings to pre-cache
|
|
37
|
-
*/
|
|
38
|
-
warm(patterns: string[]): void;
|
|
39
|
-
/**
|
|
40
|
-
* Clear the entire cache
|
|
41
|
-
*/
|
|
42
|
-
clear(): void;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Common HTML patterns that appear frequently in Astro pages.
|
|
46
|
-
* Pre-warming the cache with these patterns ensures first-render cache hits.
|
|
47
|
-
*/
|
|
48
|
-
export declare const COMMON_HTML_PATTERNS: string[];
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { HTMLString } from "./escape.js";
|
|
2
|
-
class HTMLStringCache {
|
|
3
|
-
cache = /* @__PURE__ */ new Map();
|
|
4
|
-
maxSize;
|
|
5
|
-
constructor(maxSize = 1e3) {
|
|
6
|
-
this.maxSize = maxSize;
|
|
7
|
-
this.warm(COMMON_HTML_PATTERNS);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Get or create an HTMLString for the given content.
|
|
11
|
-
* If cached, the existing object is returned and moved to end (most recently used).
|
|
12
|
-
* If not cached, a new HTMLString is created, cached, and returned.
|
|
13
|
-
*
|
|
14
|
-
* @param content - The HTML string content
|
|
15
|
-
* @returns HTMLString object (cached or newly created)
|
|
16
|
-
*/
|
|
17
|
-
getOrCreate(content) {
|
|
18
|
-
const cached = this.cache.get(content);
|
|
19
|
-
if (cached) {
|
|
20
|
-
this.cache.delete(content);
|
|
21
|
-
this.cache.set(content, cached);
|
|
22
|
-
return cached;
|
|
23
|
-
}
|
|
24
|
-
const htmlString = new HTMLString(content);
|
|
25
|
-
this.cache.set(content, htmlString);
|
|
26
|
-
if (this.cache.size > this.maxSize) {
|
|
27
|
-
const firstKey = this.cache.keys().next().value;
|
|
28
|
-
if (firstKey !== void 0) {
|
|
29
|
-
this.cache.delete(firstKey);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return htmlString;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get current cache size
|
|
36
|
-
*/
|
|
37
|
-
size() {
|
|
38
|
-
return this.cache.size;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Pre-warms the cache with common HTML patterns.
|
|
42
|
-
* This ensures first-render cache hits for frequently used tags.
|
|
43
|
-
*
|
|
44
|
-
* @param patterns - Array of HTML strings to pre-cache
|
|
45
|
-
*/
|
|
46
|
-
warm(patterns) {
|
|
47
|
-
for (const pattern of patterns) {
|
|
48
|
-
if (!this.cache.has(pattern)) {
|
|
49
|
-
this.cache.set(pattern, new HTMLString(pattern));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Clear the entire cache
|
|
55
|
-
*/
|
|
56
|
-
clear() {
|
|
57
|
-
this.cache.clear();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const COMMON_HTML_PATTERNS = [
|
|
61
|
-
// Structural elements
|
|
62
|
-
"<div>",
|
|
63
|
-
"</div>",
|
|
64
|
-
"<span>",
|
|
65
|
-
"</span>",
|
|
66
|
-
"<p>",
|
|
67
|
-
"</p>",
|
|
68
|
-
"<section>",
|
|
69
|
-
"</section>",
|
|
70
|
-
"<article>",
|
|
71
|
-
"</article>",
|
|
72
|
-
"<header>",
|
|
73
|
-
"</header>",
|
|
74
|
-
"<footer>",
|
|
75
|
-
"</footer>",
|
|
76
|
-
"<nav>",
|
|
77
|
-
"</nav>",
|
|
78
|
-
"<main>",
|
|
79
|
-
"</main>",
|
|
80
|
-
"<aside>",
|
|
81
|
-
"</aside>",
|
|
82
|
-
// List elements
|
|
83
|
-
"<ul>",
|
|
84
|
-
"</ul>",
|
|
85
|
-
"<ol>",
|
|
86
|
-
"</ol>",
|
|
87
|
-
"<li>",
|
|
88
|
-
"</li>",
|
|
89
|
-
// Void/self-closing elements
|
|
90
|
-
"<br>",
|
|
91
|
-
"<hr>",
|
|
92
|
-
"<br/>",
|
|
93
|
-
"<hr/>",
|
|
94
|
-
// Heading elements
|
|
95
|
-
"<h1>",
|
|
96
|
-
"</h1>",
|
|
97
|
-
"<h2>",
|
|
98
|
-
"</h2>",
|
|
99
|
-
"<h3>",
|
|
100
|
-
"</h3>",
|
|
101
|
-
"<h4>",
|
|
102
|
-
"</h4>",
|
|
103
|
-
// Inline elements
|
|
104
|
-
"<a>",
|
|
105
|
-
"</a>",
|
|
106
|
-
"<strong>",
|
|
107
|
-
"</strong>",
|
|
108
|
-
"<em>",
|
|
109
|
-
"</em>",
|
|
110
|
-
"<code>",
|
|
111
|
-
"</code>",
|
|
112
|
-
// Common whitespace
|
|
113
|
-
" ",
|
|
114
|
-
"\n"
|
|
115
|
-
];
|
|
116
|
-
export {
|
|
117
|
-
COMMON_HTML_PATTERNS,
|
|
118
|
-
HTMLStringCache
|
|
119
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { SSRResult } from '../../../../types/public/internal.js';
|
|
2
|
-
import type { RenderQueue } from './types.js';
|
|
3
|
-
import type { NodePool } from './pool.js';
|
|
4
|
-
/**
|
|
5
|
-
* Builds a render queue from a component tree.
|
|
6
|
-
* This function traverses the tree depth-first and creates a flat queue
|
|
7
|
-
* of nodes to be rendered, with parent tracking.
|
|
8
|
-
*
|
|
9
|
-
* @param root - The root component/value to render
|
|
10
|
-
* @param result - SSR result context
|
|
11
|
-
* @param pool
|
|
12
|
-
* @returns A render queue ready for rendering
|
|
13
|
-
*/
|
|
14
|
-
export declare function buildRenderQueue(root: any, result: SSRResult, pool: NodePool): Promise<RenderQueue>;
|