primate 0.21.2 → 0.21.4
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 +1 -1
- package/src/app.js +14 -14
- package/src/loaders/routes.js +4 -4
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -21,7 +21,7 @@ const fallback = (app, page) =>
|
|
|
21
21
|
|
|
22
22
|
// use user-provided file or fall back to default
|
|
23
23
|
const index = (app, page) =>
|
|
24
|
-
tryreturn(_ => File.read(`${app.paths.pages.join(
|
|
24
|
+
tryreturn(_ => File.read(`${app.paths.pages.join(page)}`))
|
|
25
25
|
.orelse(_ => fallback(app, page));
|
|
26
26
|
|
|
27
27
|
const encoder = new TextEncoder();
|
|
@@ -83,15 +83,15 @@ export default async (config, root, log) => {
|
|
|
83
83
|
}));
|
|
84
84
|
},
|
|
85
85
|
headers() {
|
|
86
|
-
const csp = Object.keys(http.csp).reduce((
|
|
87
|
-
`${
|
|
86
|
+
const csp = Object.keys(http.csp).reduce((policy, key) =>
|
|
87
|
+
`${policy}${key} ${http.csp[key]};`, "")
|
|
88
88
|
.replace("script-src 'self'", `script-src 'self' ${
|
|
89
|
-
|
|
89
|
+
this.assets
|
|
90
90
|
.filter(({type}) => type !== "style")
|
|
91
91
|
.map(asset => `'${asset.integrity}'`).join(" ")
|
|
92
92
|
} `)
|
|
93
93
|
.replace("style-src 'self'", `style-src 'self' ${
|
|
94
|
-
|
|
94
|
+
this.assets
|
|
95
95
|
.filter(({type}) => type === "style")
|
|
96
96
|
.map(asset => `'${asset.integrity}'`).join(" ")
|
|
97
97
|
} `);
|
|
@@ -103,7 +103,7 @@ export default async (config, root, log) => {
|
|
|
103
103
|
},
|
|
104
104
|
handlers: {...handlers},
|
|
105
105
|
async render({body = "", page} = {}) {
|
|
106
|
-
const html = await index(
|
|
106
|
+
const html = await index(this, page ?? config.pages.index);
|
|
107
107
|
// inline: <script type integrity>...</script>
|
|
108
108
|
// outline: <script type integrity src></script>
|
|
109
109
|
const script = ({inline, code, type, integrity, src}) => inline
|
|
@@ -141,16 +141,16 @@ export default async (config, root, log) => {
|
|
|
141
141
|
this.entrypoints.push({type, code});
|
|
142
142
|
},
|
|
143
143
|
async import(module) {
|
|
144
|
-
const {build} = config;
|
|
145
|
-
const
|
|
146
|
-
const path = [library, ...
|
|
144
|
+
const {build: {modules}, http: {static: {root}}} = this.config;
|
|
145
|
+
const parts = module.split("/");
|
|
146
|
+
const path = [library, ...parts];
|
|
147
147
|
const pkg = await Path.resolve().join(...path, packager).json();
|
|
148
148
|
const exports = pkg.exports === undefined
|
|
149
149
|
? {[module]: `/${module}/${pkg.main}`}
|
|
150
150
|
: transform(pkg.exports, entry => entry
|
|
151
|
-
.filter(([,
|
|
152
|
-
||
|
|
153
|
-
||
|
|
151
|
+
.filter(([, export$]) => export$.browser?.default !== undefined
|
|
152
|
+
|| export$.import !== undefined
|
|
153
|
+
|| export$.default !== undefined)
|
|
154
154
|
.map(([key, value]) => [
|
|
155
155
|
key.replace(".", module),
|
|
156
156
|
value.browser?.default.replace(".", `./${module}`)
|
|
@@ -158,10 +158,10 @@ export default async (config, root, log) => {
|
|
|
158
158
|
?? value.import?.replace(".", `./${module}`),
|
|
159
159
|
]));
|
|
160
160
|
const dependency = Path.resolve().join(...path);
|
|
161
|
-
const to = new Path(this.build.paths.client,
|
|
161
|
+
const to = new Path(this.build.paths.client, modules, ...parts);
|
|
162
162
|
await dependency.file.copy(to);
|
|
163
163
|
this.importmaps = {
|
|
164
|
-
...valmap(exports, value => new Path(root,
|
|
164
|
+
...valmap(exports, value => new Path(root, modules, value).path),
|
|
165
165
|
...this.importmaps};
|
|
166
166
|
},
|
|
167
167
|
types,
|
package/src/loaders/routes.js
CHANGED
|
@@ -26,7 +26,7 @@ const make = path => {
|
|
|
26
26
|
const specials = ["guards", "errors", "layouts"];
|
|
27
27
|
export default async (log, directory, load = fs) => {
|
|
28
28
|
const routes = await get.routes(log, directory, load);
|
|
29
|
-
const $
|
|
29
|
+
const routes$ = from(await Promise.all(specials.map(async extra =>
|
|
30
30
|
[extra, await get[extra](log, directory, load)])));
|
|
31
31
|
const filter = path => ([name]) => path.includes(name);
|
|
32
32
|
|
|
@@ -40,9 +40,9 @@ export default async (log, directory, load = fs) => {
|
|
|
40
40
|
method,
|
|
41
41
|
handler,
|
|
42
42
|
pathname: make(path.endsWith("/") ? path.slice(0, -1) : path),
|
|
43
|
-
guards:
|
|
44
|
-
errors:
|
|
45
|
-
layouts:
|
|
43
|
+
guards: routes$.guards.filter(filter(path)).map(([, guard]) => guard),
|
|
44
|
+
errors: routes$.errors.filter(filter(path)).map(([, error]) => error),
|
|
45
|
+
layouts: routes$.layouts.filter(filter(path)).map(([, layout]) => layout),
|
|
46
46
|
}));
|
|
47
47
|
}).flat();
|
|
48
48
|
};
|