jsgar 4.0.2 → 4.0.3

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/gar.umd.js CHANGED
@@ -582,13 +582,13 @@
582
582
  if (typeof globalThis !== 'undefined' && globalThis.WebSocket) {
583
583
  return globalThis.WebSocket;
584
584
  }
585
- // Node.js: resolve 'ws' at runtime without using dynamic import (avoids rollup code-splitting)
585
+ // Node.js: resolve 'ws' at runtime
586
586
  const isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
587
587
  if (isNode) {
588
588
  try {
589
- const req = (typeof module !== 'undefined' && module.require)
590
- ? module.require.bind(module)
591
- : (typeof require !== 'undefined' ? require : Function('return require')());
589
+ // createRequire works in both ESM and CJS; resolves from cwd
590
+ const { createRequire } = await import('node:module');
591
+ const req = createRequire(process.cwd() + '/');
592
592
  const mod = req('ws');
593
593
  const WS = mod.default || mod.WebSocket || mod;
594
594
  globalThis.WebSocket = WS;
package/gar.js CHANGED
@@ -576,13 +576,13 @@ class GARClient {
576
576
  if (typeof globalThis !== 'undefined' && globalThis.WebSocket) {
577
577
  return globalThis.WebSocket;
578
578
  }
579
- // Node.js: resolve 'ws' at runtime without using dynamic import (avoids rollup code-splitting)
579
+ // Node.js: resolve 'ws' at runtime
580
580
  const isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
581
581
  if (isNode) {
582
582
  try {
583
- const req = (typeof module !== 'undefined' && module.require)
584
- ? module.require.bind(module)
585
- : (typeof require !== 'undefined' ? require : Function('return require')());
583
+ // createRequire works in both ESM and CJS; resolves from cwd
584
+ const { createRequire } = await import('node:module');
585
+ const req = createRequire(process.cwd() + '/');
586
586
  const mod = req('ws');
587
587
  const WS = mod.default || mod.WebSocket || mod;
588
588
  globalThis.WebSocket = WS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsgar",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "A Javascript client for the GAR protocol",
5
5
  "type": "module",
6
6
  "main": "dist/gar.umd.js",