@primate/core 0.1.4 → 0.1.5

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.4",
3
+ "version": "0.1.5",
4
4
  "description": "Primate core",
5
5
  "homepage": "https://primatejs.com",
6
6
  "bugs": "https://github.com/primatejs/primate/issues",
@@ -21,9 +21,9 @@
21
21
  "@rcompat/build": "^0.4.0",
22
22
  "@rcompat/cli": "^0.5.1",
23
23
  "@rcompat/crypto": "^0.5.0",
24
- "@rcompat/fs": "^0.4.1",
24
+ "@rcompat/fs": "^0.5.0",
25
25
  "@rcompat/function": "^0.4.0",
26
- "@rcompat/http": "^0.5.2",
26
+ "@rcompat/http": "^0.5.3",
27
27
  "@rcompat/invariant": "^0.5.0",
28
28
  "@rcompat/object": "^0.5.0",
29
29
  "@rcompat/package": "^0.7.0",
@@ -11,6 +11,7 @@ import manifest from "@rcompat/package/manifest";
11
11
  import root from "@rcompat/package/root";
12
12
  import copy_includes from "./copy_includes.js";
13
13
  import $router from "./router.js";
14
+ import webpath from "@rcompat/fs/webpath";
14
15
 
15
16
  const pre = async (app, mode, target) => {
16
17
  let target$ = target;
@@ -52,12 +53,12 @@ const write_directories = async (build_directory, app) => {
52
53
  for (const name of app.server_build) {
53
54
  const d = app.runpath(name);
54
55
  const e = await Promise.all((await collect(d, js_re, { recursive: true }))
55
- .map(async file => `${file}`.replace(d, _ => "")));
56
+ .map(async path => `${path}`.replace(d, _ => "")));
56
57
  const files_js = `
57
58
  const ${name} = [];
58
- ${e.map((file , i) =>
59
- `import * as ${name}${i} from "../${name}${file}";
60
- ${name}.push(["${file.slice(1, -".js".length)}", ${name}${i}]);`,
59
+ ${e.map((path, i) =>
60
+ `import * as ${name}${i} from "${webpath(`../${name}${path}`)}";
61
+ ${name}.push(["${webpath(path.slice(1, -".js".length))}", ${name}${i}]);`,
61
62
  ).join("\n")}
62
63
  export default ${name};`;
63
64
  await build_directory.join(`${name}.js`).write(files_js);
@@ -68,16 +69,16 @@ const write_components = async (build_directory, app) => {
68
69
  const location = app.get("location");
69
70
  const d2 = app.runpath(location.server, location.components);
70
71
  const e = await Promise.all((await collect(d2, js_re, { recursive: true }))
71
- .map(async file => `${file}`.replace(d2, _ => "")));
72
+ .map(async path => `${path}`.replace(d2, _ => "")));
72
73
  const components_js = `
73
74
  const components = [];
74
75
  ${e.map((component, i) =>
75
- `import * as component${i} from "../server/components${component}";
76
- components.push(["${component.slice(1, -".js".length)}", component${i}]);`,
76
+ `import * as component${i} from "${webpath(`../server/components${component}`)}";
77
+ components.push(["${webpath(component.slice(1, -".js".length))}", component${i}]);`,
77
78
  ).join("\n")}
78
79
 
79
80
  ${app.roots.map((root, i) => `
80
- import * as root${i} from "${root}";
81
+ import * as root${i} from "${webpath(`../server/${root.name}`)}";
81
82
  components.push(["${root.name}", root${i}]);
82
83
  `).join("\n")}
83
84
 
@@ -1,4 +1,5 @@
1
1
  import collect from "@rcompat/fs/collect";
2
+ import webpath from "@rcompat/fs/webpath";
2
3
 
3
4
  const html = /^.*.html$/u;
4
5
 
@@ -20,9 +21,9 @@ export default async app => {
20
21
  });
21
22
  const d = app.runpath(location.pages);
22
23
  const pages = await Promise.all((await collect(d, html, { recursive: true }))
23
- .map(async file => `${file}`.replace(`${d}/`, _ => "")));
24
+ .map(async file => `${file.debase(d)}`.slice(1)));
24
25
  const pages_str = pages.map(page =>
25
- `"${page}": await join(import.meta.url, "../${location.pages}/${page}").text(),`).join("\n");
26
+ `"${page}": await join(import.meta.url, "${webpath(`../${location.pages}/${page}`)}").text(),`).join("\n");
26
27
 
27
28
  const assets_scripts = `
28
29
  import file from "@rcompat/fs/file";
@@ -80,11 +81,11 @@ export default async app => {
80
81
  },
81
82
  async asset(pathname) {
82
83
  const root_asset = buildroot.join(\`client/\${pathname}\`);
83
- if (await await root_asset.isFile) {
84
+ if (await await root_asset.isFile()) {
84
85
  return serve_asset(root_asset);
85
86
  }
86
87
  const static_asset = buildroot.join(\`client/static/\${pathname}\`);
87
- if (await static_asset.isFile) {
88
+ if (await static_asset.isFile()) {
88
89
  return serve_asset(static_asset);
89
90
  }
90
91
  },