@primate/core 0.1.7 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/core",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
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.4.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.5.1",
24
+ "@rcompat/fs": "^0.6.0",
25
25
  "@rcompat/function": "^0.4.0",
26
- "@rcompat/http": "^0.5.3",
26
+ "@rcompat/http": "^0.6.0",
27
27
  "@rcompat/invariant": "^0.5.0",
28
28
  "@rcompat/object": "^0.5.0",
29
- "@rcompat/package": "^0.7.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
- "@primate/lt": "./src/private/*.js",
37
+ "livetypes": "./src/private/*.js",
38
38
  "default": "./src/private/*.js"
39
39
  },
40
40
  "#error/*": {
41
- "@primate/lt": "./src/private/error/*.js",
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
  }
@@ -111,7 +111,7 @@ await serve(import.meta.url, {
111
111
 
112
112
  const post = async (app, mode, target) => {
113
113
  const location = app.get("location");
114
- const defaults = join(import.meta.dirname, "../defaults");
114
+ const defaults = join(import.meta.url, "../../defaults");
115
115
 
116
116
  // stage routes
117
117
  await app.stage(app.path.routes, join(location.server, location.routes));
@@ -122,7 +122,7 @@ const post = async (app, mode, target) => {
122
122
  // stage components, transforming defines
123
123
  await app.stage(app.path.components, location.components, true);
124
124
 
125
- const directory = app.runpath(location.routes);
125
+ const directory = app.runpath(location.server, location.routes);
126
126
  for (const path of await directory.collect()) {
127
127
  await app.bindings[path.extension]
128
128
  ?.(directory, path.debase(`${directory}/`));
@@ -135,9 +135,6 @@ const post = async (app, mode, target) => {
135
135
  // copy static files to build/server/static
136
136
  await app.stage(app.path.static, join(location.server, location.static));
137
137
 
138
- // copy static files to build/client/static
139
- await app.stage(app.path.static, join(location.client, location.static));
140
-
141
138
  // publish JavaScript and CSS files
142
139
  const imports = await collect(app.path.static, /\.(?:css)$/u);
143
140
  await Promise.all(imports.map(async file => {
@@ -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 re = /app..*(?:js|css)$/u;
12
- const $imports = (await client.collect(re, { recursive: false })).map((file, i) => {
13
- const type = file.extension === ".css" ? "style" : "js";
14
- const src = `${http.static.root}${file.debase(client).name}`;
15
- const path = `./${file.debase(`${app.path.build}/`)}`;
16
- return {
17
- src,
18
- path,
19
- code: `await load_text(asset${i})`,
20
- type,
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
- ${$imports.map(({ path }, i) =>
35
- `const asset${i} = await load_text(import.meta.dirname, "${path}");`)
32
+ ${client_imports.map(({ path }, i) =>
33
+ `const asset${i} = await load_text(import.meta.url, "../${path}");`)
36
34
  .join("\n ")}
37
- const assets = [${$imports.map(($import, i) => `{
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
- app: "${join(http.static.root, $imports.find($import =>
46
- $import.src.includes("app") && $import.src.endsWith(".js")).src).webpath()}"
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
  };
@@ -0,0 +1,11 @@
1
+ export default [
2
+ "get",
3
+ "post",
4
+ "put",
5
+ "delete",
6
+ "head",
7
+ "connect",
8
+ "options",
9
+ "trace",
10
+ "patch",
11
+ ];