engage-wasm 1.235.90750003 → 1.235.90750004

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/engagewasm.api.js CHANGED
@@ -1,45 +1,61 @@
1
+ /* eslint-disable class-methods-use-this,no-undef */
2
+ // noinspection JSUnusedGlobalSymbols
3
+
1
4
  //
2
5
  // Copyright (c) 2022 Rally Tactical Systems, Inc.
3
6
  //
4
7
 
5
- // The Engage class - DO NOT INSTANTIATE THIS!!!
6
- class Engage extends EventTarget {
7
- #_engageWasm;
8
+ export default class Engage extends EventTarget {
9
+ // The WASM object produced by awaiting the promise returned by the
10
+ // engagewasm.js module.
11
+ _wasm;
12
+
13
+ // The Engage wrapper object (representing the exported API of the WASM).
14
+ _wasmWrapper;
15
+
16
+ constructor(engageWasm) {
17
+ super();
18
+ this._wasm = engageWasm;
19
+ this._wasmWrapper = new engageWasm.EngageWasmWrapper();
20
+ }
8
21
 
9
- constructor() {
10
- super()
11
- this.#_engageWasm = new Module.EngageWasmWrapper();
22
+ get wasm() {
23
+ return this._wasm;
12
24
  }
13
25
 
14
- engage_dev_wasm_test_01() {
15
- return this.#_engageWasm.engage_dev_wasm_test_01();
26
+ get wasmWrapper() {
27
+ return this._wasmWrapper;
16
28
  }
17
29
 
18
30
  engageSetLogLevel(level) {
19
- return this.#_engageWasm.engageSetLogLevel(level);
31
+ return this.wasmWrapper.engageSetLogLevel(level);
20
32
  }
21
33
 
22
34
  engageInitialize(policy, identity, tmpDir) {
23
- return this.#_engageWasm.engageInitialize(policy, identity, tmpDir)
35
+ return this.wasmWrapper.engageInitialize(policy, identity, tmpDir);
24
36
  }
25
37
 
26
38
  engageShutdown() {
27
- return this.#_engageWasm.engageShutdown();
39
+ return this.wasmWrapper.engageShutdown();
28
40
  }
29
41
 
30
42
  engageStart() {
31
- return this.#_engageWasm.engageStart();
43
+ return this.wasmWrapper.engageStart();
32
44
  }
33
45
 
34
46
  engageStop() {
35
- return this.#_engageWasm.engageStop();
47
+ return this.wasmWrapper.engageStop();
36
48
  }
37
49
 
38
50
  engageSetCertStore(csUint8Array, arraySize, passwordHex) {
39
- var heapSpace = Module._malloc(arraySize * 1);
40
- Module.HEAPU8.set(csUint8Array, heapSpace);
41
- var rc = this.#_engageWasm.engageSetCertStore(heapSpace, arraySize, passwordHex);
42
- Module._free(heapSpace);
51
+ const heapSpace = this.wasm._malloc(arraySize * 1);
52
+ this.wasm.HEAPU8.set(csUint8Array, heapSpace);
53
+ const rc = this.wasmWrapper.engageSetCertStore(
54
+ heapSpace,
55
+ arraySize,
56
+ passwordHex
57
+ );
58
+ this.wasm._free(heapSpace);
43
59
  return rc;
44
60
  }
45
61
 
@@ -53,71 +69,56 @@ class Engage extends EventTarget {
53
69
 
54
70
  return this.engageSetCertStore(u8array, u8array.length, passwordHex);
55
71
  }
56
-
72
+
57
73
  engageCreateGroup(jsonConfig) {
58
- return this.#_engageWasm.engageCreateGroup(jsonConfig);
74
+ return this.wasmWrapper.engageCreateGroup(jsonConfig);
59
75
  }
60
76
 
61
77
  engageDeleteGroup(id) {
62
- return this.#_engageWasm.engageDeleteGroup(id);
78
+ return this.wasmWrapper.engageDeleteGroup(id);
63
79
  }
64
80
 
65
81
  engageJoinGroup(id) {
66
- return this.#_engageWasm.engageJoinGroup(id);
82
+ return this.wasmWrapper.engageJoinGroup(id);
67
83
  }
68
84
 
69
85
  engageLeaveGroup(id) {
70
- return this.#_engageWasm.engageLeaveGroup(id);
86
+ return this.wasmWrapper.engageLeaveGroup(id);
71
87
  }
72
88
 
73
89
  engageBeginGroupTx(id, priority, flags) {
74
- return this.#_engageWasm.engageBeginGroupTx(id, priority, flags);
90
+ return this.wasmWrapper.engageBeginGroupTx(id, priority, flags);
75
91
  }
76
92
 
77
93
  engageBeginGroupTxAdvanced(id, jsonParams) {
78
- return this.#_engageWasm.engageBeginGroupTxAdvanced(id, jsonParams);
94
+ return this.wasmWrapper.engageBeginGroupTxAdvanced(id, jsonParams);
79
95
  }
80
96
 
81
97
  engageEndGroupTx(id) {
82
- return this.#_engageWasm.engageEndGroupTx(id);
98
+ return this.wasmWrapper.engageEndGroupTx(id);
83
99
  }
84
100
 
85
101
  engageMuteGroupTx(id) {
86
- return this.#_engageWasm.engageMuteGroupTx(id);
102
+ return this.wasmWrapper.engageMuteGroupTx(id);
87
103
  }
88
104
 
89
105
  engageUnmuteGroupTx(id) {
90
- return this.#_engageWasm.engageUnmuteGroupTx(id);
106
+ return this.wasmWrapper.engageUnmuteGroupTx(id);
91
107
  }
92
108
 
93
109
  engageMuteGroupRx(id) {
94
- return this.#_engageWasm.engageMuteGroupRx(id);
110
+ return this.wasmWrapper.engageMuteGroupRx(id);
95
111
  }
96
112
 
97
113
  engageUnmuteGroupRx(id) {
98
- return this.#_engageWasm.engageUnmuteGroupRx(id);
114
+ return this.wasmWrapper.engageUnmuteGroupRx(id);
99
115
  }
100
- };
101
-
102
- // Our Engage object
103
- let __engageObject;
104
-
105
- // Global Engage object functions
106
- function createEngageObject() {
107
- __engageObject = new Engage();
108
- }
109
-
110
- function destroyEngageObject() {
111
- }
112
-
113
- function getEngageObject() {
114
- return __engageObject;
115
116
  }
116
117
 
117
118
  /*
118
119
  Events generated by the Engage object. To subscribe to these events, follow the
119
120
  pattern of:
120
- getEngageObject().addEventListener(name_of_event_as_a_string, (e) => {
121
+ this.wasmWrapper.addEventListener(name_of_event_as_a_string, (e) => {
121
122
  /// process the event
122
123
  });
123
124
 
@@ -125,17 +126,17 @@ function getEngageObject() {
125
126
  contains a subobject consisting of fields specific to the event.
126
127
 
127
128
  For example, to subscribe to the "onEngineStarted" event:
128
- getEngageObject().addEventListener("onEngineStarted", (e) => {
129
+ this.wasmWrapper.addEventListener("onEngineStarted", (e) => {
129
130
  processEngineStateChange("started");
130
131
  });
131
132
 
132
133
  To subscribe to the "onGroupCreated" event:
133
- getEngageObject().addEventListener("onGroupCreated", (e) => {
134
+ this.wasmWrapper.addEventListener("onGroupCreated", (e) => {
134
135
  processGroupStateChange(e.detail.id, "created");
135
136
  });
136
137
 
137
- To subscribe to the "onGroupRxSpeakersChanged" event:
138
- getEngageObject().addEventListener("onGroupRxSpeakersChanged", (e) => {
138
+ To subscribe to the "onGroupRxSpeakersChanged" event:
139
+ this.wasmWrapper.addEventListener("onGroupRxSpeakersChanged", (e) => {
139
140
  processGroupSpeakers(e.detail.id, e.detail.talkers);
140
141
  });
141
142