@rsdoctor/components 0.3.0 → 0.3.1

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.
@@ -21,7 +21,7 @@ class LocalServerDataLoader extends BaseDataLoader {
21
21
  if (ManifestShared.isShardingData(res)) {
22
22
  if (!this.shardingDataMap.has(key)) {
23
23
  const task = new Promise((resolve) => {
24
- getSocket(this.manifest.__SOCKET__URL__).emit(
24
+ getSocket().emit(
25
25
  SDK.ServerAPI.API.LoadDataByKey,
26
26
  { key },
27
27
  (res2) => {
@@ -43,9 +43,13 @@ class LocalServerDataLoader extends BaseDataLoader {
43
43
  const key = body ? `${api}_${JSON.stringify(body)}` : `${api}`;
44
44
  return this.limit(key, async () => {
45
45
  return new Promise((resolve) => {
46
- getSocket(this.manifest.__SOCKET__URL__).emit(api, body, (res) => {
47
- resolve(res.res);
48
- });
46
+ getSocket().emit(
47
+ api,
48
+ body,
49
+ (res) => {
50
+ resolve(res.res);
51
+ }
52
+ );
49
53
  });
50
54
  });
51
55
  }
@@ -70,10 +74,10 @@ class LocalServerDataLoader extends BaseDataLoader {
70
74
  return;
71
75
  }
72
76
  this.events.get(api).add(fn);
73
- getSocket(this.manifest.__SOCKET__URL__).on(api, fn);
77
+ getSocket().on(api, fn);
74
78
  }
75
79
  removeOnDataUpdate(api, fn) {
76
- getSocket(this.manifest.__SOCKET__URL__).off(api, fn);
80
+ getSocket().off(api, fn);
77
81
  this.events.get(api).delete(fn);
78
82
  }
79
83
  }
@@ -1,2 +1,2 @@
1
1
  import { Socket } from 'socket.io-client';
2
- export declare function getSocket(socketUrl?: string): Socket;
2
+ export declare function getSocket(): Socket;
@@ -1,6 +1,7 @@
1
1
  import { io } from "socket.io-client";
2
2
  const map = /* @__PURE__ */ new Map();
3
- const defaultSocketUrl = process.env.NODE_ENV === "development" ? `ws://${location.hostname}:${process.env.LOCAL_CLI_PORT}` : `ws://${location.host}`;
3
+ const socketProtocol = location.protocol.includes("https") ? "wss" : "ws";
4
+ const defaultSocketUrl = process.env.NODE_ENV === "development" ? `${socketProtocol}://${location.hostname}:${process.env.LOCAL_CLI_PORT}` : `${socketProtocol}://${location.host}`;
4
5
  function ensureSocket(socketUrl = defaultSocketUrl) {
5
6
  if (!map.has(socketUrl)) {
6
7
  const socket = io(socketUrl, {});
@@ -11,8 +12,8 @@ function ensureSocket(socketUrl = defaultSocketUrl) {
11
12
  }
12
13
  return map.get(socketUrl);
13
14
  }
14
- function getSocket(socketUrl = defaultSocketUrl) {
15
- const socket = ensureSocket(socketUrl);
15
+ function getSocket() {
16
+ const socket = ensureSocket(defaultSocketUrl);
16
17
  return socket;
17
18
  }
18
19
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/components",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "main": "./dist/index.js",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -75,9 +75,9 @@
75
75
  "terser": "^5.26.0",
76
76
  "typescript": "^5.2.2",
77
77
  "url-parse": "1.5.10",
78
- "@rsdoctor/graph": "0.3.0",
79
- "@rsdoctor/types": "0.3.0",
80
- "@rsdoctor/utils": "0.3.0"
78
+ "@rsdoctor/graph": "0.3.1",
79
+ "@rsdoctor/types": "0.3.1",
80
+ "@rsdoctor/utils": "0.3.1"
81
81
  },
82
82
  "publishConfig": {
83
83
  "access": "public",