@spooled/sdk 1.0.25 → 1.0.26

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.
@@ -107,11 +107,11 @@ declare const DEFAULT_CONFIG: {
107
107
  successThreshold: number;
108
108
  timeout: number;
109
109
  };
110
- readonly userAgent: "@spooled/sdk-nodejs/1.0.25";
110
+ readonly userAgent: "@spooled/sdk-nodejs/1.0.26";
111
111
  readonly autoRefreshToken: true;
112
112
  };
113
113
  /** SDK version */
114
- declare const SDK_VERSION = "1.0.25";
114
+ declare const SDK_VERSION = "1.0.26";
115
115
  /** API version prefix */
116
116
  declare const API_VERSION = "v1";
117
117
  /**
@@ -107,11 +107,11 @@ declare const DEFAULT_CONFIG: {
107
107
  successThreshold: number;
108
108
  timeout: number;
109
109
  };
110
- readonly userAgent: "@spooled/sdk-nodejs/1.0.25";
110
+ readonly userAgent: "@spooled/sdk-nodejs/1.0.26";
111
111
  readonly autoRefreshToken: true;
112
112
  };
113
113
  /** SDK version */
114
- declare const SDK_VERSION = "1.0.25";
114
+ declare const SDK_VERSION = "1.0.26";
115
115
  /** API version prefix */
116
116
  declare const API_VERSION = "v1";
117
117
  /**
package/dist/index.cjs CHANGED
@@ -30,13 +30,6 @@ function _interopNamespace(e) {
30
30
  var grpc2__namespace = /*#__PURE__*/_interopNamespace(grpc2);
31
31
  var protoLoader__namespace = /*#__PURE__*/_interopNamespace(protoLoader);
32
32
 
33
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
34
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
35
- }) : x)(function(x) {
36
- if (typeof require !== "undefined") return require.apply(this, arguments);
37
- throw Error('Dynamic require of "' + x + '" is not supported');
38
- });
39
-
40
33
  // src/config.ts
41
34
  var DEFAULT_CONFIG = {
42
35
  baseUrl: "https://api.spooled.cloud",
@@ -56,10 +49,10 @@ var DEFAULT_CONFIG = {
56
49
  successThreshold: 3,
57
50
  timeout: 3e4
58
51
  },
59
- userAgent: "@spooled/sdk-nodejs/1.0.25",
52
+ userAgent: "@spooled/sdk-nodejs/1.0.26",
60
53
  autoRefreshToken: true
61
54
  };
62
- var SDK_VERSION = "1.0.25";
55
+ var SDK_VERSION = "1.0.26";
63
56
  var API_VERSION = "v1";
64
57
  var API_BASE_PATH = `/api/${API_VERSION}`;
65
58
  function resolveConfig(options) {
@@ -1812,6 +1805,16 @@ var WebSocketRealtimeClient = class {
1812
1805
  getState() {
1813
1806
  return this.state;
1814
1807
  }
1808
+ /**
1809
+ * Get WebSocket implementation (browser native or Node.js ws package)
1810
+ */
1811
+ async getWebSocketImpl() {
1812
+ if (typeof WebSocket !== "undefined") {
1813
+ return WebSocket;
1814
+ }
1815
+ const wsModule = await import('ws');
1816
+ return wsModule.default;
1817
+ }
1815
1818
  /**
1816
1819
  * Connect to the WebSocket server
1817
1820
  */
@@ -1819,12 +1822,18 @@ var WebSocketRealtimeClient = class {
1819
1822
  if (this.state === "connected" || this.state === "connecting") {
1820
1823
  return;
1821
1824
  }
1825
+ this.setState("connecting");
1826
+ const wsUrl = this.buildWsUrl();
1827
+ this.options.debug(`Connecting to ${wsUrl}`);
1828
+ let WebSocketImpl;
1829
+ try {
1830
+ WebSocketImpl = await this.getWebSocketImpl();
1831
+ } catch (error) {
1832
+ this.setState("disconnected");
1833
+ throw new Error(`Failed to load WebSocket implementation: ${error}`);
1834
+ }
1822
1835
  return new Promise((resolve, reject) => {
1823
- this.setState("connecting");
1824
- const wsUrl = this.buildWsUrl();
1825
- this.options.debug(`Connecting to ${wsUrl}`);
1826
1836
  try {
1827
- const WebSocketImpl = typeof WebSocket !== "undefined" ? WebSocket : __require("ws");
1828
1837
  this.ws = new WebSocketImpl(wsUrl);
1829
1838
  this.ws.onopen = () => {
1830
1839
  this.options.debug("WebSocket connected");
@@ -3050,7 +3059,7 @@ var SpooledWorker = class {
3050
3059
  ...DEFAULT_OPTIONS,
3051
3060
  hostname: os.hostname(),
3052
3061
  workerType: "nodejs",
3053
- version: "1.0.25",
3062
+ version: "1.0.26",
3054
3063
  metadata: {},
3055
3064
  ...options
3056
3065
  };