hx-stream 0.0.1 → 0.0.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/dist/client.min.js +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};!function(){let e;globalThis.htmx.defineExtension("hx-stream",{init:t=>{e=t},onEvent:(r,n)=>{if("htmx:beforeRequest"!==r);else{const r=n.detail.elt;if("on"!==e.getAttributeValue(r,"hx-stream"))return;n.preventDefault();const o=n.detail.requestConfig.formData,i=n.detail.requestConfig.headers,s=n.detail.requestConfig.path;(function(r,n,o,i,s){return __awaiter(this,void 0,void 0,(function*(){s.classList.add("htmx-request");const a=yield fetch(n,{method:r,headers:o,body:i});if(!a.ok)return console.error(yield a.text()),void s.classList.remove("htmx-request");if(!a.body)return console.error("hx-stream response is missing body"),void s.classList.remove("htmx-request");const c=a.body.getReader();for(;;){const{done:r,value:n}=yield c.read();if(r)break;const o=t.decode(n).trim();""!==o&&e.swap(s,o,{swapStyle:"beforeend"})}s.classList.remove("htmx-request")}))})(n.detail.requestConfig.verb,s,i,o,n.detail.target).catch(console.error)}}});const t=new TextDecoder("utf8")}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hx-stream",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "keep htmx client state across page refreshes",
|
|
5
5
|
"keywords": [ "htmx", "streaming" ],
|
|
6
6
|
"homepage": "https://hx-stream.ajanibilby.com",
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "npm run build:client & npm run build:server",
|
|
16
|
-
"build:client": "tsc --project tsconfig.client.json
|
|
17
|
-
"build:server": "tsc --project tsconfig.server.json"
|
|
16
|
+
"build:client": "tsc --project tsconfig.client.json",
|
|
17
|
+
"build:server": "tsc --project tsconfig.server.json",
|
|
18
|
+
"minify": "npm run minify:client",
|
|
19
|
+
"minify:client": "terser dist/client.js --compress --mangle --output dist/client.min.js"
|
|
18
20
|
},
|
|
19
21
|
"license": "MIT",
|
|
20
22
|
"author": "Ajani Bilby",
|