astro 2.0.9 → 2.0.11

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-jsx.d.ts CHANGED
@@ -936,10 +936,10 @@ declare namespace astroHTML.JSX {
936
936
  interface TableHTMLAttributes extends HTMLAttributes {
937
937
  align?: 'left' | 'center' | 'right' | undefined | null;
938
938
  bgcolor?: string | undefined | null;
939
- border?: number | undefined | null;
939
+ border?: string | number | undefined | null;
940
940
  cellpadding?: number | string | undefined | null;
941
941
  cellspacing?: number | string | undefined | null;
942
- frame?: boolean | undefined | null;
942
+ frame?: boolean | 'false' | 'true' | undefined | null;
943
943
  rules?: 'none' | 'groups' | 'rows' | 'columns' | 'all' | undefined | null;
944
944
  summary?: string | undefined | null;
945
945
  width?: number | string | undefined | null;
@@ -15,14 +15,14 @@ function stringify(opts) {
15
15
 
16
16
  /**
17
17
  * @param {import('shiki').HighlighterOptions} opts
18
- * @returns {Promise<import('shiki').Highlighter>}
18
+ * @returns {Promise<import('shiki').HighlighterOptions>}
19
19
  */
20
- async function resolveHighlighter(opts) {
20
+ export async function resolveHighlighterOptions(opts) {
21
21
  const resolvedThemes = [];
22
- if (Object.keys(opts.theme).length) {
23
- resolvedThemes.push(opts.theme);
24
- } else if (opts.theme && opts.theme in themes) {
22
+ if (opts.theme && opts.theme in themes) {
25
23
  resolvedThemes.push(await themes[opts.theme]());
24
+ } else if (Object.keys(opts.theme).length) {
25
+ resolvedThemes.push(opts.theme);
26
26
  }
27
27
 
28
28
  let resolvedLanguages;
@@ -47,6 +47,16 @@ async function resolveHighlighter(opts) {
47
47
  // Do not pass through the theme as that will attempt to load it, even if it's included in themes
48
48
  delete highlighterOptions['theme'];
49
49
 
50
+ return highlighterOptions;
51
+ }
52
+
53
+ /**
54
+ * @param {import('shiki').HighlighterOptions} opts
55
+ * @returns {Promise<import('shiki').Highlighter>}
56
+ */
57
+ async function resolveHighlighter(opts) {
58
+ const highlighterOptions = await resolveHighlighterOptions(opts);
59
+
50
60
  // Start the async getHighlighter call and cache the Promise
51
61
  const highlighter = getShikiHighlighter(highlighterOptions).then((hl) => {
52
62
  hl.setColorReplacements({
@@ -5,7 +5,6 @@ import { fileURLToPath, pathToFileURL } from "node:url";
5
5
  import { normalizePath } from "vite";
6
6
  import { z } from "zod";
7
7
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
8
- import { appendForwardSlash } from "../core/path.js";
9
8
  import { contentFileExts, CONTENT_TYPES_FILE } from "./consts.js";
10
9
  const collectionConfigParser = z.object({
11
10
  schema: z.any().optional()
@@ -104,10 +103,9 @@ function getEntryInfo({
104
103
  return res;
105
104
  }
106
105
  function getEntryType(entryPath, paths) {
107
- const { dir: rawDir, ext, base } = path.parse(entryPath);
108
- const dir = appendForwardSlash(pathToFileURL(rawDir).href);
109
- const fileUrl = new URL(base, dir);
110
- if (hasUnderscoreInPath(fileUrl) || isOnIgnoreList(fileUrl)) {
106
+ const { ext, base } = path.parse(entryPath);
107
+ const fileUrl = pathToFileURL(entryPath);
108
+ if (hasUnderscoreInPath(fileUrl) || isOnIgnoreList(base)) {
111
109
  return "ignored";
112
110
  } else if (contentFileExts.includes(ext)) {
113
111
  return "content";
@@ -117,9 +115,8 @@ function getEntryType(entryPath, paths) {
117
115
  return "unsupported";
118
116
  }
119
117
  }
120
- function isOnIgnoreList(fileUrl) {
121
- const { base } = path.parse(fileURLToPath(fileUrl));
122
- return [".DS_Store"].includes(base);
118
+ function isOnIgnoreList(fileName) {
119
+ return [".DS_Store"].includes(fileName);
123
120
  }
124
121
  function hasUnderscoreInPath(fileUrl) {
125
122
  const parts = fileUrl.pathname.split("/");
@@ -83,6 +83,7 @@ function astroConfigBuildPlugin(options, internals) {
83
83
  "build:post": ({ ssrOutputs, clientOutputs, mutate }) => {
84
84
  var _a, _b;
85
85
  const outputs = ssrOutputs.flatMap((o) => o.output);
86
+ const prependBase = (src) => prependForwardSlash(npath.posix.join(options.settings.config.base, src));
86
87
  for (const chunk of outputs) {
87
88
  if (chunk.type === "chunk" && (chunk.code.includes(LINKS_PLACEHOLDER) || chunk.code.includes(SCRIPTS_PLACEHOLDER))) {
88
89
  let entryCSS = /* @__PURE__ */ new Set();
@@ -113,7 +114,7 @@ function astroConfigBuildPlugin(options, internals) {
113
114
  if (entryCSS.size) {
114
115
  newCode = newCode.replace(
115
116
  JSON.stringify(LINKS_PLACEHOLDER),
116
- JSON.stringify([...entryCSS])
117
+ JSON.stringify(Array.from(entryCSS).map(prependBase))
117
118
  );
118
119
  }
119
120
  if (entryScripts.size) {
@@ -134,7 +135,7 @@ function astroConfigBuildPlugin(options, internals) {
134
135
  JSON.stringify(
135
136
  [...entryFileNames].map((src) => ({
136
137
  props: {
137
- src: prependForwardSlash(npath.posix.join(options.settings.config.base, src)),
138
+ src: prependBase(src),
138
139
  type: "module"
139
140
  },
140
141
  children: ""
@@ -276,7 +276,8 @@ async function generatePath(pathname, opts, gopts) {
276
276
  throwIfRedirectNotAllowed(result.response, opts.settings.config);
277
277
  if (!result.response.body)
278
278
  return;
279
- body = await result.response.text();
279
+ const ab = await result.response.arrayBuffer();
280
+ body = new Uint8Array(ab);
280
281
  } else {
281
282
  body = result.body;
282
283
  encoding = result.encoding;
@@ -209,74 +209,9 @@ export declare const AstroConfigSchema: z.ZodObject<{
209
209
  experimental?: {} | undefined;
210
210
  legacy?: {} | undefined;
211
211
  }>;
212
- export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL): z.ZodEffects<z.ZodObject<z.extendShape<{
213
- root: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
214
- srcDir: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
215
- publicDir: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
216
- outDir: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
212
+ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL): z.ZodEffects<z.ZodObject<{
217
213
  site: z.ZodOptional<z.ZodString>;
218
214
  base: z.ZodDefault<z.ZodOptional<z.ZodString>>;
219
- trailingSlash: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"always">, z.ZodLiteral<"never">, z.ZodLiteral<"ignore">]>>>;
220
- output: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"static">, z.ZodLiteral<"server">]>>>;
221
- adapter: z.ZodOptional<z.ZodObject<{
222
- name: z.ZodString;
223
- hooks: z.ZodDefault<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
224
- }, "strip", z.ZodTypeAny, {
225
- name: string;
226
- hooks: {};
227
- }, {
228
- hooks?: {} | undefined;
229
- name: string;
230
- }>>;
231
- integrations: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodObject<{
232
- name: z.ZodString;
233
- hooks: z.ZodDefault<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
234
- }, "strip", z.ZodTypeAny, {
235
- name: string;
236
- hooks: {};
237
- }, {
238
- hooks?: {} | undefined;
239
- name: string;
240
- }>, "many">>, {
241
- name: string;
242
- hooks: {};
243
- }[], unknown>;
244
- build: z.ZodDefault<z.ZodOptional<z.ZodObject<{
245
- format: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"file">, z.ZodLiteral<"directory">]>>>;
246
- client: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
247
- server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
248
- assets: z.ZodDefault<z.ZodOptional<z.ZodString>>;
249
- serverEntry: z.ZodDefault<z.ZodOptional<z.ZodString>>;
250
- }, "strip", z.ZodTypeAny, {
251
- assets: string;
252
- server: URL;
253
- format: "file" | "directory";
254
- client: URL;
255
- serverEntry: string;
256
- }, {
257
- assets?: string | undefined;
258
- server?: string | undefined;
259
- format?: "file" | "directory" | undefined;
260
- client?: string | undefined;
261
- serverEntry?: string | undefined;
262
- }>>>;
263
- server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodObject<{
264
- host: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>>;
265
- port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
266
- headers: z.ZodOptional<z.ZodType<OutgoingHttpHeaders, z.ZodTypeDef, OutgoingHttpHeaders>>;
267
- }, "strip", z.ZodTypeAny, {
268
- headers?: OutgoingHttpHeaders | undefined;
269
- host: string | boolean;
270
- port: number;
271
- }, {
272
- host?: string | boolean | undefined;
273
- port?: number | undefined;
274
- headers?: OutgoingHttpHeaders | undefined;
275
- }>>>, {
276
- headers?: OutgoingHttpHeaders | undefined;
277
- host: string | boolean;
278
- port: number;
279
- }, unknown>;
280
215
  markdown: z.ZodDefault<z.ZodObject<{
281
216
  drafts: z.ZodDefault<z.ZodBoolean>;
282
217
  syntaxHighlight: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"shiki">, z.ZodLiteral<"prism">, z.ZodLiteral<false>]>>;
@@ -325,10 +260,34 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
325
260
  gfm?: boolean | undefined;
326
261
  smartypants?: boolean | undefined;
327
262
  }>>;
263
+ output: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"static">, z.ZodLiteral<"server">]>>>;
264
+ trailingSlash: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"always">, z.ZodLiteral<"never">, z.ZodLiteral<"ignore">]>>>;
265
+ adapter: z.ZodOptional<z.ZodObject<{
266
+ name: z.ZodString;
267
+ hooks: z.ZodDefault<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
268
+ }, "strip", z.ZodTypeAny, {
269
+ name: string;
270
+ hooks: {};
271
+ }, {
272
+ hooks?: {} | undefined;
273
+ name: string;
274
+ }>>;
275
+ integrations: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodObject<{
276
+ name: z.ZodString;
277
+ hooks: z.ZodDefault<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
278
+ }, "strip", z.ZodTypeAny, {
279
+ name: string;
280
+ hooks: {};
281
+ }, {
282
+ hooks?: {} | undefined;
283
+ name: string;
284
+ }>, "many">>, {
285
+ name: string;
286
+ hooks: {};
287
+ }[], unknown>;
328
288
  vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
329
289
  experimental: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
330
290
  legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
331
- }, {
332
291
  root: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
333
292
  srcDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
334
293
  publicDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
@@ -373,7 +332,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
373
332
  port: number;
374
333
  streaming: boolean;
375
334
  }, unknown>;
376
- }>, "strip", z.ZodTypeAny, {
335
+ }, "strip", z.ZodTypeAny, {
377
336
  site?: string | undefined;
378
337
  adapter?: {
379
338
  name: string;
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "2.0.9";
1
+ const ASTRO_VERSION = "2.0.11";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -5,7 +5,7 @@ import * as msg from "../messages.js";
5
5
  import { startContainer } from "./container.js";
6
6
  import { createContainerWithAutomaticRestart } from "./restart.js";
7
7
  async function dev(settings, options) {
8
- var _a, _b;
8
+ var _a, _b, _c;
9
9
  const devStart = performance.now();
10
10
  await options.telemetry.record([]);
11
11
  const restart = await createContainerWithAutomaticRestart({
@@ -14,6 +14,7 @@ async function dev(settings, options) {
14
14
  beforeRestart: () => console.clear(),
15
15
  params: {
16
16
  settings,
17
+ root: (_a = options.flags) == null ? void 0 : _a.root,
17
18
  logging: options.logging,
18
19
  isRestart: options.isRestart
19
20
  }
@@ -30,11 +31,11 @@ async function dev(settings, options) {
30
31
  isRestart: options.isRestart
31
32
  })
32
33
  );
33
- const currentVersion = "2.0.9";
34
+ const currentVersion = "2.0.11";
34
35
  if (currentVersion.includes("-")) {
35
36
  warn(options.logging, null, msg.prerelease({ currentVersion }));
36
37
  }
37
- if (((_b = (_a = restart.container.viteConfig.server) == null ? void 0 : _a.fs) == null ? void 0 : _b.strict) === false) {
38
+ if (((_c = (_b = restart.container.viteConfig.server) == null ? void 0 : _b.fs) == null ? void 0 : _c.strict) === false) {
38
39
  warn(options.logging, null, msg.fsStrictWarning());
39
40
  }
40
41
  await attachContentServerListeners(restart.container);
@@ -47,7 +47,7 @@ function serverStart({
47
47
  base,
48
48
  isRestart = false
49
49
  }) {
50
- const version = "2.0.9";
50
+ const version = "2.0.11";
51
51
  const localPrefix = `${dim("\u2503")} Local `;
52
52
  const networkPrefix = `${dim("\u2503")} Network `;
53
53
  const emptyPrefix = " ".repeat(11);
@@ -233,7 +233,7 @@ function printHelp({
233
233
  message.push(
234
234
  linebreak(),
235
235
  ` ${bgGreen(black(` ${commandName} `))} ${green(
236
- `v${"2.0.9"}`
236
+ `v${"2.0.11"}`
237
237
  )} ${headline}`
238
238
  );
239
239
  }
@@ -43,7 +43,7 @@ function generatePaginateFunction(routeMatch) {
43
43
  next: pageNum === lastPage ? void 0 : routeMatch.generate({ ...params, page: String(pageNum + 1) }),
44
44
  prev: pageNum === 1 ? void 0 : routeMatch.generate({
45
45
  ...params,
46
- page: !includesFirstPageNumber && pageNum - 1 === 1 ? void 0 : String(pageNum - 1)
46
+ page: !includesFirstPageNumber && pageNum - 1 === 1 ? "" : String(pageNum - 1)
47
47
  })
48
48
  }
49
49
  }
@@ -5,7 +5,7 @@ import {
5
5
  getPrescripts
6
6
  } from "../scripts.js";
7
7
  import { renderAllHeadContent } from "./head.js";
8
- import { ScopeFlags } from "./scope.js";
8
+ import { hasScopeFlag, ScopeFlags } from "./scope.js";
9
9
  import { isSlotString } from "./slot.js";
10
10
  const Fragment = Symbol.for("astro:fragment");
11
11
  const Renderer = Symbol.for("astro:renderer");
@@ -44,6 +44,25 @@ function stringifyChunk(result, chunk) {
44
44
  case ScopeFlags.JSX | ScopeFlags.Slot | ScopeFlags.Astro | ScopeFlags.HeadBuffer: {
45
45
  return "";
46
46
  }
47
+ case ScopeFlags.JSX | ScopeFlags.Astro: {
48
+ if (hasScopeFlag(result, ScopeFlags.JSX)) {
49
+ return "";
50
+ }
51
+ break;
52
+ }
53
+ case ScopeFlags.Slot:
54
+ case ScopeFlags.Slot | ScopeFlags.HeadBuffer: {
55
+ if (hasScopeFlag(result, ScopeFlags.RenderSlot)) {
56
+ return "";
57
+ }
58
+ break;
59
+ }
60
+ case ScopeFlags.HeadBuffer: {
61
+ if (hasScopeFlag(result, ScopeFlags.JSX | ScopeFlags.HeadBuffer)) {
62
+ return "";
63
+ }
64
+ break;
65
+ }
47
66
  case ScopeFlags.RenderSlot | ScopeFlags.Astro:
48
67
  case ScopeFlags.RenderSlot | ScopeFlags.Astro | ScopeFlags.JSX:
49
68
  case ScopeFlags.RenderSlot | ScopeFlags.Astro | ScopeFlags.JSX | ScopeFlags.HeadBuffer: {
@@ -9,5 +9,6 @@ export declare const ScopeFlags: {
9
9
  type ScopeFlagValues = (typeof ScopeFlags)[keyof typeof ScopeFlags];
10
10
  export declare function addScopeFlag(result: SSRResult, flag: ScopeFlagValues): void;
11
11
  export declare function removeScopeFlag(result: SSRResult, flag: ScopeFlagValues): void;
12
+ export declare function hasScopeFlag(result: SSRResult, flag: ScopeFlagValues): boolean;
12
13
  export declare function createScopedResult(result: SSRResult, flag?: ScopeFlagValues): SSRResult;
13
14
  export {};
@@ -11,6 +11,9 @@ function addScopeFlag(result, flag) {
11
11
  function removeScopeFlag(result, flag) {
12
12
  result.scope &= ~flag;
13
13
  }
14
+ function hasScopeFlag(result, flag) {
15
+ return (result.scope & flag) === flag;
16
+ }
14
17
  function createScopedResult(result, flag) {
15
18
  const scopedResult = Object.create(result, {
16
19
  scope: {
@@ -27,5 +30,6 @@ export {
27
30
  ScopeFlags,
28
31
  addScopeFlag,
29
32
  createScopedResult,
33
+ hasScopeFlag,
30
34
  removeScopeFlag
31
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
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",