@primate/htmx 0.2.0 → 0.3.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/handler.js +7 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/htmx",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "author": "Terrablue <terrablue@proton.me>",
5
5
  "homepage": "https://primatejs.com/modules/htmx",
6
6
  "bugs": "https://github.com/primatejs/primate-htmx/issues",
package/src/handler.js CHANGED
@@ -16,7 +16,7 @@ const getIndex = async env => {
16
16
  }
17
17
  };
18
18
 
19
- const scriptPath = ["node_modules", "htmx.org", "dist", "htmx.js"];
19
+ const scriptPath = ["node_modules", "htmx.org", "dist", "htmx.min.js"];
20
20
 
21
21
  const hash = async (string, algorithm = "sha-384") => {
22
22
  const buffer = new ArrayBuffer(string.length);
@@ -30,11 +30,15 @@ const hash = async (string, algorithm = "sha-384") => {
30
30
 
31
31
  export default (strings, ...keys) => async (env, headers) => {
32
32
  // if doesn't exist, copy htmx.js to public
33
- const htmx = env.paths.public.join("htmx.js");
33
+ // if public doesn't exist, create it
34
+ const _public = env.paths.public;
35
+ if (!await _public.exists) {
36
+ await _public.file.create();
37
+ }
38
+ const htmx = _public.join("htmx.js");
34
39
  if (!await htmx.exists) {
35
40
  await Path.resolve().join(...scriptPath).file.copy(`${htmx}`);
36
41
  }
37
- //console.log(btoa("sha384-" + await hash(file)));
38
42
  const src = "/htmx.js";
39
43
  const integrity = `sha384-${await hash(await htmx.file.read())}`;
40
44
  const script = `<script src="${src}" integrity="${integrity}"></script>`;