astro 2.7.1 → 2.7.3
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 +5 -4
- package/dist/cli/index.js +3 -5
- package/dist/cli/telemetry.d.ts +1 -3
- package/dist/cli/telemetry.js +2 -1
- package/dist/core/add/index.d.ts +1 -3
- package/dist/core/add/index.js +8 -4
- package/dist/core/app/index.js +10 -2
- package/dist/core/app/types.d.ts +1 -0
- package/dist/core/build/generate.js +19 -1
- package/dist/core/build/index.d.ts +0 -2
- package/dist/core/build/internal.js +6 -2
- package/dist/core/build/plugins/plugin-ssr.js +1 -0
- package/dist/core/compile/style.js +3 -4
- package/dist/core/config/settings.js +0 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/container.d.ts +0 -1
- package/dist/core/dev/container.js +2 -6
- package/dist/core/dev/dev.d.ts +0 -2
- package/dist/core/dev/dev.js +3 -2
- package/dist/core/endpoint/dev/index.js +3 -7
- package/dist/core/messages.js +2 -2
- package/dist/core/preview/index.d.ts +0 -2
- package/dist/core/render/dev/environment.js +1 -2
- package/dist/core/render/dev/index.d.ts +7 -7
- package/dist/core/render/dev/index.js +6 -13
- package/dist/core/render/environment.d.ts +0 -1
- package/dist/core/render/environment.js +1 -2
- package/dist/core/render/index.d.ts +1 -1
- package/dist/core/render/index.js +2 -1
- package/dist/core/render/renderer.d.ts +4 -9
- package/dist/core/render/renderer.js +12 -17
- package/dist/core/render/result.js +0 -8
- package/dist/prerender/routing.d.ts +3 -3
- package/dist/prerender/routing.js +2 -5
- package/dist/runtime/server/astro-island.js +10 -9
- 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/render/util.js +11 -4
- package/dist/runtime/server/serialize.js +2 -0
- package/dist/vite-plugin-astro-postprocess/index.js +1 -1
- package/dist/vite-plugin-astro-server/request.js +5 -3
- package/dist/vite-plugin-astro-server/route.d.ts +2 -2
- package/dist/vite-plugin-astro-server/route.js +3 -13
- package/dist/vite-plugin-env/index.js +1 -1
- package/dist/vite-plugin-scripts/page-ssr.js +1 -1
- package/package.json +2 -2
- package/dist/core/render/script.d.ts +0 -2
- package/dist/core/render/script.js +0 -9
- package/dist/runtime/client/events.d.ts +0 -1
- package/dist/runtime/client/events.js +0 -21
- package/dist/runtime/client/hydration-directives.d.js +0 -0
package/dist/@types/astro.d.ts
CHANGED
|
@@ -488,9 +488,11 @@ export interface AstroUserConfig {
|
|
|
488
488
|
*
|
|
489
489
|
* When using this option, all of your static asset imports and URLs should add the base as a prefix. You can access this value via `import.meta.env.BASE_URL`.
|
|
490
490
|
*
|
|
491
|
+
* By default, the value of `import.meta.env.BASE_URL` includes a trailing slash. If you have the [`trailingSlash`](https://docs.astro.build/en/reference/configuration-reference/#trailingslash) option set to `'never'`, you will need to add it manually in your static asset imports and URLs.
|
|
492
|
+
*
|
|
491
493
|
* ```astro
|
|
492
494
|
* <a href="/docs/about/">About</a>
|
|
493
|
-
* <img src=`${import.meta.env.BASE_URL}
|
|
495
|
+
* <img src=`${import.meta.env.BASE_URL}image.png`>
|
|
494
496
|
* ```
|
|
495
497
|
*/
|
|
496
498
|
base?: string;
|
|
@@ -1267,7 +1269,6 @@ export interface AstroSettings {
|
|
|
1267
1269
|
tsConfig: TsConfigJson | undefined;
|
|
1268
1270
|
tsConfigPath: string | undefined;
|
|
1269
1271
|
watchFiles: string[];
|
|
1270
|
-
forceDisableTelemetry: boolean;
|
|
1271
1272
|
timer: AstroTimer;
|
|
1272
1273
|
}
|
|
1273
1274
|
export type AsyncRendererComponentFn<U> = (Component: any, props: any, slots: Record<string, string>, metadata?: AstroComponentMetadata) => Promise<U>;
|
|
@@ -1598,15 +1599,15 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
1598
1599
|
*/
|
|
1599
1600
|
locals: App.Locals;
|
|
1600
1601
|
}
|
|
1601
|
-
export type Props = Record<string, unknown>;
|
|
1602
1602
|
export interface EndpointOutput {
|
|
1603
1603
|
body: Body;
|
|
1604
1604
|
encoding?: BufferEncoding;
|
|
1605
1605
|
}
|
|
1606
|
-
export type APIRoute = (context: APIContext) => EndpointOutput | Response | Promise<EndpointOutput | Response>;
|
|
1606
|
+
export type APIRoute<Props extends Record<string, any> = Record<string, any>> = (context: APIContext<Props>) => EndpointOutput | Response | Promise<EndpointOutput | Response>;
|
|
1607
1607
|
export interface EndpointHandler {
|
|
1608
1608
|
[method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response);
|
|
1609
1609
|
}
|
|
1610
|
+
export type Props = Record<string, unknown>;
|
|
1610
1611
|
export interface AstroRenderer {
|
|
1611
1612
|
/** Name of the renderer. */
|
|
1612
1613
|
name: string;
|
package/dist/cli/index.js
CHANGED
|
@@ -109,7 +109,7 @@ async function runCommand(cmd, flags) {
|
|
|
109
109
|
const { default: add } = await import("../core/add/index.js");
|
|
110
110
|
telemetry.record(event.eventCliSession(cmd));
|
|
111
111
|
const packages = flags._.slice(3);
|
|
112
|
-
return await add(packages, { cwd: root, flags, logging
|
|
112
|
+
return await add(packages, { cwd: root, flags, logging });
|
|
113
113
|
}
|
|
114
114
|
case "docs": {
|
|
115
115
|
telemetry.record(event.eventCliSession(cmd));
|
|
@@ -128,7 +128,7 @@ async function runCommand(cmd, flags) {
|
|
|
128
128
|
case "telemetry": {
|
|
129
129
|
const telemetryHandler = await import("./telemetry.js");
|
|
130
130
|
const subcommand = (_a = flags._[3]) == null ? void 0 : _a.toString();
|
|
131
|
-
return await telemetryHandler.update(subcommand, { flags
|
|
131
|
+
return await telemetryHandler.update(subcommand, { flags });
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
if (!process.env.NODE_ENV) {
|
|
@@ -157,7 +157,6 @@ async function runCommand(cmd, flags) {
|
|
|
157
157
|
configFlagPath,
|
|
158
158
|
flags,
|
|
159
159
|
logging,
|
|
160
|
-
telemetry,
|
|
161
160
|
handleConfigError(e) {
|
|
162
161
|
handleConfigError(e, { cmd, cwd: root, flags, logging });
|
|
163
162
|
info(logging, "astro", "Continuing with previous valid configuration\n");
|
|
@@ -171,7 +170,6 @@ async function runCommand(cmd, flags) {
|
|
|
171
170
|
return await build(settings, {
|
|
172
171
|
flags,
|
|
173
172
|
logging,
|
|
174
|
-
telemetry,
|
|
175
173
|
teardownCompiler: true,
|
|
176
174
|
mode: flags.mode
|
|
177
175
|
});
|
|
@@ -197,7 +195,7 @@ async function runCommand(cmd, flags) {
|
|
|
197
195
|
}
|
|
198
196
|
case "preview": {
|
|
199
197
|
const { default: preview } = await import("../core/preview/index.js");
|
|
200
|
-
const server = await preview(settings, { logging,
|
|
198
|
+
const server = await preview(settings, { logging, flags });
|
|
201
199
|
if (server) {
|
|
202
200
|
return await server.closed();
|
|
203
201
|
}
|
package/dist/cli/telemetry.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { AstroTelemetry } from '@astrojs/telemetry';
|
|
2
1
|
import type yargs from 'yargs-parser';
|
|
3
2
|
export interface TelemetryOptions {
|
|
4
3
|
flags: yargs.Arguments;
|
|
5
|
-
telemetry: AstroTelemetry;
|
|
6
4
|
}
|
|
7
|
-
export declare function update(subcommand: string, { flags
|
|
5
|
+
export declare function update(subcommand: string, { flags }: TelemetryOptions): Promise<void>;
|
package/dist/cli/telemetry.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as msg from "../core/messages.js";
|
|
2
|
-
|
|
2
|
+
import { telemetry } from "../events/index.js";
|
|
3
|
+
async function update(subcommand, { flags }) {
|
|
3
4
|
const isValid = ["enable", "disable", "reset"].includes(subcommand);
|
|
4
5
|
if (flags.help || flags.h || !isValid) {
|
|
5
6
|
msg.printHelp({
|
package/dist/core/add/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { AstroTelemetry } from '@astrojs/telemetry';
|
|
2
1
|
import type yargs from 'yargs-parser';
|
|
3
2
|
import { type LogOptions } from '../logger/core.js';
|
|
4
3
|
export interface AddOptions {
|
|
5
4
|
logging: LogOptions;
|
|
6
5
|
flags: yargs.Arguments;
|
|
7
|
-
telemetry: AstroTelemetry;
|
|
8
6
|
cwd?: string;
|
|
9
7
|
}
|
|
10
8
|
export interface IntegrationInfo {
|
|
@@ -13,5 +11,5 @@ export interface IntegrationInfo {
|
|
|
13
11
|
dependencies: [name: string, version: string][];
|
|
14
12
|
type: 'integration' | 'adapter';
|
|
15
13
|
}
|
|
16
|
-
export default function add(names: string[], { cwd, flags, logging
|
|
14
|
+
export default function add(names: string[], { cwd, flags, logging }: AddOptions): Promise<void>;
|
|
17
15
|
export declare function validateIntegrations(integrations: string[]): Promise<IntegrationInfo[]>;
|
package/dist/core/add/index.js
CHANGED
|
@@ -56,12 +56,16 @@ const OFFICIAL_ADAPTER_TO_IMPORT_MAP = {
|
|
|
56
56
|
deno: "@astrojs/deno"
|
|
57
57
|
};
|
|
58
58
|
async function getRegistry() {
|
|
59
|
-
var _a;
|
|
59
|
+
var _a, _b;
|
|
60
60
|
const packageManager = ((_a = await preferredPM(process.cwd())) == null ? void 0 : _a.name) || "npm";
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
try {
|
|
62
|
+
const { stdout } = await execa(packageManager, ["config", "get", "registry"]);
|
|
63
|
+
return ((_b = stdout == null ? void 0 : stdout.trim()) == null ? void 0 : _b.replace(/\/$/, "")) || "https://registry.npmjs.org";
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return "https://registry.npmjs.org";
|
|
66
|
+
}
|
|
63
67
|
}
|
|
64
|
-
async function add(names, { cwd, flags, logging
|
|
68
|
+
async function add(names, { cwd, flags, logging }) {
|
|
65
69
|
var _a;
|
|
66
70
|
applyPolyfill();
|
|
67
71
|
if (flags.help || names.length === 0) {
|
package/dist/core/app/index.js
CHANGED
|
@@ -170,6 +170,7 @@ class App {
|
|
|
170
170
|
const url = new URL(request.url);
|
|
171
171
|
const pathname = prependForwardSlash(this.removeBase(url.pathname));
|
|
172
172
|
const info = this.#routeDataToRouteInfo.get(routeData);
|
|
173
|
+
const isCompressHTML = this.#manifest.compressHTML ?? false;
|
|
173
174
|
const links = /* @__PURE__ */ new Set();
|
|
174
175
|
const styles = createStylesheetElementSet(info.styles);
|
|
175
176
|
let scripts = /* @__PURE__ */ new Set();
|
|
@@ -214,7 +215,13 @@ class App {
|
|
|
214
215
|
page.onRequest,
|
|
215
216
|
apiContext,
|
|
216
217
|
() => {
|
|
217
|
-
return renderPage({
|
|
218
|
+
return renderPage({
|
|
219
|
+
mod,
|
|
220
|
+
renderContext,
|
|
221
|
+
env: this.#env,
|
|
222
|
+
cookies: apiContext.cookies,
|
|
223
|
+
isCompressHTML
|
|
224
|
+
});
|
|
218
225
|
}
|
|
219
226
|
);
|
|
220
227
|
} else {
|
|
@@ -222,7 +229,8 @@ class App {
|
|
|
222
229
|
mod,
|
|
223
230
|
renderContext,
|
|
224
231
|
env: this.#env,
|
|
225
|
-
cookies: apiContext.cookies
|
|
232
|
+
cookies: apiContext.cookies,
|
|
233
|
+
isCompressHTML
|
|
226
234
|
});
|
|
227
235
|
}
|
|
228
236
|
Reflect.set(request, responseSentSymbol, true);
|
package/dist/core/app/types.d.ts
CHANGED
|
@@ -103,7 +103,25 @@ ${bgGreen(black(` ${verb} static routes `))}`);
|
|
|
103
103
|
if (pageData.route.prerender) {
|
|
104
104
|
const ssrEntryURLPage = createEntryURL(filePath, outFolder);
|
|
105
105
|
const ssrEntryPage = await import(ssrEntryURLPage.toString());
|
|
106
|
-
|
|
106
|
+
if (opts.settings.config.build.split) {
|
|
107
|
+
const manifest = ssrEntryPage.manifest;
|
|
108
|
+
const ssrEntry = manifest == null ? void 0 : manifest.pageModule;
|
|
109
|
+
if (ssrEntry) {
|
|
110
|
+
await generatePage(opts, internals, pageData, ssrEntry, builtPaths);
|
|
111
|
+
} else {
|
|
112
|
+
throw new Error(
|
|
113
|
+
`Unable to find the manifest for the module ${ssrEntryURLPage.toString()}. This is unexpected and likely a bug in Astro, please report.`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
await generatePage(
|
|
118
|
+
opts,
|
|
119
|
+
internals,
|
|
120
|
+
pageData,
|
|
121
|
+
ssrEntryPage,
|
|
122
|
+
builtPaths
|
|
123
|
+
);
|
|
124
|
+
}
|
|
107
125
|
}
|
|
108
126
|
}
|
|
109
127
|
for (const pageData of eachRedirectPageData(internals)) {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { AstroTelemetry } from '@astrojs/telemetry';
|
|
2
1
|
import type { AstroSettings, RuntimeMode } from '../../@types/astro';
|
|
3
2
|
import type yargs from 'yargs-parser';
|
|
4
3
|
import { type LogOptions } from '../logger/core.js';
|
|
5
4
|
export interface BuildOptions {
|
|
6
5
|
mode?: RuntimeMode;
|
|
7
6
|
logging: LogOptions;
|
|
8
|
-
telemetry: AstroTelemetry;
|
|
9
7
|
/**
|
|
10
8
|
* Teardown the compiler WASM instance after build. This can improve performance when
|
|
11
9
|
* building once, but may cause a performance hit if building multiple times in a row.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { prependForwardSlash, removeFileExtension } from "../path.js";
|
|
2
2
|
import { viteID } from "../util.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ASTRO_PAGE_RESOLVED_MODULE_ID,
|
|
5
|
+
getVirtualModulePageIdFromPath
|
|
6
|
+
} from "./plugins/plugin-pages.js";
|
|
7
|
+
import { RESOLVED_SPLIT_MODULE_ID } from "./plugins/plugin-ssr.js";
|
|
4
8
|
import { ASTRO_PAGE_EXTENSION_POST_PATTERN } from "./plugins/util.js";
|
|
5
9
|
function createBuildInternals() {
|
|
6
10
|
const hoistedScriptIdToHoistedMap = /* @__PURE__ */ new Map();
|
|
@@ -95,7 +99,7 @@ function* eachRedirectPageData(internals) {
|
|
|
95
99
|
}
|
|
96
100
|
function* eachPageDataFromEntryPoint(internals) {
|
|
97
101
|
for (const [entryPoint, filePath] of internals.entrySpecifierToBundleMap) {
|
|
98
|
-
if (entryPoint.includes(
|
|
102
|
+
if (entryPoint.includes(ASTRO_PAGE_RESOLVED_MODULE_ID) || entryPoint.includes(RESOLVED_SPLIT_MODULE_ID)) {
|
|
99
103
|
const [, pageName] = entryPoint.split(":");
|
|
100
104
|
const pageData = internals.pagesByComponent.get(
|
|
101
105
|
`${pageName.replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, ".")}`
|
|
@@ -371,6 +371,7 @@ function buildManifest(opts, internals, staticFiles) {
|
|
|
371
371
|
routes,
|
|
372
372
|
site: settings.config.site,
|
|
373
373
|
base: settings.config.base,
|
|
374
|
+
compressHTML: settings.config.compressHTML,
|
|
374
375
|
assetsPrefix: settings.config.build.assetsPrefix,
|
|
375
376
|
markdown: settings.config.markdown,
|
|
376
377
|
componentMetadata: Array.from(internals.componentMetadata),
|
|
@@ -27,7 +27,7 @@ function createStylePreprocessor({
|
|
|
27
27
|
return { code: result.code, map };
|
|
28
28
|
} catch (err) {
|
|
29
29
|
try {
|
|
30
|
-
err = enhanceCSSError(err, filename);
|
|
30
|
+
err = enhanceCSSError(err, filename, content);
|
|
31
31
|
} catch {
|
|
32
32
|
}
|
|
33
33
|
cssTransformErrors.push(err);
|
|
@@ -35,10 +35,9 @@ function createStylePreprocessor({
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
function enhanceCSSError(err, filename) {
|
|
39
|
-
var _a;
|
|
38
|
+
function enhanceCSSError(err, filename, cssContent) {
|
|
40
39
|
const fileContent = fs.readFileSync(filename).toString();
|
|
41
|
-
const styleTagBeginning = fileContent.indexOf(
|
|
40
|
+
const styleTagBeginning = fileContent.indexOf(cssContent);
|
|
42
41
|
if (err.name === "CssSyntaxError") {
|
|
43
42
|
const errorLine = positionAt(styleTagBeginning, fileContent).line + (err.line ?? 0);
|
|
44
43
|
return new CSSError({
|
package/dist/core/constants.js
CHANGED
|
@@ -29,7 +29,6 @@ export interface CreateContainerParams {
|
|
|
29
29
|
root?: string | URL;
|
|
30
30
|
configFlag?: string;
|
|
31
31
|
configFlagPath?: string;
|
|
32
|
-
disableTelemetry?: boolean;
|
|
33
32
|
}
|
|
34
33
|
export declare function createContainer(params?: CreateContainerParams): Promise<Container>;
|
|
35
34
|
export declare function startContainer({ settings, viteServer, logging, }: Container): Promise<AddressInfo>;
|
|
@@ -20,12 +20,8 @@ async function createContainer(params = {}) {
|
|
|
20
20
|
isRestart = false,
|
|
21
21
|
logging = defaultLogging,
|
|
22
22
|
settings = await createDefaultDevSettings(params.userConfig, params.root),
|
|
23
|
-
fs = nodeFs
|
|
24
|
-
disableTelemetry
|
|
23
|
+
fs = nodeFs
|
|
25
24
|
} = params;
|
|
26
|
-
if (disableTelemetry) {
|
|
27
|
-
settings.forceDisableTelemetry = true;
|
|
28
|
-
}
|
|
29
25
|
applyPolyfill();
|
|
30
26
|
settings = await runHookConfigSetup({
|
|
31
27
|
settings,
|
|
@@ -94,7 +90,7 @@ function isStarted(container) {
|
|
|
94
90
|
return !!((_a = container.viteServer.httpServer) == null ? void 0 : _a.listening);
|
|
95
91
|
}
|
|
96
92
|
async function runInContainer(params, callback) {
|
|
97
|
-
const container = await createContainer(
|
|
93
|
+
const container = await createContainer(params);
|
|
98
94
|
try {
|
|
99
95
|
await callback(container);
|
|
100
96
|
} finally {
|
package/dist/core/dev/dev.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type { AstroTelemetry } from '@astrojs/telemetry';
|
|
4
3
|
import type http from 'http';
|
|
5
4
|
import type { AddressInfo } from 'net';
|
|
6
5
|
import type * as vite from 'vite';
|
|
@@ -12,7 +11,6 @@ export interface DevOptions {
|
|
|
12
11
|
configFlagPath: string | undefined;
|
|
13
12
|
flags?: yargs.Arguments;
|
|
14
13
|
logging: LogOptions;
|
|
15
|
-
telemetry: AstroTelemetry;
|
|
16
14
|
handleConfigError: (error: Error) => void;
|
|
17
15
|
isRestart?: boolean;
|
|
18
16
|
}
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cyan } from "kleur/colors";
|
|
2
2
|
import { performance } from "perf_hooks";
|
|
3
3
|
import { attachContentServerListeners } from "../../content/index.js";
|
|
4
|
+
import { telemetry } from "../../events/index.js";
|
|
4
5
|
import { info, warn } from "../logger/core.js";
|
|
5
6
|
import * as msg from "../messages.js";
|
|
6
7
|
import { printHelp } from "../messages.js";
|
|
@@ -28,7 +29,7 @@ async function dev(settings, options) {
|
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
const devStart = performance.now();
|
|
31
|
-
await
|
|
32
|
+
await telemetry.record([]);
|
|
32
33
|
const restart = await createContainerWithAutomaticRestart({
|
|
33
34
|
flags: options.flags ?? {},
|
|
34
35
|
handleConfigError: options.handleConfigError,
|
|
@@ -53,7 +54,7 @@ async function dev(settings, options) {
|
|
|
53
54
|
isRestart: options.isRestart
|
|
54
55
|
})
|
|
55
56
|
);
|
|
56
|
-
const currentVersion = "2.7.
|
|
57
|
+
const currentVersion = "2.7.3";
|
|
57
58
|
if (currentVersion.includes("-")) {
|
|
58
59
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
59
60
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { createRenderContext } from "../../render/index.js";
|
|
2
2
|
import { callEndpoint } from "../index.js";
|
|
3
3
|
async function call(options, logging) {
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
preload: [, mod],
|
|
7
|
-
middleware
|
|
8
|
-
} = options;
|
|
9
|
-
const endpointHandler = mod;
|
|
4
|
+
const { env, preload, middleware } = options;
|
|
5
|
+
const endpointHandler = preload;
|
|
10
6
|
const ctx = await createRenderContext({
|
|
11
7
|
request: options.request,
|
|
12
8
|
origin: options.origin,
|
|
13
9
|
pathname: options.pathname,
|
|
14
10
|
route: options.route,
|
|
15
11
|
env,
|
|
16
|
-
mod:
|
|
12
|
+
mod: preload
|
|
17
13
|
});
|
|
18
14
|
return await callEndpoint(endpointHandler, env, ctx, logging, middleware == null ? void 0 : middleware.onRequest);
|
|
19
15
|
}
|
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.7.
|
|
50
|
+
const version = "2.7.3";
|
|
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.7.
|
|
236
|
+
`v${"2.7.3"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { AstroTelemetry } from '@astrojs/telemetry';
|
|
2
1
|
import type { Arguments } from 'yargs-parser';
|
|
3
2
|
import type { AstroSettings, PreviewServer } from '../../@types/astro';
|
|
4
3
|
import type { LogOptions } from '../logger/core';
|
|
5
4
|
interface PreviewOptions {
|
|
6
5
|
logging: LogOptions;
|
|
7
|
-
telemetry: AstroTelemetry;
|
|
8
6
|
flags?: Arguments;
|
|
9
7
|
}
|
|
10
8
|
/** The primary dev action */
|
|
@@ -17,8 +17,7 @@ function createDevelopmentEnvironment(settings, logging, loader) {
|
|
|
17
17
|
routeCache: new RouteCache(logging, mode),
|
|
18
18
|
site: settings.config.site,
|
|
19
19
|
ssr: isServerLikeOutput(settings.config),
|
|
20
|
-
streaming: true
|
|
21
|
-
telemetry: Boolean(settings.forceDisableTelemetry)
|
|
20
|
+
streaming: true
|
|
22
21
|
});
|
|
23
22
|
return {
|
|
24
23
|
...env,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { AstroMiddlewareInstance,
|
|
2
|
-
import type { ModuleLoader } from '../../module-loader/index';
|
|
1
|
+
import type { AstroMiddlewareInstance, ComponentInstance, RouteData } from '../../../@types/astro';
|
|
3
2
|
import type { DevelopmentEnvironment } from './environment';
|
|
4
3
|
export { createDevelopmentEnvironment } from './environment.js';
|
|
5
4
|
export type { DevelopmentEnvironment };
|
|
@@ -12,8 +11,8 @@ export interface SSROptions {
|
|
|
12
11
|
origin: string;
|
|
13
12
|
/** the web request (needed for dynamic routes) */
|
|
14
13
|
pathname: string;
|
|
15
|
-
/** The
|
|
16
|
-
preload:
|
|
14
|
+
/** The runtime component instance */
|
|
15
|
+
preload: ComponentInstance;
|
|
17
16
|
/** Request */
|
|
18
17
|
request: Request;
|
|
19
18
|
/** optional, in case we need to render something outside of a dev server */
|
|
@@ -23,7 +22,8 @@ export interface SSROptions {
|
|
|
23
22
|
*/
|
|
24
23
|
middleware?: AstroMiddlewareInstance<unknown>;
|
|
25
24
|
}
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
export declare function preload({ env, filePath, }: {
|
|
26
|
+
env: DevelopmentEnvironment;
|
|
27
|
+
filePath: URL;
|
|
28
|
+
}): Promise<ComponentInstance>;
|
|
29
29
|
export declare function renderPage(options: SSROptions): Promise<Response>;
|
|
@@ -4,30 +4,25 @@ import { enhanceViteSSRError } from "../../errors/dev/index.js";
|
|
|
4
4
|
import { AggregateError, CSSError, MarkdownError } from "../../errors/index.js";
|
|
5
5
|
import { callMiddleware } from "../../middleware/callMiddleware.js";
|
|
6
6
|
import { isPage, resolveIdToUrl, viteID } from "../../util.js";
|
|
7
|
-
import { createRenderContext, renderPage as coreRenderPage } from "../index.js";
|
|
8
|
-
import { filterFoundRenderers, loadRenderer } from "../renderer.js";
|
|
7
|
+
import { createRenderContext, loadRenderers, renderPage as coreRenderPage } from "../index.js";
|
|
9
8
|
import { getStylesForURL } from "./css.js";
|
|
10
9
|
import { getComponentMetadata } from "./metadata.js";
|
|
11
10
|
import { getScriptsForURL } from "./scripts.js";
|
|
12
11
|
import { createDevelopmentEnvironment } from "./environment.js";
|
|
13
|
-
async function loadRenderers(moduleLoader, settings) {
|
|
14
|
-
const loader = (entry) => moduleLoader.import(entry);
|
|
15
|
-
const renderers = await Promise.all(settings.renderers.map((r) => loadRenderer(r, loader)));
|
|
16
|
-
return filterFoundRenderers(renderers);
|
|
17
|
-
}
|
|
18
12
|
async function preload({
|
|
19
13
|
env,
|
|
20
14
|
filePath
|
|
21
15
|
}) {
|
|
22
|
-
const renderers = await loadRenderers(env.
|
|
16
|
+
const renderers = await loadRenderers(env.settings, env.loader);
|
|
17
|
+
env.renderers = renderers;
|
|
23
18
|
try {
|
|
24
19
|
const mod = await env.loader.import(viteID(filePath));
|
|
25
|
-
return
|
|
20
|
+
return mod;
|
|
26
21
|
} catch (error) {
|
|
27
22
|
if (MarkdownError.is(error) || CSSError.is(error) || AggregateError.is(error)) {
|
|
28
23
|
throw error;
|
|
29
24
|
}
|
|
30
|
-
throw enhanceViteSSRError({ error, filePath, loader: env.loader
|
|
25
|
+
throw enhanceViteSSRError({ error, filePath, loader: env.loader });
|
|
31
26
|
}
|
|
32
27
|
}
|
|
33
28
|
async function getScriptsAndStyles({ env, filePath }) {
|
|
@@ -91,8 +86,7 @@ async function getScriptsAndStyles({ env, filePath }) {
|
|
|
91
86
|
return { scripts, styles, links, metadata };
|
|
92
87
|
}
|
|
93
88
|
async function renderPage(options) {
|
|
94
|
-
const
|
|
95
|
-
options.env.renderers = renderers;
|
|
89
|
+
const mod = options.preload;
|
|
96
90
|
const { scripts, links, styles, metadata } = await getScriptsAndStyles({
|
|
97
91
|
env: options.env,
|
|
98
92
|
filePath: options.filePath
|
|
@@ -139,7 +133,6 @@ async function renderPage(options) {
|
|
|
139
133
|
}
|
|
140
134
|
export {
|
|
141
135
|
createDevelopmentEnvironment,
|
|
142
|
-
loadRenderers,
|
|
143
136
|
preload,
|
|
144
137
|
renderPage
|
|
145
138
|
};
|
|
@@ -16,8 +16,7 @@ function createBasicEnvironment(options) {
|
|
|
16
16
|
resolve: options.resolve ?? ((s) => Promise.resolve(s)),
|
|
17
17
|
routeCache: new RouteCache(options.logging, mode),
|
|
18
18
|
ssr: options.ssr ?? true,
|
|
19
|
-
streaming: options.streaming ?? true
|
|
20
|
-
telemetry: false
|
|
19
|
+
streaming: options.streaming ?? true
|
|
21
20
|
});
|
|
22
21
|
}
|
|
23
22
|
export {
|
|
@@ -3,4 +3,4 @@ export type { RenderContext } from './context.js';
|
|
|
3
3
|
export { getParamsAndProps, GetParamsAndPropsError, getParamsAndPropsOrThrow, renderPage, } from './core.js';
|
|
4
4
|
export type { Environment } from './environment';
|
|
5
5
|
export { createBasicEnvironment, createEnvironment } from './environment.js';
|
|
6
|
-
export { loadRenderer } from './renderer.js';
|
|
6
|
+
export { loadRenderer, loadRenderers } from './renderer.js';
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
renderPage
|
|
7
7
|
} from "./core.js";
|
|
8
8
|
import { createBasicEnvironment, createEnvironment } from "./environment.js";
|
|
9
|
-
import { loadRenderer } from "./renderer.js";
|
|
9
|
+
import { loadRenderer, loadRenderers } from "./renderer.js";
|
|
10
10
|
export {
|
|
11
11
|
GetParamsAndPropsError,
|
|
12
12
|
createBasicEnvironment,
|
|
@@ -15,5 +15,6 @@ export {
|
|
|
15
15
|
getParamsAndProps,
|
|
16
16
|
getParamsAndPropsOrThrow,
|
|
17
17
|
loadRenderer,
|
|
18
|
+
loadRenderers,
|
|
18
19
|
renderPage
|
|
19
20
|
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type { AstroRenderer, SSRLoadedRenderer } from '../../@types/astro';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type MaybeRendererServerEntrypointModule = Partial<RendererServerEntrypointModule>;
|
|
6
|
-
export type RendererLoader = (entryPoint: string) => Promise<MaybeRendererServerEntrypointModule>;
|
|
7
|
-
export declare function loadRenderer(renderer: AstroRenderer, loader: RendererLoader): Promise<SSRLoadedRenderer | undefined>;
|
|
8
|
-
export declare function filterFoundRenderers(renderers: Array<SSRLoadedRenderer | undefined>): SSRLoadedRenderer[];
|
|
9
|
-
export declare function createLoadedRenderer(renderer: AstroRenderer, mod: RendererServerEntrypointModule): SSRLoadedRenderer;
|
|
1
|
+
import type { AstroRenderer, AstroSettings, SSRLoadedRenderer } from '../../@types/astro';
|
|
2
|
+
import type { ModuleLoader } from '../module-loader/index.js';
|
|
3
|
+
export declare function loadRenderers(settings: AstroSettings, moduleLoader: ModuleLoader): Promise<SSRLoadedRenderer[]>;
|
|
4
|
+
export declare function loadRenderer(renderer: AstroRenderer, moduleLoader: ModuleLoader): Promise<SSRLoadedRenderer | undefined>;
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
async function
|
|
2
|
-
const
|
|
1
|
+
async function loadRenderers(settings, moduleLoader) {
|
|
2
|
+
const renderers = await Promise.all(settings.renderers.map((r) => loadRenderer(r, moduleLoader)));
|
|
3
|
+
return renderers.filter(Boolean);
|
|
4
|
+
}
|
|
5
|
+
async function loadRenderer(renderer, moduleLoader) {
|
|
6
|
+
const mod = await moduleLoader.import(renderer.serverEntrypoint);
|
|
3
7
|
if (typeof mod.default !== "undefined") {
|
|
4
|
-
return
|
|
8
|
+
return {
|
|
9
|
+
...renderer,
|
|
10
|
+
ssr: mod.default
|
|
11
|
+
};
|
|
5
12
|
}
|
|
6
13
|
return void 0;
|
|
7
14
|
}
|
|
8
|
-
function filterFoundRenderers(renderers) {
|
|
9
|
-
return renderers.filter((renderer) => {
|
|
10
|
-
return !!renderer;
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
function createLoadedRenderer(renderer, mod) {
|
|
14
|
-
return {
|
|
15
|
-
...renderer,
|
|
16
|
-
ssr: mod.default
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
15
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
loadRenderer
|
|
16
|
+
loadRenderer,
|
|
17
|
+
loadRenderers
|
|
23
18
|
};
|
|
@@ -9,14 +9,6 @@ import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
|
9
9
|
import { warn } from "../logger/core.js";
|
|
10
10
|
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
|
11
11
|
const responseSentSymbol = Symbol.for("astro.responseSent");
|
|
12
|
-
function onlyAvailableInSSR(name) {
|
|
13
|
-
return function _onlyAvailableInSSR() {
|
|
14
|
-
switch (name) {
|
|
15
|
-
case "Astro.redirect":
|
|
16
|
-
throw new AstroError(AstroErrorData.StaticRedirectNotAvailable);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
12
|
function getFunctionExpression(slot) {
|
|
21
13
|
var _a;
|
|
22
14
|
if (!slot)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AstroSettings, RouteData } from '../@types/astro';
|
|
2
|
-
import { type
|
|
1
|
+
import type { AstroSettings, ComponentInstance, RouteData } from '../@types/astro';
|
|
2
|
+
import { type DevelopmentEnvironment } from '../core/render/dev/index.js';
|
|
3
3
|
type GetSortedPreloadedMatchesParams = {
|
|
4
4
|
env: DevelopmentEnvironment;
|
|
5
5
|
matches: RouteData[];
|
|
@@ -9,6 +9,6 @@ export declare function getSortedPreloadedMatches({ env, matches, settings, }: G
|
|
|
9
9
|
type PreloadAndSetPrerenderStatusResult = {
|
|
10
10
|
filePath: URL;
|
|
11
11
|
route: RouteData;
|
|
12
|
-
preloadedComponent:
|
|
12
|
+
preloadedComponent: ComponentInstance;
|
|
13
13
|
};
|
|
14
14
|
export {};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RedirectComponentInstance, routeIsRedirect } from "../core/redirects/index.js";
|
|
2
|
-
import {
|
|
3
|
-
preload
|
|
4
|
-
} from "../core/render/dev/index.js";
|
|
2
|
+
import { preload } from "../core/render/dev/index.js";
|
|
5
3
|
import { getPrerenderStatus } from "./metadata.js";
|
|
6
4
|
async function getSortedPreloadedMatches({
|
|
7
5
|
env,
|
|
@@ -23,9 +21,8 @@ async function preloadAndSetPrerenderStatus({
|
|
|
23
21
|
matches.map(async (route) => {
|
|
24
22
|
const filePath = new URL(`./${route.component}`, settings.config.root);
|
|
25
23
|
if (routeIsRedirect(route)) {
|
|
26
|
-
const preloadedComponent2 = [[], RedirectComponentInstance];
|
|
27
24
|
return {
|
|
28
|
-
preloadedComponent:
|
|
25
|
+
preloadedComponent: RedirectComponentInstance,
|
|
29
26
|
route,
|
|
30
27
|
filePath
|
|
31
28
|
};
|
|
@@ -25,12 +25,15 @@ var _a;
|
|
|
25
25
|
(_a = class extends HTMLElement {
|
|
26
26
|
constructor() {
|
|
27
27
|
super(...arguments);
|
|
28
|
-
this.hydrate = () => {
|
|
28
|
+
this.hydrate = async () => {
|
|
29
29
|
var _a2;
|
|
30
|
-
if (!this.hydrator
|
|
31
|
-
|
|
32
|
-
!this.isConnected
|
|
33
|
-
|
|
30
|
+
if (!this.hydrator)
|
|
31
|
+
return;
|
|
32
|
+
if (!this.isConnected)
|
|
33
|
+
return;
|
|
34
|
+
const parentSsrIsland = (_a2 = this.parentElement) == null ? void 0 : _a2.closest("astro-island[ssr]");
|
|
35
|
+
if (parentSsrIsland) {
|
|
36
|
+
parentSsrIsland.addEventListener("astro:hydrate", this.hydrate, { once: true });
|
|
34
37
|
return;
|
|
35
38
|
}
|
|
36
39
|
const slotted = this.querySelectorAll("astro-slot");
|
|
@@ -50,12 +53,11 @@ var _a;
|
|
|
50
53
|
slots[slot.getAttribute("name") || "default"] = slot.innerHTML;
|
|
51
54
|
}
|
|
52
55
|
const props = this.hasAttribute("props") ? JSON.parse(this.getAttribute("props"), reviver) : {};
|
|
53
|
-
this.hydrator(this)(this.Component, props, slots, {
|
|
56
|
+
await this.hydrator(this)(this.Component, props, slots, {
|
|
54
57
|
client: this.getAttribute("client")
|
|
55
58
|
});
|
|
56
59
|
this.removeAttribute("ssr");
|
|
57
|
-
|
|
58
|
-
window.dispatchEvent(new CustomEvent("astro:hydrate"));
|
|
60
|
+
this.dispatchEvent(new CustomEvent("astro:hydrate"));
|
|
59
61
|
};
|
|
60
62
|
}
|
|
61
63
|
connectedCallback() {
|
|
@@ -69,7 +71,6 @@ var _a;
|
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
async childrenConnectedCallback() {
|
|
72
|
-
window.addEventListener("astro:hydrate", this.hydrate);
|
|
73
74
|
let beforeHydrationUrl = this.getAttribute("before-hydration-url");
|
|
74
75
|
if (beforeHydrationUrl) {
|
|
75
76
|
await import(beforeHydrationUrl);
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "(()=>{var
|
|
6
|
+
declare const _default: "(()=>{var d;{let h={0:t=>t,1:t=>JSON.parse(t,a),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,a)),5:t=>new Set(JSON.parse(t,a)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},a=(t,e)=>{if(t===\"\"||!Array.isArray(e))return e;let[s,n]=e;return s in h?h[s](n):void 0};customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var i;if(!this.hydrator||!this.isConnected)return;let e=(i=this.parentElement)==null?void 0:i.closest(\"astro-island[ssr]\");if(e){e.addEventListener(\"astro:hydrate\",this.hydrate,{once:!0});return}let s=this.querySelectorAll(\"astro-slot\"),n={},c=this.querySelectorAll(\"template[data-astro-template]\");for(let r of c){let o=r.closest(this.tagName);!o||!o.isSameNode(this)||(n[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(let r of s){let o=r.closest(this.tagName);!o||!o.isSameNode(this)||(n[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}let l=this.hasAttribute(\"props\")?JSON.parse(this.getAttribute(\"props\"),a):{};await this.hydrator(this)(this.Component,l,n,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),this.dispatchEvent(new CustomEvent(\"astro:hydrate\"))}}connectedCallback(){!this.hasAttribute(\"await-children\")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((e,s)=>{s.disconnect(),setTimeout(()=>this.childrenConnectedCallback(),0)}).observe(this,{childList:!0})}async childrenConnectedCallback(){let e=this.getAttribute(\"before-hydration-url\");e&&await import(e),this.start()}start(){let e=JSON.parse(this.getAttribute(\"opts\")),s=this.getAttribute(\"client\");if(Astro[s]===void 0){window.addEventListener(`astro:${s}`,()=>this.start(),{once:!0});return}Astro[s](async()=>{let n=this.getAttribute(\"renderer-url\"),[c,{default:l}]=await Promise.all([import(this.getAttribute(\"component-url\")),n?import(n):()=>()=>{}]),i=this.getAttribute(\"component-export\")||\"default\";if(!i.includes(\".\"))this.Component=c[i];else{this.Component=c;for(let r of i.split(\".\"))this.Component=this.Component[r]}return this.hydrator=l,this.hydrate},e,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=[\"props\"],d))}})();";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var astro_island_prebuilt_default = `(()=>{var
|
|
1
|
+
var astro_island_prebuilt_default = `(()=>{var d;{let h={0:t=>t,1:t=>JSON.parse(t,a),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,a)),5:t=>new Set(JSON.parse(t,a)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},a=(t,e)=>{if(t===""||!Array.isArray(e))return e;let[s,n]=e;return s in h?h[s](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var i;if(!this.hydrator||!this.isConnected)return;let e=(i=this.parentElement)==null?void 0:i.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let s=this.querySelectorAll("astro-slot"),n={},c=this.querySelectorAll("template[data-astro-template]");for(let r of c){let o=r.closest(this.tagName);!o||!o.isSameNode(this)||(n[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of s){let o=r.closest(this.tagName);!o||!o.isSameNode(this)||(n[r.getAttribute("name")||"default"]=r.innerHTML)}let l=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),a):{};await this.hydrator(this)(this.Component,l,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((e,s)=>{s.disconnect(),setTimeout(()=>this.childrenConnectedCallback(),0)}).observe(this,{childList:!0})}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}start(){let e=JSON.parse(this.getAttribute("opts")),s=this.getAttribute("client");if(Astro[s]===void 0){window.addEventListener(\`astro:\${s}\`,()=>this.start(),{once:!0});return}Astro[s](async()=>{let n=this.getAttribute("renderer-url"),[c,{default:l}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=c[i];else{this.Component=c;for(let r of i.split("."))this.Component=this.Component[r]}return this.hydrator=l,this.hydrate},e,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=["props"],d))}})();`;
|
|
2
2
|
export {
|
|
3
3
|
astro_island_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -60,8 +60,15 @@ Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the
|
|
|
60
60
|
}
|
|
61
61
|
return markHTMLString(` ${key.slice(0, -5)}="${listValue}"`);
|
|
62
62
|
}
|
|
63
|
-
if (key === "style" && !(value instanceof HTMLString)
|
|
64
|
-
|
|
63
|
+
if (key === "style" && !(value instanceof HTMLString)) {
|
|
64
|
+
if (Array.isArray(value) && value.length === 2) {
|
|
65
|
+
return markHTMLString(
|
|
66
|
+
` ${key}="${toAttributeString(`${toStyleString(value[0])};${value[1]}`, shouldEscape)}"`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (typeof value === "object") {
|
|
70
|
+
return markHTMLString(` ${key}="${toAttributeString(toStyleString(value), shouldEscape)}"`);
|
|
71
|
+
}
|
|
65
72
|
}
|
|
66
73
|
if (key === "className") {
|
|
67
74
|
return markHTMLString(` class="${toAttributeString(value, shouldEscape)}"`);
|
|
@@ -98,9 +105,9 @@ function renderElement(name, { props: _props, children = "" }, shouldEscape = tr
|
|
|
98
105
|
}
|
|
99
106
|
function bufferIterators(iterators) {
|
|
100
107
|
const eagerIterators = iterators.map((it) => new EagerAsyncIterableIterator(it));
|
|
101
|
-
|
|
108
|
+
queueMicrotask(() => {
|
|
102
109
|
eagerIterators.forEach((it) => !it.isStarted() && it.buffer());
|
|
103
|
-
}
|
|
110
|
+
});
|
|
104
111
|
return eagerIterators;
|
|
105
112
|
}
|
|
106
113
|
class EagerAsyncIterableIterator {
|
|
@@ -81,6 +81,8 @@ function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */
|
|
|
81
81
|
default: {
|
|
82
82
|
if (value !== null && typeof value === "object") {
|
|
83
83
|
return [PROP_TYPE.Value, serializeObject(value, metadata, parents)];
|
|
84
|
+
} else if (value === void 0) {
|
|
85
|
+
return [PROP_TYPE.Value];
|
|
84
86
|
} else {
|
|
85
87
|
return [PROP_TYPE.Value, value];
|
|
86
88
|
}
|
|
@@ -58,10 +58,12 @@ async function handleRequest(env, manifest, controller, req, res) {
|
|
|
58
58
|
},
|
|
59
59
|
onError(_err) {
|
|
60
60
|
const err = createSafeError(_err);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
try {
|
|
62
|
+
env.loader.fixStacktrace(err);
|
|
63
|
+
} catch {
|
|
64
64
|
}
|
|
65
|
+
const errorWithMetadata = collectErrorMetadata(err, config.root);
|
|
66
|
+
telemetry.record(eventError({ cmd: "dev", err: errorWithMetadata, isFatal: false }));
|
|
65
67
|
error(env.logging, null, msg.formatErrorMessage(errorWithMetadata));
|
|
66
68
|
handle500Response(moduleLoader, res, errorWithMetadata);
|
|
67
69
|
return err;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type http from 'http';
|
|
3
3
|
import type { ComponentInstance, ManifestData, RouteData } from '../@types/astro';
|
|
4
|
-
import type {
|
|
4
|
+
import type { DevelopmentEnvironment } from '../core/render/dev/index';
|
|
5
5
|
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
6
6
|
interface MatchedRoute {
|
|
7
7
|
route: RouteData;
|
|
8
8
|
filePath: URL;
|
|
9
9
|
resolvedPathname: string;
|
|
10
|
-
preloadedComponent:
|
|
10
|
+
preloadedComponent: ComponentInstance;
|
|
11
11
|
mod: ComponentInstance;
|
|
12
12
|
}
|
|
13
13
|
export declare function matchRoute(pathname: string, env: DevelopmentEnvironment, manifest: ManifestData): Promise<MatchedRoute | undefined>;
|
|
@@ -23,9 +23,8 @@ async function matchRoute(pathname, env, manifest) {
|
|
|
23
23
|
const matches = matchAllRoutes(pathname, manifest);
|
|
24
24
|
const preloadedMatches = await getSortedPreloadedMatches({ env, matches, settings });
|
|
25
25
|
for await (const { preloadedComponent, route: maybeRoute, filePath } of preloadedMatches) {
|
|
26
|
-
const [, mod] = preloadedComponent;
|
|
27
26
|
const paramsAndPropsRes = await getParamsAndProps({
|
|
28
|
-
mod,
|
|
27
|
+
mod: preloadedComponent,
|
|
29
28
|
route: maybeRoute,
|
|
30
29
|
routeCache,
|
|
31
30
|
pathname,
|
|
@@ -38,7 +37,7 @@ async function matchRoute(pathname, env, manifest) {
|
|
|
38
37
|
filePath,
|
|
39
38
|
resolvedPathname: pathname,
|
|
40
39
|
preloadedComponent,
|
|
41
|
-
mod
|
|
40
|
+
mod: preloadedComponent
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -63,13 +62,12 @@ ${AstroErrorData.NoMatchingStaticPathFound.hint(possibleRoutes)}`
|
|
|
63
62
|
if (custom404) {
|
|
64
63
|
const filePath = new URL(`./${custom404.component}`, settings.config.root);
|
|
65
64
|
const preloadedComponent = await preload({ env, filePath });
|
|
66
|
-
const [, mod] = preloadedComponent;
|
|
67
65
|
return {
|
|
68
66
|
route: custom404,
|
|
69
67
|
filePath,
|
|
70
68
|
resolvedPathname: pathname,
|
|
71
69
|
preloadedComponent,
|
|
72
|
-
mod
|
|
70
|
+
mod: preloadedComponent
|
|
73
71
|
};
|
|
74
72
|
}
|
|
75
73
|
return void 0;
|
|
@@ -107,14 +105,6 @@ async function handleRoute(matchedRoute, url, pathname, body, origin, env, manif
|
|
|
107
105
|
if (value)
|
|
108
106
|
res.setHeader(name, value);
|
|
109
107
|
}
|
|
110
|
-
const paramsAndPropsRes = await getParamsAndProps({
|
|
111
|
-
mod,
|
|
112
|
-
route,
|
|
113
|
-
routeCache: env.routeCache,
|
|
114
|
-
pathname,
|
|
115
|
-
logging,
|
|
116
|
-
ssr: isServerLikeOutput(config)
|
|
117
|
-
});
|
|
118
108
|
const options = {
|
|
119
109
|
env,
|
|
120
110
|
filePath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
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",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"vendor"
|
|
101
101
|
],
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@astrojs/compiler": "^1.5.
|
|
103
|
+
"@astrojs/compiler": "^1.5.3",
|
|
104
104
|
"@astrojs/internal-helpers": "^0.1.1",
|
|
105
105
|
"@astrojs/language-server": "^1.0.0",
|
|
106
106
|
"@astrojs/markdown-remark": "^2.2.1",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".ts"]);
|
|
2
|
-
const scriptRe = new RegExp(
|
|
3
|
-
`\\.(${Array.from(SCRIPT_EXTENSIONS).map((s) => s.slice(1)).join("|")})($|\\?)`
|
|
4
|
-
);
|
|
5
|
-
const isScriptRequest = (request) => scriptRe.test(request);
|
|
6
|
-
export {
|
|
7
|
-
SCRIPT_EXTENSIONS,
|
|
8
|
-
isScriptRequest
|
|
9
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const notify: () => void;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const HYDRATE_KEY = `astro:hydrate`;
|
|
2
|
-
function debounce(cb, wait = 20) {
|
|
3
|
-
let h = 0;
|
|
4
|
-
let callable = (...args) => {
|
|
5
|
-
clearTimeout(h);
|
|
6
|
-
h = setTimeout(() => cb(...args), wait);
|
|
7
|
-
};
|
|
8
|
-
return callable;
|
|
9
|
-
}
|
|
10
|
-
const notify = debounce(() => {
|
|
11
|
-
window.dispatchEvent(new CustomEvent(HYDRATE_KEY));
|
|
12
|
-
});
|
|
13
|
-
if (!window[HYDRATE_KEY]) {
|
|
14
|
-
if ("MutationObserver" in window) {
|
|
15
|
-
new MutationObserver(notify).observe(document.body, { subtree: true, childList: true });
|
|
16
|
-
}
|
|
17
|
-
window[HYDRATE_KEY] = true;
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
notify
|
|
21
|
-
};
|
|
File without changes
|