@zerodensity/realityhub-api 1.16.0 → 2.0.0

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.
@@ -0,0 +1,10 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(node:*)",
5
+ "Bash(rm:*)",
6
+ "Bash(mv:*)"
7
+ ],
8
+ "deny": []
9
+ }
10
+ }
package/package.json CHANGED
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "@zerodensity/realityhub-api",
3
- "version": "1.16.0",
3
+ "version": "2.0.0",
4
4
  "description": "RealityHub API Javascript Implementation",
5
+ "type": "module",
5
6
  "main": "src/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./src/index.js",
10
+ "require": "./src/index.cjs"
11
+ }
12
+ },
6
13
  "repository": {
7
14
  "type": "git",
8
15
  "url": "git+ssh://git@github.com/zerodensity/realityhub-api.git"
@@ -30,7 +37,6 @@
30
37
  },
31
38
  "homepage": "https://github.com/zerodensity/realityhub-api#readme",
32
39
  "dependencies": {
33
- "uuid": "^11.0.3",
34
- "ws": "^8.18.0"
40
+ "uuid": "^11.0.3"
35
41
  }
36
42
  }
package/src/index.cjs ADDED
@@ -0,0 +1,17 @@
1
+ // Copyright (c) 2019-2025 Zero Density Inc.
2
+ //
3
+ // This file is part of realityhub-api.
4
+ //
5
+ // realityhub-api is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU General Public License version 2, as published by
7
+ // the Free Software Foundation.
8
+ //
9
+ // realityhub-api is distributed in the hope that it will be useful,
10
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ // GNU General Public License for more details.
13
+ //
14
+ // You should have received a copy of the GNU General Public License
15
+ // along with realityhub-api. If not, see <https://www.gnu.org/licenses/>.
16
+
17
+ module.exports = require('./index.js');
package/src/index.js CHANGED
@@ -14,9 +14,7 @@
14
14
  // You should have received a copy of the GNU General Public License
15
15
  // along with realityhub-api. If not, see <https://www.gnu.org/licenses/>.
16
16
 
17
- module.exports = {
18
- BrokerBase: require('./lib/BrokerBase'),
19
- BrokerClient: require('./lib/BrokerClient'),
20
- BrokerError: require('./lib/BrokerError'),
21
- RawRequest: require('./lib/RawRequest'),
22
- };
17
+ export { BrokerBase } from './lib/BrokerBase.js';
18
+ export { BrokerClient } from './lib/BrokerClient.js';
19
+ export { BrokerError } from './lib/BrokerError.js';
20
+ export { RawRequest } from './lib/RawRequest.js';
@@ -14,10 +14,10 @@
14
14
  // You should have received a copy of the GNU General Public License
15
15
  // along with realityhub-api. If not, see <https://www.gnu.org/licenses/>.
16
16
 
17
- const { v4: uuid } = require('uuid');
18
- const EventEmitter = require('events');
19
- const BrokerError = require('./BrokerError.js');
20
- const onceMultiple = require('./onceMultiple.js');
17
+ import { v4 as uuid } from 'uuid';
18
+ import { EventEmitter } from 'events';
19
+ import { BrokerError } from './BrokerError.js';
20
+ import { onceMultiple } from './onceMultiple.js';
21
21
 
22
22
  const DEFAULT_MAX_WS_PACKET_SIZE = 50 /*MB*/ * 1024 * 1024;
23
23
 
@@ -28,7 +28,7 @@ const DEFAULT_MAX_WS_PACKET_SIZE = 50 /*MB*/ * 1024 * 1024;
28
28
  * @param {number} [params.maxPacketSize] Maximum websocket packet size
29
29
  * @param {Logger} [params.logger] Logger instance
30
30
  */
