astro 3.2.2 → 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 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 (!isStackblitz && (parseInt(version) || 0) <= skipSemverCheckIfAbove) {
22
+ if ((parseInt(version) || 0) <= skipSemverCheckIfAbove) {
28
23
  try {
29
24
  const semver = await import('semver');
30
25
  if (!semver.satisfies(version, engines)) {
@@ -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-ssredge), [Vercel](https://docs.astro.build/en/guides/deploy/vercel/#adapter-for-ssr), and more to engage Astro SSR.
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 rehypeMinifyHtml from 'rehype-minify';
1078
+ * import { rehypeAccessibleEmojis } from 'rehype-accessible-emojis';
1079
1079
  * {
1080
1080
  * markdown: {
1081
- * rehypePlugins: [rehypeMinifyHtml]
1081
+ * rehypePlugins: [rehypeAccessibleEmojis]
1082
1082
  * }
1083
1083
  * }
1084
1084
  * ```
@@ -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
- if (!SUPPORTED_SYSTEM.has(system))
34
- return;
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(`echo ${JSON.stringify(text.trim())} | ${command}`, {
47
- encoding: "utf8",
48
- stdio: "ignore"
54
+ execSync(command, {
55
+ input: text.trim(),
56
+ encoding: "utf8"
49
57
  });
50
58
  } catch (e) {
51
59
  console.error(
@@ -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
- const mod = await viteServer.moduleGraph.getModuleByUrl(modUrl);
107
- if (mod) {
108
- viteServer.moduleGraph.invalidateModule(mod);
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(([_, stylesheet]) => {
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
- return pageData.styles.push({ ...orderingInfo, sheet });
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
  };
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "3.2.2";
1
+ const ASTRO_VERSION = "3.2.3";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -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.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 let ResponseWithEncoding: ReturnType<typeof initResponseWithEncoding>;
19
- declare let initResponseWithEncoding: () => {
20
- new (body: ResponseParameters[0], init: ResponseParameters[1], encoding?: BufferEncoding): {
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
- let ResponseWithEncoding;
65
- let initResponseWithEncoding = () => {
66
- class LocalResponseWithEncoding extends Response {
67
- constructor(body, init, encoding) {
68
- if (typeof body === "string") {
69
- if (typeof Buffer !== "undefined" && Buffer.from) {
70
- body = Buffer.from(body, encoding);
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
- ResponseWithEncoding = LocalResponseWithEncoding;
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 omitted instead.
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
  */
@@ -50,7 +50,7 @@ function serverStart({
50
50
  base,
51
51
  isRestart = false
52
52
  }) {
53
- const version = "3.2.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.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
- viteServer.watcher.on("add", (...args) => events.emit("file-add", args));
5
- viteServer.watcher.on("unlink", (...args) => events.emit("file-unlink", args));
6
- viteServer.watcher.on("change", (...args) => events.emit("file-change", args));
7
- wrapMethod(viteServer.ws, "send", (msg) => {
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
  };
@@ -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 Error(
73
- `Unable to resolve a valid export for "${metadata.displayName}"! Please open an issue at https://astro.build/issues!`
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: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "3.2.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.0",
164
- "@astrojs/markdown-remark": "3.2.0",
165
- "@astrojs/telemetry": "3.0.2"
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",