astro 2.5.6 → 2.6.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 +115 -90
- package/dist/assets/generate.js +2 -2
- package/dist/config/index.js +11 -3
- package/dist/config/vite-plugin-content-listen.d.ts +18 -0
- package/dist/config/vite-plugin-content-listen.js +26 -0
- package/dist/content/consts.d.ts +2 -1
- package/dist/content/consts.js +8 -1
- package/dist/content/runtime.js +67 -47
- package/dist/content/vite-plugin-content-assets.js +26 -10
- package/dist/content/vite-plugin-content-virtual-mod.js +18 -9
- package/dist/core/app/index.js +27 -18
- package/dist/core/app/node.js +4 -3
- package/dist/core/app/types.d.ts +1 -2
- package/dist/core/build/common.js +2 -0
- package/dist/core/build/generate.js +76 -13
- package/dist/core/build/internal.d.ts +2 -0
- package/dist/core/build/internal.js +18 -1
- package/dist/core/build/plugins/plugin-css.js +1 -1
- package/dist/core/build/plugins/plugin-middleware.js +1 -7
- package/dist/core/build/plugins/plugin-pages.d.ts +1 -0
- package/dist/core/build/plugins/plugin-pages.js +14 -4
- package/dist/core/build/plugins/plugin-ssr.js +10 -14
- package/dist/core/build/static-build.js +9 -10
- package/dist/core/config/config.js +1 -10
- package/dist/core/config/schema.d.ts +48 -64
- package/dist/core/config/schema.js +13 -11
- package/dist/core/config/settings.js +2 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/index.js +2 -2
- package/dist/core/errors/errors-data.d.ts +12 -20
- package/dist/core/errors/errors-data.js +13 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/path.d.ts +1 -15
- package/dist/core/path.js +1 -80
- package/dist/core/redirects/component.d.ts +4 -0
- package/dist/core/redirects/component.js +19 -0
- package/dist/core/redirects/helpers.d.ts +4 -0
- package/dist/core/redirects/helpers.js +29 -0
- package/dist/core/redirects/index.d.ts +3 -0
- package/dist/core/redirects/index.js +11 -0
- package/dist/core/redirects/validate.d.ts +1 -0
- package/dist/core/redirects/validate.js +13 -0
- package/dist/core/render/context.d.ts +2 -1
- package/dist/core/render/core.d.ts +2 -1
- package/dist/core/render/core.js +18 -1
- package/dist/core/render/dev/environment.js +2 -2
- package/dist/core/render/dev/vite.js +12 -13
- package/dist/core/render/result.d.ts +2 -0
- package/dist/core/render/result.js +3 -3
- package/dist/core/routing/manifest/create.js +50 -4
- package/dist/core/util.js +10 -3
- package/dist/integrations/index.js +3 -8
- package/dist/prerender/utils.d.ts +2 -2
- package/dist/prerender/utils.js +6 -6
- package/dist/runtime/server/astro-island.js +7 -4
- 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/any.js +4 -2
- package/dist/runtime/server/render/astro/render-template.d.ts +1 -1
- package/dist/runtime/server/render/astro/render-template.js +5 -9
- package/dist/runtime/server/render/common.js +6 -0
- package/dist/runtime/server/render/component.js +2 -2
- package/dist/runtime/server/render/page.d.ts +1 -1
- package/dist/runtime/server/render/page.js +10 -6
- package/dist/runtime/server/render/util.d.ts +6 -0
- package/dist/runtime/server/render/util.js +8 -0
- package/dist/vite-plugin-astro-server/request.js +2 -2
- package/dist/vite-plugin-astro-server/route.js +16 -9
- package/dist/vite-plugin-head/index.js +1 -1
- package/dist/vite-plugin-html/transform/index.js +3 -7
- package/dist/vite-plugin-markdown/content-entry-type.js +6 -1
- package/dist/vite-plugin-scanner/index.js +4 -4
- package/dist/vite-plugin-utils/index.js +1 -1
- package/env.d.ts +2 -2
- package/package.json +2 -1
- package/src/content/template/virtual-mod.mjs +1 -1
- package/tsconfigs/base.json +3 -1
- package/tsconfigs/strictest.json +3 -1
|
@@ -46,6 +46,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
46
46
|
assets: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
47
47
|
assetsPrefix: z.ZodOptional<z.ZodString>;
|
|
48
48
|
serverEntry: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
49
|
+
redirects: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
50
|
+
inlineStylesheets: z.ZodDefault<z.ZodOptional<z.ZodEnum<["always", "auto", "never"]>>>;
|
|
49
51
|
}, "strip", z.ZodTypeAny, {
|
|
50
52
|
assetsPrefix?: string | undefined;
|
|
51
53
|
server: URL;
|
|
@@ -53,6 +55,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
53
55
|
client: URL;
|
|
54
56
|
assets: string;
|
|
55
57
|
serverEntry: string;
|
|
58
|
+
redirects: boolean;
|
|
59
|
+
inlineStylesheets: "never" | "always" | "auto";
|
|
56
60
|
}, {
|
|
57
61
|
server?: string | undefined;
|
|
58
62
|
format?: "file" | "directory" | undefined;
|
|
@@ -60,6 +64,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
60
64
|
assets?: string | undefined;
|
|
61
65
|
assetsPrefix?: string | undefined;
|
|
62
66
|
serverEntry?: string | undefined;
|
|
67
|
+
redirects?: boolean | undefined;
|
|
68
|
+
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
63
69
|
}>>>;
|
|
64
70
|
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
65
71
|
open: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -82,6 +88,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
82
88
|
host: string | boolean;
|
|
83
89
|
port: number;
|
|
84
90
|
}, unknown>;
|
|
91
|
+
redirects: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
85
92
|
image: z.ZodDefault<z.ZodObject<{
|
|
86
93
|
service: z.ZodObject<{
|
|
87
94
|
entrypoint: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.ZodString]>;
|
|
@@ -155,34 +162,19 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
155
162
|
vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
|
|
156
163
|
experimental: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
157
164
|
assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
158
|
-
|
|
159
|
-
inlineStylesheets: z.ZodDefault<z.ZodOptional<z.ZodEnum<["always", "auto", "never"]>>>;
|
|
160
|
-
middleware: z.ZodDefault<z.ZodOptional<z.ZodOptional<z.ZodBoolean>>>;
|
|
161
|
-
hybridOutput: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
165
|
+
redirects: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
162
166
|
}, "passthrough", z.ZodTypeAny, {
|
|
163
167
|
assets: boolean;
|
|
164
|
-
|
|
165
|
-
inlineStylesheets: "never" | "always" | "auto";
|
|
166
|
-
middleware: boolean;
|
|
167
|
-
hybridOutput: boolean;
|
|
168
|
+
redirects: boolean;
|
|
168
169
|
}, {
|
|
169
170
|
assets?: boolean | undefined;
|
|
170
|
-
|
|
171
|
-
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
172
|
-
middleware?: boolean | undefined;
|
|
173
|
-
hybridOutput?: boolean | undefined;
|
|
171
|
+
redirects?: boolean | undefined;
|
|
174
172
|
}>, {
|
|
175
173
|
assets: boolean;
|
|
176
|
-
|
|
177
|
-
inlineStylesheets: "never" | "always" | "auto";
|
|
178
|
-
middleware: boolean;
|
|
179
|
-
hybridOutput: boolean;
|
|
174
|
+
redirects: boolean;
|
|
180
175
|
}, {
|
|
181
176
|
assets?: boolean | undefined;
|
|
182
|
-
|
|
183
|
-
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
184
|
-
middleware?: boolean | undefined;
|
|
185
|
-
hybridOutput?: boolean | undefined;
|
|
177
|
+
redirects?: boolean | undefined;
|
|
186
178
|
}>>>;
|
|
187
179
|
legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
|
|
188
180
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -211,6 +203,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
211
203
|
name: string;
|
|
212
204
|
hooks: {};
|
|
213
205
|
}[];
|
|
206
|
+
redirects: Record<string, string>;
|
|
214
207
|
build: {
|
|
215
208
|
assetsPrefix?: string | undefined;
|
|
216
209
|
server: URL;
|
|
@@ -218,6 +211,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
218
211
|
client: URL;
|
|
219
212
|
assets: string;
|
|
220
213
|
serverEntry: string;
|
|
214
|
+
redirects: boolean;
|
|
215
|
+
inlineStylesheets: "never" | "always" | "auto";
|
|
221
216
|
};
|
|
222
217
|
image: {
|
|
223
218
|
service: {
|
|
@@ -242,10 +237,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
242
237
|
vite: ViteUserConfig;
|
|
243
238
|
experimental: {
|
|
244
239
|
assets: boolean;
|
|
245
|
-
|
|
246
|
-
inlineStylesheets: "never" | "always" | "auto";
|
|
247
|
-
middleware: boolean;
|
|
248
|
-
hybridOutput: boolean;
|
|
240
|
+
redirects: boolean;
|
|
249
241
|
};
|
|
250
242
|
legacy: {};
|
|
251
243
|
}, {
|
|
@@ -266,6 +258,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
266
258
|
name: string;
|
|
267
259
|
} | undefined;
|
|
268
260
|
integrations?: unknown;
|
|
261
|
+
redirects?: Record<string, string> | undefined;
|
|
269
262
|
build?: {
|
|
270
263
|
server?: string | undefined;
|
|
271
264
|
format?: "file" | "directory" | undefined;
|
|
@@ -273,6 +266,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
273
266
|
assets?: string | undefined;
|
|
274
267
|
assetsPrefix?: string | undefined;
|
|
275
268
|
serverEntry?: string | undefined;
|
|
269
|
+
redirects?: boolean | undefined;
|
|
270
|
+
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
276
271
|
} | undefined;
|
|
277
272
|
image?: {
|
|
278
273
|
service: {
|
|
@@ -297,10 +292,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
297
292
|
vite?: ViteUserConfig | undefined;
|
|
298
293
|
experimental?: {
|
|
299
294
|
assets?: boolean | undefined;
|
|
300
|
-
|
|
301
|
-
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
302
|
-
middleware?: boolean | undefined;
|
|
303
|
-
hybridOutput?: boolean | undefined;
|
|
295
|
+
redirects?: boolean | undefined;
|
|
304
296
|
} | undefined;
|
|
305
297
|
legacy?: {} | undefined;
|
|
306
298
|
}>;
|
|
@@ -333,6 +325,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
333
325
|
name: string;
|
|
334
326
|
hooks: {};
|
|
335
327
|
}[], unknown>;
|
|
328
|
+
redirects: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
336
329
|
image: z.ZodDefault<z.ZodObject<{
|
|
337
330
|
service: z.ZodObject<{
|
|
338
331
|
entrypoint: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.ZodString]>;
|
|
@@ -406,34 +399,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
406
399
|
vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
|
|
407
400
|
experimental: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
408
401
|
assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
409
|
-
|
|
410
|
-
inlineStylesheets: z.ZodDefault<z.ZodOptional<z.ZodEnum<["always", "auto", "never"]>>>;
|
|
411
|
-
middleware: z.ZodDefault<z.ZodOptional<z.ZodOptional<z.ZodBoolean>>>;
|
|
412
|
-
hybridOutput: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
402
|
+
redirects: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
413
403
|
}, "passthrough", z.ZodTypeAny, {
|
|
414
404
|
assets: boolean;
|
|
415
|
-
|
|
416
|
-
inlineStylesheets: "never" | "always" | "auto";
|
|
417
|
-
middleware: boolean;
|
|
418
|
-
hybridOutput: boolean;
|
|
405
|
+
redirects: boolean;
|
|
419
406
|
}, {
|
|
420
407
|
assets?: boolean | undefined;
|
|
421
|
-
|
|
422
|
-
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
423
|
-
middleware?: boolean | undefined;
|
|
424
|
-
hybridOutput?: boolean | undefined;
|
|
408
|
+
redirects?: boolean | undefined;
|
|
425
409
|
}>, {
|
|
426
410
|
assets: boolean;
|
|
427
|
-
|
|
428
|
-
inlineStylesheets: "never" | "always" | "auto";
|
|
429
|
-
middleware: boolean;
|
|
430
|
-
hybridOutput: boolean;
|
|
411
|
+
redirects: boolean;
|
|
431
412
|
}, {
|
|
432
413
|
assets?: boolean | undefined;
|
|
433
|
-
|
|
434
|
-
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
435
|
-
middleware?: boolean | undefined;
|
|
436
|
-
hybridOutput?: boolean | undefined;
|
|
414
|
+
redirects?: boolean | undefined;
|
|
437
415
|
}>>>;
|
|
438
416
|
legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
|
|
439
417
|
root: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
|
|
@@ -449,6 +427,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
449
427
|
assets: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
450
428
|
assetsPrefix: z.ZodOptional<z.ZodString>;
|
|
451
429
|
serverEntry: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
430
|
+
redirects: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
431
|
+
inlineStylesheets: z.ZodDefault<z.ZodOptional<z.ZodEnum<["always", "auto", "never"]>>>;
|
|
452
432
|
}, "strip", z.ZodTypeAny, {
|
|
453
433
|
assetsPrefix?: string | undefined;
|
|
454
434
|
server: URL;
|
|
@@ -456,6 +436,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
456
436
|
client: URL;
|
|
457
437
|
assets: string;
|
|
458
438
|
serverEntry: string;
|
|
439
|
+
redirects: boolean;
|
|
440
|
+
inlineStylesheets: "never" | "always" | "auto";
|
|
459
441
|
}, {
|
|
460
442
|
server?: string | undefined;
|
|
461
443
|
format?: "file" | "directory" | undefined;
|
|
@@ -463,6 +445,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
463
445
|
assets?: string | undefined;
|
|
464
446
|
assetsPrefix?: string | undefined;
|
|
465
447
|
serverEntry?: string | undefined;
|
|
448
|
+
redirects?: boolean | undefined;
|
|
449
|
+
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
466
450
|
}>>>;
|
|
467
451
|
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
468
452
|
host: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>>;
|
|
@@ -516,6 +500,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
516
500
|
name: string;
|
|
517
501
|
hooks: {};
|
|
518
502
|
}[];
|
|
503
|
+
redirects: Record<string, string>;
|
|
519
504
|
build: {
|
|
520
505
|
assetsPrefix?: string | undefined;
|
|
521
506
|
server: URL;
|
|
@@ -523,6 +508,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
523
508
|
client: URL;
|
|
524
509
|
assets: string;
|
|
525
510
|
serverEntry: string;
|
|
511
|
+
redirects: boolean;
|
|
512
|
+
inlineStylesheets: "never" | "always" | "auto";
|
|
526
513
|
};
|
|
527
514
|
image: {
|
|
528
515
|
service: {
|
|
@@ -547,10 +534,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
547
534
|
vite: ViteUserConfig;
|
|
548
535
|
experimental: {
|
|
549
536
|
assets: boolean;
|
|
550
|
-
|
|
551
|
-
inlineStylesheets: "never" | "always" | "auto";
|
|
552
|
-
middleware: boolean;
|
|
553
|
-
hybridOutput: boolean;
|
|
537
|
+
redirects: boolean;
|
|
554
538
|
};
|
|
555
539
|
legacy: {};
|
|
556
540
|
}, {
|
|
@@ -571,6 +555,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
571
555
|
name: string;
|
|
572
556
|
} | undefined;
|
|
573
557
|
integrations?: unknown;
|
|
558
|
+
redirects?: Record<string, string> | undefined;
|
|
574
559
|
build?: {
|
|
575
560
|
server?: string | undefined;
|
|
576
561
|
format?: "file" | "directory" | undefined;
|
|
@@ -578,6 +563,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
578
563
|
assets?: string | undefined;
|
|
579
564
|
assetsPrefix?: string | undefined;
|
|
580
565
|
serverEntry?: string | undefined;
|
|
566
|
+
redirects?: boolean | undefined;
|
|
567
|
+
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
581
568
|
} | undefined;
|
|
582
569
|
image?: {
|
|
583
570
|
service: {
|
|
@@ -602,10 +589,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
602
589
|
vite?: ViteUserConfig | undefined;
|
|
603
590
|
experimental?: {
|
|
604
591
|
assets?: boolean | undefined;
|
|
605
|
-
|
|
606
|
-
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
607
|
-
middleware?: boolean | undefined;
|
|
608
|
-
hybridOutput?: boolean | undefined;
|
|
592
|
+
redirects?: boolean | undefined;
|
|
609
593
|
} | undefined;
|
|
610
594
|
legacy?: {} | undefined;
|
|
611
595
|
}>, {
|
|
@@ -635,6 +619,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
635
619
|
name: string;
|
|
636
620
|
hooks: {};
|
|
637
621
|
}[];
|
|
622
|
+
redirects: Record<string, string>;
|
|
638
623
|
build: {
|
|
639
624
|
assetsPrefix?: string | undefined;
|
|
640
625
|
server: URL;
|
|
@@ -642,6 +627,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
642
627
|
client: URL;
|
|
643
628
|
assets: string;
|
|
644
629
|
serverEntry: string;
|
|
630
|
+
redirects: boolean;
|
|
631
|
+
inlineStylesheets: "never" | "always" | "auto";
|
|
645
632
|
};
|
|
646
633
|
image: {
|
|
647
634
|
service: {
|
|
@@ -666,10 +653,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
666
653
|
vite: ViteUserConfig;
|
|
667
654
|
experimental: {
|
|
668
655
|
assets: boolean;
|
|
669
|
-
|
|
670
|
-
inlineStylesheets: "never" | "always" | "auto";
|
|
671
|
-
middleware: boolean;
|
|
672
|
-
hybridOutput: boolean;
|
|
656
|
+
redirects: boolean;
|
|
673
657
|
};
|
|
674
658
|
legacy: {};
|
|
675
659
|
}, {
|
|
@@ -690,6 +674,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
690
674
|
name: string;
|
|
691
675
|
} | undefined;
|
|
692
676
|
integrations?: unknown;
|
|
677
|
+
redirects?: Record<string, string> | undefined;
|
|
693
678
|
build?: {
|
|
694
679
|
server?: string | undefined;
|
|
695
680
|
format?: "file" | "directory" | undefined;
|
|
@@ -697,6 +682,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
697
682
|
assets?: string | undefined;
|
|
698
683
|
assetsPrefix?: string | undefined;
|
|
699
684
|
serverEntry?: string | undefined;
|
|
685
|
+
redirects?: boolean | undefined;
|
|
686
|
+
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
700
687
|
} | undefined;
|
|
701
688
|
image?: {
|
|
702
689
|
service: {
|
|
@@ -721,10 +708,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
721
708
|
vite?: ViteUserConfig | undefined;
|
|
722
709
|
experimental?: {
|
|
723
710
|
assets?: boolean | undefined;
|
|
724
|
-
|
|
725
|
-
inlineStylesheets?: "never" | "always" | "auto" | undefined;
|
|
726
|
-
middleware?: boolean | undefined;
|
|
727
|
-
hybridOutput?: boolean | undefined;
|
|
711
|
+
redirects?: boolean | undefined;
|
|
728
712
|
} | undefined;
|
|
729
713
|
legacy?: {} | undefined;
|
|
730
714
|
}>;
|
|
@@ -15,7 +15,9 @@ const ASTRO_CONFIG_DEFAULTS = {
|
|
|
15
15
|
client: "./dist/client/",
|
|
16
16
|
server: "./dist/server/",
|
|
17
17
|
assets: "_astro",
|
|
18
|
-
serverEntry: "entry.mjs"
|
|
18
|
+
serverEntry: "entry.mjs",
|
|
19
|
+
redirects: true,
|
|
20
|
+
inlineStylesheets: "never"
|
|
19
21
|
},
|
|
20
22
|
compressHTML: false,
|
|
21
23
|
server: {
|
|
@@ -31,12 +33,10 @@ const ASTRO_CONFIG_DEFAULTS = {
|
|
|
31
33
|
},
|
|
32
34
|
vite: {},
|
|
33
35
|
legacy: {},
|
|
36
|
+
redirects: {},
|
|
34
37
|
experimental: {
|
|
35
38
|
assets: false,
|
|
36
|
-
|
|
37
|
-
customClientDirectives: false,
|
|
38
|
-
inlineStylesheets: "never",
|
|
39
|
-
middleware: false
|
|
39
|
+
redirects: false
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
const AstroConfigSchema = z.object({
|
|
@@ -64,7 +64,9 @@ const AstroConfigSchema = z.object({
|
|
|
64
64
|
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) => new URL(val)),
|
|
65
65
|
assets: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.assets),
|
|
66
66
|
assetsPrefix: z.string().optional(),
|
|
67
|
-
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry)
|
|
67
|
+
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry),
|
|
68
|
+
redirects: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.redirects),
|
|
69
|
+
inlineStylesheets: z.enum(["always", "auto", "never"]).optional().default(ASTRO_CONFIG_DEFAULTS.build.inlineStylesheets)
|
|
68
70
|
}).optional().default({}),
|
|
69
71
|
server: z.preprocess(
|
|
70
72
|
// preprocess
|
|
@@ -79,6 +81,7 @@ const AstroConfigSchema = z.object({
|
|
|
79
81
|
headers: z.custom().optional()
|
|
80
82
|
}).optional().default({})
|
|
81
83
|
),
|
|
84
|
+
redirects: z.record(z.string(), z.string()).default(ASTRO_CONFIG_DEFAULTS.redirects),
|
|
82
85
|
image: z.object({
|
|
83
86
|
service: z.object({
|
|
84
87
|
entrypoint: z.union([
|
|
@@ -118,10 +121,7 @@ const AstroConfigSchema = z.object({
|
|
|
118
121
|
vite: z.custom((data) => data instanceof Object && !Array.isArray(data)).default(ASTRO_CONFIG_DEFAULTS.vite),
|
|
119
122
|
experimental: z.object({
|
|
120
123
|
assets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.assets),
|
|
121
|
-
|
|
122
|
-
inlineStylesheets: z.enum(["always", "auto", "never"]).optional().default(ASTRO_CONFIG_DEFAULTS.experimental.inlineStylesheets),
|
|
123
|
-
middleware: z.oboolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.middleware),
|
|
124
|
-
hybridOutput: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.hybridOutput)
|
|
124
|
+
redirects: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.redirects)
|
|
125
125
|
}).passthrough().refine(
|
|
126
126
|
(d) => {
|
|
127
127
|
const validKeys = Object.keys(ASTRO_CONFIG_DEFAULTS.experimental);
|
|
@@ -158,7 +158,9 @@ function createRelativeSchema(cmd, fileProtocolRoot) {
|
|
|
158
158
|
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) => new URL(val, fileProtocolRoot)),
|
|
159
159
|
assets: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.assets),
|
|
160
160
|
assetsPrefix: z.string().optional(),
|
|
161
|
-
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry)
|
|
161
|
+
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry),
|
|
162
|
+
redirects: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.redirects),
|
|
163
|
+
inlineStylesheets: z.enum(["always", "auto", "never"]).optional().default(ASTRO_CONFIG_DEFAULTS.build.inlineStylesheets)
|
|
162
164
|
}).optional().default({}),
|
|
163
165
|
server: z.preprocess(
|
|
164
166
|
// preprocess
|
|
@@ -3,7 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
4
4
|
import { getContentPaths } from "../../content/index.js";
|
|
5
5
|
import jsxRenderer from "../../jsx/renderer.js";
|
|
6
|
-
import {
|
|
6
|
+
import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
7
7
|
import { markdownContentEntryType } from "../../vite-plugin-markdown/content-entry-type.js";
|
|
8
8
|
import { getDefaultClientDirectives } from "../client-directive/index.js";
|
|
9
9
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
@@ -19,7 +19,7 @@ function createBaseSettings(config) {
|
|
|
19
19
|
tsConfig: void 0,
|
|
20
20
|
tsConfigPath: void 0,
|
|
21
21
|
adapter: void 0,
|
|
22
|
-
injectedRoutes: config.experimental.assets && (config
|
|
22
|
+
injectedRoutes: config.experimental.assets && isServerLikeOutput(config) ? [{ pattern: "/_image", entryPoint: "astro/assets/image-endpoint" }] : [],
|
|
23
23
|
pageExtensions: [".astro", ".html", ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS],
|
|
24
24
|
contentEntryTypes: [markdownContentEntryType],
|
|
25
25
|
dataEntryTypes: [
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -53,7 +53,7 @@ async function dev(settings, options) {
|
|
|
53
53
|
isRestart: options.isRestart
|
|
54
54
|
})
|
|
55
55
|
);
|
|
56
|
-
const currentVersion = "2.
|
|
56
|
+
const currentVersion = "2.6.0";
|
|
57
57
|
if (currentVersion.includes("-")) {
|
|
58
58
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
59
59
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
2
2
|
import { renderEndpoint } from "../../runtime/server/index.js";
|
|
3
3
|
import { ASTRO_VERSION } from "../constants.js";
|
|
4
4
|
import { AstroCookies, attachToResponse } from "../cookies/index.js";
|
|
@@ -115,7 +115,7 @@ function isRedirect(statusCode) {
|
|
|
115
115
|
return statusCode >= 300 && statusCode < 400;
|
|
116
116
|
}
|
|
117
117
|
function throwIfRedirectNotAllowed(response, config) {
|
|
118
|
-
if (
|
|
118
|
+
if (!isServerLikeOutput(config) && isRedirect(response.status)) {
|
|
119
119
|
throw new AstroError(AstroErrorData.StaticRedirectNotAvailable);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -36,6 +36,7 @@ export declare const AstroErrorData: {
|
|
|
36
36
|
* The `Astro.redirect` function is only available when [Server-side rendering](/en/guides/server-side-rendering/) is enabled.
|
|
37
37
|
*
|
|
38
38
|
* To redirect on a static website, the [meta refresh attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) can be used. Certain hosts also provide config-based redirects (ex: [Netlify redirects](https://docs.netlify.com/routing/redirects/)).
|
|
39
|
+
* @deprecated since version 2.6
|
|
39
40
|
*/
|
|
40
41
|
readonly StaticRedirectNotAvailable: {
|
|
41
42
|
readonly title: "`Astro.redirect` is not available in static mode.";
|
|
@@ -613,26 +614,6 @@ export declare const AstroErrorData: {
|
|
|
613
614
|
readonly message: "`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.";
|
|
614
615
|
readonly hint: "If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`.";
|
|
615
616
|
};
|
|
616
|
-
/**
|
|
617
|
-
* @docs
|
|
618
|
-
* @see
|
|
619
|
-
* - [Assets (Experimental)](https://docs.astro.build/en/guides/assets/)
|
|
620
|
-
* @description
|
|
621
|
-
* When using the default image services, `Image`'s and `getImage`'s `src` parameter must be either an imported image or an URL, it cannot be a filepath.
|
|
622
|
-
*
|
|
623
|
-
* ```astro
|
|
624
|
-
* ---
|
|
625
|
-
* import { Image } from "astro:assets";
|
|
626
|
-
* import myImage from "../my_image.png";
|
|
627
|
-
* ---
|
|
628
|
-
*
|
|
629
|
-
* <!-- GOOD: `src` is the full imported image. -->
|
|
630
|
-
* <Image src={myImage} alt="Cool image" />
|
|
631
|
-
*
|
|
632
|
-
* <!-- BAD: `src` is an image's `src` path instead of the full image. -->
|
|
633
|
-
* <Image src={myImage.src} alt="Cool image" />
|
|
634
|
-
* ```
|
|
635
|
-
*/
|
|
636
617
|
readonly LocalImageUsedWrongly: {
|
|
637
618
|
readonly title: "ESM imported images must be passed as-is.";
|
|
638
619
|
readonly code: 3034;
|
|
@@ -663,6 +644,17 @@ export declare const AstroErrorData: {
|
|
|
663
644
|
readonly code: 3036;
|
|
664
645
|
readonly message: (globStr: string) => string;
|
|
665
646
|
};
|
|
647
|
+
/**
|
|
648
|
+
* @docs
|
|
649
|
+
* @see
|
|
650
|
+
* - [Astro.redirect](https://docs.astro.build/en/guides/server-side-rendering/#astroredirect)
|
|
651
|
+
* @description
|
|
652
|
+
* A redirect must be given a location with the `Location` header.
|
|
653
|
+
*/
|
|
654
|
+
readonly RedirectWithNoLocation: {
|
|
655
|
+
readonly title: "A redirect must be given a location with the `Location` header.";
|
|
656
|
+
readonly code: 3037;
|
|
657
|
+
};
|
|
666
658
|
/**
|
|
667
659
|
* @docs
|
|
668
660
|
* @see
|
|
@@ -30,6 +30,7 @@ const AstroErrorData = {
|
|
|
30
30
|
* The `Astro.redirect` function is only available when [Server-side rendering](/en/guides/server-side-rendering/) is enabled.
|
|
31
31
|
*
|
|
32
32
|
* To redirect on a static website, the [meta refresh attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) can be used. Certain hosts also provide config-based redirects (ex: [Netlify redirects](https://docs.netlify.com/routing/redirects/)).
|
|
33
|
+
* @deprecated since version 2.6
|
|
33
34
|
*/
|
|
34
35
|
StaticRedirectNotAvailable: {
|
|
35
36
|
title: "`Astro.redirect` is not available in static mode.",
|
|
@@ -627,7 +628,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
627
628
|
message: "`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.",
|
|
628
629
|
hint: "If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`."
|
|
629
630
|
},
|
|
630
|
-
|
|
631
|
+
/*
|
|
631
632
|
* @docs
|
|
632
633
|
* @see
|
|
633
634
|
* - [Assets (Experimental)](https://docs.astro.build/en/guides/assets/)
|
|
@@ -677,6 +678,17 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
677
678
|
code: 3036,
|
|
678
679
|
message: (globStr) => `\`Astro.glob(${globStr})\` did not return any matching files. Check the pattern for typos.`
|
|
679
680
|
},
|
|
681
|
+
/**
|
|
682
|
+
* @docs
|
|
683
|
+
* @see
|
|
684
|
+
* - [Astro.redirect](https://docs.astro.build/en/guides/server-side-rendering/#astroredirect)
|
|
685
|
+
* @description
|
|
686
|
+
* A redirect must be given a location with the `Location` header.
|
|
687
|
+
*/
|
|
688
|
+
RedirectWithNoLocation: {
|
|
689
|
+
title: "A redirect must be given a location with the `Location` header.",
|
|
690
|
+
code: 3037
|
|
691
|
+
},
|
|
680
692
|
// No headings here, that way Vite errors are merged with Astro ones in the docs, which makes more sense to users.
|
|
681
693
|
// Vite Errors - 4xxx
|
|
682
694
|
/**
|
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.
|
|
50
|
+
const version = "2.6.0";
|
|
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.
|
|
236
|
+
`v${"2.6.0"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
package/dist/core/path.d.ts
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare function appendForwardSlash(path: string): string;
|
|
3
|
-
export declare function prependForwardSlash(path: string): string;
|
|
4
|
-
export declare function removeTrailingForwardSlash(path: string): string;
|
|
5
|
-
export declare function removeLeadingForwardSlash(path: string): string;
|
|
6
|
-
export declare function removeLeadingForwardSlashWindows(path: string): string;
|
|
7
|
-
export declare function trimSlashes(path: string): string;
|
|
8
|
-
export declare function startsWithForwardSlash(path: string): boolean;
|
|
9
|
-
export declare function startsWithDotDotSlash(path: string): boolean;
|
|
10
|
-
export declare function startsWithDotSlash(path: string): boolean;
|
|
11
|
-
export declare function isRelativePath(path: string): boolean;
|
|
12
|
-
export declare function joinPaths(...paths: (string | undefined)[]): string;
|
|
13
|
-
export declare function removeFileExtension(path: string): string;
|
|
14
|
-
export declare function removeQueryString(path: string): string;
|
|
15
|
-
export declare function isRemotePath(src: string): boolean;
|
|
1
|
+
export * from '@astrojs/internal-helpers/path';
|
package/dist/core/path.js
CHANGED
|
@@ -1,80 +1 @@
|
|
|
1
|
-
|
|
2
|
-
return path + "." + extension;
|
|
3
|
-
}
|
|
4
|
-
function appendForwardSlash(path) {
|
|
5
|
-
return path.endsWith("/") ? path : path + "/";
|
|
6
|
-
}
|
|
7
|
-
function prependForwardSlash(path) {
|
|
8
|
-
return path[0] === "/" ? path : "/" + path;
|
|
9
|
-
}
|
|
10
|
-
function removeTrailingForwardSlash(path) {
|
|
11
|
-
return path.endsWith("/") ? path.slice(0, path.length - 1) : path;
|
|
12
|
-
}
|
|
13
|
-
function removeLeadingForwardSlash(path) {
|
|
14
|
-
return path.startsWith("/") ? path.substring(1) : path;
|
|
15
|
-
}
|
|
16
|
-
function removeLeadingForwardSlashWindows(path) {
|
|
17
|
-
return path.startsWith("/") && path[2] === ":" ? path.substring(1) : path;
|
|
18
|
-
}
|
|
19
|
-
function trimSlashes(path) {
|
|
20
|
-
return path.replace(/^\/|\/$/g, "");
|
|
21
|
-
}
|
|
22
|
-
function startsWithForwardSlash(path) {
|
|
23
|
-
return path[0] === "/";
|
|
24
|
-
}
|
|
25
|
-
function startsWithDotDotSlash(path) {
|
|
26
|
-
const c1 = path[0];
|
|
27
|
-
const c2 = path[1];
|
|
28
|
-
const c3 = path[2];
|
|
29
|
-
return c1 === "." && c2 === "." && c3 === "/";
|
|
30
|
-
}
|
|
31
|
-
function startsWithDotSlash(path) {
|
|
32
|
-
const c1 = path[0];
|
|
33
|
-
const c2 = path[1];
|
|
34
|
-
return c1 === "." && c2 === "/";
|
|
35
|
-
}
|
|
36
|
-
function isRelativePath(path) {
|
|
37
|
-
return startsWithDotDotSlash(path) || startsWithDotSlash(path);
|
|
38
|
-
}
|
|
39
|
-
function isString(path) {
|
|
40
|
-
return typeof path === "string" || path instanceof String;
|
|
41
|
-
}
|
|
42
|
-
function joinPaths(...paths) {
|
|
43
|
-
return paths.filter(isString).map((path, i) => {
|
|
44
|
-
if (i === 0) {
|
|
45
|
-
return removeTrailingForwardSlash(path);
|
|
46
|
-
} else if (i === paths.length - 1) {
|
|
47
|
-
return removeLeadingForwardSlash(path);
|
|
48
|
-
} else {
|
|
49
|
-
return trimSlashes(path);
|
|
50
|
-
}
|
|
51
|
-
}).join("/");
|
|
52
|
-
}
|
|
53
|
-
function removeFileExtension(path) {
|
|
54
|
-
let idx = path.lastIndexOf(".");
|
|
55
|
-
return idx === -1 ? path : path.slice(0, idx);
|
|
56
|
-
}
|
|
57
|
-
function removeQueryString(path) {
|
|
58
|
-
const index = path.lastIndexOf("?");
|
|
59
|
-
return index > 0 ? path.substring(0, index) : path;
|
|
60
|
-
}
|
|
61
|
-
function isRemotePath(src) {
|
|
62
|
-
return /^(http|ftp|https):?\/\//.test(src) || src.startsWith("data:");
|
|
63
|
-
}
|
|
64
|
-
export {
|
|
65
|
-
appendExtension,
|
|
66
|
-
appendForwardSlash,
|
|
67
|
-
isRelativePath,
|
|
68
|
-
isRemotePath,
|
|
69
|
-
joinPaths,
|
|
70
|
-
prependForwardSlash,
|
|
71
|
-
removeFileExtension,
|
|
72
|
-
removeLeadingForwardSlash,
|
|
73
|
-
removeLeadingForwardSlashWindows,
|
|
74
|
-
removeQueryString,
|
|
75
|
-
removeTrailingForwardSlash,
|
|
76
|
-
startsWithDotDotSlash,
|
|
77
|
-
startsWithDotSlash,
|
|
78
|
-
startsWithForwardSlash,
|
|
79
|
-
trimSlashes
|
|
80
|
-
};
|
|
1
|
+
export * from "@astrojs/internal-helpers/path";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const RedirectComponentInstance = {
|
|
2
|
+
default() {
|
|
3
|
+
return new Response(null, {
|
|
4
|
+
status: 301
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
const StaticMiddlewareInstance = {
|
|
9
|
+
onRequest: (ctx, next) => next()
|
|
10
|
+
};
|
|
11
|
+
const RedirectSinglePageBuiltModule = {
|
|
12
|
+
page: () => Promise.resolve(RedirectComponentInstance),
|
|
13
|
+
middleware: StaticMiddlewareInstance,
|
|
14
|
+
renderers: []
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
RedirectComponentInstance,
|
|
18
|
+
RedirectSinglePageBuiltModule
|
|
19
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Params, RedirectRouteData, RouteData, ValidRedirectStatus } from '../../@types/astro';
|
|
2
|
+
export declare function routeIsRedirect(route: RouteData | undefined): route is RedirectRouteData;
|
|
3
|
+
export declare function redirectRouteGenerate(redirectRoute: RouteData, data: Params): string;
|
|
4
|
+
export declare function redirectRouteStatus(redirectRoute: RouteData, method?: string): ValidRedirectStatus;
|