@primate/core 0.1.7 → 0.1.9
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 +8 -7
- package/src/build/hook/build.js +4 -6
- package/src/build/hook/router.js +3 -2
- package/src/build/targets/web.js +19 -20
- package/src/http/verbs.js +11 -0
- package/src/serve/app.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Primate core",
|
|
5
5
|
"homepage": "https://primatejs.com",
|
|
6
6
|
"bugs": "https://github.com/primatejs/primate/issues",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@rcompat/array": "^0.3.0",
|
|
20
20
|
"@rcompat/async": "^0.3.0",
|
|
21
|
-
"@rcompat/build": "^0.
|
|
21
|
+
"@rcompat/build": "^0.5.0",
|
|
22
22
|
"@rcompat/cli": "^0.5.1",
|
|
23
23
|
"@rcompat/crypto": "^0.5.0",
|
|
24
|
-
"@rcompat/fs": "^0.
|
|
24
|
+
"@rcompat/fs": "^0.7.0",
|
|
25
25
|
"@rcompat/function": "^0.4.0",
|
|
26
|
-
"@rcompat/http": "^0.
|
|
26
|
+
"@rcompat/http": "^0.6.1",
|
|
27
27
|
"@rcompat/invariant": "^0.5.0",
|
|
28
28
|
"@rcompat/object": "^0.5.0",
|
|
29
|
-
"@rcompat/package": "^0.
|
|
29
|
+
"@rcompat/package": "^0.8.0",
|
|
30
30
|
"@rcompat/runtime": "^0.1.0",
|
|
31
31
|
"@rcompat/stdio": "^0.5.0",
|
|
32
32
|
"@rcompat/sync": "^0.3.0"
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"type": "module",
|
|
35
35
|
"imports": {
|
|
36
36
|
"#*": {
|
|
37
|
-
"
|
|
37
|
+
"livetypes": "./src/private/*.js",
|
|
38
38
|
"default": "./src/private/*.js"
|
|
39
39
|
},
|
|
40
40
|
"#error/*": {
|
|
41
|
-
"
|
|
41
|
+
"livetypes": "./src/private/error/*.js",
|
|
42
42
|
"default": "./src/private/error/*.js"
|
|
43
43
|
}
|
|
44
44
|
},
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"./error": "./src/error/index.js",
|
|
49
49
|
"./log": "./src/log/index.js",
|
|
50
50
|
"./dispatch": "./src/dispatch/index.js",
|
|
51
|
+
"./http/verbs": "./src/http/verbs.js",
|
|
51
52
|
"./handler/*": "./src/serve/handler/*.js"
|
|
52
53
|
}
|
|
53
54
|
}
|
package/src/build/hook/build.js
CHANGED
|
@@ -41,7 +41,8 @@ const pre = async (app, mode, target) => {
|
|
|
41
41
|
await Promise.all(["server", "client", "components"]
|
|
42
42
|
.map(directory => app.runpath(directory).create()));
|
|
43
43
|
|
|
44
|
-
const router = await $router(app.path.routes
|
|
44
|
+
const router = await $router(app.path.routes,
|
|
45
|
+
[".js"].concat(Object.keys(app.bindings)));
|
|
45
46
|
const layout = { depth: router.depth("layout") };
|
|
46
47
|
app.set("layout", layout);
|
|
47
48
|
|
|
@@ -111,7 +112,7 @@ await serve(import.meta.url, {
|
|
|
111
112
|
|
|
112
113
|
const post = async (app, mode, target) => {
|
|
113
114
|
const location = app.get("location");
|
|
114
|
-
const defaults = join(import.meta.
|
|
115
|
+
const defaults = join(import.meta.url, "../../defaults");
|
|
115
116
|
|
|
116
117
|
// stage routes
|
|
117
118
|
await app.stage(app.path.routes, join(location.server, location.routes));
|
|
@@ -122,7 +123,7 @@ const post = async (app, mode, target) => {
|
|
|
122
123
|
// stage components, transforming defines
|
|
123
124
|
await app.stage(app.path.components, location.components, true);
|
|
124
125
|
|
|
125
|
-
const directory = app.runpath(location.routes);
|
|
126
|
+
const directory = app.runpath(location.server, location.routes);
|
|
126
127
|
for (const path of await directory.collect()) {
|
|
127
128
|
await app.bindings[path.extension]
|
|
128
129
|
?.(directory, path.debase(`${directory}/`));
|
|
@@ -135,9 +136,6 @@ const post = async (app, mode, target) => {
|
|
|
135
136
|
// copy static files to build/server/static
|
|
136
137
|
await app.stage(app.path.static, join(location.server, location.static));
|
|
137
138
|
|
|
138
|
-
// copy static files to build/client/static
|
|
139
|
-
await app.stage(app.path.static, join(location.client, location.static));
|
|
140
|
-
|
|
141
139
|
// publish JavaScript and CSS files
|
|
142
140
|
const imports = await collect(app.path.static, /\.(?:css)$/u);
|
|
143
141
|
await Promise.all(imports.map(async file => {
|
package/src/build/hook/router.js
CHANGED
|
@@ -9,10 +9,11 @@ const error_entries = Object.entries({
|
|
|
9
9
|
RestRoute: rest_route,
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
export default async directory => {
|
|
13
|
-
|
|
12
|
+
export default async (directory, extensions) => {
|
|
14
13
|
try {
|
|
15
14
|
return await Router.load({
|
|
15
|
+
import: false,
|
|
16
|
+
extensions,
|
|
16
17
|
directory,
|
|
17
18
|
specials: {
|
|
18
19
|
guard: { recursive: true },
|
package/src/build/targets/web.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import collect from "@rcompat/fs/collect";
|
|
2
|
-
import join from "@rcompat/fs/join";
|
|
3
2
|
import webpath from "@rcompat/fs/webpath";
|
|
4
3
|
|
|
5
4
|
const html = /^.*.html$/u;
|
|
6
5
|
|
|
7
6
|
export default async app => {
|
|
8
7
|
const location = app.get("location");
|
|
9
|
-
const http = app.get("http");
|
|
10
8
|
const client = app.runpath(location.client);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
const client_imports = (await client.collect())
|
|
10
|
+
.map((file, i) => {
|
|
11
|
+
const type = file.extension === ".css" ? "style" : "js";
|
|
12
|
+
const src = `/${file.debase(client).name}`;
|
|
13
|
+
const path = `./${file.debase(`${app.path.build}/`)}`;
|
|
14
|
+
return {
|
|
15
|
+
src,
|
|
16
|
+
path,
|
|
17
|
+
code: `await load_text(asset${i})`,
|
|
18
|
+
type,
|
|
19
|
+
};
|
|
20
|
+
});
|
|
23
21
|
const d = app.runpath(location.server, location.pages);
|
|
24
22
|
const pages = await Promise.all((await collect(d, html, { recursive: true }))
|
|
25
23
|
.map(async file => `${file.debase(d)}`.slice(1)));
|
|
@@ -31,10 +29,10 @@ export default async app => {
|
|
|
31
29
|
import loader from "primate/loader";
|
|
32
30
|
import load_text from "primate/load-text";
|
|
33
31
|
|
|
34
|
-
${
|
|
35
|
-
`const asset${i} = await load_text(import.meta.
|
|
32
|
+
${client_imports.map(({ path }, i) =>
|
|
33
|
+
`const asset${i} = await load_text(import.meta.url, "../${path}");`)
|
|
36
34
|
.join("\n ")}
|
|
37
|
-
const assets = [${
|
|
35
|
+
const assets = [${client_imports.map(($import, i) => `{
|
|
38
36
|
src: "${$import.src}",
|
|
39
37
|
code: asset${i},
|
|
40
38
|
type: "${$import.type}",
|
|
@@ -42,8 +40,8 @@ export default async app => {
|
|
|
42
40
|
}`).join(",\n ")}];
|
|
43
41
|
|
|
44
42
|
const imports = {
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
app: "${client_imports.find(({ src }) =>
|
|
44
|
+
src.includes("app") && src.endsWith(".js")).src}"
|
|
47
45
|
};
|
|
48
46
|
// importmap
|
|
49
47
|
assets.push({
|
|
@@ -61,7 +59,8 @@ export default async app => {
|
|
|
61
59
|
loader: loader({
|
|
62
60
|
pages,
|
|
63
61
|
rootfile: import.meta.url,
|
|
64
|
-
pages_app: "${app.get("pages.app")}"
|
|
62
|
+
pages_app: "${app.get("pages.app")}",
|
|
63
|
+
static_root: "${app.get("http.static.root")}",
|
|
65
64
|
}),
|
|
66
65
|
target: "web",
|
|
67
66
|
};
|
package/src/serve/app.js
CHANGED