astro 1.0.3 → 1.0.4
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/core/add/index.js +18 -0
- package/dist/core/build/generate.js +1 -1
- package/dist/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render/result.js +2 -1
- package/dist/core/routing/manifest/generator.js +4 -1
- package/dist/core/util.js +1 -1
- package/dist/jsx/babel.js +69 -1
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/astro-island.js +9 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/hydration.js +2 -2
- package/dist/runtime/server/render/any.js +1 -2
- package/dist/runtime/server/render/page.js +13 -2
- package/dist/types/@types/astro.d.ts +34 -1
- package/dist/types/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/types/runtime/server/hydration.d.ts +2 -10
- package/dist/types/runtime/server/index.d.ts +1 -1
- package/dist/types/runtime/server/render/any.d.ts +2 -1
- package/dist/types/runtime/server/render/astro.d.ts +3 -4
- package/dist/types/runtime/server/render/common.d.ts +2 -3
- package/dist/types/runtime/server/render/component.d.ts +2 -3
- package/dist/types/runtime/server/render/index.d.ts +0 -1
- package/dist/vite-plugin-jsx/index.js +4 -1
- package/dist/vite-plugin-markdown/index.js +3 -3
- package/env.d.ts +17 -2
- package/package.json +2 -2
- package/dist/runtime/server/render/types.js +0 -0
- package/dist/types/runtime/server/render/types.d.ts +0 -7
package/dist/core/add/index.js
CHANGED
|
@@ -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(
|
|
160
|
+
opts.pageNames.push(pathname.replace(/^\//, ""));
|
|
161
161
|
}
|
|
162
162
|
async function generatePath(pathname, opts, gopts) {
|
|
163
163
|
var _a;
|
package/dist/core/dev/index.js
CHANGED
|
@@ -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.
|
|
49
|
+
const currentVersion = "1.0.4";
|
|
50
50
|
if (currentVersion.includes("-")) {
|
|
51
51
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
52
52
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function devStart({
|
|
|
47
47
|
https,
|
|
48
48
|
site
|
|
49
49
|
}) {
|
|
50
|
-
const version = "1.0.
|
|
50
|
+
const version = "1.0.4";
|
|
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.
|
|
229
|
+
`v${"1.0.4"}`
|
|
230
230
|
)} ${headline}`
|
|
231
231
|
);
|
|
232
232
|
}
|
|
@@ -223,7 +223,8 @@ const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
|
|
223
223
|
renderers,
|
|
224
224
|
pathname,
|
|
225
225
|
hasHydrationScript: false,
|
|
226
|
-
hasDirectives: /* @__PURE__ */ new Set()
|
|
226
|
+
hasDirectives: /* @__PURE__ */ new Set(),
|
|
227
|
+
pendingInstructions: /* @__PURE__ */ new Set()
|
|
227
228
|
},
|
|
228
229
|
response
|
|
229
230
|
};
|
|
@@ -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
|
-
|
|
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.
|
|
8
|
+
const ASTRO_VERSION = "1.0.4";
|
|
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(".").
|
|
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)
|
|
@@ -72,7 +72,15 @@ var _a;
|
|
|
72
72
|
rendererUrl ? import(rendererUrl) : () => () => {
|
|
73
73
|
}
|
|
74
74
|
]);
|
|
75
|
-
|
|
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[
|
|
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
|
|
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 = {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { escapeHTML, HTMLString, markHTMLString } from "../escape.js";
|
|
2
2
|
import { AstroComponent, renderAstroComponent } from "./astro.js";
|
|
3
|
-
import { stringifyChunk } from "./common.js";
|
|
4
3
|
async function* renderChild(child) {
|
|
5
4
|
child = await child;
|
|
6
5
|
if (child instanceof HTMLString) {
|
|
@@ -28,7 +27,7 @@ async function renderSlot(result, slotted, fallback) {
|
|
|
28
27
|
let content = "";
|
|
29
28
|
for await (const chunk of iterator) {
|
|
30
29
|
if (chunk.type === "directive") {
|
|
31
|
-
|
|
30
|
+
result._metadata.pendingInstructions.add(chunk);
|
|
32
31
|
} else {
|
|
33
32
|
content += chunk;
|
|
34
33
|
}
|
|
@@ -36,13 +36,24 @@ async function renderPage(result, componentFactory, props, children, streaming)
|
|
|
36
36
|
let init = result.response;
|
|
37
37
|
let headers = new Headers(init.headers);
|
|
38
38
|
let body;
|
|
39
|
+
async function* eachChunk() {
|
|
40
|
+
for await (const chunk of iterable) {
|
|
41
|
+
if (result._metadata.pendingInstructions.size) {
|
|
42
|
+
for (const instr of result._metadata.pendingInstructions) {
|
|
43
|
+
result._metadata.pendingInstructions.delete(instr);
|
|
44
|
+
yield instr;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
yield chunk;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
39
50
|
if (streaming) {
|
|
40
51
|
body = new ReadableStream({
|
|
41
52
|
start(controller) {
|
|
42
53
|
async function read() {
|
|
43
54
|
let i = 0;
|
|
44
55
|
try {
|
|
45
|
-
for await (const chunk of
|
|
56
|
+
for await (const chunk of eachChunk()) {
|
|
46
57
|
let html = stringifyChunk(result, chunk);
|
|
47
58
|
if (i === 0) {
|
|
48
59
|
if (!/<!doctype html/i.test(html)) {
|
|
@@ -63,7 +74,7 @@ async function renderPage(result, componentFactory, props, children, streaming)
|
|
|
63
74
|
} else {
|
|
64
75
|
body = "";
|
|
65
76
|
let i = 0;
|
|
66
|
-
for await (const chunk of
|
|
77
|
+
for await (const chunk of eachChunk()) {
|
|
67
78
|
let html = stringifyChunk(result, chunk);
|
|
68
79
|
if (i === 0) {
|
|
69
80
|
if (!/<!doctype html/i.test(html)) {
|
|
@@ -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<
|
|
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,25 @@ 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 interface MDXLayoutProps<T> extends Omit<MarkdownLayoutProps<T>, 'rawContent' | 'compiledContent'> {
|
|
803
|
+
}
|
|
785
804
|
export declare type GetHydrateCallback = () => Promise<() => void | Promise<void>>;
|
|
786
805
|
/**
|
|
787
806
|
* getStaticPaths() options
|
|
@@ -997,11 +1016,25 @@ export interface SSRElement {
|
|
|
997
1016
|
props: Record<string, any>;
|
|
998
1017
|
children: string;
|
|
999
1018
|
}
|
|
1019
|
+
export interface HydrationMetadata {
|
|
1020
|
+
directive: string;
|
|
1021
|
+
value: string;
|
|
1022
|
+
componentUrl: string;
|
|
1023
|
+
componentExport: {
|
|
1024
|
+
value: string;
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
export interface SSRRenderInstruction {
|
|
1028
|
+
type: 'directive';
|
|
1029
|
+
result: SSRResult;
|
|
1030
|
+
hydration: HydrationMetadata;
|
|
1031
|
+
}
|
|
1000
1032
|
export interface SSRMetadata {
|
|
1001
1033
|
renderers: SSRLoadedRenderer[];
|
|
1002
1034
|
pathname: string;
|
|
1003
1035
|
hasHydrationScript: boolean;
|
|
1004
1036
|
hasDirectives: Set<string>;
|
|
1037
|
+
pendingInstructions: Set<SSRRenderInstruction>;
|
|
1005
1038
|
}
|
|
1006
1039
|
export interface SSRResult {
|
|
1007
1040
|
styles: Set<SSRElement>;
|
|
@@ -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[
|
|
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;
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import type { AstroComponentMetadata, SSRElement, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
|
|
1
|
+
import type { AstroComponentMetadata, HydrationMetadata, SSRElement, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
|
|
2
2
|
export declare const HydrationDirectiveProps: Set<string>;
|
|
3
|
-
export
|
|
4
|
-
directive: string;
|
|
5
|
-
value: string;
|
|
6
|
-
componentUrl: string;
|
|
7
|
-
componentExport: {
|
|
8
|
-
value: string;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
3
|
+
export { HydrationMetadata };
|
|
11
4
|
interface ExtractedProps {
|
|
12
5
|
isPage: boolean;
|
|
13
6
|
hydration: HydrationMetadata | null;
|
|
@@ -23,4 +16,3 @@ interface HydrateScriptOptions {
|
|
|
23
16
|
}
|
|
24
17
|
/** For hydrated components, generate a <script type="module"> to load the component */
|
|
25
18
|
export declare function generateHydrateScript(scriptOptions: HydrateScriptOptions, metadata: Required<AstroComponentMetadata>): Promise<SSRElement>;
|
|
26
|
-
export {};
|
|
@@ -4,7 +4,7 @@ export { escapeHTML, HTMLString, markHTMLString, markHTMLString as unescapeHTML,
|
|
|
4
4
|
export type { Metadata } from './metadata';
|
|
5
5
|
export { createMetadata } from './metadata.js';
|
|
6
6
|
export { addAttribute, defineScriptVars, Fragment, maybeRenderHead, renderAstroComponent, renderComponent, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderSlot, renderTemplate as render, renderTemplate, renderToString, stringifyChunk, voidElementNames, } from './render/index.js';
|
|
7
|
-
export type { AstroComponentFactory
|
|
7
|
+
export type { AstroComponentFactory } from './render/index.js';
|
|
8
8
|
import type { AstroComponentFactory } from './render/index.js';
|
|
9
9
|
export declare function createComponent(cb: AstroComponentFactory): AstroComponentFactory;
|
|
10
10
|
export declare function mergeSlots(...slotted: unknown[]): Record<string, () => any>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { SSRResult } from '../../../@types/astro';
|
|
1
2
|
export declare function renderChild(child: any): AsyncIterable<any>;
|
|
2
|
-
export declare function renderSlot(result:
|
|
3
|
+
export declare function renderSlot(result: SSRResult, slotted: string, fallback?: any): Promise<string>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { SSRResult } from '../../../@types/astro';
|
|
1
|
+
import type { SSRRenderInstruction, SSRResult } from '../../../@types/astro';
|
|
2
2
|
import type { AstroComponentFactory } from './index';
|
|
3
|
-
import type { RenderInstruction } from './types';
|
|
4
3
|
export declare class AstroComponent {
|
|
5
4
|
private htmlParts;
|
|
6
5
|
private expressions;
|
|
@@ -9,7 +8,7 @@ export declare class AstroComponent {
|
|
|
9
8
|
[Symbol.asyncIterator](): AsyncGenerator<any, void, undefined>;
|
|
10
9
|
}
|
|
11
10
|
export declare function isAstroComponent(obj: any): obj is AstroComponent;
|
|
12
|
-
export declare function renderAstroComponent(component: InstanceType<typeof AstroComponent>): AsyncIterable<string |
|
|
11
|
+
export declare function renderAstroComponent(component: InstanceType<typeof AstroComponent>): AsyncIterable<string | SSRRenderInstruction>;
|
|
13
12
|
export declare function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<string>;
|
|
14
|
-
export declare function renderToIterable(result: SSRResult, componentFactory: AstroComponentFactory, displayName: string, props: any, children: any): Promise<AsyncIterable<string |
|
|
13
|
+
export declare function renderToIterable(result: SSRResult, componentFactory: AstroComponentFactory, displayName: string, props: any, children: any): Promise<AsyncIterable<string | SSRRenderInstruction>>;
|
|
15
14
|
export declare function renderTemplate(htmlParts: TemplateStringsArray, ...expressions: any[]): Promise<AstroComponent>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { SSRResult } from '../../../@types/astro';
|
|
2
|
-
import type { RenderInstruction } from './types.js';
|
|
1
|
+
import type { SSRRenderInstruction, SSRResult } from '../../../@types/astro';
|
|
3
2
|
export declare const Fragment: unique symbol;
|
|
4
3
|
export declare const Renderer: unique symbol;
|
|
5
|
-
export declare function stringifyChunk(result: SSRResult, chunk: string |
|
|
4
|
+
export declare function stringifyChunk(result: SSRResult, chunk: string | SSRRenderInstruction): any;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { SSRResult } from '../../../@types/astro';
|
|
2
|
-
|
|
3
|
-
export declare function renderComponent(result: SSRResult, displayName: string, Component: unknown, _props: Record<string | number, any>, slots?: any): Promise<string | AsyncIterable<string | RenderInstruction>>;
|
|
1
|
+
import type { SSRRenderInstruction, SSRResult } from '../../../@types/astro';
|
|
2
|
+
export declare function renderComponent(result: SSRResult, displayName: string, Component: unknown, _props: Record<string | number, any>, slots?: any): Promise<string | AsyncIterable<string | SSRRenderInstruction>>;
|
|
@@ -6,7 +6,6 @@ export { renderComponent } from './component.js';
|
|
|
6
6
|
export { renderHTMLElement } from './dom.js';
|
|
7
7
|
export { maybeRenderHead, renderHead } from './head.js';
|
|
8
8
|
export { renderPage } from './page.js';
|
|
9
|
-
export type { RenderInstruction } from './types';
|
|
10
9
|
export { addAttribute, defineScriptVars, voidElementNames } from './util.js';
|
|
11
10
|
export interface AstroComponentFactory {
|
|
12
11
|
(result: any, props: any, slots: any): ReturnType<typeof renderTemplate> | Response;
|
|
@@ -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 || []
|
|
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() {
|
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
|
+
"version": "1.0.4",
|
|
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.
|
|
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",
|
|
File without changes
|