astro 3.2.1 → 3.2.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/astro.js +1 -6
- package/dist/@types/astro.d.ts +4 -4
- package/dist/cli/info/index.js +15 -7
- package/dist/content/vite-plugin-content-assets.js +2 -2
- package/dist/content/vite-plugin-content-imports.js +9 -3
- package/dist/core/build/plugins/plugin-css.js +16 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/index.d.ts +3 -22
- package/dist/core/endpoint/index.js +12 -20
- package/dist/core/errors/errors-data.d.ts +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/module-loader/vite.js +32 -12
- package/dist/core/polyfill.js +2 -49
- package/dist/core/render/result.js +1 -1
- package/dist/runtime/server/hydration.js +4 -3
- package/dist/runtime/server/render/astro/instance.js +2 -2
- package/dist/vite-plugin-astro-server/css.d.ts +7 -1
- package/dist/vite-plugin-astro-server/css.js +6 -2
- package/dist/vite-plugin-astro-server/route.js +7 -3
- package/package.json +7 -5
package/astro.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
// ISOMORPHIC FILE: NO TOP-LEVEL IMPORT/REQUIRE() ALLOWED
|
|
5
5
|
// This file has to run as both ESM and CJS on older Node.js versions
|
|
6
|
-
// Needed for Stackblitz: https://github.com/stackblitz/webcontainer-core/issues/281
|
|
7
6
|
|
|
8
7
|
const CI_INSTRUCTIONS = {
|
|
9
8
|
NETLIFY: 'https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript',
|
|
@@ -16,15 +15,11 @@ const CI_INSTRUCTIONS = {
|
|
|
16
15
|
const engines = '>=18.14.1';
|
|
17
16
|
const skipSemverCheckIfAbove = 19;
|
|
18
17
|
|
|
19
|
-
// HACK (2023-08-18) Stackblitz does not support Node 18 yet, so we'll fake Node 16 support for some time until it's supported
|
|
20
|
-
// TODO: Remove when Node 18 is supported on Stackblitz
|
|
21
|
-
const isStackblitz = process.env.SHELL === '/bin/jsh' && process.versions.webcontainer != null;
|
|
22
|
-
|
|
23
18
|
/** `astro *` */
|
|
24
19
|
async function main() {
|
|
25
20
|
const version = process.versions.node;
|
|
26
21
|
// Fast-path for higher Node.js versions
|
|
27
|
-
if (
|
|
22
|
+
if ((parseInt(version) || 0) <= skipSemverCheckIfAbove) {
|
|
28
23
|
try {
|
|
29
24
|
const semver = await import('semver');
|
|
30
25
|
if (!semver.satisfies(version, engines)) {
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -559,7 +559,7 @@ export interface AstroUserConfig {
|
|
|
559
559
|
* @see output
|
|
560
560
|
* @description
|
|
561
561
|
*
|
|
562
|
-
* Deploy to your favorite server, serverless, or edge host with build adapters. Import one of our first-party adapters for [Netlify](https://docs.astro.build/en/guides/deploy/netlify/#adapter-for-
|
|
562
|
+
* Deploy to your favorite server, serverless, or edge host with build adapters. Import one of our first-party adapters for [Netlify](https://docs.astro.build/en/guides/deploy/netlify/#adapter-for-ssr), [Vercel](https://docs.astro.build/en/guides/deploy/vercel/#adapter-for-ssr), and more to engage Astro SSR.
|
|
563
563
|
*
|
|
564
564
|
* [See our Server-side Rendering guide](https://docs.astro.build/en/guides/server-side-rendering/) for more on SSR, and [our deployment guides](https://docs.astro.build/en/guides/deploy/) for a complete list of hosts.
|
|
565
565
|
*
|
|
@@ -1075,10 +1075,10 @@ export interface AstroUserConfig {
|
|
|
1075
1075
|
* Pass [rehype plugins](https://github.com/remarkjs/remark-rehype) to customize how your Markdown's output HTML is processed. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
|
|
1076
1076
|
*
|
|
1077
1077
|
* ```js
|
|
1078
|
-
* import
|
|
1078
|
+
* import { rehypeAccessibleEmojis } from 'rehype-accessible-emojis';
|
|
1079
1079
|
* {
|
|
1080
1080
|
* markdown: {
|
|
1081
|
-
* rehypePlugins: [
|
|
1081
|
+
* rehypePlugins: [rehypeAccessibleEmojis]
|
|
1082
1082
|
* }
|
|
1083
1083
|
* }
|
|
1084
1084
|
* ```
|
|
@@ -1967,7 +1967,7 @@ export interface SSRMetadata {
|
|
|
1967
1967
|
hasRenderedHead: boolean;
|
|
1968
1968
|
headInTree: boolean;
|
|
1969
1969
|
extraHead: string[];
|
|
1970
|
-
propagators:
|
|
1970
|
+
propagators: Set<AstroComponentInstance>;
|
|
1971
1971
|
}
|
|
1972
1972
|
export interface PreviewServer {
|
|
1973
1973
|
host?: string;
|
package/dist/cli/info/index.js
CHANGED
|
@@ -27,11 +27,20 @@ async function printInfo({ flags }) {
|
|
|
27
27
|
}
|
|
28
28
|
await copyToClipboard(output.trim());
|
|
29
29
|
}
|
|
30
|
-
const SUPPORTED_SYSTEM = /* @__PURE__ */ new Set(["darwin", "win32"]);
|
|
31
30
|
async function copyToClipboard(text) {
|
|
32
31
|
const system = platform();
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
let command = "";
|
|
33
|
+
if (system === "darwin") {
|
|
34
|
+
command = "pbcopy";
|
|
35
|
+
} else if (system === "win32") {
|
|
36
|
+
command = "clip";
|
|
37
|
+
} else {
|
|
38
|
+
const output = execSync("which xclip", { encoding: "utf8" });
|
|
39
|
+
if (output[0] !== "/") {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
command = "xclip -sel clipboard -l 1";
|
|
43
|
+
}
|
|
35
44
|
console.log();
|
|
36
45
|
const { shouldCopy } = await prompts({
|
|
37
46
|
type: "confirm",
|
|
@@ -41,11 +50,10 @@ async function copyToClipboard(text) {
|
|
|
41
50
|
});
|
|
42
51
|
if (!shouldCopy)
|
|
43
52
|
return;
|
|
44
|
-
const command = system === "darwin" ? "pbcopy" : "clip";
|
|
45
53
|
try {
|
|
46
|
-
execSync(
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
execSync(command, {
|
|
55
|
+
input: text.trim(),
|
|
56
|
+
encoding: "utf8"
|
|
49
57
|
});
|
|
50
58
|
} catch (e) {
|
|
51
59
|
console.error(
|
|
@@ -49,7 +49,7 @@ function astroContentAssetPropagationPlugin({
|
|
|
49
49
|
if (!devModuleLoader.getModuleById(basePath)?.ssrModule) {
|
|
50
50
|
await devModuleLoader.import(basePath);
|
|
51
51
|
}
|
|
52
|
-
const {
|
|
52
|
+
const { styles, urls } = await getStylesForURL(
|
|
53
53
|
pathToFileURL(basePath),
|
|
54
54
|
devModuleLoader,
|
|
55
55
|
"development"
|
|
@@ -60,7 +60,7 @@ function astroContentAssetPropagationPlugin({
|
|
|
60
60
|
devModuleLoader
|
|
61
61
|
);
|
|
62
62
|
stringifiedLinks = JSON.stringify([...urls]);
|
|
63
|
-
stringifiedStyles = JSON.stringify(
|
|
63
|
+
stringifiedStyles = JSON.stringify(styles.map((s) => s.content));
|
|
64
64
|
stringifiedScripts = JSON.stringify([...hoistedScripts]);
|
|
65
65
|
} else {
|
|
66
66
|
stringifiedLinks = JSON.stringify(LINKS_PLACEHOLDER);
|
|
@@ -103,9 +103,15 @@ export const _internal = {
|
|
|
103
103
|
}
|
|
104
104
|
for (const modUrl of viteServer.moduleGraph.urlToModuleMap.keys()) {
|
|
105
105
|
if (hasContentFlag(modUrl, CONTENT_FLAG) || hasContentFlag(modUrl, DATA_FLAG) || Boolean(getContentRendererByViteId(modUrl, settings))) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
try {
|
|
107
|
+
const mod = await viteServer.moduleGraph.getModuleByUrl(modUrl);
|
|
108
|
+
if (mod) {
|
|
109
|
+
viteServer.moduleGraph.invalidateModule(mod);
|
|
110
|
+
}
|
|
111
|
+
} catch (e) {
|
|
112
|
+
if (e.code === "ERR_CLOSED_SERVER")
|
|
113
|
+
break;
|
|
114
|
+
throw e;
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
117
|
}
|
|
@@ -148,17 +148,21 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
148
148
|
async generateBundle(_outputOptions, bundle) {
|
|
149
149
|
const inlineConfig = settings.config.build.inlineStylesheets;
|
|
150
150
|
const { assetsInlineLimit = 4096 } = settings.config.vite?.build ?? {};
|
|
151
|
-
Object.entries(bundle).forEach(([
|
|
151
|
+
Object.entries(bundle).forEach(([id, stylesheet]) => {
|
|
152
152
|
if (stylesheet.type !== "asset" || stylesheet.name?.endsWith(".css") !== true || typeof stylesheet.source !== "string")
|
|
153
153
|
return;
|
|
154
154
|
const assetSize = new TextEncoder().encode(stylesheet.source).byteLength;
|
|
155
155
|
const toBeInlined = inlineConfig === "always" ? true : inlineConfig === "never" ? false : assetSize <= assetsInlineLimit;
|
|
156
156
|
const sheet = toBeInlined ? { type: "inline", content: stylesheet.source } : { type: "external", src: stylesheet.fileName };
|
|
157
157
|
const pages = Array.from(eachPageData(internals));
|
|
158
|
+
let sheetAddedToPage = false;
|
|
158
159
|
pages.forEach((pageData) => {
|
|
159
160
|
const orderingInfo = pagesToCss[pageData.moduleSpecifier]?.[stylesheet.fileName];
|
|
160
|
-
if (orderingInfo !== void 0)
|
|
161
|
-
|
|
161
|
+
if (orderingInfo !== void 0) {
|
|
162
|
+
pageData.styles.push({ ...orderingInfo, sheet });
|
|
163
|
+
sheetAddedToPage = true;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
162
166
|
const propagatedPaths = pagesToPropagatedCss[pageData.moduleSpecifier];
|
|
163
167
|
if (propagatedPaths === void 0)
|
|
164
168
|
return;
|
|
@@ -169,8 +173,17 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
169
173
|
return;
|
|
170
174
|
const propagatedStyles = pageData.propagatedStyles.get(pageInfoId) ?? pageData.propagatedStyles.set(pageInfoId, /* @__PURE__ */ new Set()).get(pageInfoId);
|
|
171
175
|
propagatedStyles.add(sheet);
|
|
176
|
+
sheetAddedToPage = true;
|
|
172
177
|
});
|
|
173
178
|
});
|
|
179
|
+
if (toBeInlined && sheetAddedToPage) {
|
|
180
|
+
delete bundle[id];
|
|
181
|
+
for (const chunk of Object.values(bundle)) {
|
|
182
|
+
if (chunk.type === "chunk") {
|
|
183
|
+
chunk.viteMetadata?.importedCss?.delete(id);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
174
187
|
});
|
|
175
188
|
}
|
|
176
189
|
};
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -20,7 +20,7 @@ async function dev(inlineConfig) {
|
|
|
20
20
|
base: restart.container.settings.config.base
|
|
21
21
|
})
|
|
22
22
|
);
|
|
23
|
-
const currentVersion = "3.2.
|
|
23
|
+
const currentVersion = "3.2.3";
|
|
24
24
|
if (currentVersion.includes("-")) {
|
|
25
25
|
logger.warn(null, msg.prerelease({ currentVersion }));
|
|
26
26
|
}
|
|
@@ -15,27 +15,8 @@ type CreateAPIContext = {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function createAPIContext({ request, params, site, props, adapterName, }: CreateAPIContext): APIContext;
|
|
17
17
|
type ResponseParameters = ConstructorParameters<typeof Response>;
|
|
18
|
-
export declare
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
readonly headers: Headers;
|
|
22
|
-
readonly ok: boolean;
|
|
23
|
-
readonly redirected: boolean;
|
|
24
|
-
readonly status: number;
|
|
25
|
-
readonly statusText: string;
|
|
26
|
-
readonly type: ResponseType;
|
|
27
|
-
readonly url: string;
|
|
28
|
-
clone(): Response;
|
|
29
|
-
readonly body: ReadableStream<Uint8Array> | null;
|
|
30
|
-
readonly bodyUsed: boolean;
|
|
31
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
32
|
-
blob(): Promise<Blob>;
|
|
33
|
-
formData(): Promise<FormData>;
|
|
34
|
-
json(): Promise<any>;
|
|
35
|
-
text(): Promise<string>;
|
|
36
|
-
};
|
|
37
|
-
error(): Response;
|
|
38
|
-
redirect(url: string | URL, status?: number | undefined): Response;
|
|
39
|
-
};
|
|
18
|
+
export declare class ResponseWithEncoding extends Response {
|
|
19
|
+
constructor(body: ResponseParameters[0], init: ResponseParameters[1], encoding?: BufferEncoding);
|
|
20
|
+
}
|
|
40
21
|
export declare function callEndpoint<MiddlewareResult = Response | EndpointOutput>(mod: EndpointHandler, env: Environment, ctx: RenderContext, onRequest?: MiddlewareHandler<MiddlewareResult> | undefined): Promise<Response>;
|
|
41
22
|
export {};
|
|
@@ -14,7 +14,6 @@ function createAPIContext({
|
|
|
14
14
|
props,
|
|
15
15
|
adapterName
|
|
16
16
|
}) {
|
|
17
|
-
initResponseWithEncoding();
|
|
18
17
|
const context = {
|
|
19
18
|
cookies: new AstroCookies(request),
|
|
20
19
|
request,
|
|
@@ -61,28 +60,21 @@ function createAPIContext({
|
|
|
61
60
|
});
|
|
62
61
|
return context;
|
|
63
62
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} else if (encoding == null || encoding === "utf8" || encoding === "utf-8") {
|
|
72
|
-
body = encoder.encode(body);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
super(body, init);
|
|
76
|
-
if (encoding) {
|
|
77
|
-
this.headers.set("X-Astro-Encoding", encoding);
|
|
63
|
+
class ResponseWithEncoding extends Response {
|
|
64
|
+
constructor(body, init, encoding) {
|
|
65
|
+
if (typeof body === "string") {
|
|
66
|
+
if (typeof Buffer !== "undefined" && Buffer.from) {
|
|
67
|
+
body = Buffer.from(body, encoding);
|
|
68
|
+
} else if (encoding == null || encoding === "utf8" || encoding === "utf-8") {
|
|
69
|
+
body = encoder.encode(body);
|
|
78
70
|
}
|
|
79
71
|
}
|
|
72
|
+
super(body, init);
|
|
73
|
+
if (encoding) {
|
|
74
|
+
this.headers.set("X-Astro-Encoding", encoding);
|
|
75
|
+
}
|
|
80
76
|
}
|
|
81
|
-
|
|
82
|
-
initResponseWithEncoding = () => {
|
|
83
|
-
};
|
|
84
|
-
return LocalResponseWithEncoding;
|
|
85
|
-
};
|
|
77
|
+
}
|
|
86
78
|
async function callEndpoint(mod, env, ctx, onRequest) {
|
|
87
79
|
const context = createAPIContext({
|
|
88
80
|
request: ctx.request,
|
|
@@ -1042,7 +1042,7 @@ export declare const ContentSchemaContainsSlugError: {
|
|
|
1042
1042
|
/**
|
|
1043
1043
|
* @docs
|
|
1044
1044
|
* @message A collection queried via `getCollection()` does not exist.
|
|
1045
|
-
* @deprecated Collections that do not exist no longer result in an error. A warning is
|
|
1045
|
+
* @deprecated Collections that do not exist no longer result in an error. A warning is given instead.
|
|
1046
1046
|
* @description
|
|
1047
1047
|
* When querying a collection, ensure a collection directory with the requested name exists under `src/content/`.
|
|
1048
1048
|
*/
|
package/dist/core/messages.js
CHANGED
|
@@ -50,7 +50,7 @@ function serverStart({
|
|
|
50
50
|
base,
|
|
51
51
|
isRestart = false
|
|
52
52
|
}) {
|
|
53
|
-
const version = "3.2.
|
|
53
|
+
const version = "3.2.3";
|
|
54
54
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
55
55
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
56
56
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -235,7 +235,7 @@ function printHelp({
|
|
|
235
235
|
message.push(
|
|
236
236
|
linebreak(),
|
|
237
237
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
238
|
-
`v${"3.2.
|
|
238
|
+
`v${"3.2.3"}`
|
|
239
239
|
)} ${headline}`
|
|
240
240
|
);
|
|
241
241
|
}
|
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
function createViteLoader(viteServer) {
|
|
3
4
|
const events = new EventEmitter();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
let isTsconfigUpdated = false;
|
|
6
|
+
function isTsconfigUpdate(filePath) {
|
|
7
|
+
const result = path.basename(filePath) === "tsconfig.json";
|
|
8
|
+
if (result)
|
|
9
|
+
isTsconfigUpdated = true;
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
viteServer.watcher.on("add", (...args) => {
|
|
13
|
+
if (!isTsconfigUpdate(args[0])) {
|
|
14
|
+
events.emit("file-add", args);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
viteServer.watcher.on("unlink", (...args) => {
|
|
18
|
+
if (!isTsconfigUpdate(args[0])) {
|
|
19
|
+
events.emit("file-unlink", args);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
viteServer.watcher.on("change", (...args) => {
|
|
23
|
+
if (!isTsconfigUpdate(args[0])) {
|
|
24
|
+
events.emit("file-change", args);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const _wsSend = viteServer.ws.send;
|
|
28
|
+
viteServer.ws.send = function(...args) {
|
|
29
|
+
if (isTsconfigUpdated) {
|
|
30
|
+
isTsconfigUpdated = false;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const msg = args[0];
|
|
8
34
|
if (msg?.type === "error") {
|
|
9
35
|
events.emit("hmr-error", msg);
|
|
10
36
|
}
|
|
11
|
-
|
|
37
|
+
_wsSend.apply(this, args);
|
|
38
|
+
};
|
|
12
39
|
return {
|
|
13
40
|
import(src) {
|
|
14
41
|
return viteServer.ssrLoadModule(src);
|
|
@@ -50,13 +77,6 @@ function createViteLoader(viteServer) {
|
|
|
50
77
|
events
|
|
51
78
|
};
|
|
52
79
|
}
|
|
53
|
-
function wrapMethod(object, method, newFn) {
|
|
54
|
-
const orig = object[method];
|
|
55
|
-
object[method] = function(...args) {
|
|
56
|
-
newFn.apply(this, args);
|
|
57
|
-
return orig.apply(this, args);
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
80
|
export {
|
|
61
81
|
createViteLoader
|
|
62
82
|
};
|
package/dist/core/polyfill.js
CHANGED
|
@@ -1,53 +1,6 @@
|
|
|
1
|
+
import buffer from "node:buffer";
|
|
1
2
|
import crypto from "node:crypto";
|
|
2
|
-
import {
|
|
3
|
-
ByteLengthQueuingStrategy,
|
|
4
|
-
CountQueuingStrategy,
|
|
5
|
-
ReadableByteStreamController,
|
|
6
|
-
ReadableStream,
|
|
7
|
-
ReadableStreamBYOBReader,
|
|
8
|
-
ReadableStreamBYOBRequest,
|
|
9
|
-
ReadableStreamDefaultController,
|
|
10
|
-
ReadableStreamDefaultReader,
|
|
11
|
-
TransformStream,
|
|
12
|
-
WritableStream,
|
|
13
|
-
WritableStreamDefaultController,
|
|
14
|
-
WritableStreamDefaultWriter
|
|
15
|
-
} from "node:stream/web";
|
|
16
|
-
import { File, FormData, Headers, Request, Response, fetch } from "undici";
|
|
17
|
-
const isStackblitz = process.env.SHELL === "/bin/jsh" && process.versions.webcontainer != null;
|
|
18
3
|
function apply() {
|
|
19
|
-
if (isStackblitz) {
|
|
20
|
-
const neededPolyfills = {
|
|
21
|
-
ByteLengthQueuingStrategy,
|
|
22
|
-
CountQueuingStrategy,
|
|
23
|
-
ReadableByteStreamController,
|
|
24
|
-
ReadableStream,
|
|
25
|
-
ReadableStreamBYOBReader,
|
|
26
|
-
ReadableStreamBYOBRequest,
|
|
27
|
-
ReadableStreamDefaultController,
|
|
28
|
-
ReadableStreamDefaultReader,
|
|
29
|
-
TransformStream,
|
|
30
|
-
WritableStream,
|
|
31
|
-
WritableStreamDefaultController,
|
|
32
|
-
WritableStreamDefaultWriter,
|
|
33
|
-
File,
|
|
34
|
-
FormData,
|
|
35
|
-
Headers,
|
|
36
|
-
Request,
|
|
37
|
-
Response,
|
|
38
|
-
fetch
|
|
39
|
-
};
|
|
40
|
-
for (let polyfillName of Object.keys(neededPolyfills)) {
|
|
41
|
-
if (Object.hasOwnProperty.call(globalThis, polyfillName))
|
|
42
|
-
continue;
|
|
43
|
-
Object.defineProperty(globalThis, polyfillName, {
|
|
44
|
-
configurable: true,
|
|
45
|
-
enumerable: true,
|
|
46
|
-
writable: true,
|
|
47
|
-
value: neededPolyfills[polyfillName]
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
4
|
if (!globalThis.crypto) {
|
|
52
5
|
Object.defineProperty(globalThis, "crypto", {
|
|
53
6
|
value: crypto.webcrypto
|
|
@@ -55,7 +8,7 @@ function apply() {
|
|
|
55
8
|
}
|
|
56
9
|
if (!globalThis.File) {
|
|
57
10
|
Object.defineProperty(globalThis, "File", {
|
|
58
|
-
value: File
|
|
11
|
+
value: buffer.File
|
|
59
12
|
});
|
|
60
13
|
}
|
|
61
14
|
}
|
|
@@ -69,9 +69,10 @@ async function generateHydrateScript(scriptOptions, metadata) {
|
|
|
69
69
|
const { renderer, result, astroId, props, attrs } = scriptOptions;
|
|
70
70
|
const { hydrate, componentUrl, componentExport } = metadata;
|
|
71
71
|
if (!componentExport.value) {
|
|
72
|
-
throw new
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
throw new AstroError({
|
|
73
|
+
...AstroErrorData.NoMatchingImport,
|
|
74
|
+
message: AstroErrorData.NoMatchingImport.message(metadata.displayName)
|
|
75
|
+
});
|
|
75
76
|
}
|
|
76
77
|
const island = {
|
|
77
78
|
children: "",
|
|
@@ -55,8 +55,8 @@ function validateComponentProps(props, displayName) {
|
|
|
55
55
|
function createAstroComponentInstance(result, displayName, factory, props, slots = {}) {
|
|
56
56
|
validateComponentProps(props, displayName);
|
|
57
57
|
const instance = new AstroComponentInstance(result, props, slots, factory);
|
|
58
|
-
if (isAPropagatingComponent(result, factory)
|
|
59
|
-
result._metadata.propagators.
|
|
58
|
+
if (isAPropagatingComponent(result, factory)) {
|
|
59
|
+
result._metadata.propagators.add(instance);
|
|
60
60
|
}
|
|
61
61
|
return instance;
|
|
62
62
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { RuntimeMode } from '../@types/astro.js';
|
|
2
2
|
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
3
|
+
interface ImportedStyle {
|
|
4
|
+
id: string;
|
|
5
|
+
url: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
3
8
|
/** Given a filePath URL, crawl Vite’s module graph to find all style imports. */
|
|
4
9
|
export declare function getStylesForURL(filePath: URL, loader: ModuleLoader, mode: RuntimeMode): Promise<{
|
|
5
10
|
urls: Set<string>;
|
|
6
|
-
|
|
11
|
+
styles: ImportedStyle[];
|
|
7
12
|
}>;
|
|
13
|
+
export {};
|
|
@@ -14,7 +14,11 @@ async function getStylesForURL(filePath, loader, mode) {
|
|
|
14
14
|
}
|
|
15
15
|
if (mode === "development" && // only inline in development
|
|
16
16
|
typeof ssrModule?.default === "string") {
|
|
17
|
-
importedStylesMap.set(importedModule.
|
|
17
|
+
importedStylesMap.set(importedModule.url, {
|
|
18
|
+
id: importedModule.id ?? importedModule.url,
|
|
19
|
+
url: importedModule.url,
|
|
20
|
+
content: ssrModule.default
|
|
21
|
+
});
|
|
18
22
|
} else {
|
|
19
23
|
importedCssUrls.add(importedModule.url);
|
|
20
24
|
}
|
|
@@ -22,7 +26,7 @@ async function getStylesForURL(filePath, loader, mode) {
|
|
|
22
26
|
}
|
|
23
27
|
return {
|
|
24
28
|
urls: importedCssUrls,
|
|
25
|
-
|
|
29
|
+
styles: [...importedStylesMap.values()]
|
|
26
30
|
};
|
|
27
31
|
}
|
|
28
32
|
export {
|
|
@@ -213,7 +213,11 @@ async function getScriptsAndStyles({ pipeline, filePath }) {
|
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
const { urls: styleUrls,
|
|
216
|
+
const { urls: styleUrls, styles: importedStyles } = await getStylesForURL(
|
|
217
|
+
filePath,
|
|
218
|
+
moduleLoader,
|
|
219
|
+
mode
|
|
220
|
+
);
|
|
217
221
|
let links = /* @__PURE__ */ new Set();
|
|
218
222
|
[...styleUrls].forEach((href) => {
|
|
219
223
|
links.add({
|
|
@@ -225,7 +229,7 @@ async function getScriptsAndStyles({ pipeline, filePath }) {
|
|
|
225
229
|
});
|
|
226
230
|
});
|
|
227
231
|
let styles = /* @__PURE__ */ new Set();
|
|
228
|
-
|
|
232
|
+
importedStyles.forEach(({ id, url, content }) => {
|
|
229
233
|
scripts.add({
|
|
230
234
|
props: {
|
|
231
235
|
type: "module",
|
|
@@ -235,7 +239,7 @@ async function getScriptsAndStyles({ pipeline, filePath }) {
|
|
|
235
239
|
});
|
|
236
240
|
styles.add({
|
|
237
241
|
props: {
|
|
238
|
-
"data-vite-dev-id":
|
|
242
|
+
"data-vite-dev-id": id
|
|
239
243
|
},
|
|
240
244
|
children: content
|
|
241
245
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.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",
|
|
@@ -152,7 +152,6 @@
|
|
|
152
152
|
"string-width": "^6.1.0",
|
|
153
153
|
"strip-ansi": "^7.1.0",
|
|
154
154
|
"tsconfig-resolver": "^3.0.1",
|
|
155
|
-
"undici": "^5.23.0",
|
|
156
155
|
"unist-util-visit": "^4.1.2",
|
|
157
156
|
"vfile": "^5.3.7",
|
|
158
157
|
"vite": "^4.4.9",
|
|
@@ -160,9 +159,9 @@
|
|
|
160
159
|
"which-pm": "^2.1.1",
|
|
161
160
|
"yargs-parser": "^21.1.1",
|
|
162
161
|
"zod": "3.21.1",
|
|
163
|
-
"@astrojs/internal-helpers": "0.2.
|
|
164
|
-
"@astrojs/markdown-remark": "3.2.
|
|
165
|
-
"@astrojs/telemetry": "3.0.
|
|
162
|
+
"@astrojs/internal-helpers": "0.2.1",
|
|
163
|
+
"@astrojs/markdown-remark": "3.2.1",
|
|
164
|
+
"@astrojs/telemetry": "3.0.3"
|
|
166
165
|
},
|
|
167
166
|
"optionalDependencies": {
|
|
168
167
|
"sharp": "^0.32.5"
|
|
@@ -214,6 +213,9 @@
|
|
|
214
213
|
"node": ">=18.14.1",
|
|
215
214
|
"npm": ">=6.14.0"
|
|
216
215
|
},
|
|
216
|
+
"publishConfig": {
|
|
217
|
+
"provenance": true
|
|
218
|
+
},
|
|
217
219
|
"scripts": {
|
|
218
220
|
"prebuild": "astro-scripts prebuild --to-string \"src/runtime/server/astro-island.ts\" \"src/runtime/client/{idle,load,media,only,visible}.ts\"",
|
|
219
221
|
"build": "pnpm run prebuild && astro-scripts build \"src/**/*.{ts,js}\" && tsc && pnpm run postbuild",
|