@primate/core 0.1.6 → 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.6",
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,27 +18,27 @@
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.0",
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",
30
- "@rcompat/platform": "^0.3.0",
29
+ "@rcompat/package": "^0.8.0",
30
+ "@rcompat/runtime": "^0.1.0",
31
31
  "@rcompat/stdio": "^0.5.0",
32
32
  "@rcompat/sync": "^0.3.0"
33
33
  },
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
  }
@@ -38,7 +38,7 @@ const pre = async (app, mode, target) => {
38
38
  await app.path.build.remove();
39
39
  await app.path.build.create();
40
40
 
41
- await Promise.all(["server", "client", "pages", "components"]
41
+ await Promise.all(["server", "client", "components"]
42
42
  .map(directory => app.runpath(directory).create()));
43
43
 
44
44
  const router = await $router(app.path.routes);
@@ -50,14 +50,15 @@ const pre = async (app, mode, target) => {
50
50
 
51
51
  const js_re = /^.*.js$/u;
52
52
  const write_directories = async (build_directory, app) => {
53
+ const location = app.get("location");
53
54
  for (const name of app.server_build) {
54
- const d = app.runpath(name);
55
+ const d = app.runpath(location.server, name);
55
56
  const e = await Promise.all((await collect(d, js_re, { recursive: true }))
56
57
  .map(async path => `${path}`.replace(d, _ => "")));
57
58
  const files_js = `
58
59
  const ${name} = [];
59
60
  ${e.map((path, i) =>
60
- `import * as ${name}${i} from "${webpath(`../${name}${path}`)}";
61
+ `import * as ${name}${i} from "${webpath(`../server/${name}${path}`)}";
61
62
  ${name}.push(["${webpath(path.slice(1, -".js".length))}", ${name}${i}]);`,
62
63
  ).join("\n")}
63
64
  export default ${name};`;
@@ -110,33 +111,30 @@ await serve(import.meta.url, {
110
111
 
111
112
  const post = async (app, mode, target) => {
112
113
  const location = app.get("location");
113
- const defaults = join(import.meta.dirname, "../defaults");
114
+ const defaults = join(import.meta.url, "../../defaults");
114
115
 
115
116
  // stage routes
116
- await app.stage(app.path.routes, location.routes);
117
+ await app.stage(app.path.routes, join(location.server, location.routes));
117
118
 
118
119
  // stage types
119
- await app.stage(app.path.types, location.types);
120
+ await app.stage(app.path.types, join(location.server, location.types));
120
121
 
121
122
  // stage components, transforming defines
122
123
  await app.stage(app.path.components, location.components, true);
123
124
 
124
- const directory = app.runpath(location.routes);
125
+ const directory = app.runpath(location.server, location.routes);
125
126
  for (const path of await directory.collect()) {
126
127
  await app.bindings[path.extension]
127
128
  ?.(directory, path.debase(`${directory}/`));
128
129
  }
129
130
  // copy framework pages
130
- await app.stage(defaults, location.pages);
131
+ await app.stage(defaults, join(location.server, location.pages));
131
132
  // overwrite transformed pages to build
132
- await app.stage(app.path.pages, location.pages);
133
+ await app.stage(app.path.pages, join(location.server, location.pages));
133
134
 
134
135
  // copy static files to build/server/static
135
136
  await app.stage(app.path.static, join(location.server, location.static));
136
137
 
137
- // copy static files to build/client/static
138
- await app.stage(app.path.static, join(location.client, location.static));
139
-
140
138
  // publish JavaScript and CSS files
141
139
  const imports = await collect(app.path.static, /\.(?:css)$/u);
142
140
  await Promise.all(imports.map(async file => {
@@ -7,7 +7,7 @@ import tryreturn from "@rcompat/async/tryreturn";
7
7
  import empty from "@rcompat/object/empty";
8
8
  import override from "@rcompat/object/override";
9
9
  import root from "@rcompat/package/root";
10
- import platform from "@rcompat/platform";
10
+ import runtime from "@rcompat/runtime";
11
11
  import app from "./app.js";
12
12
  import { build, init } from "./hook/exports.js";
13
13
 
@@ -25,7 +25,7 @@ const get_config = async project_root => {
25
25
  return imported;
26
26
  } catch (error) {
27
27
  if (error.level === undefined) {
28
- error_in_config_file(error.message, `${platform} ${local_config}`);
28
+ error_in_config_file(error.message, `${runtime} ${local_config}`);
29
29
  } else {
30
30
  throw error;
31
31
  }
@@ -1,40 +1,38 @@
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
- });
23
- const d = app.runpath(location.pages);
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
+ });
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)));
26
24
  const pages_str = pages.map(page =>
27
25
  `"${page}": await load_text(import.meta.url,
28
- "${webpath(`../${location.pages}/${page}`)}"),`).join("\n");
26
+ "${webpath(`../${location.server}/${location.pages}/${page}`)}"),`).join("\n");
29
27
 
30
28
  const assets_scripts = `
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
+ ];