socket-function 1.1.34 → 1.1.36

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.
@@ -25,6 +25,8 @@ export declare class SocketFunction {
25
25
  static COEP: string;
26
26
  static COOP: string;
27
27
  static TOTAL_CALLS: number;
28
+ static ENABLE_CLIENT_MODE: boolean;
29
+ static isClient(): boolean;
28
30
  static readonly WIRE_SERIALIZER: {
29
31
  serialize: (obj: unknown) => MaybePromise<Buffer[]>;
30
32
  deserialize: (buffers: Buffer[]) => MaybePromise<unknown>;
package/SocketFunction.ts CHANGED
@@ -69,6 +69,10 @@ export class SocketFunction {
69
69
 
70
70
  public static TOTAL_CALLS = 0;
71
71
 
72
+ public static ENABLE_CLIENT_MODE = false;
73
+ // Places where we decide if we want to act as a client. Most places we check for is node, but some places it's not, depending on if we're in Node.js or not, it's depending on if we're a client or not.
74
+ public static isClient() { return !isNode() || SocketFunction.ENABLE_CLIENT_MODE; }
75
+
72
76
  // In retrospect... dynamically changing the wire serializer is a BAD idea. If any calls happen
73
77
  // before it is changed, things just break. Also, it needs to be changed on both sides,
74
78
  // or else things break. Also, it is very hard to detect when the issue is different serializers
@@ -202,8 +202,7 @@ class HotReloadControllerBase {
202
202
  file = "https://" + (BOOTED_EDGE_NODE?.host || location.host) + "/" + file;
203
203
  let module = require.cache[file];
204
204
  if (!module) {
205
- console.log(`Module not found: ${file}, reloading page to ensure new version is loaded`);
206
- document.location.reload();
205
+ console.log(`Module not found: ${file}, not reloading page`);
207
206
  return;
208
207
  }
209
208
  if (!module.hotreload) {
package/index.d.ts CHANGED
@@ -34,6 +34,8 @@ declare module "socket-function/SocketFunction" {
34
34
  static COEP: string;
35
35
  static COOP: string;
36
36
  static TOTAL_CALLS: number;
37
+ static ENABLE_CLIENT_MODE: boolean;
38
+ static isClient(): boolean;
37
39
  static readonly WIRE_SERIALIZER: {
38
40
  serialize: (obj: unknown) => MaybePromise<Buffer[]>;
39
41
  deserialize: (buffers: Buffer[]) => MaybePromise<unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "socket-function",
3
- "version": "1.1.34",
3
+ "version": "1.1.36",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -500,7 +500,7 @@ export async function createCallFactory(
500
500
  console.error("Error getting alternate node IDs", e);
501
501
  }
502
502
 
503
- let newWebSocket = createWebsocket(nodeId, proposeProtocols(isNode() ? nodeId : undefined, { lz4: true }));
503
+ let newWebSocket = createWebsocket(nodeId, proposeProtocols(!SocketFunction.isClient() ? nodeId : undefined, { lz4: true }));
504
504
  await initializeWebsocket(newWebSocket);
505
505
 
506
506
  return newWebSocket;