astro 2.10.3 → 2.10.5
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/content-types.template.d.ts +3 -1
- package/dist/@types/astro.d.ts +27 -3
- package/dist/core/app/index.js +1 -2
- package/dist/core/build/plugins/index.js +1 -1
- package/dist/core/build/plugins/plugin-analyzer.d.ts +3 -2
- package/dist/core/build/plugins/plugin-analyzer.js +24 -25
- package/dist/core/config/schema.d.ts +16 -0
- package/dist/core/config/schema.js +4 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/index.d.ts +2 -5
- package/dist/core/endpoint/index.js +1 -2
- package/dist/core/messages.js +2 -2
- package/dist/jsx/renderer.js +3 -4
- package/dist/runtime/server/astro-island.js +15 -11
- 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/serialize.js +7 -12
- package/dist/vite-plugin-astro-server/route.js +8 -5
- package/package.json +1 -1
|
@@ -10,7 +10,9 @@ declare module 'astro:content' {
|
|
|
10
10
|
|
|
11
11
|
declare module 'astro:content' {
|
|
12
12
|
export { z } from 'astro/zod';
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
|
|
15
|
+
export type CollectionEntry<C extends keyof AnyEntryMap> = Flatten<AnyEntryMap[C]>;
|
|
14
16
|
|
|
15
17
|
// TODO: Remove this when having this fallback is no longer relevant. 2.3? 3.0? - erika, 2023-04-04
|
|
16
18
|
/**
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1186,6 +1186,27 @@ export interface AstroUserConfig {
|
|
|
1186
1186
|
* ```
|
|
1187
1187
|
*/
|
|
1188
1188
|
viewTransitions?: boolean;
|
|
1189
|
+
/**
|
|
1190
|
+
* @docs
|
|
1191
|
+
* @name experimental.optimizeHoistedScript
|
|
1192
|
+
* @type {boolean}
|
|
1193
|
+
* @default `false`
|
|
1194
|
+
* @version 2.10.4
|
|
1195
|
+
* @description
|
|
1196
|
+
* Prevents unused components' scripts from being included in a page unexpectedly.
|
|
1197
|
+
* The optimization is best-effort and may inversely miss including the used scripts. Make sure to double-check your built pages
|
|
1198
|
+
* before publishing.
|
|
1199
|
+
* Enable hoisted script analysis optimization by adding the experimental flag:
|
|
1200
|
+
*
|
|
1201
|
+
* ```js
|
|
1202
|
+
* {
|
|
1203
|
+
* experimental: {
|
|
1204
|
+
* optimizeHoistedScript: true,
|
|
1205
|
+
* },
|
|
1206
|
+
* }
|
|
1207
|
+
* ```
|
|
1208
|
+
*/
|
|
1209
|
+
optimizeHoistedScript?: boolean;
|
|
1189
1210
|
};
|
|
1190
1211
|
/** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
|
|
1191
1212
|
renderers?: never;
|
|
@@ -1653,10 +1674,13 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
1653
1674
|
*/
|
|
1654
1675
|
locals: App.Locals;
|
|
1655
1676
|
}
|
|
1656
|
-
export
|
|
1677
|
+
export type EndpointOutput = {
|
|
1657
1678
|
body: Body;
|
|
1658
|
-
encoding?: BufferEncoding
|
|
1659
|
-
}
|
|
1679
|
+
encoding?: Exclude<BufferEncoding, 'binary'>;
|
|
1680
|
+
} | {
|
|
1681
|
+
body: Uint8Array;
|
|
1682
|
+
encoding: 'binary';
|
|
1683
|
+
};
|
|
1660
1684
|
export type APIRoute<Props extends Record<string, any> = Record<string, any>> = (context: APIContext<Props>) => EndpointOutput | Response | Promise<EndpointOutput | Response>;
|
|
1661
1685
|
export interface EndpointHandler {
|
|
1662
1686
|
[method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response);
|
package/dist/core/app/index.js
CHANGED
|
@@ -162,7 +162,6 @@ class App {
|
|
|
162
162
|
}
|
|
163
163
|
return response.response;
|
|
164
164
|
} else {
|
|
165
|
-
const body = response.body;
|
|
166
165
|
const headers = new Headers();
|
|
167
166
|
const mimeType = mime.getType(url.pathname);
|
|
168
167
|
if (mimeType) {
|
|
@@ -170,7 +169,7 @@ class App {
|
|
|
170
169
|
} else {
|
|
171
170
|
headers.set("Content-Type", "text/plain;charset=utf-8");
|
|
172
171
|
}
|
|
173
|
-
const bytes = this.#encoder.encode(body);
|
|
172
|
+
const bytes = response.encoding !== "binary" ? this.#encoder.encode(response.body) : response.body;
|
|
174
173
|
headers.set("Content-Length", bytes.byteLength.toString());
|
|
175
174
|
const newResponse = new Response(bytes, {
|
|
176
175
|
status: 200,
|
|
@@ -14,7 +14,7 @@ import { pluginSSR, pluginSSRSplit } from "./plugin-ssr.js";
|
|
|
14
14
|
function registerAllPlugins({ internals, options, register }) {
|
|
15
15
|
register(pluginComponentEntry(internals));
|
|
16
16
|
register(pluginAliasResolve(internals));
|
|
17
|
-
register(pluginAnalyzer(internals));
|
|
17
|
+
register(pluginAnalyzer(options, internals));
|
|
18
18
|
register(pluginInternals(internals));
|
|
19
19
|
register(pluginRenderers(options));
|
|
20
20
|
register(pluginMiddleware(options, internals));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Plugin as VitePlugin } from 'vite';
|
|
2
2
|
import type { BuildInternals } from '../internal.js';
|
|
3
3
|
import type { AstroBuildPlugin } from '../plugin.js';
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
4
|
+
import type { StaticBuildOptions } from '../types.js';
|
|
5
|
+
export declare function vitePluginAnalyzer(options: StaticBuildOptions, internals: BuildInternals): VitePlugin;
|
|
6
|
+
export declare function pluginAnalyzer(options: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { walk } from "estree-walker";
|
|
2
1
|
import { PROPAGATED_ASSET_FLAG } from "../../../content/consts.js";
|
|
3
2
|
import { prependForwardSlash } from "../../../core/path.js";
|
|
4
3
|
import { getTopLevelPages, moduleIsTopLevelPage, walkParentInfos } from "../graph.js";
|
|
@@ -19,15 +18,13 @@ async function doesParentImportChild(parentInfo, childInfo, childExportNames) {
|
|
|
19
18
|
}
|
|
20
19
|
const imports = [];
|
|
21
20
|
const exports = [];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
exports.push(node);
|
|
28
|
-
}
|
|
21
|
+
for (const node of parentInfo.ast.body) {
|
|
22
|
+
if (node.type === "ImportDeclaration") {
|
|
23
|
+
imports.push(node);
|
|
24
|
+
} else if (node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration") {
|
|
25
|
+
exports.push(node);
|
|
29
26
|
}
|
|
30
|
-
}
|
|
27
|
+
}
|
|
31
28
|
const importNames = [];
|
|
32
29
|
const exportNames = [];
|
|
33
30
|
for (const node of imports) {
|
|
@@ -89,7 +86,7 @@ async function doesParentImportChild(parentInfo, childInfo, childExportNames) {
|
|
|
89
86
|
}
|
|
90
87
|
return exportNames;
|
|
91
88
|
}
|
|
92
|
-
function vitePluginAnalyzer(internals) {
|
|
89
|
+
function vitePluginAnalyzer(options, internals) {
|
|
93
90
|
function hoistedScriptScanner() {
|
|
94
91
|
const uniqueHoistedIds = /* @__PURE__ */ new Map();
|
|
95
92
|
const pageScripts = /* @__PURE__ */ new Map();
|
|
@@ -108,20 +105,22 @@ function vitePluginAnalyzer(internals) {
|
|
|
108
105
|
for (const [parentInfo, depth] of walkParentInfos(from, this, function until(importer) {
|
|
109
106
|
return isPropagatedAsset(importer);
|
|
110
107
|
})) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
if (options.settings.config.experimental.optimizeHoistedScript) {
|
|
109
|
+
depthsToChildren.set(depth, parentInfo);
|
|
110
|
+
if (depth > 0) {
|
|
111
|
+
const childInfo = depthsToChildren.get(depth - 1);
|
|
112
|
+
const childExportNames = depthsToExportNames.get(depth - 1);
|
|
113
|
+
const doesImport = await doesParentImportChild.call(
|
|
114
|
+
this,
|
|
115
|
+
parentInfo,
|
|
116
|
+
childInfo,
|
|
117
|
+
childExportNames
|
|
118
|
+
);
|
|
119
|
+
if (doesImport === "no") {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
depthsToExportNames.set(depth, doesImport);
|
|
123
123
|
}
|
|
124
|
-
depthsToExportNames.set(depth, doesImport);
|
|
125
124
|
}
|
|
126
125
|
if (isPropagatedAsset(parentInfo.id)) {
|
|
127
126
|
for (const [nestedParentInfo] of walkParentInfos(from, this)) {
|
|
@@ -241,13 +240,13 @@ function vitePluginAnalyzer(internals) {
|
|
|
241
240
|
}
|
|
242
241
|
};
|
|
243
242
|
}
|
|
244
|
-
function pluginAnalyzer(internals) {
|
|
243
|
+
function pluginAnalyzer(options, internals) {
|
|
245
244
|
return {
|
|
246
245
|
build: "ssr",
|
|
247
246
|
hooks: {
|
|
248
247
|
"build:before": () => {
|
|
249
248
|
return {
|
|
250
|
-
vitePlugin: vitePluginAnalyzer(internals)
|
|
249
|
+
vitePlugin: vitePluginAnalyzer(options, internals)
|
|
251
250
|
};
|
|
252
251
|
}
|
|
253
252
|
}
|
|
@@ -179,18 +179,23 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
179
179
|
experimental: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
180
180
|
assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
181
181
|
viewTransitions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
182
|
+
optimizeHoistedScript: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
182
183
|
}, "passthrough", z.ZodTypeAny, {
|
|
183
184
|
assets: boolean;
|
|
184
185
|
viewTransitions: boolean;
|
|
186
|
+
optimizeHoistedScript: boolean;
|
|
185
187
|
}, {
|
|
186
188
|
assets?: boolean | undefined;
|
|
187
189
|
viewTransitions?: boolean | undefined;
|
|
190
|
+
optimizeHoistedScript?: boolean | undefined;
|
|
188
191
|
}>, {
|
|
189
192
|
assets: boolean;
|
|
190
193
|
viewTransitions: boolean;
|
|
194
|
+
optimizeHoistedScript: boolean;
|
|
191
195
|
}, {
|
|
192
196
|
assets?: boolean | undefined;
|
|
193
197
|
viewTransitions?: boolean | undefined;
|
|
198
|
+
optimizeHoistedScript?: boolean | undefined;
|
|
194
199
|
}>>>;
|
|
195
200
|
legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
|
|
196
201
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -259,6 +264,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
259
264
|
experimental: {
|
|
260
265
|
assets: boolean;
|
|
261
266
|
viewTransitions: boolean;
|
|
267
|
+
optimizeHoistedScript: boolean;
|
|
262
268
|
};
|
|
263
269
|
legacy: {};
|
|
264
270
|
}, {
|
|
@@ -319,6 +325,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
319
325
|
experimental?: {
|
|
320
326
|
assets?: boolean | undefined;
|
|
321
327
|
viewTransitions?: boolean | undefined;
|
|
328
|
+
optimizeHoistedScript?: boolean | undefined;
|
|
322
329
|
} | undefined;
|
|
323
330
|
legacy?: {} | undefined;
|
|
324
331
|
}>;
|
|
@@ -435,18 +442,23 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
435
442
|
experimental: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
436
443
|
assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
437
444
|
viewTransitions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
445
|
+
optimizeHoistedScript: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
438
446
|
}, "passthrough", z.ZodTypeAny, {
|
|
439
447
|
assets: boolean;
|
|
440
448
|
viewTransitions: boolean;
|
|
449
|
+
optimizeHoistedScript: boolean;
|
|
441
450
|
}, {
|
|
442
451
|
assets?: boolean | undefined;
|
|
443
452
|
viewTransitions?: boolean | undefined;
|
|
453
|
+
optimizeHoistedScript?: boolean | undefined;
|
|
444
454
|
}>, {
|
|
445
455
|
assets: boolean;
|
|
446
456
|
viewTransitions: boolean;
|
|
457
|
+
optimizeHoistedScript: boolean;
|
|
447
458
|
}, {
|
|
448
459
|
assets?: boolean | undefined;
|
|
449
460
|
viewTransitions?: boolean | undefined;
|
|
461
|
+
optimizeHoistedScript?: boolean | undefined;
|
|
450
462
|
}>>>;
|
|
451
463
|
legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
|
|
452
464
|
root: z.ZodEffects<z.ZodDefault<z.ZodString>, import("url").URL, string | undefined>;
|
|
@@ -581,6 +593,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
581
593
|
experimental: {
|
|
582
594
|
assets: boolean;
|
|
583
595
|
viewTransitions: boolean;
|
|
596
|
+
optimizeHoistedScript: boolean;
|
|
584
597
|
};
|
|
585
598
|
legacy: {};
|
|
586
599
|
}, {
|
|
@@ -641,6 +654,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
641
654
|
experimental?: {
|
|
642
655
|
assets?: boolean | undefined;
|
|
643
656
|
viewTransitions?: boolean | undefined;
|
|
657
|
+
optimizeHoistedScript?: boolean | undefined;
|
|
644
658
|
} | undefined;
|
|
645
659
|
legacy?: {} | undefined;
|
|
646
660
|
}>, {
|
|
@@ -710,6 +724,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
710
724
|
experimental: {
|
|
711
725
|
assets: boolean;
|
|
712
726
|
viewTransitions: boolean;
|
|
727
|
+
optimizeHoistedScript: boolean;
|
|
713
728
|
};
|
|
714
729
|
legacy: {};
|
|
715
730
|
}, {
|
|
@@ -770,6 +785,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
770
785
|
experimental?: {
|
|
771
786
|
assets?: boolean | undefined;
|
|
772
787
|
viewTransitions?: boolean | undefined;
|
|
788
|
+
optimizeHoistedScript?: boolean | undefined;
|
|
773
789
|
} | undefined;
|
|
774
790
|
legacy?: {} | undefined;
|
|
775
791
|
}>;
|
|
@@ -39,7 +39,8 @@ const ASTRO_CONFIG_DEFAULTS = {
|
|
|
39
39
|
redirects: {},
|
|
40
40
|
experimental: {
|
|
41
41
|
assets: false,
|
|
42
|
-
viewTransitions: false
|
|
42
|
+
viewTransitions: false,
|
|
43
|
+
optimizeHoistedScript: false
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
46
|
const AstroConfigSchema = z.object({
|
|
@@ -143,7 +144,8 @@ const AstroConfigSchema = z.object({
|
|
|
143
144
|
vite: z.custom((data) => data instanceof Object && !Array.isArray(data)).default(ASTRO_CONFIG_DEFAULTS.vite),
|
|
144
145
|
experimental: z.object({
|
|
145
146
|
assets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.assets),
|
|
146
|
-
viewTransitions: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.viewTransitions)
|
|
147
|
+
viewTransitions: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.viewTransitions),
|
|
148
|
+
optimizeHoistedScript: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.optimizeHoistedScript)
|
|
147
149
|
}).passthrough().refine(
|
|
148
150
|
(d) => {
|
|
149
151
|
const validKeys = Object.keys(ASTRO_CONFIG_DEFAULTS.experimental);
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
|
|
|
23
23
|
base: restart.container.settings.config.base
|
|
24
24
|
})
|
|
25
25
|
);
|
|
26
|
-
const currentVersion = "2.10.
|
|
26
|
+
const currentVersion = "2.10.5";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
warn(logging, null, msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { APIContext, EndpointHandler, EndpointOutput, MiddlewareHandler, Params } from '../../@types/astro';
|
|
3
2
|
import type { Environment, RenderContext } from '../render/index';
|
|
4
3
|
import { AstroCookies } from '../cookies/index.js';
|
|
5
|
-
export type EndpointCallResult = {
|
|
4
|
+
export type EndpointCallResult = (EndpointOutput & {
|
|
6
5
|
type: 'simple';
|
|
7
|
-
body: string;
|
|
8
|
-
encoding?: BufferEncoding;
|
|
9
6
|
cookies: AstroCookies;
|
|
10
|
-
} | {
|
|
7
|
+
}) | {
|
|
11
8
|
type: 'response';
|
|
12
9
|
response: Response;
|
|
13
10
|
};
|
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.10.
|
|
50
|
+
const version = "2.10.5";
|
|
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.10.
|
|
236
|
+
`v${"2.10.5"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
package/dist/jsx/renderer.js
CHANGED
|
@@ -3,10 +3,9 @@ const renderer = {
|
|
|
3
3
|
serverEntrypoint: "astro/jsx/server.js",
|
|
4
4
|
jsxImportSource: "astro",
|
|
5
5
|
jsxTransformOptions: async () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = await import("@babel/plugin-transform-react-jsx");
|
|
6
|
+
var _a;
|
|
7
|
+
const plugin = await import("@babel/plugin-transform-react-jsx");
|
|
8
|
+
const jsx = ((_a = plugin.default) == null ? void 0 : _a.default) ?? plugin.default;
|
|
10
9
|
const { default: astroJSX } = await import("./babel.js");
|
|
11
10
|
return {
|
|
12
11
|
plugins: [
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
{
|
|
3
3
|
const propTypes = {
|
|
4
|
-
0: (value) => value,
|
|
5
|
-
1: (value) =>
|
|
4
|
+
0: (value) => reviveObject(value),
|
|
5
|
+
1: (value) => reviveArray(value),
|
|
6
6
|
2: (value) => new RegExp(value),
|
|
7
7
|
3: (value) => new Date(value),
|
|
8
|
-
4: (value) => new Map(
|
|
9
|
-
5: (value) => new Set(
|
|
8
|
+
4: (value) => new Map(reviveArray(value)),
|
|
9
|
+
5: (value) => new Set(reviveArray(value)),
|
|
10
10
|
6: (value) => BigInt(value),
|
|
11
11
|
7: (value) => new URL(value),
|
|
12
|
-
8: (value) => new Uint8Array(
|
|
13
|
-
9: (value) => new Uint16Array(
|
|
14
|
-
10: (value) => new Uint32Array(
|
|
12
|
+
8: (value) => new Uint8Array(value),
|
|
13
|
+
9: (value) => new Uint16Array(value),
|
|
14
|
+
10: (value) => new Uint32Array(value)
|
|
15
15
|
};
|
|
16
|
-
const
|
|
17
|
-
if (propKey === "" || !Array.isArray(raw))
|
|
18
|
-
return raw;
|
|
16
|
+
const reviveTuple = (raw) => {
|
|
19
17
|
const [type, value] = raw;
|
|
20
18
|
return type in propTypes ? propTypes[type](value) : void 0;
|
|
21
19
|
};
|
|
20
|
+
const reviveArray = (raw) => raw.map(reviveTuple);
|
|
21
|
+
const reviveObject = (raw) => {
|
|
22
|
+
if (typeof raw !== "object" || raw === null)
|
|
23
|
+
return raw;
|
|
24
|
+
return Object.fromEntries(Object.entries(raw).map(([key, value]) => [key, reviveTuple(value)]));
|
|
25
|
+
};
|
|
22
26
|
if (!customElements.get("astro-island")) {
|
|
23
27
|
customElements.define(
|
|
24
28
|
"astro-island",
|
|
@@ -54,7 +58,7 @@ var _a;
|
|
|
54
58
|
}
|
|
55
59
|
let props;
|
|
56
60
|
try {
|
|
57
|
-
props = this.hasAttribute("props") ? JSON.parse(this.getAttribute("props")
|
|
61
|
+
props = this.hasAttribute("props") ? reviveObject(JSON.parse(this.getAttribute("props"))) : {};
|
|
58
62
|
} catch (e) {
|
|
59
63
|
let componentName = this.getAttribute("component-url") || "<unknown>";
|
|
60
64
|
const componentExport = this.getAttribute("component-export");
|
|
@@ -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 d;{let p={0:t=>t,1:t=>
|
|
6
|
+
declare const _default: "(()=>{var d;{let p={0:t=>u(t),1:t=>l(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(l(t)),5:t=>new Set(l(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t)},h=t=>{let[e,n]=t;return e in p?p[e](n):void 0},l=t=>t.map(h),u=t=>typeof t!=\"object\"||t===null?t:Object.fromEntries(Object.entries(t).map(([e,n])=>[e,h(n)]));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 n=this.querySelectorAll(\"astro-slot\"),o={},a=this.querySelectorAll(\"template[data-astro-template]\");for(let r of a){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(let r of n){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}let c;try{c=this.hasAttribute(\"props\")?u(JSON.parse(this.getAttribute(\"props\"))):{}}catch(r){let s=this.getAttribute(\"component-url\")||\"<unknown>\",y=this.getAttribute(\"component-export\");throw y&&(s+=` (export ${y})`),console.error(`[hydrate] Error parsing props for component ${s}`,this.getAttribute(\"props\"),r),r}await this.hydrator(this)(this.Component,c,o,{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,n)=>{n.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\")),n=this.getAttribute(\"client\");if(Astro[n]===void 0){window.addEventListener(`astro:${n}`,()=>this.start(),{once:!0});return}Astro[n](async()=>{let o=this.getAttribute(\"renderer-url\"),[a,{default:c}]=await Promise.all([import(this.getAttribute(\"component-url\")),o?import(o):()=>()=>{}]),i=this.getAttribute(\"component-export\")||\"default\";if(!i.includes(\".\"))this.Component=a[i];else{this.Component=a;for(let r of i.split(\".\"))this.Component=this.Component[r]}return this.hydrator=c,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 d;{let p={0:t=>t,1:t=>
|
|
1
|
+
var astro_island_prebuilt_default = `(()=>{var d;{let p={0:t=>u(t),1:t=>l(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(l(t)),5:t=>new Set(l(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t)},h=t=>{let[e,n]=t;return e in p?p[e](n):void 0},l=t=>t.map(h),u=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([e,n])=>[e,h(n)]));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 n=this.querySelectorAll("astro-slot"),o={},a=this.querySelectorAll("template[data-astro-template]");for(let r of a){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of n){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute("name")||"default"]=r.innerHTML)}let c;try{c=this.hasAttribute("props")?u(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",y=this.getAttribute("component-export");throw y&&(s+=\` (export \${y})\`),console.error(\`[hydrate] Error parsing props for component \${s}\`,this.getAttribute("props"),r),r}await this.hydrator(this)(this.Component,c,o,{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,n)=>{n.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")),n=this.getAttribute("client");if(Astro[n]===void 0){window.addEventListener(\`astro:\${n}\`,()=>this.start(),{once:!0});return}Astro[n](async()=>{let o=this.getAttribute("renderer-url"),[a,{default:c}]=await Promise.all([import(this.getAttribute("component-url")),o?import(o):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=a[i];else{this.Component=a;for(let r of i.split("."))this.Component=this.Component[r]}return this.hydrator=c,this.hydrate},e,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=["props"],d))}})();`;
|
|
2
2
|
export {
|
|
3
3
|
astro_island_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const PROP_TYPE = {
|
|
2
2
|
Value: 0,
|
|
3
3
|
JSON: 1,
|
|
4
|
+
// Actually means Array
|
|
4
5
|
RegExp: 2,
|
|
5
6
|
Date: 3,
|
|
6
7
|
Map: 4,
|
|
@@ -49,16 +50,10 @@ function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */
|
|
|
49
50
|
return [PROP_TYPE.RegExp, value.source];
|
|
50
51
|
}
|
|
51
52
|
case "[object Map]": {
|
|
52
|
-
return [
|
|
53
|
-
PROP_TYPE.Map,
|
|
54
|
-
JSON.stringify(serializeArray(Array.from(value), metadata, parents))
|
|
55
|
-
];
|
|
53
|
+
return [PROP_TYPE.Map, serializeArray(Array.from(value), metadata, parents)];
|
|
56
54
|
}
|
|
57
55
|
case "[object Set]": {
|
|
58
|
-
return [
|
|
59
|
-
PROP_TYPE.Set,
|
|
60
|
-
JSON.stringify(serializeArray(Array.from(value), metadata, parents))
|
|
61
|
-
];
|
|
56
|
+
return [PROP_TYPE.Set, serializeArray(Array.from(value), metadata, parents)];
|
|
62
57
|
}
|
|
63
58
|
case "[object BigInt]": {
|
|
64
59
|
return [PROP_TYPE.BigInt, value.toString()];
|
|
@@ -67,16 +62,16 @@ function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */
|
|
|
67
62
|
return [PROP_TYPE.URL, value.toString()];
|
|
68
63
|
}
|
|
69
64
|
case "[object Array]": {
|
|
70
|
-
return [PROP_TYPE.JSON,
|
|
65
|
+
return [PROP_TYPE.JSON, serializeArray(value, metadata, parents)];
|
|
71
66
|
}
|
|
72
67
|
case "[object Uint8Array]": {
|
|
73
|
-
return [PROP_TYPE.Uint8Array,
|
|
68
|
+
return [PROP_TYPE.Uint8Array, Array.from(value)];
|
|
74
69
|
}
|
|
75
70
|
case "[object Uint16Array]": {
|
|
76
|
-
return [PROP_TYPE.Uint16Array,
|
|
71
|
+
return [PROP_TYPE.Uint16Array, Array.from(value)];
|
|
77
72
|
}
|
|
78
73
|
case "[object Uint32Array]": {
|
|
79
|
-
return [PROP_TYPE.Uint32Array,
|
|
74
|
+
return [PROP_TYPE.Uint32Array, Array.from(value)];
|
|
80
75
|
}
|
|
81
76
|
default: {
|
|
82
77
|
if (value !== null && typeof value === "object") {
|
|
@@ -178,12 +178,15 @@ async function handleRoute({
|
|
|
178
178
|
if (computedMimeType) {
|
|
179
179
|
contentType = computedMimeType;
|
|
180
180
|
}
|
|
181
|
-
const response = new Response(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
const response = new Response(
|
|
182
|
+
result.encoding !== "binary" ? Buffer.from(result.body, result.encoding) : result.body,
|
|
183
|
+
{
|
|
184
|
+
status: 200,
|
|
185
|
+
headers: {
|
|
186
|
+
"Content-Type": `${contentType};charset=utf-8`
|
|
187
|
+
}
|
|
185
188
|
}
|
|
186
|
-
|
|
189
|
+
);
|
|
187
190
|
attachToResponse(response, result.cookies);
|
|
188
191
|
await writeWebResponse(incomingResponse, response);
|
|
189
192
|
}
|