astro 2.10.2 → 2.10.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/@types/astro.d.ts +6 -3
- package/dist/core/app/index.js +1 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/index.d.ts +2 -5
- package/dist/core/endpoint/index.js +1 -2
- package/dist/core/messages.js +2 -2
- package/dist/jsx/renderer.js +3 -4
- package/dist/runtime/server/astro-island.js +15 -11
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/serialize.js +7 -12
- package/dist/vite-plugin-astro-server/route.js +8 -5
- package/dist/vite-plugin-integrations-container/index.js +4 -0
- package/package.json +1 -1
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1653,10 +1653,13 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
1653
1653
|
*/
|
|
1654
1654
|
locals: App.Locals;
|
|
1655
1655
|
}
|
|
1656
|
-
export
|
|
1656
|
+
export type EndpointOutput = {
|
|
1657
1657
|
body: Body;
|
|
1658
|
-
encoding?: BufferEncoding
|
|
1659
|
-
}
|
|
1658
|
+
encoding?: Exclude<BufferEncoding, 'binary'>;
|
|
1659
|
+
} | {
|
|
1660
|
+
body: Uint8Array;
|
|
1661
|
+
encoding: 'binary';
|
|
1662
|
+
};
|
|
1660
1663
|
export type APIRoute<Props extends Record<string, any> = Record<string, any>> = (context: APIContext<Props>) => EndpointOutput | Response | Promise<EndpointOutput | Response>;
|
|
1661
1664
|
export interface EndpointHandler {
|
|
1662
1665
|
[method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response);
|
package/dist/core/app/index.js
CHANGED
|
@@ -162,7 +162,6 @@ class App {
|
|
|
162
162
|
}
|
|
163
163
|
return response.response;
|
|
164
164
|
} else {
|
|
165
|
-
const body = response.body;
|
|
166
165
|
const headers = new Headers();
|
|
167
166
|
const mimeType = mime.getType(url.pathname);
|
|
168
167
|
if (mimeType) {
|
|
@@ -170,7 +169,7 @@ class App {
|
|
|
170
169
|
} else {
|
|
171
170
|
headers.set("Content-Type", "text/plain;charset=utf-8");
|
|
172
171
|
}
|
|
173
|
-
const bytes = this.#encoder.encode(body);
|
|
172
|
+
const bytes = response.encoding !== "binary" ? this.#encoder.encode(response.body) : response.body;
|
|
174
173
|
headers.set("Content-Length", bytes.byteLength.toString());
|
|
175
174
|
const newResponse = new Response(bytes, {
|
|
176
175
|
status: 200,
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -97,7 +97,7 @@ async function createVite(commandConfig, { settings, logging, mode, command, fs
|
|
|
97
97
|
htmlVitePlugin(),
|
|
98
98
|
jsxVitePlugin({ settings, logging }),
|
|
99
99
|
astroPostprocessVitePlugin(),
|
|
100
|
-
|
|
100
|
+
astroIntegrationsContainerPlugin({ settings, logging }),
|
|
101
101
|
astroScriptsPageSSRPlugin({ settings }),
|
|
102
102
|
astroHeadPlugin(),
|
|
103
103
|
astroScannerPlugin({ settings, logging }),
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
|
|
|
23
23
|
base: restart.container.settings.config.base
|
|
24
24
|
})
|
|
25
25
|
);
|
|
26
|
-
const currentVersion = "2.10.
|
|
26
|
+
const currentVersion = "2.10.4";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
warn(logging, null, msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { APIContext, EndpointHandler, EndpointOutput, MiddlewareHandler, Params } from '../../@types/astro';
|
|
3
2
|
import type { Environment, RenderContext } from '../render/index';
|
|
4
3
|
import { AstroCookies } from '../cookies/index.js';
|
|
5
|
-
export type EndpointCallResult = {
|
|
4
|
+
export type EndpointCallResult = (EndpointOutput & {
|
|
6
5
|
type: 'simple';
|
|
7
|
-
body: string;
|
|
8
|
-
encoding?: BufferEncoding;
|
|
9
6
|
cookies: AstroCookies;
|
|
10
|
-
} | {
|
|
7
|
+
}) | {
|
|
11
8
|
type: 'response';
|
|
12
9
|
response: Response;
|
|
13
10
|
};
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.10.
|
|
50
|
+
const version = "2.10.4";
|
|
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.10.
|
|
236
|
+
`v${"2.10.4"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
package/dist/jsx/renderer.js
CHANGED
|
@@ -3,10 +3,9 @@ const renderer = {
|
|
|
3
3
|
serverEntrypoint: "astro/jsx/server.js",
|
|
4
4
|
jsxImportSource: "astro",
|
|
5
5
|
jsxTransformOptions: async () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = await import("@babel/plugin-transform-react-jsx");
|
|
6
|
+
var _a;
|
|
7
|
+
const plugin = await import("@babel/plugin-transform-react-jsx");
|
|
8
|
+
const jsx = ((_a = plugin.default) == null ? void 0 : _a.default) ?? plugin.default;
|
|
10
9
|
const { default: astroJSX } = await import("./babel.js");
|
|
11
10
|
return {
|
|
12
11
|
plugins: [
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
{
|
|
3
3
|
const propTypes = {
|
|
4
|
-
0: (value) => value,
|
|
5
|
-
1: (value) =>
|
|
4
|
+
0: (value) => reviveObject(value),
|
|
5
|
+
1: (value) => reviveArray(value),
|
|
6
6
|
2: (value) => new RegExp(value),
|
|
7
7
|
3: (value) => new Date(value),
|
|
8
|
-
4: (value) => new Map(
|
|
9
|
-
5: (value) => new Set(
|
|
8
|
+
4: (value) => new Map(reviveArray(value)),
|
|
9
|
+
5: (value) => new Set(reviveArray(value)),
|
|
10
10
|
6: (value) => BigInt(value),
|
|
11
11
|
7: (value) => new URL(value),
|
|
12
|
-
8: (value) => new Uint8Array(
|
|
13
|
-
9: (value) => new Uint16Array(
|
|
14
|
-
10: (value) => new Uint32Array(
|
|
12
|
+
8: (value) => new Uint8Array(value),
|
|
13
|
+
9: (value) => new Uint16Array(value),
|
|
14
|
+
10: (value) => new Uint32Array(value)
|
|
15
15
|
};
|
|
16
|
-
const
|
|
17
|
-
if (propKey === "" || !Array.isArray(raw))
|
|
18
|
-
return raw;
|
|
16
|
+
const reviveTuple = (raw) => {
|
|
19
17
|
const [type, value] = raw;
|
|
20
18
|
return type in propTypes ? propTypes[type](value) : void 0;
|
|
21
19
|
};
|
|
20
|
+
const reviveArray = (raw) => raw.map(reviveTuple);
|
|
21
|
+
const reviveObject = (raw) => {
|
|
22
|
+
if (typeof raw !== "object" || raw === null)
|
|
23
|
+
return raw;
|
|
24
|
+
return Object.fromEntries(Object.entries(raw).map(([key, value]) => [key, reviveTuple(value)]));
|
|
25
|
+
};
|
|
22
26
|
if (!customElements.get("astro-island")) {
|
|
23
27
|
customElements.define(
|
|
24
28
|
"astro-island",
|
|
@@ -54,7 +58,7 @@ var _a;
|
|
|
54
58
|
}
|
|
55
59
|
let props;
|
|
56
60
|
try {
|
|
57
|
-
props = this.hasAttribute("props") ? JSON.parse(this.getAttribute("props")
|
|
61
|
+
props = this.hasAttribute("props") ? reviveObject(JSON.parse(this.getAttribute("props"))) : {};
|
|
58
62
|
} catch (e) {
|
|
59
63
|
let componentName = this.getAttribute("component-url") || "<unknown>";
|
|
60
64
|
const componentExport = this.getAttribute("component-export");
|
|
@@ -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 d;{let p={0:t=>t,1:t=>
|
|
6
|
+
declare const _default: "(()=>{var d;{let p={0:t=>u(t),1:t=>l(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(l(t)),5:t=>new Set(l(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t)},h=t=>{let[e,n]=t;return e in p?p[e](n):void 0},l=t=>t.map(h),u=t=>typeof t!=\"object\"||t===null?t:Object.fromEntries(Object.entries(t).map(([e,n])=>[e,h(n)]));customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var i;if(!this.hydrator||!this.isConnected)return;let e=(i=this.parentElement)==null?void 0:i.closest(\"astro-island[ssr]\");if(e){e.addEventListener(\"astro:hydrate\",this.hydrate,{once:!0});return}let n=this.querySelectorAll(\"astro-slot\"),o={},a=this.querySelectorAll(\"template[data-astro-template]\");for(let r of a){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(let r of n){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}let c;try{c=this.hasAttribute(\"props\")?u(JSON.parse(this.getAttribute(\"props\"))):{}}catch(r){let s=this.getAttribute(\"component-url\")||\"<unknown>\",y=this.getAttribute(\"component-export\");throw y&&(s+=` (export ${y})`),console.error(`[hydrate] Error parsing props for component ${s}`,this.getAttribute(\"props\"),r),r}await this.hydrator(this)(this.Component,c,o,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),this.dispatchEvent(new CustomEvent(\"astro:hydrate\"))}}connectedCallback(){!this.hasAttribute(\"await-children\")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((e,n)=>{n.disconnect(),setTimeout(()=>this.childrenConnectedCallback(),0)}).observe(this,{childList:!0})}async childrenConnectedCallback(){let e=this.getAttribute(\"before-hydration-url\");e&&await import(e),this.start()}start(){let e=JSON.parse(this.getAttribute(\"opts\")),n=this.getAttribute(\"client\");if(Astro[n]===void 0){window.addEventListener(`astro:${n}`,()=>this.start(),{once:!0});return}Astro[n](async()=>{let o=this.getAttribute(\"renderer-url\"),[a,{default:c}]=await Promise.all([import(this.getAttribute(\"component-url\")),o?import(o):()=>()=>{}]),i=this.getAttribute(\"component-export\")||\"default\";if(!i.includes(\".\"))this.Component=a[i];else{this.Component=a;for(let r of i.split(\".\"))this.Component=this.Component[r]}return this.hydrator=c,this.hydrate},e,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=[\"props\"],d))}})();";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var astro_island_prebuilt_default = `(()=>{var d;{let p={0:t=>t,1:t=>
|
|
1
|
+
var astro_island_prebuilt_default = `(()=>{var d;{let p={0:t=>u(t),1:t=>l(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(l(t)),5:t=>new Set(l(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t)},h=t=>{let[e,n]=t;return e in p?p[e](n):void 0},l=t=>t.map(h),u=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([e,n])=>[e,h(n)]));customElements.get("astro-island")||customElements.define("astro-island",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var i;if(!this.hydrator||!this.isConnected)return;let e=(i=this.parentElement)==null?void 0:i.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let n=this.querySelectorAll("astro-slot"),o={},a=this.querySelectorAll("template[data-astro-template]");for(let r of a){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of n){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute("name")||"default"]=r.innerHTML)}let c;try{c=this.hasAttribute("props")?u(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",y=this.getAttribute("component-export");throw y&&(s+=\` (export \${y})\`),console.error(\`[hydrate] Error parsing props for component \${s}\`,this.getAttribute("props"),r),r}await this.hydrator(this)(this.Component,c,o,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((e,n)=>{n.disconnect(),setTimeout(()=>this.childrenConnectedCallback(),0)}).observe(this,{childList:!0})}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}start(){let e=JSON.parse(this.getAttribute("opts")),n=this.getAttribute("client");if(Astro[n]===void 0){window.addEventListener(\`astro:\${n}\`,()=>this.start(),{once:!0});return}Astro[n](async()=>{let o=this.getAttribute("renderer-url"),[a,{default:c}]=await Promise.all([import(this.getAttribute("component-url")),o?import(o):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=a[i];else{this.Component=a;for(let r of i.split("."))this.Component=this.Component[r]}return this.hydrator=c,this.hydrate},e,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=["props"],d))}})();`;
|
|
2
2
|
export {
|
|
3
3
|
astro_island_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const PROP_TYPE = {
|
|
2
2
|
Value: 0,
|
|
3
3
|
JSON: 1,
|
|
4
|
+
// Actually means Array
|
|
4
5
|
RegExp: 2,
|
|
5
6
|
Date: 3,
|
|
6
7
|
Map: 4,
|
|
@@ -49,16 +50,10 @@ function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */
|
|
|
49
50
|
return [PROP_TYPE.RegExp, value.source];
|
|
50
51
|
}
|
|
51
52
|
case "[object Map]": {
|
|
52
|
-
return [
|
|
53
|
-
PROP_TYPE.Map,
|
|
54
|
-
JSON.stringify(serializeArray(Array.from(value), metadata, parents))
|
|
55
|
-
];
|
|
53
|
+
return [PROP_TYPE.Map, serializeArray(Array.from(value), metadata, parents)];
|
|
56
54
|
}
|
|
57
55
|
case "[object Set]": {
|
|
58
|
-
return [
|
|
59
|
-
PROP_TYPE.Set,
|
|
60
|
-
JSON.stringify(serializeArray(Array.from(value), metadata, parents))
|
|
61
|
-
];
|
|
56
|
+
return [PROP_TYPE.Set, serializeArray(Array.from(value), metadata, parents)];
|
|
62
57
|
}
|
|
63
58
|
case "[object BigInt]": {
|
|
64
59
|
return [PROP_TYPE.BigInt, value.toString()];
|
|
@@ -67,16 +62,16 @@ function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */
|
|
|
67
62
|
return [PROP_TYPE.URL, value.toString()];
|
|
68
63
|
}
|
|
69
64
|
case "[object Array]": {
|
|
70
|
-
return [PROP_TYPE.JSON,
|
|
65
|
+
return [PROP_TYPE.JSON, serializeArray(value, metadata, parents)];
|
|
71
66
|
}
|
|
72
67
|
case "[object Uint8Array]": {
|
|
73
|
-
return [PROP_TYPE.Uint8Array,
|
|
68
|
+
return [PROP_TYPE.Uint8Array, Array.from(value)];
|
|
74
69
|
}
|
|
75
70
|
case "[object Uint16Array]": {
|
|
76
|
-
return [PROP_TYPE.Uint16Array,
|
|
71
|
+
return [PROP_TYPE.Uint16Array, Array.from(value)];
|
|
77
72
|
}
|
|
78
73
|
case "[object Uint32Array]": {
|
|
79
|
-
return [PROP_TYPE.Uint32Array,
|
|
74
|
+
return [PROP_TYPE.Uint32Array, Array.from(value)];
|
|
80
75
|
}
|
|
81
76
|
default: {
|
|
82
77
|
if (value !== null && typeof value === "object") {
|
|
@@ -178,12 +178,15 @@ async function handleRoute({
|
|
|
178
178
|
if (computedMimeType) {
|
|
179
179
|
contentType = computedMimeType;
|
|
180
180
|
}
|
|
181
|
-
const response = new Response(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
const response = new Response(
|
|
182
|
+
result.encoding !== "binary" ? Buffer.from(result.body, result.encoding) : result.body,
|
|
183
|
+
{
|
|
184
|
+
status: 200,
|
|
185
|
+
headers: {
|
|
186
|
+
"Content-Type": `${contentType};charset=utf-8`
|
|
187
|
+
}
|
|
185
188
|
}
|
|
186
|
-
|
|
189
|
+
);
|
|
187
190
|
attachToResponse(response, result.cookies);
|
|
188
191
|
await writeWebResponse(incomingResponse, response);
|
|
189
192
|
}
|
|
@@ -7,9 +7,13 @@ function astroIntegrationsContainerPlugin({
|
|
|
7
7
|
return {
|
|
8
8
|
name: "astro:integration-container",
|
|
9
9
|
configureServer(server) {
|
|
10
|
+
if (server.config.isProduction)
|
|
11
|
+
return;
|
|
10
12
|
runHookServerSetup({ config: settings.config, server, logging });
|
|
11
13
|
},
|
|
12
14
|
async buildStart() {
|
|
15
|
+
if (settings.injectedRoutes.length === settings.resolvedInjectedRoutes.length)
|
|
16
|
+
return;
|
|
13
17
|
settings.resolvedInjectedRoutes = await Promise.all(
|
|
14
18
|
settings.injectedRoutes.map((route) => resolveEntryPoint.call(this, route))
|
|
15
19
|
);
|