astro 2.1.3 → 2.1.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/dist/@types/astro.d.ts +15 -0
- package/dist/@types/typed-emitter.d.ts +1 -2
- package/dist/assets/consts.js +8 -0
- package/dist/assets/image-endpoint.js +1 -1
- package/dist/assets/internal.d.ts +2 -1
- package/dist/assets/internal.js +10 -5
- package/dist/assets/services/service.d.ts +10 -1
- package/dist/assets/services/service.js +35 -29
- package/dist/assets/services/sharp.d.ts +1 -1
- package/dist/assets/services/sharp.js +5 -4
- package/dist/assets/services/squoosh.d.ts +1 -1
- package/dist/assets/services/squoosh.js +7 -4
- package/dist/assets/services/vendor/squoosh/codecs.js +2 -0
- package/dist/assets/services/vendor/squoosh/image-pool.js +2 -0
- package/dist/assets/services/vendor/squoosh/impl.js +2 -0
- package/dist/assets/utils/metadata.js +2 -5
- package/dist/assets/vendor/image-size/detector.d.ts +3 -0
- package/dist/assets/vendor/image-size/detector.js +28 -0
- package/dist/assets/vendor/image-size/index.d.ts +11 -0
- package/dist/assets/vendor/image-size/index.js +93 -0
- package/dist/assets/vendor/image-size/readUInt.d.ts +4 -0
- package/dist/assets/vendor/image-size/readUInt.js +9 -0
- package/dist/assets/vendor/image-size/types/bmp.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/bmp.js +14 -0
- package/dist/assets/vendor/image-size/types/cur.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/cur.js +16 -0
- package/dist/assets/vendor/image-size/types/dds.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/dds.js +14 -0
- package/dist/assets/vendor/image-size/types/gif.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/gif.js +16 -0
- package/dist/assets/vendor/image-size/types/icns.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/icns.js +87 -0
- package/dist/assets/vendor/image-size/types/ico.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/ico.js +42 -0
- package/dist/assets/vendor/image-size/types/interface.d.ts +14 -0
- package/dist/assets/vendor/image-size/types/interface.js +0 -0
- package/dist/assets/vendor/image-size/types/j2c.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/j2c.js +14 -0
- package/dist/assets/vendor/image-size/types/jp2.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/jp2.js +56 -0
- package/dist/assets/vendor/image-size/types/jpg.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/jpg.js +95 -0
- package/dist/assets/vendor/image-size/types/ktx.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/ktx.js +15 -0
- package/dist/assets/vendor/image-size/types/png.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/png.js +33 -0
- package/dist/assets/vendor/image-size/types/pnm.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/pnm.js +72 -0
- package/dist/assets/vendor/image-size/types/psd.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/psd.js +14 -0
- package/dist/assets/vendor/image-size/types/svg.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/svg.js +91 -0
- package/dist/assets/vendor/image-size/types/tiff.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/tiff.js +81 -0
- package/dist/assets/vendor/image-size/types/webp.d.ts +2 -0
- package/dist/assets/vendor/image-size/types/webp.js +51 -0
- package/dist/assets/vendor/image-size/types.d.ts +19 -0
- package/dist/assets/vendor/image-size/types.js +37 -0
- package/dist/assets/vendor/queue/queue.d.ts +39 -0
- package/dist/assets/vendor/queue/queue.js +187 -0
- package/dist/assets/vite-plugin-assets.js +4 -0
- package/dist/cli/check/index.js +43 -2
- package/dist/cli/check/print.d.ts +1 -1
- package/dist/content/error-map.js +4 -1
- package/dist/content/server-listeners.d.ts +1 -1
- package/dist/content/types-generator.d.ts +3 -3
- package/dist/content/types-generator.js +3 -0
- package/dist/content/utils.d.ts +2 -2
- package/dist/content/utils.js +2 -0
- package/dist/content/vite-plugin-content-assets.d.ts +1 -1
- package/dist/content/vite-plugin-content-imports.d.ts +1 -1
- package/dist/content/vite-plugin-content-imports.js +163 -77
- package/dist/content/vite-plugin-content-virtual-mod.js +4 -1
- package/dist/core/add/index.d.ts +1 -1
- package/dist/core/add/index.js +11 -9
- package/dist/core/app/index.js +4 -1
- package/dist/core/app/node.d.ts +1 -1
- package/dist/core/build/generate.d.ts +1 -1
- package/dist/core/build/generate.js +5 -1
- package/dist/core/build/index.js +4 -0
- package/dist/core/build/plugin.js +1 -0
- package/dist/core/build/plugins/plugin-css.d.ts +1 -1
- package/dist/core/build/plugins/plugin-pages.d.ts +1 -1
- package/dist/core/build/static-build.d.ts +1 -1
- package/dist/core/build/static-build.js +4 -1
- package/dist/core/compile/cache.d.ts +1 -1
- package/dist/core/compile/style.d.ts +1 -1
- package/dist/core/config/schema.d.ts +36 -36
- package/dist/core/config/schema.js +9 -1
- package/dist/core/config/timer.js +9 -0
- package/dist/core/config/tsconfig.js +4 -0
- package/dist/core/config/vite-load.js +3 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/cookies.js +35 -1
- package/dist/core/create-vite.js +30 -3
- package/dist/core/dev/container.js +1 -0
- package/dist/core/dev/dev.d.ts +1 -1
- package/dist/core/dev/dev.js +2 -1
- package/dist/core/endpoint/index.d.ts +1 -1
- package/dist/core/endpoint/index.js +1 -0
- package/dist/core/errors/dev/utils.d.ts +1 -1
- package/dist/core/errors/dev/utils.js +2 -1
- package/dist/core/errors/dev/vite.d.ts +1 -1
- package/dist/core/errors/dev/vite.js +5 -0
- package/dist/core/errors/errors-data.js +486 -3
- package/dist/core/errors/errors.js +2 -0
- package/dist/core/errors/overlay.js +16 -5
- package/dist/core/errors/utils.d.ts +1 -1
- package/dist/core/logger/console.js +1 -1
- package/dist/core/logger/node.js +1 -1
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/module-loader/loader.d.ts +3 -3
- package/dist/core/render/dev/css.js +2 -1
- package/dist/core/render/dev/environment.js +1 -0
- package/dist/core/render/dev/index.js +1 -0
- package/dist/core/render/dev/resolve.js +1 -6
- package/dist/core/render/dev/vite.js +13 -1
- package/dist/core/render/index.d.ts +1 -1
- package/dist/core/render/result.d.ts +1 -1
- package/dist/core/render/result.js +4 -0
- package/dist/core/render/route-cache.d.ts +1 -1
- package/dist/core/render/route-cache.js +1 -0
- package/dist/core/routing/manifest/create.js +4 -1
- package/dist/core/sync/index.d.ts +1 -1
- package/dist/core/sync/index.js +1 -1
- package/dist/events/error.d.ts +1 -1
- package/dist/integrations/index.d.ts +1 -1
- package/dist/jsx/renderer.js +1 -0
- package/dist/runtime/client/visible.prebuilt.d.ts +1 -1
- package/dist/runtime/client/visible.prebuilt.js +1 -1
- package/dist/runtime/server/hydration.js +1 -0
- package/dist/runtime/server/render/scope.js +5 -0
- package/dist/runtime/server/scripts.js +2 -2
- package/dist/vite-plugin-astro/compile.d.ts +2 -2
- package/dist/vite-plugin-astro/compile.js +1 -0
- package/dist/vite-plugin-astro/index.js +7 -1
- package/dist/vite-plugin-astro-server/base.d.ts +1 -1
- package/dist/vite-plugin-astro-server/common.d.ts +1 -1
- package/dist/vite-plugin-astro-server/response.js +2 -2
- package/dist/vite-plugin-config-alias/index.d.ts +2 -7
- package/dist/vite-plugin-config-alias/index.js +32 -41
- package/dist/vite-plugin-env/index.js +1 -0
- package/dist/vite-plugin-inject-env-ts/index.d.ts +2 -2
- package/dist/vite-plugin-inject-env-ts/index.js +2 -0
- package/dist/vite-plugin-jsx/index.d.ts +1 -1
- package/dist/vite-plugin-jsx/index.js +7 -1
- package/dist/vite-plugin-jsx/tag.js +7 -0
- package/dist/vite-plugin-markdown/index.js +27 -58
- package/dist/vite-plugin-scanner/index.d.ts +1 -1
- package/dist/vite-plugin-scripts/page-ssr.d.ts +1 -1
- package/package.json +5 -6
- package/src/content/template/types.d.ts +12 -1
- package/tsconfigs/base.json +4 -1
|
@@ -73,11 +73,11 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
73
73
|
port: number;
|
|
74
74
|
}, unknown>;
|
|
75
75
|
image: z.ZodDefault<z.ZodObject<{
|
|
76
|
-
service: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.
|
|
76
|
+
service: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.ZodString]>;
|
|
77
77
|
}, "strip", z.ZodTypeAny, {
|
|
78
|
-
service:
|
|
78
|
+
service: string;
|
|
79
79
|
}, {
|
|
80
|
-
service:
|
|
80
|
+
service: string;
|
|
81
81
|
}>>;
|
|
82
82
|
markdown: z.ZodDefault<z.ZodObject<{
|
|
83
83
|
drafts: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -95,8 +95,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
95
95
|
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
96
96
|
wrap?: boolean | null | undefined;
|
|
97
97
|
}>>;
|
|
98
|
-
remarkPlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RemarkPlugin
|
|
99
|
-
rehypePlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RehypePlugin
|
|
98
|
+
remarkPlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RemarkPlugin, z.ZodTypeDef, RemarkPlugin>, z.ZodTuple<[z.ZodType<RemarkPlugin, z.ZodTypeDef, RemarkPlugin>, z.ZodAny], null>]>, "many">>;
|
|
99
|
+
rehypePlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RehypePlugin, z.ZodTypeDef, RehypePlugin>, z.ZodTuple<[z.ZodType<RehypePlugin, z.ZodTypeDef, RehypePlugin>, z.ZodAny], null>]>, "many">>;
|
|
100
100
|
remarkRehype: z.ZodDefault<z.ZodOptional<z.ZodType<RemarkRehype, z.ZodTypeDef, RemarkRehype>>>;
|
|
101
101
|
gfm: z.ZodDefault<z.ZodBoolean>;
|
|
102
102
|
smartypants: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -108,8 +108,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
108
108
|
theme: string | import("shiki").IShikiTheme;
|
|
109
109
|
wrap: boolean | null;
|
|
110
110
|
};
|
|
111
|
-
remarkPlugins: (string | [string, any] | RemarkPlugin
|
|
112
|
-
rehypePlugins: (string | [string, any] | RehypePlugin
|
|
111
|
+
remarkPlugins: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
|
|
112
|
+
rehypePlugins: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
|
|
113
113
|
remarkRehype: RemarkRehype;
|
|
114
114
|
gfm: boolean;
|
|
115
115
|
smartypants: boolean;
|
|
@@ -121,8 +121,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
121
121
|
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
122
122
|
wrap?: boolean | null | undefined;
|
|
123
123
|
} | undefined;
|
|
124
|
-
remarkPlugins?: (string | [string, any] | RemarkPlugin
|
|
125
|
-
rehypePlugins?: (string | [string, any] | RehypePlugin
|
|
124
|
+
remarkPlugins?: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[] | undefined;
|
|
125
|
+
rehypePlugins?: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[] | undefined;
|
|
126
126
|
remarkRehype?: RemarkRehype | undefined;
|
|
127
127
|
gfm?: boolean | undefined;
|
|
128
128
|
smartypants?: boolean | undefined;
|
|
@@ -151,8 +151,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
151
151
|
theme: string | import("shiki").IShikiTheme;
|
|
152
152
|
wrap: boolean | null;
|
|
153
153
|
};
|
|
154
|
-
remarkPlugins: (string | [string, any] | RemarkPlugin
|
|
155
|
-
rehypePlugins: (string | [string, any] | RehypePlugin
|
|
154
|
+
remarkPlugins: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
|
|
155
|
+
rehypePlugins: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
|
|
156
156
|
remarkRehype: RemarkRehype;
|
|
157
157
|
gfm: boolean;
|
|
158
158
|
smartypants: boolean;
|
|
@@ -180,7 +180,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
180
180
|
serverEntry: string;
|
|
181
181
|
};
|
|
182
182
|
image: {
|
|
183
|
-
service:
|
|
183
|
+
service: string;
|
|
184
184
|
};
|
|
185
185
|
vite: ViteUserConfig;
|
|
186
186
|
experimental: {
|
|
@@ -198,8 +198,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
198
198
|
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
199
199
|
wrap?: boolean | null | undefined;
|
|
200
200
|
} | undefined;
|
|
201
|
-
remarkPlugins?: (string | [string, any] | RemarkPlugin
|
|
202
|
-
rehypePlugins?: (string | [string, any] | RehypePlugin
|
|
201
|
+
remarkPlugins?: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[] | undefined;
|
|
202
|
+
rehypePlugins?: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[] | undefined;
|
|
203
203
|
remarkRehype?: RemarkRehype | undefined;
|
|
204
204
|
gfm?: boolean | undefined;
|
|
205
205
|
smartypants?: boolean | undefined;
|
|
@@ -224,7 +224,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
224
224
|
serverEntry?: string | undefined;
|
|
225
225
|
} | undefined;
|
|
226
226
|
image?: {
|
|
227
|
-
service:
|
|
227
|
+
service: string;
|
|
228
228
|
} | undefined;
|
|
229
229
|
vite?: ViteUserConfig | undefined;
|
|
230
230
|
experimental?: {
|
|
@@ -251,8 +251,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
251
251
|
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
252
252
|
wrap?: boolean | null | undefined;
|
|
253
253
|
}>>;
|
|
254
|
-
remarkPlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RemarkPlugin
|
|
255
|
-
rehypePlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RehypePlugin
|
|
254
|
+
remarkPlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RemarkPlugin, z.ZodTypeDef, RemarkPlugin>, z.ZodTuple<[z.ZodType<RemarkPlugin, z.ZodTypeDef, RemarkPlugin>, z.ZodAny], null>]>, "many">>;
|
|
255
|
+
rehypePlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RehypePlugin, z.ZodTypeDef, RehypePlugin>, z.ZodTuple<[z.ZodType<RehypePlugin, z.ZodTypeDef, RehypePlugin>, z.ZodAny], null>]>, "many">>;
|
|
256
256
|
remarkRehype: z.ZodDefault<z.ZodOptional<z.ZodType<RemarkRehype, z.ZodTypeDef, RemarkRehype>>>;
|
|
257
257
|
gfm: z.ZodDefault<z.ZodBoolean>;
|
|
258
258
|
smartypants: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -264,8 +264,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
264
264
|
theme: string | import("shiki").IShikiTheme;
|
|
265
265
|
wrap: boolean | null;
|
|
266
266
|
};
|
|
267
|
-
remarkPlugins: (string | [string, any] | RemarkPlugin
|
|
268
|
-
rehypePlugins: (string | [string, any] | RehypePlugin
|
|
267
|
+
remarkPlugins: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
|
|
268
|
+
rehypePlugins: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
|
|
269
269
|
remarkRehype: RemarkRehype;
|
|
270
270
|
gfm: boolean;
|
|
271
271
|
smartypants: boolean;
|
|
@@ -277,8 +277,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
277
277
|
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
278
278
|
wrap?: boolean | null | undefined;
|
|
279
279
|
} | undefined;
|
|
280
|
-
remarkPlugins?: (string | [string, any] | RemarkPlugin
|
|
281
|
-
rehypePlugins?: (string | [string, any] | RehypePlugin
|
|
280
|
+
remarkPlugins?: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[] | undefined;
|
|
281
|
+
rehypePlugins?: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[] | undefined;
|
|
282
282
|
remarkRehype?: RemarkRehype | undefined;
|
|
283
283
|
gfm?: boolean | undefined;
|
|
284
284
|
smartypants?: boolean | undefined;
|
|
@@ -309,11 +309,11 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
309
309
|
hooks: {};
|
|
310
310
|
}[], unknown>;
|
|
311
311
|
image: z.ZodDefault<z.ZodObject<{
|
|
312
|
-
service: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.
|
|
312
|
+
service: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.ZodString]>;
|
|
313
313
|
}, "strip", z.ZodTypeAny, {
|
|
314
|
-
service:
|
|
314
|
+
service: string;
|
|
315
315
|
}, {
|
|
316
|
-
service:
|
|
316
|
+
service: string;
|
|
317
317
|
}>>;
|
|
318
318
|
vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
|
|
319
319
|
experimental: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
@@ -383,8 +383,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
383
383
|
theme: string | import("shiki").IShikiTheme;
|
|
384
384
|
wrap: boolean | null;
|
|
385
385
|
};
|
|
386
|
-
remarkPlugins: (string | [string, any] | RemarkPlugin
|
|
387
|
-
rehypePlugins: (string | [string, any] | RehypePlugin
|
|
386
|
+
remarkPlugins: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
|
|
387
|
+
rehypePlugins: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
|
|
388
388
|
remarkRehype: RemarkRehype;
|
|
389
389
|
gfm: boolean;
|
|
390
390
|
smartypants: boolean;
|
|
@@ -413,7 +413,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
413
413
|
serverEntry: string;
|
|
414
414
|
};
|
|
415
415
|
image: {
|
|
416
|
-
service:
|
|
416
|
+
service: string;
|
|
417
417
|
};
|
|
418
418
|
vite: ViteUserConfig;
|
|
419
419
|
experimental: {
|
|
@@ -431,8 +431,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
431
431
|
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
432
432
|
wrap?: boolean | null | undefined;
|
|
433
433
|
} | undefined;
|
|
434
|
-
remarkPlugins?: (string | [string, any] | RemarkPlugin
|
|
435
|
-
rehypePlugins?: (string | [string, any] | RehypePlugin
|
|
434
|
+
remarkPlugins?: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[] | undefined;
|
|
435
|
+
rehypePlugins?: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[] | undefined;
|
|
436
436
|
remarkRehype?: RemarkRehype | undefined;
|
|
437
437
|
gfm?: boolean | undefined;
|
|
438
438
|
smartypants?: boolean | undefined;
|
|
@@ -457,7 +457,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
457
457
|
serverEntry?: string | undefined;
|
|
458
458
|
} | undefined;
|
|
459
459
|
image?: {
|
|
460
|
-
service:
|
|
460
|
+
service: string;
|
|
461
461
|
} | undefined;
|
|
462
462
|
vite?: ViteUserConfig | undefined;
|
|
463
463
|
experimental?: {
|
|
@@ -479,8 +479,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
479
479
|
theme: string | import("shiki").IShikiTheme;
|
|
480
480
|
wrap: boolean | null;
|
|
481
481
|
};
|
|
482
|
-
remarkPlugins: (string | [string, any] | RemarkPlugin
|
|
483
|
-
rehypePlugins: (string | [string, any] | RehypePlugin
|
|
482
|
+
remarkPlugins: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
|
|
483
|
+
rehypePlugins: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
|
|
484
484
|
remarkRehype: RemarkRehype;
|
|
485
485
|
gfm: boolean;
|
|
486
486
|
smartypants: boolean;
|
|
@@ -509,7 +509,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
509
509
|
serverEntry: string;
|
|
510
510
|
};
|
|
511
511
|
image: {
|
|
512
|
-
service:
|
|
512
|
+
service: string;
|
|
513
513
|
};
|
|
514
514
|
vite: ViteUserConfig;
|
|
515
515
|
experimental: {
|
|
@@ -527,8 +527,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
527
527
|
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
528
528
|
wrap?: boolean | null | undefined;
|
|
529
529
|
} | undefined;
|
|
530
|
-
remarkPlugins?: (string | [string, any] | RemarkPlugin
|
|
531
|
-
rehypePlugins?: (string | [string, any] | RehypePlugin
|
|
530
|
+
remarkPlugins?: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[] | undefined;
|
|
531
|
+
rehypePlugins?: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[] | undefined;
|
|
532
532
|
remarkRehype?: RemarkRehype | undefined;
|
|
533
533
|
gfm?: boolean | undefined;
|
|
534
534
|
smartypants?: boolean | undefined;
|
|
@@ -553,7 +553,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
553
553
|
serverEntry?: string | undefined;
|
|
554
554
|
} | undefined;
|
|
555
555
|
image?: {
|
|
556
|
-
service:
|
|
556
|
+
service: string;
|
|
557
557
|
} | undefined;
|
|
558
558
|
vite?: ViteUserConfig | undefined;
|
|
559
559
|
experimental?: {
|
|
@@ -43,7 +43,9 @@ const AstroConfigSchema = z.object({
|
|
|
43
43
|
output: z.union([z.literal("static"), z.literal("server")]).optional().default("static"),
|
|
44
44
|
adapter: z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) }).optional(),
|
|
45
45
|
integrations: z.preprocess(
|
|
46
|
+
// preprocess
|
|
46
47
|
(val) => Array.isArray(val) ? val.flat(Infinity).filter(Boolean) : val,
|
|
48
|
+
// validate
|
|
47
49
|
z.array(z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) })).default(ASTRO_CONFIG_DEFAULTS.integrations)
|
|
48
50
|
),
|
|
49
51
|
build: z.object({
|
|
@@ -54,7 +56,11 @@ const AstroConfigSchema = z.object({
|
|
|
54
56
|
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry)
|
|
55
57
|
}).optional().default({}),
|
|
56
58
|
server: z.preprocess(
|
|
59
|
+
// preprocess
|
|
60
|
+
// NOTE: Uses the "error" command here because this is overwritten by the
|
|
61
|
+
// individualized schema parser with the correct command.
|
|
57
62
|
(val) => typeof val === "function" ? val({ command: "error" }) : val,
|
|
63
|
+
// validate
|
|
58
64
|
z.object({
|
|
59
65
|
host: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.host),
|
|
60
66
|
port: z.number().optional().default(ASTRO_CONFIG_DEFAULTS.server.port),
|
|
@@ -65,7 +71,7 @@ const AstroConfigSchema = z.object({
|
|
|
65
71
|
service: z.union([
|
|
66
72
|
z.literal("astro/assets/services/sharp"),
|
|
67
73
|
z.literal("astro/assets/services/squoosh"),
|
|
68
|
-
z.string()
|
|
74
|
+
z.string()
|
|
69
75
|
])
|
|
70
76
|
}).default({
|
|
71
77
|
service: "astro/assets/services/squoosh"
|
|
@@ -114,6 +120,7 @@ function createRelativeSchema(cmd, fileProtocolRoot) {
|
|
|
114
120
|
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry)
|
|
115
121
|
}).optional().default({}),
|
|
116
122
|
server: z.preprocess(
|
|
123
|
+
// preprocess
|
|
117
124
|
(val) => {
|
|
118
125
|
if (typeof val === "function") {
|
|
119
126
|
const result = val({ command: cmd === "dev" ? "dev" : "preview" });
|
|
@@ -126,6 +133,7 @@ function createRelativeSchema(cmd, fileProtocolRoot) {
|
|
|
126
133
|
return val;
|
|
127
134
|
}
|
|
128
135
|
},
|
|
136
|
+
// validate
|
|
129
137
|
z.object({
|
|
130
138
|
host: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.host),
|
|
131
139
|
port: z.number().optional().default(ASTRO_CONFIG_DEFAULTS.server.port),
|
|
@@ -5,6 +5,9 @@ class AstroTimer {
|
|
|
5
5
|
this.stats = {};
|
|
6
6
|
this.enabled = !!process.env.ASTRO_TIMER_PATH;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Start a timer for a scope with a given name.
|
|
10
|
+
*/
|
|
8
11
|
start(name) {
|
|
9
12
|
var _a;
|
|
10
13
|
if (!this.enabled)
|
|
@@ -15,6 +18,9 @@ class AstroTimer {
|
|
|
15
18
|
startHeap: process.memoryUsage().heapUsed
|
|
16
19
|
});
|
|
17
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* End a timer for a scope with a given name.
|
|
23
|
+
*/
|
|
18
24
|
end(name) {
|
|
19
25
|
var _a;
|
|
20
26
|
if (!this.enabled)
|
|
@@ -31,6 +37,9 @@ class AstroTimer {
|
|
|
31
37
|
};
|
|
32
38
|
this.ongoingTimers.delete(name);
|
|
33
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Write stats to `process.env.ASTRO_TIMER_PATH`
|
|
42
|
+
*/
|
|
34
43
|
writeStats() {
|
|
35
44
|
if (!this.enabled)
|
|
36
45
|
return;
|
|
@@ -6,6 +6,7 @@ const defaultTSConfig = { extends: "astro/tsconfigs/base" };
|
|
|
6
6
|
const presets = /* @__PURE__ */ new Map([
|
|
7
7
|
[
|
|
8
8
|
"vue",
|
|
9
|
+
// Settings needed for template intellisense when using Volar
|
|
9
10
|
{
|
|
10
11
|
compilerOptions: {
|
|
11
12
|
jsx: "preserve"
|
|
@@ -14,6 +15,7 @@ const presets = /* @__PURE__ */ new Map([
|
|
|
14
15
|
],
|
|
15
16
|
[
|
|
16
17
|
"react",
|
|
18
|
+
// Default TypeScript settings, but we need to redefine them in case the users changed them previously
|
|
17
19
|
{
|
|
18
20
|
compilerOptions: {
|
|
19
21
|
jsx: "react-jsx",
|
|
@@ -23,6 +25,7 @@ const presets = /* @__PURE__ */ new Map([
|
|
|
23
25
|
],
|
|
24
26
|
[
|
|
25
27
|
"preact",
|
|
28
|
+
// https://preactjs.com/guide/v10/typescript/#typescript-configuration
|
|
26
29
|
{
|
|
27
30
|
compilerOptions: {
|
|
28
31
|
jsx: "react-jsx",
|
|
@@ -32,6 +35,7 @@ const presets = /* @__PURE__ */ new Map([
|
|
|
32
35
|
],
|
|
33
36
|
[
|
|
34
37
|
"solid-js",
|
|
38
|
+
// https://www.solidjs.com/guides/typescript#configuring-typescript
|
|
35
39
|
{
|
|
36
40
|
compilerOptions: {
|
|
37
41
|
jsx: "preserve",
|
|
@@ -8,6 +8,9 @@ async function createViteLoader(root, fs) {
|
|
|
8
8
|
clearScreen: false,
|
|
9
9
|
appType: "custom",
|
|
10
10
|
ssr: {
|
|
11
|
+
// NOTE: Vite doesn't externalize linked packages by default. During testing locally,
|
|
12
|
+
// these dependencies trip up Vite's dev SSR transform. Awaiting upstream feature:
|
|
13
|
+
// https://github.com/vitejs/vite/pull/10939
|
|
11
14
|
external: [
|
|
12
15
|
"@astrojs/tailwind",
|
|
13
16
|
"@astrojs/mdx",
|
package/dist/core/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parse, serialize } from "cookie";
|
|
2
|
-
const DELETED_EXPIRATION = new Date(0);
|
|
2
|
+
const DELETED_EXPIRATION = /* @__PURE__ */ new Date(0);
|
|
3
3
|
const DELETED_VALUE = "deleted";
|
|
4
4
|
class AstroCookie {
|
|
5
5
|
constructor(value) {
|
|
@@ -31,6 +31,12 @@ class AstroCookies {
|
|
|
31
31
|
this.#requestValues = null;
|
|
32
32
|
this.#outgoing = null;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Astro.cookies.delete(key) is used to delete a cookie. Using this method will result
|
|
36
|
+
* in a Set-Cookie header added to the response.
|
|
37
|
+
* @param key The cookie to delete
|
|
38
|
+
* @param options Options related to this deletion, such as the path of the cookie.
|
|
39
|
+
*/
|
|
34
40
|
delete(key, options) {
|
|
35
41
|
const serializeOptions = {
|
|
36
42
|
expires: DELETED_EXPIRATION
|
|
@@ -47,6 +53,13 @@ class AstroCookies {
|
|
|
47
53
|
false
|
|
48
54
|
]);
|
|
49
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Astro.cookies.get(key) is used to get a cookie value. The cookie value is read from the
|
|
58
|
+
* request. If you have set a cookie via Astro.cookies.set(key, value), the value will be taken
|
|
59
|
+
* from that set call, overriding any values already part of the request.
|
|
60
|
+
* @param key The cookie to get.
|
|
61
|
+
* @returns An object containing the cookie value as well as convenience methods for converting its value.
|
|
62
|
+
*/
|
|
50
63
|
get(key) {
|
|
51
64
|
if (this.#outgoing !== null && this.#outgoing.has(key)) {
|
|
52
65
|
let [serializedValue, , isSetValue] = this.#outgoing.get(key);
|
|
@@ -60,6 +73,12 @@ class AstroCookies {
|
|
|
60
73
|
const value = values[key];
|
|
61
74
|
return new AstroCookie(value);
|
|
62
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Astro.cookies.has(key) returns a boolean indicating whether this cookie is either
|
|
78
|
+
* part of the initial request or set via Astro.cookies.set(key)
|
|
79
|
+
* @param key The cookie to check for.
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
63
82
|
has(key) {
|
|
64
83
|
if (this.#outgoing !== null && this.#outgoing.has(key)) {
|
|
65
84
|
let [, , isSetValue] = this.#outgoing.get(key);
|
|
@@ -68,6 +87,15 @@ class AstroCookies {
|
|
|
68
87
|
const values = this.#ensureParsed();
|
|
69
88
|
return !!values[key];
|
|
70
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Astro.cookies.set(key, value) is used to set a cookie's value. If provided
|
|
92
|
+
* an object it will be stringified via JSON.stringify(value). Additionally you
|
|
93
|
+
* can provide options customizing how this cookie will be set, such as setting httpOnly
|
|
94
|
+
* in order to prevent the cookie from being read in client-side JavaScript.
|
|
95
|
+
* @param key The name of the cookie to set.
|
|
96
|
+
* @param value A value, either a string or other primitive or an object.
|
|
97
|
+
* @param options Options for the cookie, such as the path and security settings.
|
|
98
|
+
*/
|
|
71
99
|
set(key, value, options) {
|
|
72
100
|
let serializedValue;
|
|
73
101
|
if (typeof value === "string") {
|
|
@@ -90,6 +118,12 @@ class AstroCookies {
|
|
|
90
118
|
true
|
|
91
119
|
]);
|
|
92
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Astro.cookies.header() returns an iterator for the cookies that have previously
|
|
123
|
+
* been set by either Astro.cookies.set() or Astro.cookies.delete().
|
|
124
|
+
* This method is primarily used by adapters to set the header on outgoing responses.
|
|
125
|
+
* @returns
|
|
126
|
+
*/
|
|
93
127
|
*headers() {
|
|
94
128
|
if (this.#outgoing == null)
|
|
95
129
|
return;
|
package/dist/core/create-vite.js
CHANGED
|
@@ -25,13 +25,20 @@ import astroScriptsPlugin from "../vite-plugin-scripts/index.js";
|
|
|
25
25
|
import astroScriptsPageSSRPlugin from "../vite-plugin-scripts/page-ssr.js";
|
|
26
26
|
import { vitePluginSSRManifest } from "../vite-plugin-ssr-manifest/index.js";
|
|
27
27
|
const ALWAYS_NOEXTERNAL = [
|
|
28
|
+
// This is only because Vite's native ESM doesn't resolve "exports" correctly.
|
|
28
29
|
"astro",
|
|
30
|
+
// Vite fails on nested `.astro` imports without bundling
|
|
29
31
|
"astro/components",
|
|
32
|
+
// Handle recommended nanostores. Only @nanostores/preact is required from our testing!
|
|
33
|
+
// Full explanation and related bug report: https://github.com/withastro/astro/pull/3667
|
|
30
34
|
"@nanostores/preact",
|
|
35
|
+
// fontsource packages are CSS that need to be processed
|
|
31
36
|
"@fontsource/*"
|
|
32
37
|
];
|
|
33
38
|
const ONLY_DEV_EXTERNAL = [
|
|
39
|
+
// Imported by `<Code/>` which is processed by Vite
|
|
34
40
|
"shiki",
|
|
41
|
+
// Imported by `@astrojs/prism` which exposes `<Prism/>` that is processed by Vite
|
|
35
42
|
"prismjs/components/index.js"
|
|
36
43
|
];
|
|
37
44
|
async function createVite(commandConfig, { settings, logging, mode, command, fs = nodeFs }) {
|
|
@@ -45,7 +52,12 @@ async function createVite(commandConfig, { settings, logging, mode, command, fs
|
|
|
45
52
|
if (((_a2 = pkgJson == null ? void 0 : pkgJson.astro) == null ? void 0 : _a2.external) === true) {
|
|
46
53
|
return false;
|
|
47
54
|
}
|
|
48
|
-
return (
|
|
55
|
+
return (
|
|
56
|
+
// Attempt: package relies on `astro`. ✅ Definitely an Astro package
|
|
57
|
+
((_b2 = pkgJson.peerDependencies) == null ? void 0 : _b2.astro) || ((_c = pkgJson.dependencies) == null ? void 0 : _c.astro) || // Attempt: package is tagged with `astro` or `astro-component`. ✅ Likely a community package
|
|
58
|
+
((_d = pkgJson.keywords) == null ? void 0 : _d.includes("astro")) || ((_e = pkgJson.keywords) == null ? void 0 : _e.includes("astro-component")) || // Attempt: package is named `astro-something` or `@scope/astro-something`. ✅ Likely a community package
|
|
59
|
+
/^(@[^\/]+\/)?astro\-/.test(pkgJson.name)
|
|
60
|
+
);
|
|
49
61
|
},
|
|
50
62
|
isFrameworkPkgByName(pkgName) {
|
|
51
63
|
const isNotAstroPkg = isCommonNotAstro(pkgName);
|
|
@@ -58,8 +70,11 @@ async function createVite(commandConfig, { settings, logging, mode, command, fs
|
|
|
58
70
|
});
|
|
59
71
|
const commonConfig = {
|
|
60
72
|
cacheDir: fileURLToPath(new URL("./node_modules/.vite/", settings.config.root)),
|
|
73
|
+
// using local caches allows Astro to be used in monorepos, etc.
|
|
61
74
|
clearScreen: false,
|
|
75
|
+
// we want to control the output, not Vite
|
|
62
76
|
logLevel: "warn",
|
|
77
|
+
// log warnings and errors only
|
|
63
78
|
appType: "custom",
|
|
64
79
|
optimizeDeps: {
|
|
65
80
|
entries: ["src/**/*"],
|
|
@@ -70,6 +85,8 @@ async function createVite(commandConfig, { settings, logging, mode, command, fs
|
|
|
70
85
|
astroLoadFallbackPlugin({ fs, root: settings.config.root }),
|
|
71
86
|
astroVitePlugin({ settings, logging }),
|
|
72
87
|
astroScriptsPlugin({ settings }),
|
|
88
|
+
// The server plugin is for dev only and having it run during the build causes
|
|
89
|
+
// the build to run very slow as the filewatcher is triggered often.
|
|
73
90
|
mode !== "build" && vitePluginAstroServer({ settings, logging, fs }),
|
|
74
91
|
envVitePlugin({ settings }),
|
|
75
92
|
markdownVitePlugin({ settings, logging }),
|
|
@@ -95,23 +112,32 @@ async function createVite(commandConfig, { settings, logging, mode, command, fs
|
|
|
95
112
|
},
|
|
96
113
|
server: {
|
|
97
114
|
hmr: process.env.NODE_ENV === "test" || process.env.NODE_ENV === "production" ? false : void 0,
|
|
98
|
-
|
|
115
|
+
// disable HMR for test
|
|
116
|
+
// handle Vite URLs
|
|
117
|
+
proxy: {
|
|
118
|
+
// add proxies here
|
|
119
|
+
},
|
|
99
120
|
watch: {
|
|
121
|
+
// Prevent watching during the build to speed it up
|
|
100
122
|
ignored: mode === "build" ? ["**"] : void 0
|
|
101
123
|
}
|
|
102
124
|
},
|
|
103
125
|
resolve: {
|
|
104
126
|
alias: [
|
|
105
127
|
{
|
|
128
|
+
// This is needed for Deno compatibility, as the non-browser version
|
|
129
|
+
// of this module depends on Node `crypto`
|
|
106
130
|
find: "randombytes",
|
|
107
131
|
replacement: "randombytes/browser"
|
|
108
132
|
},
|
|
109
133
|
{
|
|
134
|
+
// Typings are imported from 'astro' (e.g. import { Type } from 'astro')
|
|
110
135
|
find: /^astro$/,
|
|
111
136
|
replacement: fileURLToPath(new URL("../@types/astro", import.meta.url))
|
|
112
137
|
}
|
|
113
138
|
],
|
|
114
139
|
conditions: ["astro"],
|
|
140
|
+
// Astro imports in third-party packages should use the same version as root
|
|
115
141
|
dedupe: ["astro"]
|
|
116
142
|
},
|
|
117
143
|
ssr: {
|
|
@@ -125,7 +151,7 @@ async function createVite(commandConfig, { settings, logging, mode, command, fs
|
|
|
125
151
|
const applyToFilter = command === "build" ? "serve" : "build";
|
|
126
152
|
const applyArgs = [
|
|
127
153
|
{ ...settings.config.vite, mode },
|
|
128
|
-
{ command, mode }
|
|
154
|
+
{ command: command === "dev" ? "serve" : command, mode }
|
|
129
155
|
];
|
|
130
156
|
plugins = plugins.flat(Infinity).filter((p) => {
|
|
131
157
|
if (!p || (p == null ? void 0 : p.apply) === applyToFilter) {
|
|
@@ -206,6 +232,7 @@ const COMMON_PREFIXES_NOT_ASTRO = [
|
|
|
206
232
|
function isCommonNotAstro(dep) {
|
|
207
233
|
return COMMON_DEPENDENCIES_NOT_ASTRO.includes(dep) || COMMON_PREFIXES_NOT_ASTRO.some(
|
|
208
234
|
(prefix) => prefix.startsWith("@") ? dep.startsWith(prefix) : dep.substring(dep.lastIndexOf("/") + 1).startsWith(prefix)
|
|
235
|
+
// check prefix omitting @scope/
|
|
209
236
|
);
|
|
210
237
|
}
|
|
211
238
|
export {
|
package/dist/core/dev/dev.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { AddressInfo } from 'net';
|
|
|
6
6
|
import type * as vite from 'vite';
|
|
7
7
|
import type yargs from 'yargs-parser';
|
|
8
8
|
import type { AstroSettings } from '../../@types/astro';
|
|
9
|
-
import { LogOptions } from '../logger/core.js';
|
|
9
|
+
import { type LogOptions } from '../logger/core.js';
|
|
10
10
|
export interface DevOptions {
|
|
11
11
|
configFlag: string | undefined;
|
|
12
12
|
configFlagPath: string | undefined;
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -31,6 +31,7 @@ async function dev(settings, options) {
|
|
|
31
31
|
const restart = await createContainerWithAutomaticRestart({
|
|
32
32
|
flags: options.flags ?? {},
|
|
33
33
|
handleConfigError: options.handleConfigError,
|
|
34
|
+
// eslint-disable-next-line no-console
|
|
34
35
|
beforeRestart: () => console.clear(),
|
|
35
36
|
params: {
|
|
36
37
|
settings,
|
|
@@ -51,7 +52,7 @@ async function dev(settings, options) {
|
|
|
51
52
|
isRestart: options.isRestart
|
|
52
53
|
})
|
|
53
54
|
);
|
|
54
|
-
const currentVersion = "2.1.
|
|
55
|
+
const currentVersion = "2.1.5";
|
|
55
56
|
if (currentVersion.includes("-")) {
|
|
56
57
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
57
58
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { AstroConfig, EndpointHandler } from '../../@types/astro';
|
|
3
3
|
import type { Environment, RenderContext } from '../render/index';
|
|
4
4
|
import { AstroCookies } from '../cookies/index.js';
|
|
5
|
-
import { LogOptions } from '../logger/core.js';
|
|
5
|
+
import { type LogOptions } from '../logger/core.js';
|
|
6
6
|
type EndpointCallResult = {
|
|
7
7
|
type: 'simple';
|
|
8
8
|
body: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorWithMetadata } from '../errors.js';
|
|
1
|
+
import { type ErrorWithMetadata } from '../errors.js';
|
|
2
2
|
/**
|
|
3
3
|
* Takes any error-like object and returns a standardized Error + metadata object.
|
|
4
4
|
* Useful for consistent reporting regardless of where the error surfaced from.
|
|
@@ -92,7 +92,8 @@ function collectInfoFromStacktrace(error) {
|
|
|
92
92
|
error.stack = normalizeLF(error.stack);
|
|
93
93
|
const stackText = stripAnsi(error.stack);
|
|
94
94
|
if (!error.loc || !error.loc.column && !error.loc.line) {
|
|
95
|
-
const possibleFilePath = ((_a = error.loc) == null ? void 0 : _a.file) || error.pluginCode || error.id ||
|
|
95
|
+
const possibleFilePath = ((_a = error.loc) == null ? void 0 : _a.file) || error.pluginCode || error.id || // TODO: this could be better, `src` might be something else
|
|
96
|
+
stackText.split("\n").find((ln) => ln.includes("src") || ln.includes("node_modules"));
|
|
96
97
|
const source = possibleFilePath == null ? void 0 : possibleFilePath.replace(/^[^(]+\(([^)]+).*$/, "$1").replace(/^\s+at\s+/, "");
|
|
97
98
|
let file = source == null ? void 0 : source.replace(/(:[0-9]+)/g, "");
|
|
98
99
|
const location = /:([0-9]+):([0-9]+)/g.exec(source) ?? [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ErrorPayload } from 'vite';
|
|
2
2
|
import type { ModuleLoader } from '../../module-loader/index.js';
|
|
3
|
-
import { ErrorWithMetadata } from '../errors.js';
|
|
3
|
+
import { type ErrorWithMetadata } from '../errors.js';
|
|
4
4
|
import type { SSRLoadedRenderer } from './../../../@types/astro.js';
|
|
5
5
|
export declare function enhanceViteSSRError({ error, filePath, loader, renderers, }: {
|
|
6
6
|
error: unknown;
|
|
@@ -72,6 +72,7 @@ function enhanceViteSSRError({
|
|
|
72
72
|
return safeError;
|
|
73
73
|
}
|
|
74
74
|
const ALTERNATIVE_JS_EXTS = ["cjs", "mjs"];
|
|
75
|
+
const ALTERNATIVE_MD_EXTS = ["mdoc"];
|
|
75
76
|
async function getViteErrorPayload(err) {
|
|
76
77
|
var _a, _b, _c, _d, _e, _f;
|
|
77
78
|
let plugin = err.plugin;
|
|
@@ -83,6 +84,7 @@ async function getViteErrorPayload(err) {
|
|
|
83
84
|
const hasDocs = err.type && err.name && [
|
|
84
85
|
"AstroError",
|
|
85
86
|
"AggregateError",
|
|
87
|
+
/* 'CompilerError' ,*/
|
|
86
88
|
"CSSError",
|
|
87
89
|
"MarkdownError"
|
|
88
90
|
] || ["FailedToLoadModuleSSR", "InvalidGlob"].includes(err.name);
|
|
@@ -92,6 +94,9 @@ async function getViteErrorPayload(err) {
|
|
|
92
94
|
if (ALTERNATIVE_JS_EXTS.includes(highlighterLang ?? "")) {
|
|
93
95
|
highlighterLang = "js";
|
|
94
96
|
}
|
|
97
|
+
if (ALTERNATIVE_MD_EXTS.includes(highlighterLang ?? "")) {
|
|
98
|
+
highlighterLang = "md";
|
|
99
|
+
}
|
|
95
100
|
const highlightedCode = err.fullCode ? highlighter.codeToHtml(err.fullCode, {
|
|
96
101
|
lang: highlighterLang,
|
|
97
102
|
lineOptions: ((_c = err.loc) == null ? void 0 : _c.line) ? [{ line: err.loc.line, classes: ["error-line"] }] : void 0
|