astro 2.8.5 → 2.9.1
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 +9 -0
- package/components/ViewTransitions.astro +175 -0
- package/components/index.ts +1 -0
- package/components/viewtransitions.css +56 -0
- package/dist/@types/astro.d.ts +28 -10
- package/dist/assets/services/vendor/squoosh/impl.js +1 -1
- package/dist/content/runtime.js +1 -1
- package/dist/content/vite-plugin-content-assets.js +2 -2
- package/dist/core/app/index.js +115 -95
- package/dist/core/build/generate.js +18 -33
- package/dist/core/build/graph.js +1 -1
- package/dist/core/build/plugins/plugin-analyzer.js +101 -3
- package/dist/core/build/plugins/plugin-css.js +1 -1
- package/dist/core/build/types.d.ts +1 -1
- package/dist/core/compile/compile.js +2 -0
- package/dist/core/config/config.js +3 -5
- package/dist/core/config/schema.d.ts +85 -48
- package/dist/core/config/schema.js +36 -10
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +4 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/dev/index.d.ts +2 -11
- package/dist/core/endpoint/index.d.ts +2 -3
- package/dist/core/endpoint/index.js +1 -11
- package/dist/core/errors/index.d.ts +1 -1
- package/dist/core/errors/index.js +3 -3
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/index.d.ts +1 -1
- package/dist/core/render/core.d.ts +9 -3
- package/dist/core/render/core.js +42 -18
- package/dist/core/render/environment.d.ts +7 -2
- package/dist/core/render/index.d.ts +22 -1
- package/dist/core/render/index.js +2 -2
- package/dist/core/render/route-cache.js +1 -1
- package/dist/core/routing/validation.d.ts +2 -3
- package/dist/core/routing/validation.js +0 -9
- package/dist/jsx-runtime/index.d.ts +1 -1
- package/dist/prerender/routing.d.ts +1 -1
- package/dist/prerender/routing.js +1 -1
- package/dist/runtime/server/astro-component.d.ts +1 -1
- package/dist/runtime/server/astro-component.js +5 -5
- package/dist/runtime/server/index.d.ts +2 -1
- package/dist/runtime/server/index.js +3 -1
- package/dist/runtime/server/jsx.js +6 -2
- package/dist/runtime/server/render/astro/factory.d.ts +0 -1
- package/dist/runtime/server/render/astro/factory.js +1 -18
- package/dist/runtime/server/render/astro/index.d.ts +2 -1
- package/dist/runtime/server/render/astro/index.js +3 -1
- package/dist/runtime/server/render/astro/render.d.ts +4 -0
- package/dist/runtime/server/render/astro/render.js +119 -0
- package/dist/runtime/server/render/common.d.ts +8 -0
- package/dist/runtime/server/render/common.js +11 -3
- package/dist/runtime/server/render/component.js +1 -1
- package/dist/runtime/server/render/page.js +18 -89
- package/dist/runtime/server/transition.d.ts +2 -0
- package/dist/runtime/server/transition.js +133 -0
- package/dist/transitions/index.d.ts +7 -0
- package/dist/transitions/index.js +67 -0
- package/dist/transitions/vite-plugin-transitions.d.ts +5 -0
- package/dist/transitions/vite-plugin-transitions.js +36 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/css.d.ts +2 -2
- package/dist/{core/render/dev → vite-plugin-astro-server}/css.js +1 -1
- package/dist/vite-plugin-astro-server/environment.d.ts +5 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/environment.js +3 -3
- package/dist/vite-plugin-astro-server/index.d.ts +6 -0
- package/dist/vite-plugin-astro-server/index.js +21 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/metadata.d.ts +2 -2
- package/dist/{core/render/dev → vite-plugin-astro-server}/metadata.js +2 -2
- package/dist/vite-plugin-astro-server/plugin.js +1 -1
- package/dist/vite-plugin-astro-server/request.d.ts +1 -1
- package/dist/{core/render/dev → vite-plugin-astro-server}/resolve.d.ts +1 -1
- package/dist/{core/render/dev → vite-plugin-astro-server}/resolve.js +1 -1
- package/dist/vite-plugin-astro-server/route.d.ts +1 -1
- package/dist/vite-plugin-astro-server/route.js +93 -20
- package/dist/vite-plugin-astro-server/scripts.d.ts +3 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/scripts.js +2 -2
- package/dist/{core/render/dev → vite-plugin-astro-server}/vite.d.ts +1 -1
- package/dist/{core/render/dev → vite-plugin-astro-server}/vite.js +2 -2
- package/dist/vite-plugin-markdown/index.js +1 -1
- package/dist/vite-plugin-scanner/index.d.ts +6 -3
- package/dist/vite-plugin-scanner/index.js +21 -4
- package/dist/vite-plugin-scanner/scan.d.ts +2 -1
- package/dist/vite-plugin-scanner/scan.js +6 -2
- package/package.json +6 -3
- package/dist/core/render/dev/environment.d.ts +0 -9
- package/dist/core/render/dev/index.d.ts +0 -27
- package/dist/core/render/dev/index.js +0 -112
- package/dist/core/render/dev/scripts.d.ts +0 -3
- /package/dist/{core/render/dev → vite-plugin-astro-server}/util.d.ts +0 -0
- /package/dist/{core/render/dev → vite-plugin-astro-server}/util.js +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { AstroError, AstroErrorData } from "../../../../core/errors/index.js";
|
|
2
|
+
import { chunkToByteArray, chunkToString, encoder } from "../common.js";
|
|
3
|
+
import { isHeadAndContent } from "./head-and-content.js";
|
|
4
|
+
import { isRenderTemplateResult, renderAstroTemplateResult } from "./render-template.js";
|
|
5
|
+
async function renderToString(result, componentFactory, props, children, isPage = false, route) {
|
|
6
|
+
const templateResult = await callComponentAsTemplateResultOrResponse(
|
|
7
|
+
result,
|
|
8
|
+
componentFactory,
|
|
9
|
+
props,
|
|
10
|
+
children,
|
|
11
|
+
route
|
|
12
|
+
);
|
|
13
|
+
if (templateResult instanceof Response)
|
|
14
|
+
return templateResult;
|
|
15
|
+
let str = "";
|
|
16
|
+
let renderedFirstPageChunk = false;
|
|
17
|
+
const destination = {
|
|
18
|
+
write(chunk) {
|
|
19
|
+
if (isPage && !renderedFirstPageChunk) {
|
|
20
|
+
renderedFirstPageChunk = true;
|
|
21
|
+
if (!/<!doctype html/i.test(String(chunk))) {
|
|
22
|
+
const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
|
|
23
|
+
str += doctype;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (chunk instanceof Response)
|
|
27
|
+
return;
|
|
28
|
+
str += chunkToString(result, chunk);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
for await (const chunk of renderAstroTemplateResult(templateResult)) {
|
|
32
|
+
destination.write(chunk);
|
|
33
|
+
}
|
|
34
|
+
return str;
|
|
35
|
+
}
|
|
36
|
+
async function renderToReadableStream(result, componentFactory, props, children, isPage = false, route) {
|
|
37
|
+
const templateResult = await callComponentAsTemplateResultOrResponse(
|
|
38
|
+
result,
|
|
39
|
+
componentFactory,
|
|
40
|
+
props,
|
|
41
|
+
children,
|
|
42
|
+
route
|
|
43
|
+
);
|
|
44
|
+
if (templateResult instanceof Response)
|
|
45
|
+
return templateResult;
|
|
46
|
+
if (isPage) {
|
|
47
|
+
await bufferHeadContent(result);
|
|
48
|
+
}
|
|
49
|
+
let renderedFirstPageChunk = false;
|
|
50
|
+
return new ReadableStream({
|
|
51
|
+
start(controller) {
|
|
52
|
+
const destination = {
|
|
53
|
+
write(chunk) {
|
|
54
|
+
if (isPage && !renderedFirstPageChunk) {
|
|
55
|
+
renderedFirstPageChunk = true;
|
|
56
|
+
if (!/<!doctype html/i.test(String(chunk))) {
|
|
57
|
+
const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
|
|
58
|
+
controller.enqueue(encoder.encode(doctype));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (chunk instanceof Response) {
|
|
62
|
+
throw new AstroError({
|
|
63
|
+
...AstroErrorData.ResponseSentError
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const bytes = chunkToByteArray(result, chunk);
|
|
67
|
+
controller.enqueue(bytes);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
(async () => {
|
|
71
|
+
try {
|
|
72
|
+
for await (const chunk of renderAstroTemplateResult(templateResult)) {
|
|
73
|
+
destination.write(chunk);
|
|
74
|
+
}
|
|
75
|
+
controller.close();
|
|
76
|
+
} catch (e) {
|
|
77
|
+
if (AstroError.is(e) && !e.loc) {
|
|
78
|
+
e.setLocation({
|
|
79
|
+
file: route == null ? void 0 : route.component
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
controller.error(e);
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async function callComponentAsTemplateResultOrResponse(result, componentFactory, props, children, route) {
|
|
89
|
+
const factoryResult = await componentFactory(result, props, children);
|
|
90
|
+
if (factoryResult instanceof Response) {
|
|
91
|
+
return factoryResult;
|
|
92
|
+
} else if (!isRenderTemplateResult(factoryResult)) {
|
|
93
|
+
throw new AstroError({
|
|
94
|
+
...AstroErrorData.OnlyResponseCanBeReturned,
|
|
95
|
+
message: AstroErrorData.OnlyResponseCanBeReturned.message(route == null ? void 0 : route.route, typeof factoryResult),
|
|
96
|
+
location: {
|
|
97
|
+
file: route == null ? void 0 : route.component
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return isHeadAndContent(factoryResult) ? factoryResult.content : factoryResult;
|
|
102
|
+
}
|
|
103
|
+
async function bufferHeadContent(result) {
|
|
104
|
+
const iterator = result._metadata.propagators.values();
|
|
105
|
+
while (true) {
|
|
106
|
+
const { value, done } = iterator.next();
|
|
107
|
+
if (done) {
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
const returnValue = await value.init(result);
|
|
111
|
+
if (isHeadAndContent(returnValue)) {
|
|
112
|
+
result._metadata.extraHead.push(returnValue.head);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
renderToReadableStream,
|
|
118
|
+
renderToString
|
|
119
|
+
};
|
|
@@ -2,6 +2,13 @@ import type { SSRResult } from '../../../@types/astro';
|
|
|
2
2
|
import type { RenderInstruction } from './types.js';
|
|
3
3
|
import { HTMLBytes } from '../escape.js';
|
|
4
4
|
import { type SlotString } from './slot.js';
|
|
5
|
+
export interface RenderDestination {
|
|
6
|
+
/**
|
|
7
|
+
* Any rendering logic should call this to construct the HTML output.
|
|
8
|
+
* See the `chunk` parameter for possible writable values
|
|
9
|
+
*/
|
|
10
|
+
write(chunk: string | HTMLBytes | RenderInstruction | Response): void;
|
|
11
|
+
}
|
|
5
12
|
export declare const Fragment: unique symbol;
|
|
6
13
|
export declare const Renderer: unique symbol;
|
|
7
14
|
export declare const encoder: TextEncoder;
|
|
@@ -14,4 +21,5 @@ export declare class HTMLParts {
|
|
|
14
21
|
toString(): string;
|
|
15
22
|
toArrayBuffer(): Uint8Array;
|
|
16
23
|
}
|
|
24
|
+
export declare function chunkToString(result: SSRResult, chunk: string | HTMLBytes | RenderInstruction): string;
|
|
17
25
|
export declare function chunkToByteArray(result: SSRResult, chunk: string | HTMLBytes | RenderInstruction): Uint8Array;
|
|
@@ -78,18 +78,26 @@ class HTMLParts {
|
|
|
78
78
|
return encoder.encode(this.parts);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
function chunkToString(result, chunk) {
|
|
82
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
83
|
+
return decoder.decode(chunk);
|
|
84
|
+
} else {
|
|
85
|
+
return stringifyChunk(result, chunk);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
81
88
|
function chunkToByteArray(result, chunk) {
|
|
82
|
-
if (chunk
|
|
89
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
83
90
|
return chunk;
|
|
91
|
+
} else {
|
|
92
|
+
return encoder.encode(stringifyChunk(result, chunk));
|
|
84
93
|
}
|
|
85
|
-
let stringified = stringifyChunk(result, chunk);
|
|
86
|
-
return encoder.encode(stringified.toString());
|
|
87
94
|
}
|
|
88
95
|
export {
|
|
89
96
|
Fragment,
|
|
90
97
|
HTMLParts,
|
|
91
98
|
Renderer,
|
|
92
99
|
chunkToByteArray,
|
|
100
|
+
chunkToString,
|
|
93
101
|
decoder,
|
|
94
102
|
encoder,
|
|
95
103
|
stringifyChunk
|
|
@@ -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 {
|
|
16
|
+
import { renderSlotToString, renderSlots } 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) {
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { AstroError
|
|
1
|
+
import { AstroError } from "../../../core/errors/index.js";
|
|
2
2
|
import { isHTMLString } from "../escape.js";
|
|
3
3
|
import { createResponse } from "../response.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
isHeadAndContent,
|
|
8
|
-
isRenderTemplateResult,
|
|
9
|
-
renderAstroTemplateResult
|
|
10
|
-
} from "./astro/index.js";
|
|
11
|
-
import { chunkToByteArray, encoder, HTMLParts } from "./common.js";
|
|
4
|
+
import { isAstroComponentFactory, isAstroComponentInstance } from "./astro/index.js";
|
|
5
|
+
import { renderToReadableStream, renderToString } from "./astro/render.js";
|
|
6
|
+
import { HTMLParts, encoder } from "./common.js";
|
|
12
7
|
import { renderComponent } from "./component.js";
|
|
13
8
|
import { maybeRenderHead } from "./head.js";
|
|
14
9
|
const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
|
|
@@ -34,19 +29,6 @@ async function iterableToHTMLBytes(result, iterable, onDocTypeInjection) {
|
|
|
34
29
|
}
|
|
35
30
|
return parts.toArrayBuffer();
|
|
36
31
|
}
|
|
37
|
-
async function bufferHeadContent(result) {
|
|
38
|
-
const iterator = result._metadata.propagators.values();
|
|
39
|
-
while (true) {
|
|
40
|
-
const { value, done } = iterator.next();
|
|
41
|
-
if (done) {
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
const returnValue = await value.init(result);
|
|
45
|
-
if (isHeadAndContent(returnValue)) {
|
|
46
|
-
result._metadata.extraHead.push(returnValue.head);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
32
|
async function renderPage(result, componentFactory, props, children, streaming, route) {
|
|
51
33
|
var _a, _b;
|
|
52
34
|
if (!isAstroComponentFactory(componentFactory)) {
|
|
@@ -93,75 +75,22 @@ async function renderPage(result, componentFactory, props, children, streaming,
|
|
|
93
75
|
});
|
|
94
76
|
}
|
|
95
77
|
result._metadata.headInTree = ((_b = result.componentMetadata.get(componentFactory.moduleId)) == null ? void 0 : _b.containsHead) ?? false;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
let iterable = renderAstroTemplateResult(templateResult);
|
|
102
|
-
let init = result.response;
|
|
103
|
-
let headers = new Headers(init.headers);
|
|
104
|
-
let body;
|
|
105
|
-
if (streaming) {
|
|
106
|
-
body = new ReadableStream({
|
|
107
|
-
start(controller) {
|
|
108
|
-
async function read() {
|
|
109
|
-
let i = 0;
|
|
110
|
-
try {
|
|
111
|
-
for await (const chunk of iterable) {
|
|
112
|
-
if (isHTMLString(chunk)) {
|
|
113
|
-
if (i === 0) {
|
|
114
|
-
if (!/<!doctype html/i.test(String(chunk))) {
|
|
115
|
-
controller.enqueue(
|
|
116
|
-
encoder.encode(
|
|
117
|
-
`${result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n"}`
|
|
118
|
-
)
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (chunk instanceof Response) {
|
|
124
|
-
throw new AstroError({
|
|
125
|
-
...AstroErrorData.ResponseSentError
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
const bytes = chunkToByteArray(result, chunk);
|
|
129
|
-
controller.enqueue(bytes);
|
|
130
|
-
i++;
|
|
131
|
-
}
|
|
132
|
-
controller.close();
|
|
133
|
-
} catch (e) {
|
|
134
|
-
if (AstroError.is(e) && !e.loc) {
|
|
135
|
-
e.setLocation({
|
|
136
|
-
file: route == null ? void 0 : route.component
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
controller.error(e);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
read();
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
} else {
|
|
146
|
-
body = await iterableToHTMLBytes(result, iterable);
|
|
147
|
-
headers.set("Content-Length", body.byteLength.toString());
|
|
148
|
-
}
|
|
149
|
-
let response = createResponse(body, { ...init, headers });
|
|
150
|
-
return response;
|
|
78
|
+
let body;
|
|
79
|
+
if (streaming) {
|
|
80
|
+
body = await renderToReadableStream(result, componentFactory, props, children, true, route);
|
|
81
|
+
} else {
|
|
82
|
+
body = await renderToString(result, componentFactory, props, children, true, route);
|
|
151
83
|
}
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
location: {
|
|
160
|
-
file: route == null ? void 0 : route.component
|
|
161
|
-
}
|
|
162
|
-
});
|
|
84
|
+
if (body instanceof Response)
|
|
85
|
+
return body;
|
|
86
|
+
const init = result.response;
|
|
87
|
+
const headers = new Headers(init.headers);
|
|
88
|
+
if (!streaming && typeof body === "string") {
|
|
89
|
+
body = encoder.encode(body);
|
|
90
|
+
headers.set("Content-Length", body.byteLength.toString());
|
|
163
91
|
}
|
|
164
|
-
|
|
92
|
+
const response = createResponse(body, { ...init, headers });
|
|
93
|
+
return response;
|
|
165
94
|
}
|
|
166
95
|
export {
|
|
167
96
|
renderPage
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { fade, slide } from "../../transitions/index.js";
|
|
2
|
+
import { markHTMLString } from "./escape.js";
|
|
3
|
+
const transitionNameMap = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function incrementTransitionNumber(result) {
|
|
5
|
+
let num = 1;
|
|
6
|
+
if (transitionNameMap.has(result)) {
|
|
7
|
+
num = transitionNameMap.get(result) + 1;
|
|
8
|
+
}
|
|
9
|
+
transitionNameMap.set(result, num);
|
|
10
|
+
return num;
|
|
11
|
+
}
|
|
12
|
+
function createTransitionScope(result, hash) {
|
|
13
|
+
const num = incrementTransitionNumber(result);
|
|
14
|
+
return `astro-${hash}-${num}`;
|
|
15
|
+
}
|
|
16
|
+
function renderTransition(result, hash, animationName, transitionName) {
|
|
17
|
+
let animations = null;
|
|
18
|
+
switch (animationName) {
|
|
19
|
+
case "fade": {
|
|
20
|
+
animations = fade();
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case "slide": {
|
|
24
|
+
animations = slide();
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
default: {
|
|
28
|
+
if (typeof animationName === "object") {
|
|
29
|
+
animations = animationName;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const scope = createTransitionScope(result, hash);
|
|
34
|
+
if (!transitionName) {
|
|
35
|
+
transitionName = scope;
|
|
36
|
+
}
|
|
37
|
+
const styles = markHTMLString(`<style>[data-astro-transition-scope="${scope}"] {
|
|
38
|
+
view-transition-name: ${transitionName};
|
|
39
|
+
}
|
|
40
|
+
${!animations ? `` : (
|
|
41
|
+
// Regular animations
|
|
42
|
+
`
|
|
43
|
+
::view-transition-old(${transitionName}) {
|
|
44
|
+
${stringifyAnimation(animations.forwards.old)}
|
|
45
|
+
}
|
|
46
|
+
[data-astro-transition-fallback=old] [data-astro-transition-scope="${scope}"] {
|
|
47
|
+
${stringifyAnimation(animations.forwards.old)}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
::view-transition-new(${transitionName}) {
|
|
51
|
+
${stringifyAnimation(animations.forwards.new)}
|
|
52
|
+
}
|
|
53
|
+
[data-astro-transition-fallback=new] [data-astro-transition-scope="${scope}"] {
|
|
54
|
+
${stringifyAnimation(animations.forwards.new)}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[data-astro-transition=back]::view-transition-old(${transitionName}) {
|
|
58
|
+
${stringifyAnimation(animations.backwards.old)}
|
|
59
|
+
}
|
|
60
|
+
[data-astro-transition=back][data-astro-transition-fallback=old] [data-astro-transition-scope="${scope}"] {
|
|
61
|
+
${stringifyAnimation(animations.backwards.old)}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
[data-astro-transition=back]::view-transition-new(${transitionName}) {
|
|
65
|
+
${stringifyAnimation(animations.backwards.new)}
|
|
66
|
+
}
|
|
67
|
+
[data-astro-transition=back][data-astro-transition-fallback=new] [data-astro-transition-scope="${scope}"] {
|
|
68
|
+
${stringifyAnimation(animations.backwards.new)}
|
|
69
|
+
}
|
|
70
|
+
`.trim()
|
|
71
|
+
)}
|
|
72
|
+
</style>`);
|
|
73
|
+
result._metadata.extraHead.push(styles);
|
|
74
|
+
return scope;
|
|
75
|
+
}
|
|
76
|
+
function addAnimationProperty(builder, prop, value) {
|
|
77
|
+
let arr = builder[prop];
|
|
78
|
+
if (Array.isArray(arr)) {
|
|
79
|
+
arr.push(value.toString());
|
|
80
|
+
} else {
|
|
81
|
+
builder[prop] = [value.toString()];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function animationBuilder() {
|
|
85
|
+
return {
|
|
86
|
+
toString() {
|
|
87
|
+
let out = "";
|
|
88
|
+
for (let k in this) {
|
|
89
|
+
let value = this[k];
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
out += `
|
|
92
|
+
${k}: ${value.join(", ")};`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function stringifyAnimation(anim) {
|
|
100
|
+
if (Array.isArray(anim)) {
|
|
101
|
+
return stringifyAnimations(anim);
|
|
102
|
+
} else {
|
|
103
|
+
return stringifyAnimations([anim]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function stringifyAnimations(anims) {
|
|
107
|
+
const builder = animationBuilder();
|
|
108
|
+
for (const anim of anims) {
|
|
109
|
+
if (anim.duration) {
|
|
110
|
+
addAnimationProperty(builder, "animation-duration", toTimeValue(anim.duration));
|
|
111
|
+
}
|
|
112
|
+
if (anim.easing) {
|
|
113
|
+
addAnimationProperty(builder, "animation-timing-function", anim.easing);
|
|
114
|
+
}
|
|
115
|
+
if (anim.direction) {
|
|
116
|
+
addAnimationProperty(builder, "animation-direction", anim.direction);
|
|
117
|
+
}
|
|
118
|
+
if (anim.delay) {
|
|
119
|
+
addAnimationProperty(builder, "animation-delay", anim.delay);
|
|
120
|
+
}
|
|
121
|
+
if (anim.fillMode) {
|
|
122
|
+
addAnimationProperty(builder, "animation-fill-mode", anim.fillMode);
|
|
123
|
+
}
|
|
124
|
+
addAnimationProperty(builder, "animation-name", anim.name);
|
|
125
|
+
}
|
|
126
|
+
return builder.toString();
|
|
127
|
+
}
|
|
128
|
+
function toTimeValue(num) {
|
|
129
|
+
return typeof num === "number" ? num + "ms" : num;
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
renderTransition
|
|
133
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransitionDirectionalAnimations } from '../@types/astro';
|
|
2
|
+
export declare function slide({ duration, }?: {
|
|
3
|
+
duration?: string | number;
|
|
4
|
+
}): TransitionDirectionalAnimations;
|
|
5
|
+
export declare function fade({ duration, }?: {
|
|
6
|
+
duration?: string | number;
|
|
7
|
+
}): TransitionDirectionalAnimations;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
function slide({
|
|
2
|
+
duration
|
|
3
|
+
} = {}) {
|
|
4
|
+
return {
|
|
5
|
+
forwards: {
|
|
6
|
+
old: [
|
|
7
|
+
{
|
|
8
|
+
name: "astroFadeOut",
|
|
9
|
+
duration: duration ?? "90ms",
|
|
10
|
+
easing: "cubic-bezier(0.4, 0, 1, 1)",
|
|
11
|
+
fillMode: "both"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "astroSlideToLeft",
|
|
15
|
+
duration: duration ?? "300ms",
|
|
16
|
+
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
17
|
+
fillMode: "both"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
new: [
|
|
21
|
+
{
|
|
22
|
+
name: "astroFadeIn",
|
|
23
|
+
duration: duration ?? "210ms",
|
|
24
|
+
easing: "cubic-bezier(0, 0, 0.2, 1)",
|
|
25
|
+
delay: "90ms",
|
|
26
|
+
fillMode: "both"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "astroSlideFromRight",
|
|
30
|
+
duration: duration ?? "300ms",
|
|
31
|
+
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
32
|
+
fillMode: "both"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
backwards: {
|
|
37
|
+
old: [{ name: "astroFadeOut" }, { name: "astroSlideToRight" }],
|
|
38
|
+
new: [{ name: "astroFadeIn" }, { name: "astroSlideFromLeft" }]
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function fade({
|
|
43
|
+
duration
|
|
44
|
+
} = {}) {
|
|
45
|
+
const anim = {
|
|
46
|
+
old: {
|
|
47
|
+
name: "astroFadeInOut",
|
|
48
|
+
duration: duration ?? "0.2s",
|
|
49
|
+
easing: "linear",
|
|
50
|
+
fillMode: "forwards"
|
|
51
|
+
},
|
|
52
|
+
new: {
|
|
53
|
+
name: "astroFadeInOut",
|
|
54
|
+
duration: duration ?? "0.3s",
|
|
55
|
+
easing: "linear",
|
|
56
|
+
fillMode: "backwards"
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
forwards: anim,
|
|
61
|
+
backwards: anim
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
fade,
|
|
66
|
+
slide
|
|
67
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AstroError } from "../core/errors/index.js";
|
|
2
|
+
const virtualModuleId = "astro:transitions";
|
|
3
|
+
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
4
|
+
function astroTransitions({ config }) {
|
|
5
|
+
return {
|
|
6
|
+
name: "astro:transitions",
|
|
7
|
+
async resolveId(id) {
|
|
8
|
+
if (id === virtualModuleId) {
|
|
9
|
+
return resolvedVirtualModuleId;
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
load(id) {
|
|
13
|
+
if (id === resolvedVirtualModuleId) {
|
|
14
|
+
if (!config.experimental.viewTransitions) {
|
|
15
|
+
throw new AstroError({
|
|
16
|
+
title: "Experimental View Transitions not enabled",
|
|
17
|
+
message: `View Transitions support is experimental. To enable update your config to include:
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
experimental: {
|
|
21
|
+
viewTransitions: true
|
|
22
|
+
}
|
|
23
|
+
})`
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return `
|
|
27
|
+
export * from "astro/transitions";
|
|
28
|
+
export { default as ViewTransitions } from "astro/components/ViewTransitions.astro";
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
astroTransitions as default
|
|
36
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { RuntimeMode } from '../@types/astro.js';
|
|
2
|
+
import type { ModuleLoader } from '../core/module-loader';
|
|
3
3
|
/** Given a filePath URL, crawl Vite’s module graph to find all style imports. */
|
|
4
4
|
export declare function getStylesForURL(filePath: URL, loader: ModuleLoader, mode: RuntimeMode): Promise<{
|
|
5
5
|
urls: Set<string>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AstroSettings, SSRManifest } from '../@types/astro.js';
|
|
2
|
+
import type { LogOptions } from '../core/logger/core.js';
|
|
3
|
+
import type { ModuleLoader } from '../core/module-loader';
|
|
4
|
+
import type { DevelopmentEnvironment } from '../core/render';
|
|
5
|
+
export declare function createDevelopmentEnvironment(manifest: SSRManifest, settings: AstroSettings, logging: LogOptions, loader: ModuleLoader): DevelopmentEnvironment;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { createEnvironment } from "../core/render/index.js";
|
|
2
|
+
import { RouteCache } from "../core/render/route-cache.js";
|
|
3
|
+
import { isServerLikeOutput } from "../prerender/utils.js";
|
|
4
4
|
import { createResolve } from "./resolve.js";
|
|
5
5
|
function createDevelopmentEnvironment(manifest, settings, logging, loader) {
|
|
6
6
|
const mode = "development";
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import type { ComponentInstance } from '../@types/astro.js';
|
|
2
|
+
import type { DevelopmentEnvironment } from '../core/render/environment';
|
|
3
|
+
export declare function preload({ env, filePath, }: {
|
|
4
|
+
env: DevelopmentEnvironment;
|
|
5
|
+
filePath: URL;
|
|
6
|
+
}): Promise<ComponentInstance>;
|
|
1
7
|
export { createController, runWithErrorHandling } from './controller.js';
|
|
2
8
|
export { default as vitePluginAstroServer } from './plugin.js';
|
|
3
9
|
export { handleRequest } from './request.js';
|
|
@@ -1,9 +1,30 @@
|
|
|
1
|
+
import { enhanceViteSSRError } from "../core/errors/dev/index.js";
|
|
2
|
+
import { AggregateError, CSSError, MarkdownError } from "../core/errors/index.js";
|
|
3
|
+
import { loadRenderers } from "../core/render/index.js";
|
|
4
|
+
import { viteID } from "../core/util.js";
|
|
5
|
+
async function preload({
|
|
6
|
+
env,
|
|
7
|
+
filePath
|
|
8
|
+
}) {
|
|
9
|
+
const renderers = await loadRenderers(env.settings, env.loader);
|
|
10
|
+
env.renderers = renderers;
|
|
11
|
+
try {
|
|
12
|
+
const mod = await env.loader.import(viteID(filePath));
|
|
13
|
+
return mod;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (MarkdownError.is(error) || CSSError.is(error) || AggregateError.is(error)) {
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
throw enhanceViteSSRError({ error, filePath, loader: env.loader });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
1
21
|
import { createController, runWithErrorHandling } from "./controller.js";
|
|
2
22
|
import { default as default2 } from "./plugin.js";
|
|
3
23
|
import { handleRequest } from "./request.js";
|
|
4
24
|
export {
|
|
5
25
|
createController,
|
|
6
26
|
handleRequest,
|
|
27
|
+
preload,
|
|
7
28
|
runWithErrorHandling,
|
|
8
29
|
default2 as vitePluginAstroServer
|
|
9
30
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SSRResult } from '
|
|
2
|
-
import type { ModuleLoader } from '
|
|
1
|
+
import type { SSRResult } from '../@types/astro';
|
|
2
|
+
import type { ModuleLoader } from '../core/module-loader';
|
|
3
3
|
export declare function getComponentMetadata(filePath: URL, loader: ModuleLoader): Promise<SSRResult['componentMetadata']>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { viteID } from "../core/util.js";
|
|
2
|
+
import { getAstroMetadata } from "../vite-plugin-astro/index.js";
|
|
3
3
|
import { crawlGraph } from "./vite.js";
|
|
4
4
|
async function getComponentMetadata(filePath, loader) {
|
|
5
5
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { patchOverlay } from "../core/errors/overlay.js";
|
|
2
2
|
import { createViteLoader } from "../core/module-loader/index.js";
|
|
3
|
-
import { createDevelopmentEnvironment } from "../core/render/dev/index.js";
|
|
4
3
|
import { createRouteManifest } from "../core/routing/index.js";
|
|
5
4
|
import { baseMiddleware } from "./base.js";
|
|
6
5
|
import { createController } from "./controller.js";
|
|
6
|
+
import { createDevelopmentEnvironment } from "./environment.js";
|
|
7
7
|
import { handleRequest } from "./request.js";
|
|
8
8
|
function createVitePluginAstroServer({
|
|
9
9
|
settings,
|