astro 1.2.7 → 1.3.0
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/core/add/index.js +1 -1
- package/dist/core/build/generate.js +6 -0
- package/dist/core/build/static-build.js +3 -4
- package/dist/core/build/vite-plugin-css.js +3 -2
- package/dist/core/config/schema.d.ts +12 -12
- package/dist/core/dev/index.js +7 -8
- package/dist/core/messages.d.ts +10 -6
- package/dist/core/messages.js +57 -32
- package/dist/core/preview/index.js +8 -5
- package/dist/core/render/core.js +0 -1
- package/dist/core/render/result.d.ts +0 -1
- package/dist/core/render/result.js +1 -6
- package/dist/core/util.d.ts +1 -1
- package/dist/core/util.js +1 -1
- 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/escape.d.ts +9 -0
- package/dist/runtime/server/escape.js +51 -1
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +6 -10
- 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 +18 -15
- 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-jsx/tag.js +52 -20
- package/package.json +4 -3
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/core/add/index.js
CHANGED
|
@@ -256,7 +256,7 @@ async function parseAstroConfig(configURL) {
|
|
|
256
256
|
return result;
|
|
257
257
|
}
|
|
258
258
|
const toIdent = (name) => {
|
|
259
|
-
const ident = name.trim().replace(/[-_
|
|
259
|
+
const ident = name.trim().replace(/[-_\.\/]?astro(?:js)?[-_\.]?/g, "").replace(/\.js/, "").replace(/(?:[\.\-\_\/]+)([a-zA-Z])/g, (_, w) => w.toUpperCase()).replace(/^[^a-zA-Z$_]+/, "");
|
|
260
260
|
return `${ident[0].toLowerCase()}${ident.slice(1)}`;
|
|
261
261
|
};
|
|
262
262
|
function createPrettyError(err) {
|
|
@@ -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
|
}
|
|
@@ -85,6 +85,7 @@ async function ssrBuild(opts, internals, input) {
|
|
|
85
85
|
logLevel: opts.viteConfig.logLevel ?? "error",
|
|
86
86
|
mode: "production",
|
|
87
87
|
build: {
|
|
88
|
+
target: "esnext",
|
|
88
89
|
...viteConfig.build,
|
|
89
90
|
emptyOutDir: false,
|
|
90
91
|
manifest: false,
|
|
@@ -101,7 +102,6 @@ async function ssrBuild(opts, internals, input) {
|
|
|
101
102
|
}
|
|
102
103
|
},
|
|
103
104
|
ssr: true,
|
|
104
|
-
target: "esnext",
|
|
105
105
|
minify: false,
|
|
106
106
|
polyfillModulePreload: false,
|
|
107
107
|
reportCompressedSize: false
|
|
@@ -150,9 +150,9 @@ ${bgGreen(black(" building client "))}`);
|
|
|
150
150
|
logLevel: "info",
|
|
151
151
|
mode: "production",
|
|
152
152
|
build: {
|
|
153
|
+
target: "esnext",
|
|
153
154
|
...viteConfig.build,
|
|
154
155
|
emptyOutDir: false,
|
|
155
|
-
minify: "esbuild",
|
|
156
156
|
outDir: fileURLToPath(out),
|
|
157
157
|
rollupOptions: {
|
|
158
158
|
...(_a = viteConfig.build) == null ? void 0 : _a.rollupOptions,
|
|
@@ -165,8 +165,7 @@ ${bgGreen(black(" building client "))}`);
|
|
|
165
165
|
...(_c = (_b = viteConfig.build) == null ? void 0 : _b.rollupOptions) == null ? void 0 : _c.output
|
|
166
166
|
},
|
|
167
167
|
preserveEntrySignatures: "exports-only"
|
|
168
|
-
}
|
|
169
|
-
target: "esnext"
|
|
168
|
+
}
|
|
170
169
|
},
|
|
171
170
|
plugins: [
|
|
172
171
|
vitePluginInternals(input, internals),
|
|
@@ -158,15 +158,16 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
158
158
|
name: "astro:rollup-plugin-build-css-minify",
|
|
159
159
|
enforce: "post",
|
|
160
160
|
async generateBundle(_outputOptions, bundle) {
|
|
161
|
-
var _a, _b;
|
|
161
|
+
var _a, _b, _c;
|
|
162
162
|
if (options.target === "server") {
|
|
163
163
|
for (const [, output] of Object.entries(bundle)) {
|
|
164
164
|
if (output.type === "asset") {
|
|
165
165
|
if (((_a = output.name) == null ? void 0 : _a.endsWith(".css")) && typeof output.source === "string") {
|
|
166
166
|
const cssTarget = (_b = settings.config.vite.build) == null ? void 0 : _b.cssTarget;
|
|
167
|
+
const minify = ((_c = settings.config.vite.build) == null ? void 0 : _c.minify) !== false;
|
|
167
168
|
const { code: minifiedCSS } = await esbuild.transform(output.source, {
|
|
168
169
|
loader: "css",
|
|
169
|
-
minify
|
|
170
|
+
minify,
|
|
170
171
|
...cssTarget ? { target: cssTarget } : {}
|
|
171
172
|
});
|
|
172
173
|
output.source = minifiedCSS;
|
|
@@ -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.0";
|
|
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,
|
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.0";
|
|
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: address2 } of ipv4Networks) {
|
|
101
|
+
if (address2.includes("127.0.0.1")) {
|
|
102
|
+
const displayAddress = address2.replace("127.0.0.1", localAddress);
|
|
103
|
+
local = toDisplayUrl(displayAddress);
|
|
104
|
+
} else {
|
|
105
|
+
network = toDisplayUrl(address2);
|
|
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.0"}`
|
|
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,
|
|
@@ -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
|
);
|
package/dist/core/render/core.js
CHANGED
|
@@ -112,12 +112,7 @@ function createResult(args) {
|
|
|
112
112
|
const { markdown, params, pathname, props: pageProps, renderers, request, resolve } = args;
|
|
113
113
|
const url = new URL(request.url);
|
|
114
114
|
const headers = new Headers();
|
|
115
|
-
|
|
116
|
-
headers.set("Transfer-Encoding", "chunked");
|
|
117
|
-
headers.set("Content-Type", "text/html");
|
|
118
|
-
} else {
|
|
119
|
-
headers.set("Content-Type", "text/html");
|
|
120
|
-
}
|
|
115
|
+
headers.set("Content-Type", "text/html");
|
|
121
116
|
const response = {
|
|
122
117
|
status: args.status,
|
|
123
118
|
statusText: "OK",
|
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.0";
|
|
9
9
|
function isObject(value) {
|
|
10
10
|
return typeof value === "object" && value != null;
|
|
11
11
|
}
|
|
@@ -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;
|
|
@@ -198,6 +198,23 @@ async function runHookBuildSsr({
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
+
async function runHookBuildGenerated({
|
|
202
|
+
config,
|
|
203
|
+
buildConfig,
|
|
204
|
+
logging
|
|
205
|
+
}) {
|
|
206
|
+
var _a;
|
|
207
|
+
const dir = config.output === "server" ? buildConfig.client : config.outDir;
|
|
208
|
+
for (const integration of config.integrations) {
|
|
209
|
+
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:generated"]) {
|
|
210
|
+
await withTakingALongTimeMsg({
|
|
211
|
+
name: integration.name,
|
|
212
|
+
hookResult: integration.hooks["astro:build:generated"]({ dir }),
|
|
213
|
+
logging
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
201
218
|
async function runHookBuildDone({
|
|
202
219
|
config,
|
|
203
220
|
buildConfig,
|
|
@@ -223,6 +240,7 @@ async function runHookBuildDone({
|
|
|
223
240
|
}
|
|
224
241
|
export {
|
|
225
242
|
runHookBuildDone,
|
|
243
|
+
runHookBuildGenerated,
|
|
226
244
|
runHookBuildSetup,
|
|
227
245
|
runHookBuildSsr,
|
|
228
246
|
runHookBuildStart,
|
|
@@ -8,7 +8,10 @@ var _a;
|
|
|
8
8
|
4: (value) => new Map(JSON.parse(value, reviver)),
|
|
9
9
|
5: (value) => new Set(JSON.parse(value, reviver)),
|
|
10
10
|
6: (value) => BigInt(value),
|
|
11
|
-
7: (value) => new URL(value)
|
|
11
|
+
7: (value) => new URL(value),
|
|
12
|
+
8: (value) => new Uint8Array(JSON.parse(value)),
|
|
13
|
+
9: (value) => new Uint16Array(JSON.parse(value)),
|
|
14
|
+
10: (value) => new Uint32Array(JSON.parse(value))
|
|
12
15
|
};
|
|
13
16
|
const reviver = (propKey, raw) => {
|
|
14
17
|
if (propKey === "" || !Array.isArray(raw))
|
|
@@ -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 l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t)},o=(t,s)=>{if(t===\"\"||!Array.isArray(s))return s;const[e,n]=s;return e in c?c[e](n):void 0};customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest(\"astro-island[ssr]\"))return;const s=this.querySelectorAll(\"astro-slot\"),e={},n=this.querySelectorAll(\"template[data-astro-template]\");for(const r of n){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(const r of s){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}const a=this.hasAttribute(\"props\")?JSON.parse(this.getAttribute(\"props\"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),window.removeEventListener(\"astro:hydrate\",this.hydrate),window.dispatchEvent(new CustomEvent(\"astro:hydrate\"))}}connectedCallback(){!this.hasAttribute(\"await-children\")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener(\"astro:hydrate\",this.hydrate);let s=this.getAttribute(\"before-hydration-url\");s&&await import(s),this.start()}start(){const s=JSON.parse(this.getAttribute(\"opts\")),e=this.getAttribute(\"client\");if(Astro[e]===void 0){window.addEventListener(`astro:${e}`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute(\"renderer-url\"),[a,{default:r}]=await Promise.all([import(this.getAttribute(\"component-url\")),n?import(n):()=>()=>{}]),i=this.getAttribute(\"component-export\")||\"default\";if(!i.includes(\".\"))this.Component=a[i];else{this.Component=a;for(const d of i.split(\".\"))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=[\"props\"],l))}";
|
|
6
|
+
declare const _default: "var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),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))},o=(t,s)=>{if(t===\"\"||!Array.isArray(s))return s;const[e,n]=s;return e in c?c[e](n):void 0};customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest(\"astro-island[ssr]\"))return;const s=this.querySelectorAll(\"astro-slot\"),e={},n=this.querySelectorAll(\"template[data-astro-template]\");for(const r of n){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(const r of s){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}const a=this.hasAttribute(\"props\")?JSON.parse(this.getAttribute(\"props\"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),window.removeEventListener(\"astro:hydrate\",this.hydrate),window.dispatchEvent(new CustomEvent(\"astro:hydrate\"))}}connectedCallback(){!this.hasAttribute(\"await-children\")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener(\"astro:hydrate\",this.hydrate);let s=this.getAttribute(\"before-hydration-url\");s&&await import(s),this.start()}start(){const s=JSON.parse(this.getAttribute(\"opts\")),e=this.getAttribute(\"client\");if(Astro[e]===void 0){window.addEventListener(`astro:${e}`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute(\"renderer-url\"),[a,{default:r}]=await Promise.all([import(this.getAttribute(\"component-url\")),n?import(n):()=>()=>{}]),i=this.getAttribute(\"component-export\")||\"default\";if(!i.includes(\".\"))this.Component=a[i];else{this.Component=a;for(const d of i.split(\".\"))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=[\"props\"],l))}";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var astro_island_prebuilt_default = `var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t)},o=(t,s)=>{if(t===""||!Array.isArray(s))return s;const[e,n]=s;return e in c?c[e](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest("astro-island[ssr]"))return;const s=this.querySelectorAll("astro-slot"),e={},n=this.querySelectorAll("template[data-astro-template]");for(const r of n){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(const r of s){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("name")||"default"]=r.innerHTML)}const a=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),window.removeEventListener("astro:hydrate",this.hydrate),window.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener("astro:hydrate",this.hydrate);let s=this.getAttribute("before-hydration-url");s&&await import(s),this.start()}start(){const s=JSON.parse(this.getAttribute("opts")),e=this.getAttribute("client");if(Astro[e]===void 0){window.addEventListener(\`astro:\${e}\`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute("renderer-url"),[a,{default:r}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=a[i];else{this.Component=a;for(const d of i.split("."))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=["props"],l))}`;
|
|
1
|
+
var astro_island_prebuilt_default = `var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),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))},o=(t,s)=>{if(t===""||!Array.isArray(s))return s;const[e,n]=s;return e in c?c[e](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest("astro-island[ssr]"))return;const s=this.querySelectorAll("astro-slot"),e={},n=this.querySelectorAll("template[data-astro-template]");for(const r of n){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(const r of s){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("name")||"default"]=r.innerHTML)}const a=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),window.removeEventListener("astro:hydrate",this.hydrate),window.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener("astro:hydrate",this.hydrate);let s=this.getAttribute("before-hydration-url");s&&await import(s),this.start()}start(){const s=JSON.parse(this.getAttribute("opts")),e=this.getAttribute("client");if(Astro[e]===void 0){window.addEventListener(\`astro:\${e}\`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute("renderer-url"),[a,{default:r}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=a[i];else{this.Component=a;for(const d of i.split("."))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=["props"],l))}`;
|
|
2
2
|
export {
|
|
3
3
|
astro_island_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { escape } from 'html-escaper';
|
|
2
2
|
export declare const escapeHTML: typeof escape;
|
|
3
|
+
export declare class HTMLBytes extends Uint8Array {
|
|
4
|
+
get [Symbol.toStringTag](): string;
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* A "blessed" extension of String that tells Astro that the string
|
|
5
8
|
* has already been escaped. This helps prevent double-escaping of HTML.
|
|
6
9
|
*/
|
|
7
10
|
export declare class HTMLString extends String {
|
|
11
|
+
get [Symbol.toStringTag](): string;
|
|
8
12
|
}
|
|
13
|
+
declare type BlessedType = string | HTMLBytes;
|
|
9
14
|
/**
|
|
10
15
|
* markHTMLString marks a string as raw or "already escaped" by returning
|
|
11
16
|
* a `HTMLString` instance. This is meant for internal use, and should not
|
|
12
17
|
* be returned through any public JS API.
|
|
13
18
|
*/
|
|
14
19
|
export declare const markHTMLString: (value: any) => any;
|
|
20
|
+
export declare function isHTMLString(value: any): value is HTMLString;
|
|
21
|
+
export declare function isHTMLBytes(value: any): value is HTMLBytes;
|
|
22
|
+
export declare function unescapeHTML(str: any): BlessedType | Promise<BlessedType | AsyncGenerator<BlessedType, void, unknown>> | AsyncGenerator<BlessedType, void, unknown>;
|
|
23
|
+
export {};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { escape } from "html-escaper";
|
|
2
2
|
const escapeHTML = escape;
|
|
3
|
+
class HTMLBytes extends Uint8Array {
|
|
4
|
+
get [Symbol.toStringTag]() {
|
|
5
|
+
return "HTMLBytes";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
3
8
|
class HTMLString extends String {
|
|
9
|
+
get [Symbol.toStringTag]() {
|
|
10
|
+
return "HTMLString";
|
|
11
|
+
}
|
|
4
12
|
}
|
|
5
13
|
const markHTMLString = (value) => {
|
|
6
14
|
if (value instanceof HTMLString) {
|
|
@@ -11,8 +19,50 @@ const markHTMLString = (value) => {
|
|
|
11
19
|
}
|
|
12
20
|
return value;
|
|
13
21
|
};
|
|
22
|
+
function isHTMLString(value) {
|
|
23
|
+
return Object.prototype.toString.call(value) === "[object HTMLString]";
|
|
24
|
+
}
|
|
25
|
+
function markHTMLBytes(bytes) {
|
|
26
|
+
return new HTMLBytes(bytes);
|
|
27
|
+
}
|
|
28
|
+
function isHTMLBytes(value) {
|
|
29
|
+
return Object.prototype.toString.call(value) === "[object HTMLBytes]";
|
|
30
|
+
}
|
|
31
|
+
async function* unescapeChunksAsync(iterable) {
|
|
32
|
+
for await (const chunk of iterable) {
|
|
33
|
+
yield unescapeHTML(chunk);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function* unescapeChunks(iterable) {
|
|
37
|
+
for (const chunk of iterable) {
|
|
38
|
+
yield unescapeHTML(chunk);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function unescapeHTML(str) {
|
|
42
|
+
if (!!str && typeof str === "object") {
|
|
43
|
+
if (str instanceof Uint8Array) {
|
|
44
|
+
return markHTMLBytes(str);
|
|
45
|
+
} else if (str instanceof Response && str.body) {
|
|
46
|
+
const body = str.body;
|
|
47
|
+
return unescapeChunksAsync(body);
|
|
48
|
+
} else if (typeof str.then === "function") {
|
|
49
|
+
return Promise.resolve(str).then((value) => {
|
|
50
|
+
return unescapeHTML(value);
|
|
51
|
+
});
|
|
52
|
+
} else if (Symbol.iterator in str) {
|
|
53
|
+
return unescapeChunks(str);
|
|
54
|
+
} else if (Symbol.asyncIterator in str) {
|
|
55
|
+
return unescapeChunksAsync(str);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return markHTMLString(str);
|
|
59
|
+
}
|
|
14
60
|
export {
|
|
61
|
+
HTMLBytes,
|
|
15
62
|
HTMLString,
|
|
16
63
|
escapeHTML,
|
|
17
|
-
|
|
64
|
+
isHTMLBytes,
|
|
65
|
+
isHTMLString,
|
|
66
|
+
markHTMLString,
|
|
67
|
+
unescapeHTML
|
|
18
68
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createAstro } from './astro-global.js';
|
|
2
2
|
export { renderEndpoint } from './endpoint.js';
|
|
3
|
-
export { escapeHTML, HTMLString, markHTMLString,
|
|
3
|
+
export { escapeHTML, HTMLBytes, HTMLString, markHTMLString, unescapeHTML } from './escape.js';
|
|
4
4
|
export type { Metadata } from './metadata';
|
|
5
5
|
export { createMetadata } from './metadata.js';
|
|
6
6
|
export { addAttribute, defineScriptVars, Fragment, maybeRenderHead, renderAstroComponent, renderComponent, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderSlot, renderTemplate as render, renderTemplate, renderToString, stringifyChunk, voidElementNames, } from './render/index.js';
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { createAstro } from "./astro-global.js";
|
|
2
2
|
import { renderEndpoint } from "./endpoint.js";
|
|
3
|
-
import {
|
|
4
|
-
escapeHTML,
|
|
5
|
-
HTMLString,
|
|
6
|
-
markHTMLString,
|
|
7
|
-
markHTMLString as markHTMLString2
|
|
8
|
-
} from "./escape.js";
|
|
3
|
+
import { escapeHTML, HTMLBytes, HTMLString, markHTMLString, unescapeHTML } from "./escape.js";
|
|
9
4
|
import { createMetadata } from "./metadata.js";
|
|
10
5
|
import {
|
|
11
6
|
addAttribute,
|
|
@@ -25,7 +20,7 @@ import {
|
|
|
25
20
|
stringifyChunk,
|
|
26
21
|
voidElementNames
|
|
27
22
|
} from "./render/index.js";
|
|
28
|
-
import { markHTMLString as
|
|
23
|
+
import { markHTMLString as markHTMLString2 } from "./escape.js";
|
|
29
24
|
import { Renderer as Renderer2 } from "./render/index.js";
|
|
30
25
|
import { addAttribute as addAttribute2 } from "./render/index.js";
|
|
31
26
|
function createComponent(cb) {
|
|
@@ -70,7 +65,7 @@ function spreadAttributes(values, _name, { class: scopedClassName } = {}) {
|
|
|
70
65
|
for (const [key, value] of Object.entries(values)) {
|
|
71
66
|
output += addAttribute2(value, key, true);
|
|
72
67
|
}
|
|
73
|
-
return
|
|
68
|
+
return markHTMLString2(output);
|
|
74
69
|
}
|
|
75
70
|
function defineStyleVars(defs) {
|
|
76
71
|
let output = "";
|
|
@@ -82,10 +77,11 @@ function defineStyleVars(defs) {
|
|
|
82
77
|
}
|
|
83
78
|
}
|
|
84
79
|
}
|
|
85
|
-
return
|
|
80
|
+
return markHTMLString2(output);
|
|
86
81
|
}
|
|
87
82
|
export {
|
|
88
83
|
Fragment,
|
|
84
|
+
HTMLBytes,
|
|
89
85
|
HTMLString,
|
|
90
86
|
Renderer,
|
|
91
87
|
__astro_tag_component__,
|
|
@@ -111,6 +107,6 @@ export {
|
|
|
111
107
|
renderToString,
|
|
112
108
|
spreadAttributes,
|
|
113
109
|
stringifyChunk,
|
|
114
|
-
|
|
110
|
+
unescapeHTML,
|
|
115
111
|
voidElementNames
|
|
116
112
|
};
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
renderComponent,
|
|
7
7
|
renderToString,
|
|
8
8
|
spreadAttributes,
|
|
9
|
-
stringifyChunk,
|
|
10
9
|
voidElementNames
|
|
11
10
|
} from "./index.js";
|
|
11
|
+
import { HTMLParts } from "./render/common.js";
|
|
12
12
|
const ClientOnlyPlaceholder = "astro-client-only";
|
|
13
13
|
const skipAstroJSXCheck = /* @__PURE__ */ new WeakSet();
|
|
14
14
|
let originalConsoleError;
|
|
@@ -131,12 +131,11 @@ async function renderJSX(result, vnode) {
|
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
if (typeof output !== "string" && Symbol.asyncIterator in output) {
|
|
134
|
-
let
|
|
134
|
+
let parts = new HTMLParts();
|
|
135
135
|
for await (const chunk of output) {
|
|
136
|
-
|
|
137
|
-
body += html;
|
|
136
|
+
parts.append(chunk, result);
|
|
138
137
|
}
|
|
139
|
-
return markHTMLString(
|
|
138
|
+
return markHTMLString(parts.toString());
|
|
140
139
|
} else {
|
|
141
140
|
return markHTMLString(output);
|
|
142
141
|
}
|
|
@@ -16,7 +16,9 @@ async function* renderChild(child) {
|
|
|
16
16
|
} else if (!child && child !== 0) {
|
|
17
17
|
} else if (child instanceof AstroComponent || Object.prototype.toString.call(child) === "[object AstroComponent]") {
|
|
18
18
|
yield* renderAstroComponent(child);
|
|
19
|
-
} else if (
|
|
19
|
+
} else if (ArrayBuffer.isView(child)) {
|
|
20
|
+
yield child;
|
|
21
|
+
} else if (typeof child === "object" && (Symbol.asyncIterator in child || Symbol.iterator in child)) {
|
|
20
22
|
yield* child;
|
|
21
23
|
} else {
|
|
22
24
|
yield child;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro';
|
|
2
2
|
import type { AstroComponentFactory } from './index';
|
|
3
3
|
import type { RenderInstruction } from './types';
|
|
4
|
+
import { HTMLBytes } from '../escape.js';
|
|
4
5
|
export declare class AstroComponent {
|
|
5
6
|
private htmlParts;
|
|
6
7
|
private expressions;
|
|
@@ -10,7 +11,7 @@ export declare class AstroComponent {
|
|
|
10
11
|
}
|
|
11
12
|
export declare function isAstroComponent(obj: any): obj is AstroComponent;
|
|
12
13
|
export declare function isAstroComponentFactory(obj: any): obj is AstroComponentFactory;
|
|
13
|
-
export declare function renderAstroComponent(component: InstanceType<typeof AstroComponent>): AsyncIterable<string | RenderInstruction>;
|
|
14
|
+
export declare function renderAstroComponent(component: InstanceType<typeof AstroComponent>): AsyncIterable<string | HTMLBytes | RenderInstruction>;
|
|
14
15
|
export declare function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<string>;
|
|
15
|
-
export declare function renderToIterable(result: SSRResult, componentFactory: AstroComponentFactory, displayName: string, props: any, children: any): Promise<AsyncIterable<string | RenderInstruction>>;
|
|
16
|
+
export declare function renderToIterable(result: SSRResult, componentFactory: AstroComponentFactory, displayName: string, props: any, children: any): Promise<AsyncIterable<string | HTMLBytes | RenderInstruction>>;
|
|
16
17
|
export declare function renderTemplate(htmlParts: TemplateStringsArray, ...expressions: any[]): Promise<AstroComponent>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { markHTMLString } from "../escape.js";
|
|
2
2
|
import { HydrationDirectiveProps } from "../hydration.js";
|
|
3
3
|
import { renderChild } from "./any.js";
|
|
4
|
-
import {
|
|
4
|
+
import { HTMLParts } from "./common.js";
|
|
5
5
|
function validateComponentProps(props, displayName) {
|
|
6
6
|
var _a;
|
|
7
7
|
if (((_a = import.meta.env) == null ? void 0 : _a.DEV) && props != null) {
|
|
@@ -62,11 +62,11 @@ async function renderToString(result, componentFactory, props, children) {
|
|
|
62
62
|
const response = Component;
|
|
63
63
|
throw response;
|
|
64
64
|
}
|
|
65
|
-
let
|
|
65
|
+
let parts = new HTMLParts();
|
|
66
66
|
for await (const chunk of renderAstroComponent(Component)) {
|
|
67
|
-
|
|
67
|
+
parts.append(chunk, result);
|
|
68
68
|
}
|
|
69
|
-
return
|
|
69
|
+
return parts.toString();
|
|
70
70
|
}
|
|
71
71
|
async function renderToIterable(result, componentFactory, displayName, props, children) {
|
|
72
72
|
validateComponentProps(props, displayName);
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro';
|
|
2
2
|
import type { RenderInstruction } from './types.js';
|
|
3
|
+
import { HTMLBytes } from '../escape.js';
|
|
3
4
|
export declare const Fragment: unique symbol;
|
|
4
5
|
export declare const Renderer: unique symbol;
|
|
6
|
+
export declare const encoder: TextEncoder;
|
|
7
|
+
export declare const decoder: TextDecoder;
|
|
5
8
|
export declare function stringifyChunk(result: SSRResult, chunk: string | RenderInstruction): any;
|
|
9
|
+
export declare class HTMLParts {
|
|
10
|
+
parts: Array<HTMLBytes | string>;
|
|
11
|
+
constructor();
|
|
12
|
+
append(part: string | HTMLBytes | RenderInstruction, result: SSRResult): void;
|
|
13
|
+
toString(): string;
|
|
14
|
+
toArrayBuffer(): Uint8Array;
|
|
15
|
+
}
|
|
16
|
+
export declare function chunkToByteArray(result: SSRResult, chunk: string | HTMLBytes | RenderInstruction): Uint8Array;
|
|
17
|
+
export declare function concatUint8Arrays(arrays: Array<Uint8Array>): Uint8Array;
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
} from "../scripts.js";
|
|
7
7
|
const Fragment = Symbol.for("astro:fragment");
|
|
8
8
|
const Renderer = Symbol.for("astro:renderer");
|
|
9
|
+
const encoder = new TextEncoder();
|
|
10
|
+
const decoder = new TextDecoder();
|
|
9
11
|
function stringifyChunk(result, chunk) {
|
|
10
12
|
switch (chunk.type) {
|
|
11
13
|
case "directive": {
|
|
@@ -25,8 +27,61 @@ function stringifyChunk(result, chunk) {
|
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
}
|
|
30
|
+
class HTMLParts {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.parts = [];
|
|
33
|
+
}
|
|
34
|
+
append(part, result) {
|
|
35
|
+
if (ArrayBuffer.isView(part)) {
|
|
36
|
+
this.parts.push(part);
|
|
37
|
+
} else {
|
|
38
|
+
this.parts.push(stringifyChunk(result, part));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
toString() {
|
|
42
|
+
let html = "";
|
|
43
|
+
for (const part of this.parts) {
|
|
44
|
+
if (ArrayBuffer.isView(part)) {
|
|
45
|
+
html += decoder.decode(part);
|
|
46
|
+
} else {
|
|
47
|
+
html += part;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return html;
|
|
51
|
+
}
|
|
52
|
+
toArrayBuffer() {
|
|
53
|
+
this.parts.forEach((part, i) => {
|
|
54
|
+
if (typeof part === "string") {
|
|
55
|
+
this.parts[i] = encoder.encode(String(part));
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return concatUint8Arrays(this.parts);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function chunkToByteArray(result, chunk) {
|
|
62
|
+
if (chunk instanceof Uint8Array) {
|
|
63
|
+
return chunk;
|
|
64
|
+
}
|
|
65
|
+
return encoder.encode(stringifyChunk(result, chunk));
|
|
66
|
+
}
|
|
67
|
+
function concatUint8Arrays(arrays) {
|
|
68
|
+
let len = 0;
|
|
69
|
+
arrays.forEach((arr) => len += arr.length);
|
|
70
|
+
let merged = new Uint8Array(len);
|
|
71
|
+
let offset = 0;
|
|
72
|
+
arrays.forEach((arr) => {
|
|
73
|
+
merged.set(arr, offset);
|
|
74
|
+
offset += arr.length;
|
|
75
|
+
});
|
|
76
|
+
return merged;
|
|
77
|
+
}
|
|
28
78
|
export {
|
|
29
79
|
Fragment,
|
|
80
|
+
HTMLParts,
|
|
30
81
|
Renderer,
|
|
82
|
+
chunkToByteArray,
|
|
83
|
+
concatUint8Arrays,
|
|
84
|
+
decoder,
|
|
85
|
+
encoder,
|
|
31
86
|
stringifyChunk
|
|
32
87
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro';
|
|
2
2
|
import type { RenderInstruction } from './types.js';
|
|
3
|
-
|
|
3
|
+
import { HTMLBytes } from '../escape.js';
|
|
4
|
+
export declare function renderComponent(result: SSRResult, displayName: string, Component: unknown, _props: Record<string | number, any>, slots?: any): Promise<string | AsyncIterable<string | HTMLBytes | RenderInstruction>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { isHTMLString } from "../escape.js";
|
|
1
2
|
import { createResponse } from "../response.js";
|
|
2
3
|
import { isAstroComponent, isAstroComponentFactory, renderAstroComponent } from "./astro.js";
|
|
3
|
-
import {
|
|
4
|
+
import { chunkToByteArray, encoder, HTMLParts } from "./common.js";
|
|
4
5
|
import { renderComponent } from "./component.js";
|
|
5
6
|
import { maybeRenderHead } from "./head.js";
|
|
6
|
-
const encoder = new TextEncoder();
|
|
7
7
|
const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
|
|
8
8
|
function nonAstroPageNeedsHeadInjection(pageComponent) {
|
|
9
9
|
return needsHeadRenderingSymbol in pageComponent && !!pageComponent[needsHeadRenderingSymbol];
|
|
@@ -50,13 +50,15 @@ async function renderPage(result, componentFactory, props, children, streaming)
|
|
|
50
50
|
let i = 0;
|
|
51
51
|
try {
|
|
52
52
|
for await (const chunk of iterable) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
if (isHTMLString(chunk)) {
|
|
54
|
+
if (i === 0) {
|
|
55
|
+
if (!/<!doctype html/i.test(String(chunk))) {
|
|
56
|
+
controller.enqueue(encoder.encode("<!DOCTYPE html>\n"));
|
|
57
|
+
}
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
+
let bytes = chunkToByteArray(result, chunk);
|
|
61
|
+
controller.enqueue(bytes);
|
|
60
62
|
i++;
|
|
61
63
|
}
|
|
62
64
|
controller.close();
|
|
@@ -68,20 +70,21 @@ async function renderPage(result, componentFactory, props, children, streaming)
|
|
|
68
70
|
}
|
|
69
71
|
});
|
|
70
72
|
} else {
|
|
71
|
-
|
|
73
|
+
let parts = new HTMLParts();
|
|
72
74
|
let i = 0;
|
|
73
75
|
for await (const chunk of iterable) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
if (isHTMLString(chunk)) {
|
|
77
|
+
if (i === 0) {
|
|
78
|
+
if (!/<!doctype html/i.test(String(chunk))) {
|
|
79
|
+
parts.append("<!DOCTYPE html>\n", result);
|
|
80
|
+
}
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
|
-
|
|
83
|
+
parts.append(chunk, result);
|
|
81
84
|
i++;
|
|
82
85
|
}
|
|
83
|
-
|
|
84
|
-
headers.set("Content-Length",
|
|
86
|
+
body = parts.toArrayBuffer();
|
|
87
|
+
headers.set("Content-Length", body.byteLength.toString());
|
|
85
88
|
}
|
|
86
89
|
let response = createResponse(body, { ...init, headers });
|
|
87
90
|
return response;
|
|
@@ -67,7 +67,7 @@ function createResponseClass() {
|
|
|
67
67
|
return StreamingCompatibleResponse;
|
|
68
68
|
}
|
|
69
69
|
const createResponse = isNodeJS ? (body, init) => {
|
|
70
|
-
if (typeof body === "string") {
|
|
70
|
+
if (typeof body === "string" || ArrayBuffer.isView(body)) {
|
|
71
71
|
return new Response(body, init);
|
|
72
72
|
}
|
|
73
73
|
if (typeof StreamingCompatibleResponse === "undefined") {
|
|
@@ -6,7 +6,10 @@ const PROP_TYPE = {
|
|
|
6
6
|
Map: 4,
|
|
7
7
|
Set: 5,
|
|
8
8
|
BigInt: 6,
|
|
9
|
-
URL: 7
|
|
9
|
+
URL: 7,
|
|
10
|
+
Uint8Array: 8,
|
|
11
|
+
Uint16Array: 9,
|
|
12
|
+
Uint32Array: 10
|
|
10
13
|
};
|
|
11
14
|
function serializeArray(value, metadata = {}, parents = /* @__PURE__ */ new WeakSet()) {
|
|
12
15
|
if (parents.has(value)) {
|
|
@@ -66,6 +69,15 @@ function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */
|
|
|
66
69
|
case "[object Array]": {
|
|
67
70
|
return [PROP_TYPE.JSON, JSON.stringify(serializeArray(value, metadata, parents))];
|
|
68
71
|
}
|
|
72
|
+
case "[object Uint8Array]": {
|
|
73
|
+
return [PROP_TYPE.Uint8Array, JSON.stringify(Array.from(value))];
|
|
74
|
+
}
|
|
75
|
+
case "[object Uint16Array]": {
|
|
76
|
+
return [PROP_TYPE.Uint16Array, JSON.stringify(Array.from(value))];
|
|
77
|
+
}
|
|
78
|
+
case "[object Uint32Array]": {
|
|
79
|
+
return [PROP_TYPE.Uint32Array, JSON.stringify(Array.from(value))];
|
|
80
|
+
}
|
|
69
81
|
default: {
|
|
70
82
|
if (value !== null && typeof value === "object") {
|
|
71
83
|
return [PROP_TYPE.Value, serializeObject(value, metadata, parents)];
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
function formatList(values) {
|
|
2
|
-
if (values.length === 1) {
|
|
3
|
-
return values[0];
|
|
4
|
-
}
|
|
5
|
-
return `${values.slice(0, -1).join(", ")} or ${values[values.length - 1]}`;
|
|
6
|
-
}
|
|
7
1
|
function serializeListValue(value) {
|
|
8
2
|
const hash = {};
|
|
9
3
|
push(value);
|
|
@@ -26,6 +20,10 @@ function serializeListValue(value) {
|
|
|
26
20
|
}
|
|
27
21
|
}
|
|
28
22
|
}
|
|
23
|
+
function isPromise(value) {
|
|
24
|
+
return !!value && typeof value === "object" && typeof value.then === "function";
|
|
25
|
+
}
|
|
29
26
|
export {
|
|
27
|
+
isPromise,
|
|
30
28
|
serializeListValue
|
|
31
29
|
};
|
|
@@ -36,27 +36,59 @@ function tagExportsWithRenderer({
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
ExportDeclaration
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
ExportDeclaration: {
|
|
40
|
+
enter(path) {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
const node = path.node;
|
|
43
|
+
if (node.type !== "ExportDefaultDeclaration")
|
|
44
|
+
return;
|
|
45
|
+
if (((_a = node.declaration) == null ? void 0 : _a.type) === "ArrowFunctionExpression") {
|
|
46
|
+
const uidIdentifier = path.scope.generateUidIdentifier("_arrow_function");
|
|
47
|
+
path.insertBefore(
|
|
48
|
+
t.variableDeclaration("const", [
|
|
49
|
+
t.variableDeclarator(uidIdentifier, node.declaration)
|
|
50
|
+
])
|
|
51
|
+
);
|
|
52
|
+
node.declaration = uidIdentifier;
|
|
53
|
+
} else if (((_b = node.declaration) == null ? void 0 : _b.type) === "FunctionDeclaration" && !((_c = node.declaration.id) == null ? void 0 : _c.name)) {
|
|
54
|
+
const uidIdentifier = path.scope.generateUidIdentifier("_function");
|
|
55
|
+
node.declaration.id = uidIdentifier;
|
|
53
56
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
},
|
|
58
|
+
exit(path, state) {
|
|
59
|
+
var _a, _b, _c;
|
|
60
|
+
const node = path.node;
|
|
61
|
+
if (node.exportKind === "type")
|
|
62
|
+
return;
|
|
63
|
+
if (node.type === "ExportAllDeclaration")
|
|
64
|
+
return;
|
|
65
|
+
const addTag = (id) => {
|
|
66
|
+
const tags = state.get("astro:tags") ?? [];
|
|
67
|
+
state.set("astro:tags", [...tags, id]);
|
|
68
|
+
};
|
|
69
|
+
if (node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") {
|
|
70
|
+
if (t.isIdentifier(node.declaration)) {
|
|
71
|
+
addTag(node.declaration.name);
|
|
72
|
+
} else if (t.isFunctionDeclaration(node.declaration) && ((_a = node.declaration.id) == null ? void 0 : _a.name)) {
|
|
73
|
+
addTag(node.declaration.id.name);
|
|
74
|
+
} else if (t.isVariableDeclaration(node.declaration)) {
|
|
75
|
+
(_b = node.declaration.declarations) == null ? void 0 : _b.forEach((declaration) => {
|
|
76
|
+
if (t.isArrowFunctionExpression(declaration.init) && t.isIdentifier(declaration.id)) {
|
|
77
|
+
addTag(declaration.id.name);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
} else if (t.isObjectExpression(node.declaration)) {
|
|
81
|
+
(_c = node.declaration.properties) == null ? void 0 : _c.forEach((property) => {
|
|
82
|
+
if (t.isProperty(property) && t.isIdentifier(property.key)) {
|
|
83
|
+
addTag(property.key.name);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
} else if (t.isExportNamedDeclaration(node)) {
|
|
87
|
+
node.specifiers.forEach((specifier) => {
|
|
88
|
+
if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
|
|
89
|
+
addTag(specifier.local.name);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
60
92
|
}
|
|
61
93
|
}
|
|
62
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
],
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@astrojs/compiler": "^0.24.0",
|
|
86
|
-
"@astrojs/language-server": "^0.
|
|
87
|
-
"@astrojs/markdown-remark": "^1.1.
|
|
86
|
+
"@astrojs/language-server": "^0.26.2",
|
|
87
|
+
"@astrojs/markdown-remark": "^1.1.2",
|
|
88
88
|
"@astrojs/telemetry": "^1.0.0",
|
|
89
89
|
"@astrojs/webapi": "^1.0.0",
|
|
90
90
|
"@babel/core": "^7.18.2",
|
|
@@ -134,6 +134,7 @@
|
|
|
134
134
|
"strip-ansi": "^7.0.1",
|
|
135
135
|
"supports-esm": "^1.0.0",
|
|
136
136
|
"tsconfig-resolver": "^3.0.1",
|
|
137
|
+
"typescript": "*",
|
|
137
138
|
"unist-util-visit": "^4.1.0",
|
|
138
139
|
"vfile": "^5.3.2",
|
|
139
140
|
"vite": "~3.1.3",
|