itty-sockets 0.5.3 → 0.5.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/README.md CHANGED
@@ -69,7 +69,8 @@ import { connect } from 'itty-sockets'
69
69
  ...or simply paste this into your environment/console:
70
70
  <!-- BEGIN SNIPPET -->
71
71
  ```ts
72
- let connect=(e,s={})=>{let t,a=0,n=[],p=[],o={},l=()=>(t||(t=new WebSocket((/^wss?:/.test(e)?e:"wss://ittysockets.io/c/"+e)+"?"+new URLSearchParams(s)),t.onmessage=(e,s=JSON.parse(e.data),t=s?.message,a={...null==t?.[0]&&t,...s,...s.date&&{date:new Date(s.date)}})=>{o[s?.type??t?.type]?.map(e=>e(a)),s?.type||o.message?.map(e=>e(a)),p.map(([e,s])=>e(a)&&s(a))},t.onopen=()=>(n.splice(0).map(e=>t?.send(e)),o.open?.map(e=>e()),a&&t?.close()),t.onclose=()=>(a=0,t=null,o.close?.map(e=>e()))),c),c=new Proxy(l,{get:(e,s)=>({open:l,close:()=>(1==t?.readyState?t.close():a=1,c),push:(e,s)=>(a=1,c.send(e,s)),send:(e,s)=>(e=JSON.stringify(e),e=s?"@@"+s+"@@"+e:e,1==t?.readyState?(t.send(e),c):(n.push(e),l())),on:(e,s)=>(s&&(e?.[0]?(o[e]??=[]).push(s):p.push([e,s])),l()),remove:(e,s,t=o[e],a=t?.indexOf(s)??-1)=>(~a&&t?.splice(a,1),l())}[s])});return c};```
72
+ let connect=(e,s={})=>{let t,a=0,n=[],p=[],o={},l=()=>(t||(t=new WebSocket((/^wss?:/.test(e)?e:"wss://ittysockets.io/c/"+e)+"?"+new URLSearchParams(s)),t.onmessage=(e,s=JSON.parse(e.data),t=s?.message,a={...null==t?.[0]&&t,...s,...s.date&&{date:new Date(s.date)}})=>{o[s?.type??t?.type]?.map(e=>e(a)),s?.type||o.message?.map(e=>e(a)),p.map(([e,s])=>e(a)&&s(a))},t.onopen=()=>(n.splice(0).map(e=>t?.send(e)),o.open?.map(e=>e()),a&&t?.close()),t.onclose=()=>(a=0,t=null,o.close?.map(e=>e()))),c),c=new Proxy(l,{get:(e,s)=>({open:l,close:()=>(1==t?.readyState?t.close():a=1,c),push:(e,s)=>(a=1,c.send(e,s)),send:(e,s)=>(e=JSON.stringify(e),e=s?"@@"+s+"@@"+e:e,1==t?.readyState?(t.send(e),c):(n.push(e),l())),on:(e,s)=>(s&&(e?.[0]?(o[e]??=[]).push(s):p.push([e,s])),l()),remove:(e,s,t=o[e],a=t?.indexOf(s)??-1)=>(~a&&t?.splice(a,1),l())}[s])});return c};
73
+ ```
73
74
  <!-- END SNIPPET -->
74
75
 
75
76
  <br />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itty-sockets",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "WebSockets : simplified and minified.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -12,14 +12,11 @@
12
12
  },
13
13
  "scripts": {
14
14
  "dev": "bun test --watch --coverage",
15
+ "test": "bun test --coverage",
15
16
  "lint": "itty lint",
16
- "verify": "echo 'verifying module...' && bun run build && bun test",
17
- "prerelease": "bun run verify",
18
- "prerelease:next": "bun run verify",
19
- "build": "itty build --snippet=connect --hybrid",
20
- "release:dry": "itty publish --patch --tag --dry-run",
21
- "release": "itty publish --tag --push --patch --src=dist",
22
- "release:next": "itty publish --tag --push --type=next --src=dist"
17
+ "build": "itty lint && itty build --snippet=connect --hybrid",
18
+ "release": "itty release --prepare --tag --push",
19
+ "release:next": "itty release --prepare --tag --push --type=next"
23
20
  },
24
21
  "keywords": [
25
22
  "websockets",
@@ -37,6 +34,6 @@
37
34
  },
38
35
  "devDependencies": {
39
36
  "@types/bun": "^1.2.3",
40
- "itty-packager": "^1.0.2"
37
+ "itty-packager": "^1.6.7"
41
38
  }
42
39
  }
package/CHANGELOG.md DELETED
@@ -1,21 +0,0 @@
1
- ## Changelog
2
- CAUTION: Pre v1.0.0, this should be considered an alpha release, with minor updates allowing for breaking changes to the interface.
3
-
4
- #### v0.5.0
5
- - BREAKING: removed base (url) option - instead, simply pass a full wss:// path as the channelId to use an external compatible server.
6
- #### v0.4.0
7
- - added: base (url) option
8
- #### v0.3.1
9
- - fixes: module export
10
- - removes extra NPM files
11
- #### v0.3.0
12
- - breaking: every event has multiple listeners (previously only on('message') allowed multiple)
13
- - added: join/leave/error event types
14
- - added: .remove('event-name', listener) to remove listeners
15
- #### v0.2.3
16
- - fix type hinting on listeners
17
- - improve type hinting on send/push
18
- #### v0.2.0
19
- - alpha release 2
20
- #### v0.1.0
21
- - alpha release 1