astro 4.10.1 → 4.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/astro.d.ts +43 -39
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +4 -4
- package/dist/container/index.d.ts +32 -1
- package/dist/container/index.js +45 -0
- package/dist/container/pipeline.d.ts +1 -1
- package/dist/container/pipeline.js +17 -18
- package/dist/container/vite-plugin-container.d.ts +2 -0
- package/dist/container/vite-plugin-container.js +15 -0
- package/dist/content/runtime.js +2 -2
- package/dist/content/types-generator.js +30 -32
- package/dist/content/utils.d.ts +11 -0
- package/dist/content/utils.js +49 -0
- package/dist/content/vite-plugin-content-imports.d.ts +3 -1
- package/dist/content/vite-plugin-content-imports.js +15 -4
- package/dist/core/app/index.js +0 -4
- package/dist/core/app/pipeline.d.ts +1 -1
- package/dist/core/app/pipeline.js +4 -4
- package/dist/core/base-pipeline.d.ts +1 -1
- package/dist/core/base-pipeline.js +1 -1
- package/dist/core/build/generate.js +2 -1
- package/dist/core/build/internal.d.ts +4 -0
- package/dist/core/build/internal.js +2 -1
- package/dist/core/build/page-data.js +2 -4
- package/dist/core/build/pipeline.d.ts +1 -1
- package/dist/core/build/pipeline.js +4 -4
- package/dist/core/build/plugins/plugin-chunks.js +6 -0
- package/dist/core/build/plugins/plugin-prerender.js +55 -48
- package/dist/core/build/plugins/plugin-ssr.js +15 -12
- package/dist/core/build/static-build.js +36 -44
- package/dist/core/build/types.d.ts +0 -1
- package/dist/core/config/schema.d.ts +422 -78
- package/dist/core/constants.d.ts +4 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/create-vite.js +4 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +31 -0
- package/dist/core/errors/errors-data.js +12 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/render-context.d.ts +1 -1
- package/dist/core/render-context.js +28 -22
- package/dist/core/routing/astro-designed-error-pages.d.ts +1 -0
- package/dist/core/routing/astro-designed-error-pages.js +15 -1
- package/dist/core/routing/params.js +1 -1
- package/dist/core/util.js +5 -2
- package/dist/env/config.d.ts +2 -1
- package/dist/env/config.js +4 -0
- package/dist/env/constants.d.ts +0 -1
- package/dist/env/constants.js +0 -2
- package/dist/env/runtime.d.ts +3 -1
- package/dist/env/runtime.js +8 -1
- package/dist/env/schema.d.ts +198 -220
- package/dist/env/schema.js +47 -79
- package/dist/env/validators.js +73 -10
- package/dist/env/vite-plugin-env.js +15 -15
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +4 -11
- package/dist/jsx/server.d.ts +3 -5
- package/dist/jsx/server.js +3 -1
- package/dist/runtime/server/render/astro/render.js +8 -2
- package/dist/vite-plugin-astro/index.js +1 -1
- package/dist/vite-plugin-astro-server/pipeline.d.ts +1 -1
- package/dist/vite-plugin-astro-server/pipeline.js +4 -4
- package/dist/vite-plugin-astro-server/request.js +2 -2
- package/dist/vite-plugin-astro-server/route.js +18 -1
- package/package.json +16 -16
- package/templates/env/module.mjs +14 -5
- package/templates/env/types.d.ts +1 -12
package/dist/env/validators.js
CHANGED
|
@@ -1,17 +1,66 @@
|
|
|
1
1
|
function getEnvFieldType(options) {
|
|
2
2
|
const optional = options.optional ? options.default !== void 0 ? false : true : false;
|
|
3
|
-
|
|
3
|
+
let type;
|
|
4
|
+
if (options.type === "enum") {
|
|
5
|
+
type = options.values.map((v) => `'${v}'`).join(" | ");
|
|
6
|
+
} else {
|
|
7
|
+
type = options.type;
|
|
8
|
+
}
|
|
9
|
+
return `${type}${optional ? " | undefined" : ""}`;
|
|
4
10
|
}
|
|
5
|
-
const stringValidator = (input) => {
|
|
11
|
+
const stringValidator = ({ max, min, length, url, includes, startsWith, endsWith }) => (input) => {
|
|
12
|
+
let valid = typeof input === "string";
|
|
13
|
+
if (valid && max !== void 0) {
|
|
14
|
+
valid = input.length <= max;
|
|
15
|
+
}
|
|
16
|
+
if (valid && min !== void 0) {
|
|
17
|
+
valid = input.length >= min;
|
|
18
|
+
}
|
|
19
|
+
if (valid && length !== void 0) {
|
|
20
|
+
valid = input.length === length;
|
|
21
|
+
}
|
|
22
|
+
if (valid && url !== void 0) {
|
|
23
|
+
try {
|
|
24
|
+
new URL(input);
|
|
25
|
+
} catch (_) {
|
|
26
|
+
valid = false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (valid && includes !== void 0) {
|
|
30
|
+
valid = input.includes(includes);
|
|
31
|
+
}
|
|
32
|
+
if (valid && startsWith !== void 0) {
|
|
33
|
+
valid = input.startsWith(startsWith);
|
|
34
|
+
}
|
|
35
|
+
if (valid && endsWith !== void 0) {
|
|
36
|
+
valid = input.endsWith(endsWith);
|
|
37
|
+
}
|
|
6
38
|
return {
|
|
7
|
-
valid
|
|
39
|
+
valid,
|
|
8
40
|
parsed: input
|
|
9
41
|
};
|
|
10
42
|
};
|
|
11
|
-
const numberValidator = (input) => {
|
|
43
|
+
const numberValidator = ({ gt, min, lt, max, int }) => (input) => {
|
|
12
44
|
const num = parseFloat(input ?? "");
|
|
45
|
+
let valid = !isNaN(num);
|
|
46
|
+
if (valid && gt !== void 0) {
|
|
47
|
+
valid = num > gt;
|
|
48
|
+
}
|
|
49
|
+
if (valid && min !== void 0) {
|
|
50
|
+
valid = num >= min;
|
|
51
|
+
}
|
|
52
|
+
if (valid && lt !== void 0) {
|
|
53
|
+
valid = num < lt;
|
|
54
|
+
}
|
|
55
|
+
if (valid && max !== void 0) {
|
|
56
|
+
valid = num <= max;
|
|
57
|
+
}
|
|
58
|
+
if (valid && int !== void 0) {
|
|
59
|
+
const isInt = Number.isInteger(num);
|
|
60
|
+
valid = int ? isInt : !isInt;
|
|
61
|
+
}
|
|
13
62
|
return {
|
|
14
|
-
valid
|
|
63
|
+
valid,
|
|
15
64
|
parsed: num
|
|
16
65
|
};
|
|
17
66
|
};
|
|
@@ -22,12 +71,26 @@ const booleanValidator = (input) => {
|
|
|
22
71
|
parsed: bool
|
|
23
72
|
};
|
|
24
73
|
};
|
|
74
|
+
const enumValidator = ({ values }) => (input) => {
|
|
75
|
+
return {
|
|
76
|
+
valid: typeof input === "string" ? values.includes(input) : false,
|
|
77
|
+
parsed: input
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
function selectValidator(options) {
|
|
81
|
+
switch (options.type) {
|
|
82
|
+
case "string":
|
|
83
|
+
return stringValidator(options);
|
|
84
|
+
case "number":
|
|
85
|
+
return numberValidator(options);
|
|
86
|
+
case "boolean":
|
|
87
|
+
return booleanValidator;
|
|
88
|
+
case "enum":
|
|
89
|
+
return enumValidator(options);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
25
92
|
function validateEnvVariable(value, options) {
|
|
26
|
-
const validator =
|
|
27
|
-
string: stringValidator,
|
|
28
|
-
number: numberValidator,
|
|
29
|
-
boolean: booleanValidator
|
|
30
|
-
}[options.type];
|
|
93
|
+
const validator = selectValidator(options);
|
|
31
94
|
const type = getEnvFieldType(options);
|
|
32
95
|
if (options.optional || options.default !== void 0) {
|
|
33
96
|
if (value === void 0) {
|
|
@@ -46,9 +46,8 @@ function astroEnv({
|
|
|
46
46
|
fs,
|
|
47
47
|
content: getDts({
|
|
48
48
|
fs,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
serverSecret: serverTemplates.types.secret
|
|
49
|
+
client: clientTemplates.types,
|
|
50
|
+
server: serverTemplates.types
|
|
52
51
|
})
|
|
53
52
|
});
|
|
54
53
|
},
|
|
@@ -119,13 +118,12 @@ function validatePublicVariables({
|
|
|
119
118
|
return valid;
|
|
120
119
|
}
|
|
121
120
|
function getDts({
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
serverSecret,
|
|
121
|
+
client,
|
|
122
|
+
server,
|
|
125
123
|
fs
|
|
126
124
|
}) {
|
|
127
125
|
const template = fs.readFileSync(TYPES_TEMPLATE_URL, "utf-8");
|
|
128
|
-
return template.replace("// @@CLIENT@@",
|
|
126
|
+
return template.replace("// @@CLIENT@@", client).replace("// @@SERVER@@", server);
|
|
129
127
|
}
|
|
130
128
|
function getClientTemplates({
|
|
131
129
|
validatedVariables
|
|
@@ -148,26 +146,28 @@ function getServerTemplates({
|
|
|
148
146
|
fs
|
|
149
147
|
}) {
|
|
150
148
|
let module = fs.readFileSync(MODULE_TEMPLATE_URL, "utf-8");
|
|
151
|
-
let
|
|
152
|
-
let
|
|
149
|
+
let types = "";
|
|
150
|
+
let onSetGetEnv = "";
|
|
153
151
|
for (const { key, type, value } of validatedVariables.filter((e) => e.context === "server")) {
|
|
154
152
|
module += `export const ${key} = ${JSON.stringify(value)};`;
|
|
155
|
-
|
|
153
|
+
types += `export const ${key}: ${type};
|
|
156
154
|
`;
|
|
157
155
|
}
|
|
158
156
|
for (const [key, options] of Object.entries(schema)) {
|
|
159
157
|
if (!(options.context === "server" && options.access === "secret")) {
|
|
160
158
|
continue;
|
|
161
159
|
}
|
|
162
|
-
|
|
160
|
+
types += `export const ${key}: ${getEnvFieldType(options)};
|
|
161
|
+
`;
|
|
162
|
+
module += `export let ${key} = _internalGetSecret(${JSON.stringify(key)});
|
|
163
|
+
`;
|
|
164
|
+
onSetGetEnv += `${key} = reset ? undefined : _internalGetSecret(${JSON.stringify(key)});
|
|
163
165
|
`;
|
|
164
166
|
}
|
|
167
|
+
module = module.replace("// @@ON_SET_GET_ENV@@", onSetGetEnv);
|
|
165
168
|
return {
|
|
166
169
|
module,
|
|
167
|
-
types
|
|
168
|
-
public: publicTypes,
|
|
169
|
-
secret: secretTypes
|
|
170
|
-
}
|
|
170
|
+
types
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
export {
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare function getLocaleAbsoluteUrlList(params: GetLocalesAbsoluteUrlLi
|
|
|
60
60
|
*/
|
|
61
61
|
export declare function getPathByLocale(locale: string, locales: Locales): string;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* A utility function that retrieves the preferred locale that correspond to a path.
|
|
64
64
|
*
|
|
65
65
|
* @param path
|
|
66
66
|
* @param locales
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { appendForwardSlash, joinPaths } from "@astrojs/internal-helpers/path";
|
|
2
2
|
import { shouldAppendForwardSlash } from "../core/build/util.js";
|
|
3
3
|
import { REROUTE_DIRECTIVE_HEADER } from "../core/constants.js";
|
|
4
|
-
import { MissingLocale } from "../core/errors/errors-data.js";
|
|
4
|
+
import { MissingLocale, i18nNoLocaleFoundInPath } from "../core/errors/errors-data.js";
|
|
5
5
|
import { AstroError } from "../core/errors/index.js";
|
|
6
6
|
import { createI18nMiddleware } from "./middleware.js";
|
|
7
7
|
function requestHasLocale(locales) {
|
|
@@ -110,21 +110,21 @@ function getPathByLocale(locale, locales) {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
throw new
|
|
113
|
+
throw new AstroError(i18nNoLocaleFoundInPath);
|
|
114
114
|
}
|
|
115
115
|
function getLocaleByPath(path, locales) {
|
|
116
116
|
for (const locale of locales) {
|
|
117
117
|
if (typeof locale !== "string") {
|
|
118
118
|
if (locale.path === path) {
|
|
119
119
|
const code = locale.codes.at(0);
|
|
120
|
-
if (code === void 0) throw new
|
|
120
|
+
if (code === void 0) throw new AstroError(i18nNoLocaleFoundInPath);
|
|
121
121
|
return code;
|
|
122
122
|
}
|
|
123
123
|
} else if (locale === path) {
|
|
124
124
|
return locale;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
throw new
|
|
127
|
+
throw new AstroError(i18nNoLocaleFoundInPath);
|
|
128
128
|
}
|
|
129
129
|
function normalizeTheLocale(locale) {
|
|
130
130
|
return locale.replaceAll("_", "-").toLowerCase();
|
|
@@ -163,13 +163,6 @@ function peekCodePathToUse(locales, locale) {
|
|
|
163
163
|
}
|
|
164
164
|
return void 0;
|
|
165
165
|
}
|
|
166
|
-
class Unreachable extends Error {
|
|
167
|
-
constructor() {
|
|
168
|
-
super(
|
|
169
|
-
"Astro encountered an unexpected line of code.\nIn most cases, this is not your fault, but a bug in astro code.\nIf there isn't one already, please create an issue.\nhttps://astro.build/issues"
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
166
|
function redirectToDefaultLocale({
|
|
174
167
|
trailingSlash,
|
|
175
168
|
format,
|
package/dist/jsx/server.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NamedSSRLoadedRendererValue } from '../@types/astro.js';
|
|
1
2
|
export declare function check(Component: any, props: any, { default: children, ...slotted }?: {
|
|
2
3
|
default?: null | undefined;
|
|
3
4
|
}): Promise<any>;
|
|
@@ -6,8 +7,5 @@ export declare function renderToStaticMarkup(this: any, Component: any, props?:
|
|
|
6
7
|
}): Promise<{
|
|
7
8
|
html: any;
|
|
8
9
|
}>;
|
|
9
|
-
declare const
|
|
10
|
-
|
|
11
|
-
renderToStaticMarkup: typeof renderToStaticMarkup;
|
|
12
|
-
};
|
|
13
|
-
export default _default;
|
|
10
|
+
declare const renderer: NamedSSRLoadedRendererValue;
|
|
11
|
+
export default renderer;
|
package/dist/jsx/server.js
CHANGED
|
@@ -44,10 +44,12 @@ function throwEnhancedErrorIfMdxComponent(error, Component) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
const renderer = {
|
|
48
|
+
name: "astro:jsx",
|
|
48
49
|
check,
|
|
49
50
|
renderToStaticMarkup
|
|
50
51
|
};
|
|
52
|
+
var server_default = renderer;
|
|
51
53
|
export {
|
|
52
54
|
check,
|
|
53
55
|
server_default as default,
|
|
@@ -150,6 +150,9 @@ async function renderToAsyncIterable(result, componentFactory, props, children,
|
|
|
150
150
|
if (result.cancelled) return { done: true, value: void 0 };
|
|
151
151
|
if (next !== null) {
|
|
152
152
|
await next.promise;
|
|
153
|
+
} else if (!renderingComplete && !buffer.length) {
|
|
154
|
+
next = promiseWithResolvers();
|
|
155
|
+
await next.promise;
|
|
153
156
|
}
|
|
154
157
|
if (!renderingComplete) {
|
|
155
158
|
next = promiseWithResolvers();
|
|
@@ -170,8 +173,9 @@ async function renderToAsyncIterable(result, componentFactory, props, children,
|
|
|
170
173
|
}
|
|
171
174
|
buffer.length = 0;
|
|
172
175
|
const returnValue = {
|
|
173
|
-
// The iterator is done
|
|
174
|
-
|
|
176
|
+
// The iterator is done when rendering has finished
|
|
177
|
+
// and there are no more chunks to return.
|
|
178
|
+
done: length === 0 && renderingComplete,
|
|
175
179
|
value: mergedArray
|
|
176
180
|
};
|
|
177
181
|
return returnValue;
|
|
@@ -197,6 +201,8 @@ async function renderToAsyncIterable(result, componentFactory, props, children,
|
|
|
197
201
|
if (bytes.length > 0) {
|
|
198
202
|
buffer.push(bytes);
|
|
199
203
|
next?.resolve();
|
|
204
|
+
} else if (buffer.length > 0) {
|
|
205
|
+
next?.resolve();
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
208
|
};
|
|
@@ -148,7 +148,7 @@ File: ${id}`
|
|
|
148
148
|
},
|
|
149
149
|
async transform(source, id) {
|
|
150
150
|
const parsedId = parseAstroRequest(id);
|
|
151
|
-
if (!
|
|
151
|
+
if (!parsedId.filename.endsWith(".astro") || parsedId.query.astro) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
const filename = normalizePath(parsedId.filename);
|
|
@@ -19,7 +19,7 @@ export declare class DevPipeline extends Pipeline {
|
|
|
19
19
|
preload(routeData: RouteData, filePath: URL): Promise<ComponentInstance>;
|
|
20
20
|
clearRouteCache(): void;
|
|
21
21
|
getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
|
|
22
|
-
tryRewrite(payload: RewritePayload, request: Request, sourceRoute: RouteData): Promise<[RouteData, ComponentInstance]>;
|
|
22
|
+
tryRewrite(payload: RewritePayload, request: Request, sourceRoute: RouteData): Promise<[RouteData, ComponentInstance, URL]>;
|
|
23
23
|
setManifestData(manifestData: ManifestData): void;
|
|
24
24
|
rewriteKnownRoute(route: string, sourceRoute: RouteData): ComponentInstance;
|
|
25
25
|
}
|
|
@@ -138,8 +138,8 @@ class DevPipeline extends Pipeline {
|
|
|
138
138
|
if (!this.manifestData) {
|
|
139
139
|
throw new Error("Missing manifest data. This is an internal error, please file an issue.");
|
|
140
140
|
}
|
|
141
|
+
let finalUrl = void 0;
|
|
141
142
|
for (const route of this.manifestData.routes) {
|
|
142
|
-
let finalUrl = void 0;
|
|
143
143
|
if (payload instanceof URL) {
|
|
144
144
|
finalUrl = payload;
|
|
145
145
|
} else if (payload instanceof Request) {
|
|
@@ -155,13 +155,13 @@ class DevPipeline extends Pipeline {
|
|
|
155
155
|
break;
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
if (foundRoute) {
|
|
158
|
+
if (foundRoute && finalUrl) {
|
|
159
159
|
if (foundRoute.pathname === "/404") {
|
|
160
160
|
const componentInstance = this.rewriteKnownRoute(foundRoute.pathname, sourceRoute);
|
|
161
|
-
return [foundRoute, componentInstance];
|
|
161
|
+
return [foundRoute, componentInstance, finalUrl];
|
|
162
162
|
} else {
|
|
163
163
|
const componentInstance = await this.getComponentByRoute(foundRoute);
|
|
164
|
-
return [foundRoute, componentInstance];
|
|
164
|
+
return [foundRoute, componentInstance, finalUrl];
|
|
165
165
|
}
|
|
166
166
|
} else {
|
|
167
167
|
throw new AstroError({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { removeTrailingForwardSlash } from "../core/path.js";
|
|
2
2
|
import { runWithErrorHandling } from "./controller.js";
|
|
3
3
|
import { recordServerError } from "./error.js";
|
|
4
4
|
import { handle500Response } from "./response.js";
|
|
@@ -12,7 +12,7 @@ async function handleRequest({
|
|
|
12
12
|
}) {
|
|
13
13
|
const { config, loader } = pipeline;
|
|
14
14
|
const origin = `${loader.isHttps() ? "https" : "http"}://${incomingRequest.headers.host}`;
|
|
15
|
-
const url = new URL(
|
|
15
|
+
const url = new URL(origin + incomingRequest.url);
|
|
16
16
|
let pathname;
|
|
17
17
|
if (config.trailingSlash === "never" && !incomingRequest.url) {
|
|
18
18
|
pathname = "";
|
|
@@ -21,6 +21,10 @@ function getCustom404Route(manifestData) {
|
|
|
21
21
|
const route404 = /^\/404\/?$/;
|
|
22
22
|
return manifestData.routes.find((r) => route404.test(r.route));
|
|
23
23
|
}
|
|
24
|
+
function getCustom500Route(manifestData) {
|
|
25
|
+
const route500 = /^\/500\/?$/;
|
|
26
|
+
return manifestData.routes.find((r) => route500.test(r.route));
|
|
27
|
+
}
|
|
24
28
|
async function matchRoute(pathname, manifestData, pipeline) {
|
|
25
29
|
const { config, logger, routeCache, serverLike, settings } = pipeline;
|
|
26
30
|
const matches = matchAllRoutes(pathname, manifestData);
|
|
@@ -207,7 +211,20 @@ async function handleRoute({
|
|
|
207
211
|
routeData: route
|
|
208
212
|
});
|
|
209
213
|
}
|
|
210
|
-
let response
|
|
214
|
+
let response;
|
|
215
|
+
try {
|
|
216
|
+
response = await renderContext.render(mod);
|
|
217
|
+
} catch (err) {
|
|
218
|
+
const custom500 = getCustom500Route(manifestData);
|
|
219
|
+
if (!custom500) {
|
|
220
|
+
throw err;
|
|
221
|
+
}
|
|
222
|
+
logger.error("router", err.stack || err.message);
|
|
223
|
+
const filePath = new URL(`./${custom500.component}`, config.root);
|
|
224
|
+
const preloadedComponent = await pipeline.preload(custom500, filePath);
|
|
225
|
+
response = await renderContext.render(preloadedComponent);
|
|
226
|
+
status = 500;
|
|
227
|
+
}
|
|
211
228
|
if (isLoggedRequest(pathname)) {
|
|
212
229
|
const timeEnd = performance.now();
|
|
213
230
|
logger.info(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.3",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -110,15 +110,15 @@
|
|
|
110
110
|
],
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@astrojs/compiler": "^2.8.0",
|
|
113
|
-
"@babel/core": "^7.24.
|
|
114
|
-
"@babel/generator": "^7.24.
|
|
115
|
-
"@babel/parser": "^7.24.
|
|
116
|
-
"@babel/plugin-transform-react-jsx": "^7.24.
|
|
117
|
-
"@babel/traverse": "^7.24.
|
|
118
|
-
"@babel/types": "^7.24.
|
|
113
|
+
"@babel/core": "^7.24.7",
|
|
114
|
+
"@babel/generator": "^7.24.7",
|
|
115
|
+
"@babel/parser": "^7.24.7",
|
|
116
|
+
"@babel/plugin-transform-react-jsx": "^7.24.7",
|
|
117
|
+
"@babel/traverse": "^7.24.7",
|
|
118
|
+
"@babel/types": "^7.24.7",
|
|
119
119
|
"@types/babel__core": "^7.20.5",
|
|
120
120
|
"@types/cookie": "^0.6.0",
|
|
121
|
-
"acorn": "^8.
|
|
121
|
+
"acorn": "^8.12.0",
|
|
122
122
|
"aria-query": "^5.3.0",
|
|
123
123
|
"axobject-query": "^4.0.0",
|
|
124
124
|
"boxen": "^7.1.1",
|
|
@@ -128,14 +128,14 @@
|
|
|
128
128
|
"common-ancestor-path": "^1.0.1",
|
|
129
129
|
"cookie": "^0.6.0",
|
|
130
130
|
"cssesc": "^3.0.0",
|
|
131
|
-
"debug": "^4.3.
|
|
131
|
+
"debug": "^4.3.5",
|
|
132
132
|
"deterministic-object-hash": "^2.0.2",
|
|
133
133
|
"devalue": "^5.0.0",
|
|
134
134
|
"diff": "^5.2.0",
|
|
135
135
|
"dlv": "^1.1.3",
|
|
136
136
|
"dset": "^3.1.3",
|
|
137
137
|
"es-module-lexer": "^1.5.3",
|
|
138
|
-
"esbuild": "^0.21.
|
|
138
|
+
"esbuild": "^0.21.5",
|
|
139
139
|
"estree-walker": "^3.0.3",
|
|
140
140
|
"execa": "^8.0.1",
|
|
141
141
|
"fast-glob": "^3.3.2",
|
|
@@ -157,21 +157,21 @@
|
|
|
157
157
|
"rehype": "^13.0.1",
|
|
158
158
|
"resolve": "^1.22.8",
|
|
159
159
|
"semver": "^7.6.2",
|
|
160
|
-
"shiki": "^1.6.
|
|
160
|
+
"shiki": "^1.6.5",
|
|
161
161
|
"string-width": "^7.1.0",
|
|
162
162
|
"strip-ansi": "^7.1.0",
|
|
163
163
|
"tsconfck": "^3.1.0",
|
|
164
164
|
"unist-util-visit": "^5.0.0",
|
|
165
165
|
"vfile": "^6.0.1",
|
|
166
|
-
"vite": "^5.
|
|
166
|
+
"vite": "^5.3.1",
|
|
167
167
|
"vitefu": "^0.2.5",
|
|
168
168
|
"which-pm": "^2.2.0",
|
|
169
169
|
"yargs-parser": "^21.1.1",
|
|
170
170
|
"zod": "^3.23.8",
|
|
171
171
|
"zod-to-json-schema": "^3.23.0",
|
|
172
172
|
"@astrojs/internal-helpers": "0.4.0",
|
|
173
|
-
"@astrojs/
|
|
174
|
-
"@astrojs/
|
|
173
|
+
"@astrojs/telemetry": "3.1.0",
|
|
174
|
+
"@astrojs/markdown-remark": "5.1.0"
|
|
175
175
|
},
|
|
176
176
|
"optionalDependencies": {
|
|
177
177
|
"sharp": "^0.33.3"
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
"eol": "^0.9.1",
|
|
205
205
|
"mdast-util-mdx": "^3.0.0",
|
|
206
206
|
"mdast-util-mdx-jsx": "^3.1.2",
|
|
207
|
-
"memfs": "^4.9.
|
|
207
|
+
"memfs": "^4.9.3",
|
|
208
208
|
"node-mocks-http": "^1.14.1",
|
|
209
209
|
"parse-srcset": "^1.0.2",
|
|
210
210
|
"rehype-autolink-headings": "^7.1.0",
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
"rehype-toc": "^3.0.2",
|
|
213
213
|
"remark-code-titles": "^0.1.2",
|
|
214
214
|
"rollup": "^4.18.0",
|
|
215
|
-
"sass": "^1.77.
|
|
215
|
+
"sass": "^1.77.5",
|
|
216
216
|
"srcset-parse": "^1.1.0",
|
|
217
217
|
"unified": "^11.0.4",
|
|
218
218
|
"astro-scripts": "0.0.14"
|
package/templates/env/module.mjs
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import { schema } from 'virtual:astro:env/internal';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createInvalidVariableError,
|
|
4
|
+
getEnv,
|
|
5
|
+
setOnSetGetEnv,
|
|
6
|
+
validateEnvVariable,
|
|
7
|
+
} from 'astro/env/runtime';
|
|
3
8
|
|
|
4
9
|
export const getSecret = (key) => {
|
|
10
|
+
return getEnv(key);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const _internalGetSecret = (key) => {
|
|
5
14
|
const rawVariable = getEnv(key);
|
|
6
15
|
const variable = rawVariable === '' ? undefined : rawVariable;
|
|
7
16
|
const options = schema[key];
|
|
8
17
|
|
|
9
|
-
if (!options) {
|
|
10
|
-
return variable;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
18
|
const result = validateEnvVariable(variable, options);
|
|
14
19
|
if (result.ok) {
|
|
15
20
|
return result.value;
|
|
16
21
|
}
|
|
17
22
|
throw createInvalidVariableError(key, result.type);
|
|
18
23
|
};
|
|
24
|
+
|
|
25
|
+
setOnSetGetEnv((reset) => {
|
|
26
|
+
// @@ON_SET_GET_ENV@@
|
|
27
|
+
});
|
package/templates/env/types.d.ts
CHANGED
|
@@ -5,16 +5,5 @@ declare module 'astro:env/client' {
|
|
|
5
5
|
declare module 'astro:env/server' {
|
|
6
6
|
// @@SERVER@@
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
// @@SECRET_VALUES@@
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type SecretValue = keyof SecretValues;
|
|
13
|
-
|
|
14
|
-
type Loose<T> = T | (string & {});
|
|
15
|
-
type Strictify<T extends string> = T extends `${infer _}` ? T : never;
|
|
16
|
-
|
|
17
|
-
export const getSecret: <TKey extends Loose<SecretValue>>(
|
|
18
|
-
key: TKey
|
|
19
|
-
) => TKey extends Strictify<SecretValue> ? SecretValues[TKey] : string | undefined;
|
|
8
|
+
export const getSecret: (key: string) => string | undefined;
|
|
20
9
|
}
|