astro 2.9.2 → 2.9.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/components/ViewTransitions.astro +37 -2
- package/dist/@types/astro.d.ts +1 -0
- package/dist/assets/internal.d.ts +2 -0
- package/dist/assets/internal.js +9 -0
- package/dist/assets/services/squoosh.js +3 -5
- package/dist/assets/types.d.ts +1 -1
- package/dist/assets/utils/emitAsset.js +21 -11
- package/dist/assets/utils/metadata.d.ts +1 -1
- package/dist/assets/utils/metadata.js +2 -13
- package/dist/cli/add/index.js +1 -1
- package/dist/cli/load-settings.js +1 -2
- package/dist/config/index.js +1 -1
- package/dist/content/runtime.js +2 -2
- package/dist/core/build/generate.js +5 -2
- package/dist/core/build/index.js +5 -0
- package/dist/core/config/settings.d.ts +2 -2
- package/dist/core/config/settings.js +5 -6
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/container.js +4 -0
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render/result.js +6 -8
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +2 -6
- package/dist/runtime/server/jsx.js +4 -13
- package/dist/runtime/server/render/any.d.ts +2 -1
- package/dist/runtime/server/render/any.js +18 -22
- package/dist/runtime/server/render/astro/index.d.ts +1 -1
- package/dist/runtime/server/render/astro/index.js +1 -6
- package/dist/runtime/server/render/astro/instance.d.ts +3 -2
- package/dist/runtime/server/render/astro/instance.js +8 -4
- package/dist/runtime/server/render/astro/render-template.d.ts +2 -4
- package/dist/runtime/server/render/astro/render-template.js +8 -29
- package/dist/runtime/server/render/astro/render.js +4 -8
- package/dist/runtime/server/render/common.d.ts +17 -13
- package/dist/runtime/server/render/common.js +4 -20
- package/dist/runtime/server/render/component.d.ts +10 -4
- package/dist/runtime/server/render/component.js +131 -54
- package/dist/runtime/server/render/dom.d.ts +1 -1
- package/dist/runtime/server/render/index.d.ts +4 -4
- package/dist/runtime/server/render/index.js +8 -12
- package/dist/runtime/server/render/page.d.ts +2 -7
- package/dist/runtime/server/render/page.js +13 -62
- package/dist/runtime/server/render/slot.d.ts +2 -1
- package/dist/runtime/server/render/slot.js +23 -16
- package/dist/runtime/server/render/tags.d.ts +1 -0
- package/dist/runtime/server/render/tags.js +34 -1
- package/dist/runtime/server/render/util.d.ts +0 -18
- package/dist/runtime/server/render/util.js +0 -101
- package/package.json +2 -2
|
@@ -13,6 +13,7 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
13
13
|
<script>
|
|
14
14
|
type Fallback = 'none' | 'animate' | 'swap';
|
|
15
15
|
type Direction = 'forward' | 'back';
|
|
16
|
+
type Events = 'astro:load' | 'astro:beforeload';
|
|
16
17
|
|
|
17
18
|
// The History API does not tell you if navigation is forward or back, so
|
|
18
19
|
// you can figure it using an index. On pushState the index is incremented so you
|
|
@@ -25,6 +26,8 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
25
26
|
const supportsViewTransitions = !!document.startViewTransition;
|
|
26
27
|
const transitionEnabledOnThisPage = () =>
|
|
27
28
|
!!document.querySelector('[name="astro-view-transitions-enabled"]');
|
|
29
|
+
const triggerEvent = (name: Events) => document.dispatchEvent(new Event(name));
|
|
30
|
+
const onload = () => triggerEvent('astro:load');
|
|
28
31
|
|
|
29
32
|
async function getHTML(href: string) {
|
|
30
33
|
const res = await fetch(href);
|
|
@@ -40,12 +43,34 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
40
43
|
return 'animate';
|
|
41
44
|
}
|
|
42
45
|
|
|
46
|
+
function runScripts() {
|
|
47
|
+
let wait = Promise.resolve();
|
|
48
|
+
for (const script of Array.from(document.scripts)) {
|
|
49
|
+
const s = document.createElement('script');
|
|
50
|
+
s.innerHTML = script.innerHTML;
|
|
51
|
+
for (const attr of script.attributes) {
|
|
52
|
+
if (attr.name === 'src') {
|
|
53
|
+
const p = new Promise((r) => {
|
|
54
|
+
s.onload = r;
|
|
55
|
+
});
|
|
56
|
+
wait = wait.then(() => p as any);
|
|
57
|
+
}
|
|
58
|
+
s.setAttribute(attr.name, attr.value);
|
|
59
|
+
}
|
|
60
|
+
script.replaceWith(s);
|
|
61
|
+
}
|
|
62
|
+
return wait;
|
|
63
|
+
}
|
|
64
|
+
|
|
43
65
|
const parser = new DOMParser();
|
|
44
66
|
|
|
45
67
|
async function updateDOM(dir: Direction, html: string, fallback?: Fallback) {
|
|
46
68
|
const doc = parser.parseFromString(html, 'text/html');
|
|
47
69
|
doc.documentElement.dataset.astroTransition = dir;
|
|
48
|
-
const swap = () =>
|
|
70
|
+
const swap = () => {
|
|
71
|
+
document.documentElement.replaceWith(doc.documentElement);
|
|
72
|
+
triggerEvent('astro:beforeload');
|
|
73
|
+
};
|
|
49
74
|
|
|
50
75
|
// Wait on links to finish, to prevent FOUC
|
|
51
76
|
const links = Array.from(doc.querySelectorAll('head link[rel=stylesheet]')).map(
|
|
@@ -95,6 +120,8 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
95
120
|
await finished;
|
|
96
121
|
} finally {
|
|
97
122
|
document.documentElement.removeAttribute('data-astro-transition');
|
|
123
|
+
await runScripts();
|
|
124
|
+
onload();
|
|
98
125
|
}
|
|
99
126
|
}
|
|
100
127
|
|
|
@@ -126,6 +153,7 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
126
153
|
link.href &&
|
|
127
154
|
(!link.target || link.target === '_self') &&
|
|
128
155
|
link.origin === location.origin &&
|
|
156
|
+
!link.hash &&
|
|
129
157
|
ev.button === 0 && // left clicks only
|
|
130
158
|
!ev.metaKey && // new tab (mac)
|
|
131
159
|
!ev.ctrlKey && // new tab (windows)
|
|
@@ -140,13 +168,19 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
140
168
|
history.pushState({ index: currentHistoryIndex }, '', link.href);
|
|
141
169
|
}
|
|
142
170
|
});
|
|
143
|
-
window.addEventListener('popstate', () => {
|
|
171
|
+
window.addEventListener('popstate', (ev) => {
|
|
144
172
|
if (!transitionEnabledOnThisPage()) {
|
|
145
173
|
// The current page doesn't haven't View Transitions,
|
|
146
174
|
// respect that with a full page reload
|
|
147
175
|
location.reload();
|
|
148
176
|
return;
|
|
149
177
|
}
|
|
178
|
+
// hash change creates no state.
|
|
179
|
+
if (ev.state === null) {
|
|
180
|
+
history.replaceState({ index: currentHistoryIndex }, '');
|
|
181
|
+
ev.preventDefault();
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
150
184
|
const nextIndex = history.state?.index ?? currentHistoryIndex + 1;
|
|
151
185
|
const direction: Direction = nextIndex > currentHistoryIndex ? 'forward' : 'back';
|
|
152
186
|
navigate(direction, location.href);
|
|
@@ -171,5 +205,6 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
171
205
|
{ passive: true, capture: true }
|
|
172
206
|
);
|
|
173
207
|
});
|
|
208
|
+
addEventListener('load', onload);
|
|
174
209
|
}
|
|
175
210
|
</script>
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1826,6 +1826,7 @@ export interface SSRMetadata {
|
|
|
1826
1826
|
headInTree: boolean;
|
|
1827
1827
|
extraHead: string[];
|
|
1828
1828
|
propagators: Map<AstroComponentFactory, AstroComponentInstance>;
|
|
1829
|
+
contentKeys: Set<string>;
|
|
1829
1830
|
}
|
|
1830
1831
|
export interface PreviewServer {
|
|
1831
1832
|
host?: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { AstroSettings } from '../@types/astro.js';
|
|
1
2
|
import { type ImageService } from './services/service.js';
|
|
2
3
|
import type { GetImageResult, ImageMetadata, ImageTransform } from './types.js';
|
|
4
|
+
export declare function injectImageEndpoint(settings: AstroSettings): AstroSettings;
|
|
3
5
|
export declare function isESMImportedImage(src: ImageMetadata | string): src is ImageMetadata;
|
|
4
6
|
export declare function getConfiguredImageService(): Promise<ImageService>;
|
|
5
7
|
export declare function getImage(options: ImageTransform, serviceConfig: Record<string, any>): Promise<GetImageResult>;
|
package/dist/assets/internal.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
2
2
|
import { isLocalService } from "./services/service.js";
|
|
3
|
+
function injectImageEndpoint(settings) {
|
|
4
|
+
settings.injectedRoutes.push({
|
|
5
|
+
pattern: "/_image",
|
|
6
|
+
entryPoint: "astro/assets/image-endpoint",
|
|
7
|
+
prerender: false
|
|
8
|
+
});
|
|
9
|
+
return settings;
|
|
10
|
+
}
|
|
3
11
|
function isESMImportedImage(src) {
|
|
4
12
|
return typeof src === "object";
|
|
5
13
|
}
|
|
@@ -44,5 +52,6 @@ async function getImage(options, serviceConfig) {
|
|
|
44
52
|
export {
|
|
45
53
|
getConfiguredImageService,
|
|
46
54
|
getImage,
|
|
55
|
+
injectImageEndpoint,
|
|
47
56
|
isESMImportedImage
|
|
48
57
|
};
|
|
@@ -18,10 +18,8 @@ const qualityTable = {
|
|
|
18
18
|
webp: baseQuality
|
|
19
19
|
// Squoosh's PNG encoder does not support a quality setting, so we can skip that here
|
|
20
20
|
};
|
|
21
|
-
async function getRotationForEXIF(
|
|
22
|
-
const
|
|
23
|
-
const filePathURL = new URL("." + filePath, "file:");
|
|
24
|
-
const meta = await imageMetadata(filePathURL, inputBuffer);
|
|
21
|
+
async function getRotationForEXIF(inputBuffer) {
|
|
22
|
+
const meta = await imageMetadata(inputBuffer);
|
|
25
23
|
if (!meta)
|
|
26
24
|
return void 0;
|
|
27
25
|
switch (meta.orientation) {
|
|
@@ -47,7 +45,7 @@ const service = {
|
|
|
47
45
|
if (format === "svg")
|
|
48
46
|
return { data: inputBuffer, format: "svg" };
|
|
49
47
|
const operations = [];
|
|
50
|
-
const rotation = await getRotationForEXIF(
|
|
48
|
+
const rotation = await getRotationForEXIF(inputBuffer);
|
|
51
49
|
if (rotation) {
|
|
52
50
|
operations.push(rotation);
|
|
53
51
|
}
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { prependForwardSlash, slash } from "../../core/path.js";
|
|
@@ -8,26 +8,36 @@ async function emitESMImage(id, watchMode, fileEmitter) {
|
|
|
8
8
|
return void 0;
|
|
9
9
|
}
|
|
10
10
|
const url = pathToFileURL(id);
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
let fileData;
|
|
12
|
+
try {
|
|
13
|
+
fileData = await fs.readFile(url);
|
|
14
|
+
} catch (err) {
|
|
13
15
|
return void 0;
|
|
14
16
|
}
|
|
17
|
+
const fileMetadata = await imageMetadata(fileData);
|
|
18
|
+
if (!fileMetadata) {
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
const emittedImage = {
|
|
22
|
+
src: "",
|
|
23
|
+
...fileMetadata
|
|
24
|
+
};
|
|
15
25
|
if (!watchMode) {
|
|
16
26
|
const pathname = decodeURI(url.pathname);
|
|
17
|
-
const filename = path.basename(pathname, path.extname(pathname) + `.${
|
|
27
|
+
const filename = path.basename(pathname, path.extname(pathname) + `.${fileMetadata.format}`);
|
|
18
28
|
const handle = fileEmitter({
|
|
19
29
|
name: filename,
|
|
20
|
-
source: await fs.
|
|
30
|
+
source: await fs.readFile(url),
|
|
21
31
|
type: "asset"
|
|
22
32
|
});
|
|
23
|
-
|
|
33
|
+
emittedImage.src = `__ASTRO_ASSET_IMAGE__${handle}__`;
|
|
24
34
|
} else {
|
|
25
|
-
url.searchParams.append("origWidth",
|
|
26
|
-
url.searchParams.append("origHeight",
|
|
27
|
-
url.searchParams.append("origFormat",
|
|
28
|
-
|
|
35
|
+
url.searchParams.append("origWidth", fileMetadata.width.toString());
|
|
36
|
+
url.searchParams.append("origHeight", fileMetadata.height.toString());
|
|
37
|
+
url.searchParams.append("origFormat", fileMetadata.format);
|
|
38
|
+
emittedImage.src = `/@fs` + prependForwardSlash(fileURLToNormalizedPath(url));
|
|
29
39
|
}
|
|
30
|
-
return
|
|
40
|
+
return emittedImage;
|
|
31
41
|
}
|
|
32
42
|
function fileURLToNormalizedPath(filePath) {
|
|
33
43
|
return slash(fileURLToPath(filePath) + filePath.search).replace(/\\/g, "/");
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { ImageMetadata } from '../types.js';
|
|
3
|
-
export declare function imageMetadata(
|
|
3
|
+
export declare function imageMetadata(data: Buffer): Promise<Omit<ImageMetadata, 'src'> | undefined>;
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
1
|
import imageSize from "../vendor/image-size/index.js";
|
|
4
|
-
async function imageMetadata(
|
|
5
|
-
|
|
6
|
-
if (!file) {
|
|
7
|
-
try {
|
|
8
|
-
file = await fs.readFile(src);
|
|
9
|
-
} catch (e) {
|
|
10
|
-
return void 0;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const { width, height, type, orientation } = imageSize(file);
|
|
2
|
+
async function imageMetadata(data) {
|
|
3
|
+
const { width, height, type, orientation } = imageSize(data);
|
|
14
4
|
const isPortrait = (orientation || 0) >= 5;
|
|
15
5
|
if (!width || !height || !type) {
|
|
16
6
|
return void 0;
|
|
17
7
|
}
|
|
18
8
|
return {
|
|
19
|
-
src: fileURLToPath(src),
|
|
20
9
|
width: isPortrait ? height : width,
|
|
21
10
|
height: isPortrait ? width : height,
|
|
22
11
|
format: type,
|
package/dist/cli/add/index.js
CHANGED
|
@@ -86,7 +86,7 @@ async function add(names, { flags, logging }) {
|
|
|
86
86
|
["svelte", "astro add svelte"],
|
|
87
87
|
["solid-js", "astro add solid-js"],
|
|
88
88
|
["lit", "astro add lit"],
|
|
89
|
-
["
|
|
89
|
+
["alpinejs", "astro add alpinejs"]
|
|
90
90
|
],
|
|
91
91
|
"SSR Adapters": [
|
|
92
92
|
["netlify", "astro add netlify"],
|
|
@@ -17,11 +17,10 @@ async function loadSettings({ cmd, flags, logging }) {
|
|
|
17
17
|
await handleConfigError(e, { cmd, cwd: root, flags, logging });
|
|
18
18
|
return {};
|
|
19
19
|
});
|
|
20
|
-
const mode = cmd === "build" ? "build" : "dev";
|
|
21
20
|
if (!initialAstroConfig)
|
|
22
21
|
return;
|
|
23
22
|
telemetry.record(event.eventCliSession(cmd, initialUserConfig, flags));
|
|
24
|
-
return createSettings(initialAstroConfig,
|
|
23
|
+
return createSettings(initialAstroConfig, root);
|
|
25
24
|
}
|
|
26
25
|
async function handleConfigError(e, { cmd, cwd, flags, logging }) {
|
|
27
26
|
const path = await resolveConfigPath({ cwd, flags, fs });
|
package/dist/config/index.js
CHANGED
|
@@ -26,7 +26,7 @@ function getViteConfig(inlineConfig) {
|
|
|
26
26
|
level: "info"
|
|
27
27
|
};
|
|
28
28
|
const { astroConfig: config } = await openConfig({ cmd });
|
|
29
|
-
const settings = createSettings(config,
|
|
29
|
+
const settings = createSettings(config, inlineConfig.root);
|
|
30
30
|
await runHookConfigSetup({ settings, command: cmd, logging });
|
|
31
31
|
const viteConfig = await createVite(
|
|
32
32
|
{
|
package/dist/content/runtime.js
CHANGED
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
createComponent,
|
|
6
6
|
createHeadAndContent,
|
|
7
7
|
renderComponent,
|
|
8
|
-
renderScriptElement,
|
|
9
8
|
renderTemplate,
|
|
9
|
+
renderUniqueScriptElement,
|
|
10
10
|
renderUniqueStylesheet,
|
|
11
11
|
unescapeHTML
|
|
12
12
|
} from "../runtime/server/index.js";
|
|
@@ -222,7 +222,7 @@ async function render({
|
|
|
222
222
|
}).join("");
|
|
223
223
|
}
|
|
224
224
|
if (Array.isArray(collectedScripts)) {
|
|
225
|
-
scripts = collectedScripts.map((script) =>
|
|
225
|
+
scripts = collectedScripts.map((script) => renderUniqueScriptElement(result, script)).join("");
|
|
226
226
|
}
|
|
227
227
|
let props = baseProps;
|
|
228
228
|
if (id.endsWith("mdx")) {
|
|
@@ -84,11 +84,14 @@ function chunkIsPage(settings, output, internals) {
|
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
86
|
async function generatePages(opts, internals) {
|
|
87
|
+
var _a, _b;
|
|
87
88
|
const timer = performance.now();
|
|
88
89
|
const ssr = isServerLikeOutput(opts.settings.config);
|
|
89
90
|
const outFolder = ssr ? opts.settings.config.build.server : getOutDirWithinCwd(opts.settings.config.outDir);
|
|
90
|
-
if (ssr && !hasPrerenderedPages(internals))
|
|
91
|
+
if (ssr && !hasPrerenderedPages(internals)) {
|
|
92
|
+
(_a = globalThis == null ? void 0 : globalThis.astroAsset) == null ? true : delete _a.addStaticImage;
|
|
91
93
|
return;
|
|
94
|
+
}
|
|
92
95
|
const verb = ssr ? "prerendering" : "generating";
|
|
93
96
|
info(opts.logging, null, `
|
|
94
97
|
${bgGreen(black(` ${verb} static routes `))}`);
|
|
@@ -139,7 +142,7 @@ ${bgGreen(black(` generating optimized images `))}`);
|
|
|
139
142
|
for (const imageData of getStaticImageList()) {
|
|
140
143
|
await generateImage(opts, imageData[1].options, imageData[1].path);
|
|
141
144
|
}
|
|
142
|
-
|
|
145
|
+
(_b = globalThis == null ? void 0 : globalThis.astroAsset) == null ? true : delete _b.addStaticImage;
|
|
143
146
|
}
|
|
144
147
|
await runHookBuildGenerated({
|
|
145
148
|
config: opts.settings.config,
|
package/dist/core/build/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as colors from "kleur/colors";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { performance } from "node:perf_hooks";
|
|
4
|
+
import { injectImageEndpoint } from "../../assets/internal.js";
|
|
4
5
|
import {
|
|
5
6
|
runHookBuildDone,
|
|
6
7
|
runHookBuildStart,
|
|
7
8
|
runHookConfigDone,
|
|
8
9
|
runHookConfigSetup
|
|
9
10
|
} from "../../integrations/index.js";
|
|
11
|
+
import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
10
12
|
import { createVite } from "../create-vite.js";
|
|
11
13
|
import { debug, info, levels, timerMessage, warn } from "../logger/core.js";
|
|
12
14
|
import { printHelp } from "../messages.js";
|
|
@@ -60,6 +62,9 @@ class AstroBuilder {
|
|
|
60
62
|
command: "build",
|
|
61
63
|
logging
|
|
62
64
|
});
|
|
65
|
+
if (this.settings.config.experimental.assets && isServerLikeOutput(this.settings.config)) {
|
|
66
|
+
this.settings = injectImageEndpoint(this.settings);
|
|
67
|
+
}
|
|
63
68
|
this.manifest = createRouteManifest({ settings: this.settings }, this.logging);
|
|
64
69
|
const viteConfig = await createVite(
|
|
65
70
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AstroConfig, AstroSettings, AstroUserConfig } from '../../@types/astro';
|
|
2
|
-
export declare function createBaseSettings(config: AstroConfig
|
|
3
|
-
export declare function createSettings(config: AstroConfig,
|
|
2
|
+
export declare function createBaseSettings(config: AstroConfig): AstroSettings;
|
|
3
|
+
export declare function createSettings(config: AstroConfig, cwd?: string): AstroSettings;
|
|
4
4
|
export declare function createDefaultDevSettings(userConfig?: AstroUserConfig, root?: string | URL): Promise<AstroSettings>;
|
|
@@ -3,7 +3,6 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { getContentPaths } from "../../content/index.js";
|
|
5
5
|
import jsxRenderer from "../../jsx/renderer.js";
|
|
6
|
-
import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
7
6
|
import { markdownContentEntryType } from "../../vite-plugin-markdown/content-entry-type.js";
|
|
8
7
|
import { getDefaultClientDirectives } from "../client-directive/index.js";
|
|
9
8
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
@@ -12,14 +11,14 @@ import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./../constants.js";
|
|
|
12
11
|
import { createDefaultDevConfig } from "./config.js";
|
|
13
12
|
import { AstroTimer } from "./timer.js";
|
|
14
13
|
import { loadTSConfig } from "./tsconfig.js";
|
|
15
|
-
function createBaseSettings(config
|
|
14
|
+
function createBaseSettings(config) {
|
|
16
15
|
const { contentDir } = getContentPaths(config);
|
|
17
16
|
return {
|
|
18
17
|
config,
|
|
19
18
|
tsConfig: void 0,
|
|
20
19
|
tsConfigPath: void 0,
|
|
21
20
|
adapter: void 0,
|
|
22
|
-
injectedRoutes:
|
|
21
|
+
injectedRoutes: [],
|
|
23
22
|
pageExtensions: [".astro", ".html", ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS],
|
|
24
23
|
contentEntryTypes: [markdownContentEntryType],
|
|
25
24
|
dataEntryTypes: [
|
|
@@ -92,9 +91,9 @@ function createBaseSettings(config, mode) {
|
|
|
92
91
|
timer: new AstroTimer()
|
|
93
92
|
};
|
|
94
93
|
}
|
|
95
|
-
function createSettings(config,
|
|
94
|
+
function createSettings(config, cwd) {
|
|
96
95
|
const tsconfig = loadTSConfig(cwd);
|
|
97
|
-
const settings = createBaseSettings(config
|
|
96
|
+
const settings = createBaseSettings(config);
|
|
98
97
|
const watchFiles = (tsconfig == null ? void 0 : tsconfig.exists) ? [tsconfig.path, ...tsconfig.extendedPaths] : [];
|
|
99
98
|
if (cwd) {
|
|
100
99
|
watchFiles.push(fileURLToPath(new URL("./package.json", pathToFileURL(cwd))));
|
|
@@ -109,7 +108,7 @@ async function createDefaultDevSettings(userConfig = {}, root) {
|
|
|
109
108
|
root = fileURLToPath(root);
|
|
110
109
|
}
|
|
111
110
|
const config = await createDefaultDevConfig(userConfig, root);
|
|
112
|
-
return createBaseSettings(config
|
|
111
|
+
return createBaseSettings(config);
|
|
113
112
|
}
|
|
114
113
|
export {
|
|
115
114
|
createBaseSettings,
|
package/dist/core/constants.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import nodeFs from "node:fs";
|
|
2
2
|
import * as vite from "vite";
|
|
3
|
+
import { injectImageEndpoint } from "../../assets/internal.js";
|
|
3
4
|
import {
|
|
4
5
|
runHookConfigDone,
|
|
5
6
|
runHookConfigSetup,
|
|
@@ -29,6 +30,9 @@ async function createContainer(params = {}) {
|
|
|
29
30
|
logging,
|
|
30
31
|
isRestart
|
|
31
32
|
});
|
|
33
|
+
if (settings.config.experimental.assets) {
|
|
34
|
+
settings = injectImageEndpoint(settings);
|
|
35
|
+
}
|
|
32
36
|
const { host, headers, open } = settings.config.server;
|
|
33
37
|
const rendererClientEntries = settings.renderers.map((r) => r.clientEntrypoint).filter(Boolean);
|
|
34
38
|
const viteConfig = await createVite(
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -54,7 +54,7 @@ async function dev(settings, options) {
|
|
|
54
54
|
isRestart: options.isRestart
|
|
55
55
|
})
|
|
56
56
|
);
|
|
57
|
-
const currentVersion = "2.9.
|
|
57
|
+
const currentVersion = "2.9.4";
|
|
58
58
|
if (currentVersion.includes("-")) {
|
|
59
59
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
60
60
|
}
|
package/dist/core/dev/restart.js
CHANGED
|
@@ -62,7 +62,7 @@ async function restartContainer({
|
|
|
62
62
|
});
|
|
63
63
|
info(logging, "astro", logMsg + "\n");
|
|
64
64
|
let astroConfig = newConfig.astroConfig;
|
|
65
|
-
const settings = createSettings(astroConfig,
|
|
65
|
+
const settings = createSettings(astroConfig, resolvedRoot);
|
|
66
66
|
await close();
|
|
67
67
|
return {
|
|
68
68
|
container: await createRestartedContainer(container, settings, needsStart),
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.9.
|
|
50
|
+
const version = "2.9.4";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
53
53
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -233,7 +233,7 @@ function printHelp({
|
|
|
233
233
|
message.push(
|
|
234
234
|
linebreak(),
|
|
235
235
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
236
|
-
`v${"2.9.
|
|
236
|
+
`v${"2.9.4"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
renderSlotToString,
|
|
4
|
-
stringifyChunk
|
|
5
|
-
} from "../../runtime/server/index.js";
|
|
1
|
+
import { renderSlotToString } from "../../runtime/server/index.js";
|
|
6
2
|
import { renderJSX } from "../../runtime/server/jsx.js";
|
|
3
|
+
import { chunkToString } from "../../runtime/server/render/index.js";
|
|
7
4
|
import { AstroCookies } from "../cookies/index.js";
|
|
8
5
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
9
6
|
import { warn } from "../logger/core.js";
|
|
@@ -62,7 +59,7 @@ class Slots {
|
|
|
62
59
|
const component = typeof slotValue === "function" ? await slotValue(result) : await slotValue;
|
|
63
60
|
const expression = getFunctionExpression(component);
|
|
64
61
|
if (expression) {
|
|
65
|
-
const slot = async () =>
|
|
62
|
+
const slot = async () => typeof expression === "function" ? expression(...args) : expression;
|
|
66
63
|
return await renderSlotToString(result, slot).then((res) => {
|
|
67
64
|
return res != null ? String(res) : res;
|
|
68
65
|
});
|
|
@@ -74,7 +71,7 @@ class Slots {
|
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
73
|
const content = await renderSlotToString(result, this.#slots[name]);
|
|
77
|
-
const outHTML =
|
|
74
|
+
const outHTML = chunkToString(result, content);
|
|
78
75
|
return outHTML;
|
|
79
76
|
}
|
|
80
77
|
}
|
|
@@ -181,7 +178,8 @@ function createResult(args) {
|
|
|
181
178
|
hasDirectives: /* @__PURE__ */ new Set(),
|
|
182
179
|
headInTree: false,
|
|
183
180
|
extraHead: [],
|
|
184
|
-
propagators: /* @__PURE__ */ new Map()
|
|
181
|
+
propagators: /* @__PURE__ */ new Map(),
|
|
182
|
+
contentKeys: /* @__PURE__ */ new Set()
|
|
185
183
|
}
|
|
186
184
|
};
|
|
187
185
|
return result;
|
|
@@ -3,7 +3,7 @@ export { createAstro } from './astro-global.js';
|
|
|
3
3
|
export { renderEndpoint } from './endpoint.js';
|
|
4
4
|
export { escapeHTML, HTMLBytes, HTMLString, isHTMLString, markHTMLString, unescapeHTML, } from './escape.js';
|
|
5
5
|
export { renderJSX } from './jsx.js';
|
|
6
|
-
export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, renderTemplate as render,
|
|
6
|
+
export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, renderTemplate as render, renderComponent, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderScriptElement, renderSlot, renderSlotToString, renderTemplate, renderToString, renderUniqueScriptElement, renderUniqueStylesheet, voidElementNames, } from './render/index.js';
|
|
7
7
|
export type { AstroComponentFactory, AstroComponentInstance, ComponentSlots, RenderInstruction, } from './render/index.js';
|
|
8
8
|
export { renderTransition } from './transition.js';
|
|
9
9
|
export declare function mergeSlots(...slotted: unknown[]): Record<string, () => any>;
|
|
@@ -17,9 +17,7 @@ import {
|
|
|
17
17
|
Fragment,
|
|
18
18
|
maybeRenderHead,
|
|
19
19
|
renderTemplate,
|
|
20
|
-
renderAstroTemplateResult,
|
|
21
20
|
renderComponent,
|
|
22
|
-
renderComponentToIterable,
|
|
23
21
|
Renderer,
|
|
24
22
|
renderHead,
|
|
25
23
|
renderHTMLElement,
|
|
@@ -29,8 +27,8 @@ import {
|
|
|
29
27
|
renderSlotToString,
|
|
30
28
|
renderTemplate as renderTemplate2,
|
|
31
29
|
renderToString,
|
|
30
|
+
renderUniqueScriptElement,
|
|
32
31
|
renderUniqueStylesheet,
|
|
33
|
-
stringifyChunk,
|
|
34
32
|
voidElementNames
|
|
35
33
|
} from "./render/index.js";
|
|
36
34
|
import { renderTransition } from "./transition.js";
|
|
@@ -106,9 +104,7 @@ export {
|
|
|
106
104
|
maybeRenderHead,
|
|
107
105
|
mergeSlots,
|
|
108
106
|
renderTemplate as render,
|
|
109
|
-
renderAstroTemplateResult as renderAstroComponent,
|
|
110
107
|
renderComponent,
|
|
111
|
-
renderComponentToIterable,
|
|
112
108
|
renderEndpoint,
|
|
113
109
|
renderHTMLElement,
|
|
114
110
|
renderHead,
|
|
@@ -120,9 +116,9 @@ export {
|
|
|
120
116
|
renderTemplate2 as renderTemplate,
|
|
121
117
|
renderToString,
|
|
122
118
|
renderTransition,
|
|
119
|
+
renderUniqueScriptElement,
|
|
123
120
|
renderUniqueStylesheet,
|
|
124
121
|
spreadAttributes,
|
|
125
|
-
stringifyChunk,
|
|
126
122
|
unescapeHTML,
|
|
127
123
|
voidElementNames
|
|
128
124
|
};
|
|
@@ -3,12 +3,11 @@ import {
|
|
|
3
3
|
HTMLString,
|
|
4
4
|
escapeHTML,
|
|
5
5
|
markHTMLString,
|
|
6
|
-
renderComponentToIterable,
|
|
7
6
|
renderToString,
|
|
8
7
|
spreadAttributes,
|
|
9
8
|
voidElementNames
|
|
10
9
|
} from "./index.js";
|
|
11
|
-
import {
|
|
10
|
+
import { renderComponentToString } from "./render/component.js";
|
|
12
11
|
const ClientOnlyPlaceholder = "astro-client-only";
|
|
13
12
|
class Skip {
|
|
14
13
|
constructor(vnode) {
|
|
@@ -164,7 +163,7 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
164
163
|
props[Skip.symbol] = skip;
|
|
165
164
|
let output;
|
|
166
165
|
if (vnode.type === ClientOnlyPlaceholder && vnode.props["client:only"]) {
|
|
167
|
-
output = await
|
|
166
|
+
output = await renderComponentToString(
|
|
168
167
|
result,
|
|
169
168
|
vnode.props["client:display-name"] ?? "",
|
|
170
169
|
null,
|
|
@@ -172,7 +171,7 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
172
171
|
slots
|
|
173
172
|
);
|
|
174
173
|
} else {
|
|
175
|
-
output = await
|
|
174
|
+
output = await renderComponentToString(
|
|
176
175
|
result,
|
|
177
176
|
typeof vnode.type === "function" ? vnode.type.name : vnode.type,
|
|
178
177
|
vnode.type,
|
|
@@ -180,15 +179,7 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
180
179
|
slots
|
|
181
180
|
);
|
|
182
181
|
}
|
|
183
|
-
|
|
184
|
-
let parts = new HTMLParts();
|
|
185
|
-
for await (const chunk of output) {
|
|
186
|
-
parts.append(chunk, result);
|
|
187
|
-
}
|
|
188
|
-
return markHTMLString(parts.toString());
|
|
189
|
-
} else {
|
|
190
|
-
return markHTMLString(output);
|
|
191
|
-
}
|
|
182
|
+
return markHTMLString(output);
|
|
192
183
|
}
|
|
193
184
|
}
|
|
194
185
|
return markHTMLString(`${vnode}`);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { type RenderDestination } from './common.js';
|
|
2
|
+
export declare function renderChild(destination: RenderDestination, child: any): Promise<void>;
|