astro 4.8.5 → 4.8.7
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/astro-jsx.d.ts +1 -1
- package/dist/actions/runtime/middleware.js +31 -1
- package/dist/core/build/consts.d.ts +1 -0
- package/dist/core/build/consts.js +3 -1
- package/dist/core/build/index.js +2 -2
- package/dist/core/build/plugins/plugin-analyzer.js +6 -1
- package/dist/core/build/plugins/plugin-content.d.ts +1 -1
- package/dist/core/build/plugins/plugin-content.js +13 -2
- package/dist/core/build/static-build.d.ts +2 -1
- package/dist/core/build/static-build.js +7 -6
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/i18n/utils.d.ts +1 -1
- package/dist/runtime/client/dev-toolbar/apps/utils/highlight.js +2 -0
- package/dist/runtime/server/jsx.js +1 -0
- package/package.json +1 -1
package/astro-jsx.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { yellow } from "kleur/colors";
|
|
1
2
|
import { defineMiddleware } from "../../core/middleware/index.js";
|
|
2
3
|
import { ApiContextStorage } from "./store.js";
|
|
3
4
|
import { formContentTypes, getAction, hasContentType } from "./utils.js";
|
|
4
5
|
import { callSafely } from "./virtual/shared.js";
|
|
5
6
|
const onRequest = defineMiddleware(async (context, next) => {
|
|
6
7
|
const locals = context.locals;
|
|
8
|
+
if (context.request.method === "GET") {
|
|
9
|
+
return nextWithLocalsStub(next, locals);
|
|
10
|
+
}
|
|
11
|
+
if (context.request.method === "POST" && context.request.body === null) {
|
|
12
|
+
return nextWithStaticStub(next, locals);
|
|
13
|
+
}
|
|
7
14
|
if (locals._actionsInternal) return next();
|
|
8
15
|
const { request, url } = context;
|
|
9
16
|
const contentType = request.headers.get("Content-Type");
|
|
@@ -25,8 +32,31 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
25
32
|
}
|
|
26
33
|
};
|
|
27
34
|
Object.defineProperty(locals, "_actionsInternal", { writable: false, value: actionsInternal });
|
|
28
|
-
|
|
35
|
+
const response = await next();
|
|
36
|
+
if (result.error) {
|
|
37
|
+
return new Response(response.body, {
|
|
38
|
+
status: result.error.status,
|
|
39
|
+
statusText: result.error.name,
|
|
40
|
+
headers: response.headers
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return response;
|
|
29
44
|
});
|
|
45
|
+
function nextWithStaticStub(next, locals) {
|
|
46
|
+
Object.defineProperty(locals, "_actionsInternal", {
|
|
47
|
+
writable: false,
|
|
48
|
+
value: {
|
|
49
|
+
getActionResult: () => {
|
|
50
|
+
console.warn(
|
|
51
|
+
yellow("[astro:actions]"),
|
|
52
|
+
"`getActionResult()` should not be called on prerendered pages. Astro can only handle actions for pages rendered on-demand."
|
|
53
|
+
);
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return next();
|
|
59
|
+
}
|
|
30
60
|
function nextWithLocalsStub(next, locals) {
|
|
31
61
|
Object.defineProperty(locals, "_actionsInternal", {
|
|
32
62
|
writable: false,
|
package/dist/core/build/index.js
CHANGED
|
@@ -129,8 +129,8 @@ class AstroBuilder {
|
|
|
129
129
|
teardownCompiler: this.teardownCompiler,
|
|
130
130
|
viteConfig
|
|
131
131
|
};
|
|
132
|
-
const { internals, ssrOutputChunkNames } = await viteBuild(opts);
|
|
133
|
-
await staticBuild(opts, internals, ssrOutputChunkNames);
|
|
132
|
+
const { internals, ssrOutputChunkNames, contentFileNames } = await viteBuild(opts);
|
|
133
|
+
await staticBuild(opts, internals, ssrOutputChunkNames, contentFileNames);
|
|
134
134
|
this.timer.assetsStart = performance.now();
|
|
135
135
|
Object.keys(assets).map((k) => {
|
|
136
136
|
if (!assets[k]) return;
|
|
@@ -31,7 +31,12 @@ function vitePluginAnalyzer(options, internals) {
|
|
|
31
31
|
if (hoistedScripts.size) {
|
|
32
32
|
for (const parentInfo of getParentModuleInfos(from, this, isPropagatedAsset)) {
|
|
33
33
|
if (isPropagatedAsset(parentInfo.id)) {
|
|
34
|
-
|
|
34
|
+
for (const hid of hoistedScripts) {
|
|
35
|
+
if (!internals.propagatedScriptsMap.has(parentInfo.id)) {
|
|
36
|
+
internals.propagatedScriptsMap.set(parentInfo.id, /* @__PURE__ */ new Set());
|
|
37
|
+
}
|
|
38
|
+
internals.propagatedScriptsMap.get(parentInfo.id)?.add(hid);
|
|
39
|
+
}
|
|
35
40
|
} else if (moduleIsTopLevelPage(parentInfo)) {
|
|
36
41
|
for (const hid of hoistedScripts) {
|
|
37
42
|
if (!pageScripts.has(parentInfo.id)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BuildInternals } from '../internal.js';
|
|
2
2
|
import type { AstroBuildPlugin } from '../plugin.js';
|
|
3
3
|
import type { StaticBuildOptions } from '../types.js';
|
|
4
|
-
export declare function copyContentToCache(opts: StaticBuildOptions): Promise<
|
|
4
|
+
export declare function copyContentToCache(opts: StaticBuildOptions): Promise<string[]>;
|
|
5
5
|
export declare function pluginContent(opts: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import fsMod from "node:fs";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import glob from "fast-glob";
|
|
4
5
|
import pLimit from "p-limit";
|
|
5
6
|
import { normalizePath } from "vite";
|
|
6
7
|
import { CONTENT_RENDER_FLAG, PROPAGATED_ASSET_FLAG } from "../../../content/consts.js";
|
|
@@ -19,12 +20,12 @@ import {
|
|
|
19
20
|
} from "../../path.js";
|
|
20
21
|
import { isContentCollectionsCacheEnabled } from "../../util.js";
|
|
21
22
|
import { addRollupInput } from "../add-rollup-input.js";
|
|
22
|
-
import { CHUNKS_PATH } from "../consts.js";
|
|
23
|
+
import { CHUNKS_PATH, CONTENT_PATH } from "../consts.js";
|
|
23
24
|
import {} from "../internal.js";
|
|
24
25
|
import { copyFiles } from "../static-build.js";
|
|
25
26
|
import { encodeName } from "../util.js";
|
|
26
27
|
import { extendManualChunks } from "./util.js";
|
|
27
|
-
const CONTENT_CACHE_DIR = "./
|
|
28
|
+
const CONTENT_CACHE_DIR = "./" + CONTENT_PATH;
|
|
28
29
|
const CONTENT_MANIFEST_FILE = "./manifest.json";
|
|
29
30
|
const CONTENT_MANIFEST_VERSION = 1;
|
|
30
31
|
const virtualEmptyModuleId = `virtual:empty-content`;
|
|
@@ -340,7 +341,17 @@ async function copyContentToCache(opts) {
|
|
|
340
341
|
await fsMod.promises.mkdir(cacheTmp, { recursive: true });
|
|
341
342
|
await copyFiles(distContentRoot, cacheTmp, true);
|
|
342
343
|
await copyFiles(cacheTmp, contentCacheDir);
|
|
344
|
+
let files = [];
|
|
345
|
+
await Promise.all([
|
|
346
|
+
glob(`**/*.{mjs,json}`, {
|
|
347
|
+
cwd: fileURLToPath(cacheTmp)
|
|
348
|
+
}).then((f) => files.push(...f.map((file) => CONTENT_PATH + file))),
|
|
349
|
+
glob(`**/*.{mjs,json}`, {
|
|
350
|
+
cwd: fileURLToPath(new URL("./" + CHUNKS_PATH, config.outDir))
|
|
351
|
+
}).then((f) => files.push(...f.map((file) => CHUNKS_PATH + file)))
|
|
352
|
+
]);
|
|
343
353
|
await fsMod.promises.rm(cacheTmp, { recursive: true, force: true });
|
|
354
|
+
return files;
|
|
344
355
|
}
|
|
345
356
|
function pluginContent(opts, internals) {
|
|
346
357
|
const { cacheDir, outDir } = opts.settings.config;
|
|
@@ -4,8 +4,9 @@ import type { StaticBuildOptions } from './types.js';
|
|
|
4
4
|
export declare function viteBuild(opts: StaticBuildOptions): Promise<{
|
|
5
5
|
internals: BuildInternals;
|
|
6
6
|
ssrOutputChunkNames: string[];
|
|
7
|
+
contentFileNames: string[] | undefined;
|
|
7
8
|
}>;
|
|
8
|
-
export declare function staticBuild(opts: StaticBuildOptions, internals: BuildInternals, ssrOutputChunkNames: string[]): Promise<void>;
|
|
9
|
+
export declare function staticBuild(opts: StaticBuildOptions, internals: BuildInternals, ssrOutputChunkNames: string[], contentFileNames?: string[]): Promise<void>;
|
|
9
10
|
export declare function copyFiles(fromFolder: URL, toFolder: URL, includeDotfiles?: boolean): Promise<void[] | undefined>;
|
|
10
11
|
/**
|
|
11
12
|
* This function takes the virtual module name of any page entrypoint and
|
|
@@ -75,8 +75,9 @@ async function viteBuild(opts) {
|
|
|
75
75
|
const ssrOutputs = viteBuildReturnToRollupOutputs(ssrOutput);
|
|
76
76
|
const clientOutputs = viteBuildReturnToRollupOutputs(clientOutput ?? []);
|
|
77
77
|
await runPostBuildHooks(container, ssrOutputs, clientOutputs);
|
|
78
|
+
let contentFileNames = void 0;
|
|
78
79
|
if (opts.settings.config.experimental.contentCollectionCache) {
|
|
79
|
-
await copyContentToCache(opts);
|
|
80
|
+
contentFileNames = await copyContentToCache(opts);
|
|
80
81
|
}
|
|
81
82
|
settings.timer.end("Client build");
|
|
82
83
|
internals.ssrEntryChunk = void 0;
|
|
@@ -91,15 +92,15 @@ async function viteBuild(opts) {
|
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
|
-
return { internals, ssrOutputChunkNames };
|
|
95
|
+
return { internals, ssrOutputChunkNames, contentFileNames };
|
|
95
96
|
}
|
|
96
|
-
async function staticBuild(opts, internals, ssrOutputChunkNames) {
|
|
97
|
+
async function staticBuild(opts, internals, ssrOutputChunkNames, contentFileNames) {
|
|
97
98
|
const { settings } = opts;
|
|
98
99
|
switch (true) {
|
|
99
100
|
case settings.config.output === "static": {
|
|
100
101
|
settings.timer.start("Static generate");
|
|
101
102
|
await generatePages(opts, internals);
|
|
102
|
-
await cleanServerOutput(opts, ssrOutputChunkNames, internals);
|
|
103
|
+
await cleanServerOutput(opts, ssrOutputChunkNames, contentFileNames, internals);
|
|
103
104
|
settings.timer.end("Static generate");
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
@@ -325,9 +326,9 @@ export const ${e.n} = noop;`;
|
|
|
325
326
|
removeEmptyDirs(out);
|
|
326
327
|
}
|
|
327
328
|
}
|
|
328
|
-
async function cleanServerOutput(opts, ssrOutputChunkNames, internals) {
|
|
329
|
+
async function cleanServerOutput(opts, ssrOutputChunkNames, contentFileNames, internals) {
|
|
329
330
|
const out = getOutDirWithinCwd(opts.settings.config.outDir);
|
|
330
|
-
const files = ssrOutputChunkNames.filter((f) => f.endsWith(".mjs"));
|
|
331
|
+
const files = ssrOutputChunkNames.filter((f) => f.endsWith(".mjs")).concat(contentFileNames ?? []);
|
|
331
332
|
if (internals.manifestFileName) {
|
|
332
333
|
files.push(internals.manifestFileName);
|
|
333
334
|
}
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -19,7 +19,7 @@ async function dev(inlineConfig) {
|
|
|
19
19
|
await telemetry.record([]);
|
|
20
20
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
21
21
|
const logger = restart.container.logger;
|
|
22
|
-
const currentVersion = "4.8.
|
|
22
|
+
const currentVersion = "4.8.7";
|
|
23
23
|
const isPrerelease = currentVersion.includes("-");
|
|
24
24
|
if (!isPrerelease) {
|
|
25
25
|
try {
|
package/dist/core/messages.js
CHANGED
|
@@ -37,7 +37,7 @@ function serverStart({
|
|
|
37
37
|
host,
|
|
38
38
|
base
|
|
39
39
|
}) {
|
|
40
|
-
const version = "4.8.
|
|
40
|
+
const version = "4.8.7";
|
|
41
41
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
42
42
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
43
43
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -269,7 +269,7 @@ function printHelp({
|
|
|
269
269
|
message.push(
|
|
270
270
|
linebreak(),
|
|
271
271
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
272
|
-
`v${"4.8.
|
|
272
|
+
`v${"4.8.7"}`
|
|
273
273
|
)} ${headline}`
|
|
274
274
|
);
|
|
275
275
|
}
|
package/dist/i18n/utils.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ type BrowserLocale = {
|
|
|
4
4
|
qualityValue: number | undefined;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
|
-
* Parses the value of the `Accept-
|
|
7
|
+
* Parses the value of the `Accept-Language` header:
|
|
8
8
|
*
|
|
9
9
|
* More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language
|
|
10
10
|
*
|
|
@@ -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);
|