primate 0.29.4 → 0.29.6
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primate",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.6",
|
|
4
4
|
"description": "Polymorphic development platform",
|
|
5
5
|
"homepage": "https://primatejs.com",
|
|
6
6
|
"bugs": "https://github.com/primatejs/primate/issues",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"directory": "packages/primate"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"rcompat": "^0.8.
|
|
22
|
+
"rcompat": "^0.8.3"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=18"
|
package/src/app.js
CHANGED
|
@@ -238,8 +238,8 @@ export default async (log, root, config) => {
|
|
|
238
238
|
const dependency = File.resolve().join(...path);
|
|
239
239
|
const target = File.join(this.runpath(client), this.library, ...parts);
|
|
240
240
|
await dependency.copy(target);
|
|
241
|
-
this.importmaps = {
|
|
242
|
-
|
|
241
|
+
this.importmaps = { ...valmap(exports, value =>
|
|
242
|
+
File.join(root, this.library, value).normalize()),
|
|
243
243
|
...this.importmaps };
|
|
244
244
|
},
|
|
245
245
|
};
|
package/src/hooks/handle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Response, Status, MediaType } from "rcompat/http";
|
|
2
2
|
import { cascade, tryreturn } from "rcompat/async";
|
|
3
|
-
import
|
|
3
|
+
import respond from "./respond.js";
|
|
4
4
|
import { error as clientError } from "../handlers.js";
|
|
5
5
|
|
|
6
6
|
const guard_error = Symbol("guard_error");
|
package/src/hooks/publish.js
CHANGED
|
@@ -16,7 +16,7 @@ const post = async app => {
|
|
|
16
16
|
type: "module",
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
const imports = { ...app.importmaps, app: src.
|
|
19
|
+
const imports = { ...app.importmaps, app: src.normalize() };
|
|
20
20
|
const type = "importmap";
|
|
21
21
|
await app.publish({ inline: true, code: stringify({ imports }), type });
|
|
22
22
|
}
|
|
@@ -9,8 +9,8 @@ const not_found = value => {
|
|
|
9
9
|
const is_text = value => typeof value === "string";
|
|
10
10
|
const is_non_null_object = value => typeof value === "object" && value !== null;
|
|
11
11
|
const is_instance = of => value => value instanceof of;
|
|
12
|
-
const is_response = is_instance(Response);
|
|
13
|
-
const
|
|
12
|
+
const is_response = is_instance(globalThis.Response);
|
|
13
|
+
const is_fake_response = is_instance(Response);
|
|
14
14
|
const is_streamable =
|
|
15
15
|
value => value instanceof Blob || value?.streamable === s_streamable;
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ const guesses = [
|
|
|
19
19
|
[is_instance(URL), redirect],
|
|
20
20
|
[is_streamable, value => stream(value.stream())],
|
|
21
21
|
[is_instance(ReadableStream), stream],
|
|
22
|
-
[value => is_response(value) ||
|
|
22
|
+
[value => is_response(value) || is_fake_response(value), value => _ => value],
|
|
23
23
|
[is_non_null_object, json],
|
|
24
24
|
[is_text, text],
|
|
25
25
|
[not_found, identity],
|
package/src/loaders/routes.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { tryreturn } from "rcompat/sync";
|
|
2
2
|
import { from } from "rcompat/object";
|
|
3
|
+
import { File } from "rcompat/fs";
|
|
3
4
|
import { default as fs, doubled } from "./common.js";
|
|
4
5
|
import * as get from "./routes/exports.js";
|
|
5
6
|
import errors from "../errors.js";
|
|
6
7
|
|
|
8
|
+
const { separator } = File;
|
|
9
|
+
|
|
7
10
|
const make = path => {
|
|
8
|
-
const double = doubled(path.split(
|
|
11
|
+
const double = doubled(path.split(separator)
|
|
9
12
|
.filter(part => part.startsWith("{") && part.endsWith("}"))
|
|
10
13
|
.map(part => part.slice(1, part.indexOf("="))));
|
|
11
14
|
double && errors.DoublePathParameter.throw(double, path);
|
|
@@ -17,7 +20,8 @@ const make = path => {
|
|
|
17
20
|
return `(?<${param}>[^/]{1,}?)`;
|
|
18
21
|
}).orelse(_ => errors.InvalidPathParameter.throw(named, path)));
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
// normalize to unix
|
|
24
|
+
return new RegExp(`^/${route.replaceAll(separator, "/")}$`, "u");
|
|
21
25
|
};
|
|
22
26
|
|
|
23
27
|
export default async (app, load = fs) => {
|
|
@@ -38,7 +42,7 @@ export default async (app, load = fs) => {
|
|
|
38
42
|
return Object.entries(route).map(([method, handler]) => ({
|
|
39
43
|
method,
|
|
40
44
|
handler,
|
|
41
|
-
pathname: make(path.endsWith(
|
|
45
|
+
pathname: make(path.endsWith(separator) ? path.slice(0, -1) : path),
|
|
42
46
|
guards: routes.guards.filter(filtered).map(([, guard]) => guard.default),
|
|
43
47
|
errors: routes.errors.filter(filtered).map(([, error]) => error.default),
|
|
44
48
|
layouts: routes.layouts.filter(filtered).map(([, layout]) => layout),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as respond } from "./respond.js";
|