@primate/htmx 0.14.0 → 0.15.0

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 (3) hide show
  1. package/README.md +3 -15
  2. package/package.json +3 -3
  3. package/src/module.js +5 -11
package/README.md CHANGED
@@ -1,17 +1,5 @@
1
- # Primate HTMX module
1
+ # HTMX
2
2
 
3
- ## Install
3
+ This handler module serves HTMX components with the .htmx extension.
4
4
 
5
- `npm i @primate/htmx`
6
-
7
- ## Configure
8
-
9
- Add to `primate.config.js`
10
-
11
- ```js
12
- import htmx from "@primate/htmx";
13
-
14
- export default {
15
- modules: [htmx()],
16
- };
17
- ```
5
+ ## [Documentation](https://primatejs.com/modules/htmx)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/htmx",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Primate HTMX module",
5
5
  "homepage": "https://primatejs.com/modules/htmx",
6
6
  "bugs": "https://github.com/primatejs/primate/issues",
@@ -16,10 +16,10 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "htmx.org": "^1.9.2",
19
- "runtime-compat": "^0.17.0"
19
+ "runtime-compat": "^0.20.2"
20
20
  },
21
21
  "peerDependencies": {
22
- "primate": "0.19"
22
+ "primate": "0.20"
23
23
  },
24
24
  "type": "module",
25
25
  "exports": "./src/exports.js"
package/src/module.js CHANGED
@@ -1,5 +1,3 @@
1
- import {Path} from "runtime-compat/fs";
2
-
3
1
  const loadComponent = async (file) => {
4
2
  try {
5
3
  return await file.read();
@@ -14,7 +12,8 @@ const getBody = async (app, partial, file) => {
14
12
  };
15
13
 
16
14
  const handler = path => (name, {status = 200, partial = false} = {}) =>
17
- async (app, headers) => {
15
+ async app => {
16
+ const headers = app.headers();
18
17
  const styleSrc = "style-src 'self' 'unsafe-inline';";
19
18
  const csp = `${headers["Content-Security-Policy"]}${styleSrc}`;
20
19
  const options = {
@@ -35,14 +34,9 @@ export default directory => ({
35
34
  return next(app);
36
35
  },
37
36
  async publish(app, next) {
38
- const src = "htmx.js";
39
- const scriptPath = ["node_modules", "htmx.org", "dist", src];
40
- const path = import.meta.resolve === undefined
41
- ? await Path.resolve().join(...scriptPath)
42
- : new Path(await import.meta.resolve("htmx.org"));
43
- const code = await path.file.read();
44
- await app.publish({src, code, type: "module"});
45
- app.bootstrap({type: "script", code: `import * as htmx from "./${src}";`});
37
+ const name = "htmx.org";
38
+ await app.import(name);
39
+ app.bootstrap({type: "script", code: `import * as htmx from "${name}";`});
46
40
  return next(app);
47
41
  },
48
42
  });