31
- module.exports = class BrokerBase extends EventEmitter {
31
+ export class BrokerBase extends EventEmitter {
32
32
  constructor(params) {
33
33
  super();
34
34
  this.moduleName = params.moduleName;
@@ -14,24 +14,14 @@
14
14
  // You should have received a copy of the GNU General Public License
15
15
  // along with realityhub-api. If not, see <https://www.gnu.org/licenses/>.
16
16
 
17
- const { v4: uuid } = require('uuid');
18
- const BrokerBase = require('./BrokerBase.js');
19
- const BrokerError = require('./BrokerError.js');
20
- const RawRequest = require('./RawRequest.js');
21
- const consoleLogger = require('./consoleLogger.js');
22
- const onceMultiple = require('./onceMultiple.js');
23
-
24
- let ws;
25
-
26
- const runningInBrowser = typeof window !== 'undefined';
27
-
28
- if (runningInBrowser) {
29
- ws = WebSocket;
30
- } else {
31
- ws = require('ws');
32
- }
33
-
34
- module.exports = class BrokerClient extends BrokerBase {
17
+ import { v4 as uuid } from 'uuid';
18
+ import { BrokerBase } from './BrokerBase.js';
19
+ import { BrokerError } from './BrokerError.js';
20
+ import { RawRequest } from './RawRequest.js';
21
+ import { consoleLogger } from './consoleLogger.js';
22
+ import { onceMultiple } from './onceMultiple.js';
23
+
24
+ export class BrokerClient extends BrokerBase {
35
25
  /**
36
26
  * BrokerClient constructor
37
27
  * @param {object} params Parameters
@@ -137,10 +127,10 @@ module.exports = class BrokerClient extends BrokerBase {
137
127
  if (typeof process !== "undefined" && process.versions != null && process.versions.node != null) {
138
128
  const NODE_TLS_REJECT_UNAUTHORIZED = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
139
129
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
140
- this.socket = new ws(webSocketURL);
130
+ this.socket = new WebSocket(webSocketURL);
141
131
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = NODE_TLS_REJECT_UNAUTHORIZED;
142
132
  } else {
143
- this.socket = new ws(webSocketURL);
133
+ this.socket = new WebSocket(webSocketURL);
144
134
  }
145
135
 
146
136
  this.addSocketListeners();
@@ -441,7 +431,7 @@ module.exports = class BrokerClient extends BrokerBase {
441
431
  },
442
432
  );
443
433
 
444
- if (socket.readyState !== ws.OPEN) {
434
+ if (socket.readyState !== WebSocket.OPEN) {
445
435
  try {
446
436
  await onceMultiple(this, ['connect'], webSocketMessage.timeout || this.messageTimeout);
447
437
  } catch (ex) {
@@ -14,5 +14,4 @@
14
14
  // You should have received a copy of the GNU General Public License
15
15
  // along with realityhub-api. If not, see <https://www.gnu.org/licenses/>.
16
16
 
17
- class BrokerError extends Error { }
18
- module.exports = BrokerError;
17
+ export class BrokerError extends Error { }
@@ -14,7 +14,7 @@
14
14
  // You should have received a copy of the GNU General Public License
15
15
  // along with realityhub-api. If not, see <https://www.gnu.org/licenses/>.
16
16
 
17
- class RawRequest {
17
+ export class RawRequest {
18
18
  setCallback(callback) {
19
19
  if (typeof callback !== 'function') {
20
20
  throw new Error('callback must be a function.');
@@ -37,5 +37,3 @@ class RawRequest {
37
37
  }
38
38
  }
39
39
  }
40
-
41
- module.exports = RawRequest;
@@ -14,7 +14,7 @@
14
14
  // You should have received a copy of the GNU General Public License
15
15
  // along with realityhub-api. If not, see <https://www.gnu.org/licenses/>.
16
16
 
17
- module.exports = function consoleLogger(moduleName, options = { silent: false }) {
17
+ export function consoleLogger(moduleName, options = { silent: false }) {
18
18
  const { silent } = options;
19
19
 
20
20
  return ['log', 'info', 'warn', 'error', 'trace', 'debug'].reduce((o, item) => {
@@ -22,7 +22,7 @@ class TimeoutError extends Error {
22
22
  }
23
23
  }
24
24
 
25
- module.exports = function onceMultiple(target, eventNames, timeout = null) {
25
+ export function onceMultiple(target, eventNames, timeout = null) {
26
26
  return new Promise((resolve, reject) => {
27
27
  let timer;
28
28
  let handler;