primate 0.22.0 → 0.22.2

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.22.0",
3
+ "version": "0.22.2",
4
4
  "description": "Expressive, minimal and extensible web framework",
5
5
  "homepage": "https://primatejs.com",
6
6
  "bugs": "https://github.com/primatejs/primate/issues",
@@ -18,7 +18,7 @@
18
18
  "directory": "packages/primate"
19
19
  },
20
20
  "dependencies": {
21
- "runtime-compat": "^0.25.7"
21
+ "runtime-compat": "^0.25.8"
22
22
  },
23
23
  "engines": {
24
24
  "node": ">=18.16"
package/src/app.js CHANGED
@@ -88,10 +88,11 @@ export default async (log, root, config) => {
88
88
  const target = this.runpath(directory);
89
89
 
90
90
  await Promise.all((await source.collect(filter)).map(async path => {
91
+ const debased = path.debase(this.root).path.slice(1);
91
92
  const filename = new Path(directory).join(path.debase(source));
92
93
  const to = await target.join(filename.debase(directory));
93
94
  await to.directory.file.create();
94
- if (regexs.some(regex => regex.test(filename))) {
95
+ if (regexs.some(regex => regex.test(debased))) {
95
96
  const contents = mapper(await path.text());
96
97
  await to.file.write(contents);
97
98
  } else {
@@ -9,7 +9,7 @@ const {NoFileForPath} = _errors;
9
9
  const guardError = Symbol("guardError");
10
10
 
11
11
  export default app => {
12
- const {config: {http: {static: {root}}}, location} = app;
12
+ const {config: {http: {static: {root}}, location}} = app;
13
13
 
14
14
  const as_route = async request => {
15
15
  const {pathname} = request.url;
@@ -64,13 +64,13 @@ export default app => {
64
64
  },
65
65
  });
66
66
 
67
- const client = app.runpath(app.config.location.client);
67
+ const client = app.runpath(location.client);
68
68
  const handle = async request => {
69
69
  const {pathname} = request.url;
70
70
  if (pathname.startsWith(root)) {
71
71
  const debased = pathname.replace(root, _ => "");
72
72
  // try static first
73
- const asset = app.path.build.join(app.config.location.static, debased);
73
+ const asset = client.join(location.static, debased);
74
74
  if (await asset.isFile) {
75
75
  return as_asset(asset.file);
76
76
  }
@@ -1,5 +1,6 @@
1
1
  import {Path} from "runtime-compat/fs";
2
2
  import {cascade} from "runtime-compat/async";
3
+ import {stringify} from "runtime-compat/object";
3
4
  import copy_includes from "./copy_includes.js";
4
5
 
5
6
  const post = async app => {
@@ -17,23 +18,21 @@ const post = async app => {
17
18
  });
18
19
 
19
20
  if (await path.components.exists) {
20
- // copy .js files from components to build/client, since frontend
21
- // frameworks handle non-js files
21
+ // copy .js files from components to build/client/components, since
22
+ // frontend frameworks handle non-js files
22
23
  const to = Path.join(location.client, location.components);
23
24
  await app.stage(path.components, to, /^.*.js$/u);
24
25
  }
25
26
 
26
27
  const imports = {...app.importmaps, app: src.path};
27
- await app.publish({
28
- inline: true,
29
- code: JSON.stringify({imports}, null, 2),
30
- type: "importmap",
31
- });
28
+ const inline = true;
29
+ const type = "importmap";
30
+ await app.publish({inline, code: stringify({imports}), type});
32
31
  }
33
32
 
34
33
  if (await path.static.exists) {
35
34
  // copy static files to build/static
36
- await app.stage(path.static, location.static);
35
+ await app.stage(path.static, new Path(location.client, location.static));
37
36
 
38
37
  // publish JavaScript and CSS files
39
38
  const imports = await Path.collect(path.static, /\.(?:js|css)$/u);
@@ -44,7 +43,7 @@ const post = async app => {
44
43
  // already copied in `app.stage`
45
44
  await app.publish({src, code, type, copy: false});
46
45
  type === "style" && app.export({type,
47
- code: `import "../${location.static}${src}";`});
46
+ code: `import "../${location.client}/${location.static}${src}";`});
48
47
  }));
49
48
  }
50
49