@primate/htmx 0.21.0 → 0.23.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.
- package/lib/private/Default.js +11 -7
- package/lib/private/Runtime.js +6 -6
- package/lib/public/browser.d.ts +3 -0
- package/lib/public/browser.js +2 -0
- package/package.json +14 -16
package/lib/private/Default.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import Runtime from "#Runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import is from "@rcompat/is";
|
|
3
|
+
import string from "@rcompat/string";
|
|
4
4
|
const htmx_esm = "htmx-esm";
|
|
5
5
|
const _export = `export * from "${htmx_esm}`;
|
|
6
6
|
export default class Default extends Runtime {
|
|
7
7
|
#extensions;
|
|
8
8
|
#templates;
|
|
9
9
|
compile = {
|
|
10
|
-
server: (text) => dedent `
|
|
10
|
+
server: (text) => string.dedent `
|
|
11
11
|
import render from "@primate/htmx/render";
|
|
12
12
|
|
|
13
13
|
export default props => render(${JSON.stringify(text)}, props);`,
|
|
@@ -19,15 +19,19 @@ export default class Default extends Runtime {
|
|
|
19
19
|
}
|
|
20
20
|
get #has_templates() {
|
|
21
21
|
return this.#extensions.includes("client-side-templates") &&
|
|
22
|
-
!empty(this.#templates);
|
|
22
|
+
!is.empty(this.#templates);
|
|
23
23
|
}
|
|
24
24
|
publish(app) {
|
|
25
|
-
app.
|
|
26
|
-
this.#extensions.
|
|
25
|
+
app.entrypoint(`export { default as htmx } from "${htmx_esm}";`);
|
|
26
|
+
this.#extensions.forEach(extension => {
|
|
27
|
+
app.entrypoint(`export * from "${htmx_esm}/${extension}";`);
|
|
28
|
+
});
|
|
27
29
|
if (this.#has_templates) {
|
|
28
30
|
this.#templates
|
|
29
31
|
.filter(template => template !== "xslt")
|
|
30
|
-
.
|
|
32
|
+
.forEach(template => {
|
|
33
|
+
app.entrypoint(`export * from "${htmx_esm}/templates/${template}";`);
|
|
34
|
+
});
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
}
|
package/lib/private/Runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import fail from "@primate/core/fail";
|
|
1
2
|
import FrontendModule from "@primate/core/frontend/Module";
|
|
2
|
-
import inline from "@primate/core/inline";
|
|
3
3
|
import response from "@primate/html/response";
|
|
4
4
|
export default class Runtime extends FrontendModule {
|
|
5
5
|
name = "htmx";
|
|
@@ -8,12 +8,12 @@ export default class Runtime extends FrontendModule {
|
|
|
8
8
|
client = false;
|
|
9
9
|
respond = (name, props, options = {}) => {
|
|
10
10
|
return async (app, _, request) => {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const app_js = app.assets.find(asset => asset.src?.includes("app") && asset.src.endsWith(".js"));
|
|
12
|
+
if (!app_js)
|
|
13
|
+
throw fail("Could not find app.js in assets");
|
|
14
|
+
const script = `<script type="module" src="${app_js.src}"></script>`;
|
|
14
15
|
return response(this)(name, props, {
|
|
15
|
-
|
|
16
|
-
head,
|
|
16
|
+
head: script,
|
|
17
17
|
partial: Boolean(request.headers.try("hx-request")),
|
|
18
18
|
...options,
|
|
19
19
|
})(app, _, request);
|
package/package.json
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/htmx",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.23.0",
|
|
4
|
+
"description": "HTMX for Primate",
|
|
5
5
|
"homepage": "https://primate.run/docs/frontend/htmx",
|
|
6
6
|
"bugs": "https://github.com/primate-run/primate/issues",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"license": "MIT",
|
|
8
|
-
"files": [
|
|
9
|
-
"/lib/**/*.js",
|
|
10
|
-
"/lib/**/*.d.ts",
|
|
11
|
-
"!/**/*.spec.*"
|
|
12
|
-
],
|
|
13
9
|
"repository": {
|
|
14
10
|
"type": "git",
|
|
15
11
|
"url": "https://github.com/primate-run/primate",
|
|
16
12
|
"directory": "packages/htmx"
|
|
17
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"/lib/**/*.js",
|
|
16
|
+
"/lib/**/*.d.ts",
|
|
17
|
+
"!/**/*.spec.*"
|
|
18
|
+
],
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@rcompat/
|
|
20
|
-
"@rcompat/
|
|
21
|
-
"@rcompat/html": "^0.6.0",
|
|
22
|
-
"@rcompat/record": "^0.9.1",
|
|
23
|
-
"@rcompat/string": "^0.10.0",
|
|
20
|
+
"@rcompat/is": "^0.4.2",
|
|
21
|
+
"@rcompat/string": "^0.13.0",
|
|
24
22
|
"htmx-esm": "^0.2.1910",
|
|
25
|
-
"@primate/core": "^0.
|
|
26
|
-
"@primate/html": "^0.
|
|
23
|
+
"@primate/core": "^0.5.0",
|
|
24
|
+
"@primate/html": "^0.16.0"
|
|
27
25
|
},
|
|
28
26
|
"peerDependencies": {
|
|
29
|
-
"primate": "^0.
|
|
27
|
+
"primate": "^0.36.0"
|
|
30
28
|
},
|
|
31
|
-
"type": "module",
|
|
32
29
|
"imports": {
|
|
33
30
|
"#*": {
|
|
34
31
|
"apekit": "./src/private/*.ts",
|
|
@@ -37,6 +34,7 @@
|
|
|
37
34
|
},
|
|
38
35
|
"exports": {
|
|
39
36
|
".": {
|
|
37
|
+
"browser": "./lib/public/browser.js",
|
|
40
38
|
"runtime": "./lib/public/runtime.js",
|
|
41
39
|
"default": "./lib/public/default.js"
|
|
42
40
|
},
|