6 Commits

Author SHA1 Message Date
dc2cd4ec4c Update comment 2025-03-21 12:03:20 -05:00
458048b58a Reinstate ws WebSocket library
All checks were successful
Node.js CI / build (18.x) (push) Successful in 16m17s
Node.js CI / build (20.x) (push) Successful in 11s
Node.js CI / build (22.x) (push) Successful in 11s
In some environments, such as MagicMirror modules, the WebSocket class is not defined. This is apparently a client-only class and generally only exists in browsers, but I'm confused how the unit tests were passing when run against just node. Either way, this means we have to disable the test again since ws is not compatible with jest-websocket-mock, and I haven't found an alternative mock server that is.
2025-01-25 12:06:01 -06:00
f8e2aa0f3e Get basic test up and passing
This replaces the 'ws' library with built-in websockets so that we can mock a server and successfully connect to it. A simple test verifies that Unit is handling a message request and response as we expect it to.
2025-01-13 13:06:58 -06:00
7976348197 Pass error along with error event
All checks were successful
Node.js CI / build (18.x) (push) Successful in 11s
Node.js CI / build (20.x) (push) Successful in 10s
Node.js CI / build (22.x) (push) Successful in 11s
2025-01-08 21:16:46 -06:00
2ffed2204b Fix timeouts and errors not emitting "close" 2025-01-08 21:11:45 -06:00
c445a844ee Split into commonjs and ESM outputs
This allows require() and import to work for even better compatibility between CJS and ESM consumers.

I dislike that this kills our ability for top-level awaits in example.ts, but seeing as how my primary use case for this library is a commonjs module, I think this is a fair trade-off.

Also changed "messages" to not encapsulate its export under the name "messages" to remove some repetition in importing "messages" and still needing to do "messages." to get the methods out. Now it's simple to import each message by name or group them under something like "messages" as desired on a per-library-user basis.

Refs:
* https://www.kravchyk.com/typescript-npm-package-json-exports/
* https://arethetypeswrong.github.io/
* https://evertpot.com/universal-commonjs-esm-typescript-packages/
2025-01-05 15:34:07 -06:00