@primate/htmx 0.3.1 → 0.3.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 +1 -1
- package/src/handler.js +5 -4
package/package.json
CHANGED
package/src/handler.js
CHANGED
|
@@ -16,7 +16,8 @@ const getIndex = async env => {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const fileName = "htmx.min.js";
|
|
20
|
+
const scriptPath = ["node_modules", "htmx.org", "dist", fileName];
|
|
20
21
|
|
|
21
22
|
const hash = async (string, algorithm = "sha-384") => {
|
|
22
23
|
const buffer = new ArrayBuffer(string.length);
|
|
@@ -29,17 +30,17 @@ const hash = async (string, algorithm = "sha-384") => {
|
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export default (strings, ...keys) => async (env, headers) => {
|
|
32
|
-
// if doesn't exist, copy htmx
|
|
33
|
+
// if doesn't exist, copy htmx file to public
|
|
33
34
|
// if public doesn't exist, create it
|
|
34
35
|
const _public = env.paths.public;
|
|
35
36
|
if (!await _public.exists) {
|
|
36
37
|
await _public.file.create();
|
|
37
38
|
}
|
|
38
|
-
const htmx = _public.join(
|
|
39
|
+
const htmx = _public.join(fileName);
|
|
39
40
|
if (!await htmx.exists) {
|
|
40
41
|
await Path.resolve().join(...scriptPath).file.copy(`${htmx}`);
|
|
41
42
|
}
|
|
42
|
-
const src =
|
|
43
|
+
const src = `/${fileName}`;
|
|
43
44
|
const integrity = `sha384-${await hash(await htmx.file.read())}`;
|
|
44
45
|
const script = `<script src="${src}" integrity="${integrity}"></script>`;
|
|
45
46
|
const index = (await getIndex(env)).replace("</head>", `${script}</head>`);
|