astro 1.2.8 → 1.3.1
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/@types/astro.d.ts +3 -0
- package/dist/cli/check/index.js +7 -2
- package/dist/cli/check/print.js +1 -2
- package/dist/cli/index.js +1 -1
- package/dist/core/build/generate.js +6 -0
- package/dist/core/build/index.js +9 -0
- package/dist/core/build/static-build.js +31 -11
- package/dist/core/config/schema.d.ts +12 -12
- package/dist/core/dev/index.js +7 -8
- package/dist/core/endpoint/index.js +1 -1
- package/dist/core/messages.d.ts +10 -6
- package/dist/core/messages.js +57 -32
- package/dist/core/path.d.ts +1 -0
- package/dist/core/path.js +4 -0
- package/dist/core/preview/index.js +8 -5
- package/dist/core/render/route-cache.js +1 -4
- package/dist/core/routing/params.js +1 -1
- package/dist/core/util.d.ts +1 -1
- package/dist/core/util.js +2 -2
- package/dist/integrations/index.d.ts +5 -0
- package/dist/integrations/index.js +18 -0
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/astro-island.js +4 -1
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/endpoint.d.ts +1 -1
- package/dist/runtime/server/endpoint.js +5 -1
- package/dist/runtime/server/escape.d.ts +8 -1
- package/dist/runtime/server/escape.js +47 -4
- package/dist/runtime/server/hydration.js +3 -1
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +2 -1
- package/dist/runtime/server/jsx.js +4 -5
- package/dist/runtime/server/render/any.js +3 -1
- package/dist/runtime/server/render/astro.d.ts +3 -2
- package/dist/runtime/server/render/astro.js +4 -4
- package/dist/runtime/server/render/common.d.ts +12 -0
- package/dist/runtime/server/render/common.js +55 -0
- package/dist/runtime/server/render/component.d.ts +2 -1
- package/dist/runtime/server/render/page.js +22 -17
- package/dist/runtime/server/render/util.js +2 -2
- package/dist/runtime/server/response.js +1 -1
- package/dist/runtime/server/serialize.js +13 -1
- package/dist/runtime/server/util.d.ts +1 -0
- package/dist/runtime/server/util.js +4 -6
- package/dist/vite-plugin-astro/hmr.js +3 -2
- package/dist/vite-plugin-jsx/tag.js +52 -20
- package/dist/vite-plugin-markdown/index.js +6 -1
- package/dist/vite-plugin-utils/index.js +4 -1
- package/package.json +5 -4
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1043,6 +1043,9 @@ export interface AstroIntegration {
|
|
|
1043
1043
|
target: 'client' | 'server';
|
|
1044
1044
|
updateConfig: (newConfig: ViteConfigWithSSR) => void;
|
|
1045
1045
|
}) => void | Promise<void>;
|
|
1046
|
+
'astro:build:generated'?: (options: {
|
|
1047
|
+
dir: URL;
|
|
1048
|
+
}) => void | Promise<void>;
|
|
1046
1049
|
'astro:build:done'?: (options: {
|
|
1047
1050
|
pages: {
|
|
1048
1051
|
pathname: string;
|
package/dist/cli/check/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { AstroCheck, DiagnosticSeverity } from "@astrojs/language-server";
|
|
|
2
2
|
import glob from "fast-glob";
|
|
3
3
|
import * as fs from "fs";
|
|
4
4
|
import { bold, dim, red, yellow } from "kleur/colors";
|
|
5
|
+
import { createRequire } from "module";
|
|
5
6
|
import ora from "ora";
|
|
6
7
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
7
8
|
import { printDiagnostic } from "./print.js";
|
|
@@ -9,7 +10,11 @@ async function check(settings) {
|
|
|
9
10
|
console.log(bold("astro check"));
|
|
10
11
|
const root = settings.config.root;
|
|
11
12
|
const spinner = ora(` Getting diagnostics for Astro files in ${fileURLToPath(root)}\u2026`).start();
|
|
12
|
-
|
|
13
|
+
const require2 = createRequire(import.meta.url);
|
|
14
|
+
let checker = new AstroCheck(
|
|
15
|
+
root.toString(),
|
|
16
|
+
require2.resolve("typescript/lib/tsserverlibrary.js", { paths: [root.toString()] })
|
|
17
|
+
);
|
|
13
18
|
const filesCount = await openAllDocuments(root, [], checker);
|
|
14
19
|
let diagnostics = await checker.getDiagnostics();
|
|
15
20
|
spinner.succeed();
|
|
@@ -20,7 +25,7 @@ async function check(settings) {
|
|
|
20
25
|
};
|
|
21
26
|
diagnostics.forEach((diag) => {
|
|
22
27
|
diag.diagnostics.forEach((d) => {
|
|
23
|
-
console.log(printDiagnostic(diag.
|
|
28
|
+
console.log(printDiagnostic(diag.fileUri, diag.text, d));
|
|
24
29
|
switch (d.severity) {
|
|
25
30
|
case DiagnosticSeverity.Error: {
|
|
26
31
|
result.errors++;
|
package/dist/cli/check/print.js
CHANGED
|
@@ -17,8 +17,7 @@ function printDiagnostic(filePath, text, diag) {
|
|
|
17
17
|
let result = [];
|
|
18
18
|
const realStartLine = diag.range.start.line + 1;
|
|
19
19
|
const realStartCharacter = diag.range.start.character + 1;
|
|
20
|
-
const
|
|
21
|
-
const IDEFilePath = `${bold(cyan(normalizedFilePath))}:${bold(yellow(realStartLine))}:${bold(
|
|
20
|
+
const IDEFilePath = `${bold(cyan(fileURLToPath(filePath)))}:${bold(yellow(realStartLine))}:${bold(
|
|
22
21
|
yellow(realStartCharacter)
|
|
23
22
|
)}`;
|
|
24
23
|
result.push(
|
package/dist/cli/index.js
CHANGED
|
@@ -187,7 +187,7 @@ async function runCommand(cmd, flags) {
|
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
case "build": {
|
|
190
|
-
return await build(settings, { logging, telemetry });
|
|
190
|
+
return await build(settings, { ...flags, logging, telemetry });
|
|
191
191
|
}
|
|
192
192
|
case "check": {
|
|
193
193
|
const ret = await check(settings);
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
removeLeadingForwardSlash,
|
|
10
10
|
removeTrailingForwardSlash
|
|
11
11
|
} from "../../core/path.js";
|
|
12
|
+
import { runHookBuildGenerated } from "../../integrations/index.js";
|
|
12
13
|
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
|
|
13
14
|
import { call as callEndpoint } from "../endpoint/index.js";
|
|
14
15
|
import { debug, info } from "../logger/core.js";
|
|
@@ -72,6 +73,11 @@ ${bgGreen(black(" generating static routes "))}`);
|
|
|
72
73
|
for (const pageData of eachPageData(internals)) {
|
|
73
74
|
await generatePage(opts, internals, pageData, ssrEntry, builtPaths);
|
|
74
75
|
}
|
|
76
|
+
await runHookBuildGenerated({
|
|
77
|
+
config: opts.settings.config,
|
|
78
|
+
buildConfig: opts.buildConfig,
|
|
79
|
+
logging: opts.logging
|
|
80
|
+
});
|
|
75
81
|
info(opts.logging, null, dim(`Completed in ${getTimeStat(timer, performance.now())}.
|
|
76
82
|
`));
|
|
77
83
|
}
|
package/dist/core/build/index.js
CHANGED
|
@@ -64,6 +64,7 @@ class AstroBuilder {
|
|
|
64
64
|
serverEntry: "entry.mjs"
|
|
65
65
|
};
|
|
66
66
|
await runHookBuildStart({ config: this.settings.config, buildConfig, logging: this.logging });
|
|
67
|
+
this.validateConfig();
|
|
67
68
|
info(this.logging, "build", `output target: ${colors.green(this.settings.config.output)}`);
|
|
68
69
|
if (this.settings.adapter) {
|
|
69
70
|
info(this.logging, "build", `deploy adapter: ${colors.green(this.settings.adapter.name)}`);
|
|
@@ -129,6 +130,14 @@ class AstroBuilder {
|
|
|
129
130
|
throw fixViteErrorMessage(_err);
|
|
130
131
|
}
|
|
131
132
|
}
|
|
133
|
+
validateConfig() {
|
|
134
|
+
const { config } = this.settings;
|
|
135
|
+
if (config.outDir.toString() === config.root.toString()) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`the outDir cannot be the root folder. Please build to a folder such as dist.`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
132
141
|
async printStats({
|
|
133
142
|
logging,
|
|
134
143
|
timeStart,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import glob from "fast-glob";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { bgGreen, bgMagenta, black, dim } from "kleur/colors";
|
|
4
|
+
import path from "path";
|
|
4
5
|
import { fileURLToPath } from "url";
|
|
5
6
|
import * as vite from "vite";
|
|
6
7
|
import { createBuildInternals } from "../../core/build/internal.js";
|
|
@@ -82,8 +83,8 @@ async function ssrBuild(opts, internals, input) {
|
|
|
82
83
|
const out = ssr ? opts.buildConfig.server : getOutDirWithinCwd(settings.config.outDir);
|
|
83
84
|
const viteBuildConfig = {
|
|
84
85
|
...viteConfig,
|
|
86
|
+
mode: viteConfig.mode || "production",
|
|
85
87
|
logLevel: opts.viteConfig.logLevel ?? "error",
|
|
86
|
-
mode: "production",
|
|
87
88
|
build: {
|
|
88
89
|
target: "esnext",
|
|
89
90
|
...viteConfig.build,
|
|
@@ -147,8 +148,8 @@ async function clientBuild(opts, internals, input) {
|
|
|
147
148
|
${bgGreen(black(" building client "))}`);
|
|
148
149
|
const viteBuildConfig = {
|
|
149
150
|
...viteConfig,
|
|
151
|
+
mode: viteConfig.mode || "production",
|
|
150
152
|
logLevel: "info",
|
|
151
|
-
mode: "production",
|
|
152
153
|
build: {
|
|
153
154
|
target: "esnext",
|
|
154
155
|
...viteConfig.build,
|
|
@@ -194,19 +195,38 @@ ${bgGreen(black(" building client "))}`);
|
|
|
194
195
|
}
|
|
195
196
|
async function cleanSsrOutput(opts) {
|
|
196
197
|
const out = getOutDirWithinCwd(opts.settings.config.outDir);
|
|
198
|
+
const files = await glob("**/*.mjs", {
|
|
199
|
+
cwd: fileURLToPath(out)
|
|
200
|
+
});
|
|
201
|
+
if (files.length) {
|
|
202
|
+
await Promise.all(
|
|
203
|
+
files.map(async (filename) => {
|
|
204
|
+
const url = new URL(filename, out);
|
|
205
|
+
await fs.promises.rm(url);
|
|
206
|
+
})
|
|
207
|
+
);
|
|
208
|
+
const directories = /* @__PURE__ */ new Set();
|
|
209
|
+
files.forEach((i) => {
|
|
210
|
+
const splitFilePath = i.split(path.sep);
|
|
211
|
+
if (splitFilePath.length > 1) {
|
|
212
|
+
directories.add(splitFilePath[0]);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
await Promise.all(
|
|
216
|
+
Array.from(directories).map(async (filename) => {
|
|
217
|
+
const url = new URL(filename, out);
|
|
218
|
+
const folder = await fs.promises.readdir(url);
|
|
219
|
+
if (!folder.length) {
|
|
220
|
+
await fs.promises.rmdir(url, { recursive: true });
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
);
|
|
224
|
+
}
|
|
197
225
|
if (out.toString() !== opts.settings.config.outDir.toString()) {
|
|
226
|
+
copyFiles(out, opts.settings.config.outDir);
|
|
198
227
|
await fs.promises.rm(out, { recursive: true });
|
|
199
228
|
return;
|
|
200
229
|
}
|
|
201
|
-
const files = await glob("**/*.mjs", {
|
|
202
|
-
cwd: fileURLToPath(out)
|
|
203
|
-
});
|
|
204
|
-
await Promise.all(
|
|
205
|
-
files.map(async (filename) => {
|
|
206
|
-
const url = new URL(filename, out);
|
|
207
|
-
await fs.promises.rm(url);
|
|
208
|
-
})
|
|
209
|
-
);
|
|
210
230
|
}
|
|
211
231
|
async function copyFiles(fromFolder, toFolder) {
|
|
212
232
|
const files = await glob("**/*", {
|
|
@@ -85,11 +85,11 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
85
85
|
wrap: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodNull]>>;
|
|
86
86
|
}, "strip", z.ZodTypeAny, {
|
|
87
87
|
langs: ILanguageRegistration[];
|
|
88
|
-
theme:
|
|
88
|
+
theme: string | import("shiki").IShikiTheme;
|
|
89
89
|
wrap: boolean | null;
|
|
90
90
|
}, {
|
|
91
91
|
langs?: ILanguageRegistration[] | undefined;
|
|
92
|
-
theme?:
|
|
92
|
+
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
93
93
|
wrap?: boolean | null | undefined;
|
|
94
94
|
}>>;
|
|
95
95
|
remarkPlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RemarkPlugin<any[]>, z.ZodTypeDef, RemarkPlugin<any[]>>, z.ZodTuple<[z.ZodType<RemarkPlugin<any[]>, z.ZodTypeDef, RemarkPlugin<any[]>>, z.ZodAny], null>]>, "many">>;
|
|
@@ -101,7 +101,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
101
101
|
syntaxHighlight: false | "shiki" | "prism";
|
|
102
102
|
shikiConfig: {
|
|
103
103
|
langs: ILanguageRegistration[];
|
|
104
|
-
theme:
|
|
104
|
+
theme: string | import("shiki").IShikiTheme;
|
|
105
105
|
wrap: boolean | null;
|
|
106
106
|
};
|
|
107
107
|
remarkPlugins: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[];
|
|
@@ -113,7 +113,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
113
113
|
syntaxHighlight?: false | "shiki" | "prism" | undefined;
|
|
114
114
|
shikiConfig?: {
|
|
115
115
|
langs?: ILanguageRegistration[] | undefined;
|
|
116
|
-
theme?:
|
|
116
|
+
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
117
117
|
wrap?: boolean | null | undefined;
|
|
118
118
|
} | undefined;
|
|
119
119
|
remarkPlugins?: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[] | undefined;
|
|
@@ -141,7 +141,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
141
141
|
syntaxHighlight: false | "shiki" | "prism";
|
|
142
142
|
shikiConfig: {
|
|
143
143
|
langs: ILanguageRegistration[];
|
|
144
|
-
theme:
|
|
144
|
+
theme: string | import("shiki").IShikiTheme;
|
|
145
145
|
wrap: boolean | null;
|
|
146
146
|
};
|
|
147
147
|
remarkPlugins: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[];
|
|
@@ -184,7 +184,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
184
184
|
syntaxHighlight?: false | "shiki" | "prism" | undefined;
|
|
185
185
|
shikiConfig?: {
|
|
186
186
|
langs?: ILanguageRegistration[] | undefined;
|
|
187
|
-
theme?:
|
|
187
|
+
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
188
188
|
wrap?: boolean | null | undefined;
|
|
189
189
|
} | undefined;
|
|
190
190
|
remarkPlugins?: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[] | undefined;
|
|
@@ -301,11 +301,11 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
301
301
|
wrap: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodNull]>>;
|
|
302
302
|
}, "strip", z.ZodTypeAny, {
|
|
303
303
|
langs: ILanguageRegistration[];
|
|
304
|
-
theme:
|
|
304
|
+
theme: string | import("shiki").IShikiTheme;
|
|
305
305
|
wrap: boolean | null;
|
|
306
306
|
}, {
|
|
307
307
|
langs?: ILanguageRegistration[] | undefined;
|
|
308
|
-
theme?:
|
|
308
|
+
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
309
309
|
wrap?: boolean | null | undefined;
|
|
310
310
|
}>>;
|
|
311
311
|
remarkPlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RemarkPlugin<any[]>, z.ZodTypeDef, RemarkPlugin<any[]>>, z.ZodTuple<[z.ZodType<RemarkPlugin<any[]>, z.ZodTypeDef, RemarkPlugin<any[]>>, z.ZodAny], null>]>, "many">>;
|
|
@@ -317,7 +317,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
317
317
|
syntaxHighlight: false | "shiki" | "prism";
|
|
318
318
|
shikiConfig: {
|
|
319
319
|
langs: ILanguageRegistration[];
|
|
320
|
-
theme:
|
|
320
|
+
theme: string | import("shiki").IShikiTheme;
|
|
321
321
|
wrap: boolean | null;
|
|
322
322
|
};
|
|
323
323
|
remarkPlugins: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[];
|
|
@@ -329,7 +329,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
329
329
|
syntaxHighlight?: false | "shiki" | "prism" | undefined;
|
|
330
330
|
shikiConfig?: {
|
|
331
331
|
langs?: ILanguageRegistration[] | undefined;
|
|
332
|
-
theme?:
|
|
332
|
+
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
333
333
|
wrap?: boolean | null | undefined;
|
|
334
334
|
} | undefined;
|
|
335
335
|
remarkPlugins?: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[] | undefined;
|
|
@@ -401,7 +401,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
401
401
|
syntaxHighlight: false | "shiki" | "prism";
|
|
402
402
|
shikiConfig: {
|
|
403
403
|
langs: ILanguageRegistration[];
|
|
404
|
-
theme:
|
|
404
|
+
theme: string | import("shiki").IShikiTheme;
|
|
405
405
|
wrap: boolean | null;
|
|
406
406
|
};
|
|
407
407
|
remarkPlugins: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[];
|
|
@@ -445,7 +445,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
445
445
|
syntaxHighlight?: false | "shiki" | "prism" | undefined;
|
|
446
446
|
shikiConfig?: {
|
|
447
447
|
langs?: ILanguageRegistration[] | undefined;
|
|
448
|
-
theme?:
|
|
448
|
+
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
449
449
|
wrap?: boolean | null | undefined;
|
|
450
450
|
} | undefined;
|
|
451
451
|
remarkPlugins?: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[] | undefined;
|
package/dist/core/dev/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { info, warn } from "../logger/core.js";
|
|
|
12
12
|
import * as msg from "../messages.js";
|
|
13
13
|
import { apply as applyPolyfill } from "../polyfill.js";
|
|
14
14
|
async function dev(settings, options) {
|
|
15
|
-
var _a, _b
|
|
15
|
+
var _a, _b;
|
|
16
16
|
const devStart = performance.now();
|
|
17
17
|
applyPolyfill();
|
|
18
18
|
await options.telemetry.record([]);
|
|
@@ -34,27 +34,26 @@ async function dev(settings, options) {
|
|
|
34
34
|
const viteServer = await vite.createServer(viteConfig);
|
|
35
35
|
runHookServerSetup({ config: settings.config, server: viteServer, logging: options.logging });
|
|
36
36
|
await viteServer.listen(port);
|
|
37
|
-
const devServerAddressInfo = viteServer.httpServer.address();
|
|
38
37
|
const site = settings.config.site ? new URL(settings.config.base, settings.config.site) : void 0;
|
|
39
38
|
info(
|
|
40
39
|
options.logging,
|
|
41
40
|
null,
|
|
42
|
-
msg.
|
|
41
|
+
msg.serverStart({
|
|
43
42
|
startupTime: performance.now() - devStart,
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
resolvedUrls: viteServer.resolvedUrls || { local: [], network: [] },
|
|
44
|
+
host: settings.config.server.host,
|
|
46
45
|
site,
|
|
47
|
-
https: !!((_a = viteConfig.server) == null ? void 0 : _a.https),
|
|
48
46
|
isRestart
|
|
49
47
|
})
|
|
50
48
|
);
|
|
51
|
-
const currentVersion = "1.
|
|
49
|
+
const currentVersion = "1.3.1";
|
|
52
50
|
if (currentVersion.includes("-")) {
|
|
53
51
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
54
52
|
}
|
|
55
|
-
if (((
|
|
53
|
+
if (((_b = (_a = viteConfig.server) == null ? void 0 : _a.fs) == null ? void 0 : _b.strict) === false) {
|
|
56
54
|
warn(options.logging, null, msg.fsStrictWarning());
|
|
57
55
|
}
|
|
56
|
+
const devServerAddressInfo = viteServer.httpServer.address();
|
|
58
57
|
await runHookServerStart({
|
|
59
58
|
config: settings.config,
|
|
60
59
|
address: devServerAddressInfo,
|
|
@@ -8,7 +8,7 @@ async function call(mod, opts) {
|
|
|
8
8
|
);
|
|
9
9
|
}
|
|
10
10
|
const [params] = paramsAndPropsResp;
|
|
11
|
-
const response = await renderEndpoint(mod, opts.request, params);
|
|
11
|
+
const response = await renderEndpoint(mod, opts.request, params, opts.ssr);
|
|
12
12
|
if (response instanceof Response) {
|
|
13
13
|
return {
|
|
14
14
|
type: "response",
|
package/dist/core/messages.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { AddressInfo } from 'net';
|
|
3
|
+
import { ResolvedServerUrls } from 'vite';
|
|
3
4
|
import { ZodError } from 'zod';
|
|
4
|
-
import type { AstroConfig } from '../@types/astro';
|
|
5
5
|
import { ErrorWithMetadata } from './errors.js';
|
|
6
6
|
/** Display */
|
|
7
7
|
export declare function req({ url, statusCode, reqTime, }: {
|
|
@@ -16,15 +16,19 @@ export declare function hmr({ file, style }: {
|
|
|
16
16
|
file: string;
|
|
17
17
|
style?: boolean;
|
|
18
18
|
}): string;
|
|
19
|
-
/** Display
|
|
20
|
-
export declare function
|
|
19
|
+
/** Display server host and startup time */
|
|
20
|
+
export declare function serverStart({ startupTime, resolvedUrls, host, site, isRestart, }: {
|
|
21
21
|
startupTime: number;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
https: boolean;
|
|
22
|
+
resolvedUrls: ResolvedServerUrls;
|
|
23
|
+
host: string | boolean;
|
|
25
24
|
site: URL | undefined;
|
|
26
25
|
isRestart?: boolean;
|
|
27
26
|
}): string;
|
|
27
|
+
export declare function resolveServerUrls({ address, host, https, }: {
|
|
28
|
+
address: AddressInfo;
|
|
29
|
+
host: string | boolean;
|
|
30
|
+
https: boolean;
|
|
31
|
+
}): ResolvedServerUrls;
|
|
28
32
|
export declare function telemetryNotice(): string;
|
|
29
33
|
export declare function telemetryEnabled(): string;
|
|
30
34
|
export declare function telemetryDisabled(): string;
|
package/dist/core/messages.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
yellow
|
|
16
16
|
} from "kleur/colors";
|
|
17
17
|
import os from "os";
|
|
18
|
+
import { removeTrailingForwardSlash } from "./path.js";
|
|
18
19
|
import { emoji, getLocalAddress, padMultilineString } from "./util.js";
|
|
19
20
|
const PREFIX_PADDING = 6;
|
|
20
21
|
function req({
|
|
@@ -39,41 +40,34 @@ function reload({ file }) {
|
|
|
39
40
|
function hmr({ file, style = false }) {
|
|
40
41
|
return `${green("update".padStart(PREFIX_PADDING))} ${file}${style ? ` ${dim("style")}` : ""}`;
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function serverStart({
|
|
43
44
|
startupTime,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
https,
|
|
45
|
+
resolvedUrls,
|
|
46
|
+
host,
|
|
47
47
|
site,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "1.
|
|
50
|
+
const version = "1.3.1";
|
|
51
51
|
const rootPath = site ? site.pathname : "/";
|
|
52
52
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
53
53
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} else {
|
|
72
|
-
network = `${networkPrefix}${bold(cyan(toDisplayUrl(address)))}`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (!network) {
|
|
76
|
-
network = `${networkPrefix}${dim("unable to find network to expose")}`;
|
|
54
|
+
const emptyPrefix = " ".repeat(11);
|
|
55
|
+
const localUrlMessages = resolvedUrls.local.map((url, i) => {
|
|
56
|
+
return `${i === 0 ? localPrefix : emptyPrefix}${bold(
|
|
57
|
+
cyan(removeTrailingForwardSlash(url) + rootPath)
|
|
58
|
+
)}`;
|
|
59
|
+
});
|
|
60
|
+
const networkUrlMessages = resolvedUrls.network.map((url, i) => {
|
|
61
|
+
return `${i === 0 ? networkPrefix : emptyPrefix}${bold(
|
|
62
|
+
cyan(removeTrailingForwardSlash(url) + rootPath)
|
|
63
|
+
)}`;
|
|
64
|
+
});
|
|
65
|
+
if (networkUrlMessages.length === 0) {
|
|
66
|
+
const networkLogging = getNetworkLogging(host);
|
|
67
|
+
if (networkLogging === "host-to-expose") {
|
|
68
|
+
networkUrlMessages.push(`${networkPrefix}${dim("use --host to expose")}`);
|
|
69
|
+
} else if (networkLogging === "visible") {
|
|
70
|
+
networkUrlMessages.push(`${networkPrefix}${dim("unable to find network to expose")}`);
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
73
|
const messages = [
|
|
@@ -81,12 +75,42 @@ function devStart({
|
|
|
81
75
|
`${isRestart ? "re" : ""}started in ${Math.round(startupTime)}ms`
|
|
82
76
|
)}`,
|
|
83
77
|
"",
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
...localUrlMessages,
|
|
79
|
+
...networkUrlMessages,
|
|
86
80
|
""
|
|
87
81
|
];
|
|
88
82
|
return messages.filter((msg) => typeof msg === "string").map((msg) => ` ${msg}`).join("\n");
|
|
89
83
|
}
|
|
84
|
+
function resolveServerUrls({
|
|
85
|
+
address,
|
|
86
|
+
host,
|
|
87
|
+
https
|
|
88
|
+
}) {
|
|
89
|
+
const { address: networkAddress, port } = address;
|
|
90
|
+
const localAddress = getLocalAddress(networkAddress, host);
|
|
91
|
+
const networkLogging = getNetworkLogging(host);
|
|
92
|
+
const toDisplayUrl = (hostname) => `${https ? "https" : "http"}://${hostname}:${port}`;
|
|
93
|
+
let local = toDisplayUrl(localAddress);
|
|
94
|
+
let network = null;
|
|
95
|
+
if (networkLogging === "visible") {
|
|
96
|
+
const nodeVersion = Number(process.version.substring(1, process.version.indexOf(".", 5)));
|
|
97
|
+
const ipv4Networks = Object.values(os.networkInterfaces()).flatMap((networkInterface) => networkInterface ?? []).filter(
|
|
98
|
+
(networkInterface) => (networkInterface == null ? void 0 : networkInterface.address) && (networkInterface == null ? void 0 : networkInterface.family) === (nodeVersion < 18 || nodeVersion >= 18.4 ? "IPv4" : 4)
|
|
99
|
+
);
|
|
100
|
+
for (let { address: ipv4Address } of ipv4Networks) {
|
|
101
|
+
if (ipv4Address.includes("127.0.0.1")) {
|
|
102
|
+
const displayAddress = ipv4Address.replace("127.0.0.1", localAddress);
|
|
103
|
+
local = toDisplayUrl(displayAddress);
|
|
104
|
+
} else {
|
|
105
|
+
network = toDisplayUrl(ipv4Address);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
local: [local],
|
|
111
|
+
network: network ? [network] : []
|
|
112
|
+
};
|
|
113
|
+
}
|
|
90
114
|
function telemetryNotice() {
|
|
91
115
|
const headline = yellow(`Astro now collects ${bold("anonymous")} usage data.`);
|
|
92
116
|
const why = `This ${bold("optional program")} will help shape our roadmap.`;
|
|
@@ -226,7 +250,7 @@ function printHelp({
|
|
|
226
250
|
message.push(
|
|
227
251
|
linebreak(),
|
|
228
252
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
229
|
-
`v${"1.
|
|
253
|
+
`v${"1.3.1"}`
|
|
230
254
|
)} ${headline}`
|
|
231
255
|
);
|
|
232
256
|
}
|
|
@@ -251,7 +275,6 @@ function printHelp({
|
|
|
251
275
|
}
|
|
252
276
|
export {
|
|
253
277
|
cancelled,
|
|
254
|
-
devStart,
|
|
255
278
|
failure,
|
|
256
279
|
formatConfigErrorMessage,
|
|
257
280
|
formatErrorMessage,
|
|
@@ -263,6 +286,8 @@ export {
|
|
|
263
286
|
printHelp,
|
|
264
287
|
reload,
|
|
265
288
|
req,
|
|
289
|
+
resolveServerUrls,
|
|
290
|
+
serverStart,
|
|
266
291
|
success,
|
|
267
292
|
telemetryDisabled,
|
|
268
293
|
telemetryEnabled,
|
package/dist/core/path.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function appendExtension(path: string, extension: string): string;
|
|
1
2
|
export declare function appendForwardSlash(path: string): string;
|
|
2
3
|
export declare function prependForwardSlash(path: string): string;
|
|
3
4
|
export declare function removeTrailingForwardSlash(path: string): string;
|
package/dist/core/path.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
function appendExtension(path, extension) {
|
|
2
|
+
return path + "." + extension;
|
|
3
|
+
}
|
|
1
4
|
function appendForwardSlash(path) {
|
|
2
5
|
return path.endsWith("/") ? path : path + "/";
|
|
3
6
|
}
|
|
@@ -41,6 +44,7 @@ function removeFileExtension(path) {
|
|
|
41
44
|
return idx === -1 ? path : path.slice(0, idx);
|
|
42
45
|
}
|
|
43
46
|
export {
|
|
47
|
+
appendExtension,
|
|
44
48
|
appendForwardSlash,
|
|
45
49
|
isRelativePath,
|
|
46
50
|
joinPaths,
|
|
@@ -73,15 +73,18 @@ async function preview(settings, { logging }) {
|
|
|
73
73
|
const listen = () => {
|
|
74
74
|
httpServer = server.listen(port, host, async () => {
|
|
75
75
|
if (!showedListenMsg) {
|
|
76
|
-
const
|
|
76
|
+
const resolvedUrls = msg.resolveServerUrls({
|
|
77
|
+
address: server.address(),
|
|
78
|
+
host: settings.config.server.host,
|
|
79
|
+
https: false
|
|
80
|
+
});
|
|
77
81
|
info(
|
|
78
82
|
logging,
|
|
79
83
|
null,
|
|
80
|
-
msg.
|
|
84
|
+
msg.serverStart({
|
|
81
85
|
startupTime: performance.now() - timerStart,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
https: false,
|
|
86
|
+
resolvedUrls,
|
|
87
|
+
host: settings.config.server.host,
|
|
85
88
|
site: baseURL
|
|
86
89
|
})
|
|
87
90
|
);
|
|
@@ -62,14 +62,11 @@ class RouteCache {
|
|
|
62
62
|
}
|
|
63
63
|
function findPathItemByKey(staticPaths, params) {
|
|
64
64
|
const paramsKey = stringifyParams(params);
|
|
65
|
-
|
|
65
|
+
const matchedStaticPath = staticPaths.keyed.get(paramsKey);
|
|
66
66
|
if (matchedStaticPath) {
|
|
67
67
|
return matchedStaticPath;
|
|
68
68
|
}
|
|
69
69
|
debug("findPathItemByKey", `Unexpected cache miss looking for ${paramsKey}`);
|
|
70
|
-
matchedStaticPath = staticPaths.find(
|
|
71
|
-
({ params: _params }) => JSON.stringify(_params) === paramsKey
|
|
72
|
-
);
|
|
73
70
|
}
|
|
74
71
|
export {
|
|
75
72
|
RouteCache,
|
|
@@ -17,7 +17,7 @@ function stringifyParams(params) {
|
|
|
17
17
|
const validatedParams = Object.entries(params).reduce((acc, next) => {
|
|
18
18
|
validateGetStaticPathsParameter(next);
|
|
19
19
|
const [key, value] = next;
|
|
20
|
-
acc[key] = `${value}`;
|
|
20
|
+
acc[key] = typeof value === "undefined" ? void 0 : `${value}`;
|
|
21
21
|
return acc;
|
|
22
22
|
}, {});
|
|
23
23
|
return JSON.stringify(validatedParams, Object.keys(params).sort());
|
package/dist/core/util.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export declare const AggregateError: AggregateErrorConstructor | {
|
|
|
53
53
|
name: string;
|
|
54
54
|
message: string;
|
|
55
55
|
stack?: string | undefined;
|
|
56
|
-
cause?:
|
|
56
|
+
cause?: unknown;
|
|
57
57
|
};
|
|
58
58
|
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
59
59
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
package/dist/core/util.js
CHANGED
|
@@ -5,7 +5,7 @@ import resolve from "resolve";
|
|
|
5
5
|
import slash from "slash";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
7
7
|
import { prependForwardSlash, removeTrailingForwardSlash } from "./path.js";
|
|
8
|
-
const ASTRO_VERSION = "1.
|
|
8
|
+
const ASTRO_VERSION = "1.3.1";
|
|
9
9
|
function isObject(value) {
|
|
10
10
|
return typeof value === "object" && value != null;
|
|
11
11
|
}
|
|
@@ -87,7 +87,7 @@ function resolveDependency(dep, projectRoot) {
|
|
|
87
87
|
return pathToFileURL(resolved).toString();
|
|
88
88
|
}
|
|
89
89
|
function viteID(filePath) {
|
|
90
|
-
return slash(fileURLToPath(filePath) + filePath.search);
|
|
90
|
+
return slash(fileURLToPath(filePath) + filePath.search).replace(/\\/g, "/");
|
|
91
91
|
}
|
|
92
92
|
const VALID_ID_PREFIX = `/@id/`;
|
|
93
93
|
function unwrapId(id) {
|
|
@@ -46,6 +46,11 @@ export declare function runHookBuildSsr({ config, manifest, logging, }: {
|
|
|
46
46
|
manifest: SerializedSSRManifest;
|
|
47
47
|
logging: LogOptions;
|
|
48
48
|
}): Promise<void>;
|
|
49
|
+
export declare function runHookBuildGenerated({ config, buildConfig, logging, }: {
|
|
50
|
+
config: AstroConfig;
|
|
51
|
+
buildConfig: BuildConfig;
|
|
52
|
+
logging: LogOptions;
|
|
53
|
+
}): Promise<void>;
|
|
49
54
|
export declare function runHookBuildDone({ config, buildConfig, pages, routes, logging, }: {
|
|
50
55
|
config: AstroConfig;
|
|
51
56
|
buildConfig: BuildConfig;
|