@formant/data-sdk 0.0.94 → 0.0.97
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/dist/data-sdk.es.js +81 -4
- package/dist/data-sdk.umd.js +27 -27
- package/dist/types/data-sdk/src/DataChannel.d.ts +11 -0
- package/dist/types/data-sdk/src/Device.d.ts +2 -2
- package/dist/types/data-sdk/src/KeyValue.d.ts +2 -0
- package/dist/types/data-sdk/src/RequestDataChannel.d.ts +7 -1
- package/package.json +1 -1
package/dist/data-sdk.es.js
CHANGED
|
@@ -18601,6 +18601,9 @@ class DataChannel {
|
|
|
18601
18601
|
constructor(dataChannel) {
|
|
18602
18602
|
__publicField(this, "ready", false);
|
|
18603
18603
|
__publicField(this, "listeners", []);
|
|
18604
|
+
__publicField(this, "openListeners", []);
|
|
18605
|
+
__publicField(this, "closeListeners", []);
|
|
18606
|
+
__publicField(this, "errorListeners", []);
|
|
18604
18607
|
__publicField(this, "binaryListeners", []);
|
|
18605
18608
|
__publicField(this, "error");
|
|
18606
18609
|
__publicField(this, "decoder", new TextDecoder());
|
|
@@ -18608,13 +18611,16 @@ class DataChannel {
|
|
|
18608
18611
|
this.dataChannel.binaryType = "arraybuffer";
|
|
18609
18612
|
this.dataChannel.onopen = () => {
|
|
18610
18613
|
this.ready = true;
|
|
18614
|
+
this.openListeners.forEach((listener) => listener());
|
|
18611
18615
|
};
|
|
18612
18616
|
this.dataChannel.onclose = () => {
|
|
18613
18617
|
this.ready = false;
|
|
18618
|
+
this.closeListeners.forEach((listener) => listener());
|
|
18614
18619
|
};
|
|
18615
18620
|
this.dataChannel.onerror = (e) => {
|
|
18616
18621
|
console.error(e);
|
|
18617
18622
|
this.error = "An error occurred in DataChannel";
|
|
18623
|
+
this.errorListeners.forEach((listener) => listener(e));
|
|
18618
18624
|
};
|
|
18619
18625
|
this.dataChannel.onmessage = (m) => {
|
|
18620
18626
|
this.listeners.forEach((_) => {
|
|
@@ -18627,6 +18633,24 @@ class DataChannel {
|
|
|
18627
18633
|
});
|
|
18628
18634
|
};
|
|
18629
18635
|
}
|
|
18636
|
+
addOpenListener(listener) {
|
|
18637
|
+
this.openListeners.push(listener);
|
|
18638
|
+
}
|
|
18639
|
+
removeOpenListener(listener) {
|
|
18640
|
+
this.openListeners = this.openListeners.filter((_) => _ !== listener);
|
|
18641
|
+
}
|
|
18642
|
+
addCloseListener(listener) {
|
|
18643
|
+
this.closeListeners.push(listener);
|
|
18644
|
+
}
|
|
18645
|
+
removeCloseListener(listener) {
|
|
18646
|
+
this.closeListeners = this.closeListeners.filter((l) => l !== listener);
|
|
18647
|
+
}
|
|
18648
|
+
addErrorListener(listener) {
|
|
18649
|
+
this.errorListeners.push(listener);
|
|
18650
|
+
}
|
|
18651
|
+
removeErrorListener(listener) {
|
|
18652
|
+
this.errorListeners = this.errorListeners.filter((l) => l !== listener);
|
|
18653
|
+
}
|
|
18630
18654
|
async waitTilReady() {
|
|
18631
18655
|
if (this.ready) {
|
|
18632
18656
|
return true;
|
|
@@ -18716,7 +18740,10 @@ class Manipulator {
|
|
|
18716
18740
|
__publicField(this, "currentListeners", []);
|
|
18717
18741
|
__publicField(this, "onRealtimeMessage", (_peerId, message) => {
|
|
18718
18742
|
if (message.payload.jointState) {
|
|
18719
|
-
this.currentListeners.forEach((listener) =>
|
|
18743
|
+
this.currentListeners.forEach((listener) => {
|
|
18744
|
+
if (message.payload.jointState)
|
|
18745
|
+
listener(message.payload.jointState);
|
|
18746
|
+
});
|
|
18720
18747
|
}
|
|
18721
18748
|
});
|
|
18722
18749
|
this.device = device;
|
|
@@ -18742,6 +18769,24 @@ class RequestDataChannel {
|
|
|
18742
18769
|
this.channel_name = channel_name;
|
|
18743
18770
|
this.timeout = timeout;
|
|
18744
18771
|
}
|
|
18772
|
+
addOpenListener(listener) {
|
|
18773
|
+
defined(this.channel, "channel not initalized").addOpenListener(listener);
|
|
18774
|
+
}
|
|
18775
|
+
removeOpenListener(listener) {
|
|
18776
|
+
defined(this.channel, "channel not initalized").removeOpenListener(listener);
|
|
18777
|
+
}
|
|
18778
|
+
addCloseListener(listener) {
|
|
18779
|
+
defined(this.channel, "channel not initalized").addCloseListener(listener);
|
|
18780
|
+
}
|
|
18781
|
+
removeCloseListener(listener) {
|
|
18782
|
+
defined(this.channel, "channel not initalized").removeCloseListener(listener);
|
|
18783
|
+
}
|
|
18784
|
+
addErrorListener(listener) {
|
|
18785
|
+
defined(this.channel, "channel not initalized").addErrorListener(listener);
|
|
18786
|
+
}
|
|
18787
|
+
removeErrorListener(listener) {
|
|
18788
|
+
defined(this.channel, "channel not initalized").removeErrorListener(listener);
|
|
18789
|
+
}
|
|
18745
18790
|
}
|
|
18746
18791
|
class BinaryRequestDataChannel extends RequestDataChannel {
|
|
18747
18792
|
constructor() {
|
|
@@ -19759,9 +19804,6 @@ class KeyValue {
|
|
|
19759
19804
|
try {
|
|
19760
19805
|
const result = await fetch(FORMANT_API_URL + `/v1/admin/key-value/${key}`, {
|
|
19761
19806
|
method: "GET",
|
|
19762
|
-
body: JSON.stringify({
|
|
19763
|
-
organizationId: defined(Authentication.currentUser).organizationId
|
|
19764
|
-
}),
|
|
19765
19807
|
headers: {
|
|
19766
19808
|
"Content-Type": "application/json",
|
|
19767
19809
|
Authorization: "Bearer " + Authentication.token
|
|
@@ -19776,6 +19818,41 @@ class KeyValue {
|
|
|
19776
19818
|
throw e;
|
|
19777
19819
|
}
|
|
19778
19820
|
}
|
|
19821
|
+
static async list() {
|
|
19822
|
+
try {
|
|
19823
|
+
const result = await fetch(FORMANT_API_URL + "/v1/admin/key-value", {
|
|
19824
|
+
method: "GET",
|
|
19825
|
+
headers: {
|
|
19826
|
+
"Content-Type": "application/json",
|
|
19827
|
+
Authorization: "Bearer " + Authentication.token
|
|
19828
|
+
}
|
|
19829
|
+
});
|
|
19830
|
+
const keyValueList = await result.json();
|
|
19831
|
+
if (result.status !== 200) {
|
|
19832
|
+
throw new Error(keyValueList.message);
|
|
19833
|
+
}
|
|
19834
|
+
return keyValueList.items;
|
|
19835
|
+
} catch (e) {
|
|
19836
|
+
throw e;
|
|
19837
|
+
}
|
|
19838
|
+
}
|
|
19839
|
+
static async delete(key) {
|
|
19840
|
+
try {
|
|
19841
|
+
const result = await fetch(FORMANT_API_URL + `/v1/admin/key-value/${key}`, {
|
|
19842
|
+
method: "DELETE",
|
|
19843
|
+
headers: {
|
|
19844
|
+
"Content-Type": "application/json",
|
|
19845
|
+
Authorization: "Bearer " + Authentication.token
|
|
19846
|
+
}
|
|
19847
|
+
});
|
|
19848
|
+
if (!result.ok) {
|
|
19849
|
+
throw new Error("Unable to handle request");
|
|
19850
|
+
}
|
|
19851
|
+
return;
|
|
19852
|
+
} catch (e) {
|
|
19853
|
+
throw e;
|
|
19854
|
+
}
|
|
19855
|
+
}
|
|
19779
19856
|
}
|
|
19780
19857
|
const accessLevels = ["viewer", "operator", "administrator"];
|
|
19781
19858
|
const viewer = "viewer";
|