astro 1.0.3 → 1.0.6

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/dist/cli/index.js CHANGED
@@ -20,7 +20,7 @@ function printAstroHelp() {
20
20
  printHelp({
21
21
  commandName: "astro",
22
22
  usage: "[command] [...flags]",
23
- headline: "Futuristic web development tool.",
23
+ headline: "Build faster websites.",
24
24
  tables: {
25
25
  Commands: [
26
26
  ["add", "Add an integration."],
@@ -326,6 +326,24 @@ async function setAdapter(ast, adapter, exportName) {
326
326
  const configObject = path2.node.declaration.arguments[0];
327
327
  if (!t.isObjectExpression(configObject))
328
328
  return;
329
+ let outputProp = configObject.properties.find((prop) => {
330
+ if (prop.type !== "ObjectProperty")
331
+ return false;
332
+ if (prop.key.type === "Identifier") {
333
+ if (prop.key.name === "output")
334
+ return true;
335
+ }
336
+ if (prop.key.type === "StringLiteral") {
337
+ if (prop.key.value === "output")
338
+ return true;
339
+ }
340
+ return false;
341
+ });
342
+ if (!outputProp) {
343
+ configObject.properties.push(
344
+ t.objectProperty(t.identifier("output"), t.stringLiteral("server"))
345
+ );
346
+ }
329
347
  let adapterProp = configObject.properties.find((prop) => {
330
348
  if (prop.type !== "ObjectProperty")
331
349
  return false;
@@ -157,7 +157,7 @@ async function getPathsForRoute(pageData, mod, opts, builtPaths) {
157
157
  return paths;
158
158
  }
159
159
  function addPageName(pathname, opts) {
160
- opts.pageNames.push(pathname.replace(/\/?$/, "/").replace(/^\//, ""));
160
+ opts.pageNames.push(pathname.replace(/^\//, ""));
161
161
  }
162
162
  async function generatePath(pathname, opts, gopts) {
163
163
  var _a;
@@ -46,7 +46,7 @@ async function dev(config, options) {
46
46
  https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
47
47
  })
48
48
  );
49
- const currentVersion = "1.0.3";
49
+ const currentVersion = "1.0.6";
50
50
  if (currentVersion.includes("-")) {
51
51
  warn(options.logging, null, msg.prerelease({ currentVersion }));
52
52
  }
@@ -47,7 +47,7 @@ function devStart({
47
47
  https,
48
48
  site
49
49
  }) {
50
- const version = "1.0.3";
50
+ const version = "1.0.6";
51
51
  const rootPath = site ? site.pathname : "/";
52
52
  const localPrefix = `${dim("\u2503")} Local `;
53
53
  const networkPrefix = `${dim("\u2503")} Network `;
@@ -226,7 +226,7 @@ function printHelp({
226
226
  message.push(
227
227
  linebreak(),
228
228
  ` ${bgGreen(black(` ${commandName} `))} ${green(
229
- `v${"1.0.3"}`
229
+ `v${"1.0.6"}`
230
230
  )} ${headline}`
231
231
  );
232
232
  }
@@ -9,6 +9,11 @@ import * as msg from "../messages.js";
9
9
  import { getResolvedHostForHttpServer } from "./util.js";
10
10
  const HAS_FILE_EXTENSION_REGEXP = /^.*\.[^\\]+$/;
11
11
  async function preview(config, { logging }) {
12
+ if (config.output === "server") {
13
+ throw new Error(
14
+ `[preview] 'output: server' not supported. Use your deploy platform's preview command directly instead, if one exists. (ex: 'netlify dev', 'vercel dev', 'wrangler', etc.)`
15
+ );
16
+ }
12
17
  const startServerTime = performance.now();
13
18
  const defaultOrigin = "http://localhost";
14
19
  const trailingSlash = config.trailingSlash;
@@ -6,7 +6,10 @@ function getRouteGenerator(segments, addTrailingSlash) {
6
6
  return part.dynamic ? `:${part.content}` : part.content.normalize().replace(/\?/g, "%3F").replace(/#/g, "%23").replace(/%5B/g, "[").replace(/%5D/g, "]").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7
7
  }).join("");
8
8
  }).join("");
9
- const trailing = addTrailingSlash !== "never" && segments.length ? "/" : "";
9
+ let trailing = "";
10
+ if (addTrailingSlash === "always" && segments.length) {
11
+ trailing = "/";
12
+ }
10
13
  const toPath = compile(template + trailing);
11
14
  return toPath;
12
15
  }
package/dist/core/util.js CHANGED
@@ -5,7 +5,7 @@ import resolve from "resolve";
5
5
  import slash from "slash";
6
6
  import { fileURLToPath, pathToFileURL } from "url";
7
7
  import { prependForwardSlash, removeTrailingForwardSlash } from "./path.js";
8
- const ASTRO_VERSION = "1.0.3";
8
+ const ASTRO_VERSION = "1.0.6";
9
9
  function isObject(value) {
10
10
  return typeof value === "object" && value != null;
11
11
  }
package/dist/jsx/babel.js CHANGED
@@ -52,7 +52,7 @@ function addClientMetadata(node, meta) {
52
52
  }
53
53
  if (!existingAttributes.find((attr) => attr === "client:component-export")) {
54
54
  if (meta.name === "*") {
55
- meta.name = getTagName(node).split(".").at(1);
55
+ meta.name = getTagName(node).split(".").slice(1).join(".");
56
56
  }
57
57
  const componentExport = t.jsxAttribute(
58
58
  t.jsxNamespacedName(t.jsxIdentifier("client"), t.jsxIdentifier("component-export")),
@@ -157,6 +157,74 @@ function astroJSX() {
157
157
  }
158
158
  state.set("imports", imports);
159
159
  },
160
+ JSXMemberExpression(path, state) {
161
+ var _a;
162
+ const node = path.node;
163
+ if (((_a = state.filename) == null ? void 0 : _a.endsWith(".mdx")) && t.isJSXIdentifier(node.object) && node.object.name === "_components") {
164
+ return;
165
+ }
166
+ const parent = path.findParent((n) => t.isJSXElement(n));
167
+ const parentNode = parent.node;
168
+ const tagName = getTagName(parentNode);
169
+ if (!isComponent(tagName))
170
+ return;
171
+ if (!hasClientDirective(parentNode))
172
+ return;
173
+ const isClientOnly = isClientOnlyComponent(parentNode);
174
+ if (tagName === ClientOnlyPlaceholder)
175
+ return;
176
+ const imports = state.get("imports") ?? /* @__PURE__ */ new Map();
177
+ const namespace = tagName.split(".");
178
+ for (const [source, specs] of imports) {
179
+ for (const { imported, local } of specs) {
180
+ const reference = path.referencesImport(source, imported);
181
+ if (reference) {
182
+ path.setData("import", { name: imported, path: source });
183
+ break;
184
+ }
185
+ if (namespace.at(0) === local) {
186
+ path.setData("import", { name: imported, path: source });
187
+ break;
188
+ }
189
+ }
190
+ }
191
+ const meta = path.getData("import");
192
+ if (meta) {
193
+ let resolvedPath;
194
+ if (meta.path.startsWith(".")) {
195
+ const fileURL = pathToFileURL(state.filename);
196
+ resolvedPath = `/@fs${new URL(meta.path, fileURL).pathname}`;
197
+ if (resolvedPath.endsWith(".jsx")) {
198
+ resolvedPath = resolvedPath.slice(0, -4);
199
+ }
200
+ } else {
201
+ resolvedPath = meta.path;
202
+ }
203
+ if (isClientOnly) {
204
+ state.file.metadata.astro.clientOnlyComponents.push({
205
+ exportName: meta.name,
206
+ specifier: tagName,
207
+ resolvedPath
208
+ });
209
+ meta.resolvedPath = resolvedPath;
210
+ addClientOnlyMetadata(parentNode, meta);
211
+ } else {
212
+ state.file.metadata.astro.hydratedComponents.push({
213
+ exportName: "*",
214
+ specifier: tagName,
215
+ resolvedPath
216
+ });
217
+ meta.resolvedPath = resolvedPath;
218
+ addClientMetadata(parentNode, meta);
219
+ }
220
+ } else {
221
+ throw new Error(
222
+ `Unable to match <${getTagName(
223
+ parentNode
224
+ )}> with client:* directive to an import statement!`
225
+ );
226
+ }
227
+ },
160
228
  JSXIdentifier(path, state) {
161
229
  const isAttr = path.findParent((n) => t.isJSXAttribute(n));
162
230
  if (isAttr)
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "1.0.3";
1
+ const ASTRO_VERSION = "1.0.6";
2
2
  function createDeprecatedFetchContentFn() {
3
3
  return () => {
4
4
  throw new Error("Deprecated: Astro.fetchContent() has been replaced with Astro.glob().");
@@ -72,7 +72,15 @@ var _a;
72
72
  rendererUrl ? import(rendererUrl) : () => () => {
73
73
  }
74
74
  ]);
75
- this.Component = componentModule[this.getAttribute("component-export") || "default"];
75
+ const componentExport = this.getAttribute("component-export") || "default";
76
+ if (!componentExport.includes(".")) {
77
+ this.Component = componentModule[componentExport];
78
+ } else {
79
+ this.Component = componentModule;
80
+ for (const part of componentExport.split(".")) {
81
+ this.Component = this.Component[part];
82
+ }
83
+ }
76
84
  this.hydrator = hydrator;
77
85
  return this.hydrate;
78
86
  },
@@ -1,4 +1,4 @@
1
- var astro_island_prebuilt_default = `var a;{const l={0:t=>t,1:t=>JSON.parse(t,n),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,n)),5:t=>new Set(JSON.parse(t,n)),6:t=>BigInt(t),7:t=>new URL(t)},n=(t,r)=>{if(t===""||!Array.isArray(r))return r;const[e,i]=r;return e in l?l[e](i):void 0};customElements.get("astro-island")||customElements.define("astro-island",(a=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement?.closest("astro-island[ssr]"))return;const r=this.querySelectorAll("astro-slot"),e={},i=this.querySelectorAll("template[data-astro-template]");for(const s of i)!s.closest(this.tagName)?.isSameNode(this)||(e[s.getAttribute("data-astro-template")||"default"]=s.innerHTML,s.remove());for(const s of r)!s.closest(this.tagName)?.isSameNode(this)||(e[s.getAttribute("name")||"default"]=s.innerHTML);const o=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),n):{};this.hydrator(this)(this.Component,o,e,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),window.removeEventListener("astro:hydrate",this.hydrate),window.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((r,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener("astro:hydrate",this.hydrate),await import(this.getAttribute("before-hydration-url"));const r=JSON.parse(this.getAttribute("opts"));Astro[this.getAttribute("client")](async()=>{const e=this.getAttribute("renderer-url"),[i,{default:o}]=await Promise.all([import(this.getAttribute("component-url")),e?import(e):()=>()=>{}]);return this.Component=i[this.getAttribute("component-export")||"default"],this.hydrator=o,this.hydrate},r,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},a.observedAttributes=["props"],a))}`;
1
+ var astro_island_prebuilt_default = `var a;{const l={0:t=>t,1:t=>JSON.parse(t,n),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,n)),5:t=>new Set(JSON.parse(t,n)),6:t=>BigInt(t),7:t=>new URL(t)},n=(t,r)=>{if(t===""||!Array.isArray(r))return r;const[s,i]=r;return s in l?l[s](i):void 0};customElements.get("astro-island")||customElements.define("astro-island",(a=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement?.closest("astro-island[ssr]"))return;const r=this.querySelectorAll("astro-slot"),s={},i=this.querySelectorAll("template[data-astro-template]");for(const e of i)!e.closest(this.tagName)?.isSameNode(this)||(s[e.getAttribute("data-astro-template")||"default"]=e.innerHTML,e.remove());for(const e of r)!e.closest(this.tagName)?.isSameNode(this)||(s[e.getAttribute("name")||"default"]=e.innerHTML);const o=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),n):{};this.hydrator(this)(this.Component,o,s,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),window.removeEventListener("astro:hydrate",this.hydrate),window.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((r,s)=>{s.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener("astro:hydrate",this.hydrate),await import(this.getAttribute("before-hydration-url"));const r=JSON.parse(this.getAttribute("opts"));Astro[this.getAttribute("client")](async()=>{const s=this.getAttribute("renderer-url"),[i,{default:o}]=await Promise.all([import(this.getAttribute("component-url")),s?import(s):()=>()=>{}]),e=this.getAttribute("component-export")||"default";if(!e.includes("."))this.Component=i[e];else{this.Component=i;for(const c of e.split("."))this.Component=this.Component[c]}return this.hydrator=o,this.hydrate},r,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},a.observedAttributes=["props"],a))}`;
2
2
  export {
3
3
  astro_island_prebuilt_default as default
4
4
  };
@@ -69,9 +69,9 @@ function extractDirectives(inputProps) {
69
69
  async function generateHydrateScript(scriptOptions, metadata) {
70
70
  const { renderer, result, astroId, props, attrs } = scriptOptions;
71
71
  const { hydrate, componentUrl, componentExport } = metadata;
72
- if (!componentExport) {
72
+ if (!componentExport.value) {
73
73
  throw new Error(
74
- `Unable to resolve a componentExport for "${metadata.displayName}"! Please open an issue.`
74
+ `Unable to resolve a valid export for "${metadata.displayName}"! Please open an issue at https://astro.build/issues!`
75
75
  );
76
76
  }
77
77
  const island = {
@@ -35,6 +35,9 @@ class AstroComponent {
35
35
  function isAstroComponent(obj) {
36
36
  return typeof obj === "object" && Object.prototype.toString.call(obj) === "[object AstroComponent]";
37
37
  }
38
+ function isAstroComponentFactory(obj) {
39
+ return obj == null ? false : !!obj.isAstroComponentFactory;
40
+ }
38
41
  async function* renderAstroComponent(component) {
39
42
  for await (const value of component) {
40
43
  if (value || value === 0) {
@@ -83,6 +86,7 @@ async function renderTemplate(htmlParts, ...expressions) {
83
86
  export {
84
87
  AstroComponent,
85
88
  isAstroComponent,
89
+ isAstroComponentFactory,
86
90
  renderAstroComponent,
87
91
  renderTemplate,
88
92
  renderToIterable,
@@ -3,7 +3,12 @@ import { extractDirectives, generateHydrateScript } from "../hydration.js";
3
3
  import { serializeProps } from "../serialize.js";
4
4
  import { shorthash } from "../shorthash.js";
5
5
  import { renderSlot } from "./any.js";
6
- import { renderAstroComponent, renderTemplate, renderToIterable } from "./astro.js";
6
+ import {
7
+ isAstroComponentFactory,
8
+ renderAstroComponent,
9
+ renderTemplate,
10
+ renderToIterable
11
+ } from "./astro.js";
7
12
  import { Fragment, Renderer } from "./common.js";
8
13
  import { componentIsHTMLElement, renderHTMLElement } from "./dom.js";
9
14
  import { formatList, internalSpreadAttributes, renderElement, voidElementNames } from "./util.js";
@@ -29,7 +34,7 @@ function getComponentType(Component) {
29
34
  if (Component && typeof Component === "object" && Component["astro:html"]) {
30
35
  return "html";
31
36
  }
32
- if (Component && Component.isAstroComponentFactory) {
37
+ if (isAstroComponentFactory(Component)) {
33
38
  return "astro-factory";
34
39
  }
35
40
  return "unknown";
@@ -1,11 +1,15 @@
1
1
  import { createResponse } from "../response.js";
2
- import { isAstroComponent, renderAstroComponent } from "./astro.js";
2
+ import { isAstroComponent, isAstroComponentFactory, renderAstroComponent } from "./astro.js";
3
3
  import { stringifyChunk } from "./common.js";
4
4
  import { renderComponent } from "./component.js";
5
5
  import { maybeRenderHead } from "./head.js";
6
6
  const encoder = new TextEncoder();
7
+ const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
8
+ function nonAstroPageNeedsHeadInjection(pageComponent) {
9
+ return needsHeadRenderingSymbol in pageComponent && !!pageComponent[needsHeadRenderingSymbol];
10
+ }
7
11
  async function renderPage(result, componentFactory, props, children, streaming) {
8
- if (!componentFactory.isAstroComponentFactory) {
12
+ if (!isAstroComponentFactory(componentFactory)) {
9
13
  const pageProps = { ...props ?? {}, "server:root": true };
10
14
  const output = await renderComponent(
11
15
  result,
@@ -18,15 +22,18 @@ async function renderPage(result, componentFactory, props, children, streaming)
18
22
  if (!/<!doctype html/i.test(html)) {
19
23
  let rest = html;
20
24
  html = `<!DOCTYPE html>`;
21
- for await (let chunk of maybeRenderHead(result)) {
22
- html += chunk;
25
+ if (nonAstroPageNeedsHeadInjection(componentFactory)) {
26
+ for await (let chunk of maybeRenderHead(result)) {
27
+ html += chunk;
28
+ }
23
29
  }
24
30
  html += rest;
25
31
  }
26
- return new Response(html, {
32
+ const bytes = encoder.encode(html);
33
+ return new Response(bytes, {
27
34
  headers: new Headers([
28
35
  ["Content-Type", "text/html; charset=utf-8"],
29
- ["Content-Length", Buffer.byteLength(html, "utf-8").toString()]
36
+ ["Content-Length", bytes.byteLength.toString()]
30
37
  ])
31
38
  });
32
39
  }
@@ -216,7 +216,7 @@ export interface AstroGlobalPartial {
216
216
  */
217
217
  glob(globStr: `${any}.astro`): Promise<AstroInstance[]>;
218
218
  glob<T extends Record<string, any>>(globStr: `${any}.md`): Promise<MarkdownInstance<T>[]>;
219
- glob<T extends Record<string, any>>(globStr: `${any}.mdx`): Promise<MarkdownInstance<T>[]>;
219
+ glob<T extends Record<string, any>>(globStr: `${any}.mdx`): Promise<MDXInstance<T>[]>;
220
220
  glob<T extends Record<string, any>>(globStr: string): Promise<T[]>;
221
221
  /**
222
222
  * Returns a [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object built from the [site](https://docs.astro.build/en/reference/configuration-reference/#site) config option
@@ -782,6 +782,24 @@ export interface MarkdownInstance<T extends Record<string, any>> {
782
782
  default: AstroComponentFactory;
783
783
  }>;
784
784
  }
785
+ export interface MDXInstance<T> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent' | 'Content' | 'default'> {
786
+ /** MDX does not support rawContent! If you need to read the Markdown contents to calculate values (ex. reading time), we suggest injecting frontmatter via remark plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins */
787
+ rawContent: never;
788
+ /** MDX does not support compiledContent! If you need to read the HTML contents to calculate values (ex. reading time), we suggest injecting frontmatter via rehype plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins */
789
+ compiledContent: never;
790
+ default: AstroComponentFactory;
791
+ Content: AstroComponentFactory;
792
+ }
793
+ export interface MarkdownLayoutProps<T extends Record<string, any>> {
794
+ frontmatter: {
795
+ file: MarkdownInstance<T>['file'];
796
+ url: MarkdownInstance<T>['url'];
797
+ } & T;
798
+ headings: MarkdownHeading[];
799
+ rawContent: MarkdownInstance<T>['rawContent'];
800
+ compiledContent: MarkdownInstance<T>['compiledContent'];
801
+ }
802
+ export declare type MDXLayoutProps<T> = Omit<MarkdownLayoutProps<T>, 'rawContent' | 'compiledContent'>;
785
803
  export declare type GetHydrateCallback = () => Promise<() => void | Promise<void>>;
786
804
  /**
787
805
  * getStaticPaths() options
@@ -3,5 +3,5 @@
3
3
  * Do not edit this directly, but instead edit that file and rerun the prebuild
4
4
  * to generate this file.
5
5
  */
6
- declare const _default: "var a;{const l={0:t=>t,1:t=>JSON.parse(t,n),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,n)),5:t=>new Set(JSON.parse(t,n)),6:t=>BigInt(t),7:t=>new URL(t)},n=(t,r)=>{if(t===\"\"||!Array.isArray(r))return r;const[e,i]=r;return e in l?l[e](i):void 0};customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(a=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement?.closest(\"astro-island[ssr]\"))return;const r=this.querySelectorAll(\"astro-slot\"),e={},i=this.querySelectorAll(\"template[data-astro-template]\");for(const s of i)!s.closest(this.tagName)?.isSameNode(this)||(e[s.getAttribute(\"data-astro-template\")||\"default\"]=s.innerHTML,s.remove());for(const s of r)!s.closest(this.tagName)?.isSameNode(this)||(e[s.getAttribute(\"name\")||\"default\"]=s.innerHTML);const o=this.hasAttribute(\"props\")?JSON.parse(this.getAttribute(\"props\"),n):{};this.hydrator(this)(this.Component,o,e,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),window.removeEventListener(\"astro:hydrate\",this.hydrate),window.dispatchEvent(new CustomEvent(\"astro:hydrate\"))}}connectedCallback(){!this.hasAttribute(\"await-children\")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((r,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener(\"astro:hydrate\",this.hydrate),await import(this.getAttribute(\"before-hydration-url\"));const r=JSON.parse(this.getAttribute(\"opts\"));Astro[this.getAttribute(\"client\")](async()=>{const e=this.getAttribute(\"renderer-url\"),[i,{default:o}]=await Promise.all([import(this.getAttribute(\"component-url\")),e?import(e):()=>()=>{}]);return this.Component=i[this.getAttribute(\"component-export\")||\"default\"],this.hydrator=o,this.hydrate},r,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},a.observedAttributes=[\"props\"],a))}";
6
+ declare const _default: "var a;{const l={0:t=>t,1:t=>JSON.parse(t,n),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,n)),5:t=>new Set(JSON.parse(t,n)),6:t=>BigInt(t),7:t=>new URL(t)},n=(t,r)=>{if(t===\"\"||!Array.isArray(r))return r;const[s,i]=r;return s in l?l[s](i):void 0};customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(a=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement?.closest(\"astro-island[ssr]\"))return;const r=this.querySelectorAll(\"astro-slot\"),s={},i=this.querySelectorAll(\"template[data-astro-template]\");for(const e of i)!e.closest(this.tagName)?.isSameNode(this)||(s[e.getAttribute(\"data-astro-template\")||\"default\"]=e.innerHTML,e.remove());for(const e of r)!e.closest(this.tagName)?.isSameNode(this)||(s[e.getAttribute(\"name\")||\"default\"]=e.innerHTML);const o=this.hasAttribute(\"props\")?JSON.parse(this.getAttribute(\"props\"),n):{};this.hydrator(this)(this.Component,o,s,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),window.removeEventListener(\"astro:hydrate\",this.hydrate),window.dispatchEvent(new CustomEvent(\"astro:hydrate\"))}}connectedCallback(){!this.hasAttribute(\"await-children\")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((r,s)=>{s.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener(\"astro:hydrate\",this.hydrate),await import(this.getAttribute(\"before-hydration-url\"));const r=JSON.parse(this.getAttribute(\"opts\"));Astro[this.getAttribute(\"client\")](async()=>{const s=this.getAttribute(\"renderer-url\"),[i,{default:o}]=await Promise.all([import(this.getAttribute(\"component-url\")),s?import(s):()=>()=>{}]),e=this.getAttribute(\"component-export\")||\"default\";if(!e.includes(\".\"))this.Component=i[e];else{this.Component=i;for(const c of e.split(\".\"))this.Component=this.Component[c]}return this.hydrator=o,this.hydrate},r,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},a.observedAttributes=[\"props\"],a))}";
7
7
  export default _default;
@@ -9,6 +9,7 @@ export declare class AstroComponent {
9
9
  [Symbol.asyncIterator](): AsyncGenerator<any, void, undefined>;
10
10
  }
11
11
  export declare function isAstroComponent(obj: any): obj is AstroComponent;
12
+ export declare function isAstroComponentFactory(obj: any): obj is AstroComponentFactory;
12
13
  export declare function renderAstroComponent(component: InstanceType<typeof AstroComponent>): AsyncIterable<string | RenderInstruction>;
13
14
  export declare function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<string>;
14
15
  export declare function renderToIterable(result: SSRResult, componentFactory: AstroComponentFactory, displayName: string, props: any, children: any): Promise<AsyncIterable<string | RenderInstruction>>;
@@ -1,3 +1,9 @@
1
1
  import type { SSRResult } from '../../../@types/astro';
2
2
  import type { AstroComponentFactory } from './index';
3
- export declare function renderPage(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any, streaming: boolean): Promise<Response>;
3
+ declare const needsHeadRenderingSymbol: unique symbol;
4
+ declare type NonAstroPageComponent = {
5
+ name: string;
6
+ [needsHeadRenderingSymbol]: boolean;
7
+ };
8
+ export declare function renderPage(result: SSRResult, componentFactory: AstroComponentFactory | NonAstroPageComponent, props: any, children: any, streaming: boolean): Promise<Response>;
9
+ export {};
@@ -176,12 +176,6 @@ async function handleRequest(routeCache, viteServer, logging, manifest, config,
176
176
  });
177
177
  async function matchRoute() {
178
178
  const matches = matchAllRoutes(pathname, manifest);
179
- if (config.output === "server" && matches.length > 1) {
180
- throw new Error(`Found multiple matching routes for "${pathname}"! When using \`output: 'server'\`, only one route in \`src/pages\` can match a given URL. Found:
181
-
182
- ${matches.map(({ component }) => `- ${component}`).join("\n")}
183
- `);
184
- }
185
179
  for await (const maybeRoute of matches) {
186
180
  const filePath2 = new URL(`./${maybeRoute.component}`, config.root);
187
181
  const preloadedComponent = await preload({ astroConfig: config, filePath: filePath2, viteServer });
@@ -35,7 +35,10 @@ async function transformJSX({
35
35
  }) {
36
36
  const { jsxTransformOptions } = renderer;
37
37
  const options = await jsxTransformOptions({ mode, ssr });
38
- const plugins = [...options.plugins || [], tagExportsPlugin({ rendererName: renderer.name })];
38
+ const plugins = [...options.plugins || []];
39
+ if (ssr) {
40
+ plugins.push(tagExportsPlugin({ rendererName: renderer.name }));
41
+ }
39
42
  const result = await babel.transformAsync(code, {
40
43
  presets: options.presets,
41
44
  plugins,
@@ -31,9 +31,7 @@ function markdown({ config, logging }) {
31
31
  const { frontmatter: injectedFrontmatter } = safelyGetAstroData(renderResult.vfile.data);
32
32
  const frontmatter = {
33
33
  ...injectedFrontmatter,
34
- ...raw.data,
35
- url: fileUrl,
36
- file: fileId
34
+ ...raw.data
37
35
  };
38
36
  const { layout } = frontmatter;
39
37
  if (frontmatter.setup) {
@@ -67,6 +65,8 @@ function markdown({ config, logging }) {
67
65
  };
68
66
  export async function Content() {
69
67
  const { layout, ...content } = frontmatter;
68
+ content.file = file;
69
+ content.url = url;
70
70
  content.astro = {};
71
71
  Object.defineProperty(content.astro, 'headings', {
72
72
  get() {
@@ -94,6 +94,7 @@ function markdown({ config, logging }) {
94
94
  children: contentFragment
95
95
  })` : `contentFragment`};
96
96
  }
97
+ Content[Symbol.for('astro.needsHeadRendering')] = ${layout ? "false" : "true"};
97
98
  export default Content;
98
99
  `);
99
100
  return {
package/env.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./client.d.ts" />
2
2
 
3
- type Astro = import('astro').AstroGlobal;
3
+ type Astro = import('./dist/types/@types/astro').AstroGlobal;
4
4
 
5
5
  // We duplicate the description here because editors won't show the JSDoc comment from the imported type (but will for its properties, ex: Astro.request will show the AstroGlobal.request description)
6
6
  /**
@@ -13,7 +13,7 @@ declare const Astro: Readonly<Astro>;
13
13
  declare const Fragment: any;
14
14
 
15
15
  declare module '*.md' {
16
- type MD = import('astro').MarkdownInstance<Record<string, any>>;
16
+ type MD = import('./dist/types/@types/astro').MarkdownInstance<Record<string, any>>;
17
17
 
18
18
  export const frontmatter: MD['frontmatter'];
19
19
  export const file: MD['file'];
@@ -29,6 +29,21 @@ declare module '*.md' {
29
29
  export default load;
30
30
  }
31
31
 
32
+ declare module '*.mdx' {
33
+ type MDX = import('astro').MDXInstance<Record<string, any>>;
34
+
35
+ export const frontmatter: MDX['frontmatter'];
36
+ export const file: MDX['file'];
37
+ export const url: MDX['url'];
38
+ export const getHeadings: MDX['getHeadings'];
39
+ export const Content: MDX['Content'];
40
+ export const rawContent: MDX['rawContent'];
41
+ export const compiledContent: MDX['compiledContent'];
42
+
43
+ const load: MDX['default'];
44
+ export default load;
45
+ }
46
+
32
47
  declare module '*.html' {
33
48
  const Component: { render(opts: { slots: Record<string, string> }): string };
34
49
  export default Component;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
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",
@@ -74,7 +74,7 @@
74
74
  "vendor"
75
75
  ],
76
76
  "dependencies": {
77
- "@astrojs/compiler": "^0.23.1",
77
+ "@astrojs/compiler": "^0.23.3",
78
78
  "@astrojs/language-server": "^0.20.0",
79
79
  "@astrojs/markdown-remark": "^1.0.0",
80
80
  "@astrojs/telemetry": "^1.0.0",