astro 1.0.0-beta.63 → 1.0.0-beta.64
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/app/index.js +3 -1
- package/dist/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/util.js +1 -1
- package/dist/runtime/server/astro-island.js +11 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/index.js +15 -12
- package/dist/types/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/types/runtime/server/index.d.ts +1 -1
- package/dist/vite-plugin-astro-server/index.js +7 -1
- package/package.json +2 -2
package/dist/core/app/index.js
CHANGED
|
@@ -153,7 +153,9 @@ callEndpoint_fn = async function(request, routeData, mod) {
|
|
|
153
153
|
const headers = new Headers();
|
|
154
154
|
const mimeType = mime.getType(url.pathname);
|
|
155
155
|
if (mimeType) {
|
|
156
|
-
headers.set("Content-Type", mimeType);
|
|
156
|
+
headers.set("Content-Type", `${mimeType};charset=utf-8`);
|
|
157
|
+
} else {
|
|
158
|
+
headers.set("Content-Type", "text/plain;charset=utf-8");
|
|
157
159
|
}
|
|
158
160
|
const bytes = __privateGet(this, _encoder).encode(body);
|
|
159
161
|
headers.set("Content-Length", bytes.byteLength.toString());
|
package/dist/core/dev/index.js
CHANGED
|
@@ -47,7 +47,7 @@ async function dev(config, options) {
|
|
|
47
47
|
site,
|
|
48
48
|
https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
|
|
49
49
|
}));
|
|
50
|
-
const currentVersion = "1.0.0-beta.
|
|
50
|
+
const currentVersion = "1.0.0-beta.64";
|
|
51
51
|
if (currentVersion.includes("-")) {
|
|
52
52
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
53
53
|
}
|
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.0-beta.
|
|
50
|
+
const version = "1.0.0-beta.64";
|
|
51
51
|
const rootPath = site ? site.pathname : "/";
|
|
52
52
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
53
53
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
@@ -206,7 +206,7 @@ function printHelp({
|
|
|
206
206
|
};
|
|
207
207
|
let message = [];
|
|
208
208
|
if (headline) {
|
|
209
|
-
message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.
|
|
209
|
+
message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.64"}`)} ${headline}`);
|
|
210
210
|
}
|
|
211
211
|
if (usage) {
|
|
212
212
|
message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
|
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 { removeTrailingForwardSlash } from "./path.js";
|
|
8
|
-
const ASTRO_VERSION = "1.0.0-beta.
|
|
8
|
+
const ASTRO_VERSION = "1.0.0-beta.64";
|
|
9
9
|
function isObject(value) {
|
|
10
10
|
return typeof value === "object" && value != null;
|
|
11
11
|
}
|
|
@@ -48,7 +48,17 @@ var _a;
|
|
|
48
48
|
window.dispatchEvent(new CustomEvent("astro:hydrate"));
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
if (this.getAttribute("client") === "only" || this.firstChild) {
|
|
53
|
+
this.childrenConnectedCallback();
|
|
54
|
+
} else {
|
|
55
|
+
new MutationObserver((_, mo) => {
|
|
56
|
+
mo.disconnect();
|
|
57
|
+
this.childrenConnectedCallback();
|
|
58
|
+
}).observe(this, { childList: true });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async childrenConnectedCallback() {
|
|
52
62
|
window.addEventListener("astro:hydrate", this.hydrate);
|
|
53
63
|
await import(this.getAttribute("before-hydration-url"));
|
|
54
64
|
const opts = JSON.parse(this.getAttribute("opts"));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var astro_island_prebuilt_default = `var a;{const l={0:t=>t,1:t=>JSON.parse(t,
|
|
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.getAttribute("client")==="only"||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))}`;
|
|
2
2
|
export {
|
|
3
3
|
astro_island_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -448,25 +448,28 @@ async function renderToIterable(result, componentFactory, props, children) {
|
|
|
448
448
|
}
|
|
449
449
|
const encoder = new TextEncoder();
|
|
450
450
|
async function renderPage(result, componentFactory, props, children, streaming) {
|
|
451
|
-
let iterable;
|
|
452
451
|
if (!componentFactory.isAstroComponentFactory) {
|
|
453
452
|
const pageProps = { ...props ?? {}, "server:root": true };
|
|
454
453
|
const output = await renderComponent(result, componentFactory.name, componentFactory, pageProps, null);
|
|
455
454
|
let html = output.toString();
|
|
456
455
|
if (!/<!doctype html/i.test(html)) {
|
|
457
|
-
|
|
458
|
-
|
|
456
|
+
let rest = html;
|
|
457
|
+
html = `<!DOCTYPE html>`;
|
|
458
|
+
for await (let chunk of maybeRenderHead(result)) {
|
|
459
|
+
html += chunk;
|
|
460
|
+
}
|
|
461
|
+
html += rest;
|
|
459
462
|
}
|
|
460
463
|
return new Response(html, {
|
|
461
464
|
headers: new Headers([
|
|
462
465
|
["Content-Type", "text/html; charset=utf-8"],
|
|
463
|
-
["Content-Length",
|
|
466
|
+
["Content-Length", Buffer.byteLength(html, "utf-8").toString()]
|
|
464
467
|
])
|
|
465
468
|
});
|
|
466
469
|
}
|
|
467
470
|
const factoryReturnValue = await componentFactory(result, props, children);
|
|
468
471
|
if (isAstroComponent(factoryReturnValue)) {
|
|
469
|
-
let
|
|
472
|
+
let iterable = renderAstroComponent(factoryReturnValue);
|
|
470
473
|
let init = result.response;
|
|
471
474
|
let headers = new Headers(init.headers);
|
|
472
475
|
let body;
|
|
@@ -475,7 +478,7 @@ ${await maybeRenderHead(result)}${html}`;
|
|
|
475
478
|
start(controller) {
|
|
476
479
|
async function read() {
|
|
477
480
|
let i = 0;
|
|
478
|
-
for await (const chunk of
|
|
481
|
+
for await (const chunk of iterable) {
|
|
479
482
|
let html = chunk.toString();
|
|
480
483
|
if (i === 0) {
|
|
481
484
|
if (!/<!doctype html/i.test(html)) {
|
|
@@ -493,7 +496,7 @@ ${await maybeRenderHead(result)}${html}`;
|
|
|
493
496
|
} else {
|
|
494
497
|
body = "";
|
|
495
498
|
let i = 0;
|
|
496
|
-
for await (const chunk of
|
|
499
|
+
for await (const chunk of iterable) {
|
|
497
500
|
let html = chunk.toString();
|
|
498
501
|
if (i === 0) {
|
|
499
502
|
if (!/<!doctype html/i.test(html)) {
|
|
@@ -504,7 +507,7 @@ ${await maybeRenderHead(result)}${html}`;
|
|
|
504
507
|
i++;
|
|
505
508
|
}
|
|
506
509
|
const bytes = encoder.encode(body);
|
|
507
|
-
headers.set("Content-Length",
|
|
510
|
+
headers.set("Content-Length", bytes.byteLength.toString());
|
|
508
511
|
}
|
|
509
512
|
let response = createResponse(body, { ...init, headers });
|
|
510
513
|
return response;
|
|
@@ -518,7 +521,7 @@ const uniqueElements = (item, index, all) => {
|
|
|
518
521
|
return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
|
|
519
522
|
};
|
|
520
523
|
const alreadyHeadRenderedResults = /* @__PURE__ */ new WeakSet();
|
|
521
|
-
|
|
524
|
+
function renderHead(result) {
|
|
522
525
|
alreadyHeadRenderedResults.add(result);
|
|
523
526
|
const styles = Array.from(result.styles).filter(uniqueElements).map((style) => renderElement("style", style));
|
|
524
527
|
result.styles.clear();
|
|
@@ -528,11 +531,11 @@ async function renderHead(result) {
|
|
|
528
531
|
const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement("link", link, false));
|
|
529
532
|
return markHTMLString(links.join("\n") + styles.join("\n") + scripts.join("\n"));
|
|
530
533
|
}
|
|
531
|
-
function maybeRenderHead(result) {
|
|
534
|
+
async function* maybeRenderHead(result) {
|
|
532
535
|
if (alreadyHeadRenderedResults.has(result)) {
|
|
533
|
-
return
|
|
536
|
+
return;
|
|
534
537
|
}
|
|
535
|
-
|
|
538
|
+
yield renderHead(result);
|
|
536
539
|
}
|
|
537
540
|
async function* renderAstroComponent(component) {
|
|
538
541
|
for await (const value of component) {
|
|
@@ -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,
|
|
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.getAttribute(\"client\")===\"only\"||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))}";
|
|
7
7
|
export default _default;
|
|
@@ -32,6 +32,6 @@ export declare function renderToString(result: SSRResult, componentFactory: Astr
|
|
|
32
32
|
export declare function renderToIterable(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<AsyncIterable<string>>;
|
|
33
33
|
export declare function renderPage(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any, streaming: boolean): Promise<Response>;
|
|
34
34
|
export declare function renderHead(result: SSRResult): Promise<string>;
|
|
35
|
-
export declare function maybeRenderHead(result: SSRResult):
|
|
35
|
+
export declare function maybeRenderHead(result: SSRResult): AsyncIterable<string>;
|
|
36
36
|
export declare function renderAstroComponent(component: InstanceType<typeof AstroComponent>): AsyncIterable<string>;
|
|
37
37
|
export declare function renderHTMLElement(result: SSRResult, constructor: typeof HTMLElement, props: any, slots: any): Promise<any>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import mime from "mime";
|
|
1
2
|
import { Readable } from "stream";
|
|
2
3
|
import stripAnsi from "strip-ansi";
|
|
3
4
|
import { call as callEndpoint } from "../core/endpoint/dev/index.js";
|
|
@@ -234,7 +235,12 @@ async function handleRequest(routeCache, viteServer, logging, manifest, config,
|
|
|
234
235
|
if (result.type === "response") {
|
|
235
236
|
await writeWebResponse(res, result.response);
|
|
236
237
|
} else {
|
|
237
|
-
|
|
238
|
+
let contentType = "text/plain";
|
|
239
|
+
const computedMimeType = route.pathname ? mime.getType(route.pathname) : null;
|
|
240
|
+
if (computedMimeType) {
|
|
241
|
+
contentType = computedMimeType;
|
|
242
|
+
}
|
|
243
|
+
res.writeHead(200, { "Content-Type": `${contentType};charset=utf-8` });
|
|
238
244
|
res.end(result.body);
|
|
239
245
|
}
|
|
240
246
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.64",
|
|
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",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@astrojs/language-server": "^0.13.4",
|
|
73
73
|
"@astrojs/markdown-remark": "^0.11.3",
|
|
74
74
|
"@astrojs/prism": "0.4.1",
|
|
75
|
-
"@astrojs/telemetry": "^0.2.
|
|
75
|
+
"@astrojs/telemetry": "^0.2.4",
|
|
76
76
|
"@astrojs/webapi": "^0.12.0",
|
|
77
77
|
"@babel/core": "^7.18.2",
|
|
78
78
|
"@babel/generator": "^7.18.2",
|