@httpstate/typescript 0.0.2 → 0.0.4

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/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var g=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var a=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of l(t))!u.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(o=s(t,r))||o.enumerable});return e};var i=e=>c(g({},"__esModule",{value:!0}),e);var d={};a(d,{default:()=>b});module.exports=i(d);var b=()=>Object.assign(e=>(console.log("uuid",e),e),{get:()=>{}});
1
+ "use strict";var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of c(t))!m.call(e,r)&&r!==n&&i(e,r,{get:()=>t[r],enumerable:!(s=l(t,r))||s.enumerable});return e};var b=e=>v(i({},"__esModule",{value:!0}),e);var L={};p(L,{default:()=>E,get:()=>o,load:()=>d,read:()=>g,set:()=>a,write:()=>u});module.exports=b(L);var o=async e=>{let t=await fetch("https://httpstate.com/"+e);if(t.status===200)return await t.text()},d=async()=>{for(let e of document.querySelectorAll("[httpState],[httpstate]")){let t=e.getAttribute("httpState")||e.getAttribute("httpstate");console.log("node.uuid",t)}},g=async e=>o(e),a=async(e,t)=>(await fetch("https://httpstate.com/"+e,{body:t,method:"POST"})).status,u=async(e,t)=>a(e,t),f=e=>{let t={addEventListener:(n,s)=>t.et.addEventListener(n,s),data:void 0,et:new EventTarget,get:async()=>o(e),off:(n,s)=>(t.removeEventListener(n,s),t),on:(n,s)=>(t.addEventListener(n,s),t),read:async()=>g(e),removeEventListener:(n,s)=>t.et.removeEventListener(n,s),set:async n=>a(e,n),write:async n=>u(e,n)};return t},E=f;typeof document<"u"&&typeof window<"u"&&(console.log("we do some magic ..."),globalThis===window&&globalThis.httpstate&&(console.log("do the binding yo ..."),globalThis.httpstate=Object.assign(globalThis.httpstate.default,globalThis.httpstate)),window.addEventListener("load",d));0&&(module.exports={get,load,read,set,write});
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// HTTP State, https://httpstate.com/\n// Copyright (C) Alex Morales, 2026\n// \n// Unless otherwise stated in particular files or directories, this software is free software.\n// You can redistribute it and/or modify it under the terms of the GNU Affero\n// General Public License as published by the Free Software Foundation, either\n// version 3 of the License, or (at your option) any later version.\n\nexport default () => { //TYPE\n return Object.assign(\n (uuid:string) => {\n console.log('uuid', uuid);\n\n return uuid;\n },\n {\n get:() => {}\n // ...\n }\n );\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAQA,IAAOE,EAAQ,IACN,OAAO,OACXE,IACC,QAAQ,IAAI,OAAQA,CAAI,EAEjBA,GAET,CACE,IAAI,IAAM,CAAC,CAEb,CACF","names":["index_exports","__export","index_default","__toCommonJS","uuid"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// HTTP State, https://httpstate.com/\n// Copyright (C) Alex Morales, 2026\n// \n// Unless otherwise stated in particular files or directories, this software is free software.\n// You can redistribute it and/or modify it under the terms of the GNU Affero\n// General Public License as published by the Free Software Foundation, either\n// version 3 of the License, or (at your option) any later version.\n\nexport const get:(uuid:string) => Promise<undefined|string> = async (uuid:string):Promise<undefined|string> => {\n const response:Response = await fetch('https://httpstate.com/' + uuid);\n\n if(response.status === 200)\n return await response.text();\n};\n\nexport const load:() => Promise<void> = async ():Promise<void> => {\n for(const node of document.querySelectorAll('[httpState],[httpstate]')) {\n const uuid:null|string = node.getAttribute('httpState')||node.getAttribute('httpstate');\n\n console.log('node.uuid', uuid);\n\n // const ui = httpState(uuid)\n // .on('change', e => node.innerHTML = e.data);\n\n // ui.et.dispatchEvent(Object.assign(new Event('change'), { data:await ui.get() }));\n }\n};\n\nexport const read:(uuid:string) => Promise<undefined|string> = async (uuid:string):Promise<undefined|string> => get(uuid);\n\nexport const set:(uuid:string, data:string) => Promise<number> = async (uuid:string, data:string):Promise<number> => {\n const response:Response = await fetch('https://httpstate.com/' + uuid, { body:data, method:'POST' });\n\n return response.status;\n};\n\nexport const write:(uuid:string, data:string) => Promise<number> = async (uuid:string, data:string):Promise<number> => set(uuid, data);\n\n// httpState\ntype HttpState = {\n addEventListener(type:string, callback:null|EventListenerOrEventListenerObject):void;\n data?:undefined|string;\n et:EventTarget;\n get():Promise<undefined|string>;\n off(type:string, callback:null|EventListenerOrEventListenerObject):HttpState;\n on(type:string, callback:null|EventListenerOrEventListenerObject):HttpState;\n read():Promise<undefined|string>;\n removeEventListener(type:string, callback:null|EventListenerOrEventListenerObject):void;\n set(data:string):Promise<number>;\n write(data:string):Promise<number>;\n};\n\nconst httpState:(uuid:string) => HttpState = (uuid:string):HttpState => {\n const _:HttpState = {\n addEventListener:(type:string, callback:null|EventListenerOrEventListenerObject) => _.et.addEventListener(type, callback),\n data:undefined,\n et:new EventTarget(),\n get:async ():Promise<undefined|string> => get(uuid),\n off:(type:string, callback:null|EventListenerOrEventListenerObject) => {\n _.removeEventListener(type, callback);\n\n return _;\n },\n on:(type:string, callback:null|EventListenerOrEventListenerObject) => {\n _.addEventListener(type, callback);\n\n return _;\n },\n read:async ():Promise<undefined|string> => read(uuid),\n removeEventListener:(type:string, callback:null|EventListenerOrEventListenerObject) => _.et.removeEventListener(type, callback),\n set:async (data:string):Promise<number> => set(uuid, data),\n write:async (data:string):Promise<number> => write(uuid, data),\n // ws:new WebSocket('wss://httpstate.com/' + uuid)\n };\n\n // ...\n\n return _;\n};\n\nexport default httpState;\n\nif(\n typeof document !== 'undefined'\n && typeof window !== 'undefined'\n) {\n console.log('we do some magic ...');\n\n if(\n globalThis === window\n && (globalThis as any).httpstate\n ) {\n console.log('do the binding yo ...');\n\n (globalThis as any).httpstate = Object.assign(\n (globalThis as any).httpstate.default,\n (globalThis as any).httpstate\n );\n }\n\n window.addEventListener('load', load);\n}\n\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,QAAAC,EAAA,SAAAC,EAAA,SAAAC,EAAA,QAAAC,EAAA,UAAAC,IAAA,eAAAC,EAAAR,GAQO,IAAMG,EAAiD,MAAOM,GAA0C,CAC7G,IAAMC,EAAoB,MAAM,MAAM,yBAA2BD,CAAI,EAErE,GAAGC,EAAS,SAAW,IACrB,OAAO,MAAMA,EAAS,KAAK,CAC/B,EAEaN,EAA2B,SAA0B,CAChE,QAAUO,KAAQ,SAAS,iBAAiB,yBAAyB,EAAG,CACtE,IAAMF,EAAmBE,EAAK,aAAa,WAAW,GAAGA,EAAK,aAAa,WAAW,EAEtF,QAAQ,IAAI,YAAaF,CAAI,CAM/B,CACF,EAEaJ,EAAkD,MAAOI,GAA0CN,EAAIM,CAAI,EAE3GH,EAAoD,MAAOG,EAAaG,KACzD,MAAM,MAAM,yBAA2BH,EAAM,CAAE,KAAKG,EAAM,OAAO,MAAO,CAAC,GAEnF,OAGLL,EAAsD,MAAOE,EAAaG,IAAgCN,EAAIG,EAAMG,CAAI,EAgB/HC,EAAwCJ,GAA0B,CACtE,IAAMK,EAAc,CAClB,iBAAiB,CAACC,EAAaC,IAAqDF,EAAE,GAAG,iBAAiBC,EAAMC,CAAQ,EACxH,KAAK,OACL,GAAG,IAAI,YACP,IAAI,SAAsCb,EAAIM,CAAI,EAClD,IAAI,CAACM,EAAaC,KAChBF,EAAE,oBAAoBC,EAAMC,CAAQ,EAE7BF,GAET,GAAG,CAACC,EAAaC,KACfF,EAAE,iBAAiBC,EAAMC,CAAQ,EAE1BF,GAET,KAAK,SAAsCT,EAAKI,CAAI,EACpD,oBAAoB,CAACM,EAAaC,IAAqDF,EAAE,GAAG,oBAAoBC,EAAMC,CAAQ,EAC9H,IAAI,MAAOJ,GAAgCN,EAAIG,EAAMG,CAAI,EACzD,MAAM,MAAOA,GAAgCL,EAAME,EAAMG,CAAI,CAE/D,EAIA,OAAOE,CACT,EAEOZ,EAAQW,EAGV,OAAO,SAAa,KACpB,OAAO,OAAW,MAErB,QAAQ,IAAI,sBAAsB,EAG7B,aAAe,QACd,WAAmB,YAEvB,QAAQ,IAAI,uBAAuB,EAElC,WAAmB,UAAY,OAAO,OACpC,WAAmB,UAAU,QAC7B,WAAmB,SACtB,GAGF,OAAO,iBAAiB,OAAQT,CAAI","names":["index_exports","__export","index_default","get","load","read","set","write","__toCommonJS","uuid","response","node","data","httpState","_","type","callback"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,20 @@
1
- declare const _default: () => ((uuid: string) => string) & {
2
- get: () => void;
1
+ declare const get: (uuid: string) => Promise<undefined | string>;
2
+ declare const load: () => Promise<void>;
3
+ declare const read: (uuid: string) => Promise<undefined | string>;
4
+ declare const set: (uuid: string, data: string) => Promise<number>;
5
+ declare const write: (uuid: string, data: string) => Promise<number>;
6
+ type HttpState = {
7
+ addEventListener(type: string, callback: null | EventListenerOrEventListenerObject): void;
8
+ data?: undefined | string;
9
+ et: EventTarget;
10
+ get(): Promise<undefined | string>;
11
+ off(type: string, callback: null | EventListenerOrEventListenerObject): HttpState;
12
+ on(type: string, callback: null | EventListenerOrEventListenerObject): HttpState;
13
+ read(): Promise<undefined | string>;
14
+ removeEventListener(type: string, callback: null | EventListenerOrEventListenerObject): void;
15
+ set(data: string): Promise<number>;
16
+ write(data: string): Promise<number>;
3
17
  };
18
+ declare const httpState: (uuid: string) => HttpState;
4
19
 
5
- export { _default as default };
20
+ export { httpState as default, get, load, read, set, write };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,20 @@
1
- declare const _default: () => ((uuid: string) => string) & {
2
- get: () => void;
1
+ declare const get: (uuid: string) => Promise<undefined | string>;
2
+ declare const load: () => Promise<void>;
3
+ declare const read: (uuid: string) => Promise<undefined | string>;
4
+ declare const set: (uuid: string, data: string) => Promise<number>;
5
+ declare const write: (uuid: string, data: string) => Promise<number>;
6
+ type HttpState = {
7
+ addEventListener(type: string, callback: null | EventListenerOrEventListenerObject): void;
8
+ data?: undefined | string;
9
+ et: EventTarget;
10
+ get(): Promise<undefined | string>;
11
+ off(type: string, callback: null | EventListenerOrEventListenerObject): HttpState;
12
+ on(type: string, callback: null | EventListenerOrEventListenerObject): HttpState;
13
+ read(): Promise<undefined | string>;
14
+ removeEventListener(type: string, callback: null | EventListenerOrEventListenerObject): void;
15
+ set(data: string): Promise<number>;
16
+ write(data: string): Promise<number>;
3
17
  };
18
+ declare const httpState: (uuid: string) => HttpState;
4
19
 
5
- export { _default as default };
20
+ export { httpState as default, get, load, read, set, write };
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- var t=()=>Object.assign(e=>(console.log("uuid",e),e),{get:()=>{}});export{t as default};
1
+ var r=async e=>{let t=await fetch("https://httpstate.com/"+e);if(t.status===200)return await t.text()},o=async()=>{for(let e of document.querySelectorAll("[httpState],[httpstate]")){let t=e.getAttribute("httpState")||e.getAttribute("httpstate");console.log("node.uuid",t)}},a=async e=>r(e),i=async(e,t)=>(await fetch("https://httpstate.com/"+e,{body:t,method:"POST"})).status,d=async(e,t)=>i(e,t),g=e=>{let t={addEventListener:(n,s)=>t.et.addEventListener(n,s),data:void 0,et:new EventTarget,get:async()=>r(e),off:(n,s)=>(t.removeEventListener(n,s),t),on:(n,s)=>(t.addEventListener(n,s),t),read:async()=>a(e),removeEventListener:(n,s)=>t.et.removeEventListener(n,s),set:async n=>i(e,n),write:async n=>d(e,n)};return t},u=g;typeof document<"u"&&typeof window<"u"&&(console.log("we do some magic ..."),globalThis===window&&globalThis.httpstate&&(console.log("do the binding yo ..."),globalThis.httpstate=Object.assign(globalThis.httpstate.default,globalThis.httpstate)),window.addEventListener("load",o));export{u as default,r as get,o as load,a as read,i as set,d as write};
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// HTTP State, https://httpstate.com/\n// Copyright (C) Alex Morales, 2026\n// \n// Unless otherwise stated in particular files or directories, this software is free software.\n// You can redistribute it and/or modify it under the terms of the GNU Affero\n// General Public License as published by the Free Software Foundation, either\n// version 3 of the License, or (at your option) any later version.\n\nexport default () => { //TYPE\n return Object.assign(\n (uuid:string) => {\n console.log('uuid', uuid);\n\n return uuid;\n },\n {\n get:() => {}\n // ...\n }\n );\n};\n"],"mappings":"AAQA,IAAOA,EAAQ,IACN,OAAO,OACXC,IACC,QAAQ,IAAI,OAAQA,CAAI,EAEjBA,GAET,CACE,IAAI,IAAM,CAAC,CAEb,CACF","names":["index_default","uuid"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// HTTP State, https://httpstate.com/\n// Copyright (C) Alex Morales, 2026\n// \n// Unless otherwise stated in particular files or directories, this software is free software.\n// You can redistribute it and/or modify it under the terms of the GNU Affero\n// General Public License as published by the Free Software Foundation, either\n// version 3 of the License, or (at your option) any later version.\n\nexport const get:(uuid:string) => Promise<undefined|string> = async (uuid:string):Promise<undefined|string> => {\n const response:Response = await fetch('https://httpstate.com/' + uuid);\n\n if(response.status === 200)\n return await response.text();\n};\n\nexport const load:() => Promise<void> = async ():Promise<void> => {\n for(const node of document.querySelectorAll('[httpState],[httpstate]')) {\n const uuid:null|string = node.getAttribute('httpState')||node.getAttribute('httpstate');\n\n console.log('node.uuid', uuid);\n\n // const ui = httpState(uuid)\n // .on('change', e => node.innerHTML = e.data);\n\n // ui.et.dispatchEvent(Object.assign(new Event('change'), { data:await ui.get() }));\n }\n};\n\nexport const read:(uuid:string) => Promise<undefined|string> = async (uuid:string):Promise<undefined|string> => get(uuid);\n\nexport const set:(uuid:string, data:string) => Promise<number> = async (uuid:string, data:string):Promise<number> => {\n const response:Response = await fetch('https://httpstate.com/' + uuid, { body:data, method:'POST' });\n\n return response.status;\n};\n\nexport const write:(uuid:string, data:string) => Promise<number> = async (uuid:string, data:string):Promise<number> => set(uuid, data);\n\n// httpState\ntype HttpState = {\n addEventListener(type:string, callback:null|EventListenerOrEventListenerObject):void;\n data?:undefined|string;\n et:EventTarget;\n get():Promise<undefined|string>;\n off(type:string, callback:null|EventListenerOrEventListenerObject):HttpState;\n on(type:string, callback:null|EventListenerOrEventListenerObject):HttpState;\n read():Promise<undefined|string>;\n removeEventListener(type:string, callback:null|EventListenerOrEventListenerObject):void;\n set(data:string):Promise<number>;\n write(data:string):Promise<number>;\n};\n\nconst httpState:(uuid:string) => HttpState = (uuid:string):HttpState => {\n const _:HttpState = {\n addEventListener:(type:string, callback:null|EventListenerOrEventListenerObject) => _.et.addEventListener(type, callback),\n data:undefined,\n et:new EventTarget(),\n get:async ():Promise<undefined|string> => get(uuid),\n off:(type:string, callback:null|EventListenerOrEventListenerObject) => {\n _.removeEventListener(type, callback);\n\n return _;\n },\n on:(type:string, callback:null|EventListenerOrEventListenerObject) => {\n _.addEventListener(type, callback);\n\n return _;\n },\n read:async ():Promise<undefined|string> => read(uuid),\n removeEventListener:(type:string, callback:null|EventListenerOrEventListenerObject) => _.et.removeEventListener(type, callback),\n set:async (data:string):Promise<number> => set(uuid, data),\n write:async (data:string):Promise<number> => write(uuid, data),\n // ws:new WebSocket('wss://httpstate.com/' + uuid)\n };\n\n // ...\n\n return _;\n};\n\nexport default httpState;\n\nif(\n typeof document !== 'undefined'\n && typeof window !== 'undefined'\n) {\n console.log('we do some magic ...');\n\n if(\n globalThis === window\n && (globalThis as any).httpstate\n ) {\n console.log('do the binding yo ...');\n\n (globalThis as any).httpstate = Object.assign(\n (globalThis as any).httpstate.default,\n (globalThis as any).httpstate\n );\n }\n\n window.addEventListener('load', load);\n}\n\n"],"mappings":"AAQO,IAAMA,EAAiD,MAAOC,GAA0C,CAC7G,IAAMC,EAAoB,MAAM,MAAM,yBAA2BD,CAAI,EAErE,GAAGC,EAAS,SAAW,IACrB,OAAO,MAAMA,EAAS,KAAK,CAC/B,EAEaC,EAA2B,SAA0B,CAChE,QAAUC,KAAQ,SAAS,iBAAiB,yBAAyB,EAAG,CACtE,IAAMH,EAAmBG,EAAK,aAAa,WAAW,GAAGA,EAAK,aAAa,WAAW,EAEtF,QAAQ,IAAI,YAAaH,CAAI,CAM/B,CACF,EAEaI,EAAkD,MAAOJ,GAA0CD,EAAIC,CAAI,EAE3GK,EAAoD,MAAOL,EAAaM,KACzD,MAAM,MAAM,yBAA2BN,EAAM,CAAE,KAAKM,EAAM,OAAO,MAAO,CAAC,GAEnF,OAGLC,EAAsD,MAAOP,EAAaM,IAAgCD,EAAIL,EAAMM,CAAI,EAgB/HE,EAAwCR,GAA0B,CACtE,IAAMS,EAAc,CAClB,iBAAiB,CAACC,EAAaC,IAAqDF,EAAE,GAAG,iBAAiBC,EAAMC,CAAQ,EACxH,KAAK,OACL,GAAG,IAAI,YACP,IAAI,SAAsCZ,EAAIC,CAAI,EAClD,IAAI,CAACU,EAAaC,KAChBF,EAAE,oBAAoBC,EAAMC,CAAQ,EAE7BF,GAET,GAAG,CAACC,EAAaC,KACfF,EAAE,iBAAiBC,EAAMC,CAAQ,EAE1BF,GAET,KAAK,SAAsCL,EAAKJ,CAAI,EACpD,oBAAoB,CAACU,EAAaC,IAAqDF,EAAE,GAAG,oBAAoBC,EAAMC,CAAQ,EAC9H,IAAI,MAAOL,GAAgCD,EAAIL,EAAMM,CAAI,EACzD,MAAM,MAAOA,GAAgCC,EAAMP,EAAMM,CAAI,CAE/D,EAIA,OAAOG,CACT,EAEOG,EAAQJ,EAGV,OAAO,SAAa,KACpB,OAAO,OAAW,MAErB,QAAQ,IAAI,sBAAsB,EAG7B,aAAe,QACd,WAAmB,YAEvB,QAAQ,IAAI,uBAAuB,EAElC,WAAmB,UAAY,OAAO,OACpC,WAAmB,UAAU,QAC7B,WAAmB,SACtB,GAGF,OAAO,iBAAiB,OAAQN,CAAI","names":["get","uuid","response","load","node","read","set","data","write","httpState","_","type","callback","index_default"]}
@@ -1,2 +1,2 @@
1
- "use strict";var httpstate=(()=>{var g=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var a=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of l(t))!u.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(o=s(t,r))||o.enumerable});return e};var i=e=>c(g({},"__esModule",{value:!0}),e);var d={};a(d,{default:()=>b});var b=()=>Object.assign(e=>(console.log("uuid",e),e),{get:()=>{}});return i(d);})();
1
+ "use strict";var httpstate=(()=>{var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of c(t))!m.call(e,r)&&r!==n&&i(e,r,{get:()=>t[r],enumerable:!(s=l(t,r))||s.enumerable});return e};var b=e=>v(i({},"__esModule",{value:!0}),e);var L={};p(L,{default:()=>E,get:()=>o,load:()=>d,read:()=>g,set:()=>a,write:()=>u});var o=async e=>{let t=await fetch("https://httpstate.com/"+e);if(t.status===200)return await t.text()},d=async()=>{for(let e of document.querySelectorAll("[httpState],[httpstate]")){let t=e.getAttribute("httpState")||e.getAttribute("httpstate");console.log("node.uuid",t)}},g=async e=>o(e),a=async(e,t)=>(await fetch("https://httpstate.com/"+e,{body:t,method:"POST"})).status,u=async(e,t)=>a(e,t),f=e=>{let t={addEventListener:(n,s)=>t.et.addEventListener(n,s),data:void 0,et:new EventTarget,get:async()=>o(e),off:(n,s)=>(t.removeEventListener(n,s),t),on:(n,s)=>(t.addEventListener(n,s),t),read:async()=>g(e),removeEventListener:(n,s)=>t.et.removeEventListener(n,s),set:async n=>a(e,n),write:async n=>u(e,n)};return t},E=f;typeof document<"u"&&typeof window<"u"&&(console.log("we do some magic ..."),globalThis===window&&globalThis.httpstate&&(console.log("do the binding yo ..."),globalThis.httpstate=Object.assign(globalThis.httpstate.default,globalThis.httpstate)),window.addEventListener("load",d));return b(L);})();
2
2
  //# sourceMappingURL=index.global.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// HTTP State, https://httpstate.com/\n// Copyright (C) Alex Morales, 2026\n// \n// Unless otherwise stated in particular files or directories, this software is free software.\n// You can redistribute it and/or modify it under the terms of the GNU Affero\n// General Public License as published by the Free Software Foundation, either\n// version 3 of the License, or (at your option) any later version.\n\nexport default () => { //TYPE\n return Object.assign(\n (uuid:string) => {\n console.log('uuid', uuid);\n\n return uuid;\n },\n {\n get:() => {}\n // ...\n }\n );\n};\n"],"mappings":"6bAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAQA,IAAOA,EAAQ,IACN,OAAO,OACXC,IACC,QAAQ,IAAI,OAAQA,CAAI,EAEjBA,GAET,CACE,IAAI,IAAM,CAAC,CAEb,CACF","names":["index_exports","__export","index_default","uuid"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// HTTP State, https://httpstate.com/\n// Copyright (C) Alex Morales, 2026\n// \n// Unless otherwise stated in particular files or directories, this software is free software.\n// You can redistribute it and/or modify it under the terms of the GNU Affero\n// General Public License as published by the Free Software Foundation, either\n// version 3 of the License, or (at your option) any later version.\n\nexport const get:(uuid:string) => Promise<undefined|string> = async (uuid:string):Promise<undefined|string> => {\n const response:Response = await fetch('https://httpstate.com/' + uuid);\n\n if(response.status === 200)\n return await response.text();\n};\n\nexport const load:() => Promise<void> = async ():Promise<void> => {\n for(const node of document.querySelectorAll('[httpState],[httpstate]')) {\n const uuid:null|string = node.getAttribute('httpState')||node.getAttribute('httpstate');\n\n console.log('node.uuid', uuid);\n\n // const ui = httpState(uuid)\n // .on('change', e => node.innerHTML = e.data);\n\n // ui.et.dispatchEvent(Object.assign(new Event('change'), { data:await ui.get() }));\n }\n};\n\nexport const read:(uuid:string) => Promise<undefined|string> = async (uuid:string):Promise<undefined|string> => get(uuid);\n\nexport const set:(uuid:string, data:string) => Promise<number> = async (uuid:string, data:string):Promise<number> => {\n const response:Response = await fetch('https://httpstate.com/' + uuid, { body:data, method:'POST' });\n\n return response.status;\n};\n\nexport const write:(uuid:string, data:string) => Promise<number> = async (uuid:string, data:string):Promise<number> => set(uuid, data);\n\n// httpState\ntype HttpState = {\n addEventListener(type:string, callback:null|EventListenerOrEventListenerObject):void;\n data?:undefined|string;\n et:EventTarget;\n get():Promise<undefined|string>;\n off(type:string, callback:null|EventListenerOrEventListenerObject):HttpState;\n on(type:string, callback:null|EventListenerOrEventListenerObject):HttpState;\n read():Promise<undefined|string>;\n removeEventListener(type:string, callback:null|EventListenerOrEventListenerObject):void;\n set(data:string):Promise<number>;\n write(data:string):Promise<number>;\n};\n\nconst httpState:(uuid:string) => HttpState = (uuid:string):HttpState => {\n const _:HttpState = {\n addEventListener:(type:string, callback:null|EventListenerOrEventListenerObject) => _.et.addEventListener(type, callback),\n data:undefined,\n et:new EventTarget(),\n get:async ():Promise<undefined|string> => get(uuid),\n off:(type:string, callback:null|EventListenerOrEventListenerObject) => {\n _.removeEventListener(type, callback);\n\n return _;\n },\n on:(type:string, callback:null|EventListenerOrEventListenerObject) => {\n _.addEventListener(type, callback);\n\n return _;\n },\n read:async ():Promise<undefined|string> => read(uuid),\n removeEventListener:(type:string, callback:null|EventListenerOrEventListenerObject) => _.et.removeEventListener(type, callback),\n set:async (data:string):Promise<number> => set(uuid, data),\n write:async (data:string):Promise<number> => write(uuid, data),\n // ws:new WebSocket('wss://httpstate.com/' + uuid)\n };\n\n // ...\n\n return _;\n};\n\nexport default httpState;\n\nif(\n typeof document !== 'undefined'\n && typeof window !== 'undefined'\n) {\n console.log('we do some magic ...');\n\n if(\n globalThis === window\n && (globalThis as any).httpstate\n ) {\n console.log('do the binding yo ...');\n\n (globalThis as any).httpstate = Object.assign(\n (globalThis as any).httpstate.default,\n (globalThis as any).httpstate\n );\n }\n\n window.addEventListener('load', load);\n}\n\n"],"mappings":"6bAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,QAAAC,EAAA,SAAAC,EAAA,SAAAC,EAAA,QAAAC,EAAA,UAAAC,IAQO,IAAMJ,EAAiD,MAAOK,GAA0C,CAC7G,IAAMC,EAAoB,MAAM,MAAM,yBAA2BD,CAAI,EAErE,GAAGC,EAAS,SAAW,IACrB,OAAO,MAAMA,EAAS,KAAK,CAC/B,EAEaL,EAA2B,SAA0B,CAChE,QAAUM,KAAQ,SAAS,iBAAiB,yBAAyB,EAAG,CACtE,IAAMF,EAAmBE,EAAK,aAAa,WAAW,GAAGA,EAAK,aAAa,WAAW,EAEtF,QAAQ,IAAI,YAAaF,CAAI,CAM/B,CACF,EAEaH,EAAkD,MAAOG,GAA0CL,EAAIK,CAAI,EAE3GF,EAAoD,MAAOE,EAAaG,KACzD,MAAM,MAAM,yBAA2BH,EAAM,CAAE,KAAKG,EAAM,OAAO,MAAO,CAAC,GAEnF,OAGLJ,EAAsD,MAAOC,EAAaG,IAAgCL,EAAIE,EAAMG,CAAI,EAgB/HC,EAAwCJ,GAA0B,CACtE,IAAMK,EAAc,CAClB,iBAAiB,CAACC,EAAaC,IAAqDF,EAAE,GAAG,iBAAiBC,EAAMC,CAAQ,EACxH,KAAK,OACL,GAAG,IAAI,YACP,IAAI,SAAsCZ,EAAIK,CAAI,EAClD,IAAI,CAACM,EAAaC,KAChBF,EAAE,oBAAoBC,EAAMC,CAAQ,EAE7BF,GAET,GAAG,CAACC,EAAaC,KACfF,EAAE,iBAAiBC,EAAMC,CAAQ,EAE1BF,GAET,KAAK,SAAsCR,EAAKG,CAAI,EACpD,oBAAoB,CAACM,EAAaC,IAAqDF,EAAE,GAAG,oBAAoBC,EAAMC,CAAQ,EAC9H,IAAI,MAAOJ,GAAgCL,EAAIE,EAAMG,CAAI,EACzD,MAAM,MAAOA,GAAgCJ,EAAMC,EAAMG,CAAI,CAE/D,EAIA,OAAOE,CACT,EAEOX,EAAQU,EAGV,OAAO,SAAa,KACpB,OAAO,OAAW,MAErB,QAAQ,IAAI,sBAAsB,EAG7B,aAAe,QACd,WAAmB,YAEvB,QAAQ,IAAI,uBAAuB,EAElC,WAAmB,UAAY,OAAO,OACpC,WAAmB,UAAU,QAC7B,WAAmB,SACtB,GAGF,OAAO,iBAAiB,OAAQR,CAAI","names":["index_exports","__export","index_default","get","load","read","set","write","uuid","response","node","data","httpState","_","type","callback"]}
package/package.json CHANGED
@@ -23,5 +23,5 @@
23
23
  },
24
24
  "type": "module",
25
25
  "types": "dist/index.d.ts",
26
- "version": "0.0.2"
26
+ "version": "0.0.4"
27
27
  }