astro 1.4.6 → 1.5.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/components/Code.astro +1 -1
- package/dist/@types/astro.d.ts +201 -29
- package/dist/cli/index.js +35 -36
- package/dist/config/index.js +2 -7
- package/dist/core/add/index.js +140 -23
- package/dist/core/build/index.js +3 -3
- package/dist/core/build/vite-plugin-css.js +6 -17
- package/dist/core/config/config.d.ts +1 -1
- package/dist/core/config/config.js +6 -2
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/index.js +2 -1
- package/dist/core/config/schema.d.ts +139 -1
- package/dist/core/config/schema.js +24 -2
- package/dist/core/config/settings.d.ts +1 -7
- package/dist/core/config/settings.js +7 -4
- package/dist/core/config/tsconfig.d.ts +10 -1
- package/dist/core/config/tsconfig.js +73 -7
- package/dist/core/constants.d.ts +1 -0
- package/dist/core/constants.js +4 -0
- package/dist/core/cookies/cookies.d.ts +1 -1
- package/dist/core/dev/index.js +7 -2
- package/dist/core/endpoint/dev/index.js +4 -1
- package/dist/core/endpoint/index.d.ts +1 -1
- package/dist/core/endpoint/index.js +44 -4
- package/dist/core/messages.js +2 -2
- package/dist/core/preview/index.d.ts +2 -11
- package/dist/core/preview/index.js +31 -125
- package/dist/core/preview/static-preview-server.d.ts +17 -0
- package/dist/core/preview/static-preview-server.js +127 -0
- package/dist/core/render/core.d.ts +1 -1
- package/dist/core/render/result.js +2 -2
- package/dist/core/util.d.ts +3 -14
- package/dist/core/util.js +4 -2
- package/dist/events/index.js +1 -1
- package/dist/integrations/index.d.ts +3 -2
- package/dist/integrations/index.js +39 -2
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/hydration.js +1 -1
- package/dist/runtime/server/render/page.js +1 -0
- package/dist/vite-plugin-jsx/index.js +9 -5
- package/dist/vite-plugin-jsx/tag.d.ts +3 -2
- package/dist/vite-plugin-jsx/tag.js +10 -4
- package/package.json +4 -2
|
@@ -5,10 +5,11 @@ import { AstroConfig, AstroSettings, BuildConfig, RouteData } from '../@types/as
|
|
|
5
5
|
import type { SerializedSSRManifest } from '../core/app/types';
|
|
6
6
|
import type { PageBuildData } from '../core/build/types';
|
|
7
7
|
import { LogOptions } from '../core/logger/core.js';
|
|
8
|
-
export declare function runHookConfigSetup({ settings, command, logging, }: {
|
|
8
|
+
export declare function runHookConfigSetup({ settings, command, logging, isRestart, }: {
|
|
9
9
|
settings: AstroSettings;
|
|
10
|
-
command: 'dev' | 'build';
|
|
10
|
+
command: 'dev' | 'build' | 'preview';
|
|
11
11
|
logging: LogOptions;
|
|
12
|
+
isRestart?: boolean;
|
|
12
13
|
}): Promise<AstroSettings>;
|
|
13
14
|
export declare function runHookConfigDone({ settings, logging, }: {
|
|
14
15
|
settings: AstroSettings;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { bold } from "kleur/colors";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
2
3
|
import { mergeConfig } from "../core/config/config.js";
|
|
3
|
-
import { info } from "../core/logger/core.js";
|
|
4
|
+
import { info, warn } from "../core/logger/core.js";
|
|
4
5
|
async function withTakingALongTimeMsg({
|
|
5
6
|
name,
|
|
6
7
|
hookResult,
|
|
@@ -17,7 +18,8 @@ async function withTakingALongTimeMsg({
|
|
|
17
18
|
async function runHookConfigSetup({
|
|
18
19
|
settings,
|
|
19
20
|
command,
|
|
20
|
-
logging
|
|
21
|
+
logging,
|
|
22
|
+
isRestart = false
|
|
21
23
|
}) {
|
|
22
24
|
var _a;
|
|
23
25
|
if (settings.config.adapter) {
|
|
@@ -35,6 +37,7 @@ async function runHookConfigSetup({
|
|
|
35
37
|
const hooks = {
|
|
36
38
|
config: updatedConfig,
|
|
37
39
|
command,
|
|
40
|
+
isRestart,
|
|
38
41
|
addRenderer(renderer) {
|
|
39
42
|
if (!renderer.name) {
|
|
40
43
|
throw new Error(`Integration ${bold(integration.name)} has an unnamed renderer.`);
|
|
@@ -52,6 +55,9 @@ async function runHookConfigSetup({
|
|
|
52
55
|
},
|
|
53
56
|
injectRoute: (injectRoute) => {
|
|
54
57
|
updatedSettings.injectedRoutes.push(injectRoute);
|
|
58
|
+
},
|
|
59
|
+
addWatchFile: (path) => {
|
|
60
|
+
updatedSettings.watchFiles.push(path instanceof URL ? fileURLToPath(path) : path);
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
63
|
Object.defineProperty(hooks, "addPageExtension", {
|
|
@@ -147,13 +153,44 @@ async function runHookBuildStart({
|
|
|
147
153
|
logging
|
|
148
154
|
}) {
|
|
149
155
|
var _a;
|
|
156
|
+
function warnDeprecated(integration, prop) {
|
|
157
|
+
let value = Reflect.get(buildConfig, prop);
|
|
158
|
+
Object.defineProperty(buildConfig, prop, {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get() {
|
|
161
|
+
return value;
|
|
162
|
+
},
|
|
163
|
+
set(newValue) {
|
|
164
|
+
value = newValue;
|
|
165
|
+
warn(
|
|
166
|
+
logging,
|
|
167
|
+
"astro:build:start",
|
|
168
|
+
`Your adapter ${bold(integration.name)} is using a deprecated API, buildConfig. ${bold(
|
|
169
|
+
prop
|
|
170
|
+
)} config should be set via config.build.${prop} instead.`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return () => {
|
|
175
|
+
Object.defineProperty(buildConfig, prop, {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
value
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
}
|
|
150
181
|
for (const integration of config.integrations) {
|
|
151
182
|
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:start"]) {
|
|
183
|
+
const undoClientWarning = warnDeprecated(integration, "client");
|
|
184
|
+
const undoServerWarning = warnDeprecated(integration, "server");
|
|
185
|
+
const undoServerEntryWarning = warnDeprecated(integration, "serverEntry");
|
|
152
186
|
await withTakingALongTimeMsg({
|
|
153
187
|
name: integration.name,
|
|
154
188
|
hookResult: integration.hooks["astro:build:start"]({ buildConfig }),
|
|
155
189
|
logging
|
|
156
190
|
});
|
|
191
|
+
undoClientWarning();
|
|
192
|
+
undoServerEntryWarning();
|
|
193
|
+
undoServerWarning();
|
|
157
194
|
}
|
|
158
195
|
}
|
|
159
196
|
}
|
|
@@ -84,7 +84,7 @@ async function generateHydrateScript(scriptOptions, metadata) {
|
|
|
84
84
|
};
|
|
85
85
|
if (attrs) {
|
|
86
86
|
for (const [key, value] of Object.entries(attrs)) {
|
|
87
|
-
island.props[key] = value;
|
|
87
|
+
island.props[key] = escapeHTML(value);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
island.props["component-url"] = await result.resolve(decodeURI(componentUrl));
|
|
@@ -14,6 +14,7 @@ async function iterableToHTMLBytes(result, iterable, onDocTypeInjection) {
|
|
|
14
14
|
for await (const chunk of iterable) {
|
|
15
15
|
if (isHTMLString(chunk)) {
|
|
16
16
|
if (i === 0) {
|
|
17
|
+
i++;
|
|
17
18
|
if (!/<!doctype html/i.test(String(chunk))) {
|
|
18
19
|
parts.append("<!DOCTYPE html>\n", result);
|
|
19
20
|
if (onDocTypeInjection) {
|
|
@@ -61,13 +61,14 @@ async function transformJSX({
|
|
|
61
61
|
mode,
|
|
62
62
|
id,
|
|
63
63
|
ssr,
|
|
64
|
-
renderer
|
|
64
|
+
renderer,
|
|
65
|
+
root
|
|
65
66
|
}) {
|
|
66
67
|
const { jsxTransformOptions } = renderer;
|
|
67
68
|
const options = await jsxTransformOptions({ mode, ssr });
|
|
68
69
|
const plugins = [...options.plugins || []];
|
|
69
70
|
if (ssr) {
|
|
70
|
-
plugins.push(tagExportsPlugin({ rendererName: renderer.name }));
|
|
71
|
+
plugins.push(await tagExportsPlugin({ rendererName: renderer.name, root }));
|
|
71
72
|
}
|
|
72
73
|
const result = await babel.transformAsync(code, {
|
|
73
74
|
presets: options.presets,
|
|
@@ -142,7 +143,8 @@ function jsx({ settings, logging }) {
|
|
|
142
143
|
id,
|
|
143
144
|
renderer: astroJSXRenderer,
|
|
144
145
|
mode,
|
|
145
|
-
ssr
|
|
146
|
+
ssr,
|
|
147
|
+
root: settings.config.root
|
|
146
148
|
});
|
|
147
149
|
}
|
|
148
150
|
if (defaultJSXRendererEntry && jsxRenderersIntegrationOnly.size === 1) {
|
|
@@ -157,7 +159,8 @@ function jsx({ settings, logging }) {
|
|
|
157
159
|
id,
|
|
158
160
|
renderer: defaultJSXRendererEntry[1],
|
|
159
161
|
mode,
|
|
160
|
-
ssr
|
|
162
|
+
ssr,
|
|
163
|
+
root: settings.config.root
|
|
161
164
|
});
|
|
162
165
|
}
|
|
163
166
|
let importSource = detectImportSourceFromComments(code);
|
|
@@ -214,7 +217,8 @@ https://docs.astro.build/en/core-concepts/framework-components/#installing-integ
|
|
|
214
217
|
id,
|
|
215
218
|
renderer: selectedJsxRenderer,
|
|
216
219
|
mode,
|
|
217
|
-
ssr
|
|
220
|
+
ssr,
|
|
221
|
+
root: settings.config.root
|
|
218
222
|
});
|
|
219
223
|
}
|
|
220
224
|
};
|
|
@@ -7,6 +7,7 @@ import type { PluginObj } from '@babel/core';
|
|
|
7
7
|
* This plugin crawls each export in the file and "tags" each export with a given `rendererName`.
|
|
8
8
|
* This allows us to automatically match a component to a renderer and skip the usual `check()` calls.
|
|
9
9
|
*/
|
|
10
|
-
export default function tagExportsWithRenderer({ rendererName, }: {
|
|
10
|
+
export default function tagExportsWithRenderer({ rendererName, root, }: {
|
|
11
11
|
rendererName: string;
|
|
12
|
-
|
|
12
|
+
root: URL;
|
|
13
|
+
}): Promise<PluginObj>;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { resolve as importMetaResolve } from "import-meta-resolve";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
async function tagExportsWithRenderer({
|
|
5
|
+
rendererName,
|
|
6
|
+
root
|
|
4
7
|
}) {
|
|
8
|
+
const astroServerPath = fileURLToPath(
|
|
9
|
+
await importMetaResolve("astro/server/index.js", root.toString())
|
|
10
|
+
);
|
|
5
11
|
return {
|
|
6
12
|
visitor: {
|
|
7
13
|
Program: {
|
|
@@ -16,7 +22,7 @@ function tagExportsWithRenderer({
|
|
|
16
22
|
t.identifier("__astro_tag_component__")
|
|
17
23
|
)
|
|
18
24
|
],
|
|
19
|
-
t.stringLiteral(
|
|
25
|
+
t.stringLiteral(astroServerPath)
|
|
20
26
|
)
|
|
21
27
|
);
|
|
22
28
|
},
|
|
@@ -83,7 +89,7 @@ function tagExportsWithRenderer({
|
|
|
83
89
|
addTag(property.key.name);
|
|
84
90
|
}
|
|
85
91
|
});
|
|
86
|
-
} else if (t.isExportNamedDeclaration(node)) {
|
|
92
|
+
} else if (t.isExportNamedDeclaration(node) && !node.source) {
|
|
87
93
|
node.specifiers.forEach((specifier) => {
|
|
88
94
|
if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
|
|
89
95
|
addTag(specifier.local.name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"vendor"
|
|
83
83
|
],
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@astrojs/compiler": "^0.
|
|
85
|
+
"@astrojs/compiler": "^0.27.1",
|
|
86
86
|
"@astrojs/language-server": "^0.26.2",
|
|
87
87
|
"@astrojs/markdown-remark": "^1.1.3",
|
|
88
88
|
"@astrojs/telemetry": "^1.0.1",
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
"common-ancestor-path": "^1.0.1",
|
|
104
104
|
"cookie": "^0.5.0",
|
|
105
105
|
"debug": "^4.3.4",
|
|
106
|
+
"deepmerge-ts": "^4.2.2",
|
|
106
107
|
"diff": "^5.1.0",
|
|
107
108
|
"eol": "^0.9.1",
|
|
108
109
|
"es-module-lexer": "^0.10.5",
|
|
@@ -113,6 +114,7 @@
|
|
|
113
114
|
"gray-matter": "^4.0.3",
|
|
114
115
|
"html-entities": "^2.3.3",
|
|
115
116
|
"html-escaper": "^3.0.3",
|
|
117
|
+
"import-meta-resolve": "^2.1.0",
|
|
116
118
|
"kleur": "^4.1.4",
|
|
117
119
|
"magic-string": "^0.25.9",
|
|
118
120
|
"mime": "^3.0.0",
|