sst 2.36.6 → 2.36.8
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/constructs/AstroSite.js +19 -23
- package/node/util/loader.js +5 -4
- package/package.json +2 -2
package/constructs/AstroSite.js
CHANGED
|
@@ -28,38 +28,34 @@ export class AstroSite extends SsrSite {
|
|
|
28
28
|
return JSON.parse(readFileSync(filePath, "utf-8"));
|
|
29
29
|
}
|
|
30
30
|
static getCFRoutingFunction({ routes, pageResolution, }) {
|
|
31
|
-
const serializedRoutes =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var redirectPath = matchedRoute.redirectPath;
|
|
48
|
-
matchedRoute.pattern.exec(request.uri).forEach((match, index) => {
|
|
49
|
-
redirectPath = redirectPath.replace(\`\\\${\${index}}\`, match);
|
|
31
|
+
const serializedRoutes = routes.map((route) => ({
|
|
32
|
+
rt: route.route,
|
|
33
|
+
pt: route.pattern,
|
|
34
|
+
t: route.type,
|
|
35
|
+
pr: route.prerender === true ? true : undefined,
|
|
36
|
+
rp: route.redirectPath,
|
|
37
|
+
rs: route.redirectStatus,
|
|
38
|
+
}));
|
|
39
|
+
return `
|
|
40
|
+
var routes = ${JSON.stringify(serializedRoutes)}
|
|
41
|
+
var match = routes.find((route) => new RegExp(route.pt).test(request.uri));
|
|
42
|
+
if (match) {
|
|
43
|
+
if (match.t === "redirect") {
|
|
44
|
+
var redirectPath = match.rp;
|
|
45
|
+
new RegExp(match.pt).exec(request.uri)?.forEach((match, index) => {
|
|
46
|
+
redirectPath = redirectPath.replace(\`\\\${\${index}}\`, match)
|
|
50
47
|
});
|
|
51
|
-
var statusCode = matchedRoute.redirectStatus || 308;
|
|
52
48
|
return {
|
|
53
|
-
statusCode,
|
|
49
|
+
statusCode: match.rs || 308,
|
|
54
50
|
headers: { location: { value: redirectPath } },
|
|
55
51
|
};
|
|
56
|
-
} else if (
|
|
52
|
+
} else if (match.t === "page" && match.pr) {
|
|
57
53
|
${pageResolution === "file"
|
|
58
54
|
? `request.uri = request.uri === "/" ? "/index.html" : request.uri.replace(/\\/?$/, ".html");`
|
|
59
55
|
: `request.uri = request.uri.replace(/\\/?$/, "/index.html");`}
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
|
-
|
|
58
|
+
`;
|
|
63
59
|
}
|
|
64
60
|
plan() {
|
|
65
61
|
const { path: sitePath } = this.props;
|
package/node/util/loader.js
CHANGED
|
@@ -9,10 +9,11 @@ export function createLoader(batchFn) {
|
|
|
9
9
|
const batch = current;
|
|
10
10
|
if (!batch)
|
|
11
11
|
return;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
batchFn(batch.keys).then((result) => {
|
|
13
|
+
for (let i = 0; i < result.length; i++) {
|
|
14
|
+
batch.promises[i](result[i]);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
16
17
|
current = undefined;
|
|
17
18
|
}
|
|
18
19
|
function getBatch() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "sst",
|
|
4
|
-
"version": "2.36.
|
|
4
|
+
"version": "2.36.8",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"@types/ws": "^8.5.3",
|
|
121
121
|
"@types/yargs": "^17.0.13",
|
|
122
122
|
"archiver": "^5.3.1",
|
|
123
|
-
"astro-sst": "2.36.
|
|
123
|
+
"astro-sst": "2.36.8",
|
|
124
124
|
"async": "^3.2.4",
|
|
125
125
|
"tsx": "^3.12.1",
|
|
126
126
|
"typescript": "^5.2.2",
|