astro 2.2.0 → 2.2.2

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/client-base.d.ts CHANGED
@@ -178,6 +178,10 @@ declare module '*.module.pcss' {
178
178
  const classes: CSSModuleClasses;
179
179
  export default classes;
180
180
  }
181
+ declare module '*.module.sss' {
182
+ const classes: CSSModuleClasses;
183
+ export default classes;
184
+ }
181
185
 
182
186
  // CSS
183
187
  declare module '*.css' {
@@ -208,9 +212,31 @@ declare module '*.pcss' {
208
212
  const css: string;
209
213
  export default css;
210
214
  }
215
+ declare module '*.sss' {
216
+ const css: string;
217
+ export default css;
218
+ }
211
219
 
212
220
  // Built-in asset types
213
- // see `src/constants.ts`
221
+ // see `src/node/constants.ts`
222
+
223
+ // images
224
+ declare module '*.jfif' {
225
+ const src: string;
226
+ export default src;
227
+ }
228
+ declare module '*.pjpeg' {
229
+ const src: string;
230
+ export default src;
231
+ }
232
+ declare module '*.pjp' {
233
+ const src: string;
234
+ export default src;
235
+ }
236
+ declare module '*.ico' {
237
+ const src: string;
238
+ export default src;
239
+ }
214
240
 
215
241
  // media
216
242
  declare module '*.mp4' {
@@ -242,6 +268,11 @@ declare module '*.aac' {
242
268
  export default src;
243
269
  }
244
270
 
271
+ declare module '*.opus' {
272
+ const src: string;
273
+ export default src;
274
+ }
275
+
245
276
  // fonts
246
277
  declare module '*.woff' {
247
278
  const src: string;
@@ -265,10 +296,6 @@ declare module '*.otf' {
265
296
  }
266
297
 
267
298
  // other
268
- declare module '*.wasm' {
269
- const initWasm: (options: WebAssembly.Imports) => Promise<WebAssembly.Exports>;
270
- export default initWasm;
271
- }
272
299
  declare module '*.webmanifest' {
273
300
  const src: string;
274
301
  export default src;
@@ -282,6 +309,12 @@ declare module '*.txt' {
282
309
  export default src;
283
310
  }
284
311
 
312
+ // wasm?init
313
+ declare module '*.wasm?init' {
314
+ const initWasm: (options: WebAssembly.Imports) => Promise<WebAssembly.Instance>;
315
+ export default initWasm;
316
+ }
317
+
285
318
  // web worker
286
319
  declare module '*?worker' {
287
320
  const workerConstructor: {
@@ -297,6 +330,11 @@ declare module '*?worker&inline' {
297
330
  export default workerConstructor;
298
331
  }
299
332
 
333
+ declare module '*?worker&url' {
334
+ const src: string;
335
+ export default src;
336
+ }
337
+
300
338
  declare module '*?sharedworker' {
301
339
  const sharedWorkerConstructor: {
302
340
  new (): SharedWorker;
@@ -304,6 +342,18 @@ declare module '*?sharedworker' {
304
342
  export default sharedWorkerConstructor;
305
343
  }
306
344
 
345
+ declare module '*?sharedworker&inline' {
346
+ const sharedWorkerConstructor: {
347
+ new (): SharedWorker;
348
+ };
349
+ export default sharedWorkerConstructor;
350
+ }
351
+
352
+ declare module '*?sharedworker&url' {
353
+ const src: string;
354
+ export default src;
355
+ }
356
+
307
357
  declare module '*?raw' {
308
358
  const src: string;
309
359
  export default src;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { AstroCheck } from '@astrojs/language-server';
3
- import fsMod from 'fs';
3
+ import fs from 'fs';
4
4
  import type { Arguments as Flags } from 'yargs-parser';
5
5
  import type { AstroSettings } from '../../@types/astro';
6
6
  import type { LogOptions } from '../../core/logger/core.js';
@@ -53,7 +53,7 @@ type CheckerConstructor = {
53
53
  syncCli: (settings: AstroSettings, options: SyncOptions) => Promise<ProcessExit>;
54
54
  settings: Readonly<AstroSettings>;
55
55
  logging: Readonly<LogOptions>;
56
- fileSystem: typeof fsMod;
56
+ fileSystem: typeof fs;
57
57
  };
58
58
  /**
59
59
  * Responsible to check files - classic or watch mode - and report diagnostics.
@@ -3,7 +3,7 @@ import {
3
3
  DiagnosticSeverity
4
4
  } from "@astrojs/language-server";
5
5
  import glob from "fast-glob";
6
- import * as fs from "fs";
6
+ import fs from "fs";
7
7
  import { bold, dim, red, yellow } from "kleur/colors";
8
8
  import { createRequire } from "module";
9
9
  import { join } from "node:path";
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "2.2.0";
1
+ const ASTRO_VERSION = "2.2.2";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -16,6 +16,7 @@ import envVitePlugin from "../vite-plugin-env/index.js";
16
16
  import astroHeadPlugin from "../vite-plugin-head/index.js";
17
17
  import htmlVitePlugin from "../vite-plugin-html/index.js";
18
18
  import { astroInjectEnvTsPlugin } from "../vite-plugin-inject-env-ts/index.js";
19
+ import astroIntegrationsContainerPlugin from "../vite-plugin-integrations-container/index.js";
19
20
  import jsxVitePlugin from "../vite-plugin-jsx/index.js";
20
21
  import astroLoadFallbackPlugin from "../vite-plugin-load-fallback/index.js";
21
22
  import markdownVitePlugin from "../vite-plugin-markdown/index.js";
@@ -93,6 +94,7 @@ async function createVite(commandConfig, { settings, logging, mode, command, fs
93
94
  htmlVitePlugin(),
94
95
  jsxVitePlugin({ settings, logging }),
95
96
  astroPostprocessVitePlugin({ settings }),
97
+ mode === "dev" && astroIntegrationsContainerPlugin({ settings, logging }),
96
98
  astroScriptsPageSSRPlugin({ settings }),
97
99
  astroHeadPlugin({ settings }),
98
100
  astroScannerPlugin({ settings }),
@@ -4,7 +4,6 @@ import {
4
4
  runHookConfigDone,
5
5
  runHookConfigSetup,
6
6
  runHookServerDone,
7
- runHookServerSetup,
8
7
  runHookServerStart
9
8
  } from "../../integrations/index.js";
10
9
  import { createDefaultDevSettings, resolveRoot } from "../config/index.js";
@@ -48,7 +47,6 @@ async function createContainer(params = {}) {
48
47
  );
49
48
  await runHookConfigDone({ settings, logging });
50
49
  const viteServer = await vite.createServer(viteConfig);
51
- runHookServerSetup({ config: settings.config, server: viteServer, logging });
52
50
  const container = {
53
51
  configFlag: params.configFlag,
54
52
  configFlagPath: params.configFlagPath,
@@ -53,7 +53,7 @@ async function dev(settings, options) {
53
53
  isRestart: options.isRestart
54
54
  })
55
55
  );
56
- const currentVersion = "2.2.0";
56
+ const currentVersion = "2.2.2";
57
57
  if (currentVersion.includes("-")) {
58
58
  warn(options.logging, null, msg.prerelease({ currentVersion }));
59
59
  }
@@ -583,6 +583,7 @@ class ErrorOverlay extends HTMLElement {
583
583
  super();
584
584
  this.root = this.attachShadow({ mode: "open" });
585
585
  this.root.innerHTML = overlayTemplate;
586
+ this.dir = "ltr";
586
587
  const themeToggle = this.root.querySelector(".theme-toggle-checkbox");
587
588
  if (localStorage.astroErrorOverlayTheme === "dark" || !("astroErrorOverlayTheme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches) {
588
589
  this == null ? void 0 : this.classList.add("astro-dark");
@@ -47,7 +47,7 @@ function serverStart({
47
47
  base,
48
48
  isRestart = false
49
49
  }) {
50
- const version = "2.2.0";
50
+ const version = "2.2.2";
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.2.0"}`
236
+ `v${"2.2.2"}`
237
237
  )} ${headline}`
238
238
  );
239
239
  }
@@ -1,4 +1,7 @@
1
- import { renderSlot, stringifyChunk } from "../../runtime/server/index.js";
1
+ import {
2
+ renderSlotToString,
3
+ stringifyChunk
4
+ } from "../../runtime/server/index.js";
2
5
  import { renderJSX } from "../../runtime/server/jsx.js";
3
6
  import { AstroCookies } from "../cookies/index.js";
4
7
  import { AstroError, AstroErrorData } from "../errors/index.js";
@@ -67,7 +70,9 @@ class Slots {
67
70
  const expression = getFunctionExpression(component);
68
71
  if (expression) {
69
72
  const slot = () => expression(...args);
70
- return await renderSlot(result, slot).then((res) => res != null ? String(res) : res);
73
+ return await renderSlotToString(result, slot).then(
74
+ (res) => res != null ? String(res) : res
75
+ );
71
76
  }
72
77
  if (typeof component === "function") {
73
78
  return await renderJSX(result, component(...args)).then(
@@ -75,7 +80,7 @@ class Slots {
75
80
  );
76
81
  }
77
82
  }
78
- const content = await renderSlot(result, this.#slots[name]);
83
+ const content = await renderSlotToString(result, this.#slots[name]);
79
84
  const outHTML = stringifyChunk(result, content);
80
85
  return outHTML;
81
86
  }
@@ -3,7 +3,7 @@ export { createAstro } from './astro-global.js';
3
3
  export { renderEndpoint } from './endpoint.js';
4
4
  export { escapeHTML, HTMLBytes, HTMLString, markHTMLString, unescapeHTML } from './escape.js';
5
5
  export { renderJSX } from './jsx.js';
6
- export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, renderAstroTemplateResult as renderAstroComponent, renderComponent, renderComponentToIterable, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderScriptElement, renderSlot, renderStyleElement, renderTemplate as render, renderTemplate, renderToString, renderUniqueStylesheet, stringifyChunk, voidElementNames, } from './render/index.js';
6
+ export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, renderAstroTemplateResult as renderAstroComponent, renderComponent, renderComponentToIterable, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderScriptElement, renderSlot, renderSlotToString, renderStyleElement, renderTemplate as render, renderTemplate, renderToString, renderUniqueStylesheet, stringifyChunk, voidElementNames, } from './render/index.js';
7
7
  export type { AstroComponentFactory, AstroComponentInstance, ComponentSlots, RenderInstruction, } from './render/index.js';
8
8
  export declare function mergeSlots(...slotted: unknown[]): Record<string, () => any>;
9
9
  /** @internal Associate JSX components with a specific renderer (see /src/vite-plugin-jsx/tag.ts) */
@@ -18,6 +18,7 @@ import {
18
18
  renderPage,
19
19
  renderScriptElement,
20
20
  renderSlot,
21
+ renderSlotToString,
21
22
  renderStyleElement,
22
23
  renderTemplate,
23
24
  renderTemplate as renderTemplate2,
@@ -107,6 +108,7 @@ export {
107
108
  renderPage,
108
109
  renderScriptElement,
109
110
  renderSlot,
111
+ renderSlotToString,
110
112
  renderStyleElement,
111
113
  renderTemplate2 as renderTemplate,
112
114
  renderToString,
@@ -13,7 +13,7 @@ import {
13
13
  } from "./astro/index.js";
14
14
  import { Fragment, Renderer, stringifyChunk } from "./common.js";
15
15
  import { componentIsHTMLElement, renderHTMLElement } from "./dom.js";
16
- import { renderSlot, renderSlots } from "./slot.js";
16
+ import { renderSlots, renderSlotToString } from "./slot.js";
17
17
  import { formatList, internalSpreadAttributes, renderElement, voidElementNames } from "./util.js";
18
18
  const rendererAliases = /* @__PURE__ */ new Map([["solid", "solid-js"]]);
19
19
  function guessRenderers(componentUrl) {
@@ -166,7 +166,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
166
166
  }
167
167
  } else {
168
168
  if (metadata.hydrate === "only") {
169
- html = await renderSlot(result, slots == null ? void 0 : slots.fallback);
169
+ html = await renderSlotToString(result, slots == null ? void 0 : slots.fallback);
170
170
  } else {
171
171
  ({ html, attrs } = await renderer.ssr.renderToStaticMarkup.call(
172
172
  { result },
@@ -261,7 +261,7 @@ function sanitizeElementName(tag) {
261
261
  return tag.trim().split(unsafe)[0].trim();
262
262
  }
263
263
  async function renderFragmentComponent(result, slots = {}) {
264
- const children = await renderSlot(result, slots == null ? void 0 : slots.default);
264
+ const children = await renderSlotToString(result, slots == null ? void 0 : slots.default);
265
265
  if (children == null) {
266
266
  return children;
267
267
  }
@@ -1,5 +1,5 @@
1
1
  import { markHTMLString } from "../escape.js";
2
- import { renderSlot } from "./slot.js";
2
+ import { renderSlotToString } from "./slot.js";
3
3
  import { toAttributeString } from "./util.js";
4
4
  function componentIsHTMLElement(Component) {
5
5
  return typeof HTMLElement !== "undefined" && HTMLElement.isPrototypeOf(Component);
@@ -11,7 +11,7 @@ async function renderHTMLElement(result, constructor, props, slots) {
11
11
  attrHTML += ` ${attr}="${toAttributeString(await props[attr])}"`;
12
12
  }
13
13
  return markHTMLString(
14
- `<${name}${attrHTML}>${await renderSlot(result, slots == null ? void 0 : slots.default)}</${name}>`
14
+ `<${name}${attrHTML}>${await renderSlotToString(result, slots == null ? void 0 : slots.default)}</${name}>`
15
15
  );
16
16
  }
17
17
  function getHTMLElementName(constructor) {
@@ -5,7 +5,7 @@ export { renderComponent, renderComponentToIterable } from './component.js';
5
5
  export { renderHTMLElement } from './dom.js';
6
6
  export { maybeRenderHead, renderHead } from './head.js';
7
7
  export { renderPage } from './page.js';
8
- export { renderSlot, type ComponentSlots } from './slot.js';
8
+ export { renderSlot, renderSlotToString, type ComponentSlots } from './slot.js';
9
9
  export { renderScriptElement, renderStyleElement, renderUniqueStylesheet } from './tags.js';
10
10
  export type { RenderInstruction } from './types';
11
11
  export { addAttribute, defineScriptVars, voidElementNames } from './util.js';
@@ -9,7 +9,7 @@ import { renderComponent, renderComponentToIterable } from "./component.js";
9
9
  import { renderHTMLElement } from "./dom.js";
10
10
  import { maybeRenderHead, renderHead } from "./head.js";
11
11
  import { renderPage } from "./page.js";
12
- import { renderSlot } from "./slot.js";
12
+ import { renderSlot, renderSlotToString } from "./slot.js";
13
13
  import { renderScriptElement, renderStyleElement, renderUniqueStylesheet } from "./tags.js";
14
14
  import { addAttribute, defineScriptVars, voidElementNames } from "./util.js";
15
15
  export {
@@ -27,6 +27,7 @@ export {
27
27
  renderPage,
28
28
  renderScriptElement,
29
29
  renderSlot,
30
+ renderSlotToString,
30
31
  renderStyleElement,
31
32
  renderTemplate,
32
33
  renderToString,
@@ -48,8 +48,9 @@ async function bufferHeadContent(result) {
48
48
  }
49
49
  }
50
50
  async function renderPage(result, componentFactory, props, children, streaming, route) {
51
- var _a;
51
+ var _a, _b;
52
52
  if (!isAstroComponentFactory(componentFactory)) {
53
+ result._metadata.headInTree = ((_a = result.componentMetadata.get(componentFactory.moduleId)) == null ? void 0 : _a.containsHead) ?? false;
53
54
  const pageProps = { ...props ?? {}, "server:root": true };
54
55
  let output;
55
56
  let head = "";
@@ -91,7 +92,7 @@ async function renderPage(result, componentFactory, props, children, streaming,
91
92
  ])
92
93
  });
93
94
  }
94
- result._metadata.headInTree = ((_a = result.componentMetadata.get(componentFactory.moduleId)) == null ? void 0 : _a.containsHead) ?? false;
95
+ result._metadata.headInTree = ((_b = result.componentMetadata.get(componentFactory.moduleId)) == null ? void 0 : _b.containsHead) ?? false;
95
96
  const factoryReturnValue = await componentFactory(result, props, children);
96
97
  const factoryIsHeadAndContent = isHeadAndContent(factoryReturnValue);
97
98
  if (isRenderTemplateResult(factoryReturnValue) || factoryIsHeadAndContent) {
@@ -12,7 +12,8 @@ export declare class SlotString extends HTMLString {
12
12
  constructor(content: string, instructions: null | RenderInstruction[]);
13
13
  }
14
14
  export declare function isSlotString(str: string): str is any;
15
- export declare function renderSlot(result: SSRResult, slotted: ComponentSlotValue | RenderTemplateResult, fallback?: ComponentSlotValue | RenderTemplateResult): Promise<string>;
15
+ export declare function renderSlot(result: SSRResult, slotted: ComponentSlotValue | RenderTemplateResult, fallback?: ComponentSlotValue | RenderTemplateResult): AsyncGenerator<any, void, undefined>;
16
+ export declare function renderSlotToString(result: SSRResult, slotted: ComponentSlotValue | RenderTemplateResult, fallback?: ComponentSlotValue | RenderTemplateResult): Promise<string>;
16
17
  interface RenderSlotsResult {
17
18
  slotInstructions: null | RenderInstruction[];
18
19
  children: Record<string, string>;
@@ -12,27 +12,30 @@ slotString;
12
12
  function isSlotString(str) {
13
13
  return !!str[slotString];
14
14
  }
15
- async function renderSlot(result, slotted, fallback) {
15
+ async function* renderSlot(result, slotted, fallback) {
16
16
  if (slotted) {
17
17
  let iterator = renderChild(typeof slotted === "function" ? slotted(result) : slotted);
18
- let content = "";
19
- let instructions = null;
20
- for await (const chunk of iterator) {
21
- if (typeof chunk.type === "string") {
22
- if (instructions === null) {
23
- instructions = [];
24
- }
25
- instructions.push(chunk);
26
- } else {
27
- content += chunk;
28
- }
29
- }
30
- return markHTMLString(new SlotString(content, instructions));
18
+ yield* iterator;
31
19
  }
32
20
  if (fallback) {
33
- return renderSlot(result, fallback);
21
+ yield* renderSlot(result, fallback);
22
+ }
23
+ }
24
+ async function renderSlotToString(result, slotted, fallback) {
25
+ let content = "";
26
+ let instructions = null;
27
+ let iterator = renderSlot(result, slotted, fallback);
28
+ for await (const chunk of iterator) {
29
+ if (typeof chunk.type === "string") {
30
+ if (instructions === null) {
31
+ instructions = [];
32
+ }
33
+ instructions.push(chunk);
34
+ } else {
35
+ content += chunk;
36
+ }
34
37
  }
35
- return "";
38
+ return markHTMLString(new SlotString(content, instructions));
36
39
  }
37
40
  async function renderSlots(result, slots = {}) {
38
41
  let slotInstructions = null;
@@ -40,7 +43,7 @@ async function renderSlots(result, slots = {}) {
40
43
  if (slots) {
41
44
  await Promise.all(
42
45
  Object.entries(slots).map(
43
- ([key, value]) => renderSlot(result, value).then((output) => {
46
+ ([key, value]) => renderSlotToString(result, value).then((output) => {
44
47
  if (output.instructions) {
45
48
  if (slotInstructions === null) {
46
49
  slotInstructions = [];
@@ -58,5 +61,6 @@ export {
58
61
  SlotString,
59
62
  isSlotString,
60
63
  renderSlot,
64
+ renderSlotToString,
61
65
  renderSlots
62
66
  };
@@ -0,0 +1,8 @@
1
+ import type { Plugin as VitePlugin } from 'vite';
2
+ import type { AstroSettings } from '../@types/astro.js';
3
+ import type { LogOptions } from '../core/logger/core.js';
4
+ /** Connect Astro integrations into Vite, as needed. */
5
+ export default function astroIntegrationsContainerPlugin({ settings, logging, }: {
6
+ settings: AstroSettings;
7
+ logging: LogOptions;
8
+ }): VitePlugin;
@@ -0,0 +1,15 @@
1
+ import { runHookServerSetup } from "../integrations/index.js";
2
+ function astroIntegrationsContainerPlugin({
3
+ settings,
4
+ logging
5
+ }) {
6
+ return {
7
+ name: "astro:integration-container",
8
+ configureServer(server) {
9
+ runHookServerSetup({ config: settings.config, server, logging });
10
+ }
11
+ };
12
+ }
13
+ export {
14
+ astroIntegrationsContainerPlugin as default
15
+ };
@@ -5,7 +5,7 @@ function loadFallbackPlugin({
5
5
  fs,
6
6
  root
7
7
  }) {
8
- if (!fs || fs === nodeFs) {
8
+ if (!fs || fs === nodeFs || fs.default === nodeFs) {
9
9
  return false;
10
10
  }
11
11
  const tryLoadModule = async (id) => {
@@ -38,11 +38,6 @@ function loadFallbackPlugin({
38
38
  } catch {
39
39
  }
40
40
  }
41
- let resolved = await this.resolve(id, parent, { skipSelf: true });
42
- if (resolved) {
43
- return resolved.id;
44
- }
45
- return slashify(id);
46
41
  },
47
42
  async load(id) {
48
43
  const source = await tryLoadModule(id);
@@ -8,6 +8,21 @@ function includesExport(code) {
8
8
  }
9
9
  return false;
10
10
  }
11
+ function isQuoted(value) {
12
+ return (value[0] === '"' || value[0] === "'") && value[value.length - 1] === value[0];
13
+ }
14
+ function isTruthy(value) {
15
+ if (isQuoted(value)) {
16
+ value = value.slice(1, -1);
17
+ }
18
+ return value === "true" || value === "1";
19
+ }
20
+ function isFalsy(value) {
21
+ if (isQuoted(value)) {
22
+ value = value.slice(1, -1);
23
+ }
24
+ return value === "false" || value === "0";
25
+ }
11
26
  let didInit = false;
12
27
  async function scan(code, id) {
13
28
  if (!includesExport(code))
@@ -23,14 +38,14 @@ async function scan(code, id) {
23
38
  if (BOOLEAN_EXPORTS.has(name)) {
24
39
  const prefix = code.slice(0, endOfLocalName).split("export").pop().trim().replace("prerender", "").trim();
25
40
  const suffix = code.slice(endOfLocalName).trim().replace(/\=/, "").trim().split(/[;\n]/)[0];
26
- if (prefix !== "const" || !(suffix === "true" || suffix === "false")) {
41
+ if (prefix !== "const" || !(isTruthy(suffix) || isFalsy(suffix))) {
27
42
  throw new AstroError({
28
43
  ...AstroErrorData.InvalidPrerenderExport,
29
44
  message: AstroErrorData.InvalidPrerenderExport.message(prefix, suffix),
30
45
  location: { file: id }
31
46
  });
32
47
  } else {
33
- pageOptions[name] = suffix === "true";
48
+ pageOptions[name] = isTruthy(suffix);
34
49
  }
35
50
  }
36
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
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",
@@ -93,7 +93,7 @@
93
93
  "src/content/template"
94
94
  ],
95
95
  "dependencies": {
96
- "@astrojs/compiler": "^1.3.0",
96
+ "@astrojs/compiler": "^1.3.1",
97
97
  "@astrojs/language-server": "^0.28.3",
98
98
  "@astrojs/markdown-remark": "^2.1.3",
99
99
  "@astrojs/telemetry": "^2.1.0",
@@ -33,7 +33,7 @@ declare module 'astro:content' {
33
33
  export const image: never;
34
34
 
35
35
  // This needs to be in sync with ImageMetadata
36
- type ImageFunction = () => import('astro/zod').ZodObject<{
36
+ export type ImageFunction = () => import('astro/zod').ZodObject<{
37
37
  src: import('astro/zod').ZodString;
38
38
  width: import('astro/zod').ZodNumber;
39
39
  height: import('astro/zod').ZodNumber;
@@ -63,15 +63,10 @@ declare module 'astro:content' {
63
63
  | BaseSchemaWithoutEffects
64
64
  | import('astro/zod').ZodEffects<BaseSchemaWithoutEffects>;
65
65
 
66
+ export type SchemaContext = { image: ImageFunction };
67
+
66
68
  type BaseCollectionConfig<S extends BaseSchema> = {
67
- schema?: S | (({ image }: { image: ImageFunction }) => S);
68
- slug?: (entry: {
69
- id: CollectionEntry<keyof typeof entryMap>['id'];
70
- defaultSlug: string;
71
- collection: string;
72
- body: string;
73
- data: import('astro/zod').infer<S>;
74
- }) => string | Promise<string>;
69
+ schema?: S | ((context: SchemaContext) => S);
75
70
  };
76
71
  export function defineCollection<S extends BaseSchema>(
77
72
  input: BaseCollectionConfig<S>