@luxonis/visualizer-protobuf 2.68.2 → 2.68.4
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/{index-BflprWpG.js → index-7qQNdRzY.js} +1244 -460
- package/dist/{index-V6uYKXVV.js → index-B-YvYqeS.js} +2 -2
- package/dist/{index-BbYiLTP9.js → index-BRQewqsW.js} +1 -1
- package/dist/{index-NlHd3z8S.js → index-BdMCbxLs.js} +1 -1
- package/dist/{index-jUC5HjcL.js → index-Bspn2znq.js} +1 -1
- package/dist/{index-B3JtlQLZ.js → index-BtNlfgUY.js} +1 -1
- package/dist/{index-jNciNmIq.js → index-C-gyQZe6.js} +1 -1
- package/dist/{index-rFf8tT0t.js → index-CaaYr7e4.js} +1 -1
- package/dist/{index-CptfE58z.js → index-CqgVBu62.js} +1 -1
- package/dist/{index-COb2wW-D.js → index-CwGTzS5e.js} +1 -1
- package/dist/{index-BHFcd13I.js → index-DDSwKM6g.js} +1 -1
- package/dist/{index-CJYh28ux.js → index-DIjTsK3r.js} +1 -1
- package/dist/{index-C5HCa9LM.js → index-DJcmDPtm.js} +1 -1
- package/dist/{index-DwejR5F9.js → index-DNvBsNl1.js} +1 -1
- package/dist/{index-CZJ6Fn28.js → index-DQPQZ-yd.js} +1 -1
- package/dist/{index-GpwHYY7M.js → index-DgOS8MMD.js} +1 -1
- package/dist/{index-DCTEmKiy.js → index-DgwouNl2.js} +1 -1
- package/dist/{index-0qz5QyqO.js → index-DybKX-0d.js} +1 -1
- package/dist/{index-CyI9P6B1.js → index-iOv5ZlQQ.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/src/components/Panel.d.ts.map +1 -1
- package/dist/lib/src/components/Panel.js +4 -2
- package/dist/lib/src/components/Panel.js.map +1 -1
- package/package.json +2 -2
|
@@ -2,9 +2,9 @@ import { d as dist$1, e as estimateObjectSize, r as reportError, A as AppError,
|
|
|
2
2
|
import { w as wrap$3, p as proxy } from './comlink-CsH1ih07.js';
|
|
3
3
|
import { u as uint8ArrayToUint16Array } from './utils-Hzt3wxhG.js';
|
|
4
4
|
import { p as protobufsBySchema, a as protobufSchemaNameToType, g as getDefaultExportFromCjs, c as commonjsGlobal } from './protobuf-BFCtaU7c.js';
|
|
5
|
-
import { B as BinaryOpcode } from './FoxgloveServer-h5m-pXp3.js';
|
|
6
5
|
import * as React$1 from 'react';
|
|
7
6
|
import React__default, { useRef, useMemo, createContext, useContext, forwardRef, createElement, useState, Component, useCallback, useEffect, useLayoutEffect, useReducer, useImperativeHandle, Fragment as Fragment$1, Suspense } from 'react';
|
|
7
|
+
import { B as BinaryOpcode } from './FoxgloveServer-h5m-pXp3.js';
|
|
8
8
|
import { p as parseFoxgloveMessage } from './foxglove-protocol-BSYuI-q2.js';
|
|
9
9
|
import { DndProvider } from 'react-dnd';
|
|
10
10
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
@@ -1445,9 +1445,6 @@ class WebRtcDataChannel {
|
|
|
1445
1445
|
return this.channel.label;
|
|
1446
1446
|
}
|
|
1447
1447
|
sendMessage(message) {
|
|
1448
|
-
if (message instanceof DataView && this.withFragmentation) {
|
|
1449
|
-
console.log('Sending Fragmented message:', message);
|
|
1450
|
-
}
|
|
1451
1448
|
if (this.channel.readyState === "open") {
|
|
1452
1449
|
const chunks = message instanceof DataView && this.withFragmentation
|
|
1453
1450
|
? makeChunks(message)
|
|
@@ -1576,237 +1573,6 @@ class WebRtcConnection {
|
|
|
1576
1573
|
on = this.events.on.bind(this.events);
|
|
1577
1574
|
}
|
|
1578
1575
|
|
|
1579
|
-
const ICE_SERVERS_API_ENDPOINT = "https://signal.cloud.luxonis.com/api/v1/turn-credentials";
|
|
1580
|
-
const DEFAULT_SIGNALING_SERVER_URL = "wss://signal.cloud.luxonis.com/session/";
|
|
1581
|
-
const DEFAULT_ICE_SERVERS = [
|
|
1582
|
-
{ urls: ["stun:stun.l.google.com:19302", "stun:stun1.l.google.com:19302"] },
|
|
1583
|
-
];
|
|
1584
|
-
class WebRtcClient {
|
|
1585
|
-
config;
|
|
1586
|
-
socket;
|
|
1587
|
-
connection = null;
|
|
1588
|
-
signalingConnectionRetries;
|
|
1589
|
-
events = new EventEmitter();
|
|
1590
|
-
iceCandidates = [];
|
|
1591
|
-
candidateQueue = [];
|
|
1592
|
-
constructor(config) {
|
|
1593
|
-
this.config = config;
|
|
1594
|
-
// If user doesn't provide iceServers and doesn't want to use Luxonis ice servers, use default ice servers
|
|
1595
|
-
if (!config.useLuxonisIceServers && config.iceServers === undefined) {
|
|
1596
|
-
this.config.iceServers = DEFAULT_ICE_SERVERS;
|
|
1597
|
-
}
|
|
1598
|
-
this.signalingConnectionRetries =
|
|
1599
|
-
(config.signalingConnectionRetries ?? 3) || 0;
|
|
1600
|
-
console.log("WebRtcClient Configuration:", this.config);
|
|
1601
|
-
this.connectSignalingServer();
|
|
1602
|
-
}
|
|
1603
|
-
async useLuxonisIceServers() {
|
|
1604
|
-
console.log("Using Luxonis ICE servers");
|
|
1605
|
-
try {
|
|
1606
|
-
const response = await fetch(ICE_SERVERS_API_ENDPOINT);
|
|
1607
|
-
const data = (await response.json());
|
|
1608
|
-
if (data.iceServers) {
|
|
1609
|
-
if (this.config.iceServers === undefined) {
|
|
1610
|
-
this.config.iceServers = [data.iceServers];
|
|
1611
|
-
}
|
|
1612
|
-
else {
|
|
1613
|
-
this.config.iceServers.push(data.iceServers);
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
else {
|
|
1617
|
-
console.error("DAI Connection Error: Retrieved ICE servers are invalid.", data);
|
|
1618
|
-
if (this.config.iceServers === undefined ||
|
|
1619
|
-
this.config.iceServers.length === 0) {
|
|
1620
|
-
console.error("DAI Connection Error: Retrieved ICE servers are invalid and no ICE servers were provided by client, falling back to default.");
|
|
1621
|
-
this.config.iceServers = DEFAULT_ICE_SERVERS;
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
catch (error) {
|
|
1626
|
-
console.error("DAI Connection Error: Cannot retrieve ICE servers.", error);
|
|
1627
|
-
if (this.config.iceServers === undefined ||
|
|
1628
|
-
this.config.iceServers.length === 0) {
|
|
1629
|
-
console.error("DAI Connection Error: Retrieved ICE servers are invalid and no ICE servers were provided by client, falling back to default.");
|
|
1630
|
-
this.config.iceServers = DEFAULT_ICE_SERVERS;
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
get signalingServerConnected() {
|
|
1635
|
-
return this.socket.readyState === WebSocket.OPEN;
|
|
1636
|
-
}
|
|
1637
|
-
disconnect(reason) {
|
|
1638
|
-
this.connection?.close();
|
|
1639
|
-
this.sendMessage({
|
|
1640
|
-
Disconnect: {
|
|
1641
|
-
type: "normal",
|
|
1642
|
-
reason,
|
|
1643
|
-
},
|
|
1644
|
-
});
|
|
1645
|
-
}
|
|
1646
|
-
connect() {
|
|
1647
|
-
this.sendMessage({
|
|
1648
|
-
ConnectSession: {
|
|
1649
|
-
client_id: this.config.clientId,
|
|
1650
|
-
application_identifier: this.config.applicationIdentifier,
|
|
1651
|
-
auth_payload: this.config.authPayload,
|
|
1652
|
-
},
|
|
1653
|
-
});
|
|
1654
|
-
}
|
|
1655
|
-
connectSignalingServer() {
|
|
1656
|
-
this.socket = new WebSocket(this.config.signalingServerUrl ?? DEFAULT_SIGNALING_SERVER_URL);
|
|
1657
|
-
this.socket.onopen = () => {
|
|
1658
|
-
console.log("Signaling: Connected to signaling server");
|
|
1659
|
-
this.connect();
|
|
1660
|
-
};
|
|
1661
|
-
// this.socket.onclose = () => console.debug('[WebRTC] Disconnected from signaling server');
|
|
1662
|
-
this.socket.onerror = (error) => {
|
|
1663
|
-
this.events.emit("error", ["signaling_connection_error", error]);
|
|
1664
|
-
if (!this.events.isEventHandled("error")) {
|
|
1665
|
-
console.error("[WebRTC] Signaling connection error:", error);
|
|
1666
|
-
}
|
|
1667
|
-
setTimeout(() => {
|
|
1668
|
-
if (this.signalingConnectionRetries) {
|
|
1669
|
-
this.signalingConnectionRetries -= 1;
|
|
1670
|
-
if (this.socket.readyState === WebSocket.CLOSED ||
|
|
1671
|
-
this.socket.readyState === WebSocket.CLOSING) {
|
|
1672
|
-
// console.debug('[WebRTC] Reconnecting to signaling server');
|
|
1673
|
-
this.connectSignalingServer();
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
}, 3_000);
|
|
1677
|
-
};
|
|
1678
|
-
this.socket.onmessage = (event) => {
|
|
1679
|
-
const message = JSON.parse(event.data);
|
|
1680
|
-
this.handleSignalingMessage(message);
|
|
1681
|
-
};
|
|
1682
|
-
}
|
|
1683
|
-
disconnectSignalingServer(reason) {
|
|
1684
|
-
if (this.signalingServerConnected) {
|
|
1685
|
-
this.sendMessage({
|
|
1686
|
-
Disconnect: {
|
|
1687
|
-
type: "normal",
|
|
1688
|
-
reason,
|
|
1689
|
-
},
|
|
1690
|
-
});
|
|
1691
|
-
this.socket.close();
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
handleSignalingMessage(message) {
|
|
1695
|
-
if ("AcknowledgeSession" in message) {
|
|
1696
|
-
console.log("Signaling: Received AcknowledgeSession message", message);
|
|
1697
|
-
if (message.AcknowledgeSession.acknowledge) {
|
|
1698
|
-
if (this.config.useLuxonisIceServers) {
|
|
1699
|
-
this.useLuxonisIceServers().then(() => this.createConnection());
|
|
1700
|
-
}
|
|
1701
|
-
else {
|
|
1702
|
-
this.createConnection();
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
else {
|
|
1706
|
-
if (!this.events.isEventHandled("error")) {
|
|
1707
|
-
console.error("[WebRTC] Connection refused:", message.AcknowledgeSession.reason);
|
|
1708
|
-
}
|
|
1709
|
-
this.events.emit("error", [
|
|
1710
|
-
"signaling_rejected",
|
|
1711
|
-
message.AcknowledgeSession.reason,
|
|
1712
|
-
]);
|
|
1713
|
-
this.dispose("Connection refused");
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
else if ("Candidate" in message) {
|
|
1717
|
-
console.log("Signaling: Received Candidate message", message);
|
|
1718
|
-
void this.handleCandidateMessage(message);
|
|
1719
|
-
}
|
|
1720
|
-
else if ("Disconnect" in message) {
|
|
1721
|
-
console.log("Signaling: Received Disconnect message", message);
|
|
1722
|
-
this.dispose("Targed disconnected");
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
async handleCandidateMessage({ Candidate: { type: kind, candidate }, }) {
|
|
1726
|
-
if (!this.connection) {
|
|
1727
|
-
console.log("Candidate message received before connection established, adding to queue", { Candidate: { type: kind, candidate } });
|
|
1728
|
-
this.candidateQueue.push({ Candidate: { type: kind, candidate } });
|
|
1729
|
-
return;
|
|
1730
|
-
}
|
|
1731
|
-
// console.debug('[WebRTC] Processing candidate message', kind);
|
|
1732
|
-
switch (kind) {
|
|
1733
|
-
case "answer":
|
|
1734
|
-
case "offer": {
|
|
1735
|
-
const data = `${candidate}`;
|
|
1736
|
-
if (data === "null" || data === "") {
|
|
1737
|
-
console.error("[WebRTC] Offer refused: remote description cannot be null");
|
|
1738
|
-
this.reconnect("Error: received invalid candidate");
|
|
1739
|
-
return;
|
|
1740
|
-
}
|
|
1741
|
-
// console.debug('[WebRTC] Offer accepted. Setting remote description..');
|
|
1742
|
-
await this.connection.setRemoteDescription(kind, candidate);
|
|
1743
|
-
// console.debug('[WebRTC] Set remote description');
|
|
1744
|
-
for (const iceCandidate of this.iceCandidates) {
|
|
1745
|
-
// console.debug('[WebRTC] Adding stored ICE candidate');
|
|
1746
|
-
void this.connection.addIceCandidate(JSON.parse(iceCandidate));
|
|
1747
|
-
}
|
|
1748
|
-
this.iceCandidates = [];
|
|
1749
|
-
if (kind === "offer") {
|
|
1750
|
-
const answer = await this.connection.createDescription("answer");
|
|
1751
|
-
// console.debug('[WebRTC] Answer created (set local description)');
|
|
1752
|
-
this.sendMessage({
|
|
1753
|
-
Candidate: {
|
|
1754
|
-
type: "answer",
|
|
1755
|
-
candidate: answer.sdp ?? "",
|
|
1756
|
-
},
|
|
1757
|
-
});
|
|
1758
|
-
}
|
|
1759
|
-
return;
|
|
1760
|
-
}
|
|
1761
|
-
case "candidate": {
|
|
1762
|
-
if (this.connection.peerConnection.remoteDescription === null) {
|
|
1763
|
-
// console.debug('[WebRTC] Storing ICE candidate (remote description is not set yet)');
|
|
1764
|
-
this.iceCandidates.push(candidate);
|
|
1765
|
-
}
|
|
1766
|
-
else {
|
|
1767
|
-
// console.debug('[WebRTC] Adding ICE candidate');
|
|
1768
|
-
return this.connection.addIceCandidate(JSON.parse(candidate));
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
reconnect(reason) {
|
|
1774
|
-
// console.debug(`[WebRTC] Reconnecting: ${reason}`);
|
|
1775
|
-
this.disconnect(reason);
|
|
1776
|
-
this.connect();
|
|
1777
|
-
}
|
|
1778
|
-
sendMessage(message) {
|
|
1779
|
-
// console.debug('[WebRTC] Sending message', message);
|
|
1780
|
-
if (this.socket.readyState === WebSocket.OPEN) {
|
|
1781
|
-
this.socket.send(JSON.stringify(message));
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
createConnection() {
|
|
1785
|
-
this.connection = new WebRtcConnection({
|
|
1786
|
-
iceServers: this.config.iceServers,
|
|
1787
|
-
onCandidate: (candidate) => {
|
|
1788
|
-
this.sendMessage({
|
|
1789
|
-
Candidate: {
|
|
1790
|
-
type: "candidate",
|
|
1791
|
-
candidate: JSON.stringify(candidate),
|
|
1792
|
-
},
|
|
1793
|
-
});
|
|
1794
|
-
},
|
|
1795
|
-
onConnectionEstablished: () => this.disconnectSignalingServer("P2P connection established"),
|
|
1796
|
-
withFragmentation: this.config.withFragmentation,
|
|
1797
|
-
});
|
|
1798
|
-
for (const candidate of this.candidateQueue) {
|
|
1799
|
-
void this.handleCandidateMessage(candidate);
|
|
1800
|
-
}
|
|
1801
|
-
this.events.emit("connection_established", [this.connection]);
|
|
1802
|
-
}
|
|
1803
|
-
dispose(reason) {
|
|
1804
|
-
this.disconnect(reason);
|
|
1805
|
-
this.disconnectSignalingServer(reason);
|
|
1806
|
-
}
|
|
1807
|
-
on = this.events.on.bind(this.events);
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
1576
|
var safeStableStringify = {exports: {}};
|
|
1811
1577
|
|
|
1812
1578
|
(function (module, exports) {
|
|
@@ -5982,9 +5748,7 @@ function setYear(date, year) {
|
|
|
5982
5748
|
return _date;
|
|
5983
5749
|
}
|
|
5984
5750
|
|
|
5985
|
-
|
|
5986
|
-
const MINUTE = 60 * SECOND;
|
|
5987
|
-
function formatDate$1(date, format$1) {
|
|
5751
|
+
function formatDate$2(date, format$1) {
|
|
5988
5752
|
switch (format$1) {
|
|
5989
5753
|
case 'iso':
|
|
5990
5754
|
return date.toISOString();
|
|
@@ -10232,61 +9996,6 @@ z
|
|
|
10232
9996
|
.string()
|
|
10233
9997
|
.regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?$/, { message: 'Version must be in the format X.Y or X.Y.Z' });
|
|
10234
9998
|
|
|
10235
|
-
/**
|
|
10236
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
10237
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
10238
|
-
*/
|
|
10239
|
-
var byteToHex$1 = [];
|
|
10240
|
-
for (var i$1 = 0; i$1 < 256; ++i$1) {
|
|
10241
|
-
byteToHex$1.push((i$1 + 0x100).toString(16).slice(1));
|
|
10242
|
-
}
|
|
10243
|
-
function unsafeStringify$1(arr, offset = 0) {
|
|
10244
|
-
// Note: Be careful editing this code! It's been tuned for performance
|
|
10245
|
-
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
10246
|
-
//
|
|
10247
|
-
// Note to future-self: No, you can't remove the `toLowerCase()` call.
|
|
10248
|
-
// REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
|
|
10249
|
-
return (byteToHex$1[arr[offset + 0]] + byteToHex$1[arr[offset + 1]] + byteToHex$1[arr[offset + 2]] + byteToHex$1[arr[offset + 3]] + '-' + byteToHex$1[arr[offset + 4]] + byteToHex$1[arr[offset + 5]] + '-' + byteToHex$1[arr[offset + 6]] + byteToHex$1[arr[offset + 7]] + '-' + byteToHex$1[arr[offset + 8]] + byteToHex$1[arr[offset + 9]] + '-' + byteToHex$1[arr[offset + 10]] + byteToHex$1[arr[offset + 11]] + byteToHex$1[arr[offset + 12]] + byteToHex$1[arr[offset + 13]] + byteToHex$1[arr[offset + 14]] + byteToHex$1[arr[offset + 15]]).toLowerCase();
|
|
10250
|
-
}
|
|
10251
|
-
|
|
10252
|
-
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
10253
|
-
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
10254
|
-
// generators (like Math.random()).
|
|
10255
|
-
|
|
10256
|
-
var getRandomValues$1;
|
|
10257
|
-
var rnds8$1 = new Uint8Array(16);
|
|
10258
|
-
function rng$1() {
|
|
10259
|
-
// lazy load so that environments that need to polyfill have a chance to do so
|
|
10260
|
-
if (!getRandomValues$1) {
|
|
10261
|
-
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
10262
|
-
getRandomValues$1 = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
10263
|
-
if (!getRandomValues$1) {
|
|
10264
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
10265
|
-
}
|
|
10266
|
-
}
|
|
10267
|
-
return getRandomValues$1(rnds8$1);
|
|
10268
|
-
}
|
|
10269
|
-
|
|
10270
|
-
var randomUUID$1 = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
10271
|
-
var native$1 = {
|
|
10272
|
-
randomUUID: randomUUID$1
|
|
10273
|
-
};
|
|
10274
|
-
|
|
10275
|
-
function v4$1(options, buf, offset) {
|
|
10276
|
-
if (native$1.randomUUID && !buf && !options) {
|
|
10277
|
-
return native$1.randomUUID();
|
|
10278
|
-
}
|
|
10279
|
-
options = options || {};
|
|
10280
|
-
var rnds = options.random || (options.rng || rng$1)();
|
|
10281
|
-
|
|
10282
|
-
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
10283
|
-
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
10284
|
-
rnds[8] = rnds[8] & 0x3f | 0x80;
|
|
10285
|
-
return unsafeStringify$1(rnds);
|
|
10286
|
-
}
|
|
10287
|
-
|
|
10288
|
-
const MB = 1024 ** 2;
|
|
10289
|
-
|
|
10290
9999
|
/******************************************************************************
|
|
10291
10000
|
Copyright (c) Microsoft Corporation.
|
|
10292
10001
|
|
|
@@ -14948,7 +14657,7 @@ function getFormatter$2(_a, type, getDateTimeFormat, options) {
|
|
|
14948
14657
|
}
|
|
14949
14658
|
return getDateTimeFormat(locale, filteredOptions);
|
|
14950
14659
|
}
|
|
14951
|
-
function formatDate(config, getDateTimeFormat) {
|
|
14660
|
+
function formatDate$1(config, getDateTimeFormat) {
|
|
14952
14661
|
var _a = [];
|
|
14953
14662
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
14954
14663
|
_a[_i - 2] = arguments[_i];
|
|
@@ -15244,7 +14953,7 @@ function createIntl$1(config, cache) {
|
|
|
15244
14953
|
onError(new MissingDataError("Missing locale data for locale: \"".concat(locale, "\" in Intl.DateTimeFormat. Using default locale: \"").concat(defaultLocale, "\" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details")));
|
|
15245
14954
|
}
|
|
15246
14955
|
verifyConfigMessages(resolvedConfig);
|
|
15247
|
-
return __assign$6(__assign$6({}, resolvedConfig), { formatters: formatters, formatNumber: formatNumber$1.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateTimeRange: formatDateTimeRange.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules),
|
|
14956
|
+
return __assign$6(__assign$6({}, resolvedConfig), { formatters: formatters, formatNumber: formatNumber$1.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: formatDate$1.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateTimeRange: formatDateTimeRange.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules),
|
|
15248
14957
|
// @ts-expect-error TODO: will get to this later
|
|
15249
14958
|
formatMessage: formatMessage$1.bind(null, resolvedConfig, formatters),
|
|
15250
14959
|
// @ts-expect-error TODO: will get to this later
|
|
@@ -15937,15 +15646,15 @@ function isErrorLike(value) {
|
|
|
15937
15646
|
&& 'stack' in value;
|
|
15938
15647
|
}
|
|
15939
15648
|
|
|
15940
|
-
const ANSI_BACKGROUND_OFFSET = 10;
|
|
15649
|
+
const ANSI_BACKGROUND_OFFSET$1 = 10;
|
|
15941
15650
|
|
|
15942
|
-
const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
|
|
15651
|
+
const wrapAnsi16$1 = (offset = 0) => code => `\u001B[${code + offset}m`;
|
|
15943
15652
|
|
|
15944
|
-
const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
|
15653
|
+
const wrapAnsi256$1 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
|
15945
15654
|
|
|
15946
|
-
const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
|
15655
|
+
const wrapAnsi16m$1 = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
|
15947
15656
|
|
|
15948
|
-
const styles$
|
|
15657
|
+
const styles$3 = {
|
|
15949
15658
|
modifier: {
|
|
15950
15659
|
reset: [0, 0],
|
|
15951
15660
|
// 21 isn't widely supported and 22 does the same thing
|
|
@@ -16004,49 +15713,49 @@ const styles$1 = {
|
|
|
16004
15713
|
},
|
|
16005
15714
|
};
|
|
16006
15715
|
|
|
16007
|
-
Object.keys(styles$
|
|
16008
|
-
const foregroundColorNames = Object.keys(styles$
|
|
16009
|
-
const backgroundColorNames = Object.keys(styles$
|
|
16010
|
-
[...foregroundColorNames, ...backgroundColorNames];
|
|
15716
|
+
Object.keys(styles$3.modifier);
|
|
15717
|
+
const foregroundColorNames$1 = Object.keys(styles$3.color);
|
|
15718
|
+
const backgroundColorNames$1 = Object.keys(styles$3.bgColor);
|
|
15719
|
+
[...foregroundColorNames$1, ...backgroundColorNames$1];
|
|
16011
15720
|
|
|
16012
|
-
function assembleStyles() {
|
|
15721
|
+
function assembleStyles$1() {
|
|
16013
15722
|
const codes = new Map();
|
|
16014
15723
|
|
|
16015
|
-
for (const [groupName, group] of Object.entries(styles$
|
|
15724
|
+
for (const [groupName, group] of Object.entries(styles$3)) {
|
|
16016
15725
|
for (const [styleName, style] of Object.entries(group)) {
|
|
16017
|
-
styles$
|
|
15726
|
+
styles$3[styleName] = {
|
|
16018
15727
|
open: `\u001B[${style[0]}m`,
|
|
16019
15728
|
close: `\u001B[${style[1]}m`,
|
|
16020
15729
|
};
|
|
16021
15730
|
|
|
16022
|
-
group[styleName] = styles$
|
|
15731
|
+
group[styleName] = styles$3[styleName];
|
|
16023
15732
|
|
|
16024
15733
|
codes.set(style[0], style[1]);
|
|
16025
15734
|
}
|
|
16026
15735
|
|
|
16027
|
-
Object.defineProperty(styles$
|
|
15736
|
+
Object.defineProperty(styles$3, groupName, {
|
|
16028
15737
|
value: group,
|
|
16029
15738
|
enumerable: false,
|
|
16030
15739
|
});
|
|
16031
15740
|
}
|
|
16032
15741
|
|
|
16033
|
-
Object.defineProperty(styles$
|
|
15742
|
+
Object.defineProperty(styles$3, 'codes', {
|
|
16034
15743
|
value: codes,
|
|
16035
15744
|
enumerable: false,
|
|
16036
15745
|
});
|
|
16037
15746
|
|
|
16038
|
-
styles$
|
|
16039
|
-
styles$
|
|
15747
|
+
styles$3.color.close = '\u001B[39m';
|
|
15748
|
+
styles$3.bgColor.close = '\u001B[49m';
|
|
16040
15749
|
|
|
16041
|
-
styles$
|
|
16042
|
-
styles$
|
|
16043
|
-
styles$
|
|
16044
|
-
styles$
|
|
16045
|
-
styles$
|
|
16046
|
-
styles$
|
|
15750
|
+
styles$3.color.ansi = wrapAnsi16$1();
|
|
15751
|
+
styles$3.color.ansi256 = wrapAnsi256$1();
|
|
15752
|
+
styles$3.color.ansi16m = wrapAnsi16m$1();
|
|
15753
|
+
styles$3.bgColor.ansi = wrapAnsi16$1(ANSI_BACKGROUND_OFFSET$1);
|
|
15754
|
+
styles$3.bgColor.ansi256 = wrapAnsi256$1(ANSI_BACKGROUND_OFFSET$1);
|
|
15755
|
+
styles$3.bgColor.ansi16m = wrapAnsi16m$1(ANSI_BACKGROUND_OFFSET$1);
|
|
16047
15756
|
|
|
16048
15757
|
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
|
|
16049
|
-
Object.defineProperties(styles$
|
|
15758
|
+
Object.defineProperties(styles$3, {
|
|
16050
15759
|
rgbToAnsi256: {
|
|
16051
15760
|
value(red, green, blue) {
|
|
16052
15761
|
// We use the extended greyscale palette here, with the exception of
|
|
@@ -16096,7 +15805,7 @@ function assembleStyles() {
|
|
|
16096
15805
|
enumerable: false,
|
|
16097
15806
|
},
|
|
16098
15807
|
hexToAnsi256: {
|
|
16099
|
-
value: hex => styles$
|
|
15808
|
+
value: hex => styles$3.rgbToAnsi256(...styles$3.hexToRgb(hex)),
|
|
16100
15809
|
enumerable: false,
|
|
16101
15810
|
},
|
|
16102
15811
|
ansi256ToAnsi: {
|
|
@@ -16145,23 +15854,23 @@ function assembleStyles() {
|
|
|
16145
15854
|
enumerable: false,
|
|
16146
15855
|
},
|
|
16147
15856
|
rgbToAnsi: {
|
|
16148
|
-
value: (red, green, blue) => styles$
|
|
15857
|
+
value: (red, green, blue) => styles$3.ansi256ToAnsi(styles$3.rgbToAnsi256(red, green, blue)),
|
|
16149
15858
|
enumerable: false,
|
|
16150
15859
|
},
|
|
16151
15860
|
hexToAnsi: {
|
|
16152
|
-
value: hex => styles$
|
|
15861
|
+
value: hex => styles$3.ansi256ToAnsi(styles$3.hexToAnsi256(hex)),
|
|
16153
15862
|
enumerable: false,
|
|
16154
15863
|
},
|
|
16155
15864
|
});
|
|
16156
15865
|
|
|
16157
|
-
return styles$
|
|
15866
|
+
return styles$3;
|
|
16158
15867
|
}
|
|
16159
15868
|
|
|
16160
|
-
const ansiStyles = assembleStyles();
|
|
15869
|
+
const ansiStyles$1 = assembleStyles$1();
|
|
16161
15870
|
|
|
16162
15871
|
/* eslint-env browser */
|
|
16163
15872
|
|
|
16164
|
-
const level = (() => {
|
|
15873
|
+
const level$1 = (() => {
|
|
16165
15874
|
if (navigator.userAgentData) {
|
|
16166
15875
|
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
|
16167
15876
|
if (brand && brand.version > 93) {
|
|
@@ -16176,20 +15885,20 @@ const level = (() => {
|
|
|
16176
15885
|
return 0;
|
|
16177
15886
|
})();
|
|
16178
15887
|
|
|
16179
|
-
const colorSupport = level !== 0 && {
|
|
16180
|
-
level,
|
|
15888
|
+
const colorSupport$1 = level$1 !== 0 && {
|
|
15889
|
+
level: level$1,
|
|
16181
15890
|
hasBasic: true,
|
|
16182
|
-
has256: level >= 2,
|
|
16183
|
-
has16m: level >= 3,
|
|
15891
|
+
has256: level$1 >= 2,
|
|
15892
|
+
has16m: level$1 >= 3,
|
|
16184
15893
|
};
|
|
16185
15894
|
|
|
16186
|
-
const supportsColor = {
|
|
16187
|
-
stdout: colorSupport,
|
|
16188
|
-
stderr: colorSupport,
|
|
15895
|
+
const supportsColor$1 = {
|
|
15896
|
+
stdout: colorSupport$1,
|
|
15897
|
+
stderr: colorSupport$1,
|
|
16189
15898
|
};
|
|
16190
15899
|
|
|
16191
15900
|
// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.
|
|
16192
|
-
function stringReplaceAll(string, substring, replacer) {
|
|
15901
|
+
function stringReplaceAll$1(string, substring, replacer) {
|
|
16193
15902
|
let index = string.indexOf(substring);
|
|
16194
15903
|
if (index === -1) {
|
|
16195
15904
|
return string;
|
|
@@ -16208,7 +15917,7 @@ function stringReplaceAll(string, substring, replacer) {
|
|
|
16208
15917
|
return returnValue;
|
|
16209
15918
|
}
|
|
16210
15919
|
|
|
16211
|
-
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
15920
|
+
function stringEncaseCRLFWithFirstIndex$1(string, prefix, postfix, index) {
|
|
16212
15921
|
let endIndex = 0;
|
|
16213
15922
|
let returnValue = '';
|
|
16214
15923
|
do {
|
|
@@ -16222,124 +15931,124 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
|
16222
15931
|
return returnValue;
|
|
16223
15932
|
}
|
|
16224
15933
|
|
|
16225
|
-
const {stdout: stdoutColor, stderr: stderrColor} = supportsColor;
|
|
15934
|
+
const {stdout: stdoutColor$1, stderr: stderrColor$1} = supportsColor$1;
|
|
16226
15935
|
|
|
16227
|
-
const GENERATOR = Symbol('GENERATOR');
|
|
16228
|
-
const STYLER = Symbol('STYLER');
|
|
16229
|
-
const IS_EMPTY = Symbol('IS_EMPTY');
|
|
15936
|
+
const GENERATOR$1 = Symbol('GENERATOR');
|
|
15937
|
+
const STYLER$1 = Symbol('STYLER');
|
|
15938
|
+
const IS_EMPTY$1 = Symbol('IS_EMPTY');
|
|
16230
15939
|
|
|
16231
15940
|
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
|
16232
|
-
const levelMapping = [
|
|
15941
|
+
const levelMapping$1 = [
|
|
16233
15942
|
'ansi',
|
|
16234
15943
|
'ansi',
|
|
16235
15944
|
'ansi256',
|
|
16236
15945
|
'ansi16m',
|
|
16237
15946
|
];
|
|
16238
15947
|
|
|
16239
|
-
const styles = Object.create(null);
|
|
15948
|
+
const styles$2 = Object.create(null);
|
|
16240
15949
|
|
|
16241
|
-
const applyOptions = (object, options = {}) => {
|
|
15950
|
+
const applyOptions$1 = (object, options = {}) => {
|
|
16242
15951
|
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
16243
15952
|
throw new Error('The `level` option should be an integer from 0 to 3');
|
|
16244
15953
|
}
|
|
16245
15954
|
|
|
16246
15955
|
// Detect level if not set manually
|
|
16247
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
15956
|
+
const colorLevel = stdoutColor$1 ? stdoutColor$1.level : 0;
|
|
16248
15957
|
object.level = options.level === undefined ? colorLevel : options.level;
|
|
16249
15958
|
};
|
|
16250
15959
|
|
|
16251
|
-
const chalkFactory = options => {
|
|
15960
|
+
const chalkFactory$1 = options => {
|
|
16252
15961
|
const chalk = (...strings) => strings.join(' ');
|
|
16253
|
-
applyOptions(chalk, options);
|
|
15962
|
+
applyOptions$1(chalk, options);
|
|
16254
15963
|
|
|
16255
|
-
Object.setPrototypeOf(chalk, createChalk.prototype);
|
|
15964
|
+
Object.setPrototypeOf(chalk, createChalk$1.prototype);
|
|
16256
15965
|
|
|
16257
15966
|
return chalk;
|
|
16258
15967
|
};
|
|
16259
15968
|
|
|
16260
|
-
function createChalk(options) {
|
|
16261
|
-
return chalkFactory(options);
|
|
15969
|
+
function createChalk$1(options) {
|
|
15970
|
+
return chalkFactory$1(options);
|
|
16262
15971
|
}
|
|
16263
15972
|
|
|
16264
|
-
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
15973
|
+
Object.setPrototypeOf(createChalk$1.prototype, Function.prototype);
|
|
16265
15974
|
|
|
16266
|
-
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
16267
|
-
styles[styleName] = {
|
|
15975
|
+
for (const [styleName, style] of Object.entries(ansiStyles$1)) {
|
|
15976
|
+
styles$2[styleName] = {
|
|
16268
15977
|
get() {
|
|
16269
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
15978
|
+
const builder = createBuilder$1(this, createStyler$1(style.open, style.close, this[STYLER$1]), this[IS_EMPTY$1]);
|
|
16270
15979
|
Object.defineProperty(this, styleName, {value: builder});
|
|
16271
15980
|
return builder;
|
|
16272
15981
|
},
|
|
16273
15982
|
};
|
|
16274
15983
|
}
|
|
16275
15984
|
|
|
16276
|
-
styles.visible = {
|
|
15985
|
+
styles$2.visible = {
|
|
16277
15986
|
get() {
|
|
16278
|
-
const builder = createBuilder(this, this[STYLER], true);
|
|
15987
|
+
const builder = createBuilder$1(this, this[STYLER$1], true);
|
|
16279
15988
|
Object.defineProperty(this, 'visible', {value: builder});
|
|
16280
15989
|
return builder;
|
|
16281
15990
|
},
|
|
16282
15991
|
};
|
|
16283
15992
|
|
|
16284
|
-
const getModelAnsi = (model, level, type, ...arguments_) => {
|
|
15993
|
+
const getModelAnsi$1 = (model, level, type, ...arguments_) => {
|
|
16285
15994
|
if (model === 'rgb') {
|
|
16286
15995
|
if (level === 'ansi16m') {
|
|
16287
|
-
return ansiStyles[type].ansi16m(...arguments_);
|
|
15996
|
+
return ansiStyles$1[type].ansi16m(...arguments_);
|
|
16288
15997
|
}
|
|
16289
15998
|
|
|
16290
15999
|
if (level === 'ansi256') {
|
|
16291
|
-
return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
|
|
16000
|
+
return ansiStyles$1[type].ansi256(ansiStyles$1.rgbToAnsi256(...arguments_));
|
|
16292
16001
|
}
|
|
16293
16002
|
|
|
16294
|
-
return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
|
|
16003
|
+
return ansiStyles$1[type].ansi(ansiStyles$1.rgbToAnsi(...arguments_));
|
|
16295
16004
|
}
|
|
16296
16005
|
|
|
16297
16006
|
if (model === 'hex') {
|
|
16298
|
-
return getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));
|
|
16007
|
+
return getModelAnsi$1('rgb', level, type, ...ansiStyles$1.hexToRgb(...arguments_));
|
|
16299
16008
|
}
|
|
16300
16009
|
|
|
16301
|
-
return ansiStyles[type][model](...arguments_);
|
|
16010
|
+
return ansiStyles$1[type][model](...arguments_);
|
|
16302
16011
|
};
|
|
16303
16012
|
|
|
16304
|
-
const usedModels = ['rgb', 'hex', 'ansi256'];
|
|
16013
|
+
const usedModels$1 = ['rgb', 'hex', 'ansi256'];
|
|
16305
16014
|
|
|
16306
|
-
for (const model of usedModels) {
|
|
16307
|
-
styles[model] = {
|
|
16015
|
+
for (const model of usedModels$1) {
|
|
16016
|
+
styles$2[model] = {
|
|
16308
16017
|
get() {
|
|
16309
16018
|
const {level} = this;
|
|
16310
16019
|
return function (...arguments_) {
|
|
16311
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);
|
|
16312
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
16020
|
+
const styler = createStyler$1(getModelAnsi$1(model, levelMapping$1[level], 'color', ...arguments_), ansiStyles$1.color.close, this[STYLER$1]);
|
|
16021
|
+
return createBuilder$1(this, styler, this[IS_EMPTY$1]);
|
|
16313
16022
|
};
|
|
16314
16023
|
},
|
|
16315
16024
|
};
|
|
16316
16025
|
|
|
16317
16026
|
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
|
16318
|
-
styles[bgModel] = {
|
|
16027
|
+
styles$2[bgModel] = {
|
|
16319
16028
|
get() {
|
|
16320
16029
|
const {level} = this;
|
|
16321
16030
|
return function (...arguments_) {
|
|
16322
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
|
|
16323
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
16031
|
+
const styler = createStyler$1(getModelAnsi$1(model, levelMapping$1[level], 'bgColor', ...arguments_), ansiStyles$1.bgColor.close, this[STYLER$1]);
|
|
16032
|
+
return createBuilder$1(this, styler, this[IS_EMPTY$1]);
|
|
16324
16033
|
};
|
|
16325
16034
|
},
|
|
16326
16035
|
};
|
|
16327
16036
|
}
|
|
16328
16037
|
|
|
16329
|
-
const proto$
|
|
16330
|
-
...styles,
|
|
16038
|
+
const proto$2 = Object.defineProperties(() => {}, {
|
|
16039
|
+
...styles$2,
|
|
16331
16040
|
level: {
|
|
16332
16041
|
enumerable: true,
|
|
16333
16042
|
get() {
|
|
16334
|
-
return this[GENERATOR].level;
|
|
16043
|
+
return this[GENERATOR$1].level;
|
|
16335
16044
|
},
|
|
16336
16045
|
set(level) {
|
|
16337
|
-
this[GENERATOR].level = level;
|
|
16046
|
+
this[GENERATOR$1].level = level;
|
|
16338
16047
|
},
|
|
16339
16048
|
},
|
|
16340
16049
|
});
|
|
16341
16050
|
|
|
16342
|
-
const createStyler = (open, close, parent) => {
|
|
16051
|
+
const createStyler$1 = (open, close, parent) => {
|
|
16343
16052
|
let openAll;
|
|
16344
16053
|
let closeAll;
|
|
16345
16054
|
if (parent === undefined) {
|
|
@@ -16359,28 +16068,28 @@ const createStyler = (open, close, parent) => {
|
|
|
16359
16068
|
};
|
|
16360
16069
|
};
|
|
16361
16070
|
|
|
16362
|
-
const createBuilder = (self, _styler, _isEmpty) => {
|
|
16071
|
+
const createBuilder$1 = (self, _styler, _isEmpty) => {
|
|
16363
16072
|
// Single argument is hot path, implicit coercion is faster than anything
|
|
16364
16073
|
// eslint-disable-next-line no-implicit-coercion
|
|
16365
|
-
const builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
|
16074
|
+
const builder = (...arguments_) => applyStyle$1(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
|
16366
16075
|
|
|
16367
16076
|
// We alter the prototype because we must return a function, but there is
|
|
16368
16077
|
// no way to create a function with a different prototype
|
|
16369
|
-
Object.setPrototypeOf(builder, proto$
|
|
16078
|
+
Object.setPrototypeOf(builder, proto$2);
|
|
16370
16079
|
|
|
16371
|
-
builder[GENERATOR] = self;
|
|
16372
|
-
builder[STYLER] = _styler;
|
|
16373
|
-
builder[IS_EMPTY] = _isEmpty;
|
|
16080
|
+
builder[GENERATOR$1] = self;
|
|
16081
|
+
builder[STYLER$1] = _styler;
|
|
16082
|
+
builder[IS_EMPTY$1] = _isEmpty;
|
|
16374
16083
|
|
|
16375
16084
|
return builder;
|
|
16376
16085
|
};
|
|
16377
16086
|
|
|
16378
|
-
const applyStyle = (self, string) => {
|
|
16087
|
+
const applyStyle$1 = (self, string) => {
|
|
16379
16088
|
if (self.level <= 0 || !string) {
|
|
16380
|
-
return self[IS_EMPTY] ? '' : string;
|
|
16089
|
+
return self[IS_EMPTY$1] ? '' : string;
|
|
16381
16090
|
}
|
|
16382
16091
|
|
|
16383
|
-
let styler = self[STYLER];
|
|
16092
|
+
let styler = self[STYLER$1];
|
|
16384
16093
|
|
|
16385
16094
|
if (styler === undefined) {
|
|
16386
16095
|
return string;
|
|
@@ -16392,7 +16101,7 @@ const applyStyle = (self, string) => {
|
|
|
16392
16101
|
// Replace any instances already present with a re-opening code
|
|
16393
16102
|
// otherwise only the part of the string until said closing code
|
|
16394
16103
|
// will be colored, and the rest will simply be 'plain'.
|
|
16395
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
|
16104
|
+
string = stringReplaceAll$1(string, styler.close, styler.open);
|
|
16396
16105
|
|
|
16397
16106
|
styler = styler.parent;
|
|
16398
16107
|
}
|
|
@@ -16403,19 +16112,19 @@ const applyStyle = (self, string) => {
|
|
|
16403
16112
|
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
|
16404
16113
|
const lfIndex = string.indexOf('\n');
|
|
16405
16114
|
if (lfIndex !== -1) {
|
|
16406
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
16115
|
+
string = stringEncaseCRLFWithFirstIndex$1(string, closeAll, openAll, lfIndex);
|
|
16407
16116
|
}
|
|
16408
16117
|
|
|
16409
16118
|
return openAll + string + closeAll;
|
|
16410
16119
|
};
|
|
16411
16120
|
|
|
16412
|
-
Object.defineProperties(createChalk.prototype, styles);
|
|
16121
|
+
Object.defineProperties(createChalk$1.prototype, styles$2);
|
|
16413
16122
|
|
|
16414
|
-
const chalk = createChalk();
|
|
16415
|
-
createChalk({level: stderrColor ? stderrColor.level : 0});
|
|
16123
|
+
const chalk$1 = createChalk$1();
|
|
16124
|
+
createChalk$1({level: stderrColor$1 ? stderrColor$1.level : 0});
|
|
16416
16125
|
|
|
16417
16126
|
/* eslint-disable no-var */
|
|
16418
|
-
var LogLevel;
|
|
16127
|
+
var LogLevel$1;
|
|
16419
16128
|
(function (LogLevel) {
|
|
16420
16129
|
LogLevel[LogLevel["trace"] = 10] = "trace";
|
|
16421
16130
|
LogLevel[LogLevel["debug"] = 20] = "debug";
|
|
@@ -16423,11 +16132,11 @@ var LogLevel;
|
|
|
16423
16132
|
LogLevel[LogLevel["warn"] = 40] = "warn";
|
|
16424
16133
|
LogLevel[LogLevel["error"] = 50] = "error";
|
|
16425
16134
|
LogLevel[LogLevel["fatal"] = 60] = "fatal";
|
|
16426
|
-
})(LogLevel || (LogLevel = {}));
|
|
16427
|
-
function isLogFnParamsCtx(params) {
|
|
16135
|
+
})(LogLevel$1 || (LogLevel$1 = {}));
|
|
16136
|
+
function isLogFnParamsCtx$1(params) {
|
|
16428
16137
|
return typeof params[0] !== 'string' && typeof params[1] !== 'undefined';
|
|
16429
16138
|
}
|
|
16430
|
-
function parseLogFormat(value) {
|
|
16139
|
+
function parseLogFormat$1(value) {
|
|
16431
16140
|
switch (value) {
|
|
16432
16141
|
case 'pretty':
|
|
16433
16142
|
case 'plain':
|
|
@@ -16437,7 +16146,7 @@ function parseLogFormat(value) {
|
|
|
16437
16146
|
return 'json';
|
|
16438
16147
|
}
|
|
16439
16148
|
}
|
|
16440
|
-
function logLevelName(level) {
|
|
16149
|
+
function logLevelName$1(level) {
|
|
16441
16150
|
switch (level) {
|
|
16442
16151
|
case 10:
|
|
16443
16152
|
return ' T ';
|
|
@@ -16454,24 +16163,24 @@ function logLevelName(level) {
|
|
|
16454
16163
|
}
|
|
16455
16164
|
return '?????';
|
|
16456
16165
|
}
|
|
16457
|
-
function colorize(level) {
|
|
16166
|
+
function colorize$1(level) {
|
|
16458
16167
|
switch (level) {
|
|
16459
16168
|
case 10:
|
|
16460
|
-
return { color: chalk.gray, bgcolor: chalk.bgGray.black };
|
|
16169
|
+
return { color: chalk$1.gray, bgcolor: chalk$1.bgGray.black };
|
|
16461
16170
|
case 20:
|
|
16462
|
-
return { color: chalk.gray, bgcolor: chalk.bgGray.black };
|
|
16171
|
+
return { color: chalk$1.gray, bgcolor: chalk$1.bgGray.black };
|
|
16463
16172
|
case 30:
|
|
16464
|
-
return { color: chalk.white, bgcolor: chalk.bgWhite.black };
|
|
16173
|
+
return { color: chalk$1.white, bgcolor: chalk$1.bgWhite.black };
|
|
16465
16174
|
case 40:
|
|
16466
|
-
return { color: chalk.yellow, bgcolor: chalk.bgYellow.black };
|
|
16175
|
+
return { color: chalk$1.yellow, bgcolor: chalk$1.bgYellow.black };
|
|
16467
16176
|
case 50:
|
|
16468
|
-
return { color: chalk.red, bgcolor: chalk.bgRed.black };
|
|
16177
|
+
return { color: chalk$1.red, bgcolor: chalk$1.bgRed.black };
|
|
16469
16178
|
case 60:
|
|
16470
|
-
return { color: chalk.red, bgcolor: chalk.bgRed.black };
|
|
16179
|
+
return { color: chalk$1.red, bgcolor: chalk$1.bgRed.black };
|
|
16471
16180
|
}
|
|
16472
|
-
return { color: chalk.gray, bgcolor: chalk.bgGray.black };
|
|
16181
|
+
return { color: chalk$1.gray, bgcolor: chalk$1.bgGray.black };
|
|
16473
16182
|
}
|
|
16474
|
-
function customStringify(data, useSpaces = true) {
|
|
16183
|
+
function customStringify$1(data, useSpaces = true) {
|
|
16475
16184
|
return (stringify$3(data, (_key, value) => {
|
|
16476
16185
|
if (typeof Buffer !== 'undefined' && value instanceof Buffer) {
|
|
16477
16186
|
return value.toString('base64');
|
|
@@ -16479,13 +16188,13 @@ function customStringify(data, useSpaces = true) {
|
|
|
16479
16188
|
return value;
|
|
16480
16189
|
}, useSpaces ? 2 : undefined) ?? '');
|
|
16481
16190
|
}
|
|
16482
|
-
function prettyMessage(message) {
|
|
16191
|
+
function prettyMessage$1(message) {
|
|
16483
16192
|
const logLevel = message.level ?? 30;
|
|
16484
|
-
const { color, bgcolor } = colorize(logLevel);
|
|
16193
|
+
const { color, bgcolor } = colorize$1(logLevel);
|
|
16485
16194
|
const component = message.component ? `/${message.component}` : '';
|
|
16486
16195
|
const baseMsg = [
|
|
16487
|
-
chalk.gray(formatDate$
|
|
16488
|
-
bgcolor(logLevelName(logLevel)),
|
|
16196
|
+
chalk$1.gray(formatDate$2(new Date(message.when), 'time-dayofyear')),
|
|
16197
|
+
bgcolor(logLevelName$1(logLevel)),
|
|
16489
16198
|
color(`${message.logger.name}${component}`),
|
|
16490
16199
|
color(':'),
|
|
16491
16200
|
color(message.message),
|
|
@@ -16494,7 +16203,7 @@ function prettyMessage(message) {
|
|
|
16494
16203
|
for (const [key, value] of Object.entries(message.context)) {
|
|
16495
16204
|
if (value instanceof Error) {
|
|
16496
16205
|
try {
|
|
16497
|
-
baseMsg.push(`\n\n[key = ${key} contains Error]\n\n${customStringify(serializeError(value))}`);
|
|
16206
|
+
baseMsg.push(`\n\n[key = ${key} contains Error]\n\n${customStringify$1(serializeError(value))}`);
|
|
16498
16207
|
}
|
|
16499
16208
|
catch {
|
|
16500
16209
|
baseMsg.push(`\n\n[key = ${key} contains Error]\n\n${value.name}\n${value.message}`);
|
|
@@ -16502,31 +16211,31 @@ function prettyMessage(message) {
|
|
|
16502
16211
|
delete message.context[key];
|
|
16503
16212
|
}
|
|
16504
16213
|
}
|
|
16505
|
-
baseMsg.push(chalk.gray(`\n${customStringify(message.context)}`));
|
|
16214
|
+
baseMsg.push(chalk$1.gray(`\n${customStringify$1(message.context)}`));
|
|
16506
16215
|
}
|
|
16507
16216
|
return baseMsg.join(' ');
|
|
16508
16217
|
}
|
|
16509
|
-
function buildSerializeMessage(config) {
|
|
16218
|
+
function buildSerializeMessage$1(config) {
|
|
16510
16219
|
if (config.format === 'pretty' || config.runtime === 'development') {
|
|
16511
|
-
chalk.level = typeof document !== 'undefined' ? 0 : 3;
|
|
16512
|
-
return prettyMessage;
|
|
16220
|
+
chalk$1.level = typeof document !== 'undefined' ? 0 : 3;
|
|
16221
|
+
return prettyMessage$1;
|
|
16513
16222
|
}
|
|
16514
16223
|
else if (config.format === 'json') {
|
|
16515
|
-
return (message) => customStringify({ ...message, when: formatDate$
|
|
16224
|
+
return (message) => customStringify$1({ ...message, when: formatDate$2(message.when, 'iso') }, false);
|
|
16516
16225
|
}
|
|
16517
16226
|
else if (config.format === 'plain') {
|
|
16518
16227
|
return (message) => {
|
|
16519
16228
|
const logLevel = message.context.logLevel ?? 30;
|
|
16520
16229
|
const component = message.context.component ? `/${JSON.stringify(message.context.component)}` : '';
|
|
16521
16230
|
const baseMsg = [
|
|
16522
|
-
formatDate$
|
|
16523
|
-
logLevelName(logLevel),
|
|
16231
|
+
formatDate$2(message.when, 'time-dayofyear'),
|
|
16232
|
+
logLevelName$1(logLevel),
|
|
16524
16233
|
`${message.logger.name}${component}`,
|
|
16525
16234
|
':',
|
|
16526
16235
|
message.message,
|
|
16527
16236
|
];
|
|
16528
16237
|
if (Object.keys(message.context).length > 0) {
|
|
16529
|
-
baseMsg.push(`\n${customStringify(message.context)}`);
|
|
16238
|
+
baseMsg.push(`\n${customStringify$1(message.context)}`);
|
|
16530
16239
|
}
|
|
16531
16240
|
return baseMsg.join(' ');
|
|
16532
16241
|
};
|
|
@@ -16535,7 +16244,7 @@ function buildSerializeMessage(config) {
|
|
|
16535
16244
|
throw new Error(`invalid configuration provided ${JSON.stringify(config, undefined, 2)}`);
|
|
16536
16245
|
}
|
|
16537
16246
|
}
|
|
16538
|
-
const writeMessage = (msg) => {
|
|
16247
|
+
const writeMessage$1 = (msg) => {
|
|
16539
16248
|
if (msg.level < msg.logger.config.level)
|
|
16540
16249
|
return;
|
|
16541
16250
|
const message = msg.logger.serializeMessage(msg);
|
|
@@ -16551,29 +16260,29 @@ const writeMessage = (msg) => {
|
|
|
16551
16260
|
console.log(message);
|
|
16552
16261
|
}
|
|
16553
16262
|
};
|
|
16554
|
-
const buildLogger = (name, initialConfig) => {
|
|
16263
|
+
const buildLogger$1 = (name, initialConfig) => {
|
|
16555
16264
|
const _config = { ...initialConfig };
|
|
16556
|
-
let serializeMessage = buildSerializeMessage(_config);
|
|
16265
|
+
let serializeMessage = buildSerializeMessage$1(_config);
|
|
16557
16266
|
const configure = (config) => {
|
|
16558
16267
|
Object.assign(_config, config);
|
|
16559
16268
|
// logger.trace({ config: logger.config }, `reconfigured logger: ${name}`);
|
|
16560
|
-
serializeMessage = buildSerializeMessage(_config);
|
|
16269
|
+
serializeMessage = buildSerializeMessage$1(_config);
|
|
16561
16270
|
};
|
|
16562
16271
|
const buildBoundFns = (opts) => {
|
|
16563
16272
|
const { component } = opts;
|
|
16564
16273
|
return {
|
|
16565
|
-
trace: log.bind({ level: LogLevel.trace, component }),
|
|
16566
|
-
debug: log.bind({ level: LogLevel.debug, component }),
|
|
16567
|
-
info: log.bind({ level: LogLevel.info, component }),
|
|
16568
|
-
warn: log.bind({ level: LogLevel.warn, component }),
|
|
16569
|
-
error: log.bind({ level: LogLevel.error, component }),
|
|
16570
|
-
fatal: log.bind({ level: LogLevel.fatal, component }),
|
|
16274
|
+
trace: log.bind({ level: LogLevel$1.trace, component }),
|
|
16275
|
+
debug: log.bind({ level: LogLevel$1.debug, component }),
|
|
16276
|
+
info: log.bind({ level: LogLevel$1.info, component }),
|
|
16277
|
+
warn: log.bind({ level: LogLevel$1.warn, component }),
|
|
16278
|
+
error: log.bind({ level: LogLevel$1.error, component }),
|
|
16279
|
+
fatal: log.bind({ level: LogLevel$1.fatal, component }),
|
|
16571
16280
|
};
|
|
16572
16281
|
};
|
|
16573
16282
|
function log(...params) {
|
|
16574
|
-
const ctxIndex = isLogFnParamsCtx(params) ? 0 : -1;
|
|
16283
|
+
const ctxIndex = isLogFnParamsCtx$1(params) ? 0 : -1;
|
|
16575
16284
|
const message = params.slice(ctxIndex + 1).join(' ');
|
|
16576
|
-
writeMessage({
|
|
16285
|
+
writeMessage$1({
|
|
16577
16286
|
logger,
|
|
16578
16287
|
when: new Date(),
|
|
16579
16288
|
level: this.level,
|
|
@@ -16629,17 +16338,17 @@ const buildLogger = (name, initialConfig) => {
|
|
|
16629
16338
|
// logger.trace({ config: logger.config }, `built logger: ${name}`);
|
|
16630
16339
|
return logger;
|
|
16631
16340
|
};
|
|
16632
|
-
const LOG_LEVEL_ENV = globalThis.ENV?.LOG_LEVEL ?? 'info';
|
|
16633
|
-
const defaultLogger = buildLogger('default', {
|
|
16634
|
-
level: (typeof LOG_LEVEL_ENV === 'string' ? parseInt(LOG_LEVEL_ENV) : LOG_LEVEL_ENV) ?? 10,
|
|
16341
|
+
const LOG_LEVEL_ENV$1 = globalThis.ENV?.LOG_LEVEL ?? 'info';
|
|
16342
|
+
const defaultLogger$1 = buildLogger$1('default', {
|
|
16343
|
+
level: (typeof LOG_LEVEL_ENV$1 === 'string' ? parseInt(LOG_LEVEL_ENV$1) : LOG_LEVEL_ENV$1) ?? 10,
|
|
16635
16344
|
rootComponent: globalThis.ENV?.LOG_ROOT_COMPONENT ?? 'logger',
|
|
16636
|
-
format: parseLogFormat(globalThis.ENV?.LOG_FORMAT),
|
|
16345
|
+
format: parseLogFormat$1(globalThis.ENV?.LOG_FORMAT),
|
|
16637
16346
|
runtime: globalThis.ENV?.RUNTIME ?? 'development',
|
|
16638
16347
|
});
|
|
16639
|
-
const log$
|
|
16640
|
-
globalThis.log = defaultLogger;
|
|
16348
|
+
const log$6 = defaultLogger$1;
|
|
16349
|
+
globalThis.log = defaultLogger$1;
|
|
16641
16350
|
|
|
16642
|
-
const customFormats = {
|
|
16351
|
+
const customFormats$1 = {
|
|
16643
16352
|
number: {
|
|
16644
16353
|
bytes: {
|
|
16645
16354
|
style: 'decimal',
|
|
@@ -16666,18 +16375,18 @@ const customFormats = {
|
|
|
16666
16375
|
},
|
|
16667
16376
|
},
|
|
16668
16377
|
};
|
|
16669
|
-
const onIntlError = (error) => {
|
|
16378
|
+
const onIntlError$1 = (error) => {
|
|
16670
16379
|
if (typeof window !== 'undefined') {
|
|
16671
|
-
log$
|
|
16380
|
+
log$6.fatal(error);
|
|
16672
16381
|
}
|
|
16673
16382
|
};
|
|
16674
|
-
const cache$
|
|
16383
|
+
const cache$2 = createIntlCache();
|
|
16675
16384
|
createIntl({
|
|
16676
16385
|
locale: 'en-US',
|
|
16677
16386
|
defaultLocale: 'en-US',
|
|
16678
|
-
formats: customFormats,
|
|
16679
|
-
onError: onIntlError,
|
|
16680
|
-
}, cache$
|
|
16387
|
+
formats: customFormats$1,
|
|
16388
|
+
onError: onIntlError$1,
|
|
16389
|
+
}, cache$2);
|
|
16681
16390
|
|
|
16682
16391
|
const undefined$1 = void null;
|
|
16683
16392
|
|
|
@@ -19697,6 +19406,1080 @@ renderCanvas.bind(null, function (data, _, opts) {
|
|
|
19697
19406
|
return SvgRenderer.render(data, opts)
|
|
19698
19407
|
});
|
|
19699
19408
|
|
|
19409
|
+
const ICE_SERVERS_API_ENDPOINT = "https://signal.cloud.luxonis.com/api/v1/turn-credentials";
|
|
19410
|
+
const DEFAULT_SIGNALING_SERVER_URL = "wss://signal.cloud.luxonis.com/session/";
|
|
19411
|
+
const DEFAULT_ICE_SERVERS = [
|
|
19412
|
+
{ urls: ["stun:stun.l.google.com:19302", "stun:stun1.l.google.com:19302"] },
|
|
19413
|
+
];
|
|
19414
|
+
const MAX_ACK_ATTEMPTS = 3;
|
|
19415
|
+
const ACK_RETRY_INTERVAL = 5_000;
|
|
19416
|
+
class WebRtcClient {
|
|
19417
|
+
config;
|
|
19418
|
+
socket;
|
|
19419
|
+
connection = null;
|
|
19420
|
+
signalingConnectionRetries;
|
|
19421
|
+
hasAck = false;
|
|
19422
|
+
ackRetryCount = 0;
|
|
19423
|
+
events = new EventEmitter();
|
|
19424
|
+
iceCandidates = [];
|
|
19425
|
+
candidateQueue = [];
|
|
19426
|
+
constructor(config) {
|
|
19427
|
+
this.config = config;
|
|
19428
|
+
// If user doesn't provide iceServers and doesn't want to use Luxonis ice servers, use default ice servers
|
|
19429
|
+
if (!config.useLuxonisIceServers && config.iceServers === undefined) {
|
|
19430
|
+
this.config.iceServers = DEFAULT_ICE_SERVERS;
|
|
19431
|
+
}
|
|
19432
|
+
this.signalingConnectionRetries =
|
|
19433
|
+
(config.signalingConnectionRetries ?? 3) || 0;
|
|
19434
|
+
this.connectSignalingServer();
|
|
19435
|
+
}
|
|
19436
|
+
async useLuxonisIceServers() {
|
|
19437
|
+
try {
|
|
19438
|
+
const response = await fetch(ICE_SERVERS_API_ENDPOINT);
|
|
19439
|
+
const data = (await response.json());
|
|
19440
|
+
if (data.iceServers) {
|
|
19441
|
+
if (this.config.iceServers === undefined) {
|
|
19442
|
+
this.config.iceServers = [data.iceServers];
|
|
19443
|
+
}
|
|
19444
|
+
else {
|
|
19445
|
+
this.config.iceServers.push(data.iceServers);
|
|
19446
|
+
}
|
|
19447
|
+
}
|
|
19448
|
+
else {
|
|
19449
|
+
console.error("DAI Connection Error: Retrieved ICE servers are invalid.", data);
|
|
19450
|
+
if (this.config.iceServers === undefined ||
|
|
19451
|
+
this.config.iceServers.length === 0) {
|
|
19452
|
+
console.error("DAI Connection Error: Retrieved ICE servers are invalid and no ICE servers were provided by client, falling back to default.");
|
|
19453
|
+
this.config.iceServers = DEFAULT_ICE_SERVERS;
|
|
19454
|
+
}
|
|
19455
|
+
}
|
|
19456
|
+
}
|
|
19457
|
+
catch (error) {
|
|
19458
|
+
console.error("DAI Connection Error: Cannot retrieve ICE servers.", error);
|
|
19459
|
+
if (this.config.iceServers === undefined ||
|
|
19460
|
+
this.config.iceServers.length === 0) {
|
|
19461
|
+
console.error("DAI Connection Error: Retrieved ICE servers are invalid and no ICE servers were provided by client, falling back to default.");
|
|
19462
|
+
this.config.iceServers = DEFAULT_ICE_SERVERS;
|
|
19463
|
+
}
|
|
19464
|
+
}
|
|
19465
|
+
}
|
|
19466
|
+
get signalingServerConnected() {
|
|
19467
|
+
return this.socket.readyState === WebSocket.OPEN;
|
|
19468
|
+
}
|
|
19469
|
+
disconnect(reason) {
|
|
19470
|
+
this.connection?.close();
|
|
19471
|
+
this.sendMessage({
|
|
19472
|
+
Disconnect: {
|
|
19473
|
+
type: "normal",
|
|
19474
|
+
reason,
|
|
19475
|
+
},
|
|
19476
|
+
});
|
|
19477
|
+
}
|
|
19478
|
+
connect() {
|
|
19479
|
+
this.sendConnectSessionMessage();
|
|
19480
|
+
const interval = setInterval(() => {
|
|
19481
|
+
this.sendConnectSessionMessage(interval);
|
|
19482
|
+
}, ACK_RETRY_INTERVAL);
|
|
19483
|
+
}
|
|
19484
|
+
sendConnectSessionMessage(interval) {
|
|
19485
|
+
if (this.hasAck) {
|
|
19486
|
+
log$6.debug("[Signaling] Session acknowledged. Stopping retry interval.");
|
|
19487
|
+
clearInterval(interval);
|
|
19488
|
+
return;
|
|
19489
|
+
}
|
|
19490
|
+
if (this.ackRetryCount >= MAX_ACK_ATTEMPTS) {
|
|
19491
|
+
log$6.error("[Signaling] Ran out of session acknowledge attempts");
|
|
19492
|
+
clearInterval(interval);
|
|
19493
|
+
this.events.emit("error", ["signaling_connection_timeout", "Run out of attempts to connect to signaling server"]);
|
|
19494
|
+
return;
|
|
19495
|
+
}
|
|
19496
|
+
log$6.debug(`[Signaling] Sending ConnectSession message to signaling server number ${this.ackRetryCount + 1}/${MAX_ACK_ATTEMPTS}`);
|
|
19497
|
+
this.sendMessage({
|
|
19498
|
+
ConnectSession: {
|
|
19499
|
+
client_id: this.config.clientId,
|
|
19500
|
+
application_identifier: this.config.applicationIdentifier,
|
|
19501
|
+
auth_payload: this.config.authPayload,
|
|
19502
|
+
},
|
|
19503
|
+
});
|
|
19504
|
+
this.ackRetryCount += 1;
|
|
19505
|
+
}
|
|
19506
|
+
connectSignalingServer() {
|
|
19507
|
+
log$6.debug({ signalingServerUrl: this.config.signalingServerUrl ?? DEFAULT_SIGNALING_SERVER_URL }, '[Signaling] Opening connection to Signaling server');
|
|
19508
|
+
this.socket = new WebSocket(this.config.signalingServerUrl ?? DEFAULT_SIGNALING_SERVER_URL);
|
|
19509
|
+
this.socket.onopen = () => {
|
|
19510
|
+
log$6.debug("[Signaling] Connected to signaling server");
|
|
19511
|
+
this.connect();
|
|
19512
|
+
};
|
|
19513
|
+
this.socket.onclose = () => {
|
|
19514
|
+
log$6.debug('[Signaling] Disconnected from signaling server');
|
|
19515
|
+
this.events.emit("signaling_connection_closed", []);
|
|
19516
|
+
};
|
|
19517
|
+
this.socket.onerror = (error) => {
|
|
19518
|
+
this.events.emit("error", ["signaling_connection_error", error]);
|
|
19519
|
+
if (!this.events.isEventHandled("error")) {
|
|
19520
|
+
log$6.error({ error }, "[Signaling] Signaling connection error:");
|
|
19521
|
+
}
|
|
19522
|
+
setTimeout(() => {
|
|
19523
|
+
if (this.signalingConnectionRetries) {
|
|
19524
|
+
this.signalingConnectionRetries -= 1;
|
|
19525
|
+
if (this.socket.readyState === WebSocket.CLOSED ||
|
|
19526
|
+
this.socket.readyState === WebSocket.CLOSING) {
|
|
19527
|
+
// console.debug('[WebRTC] Reconnecting to signaling server');
|
|
19528
|
+
this.connectSignalingServer();
|
|
19529
|
+
}
|
|
19530
|
+
}
|
|
19531
|
+
}, 3_000);
|
|
19532
|
+
};
|
|
19533
|
+
this.socket.onmessage = (event) => {
|
|
19534
|
+
const message = JSON.parse(event.data);
|
|
19535
|
+
log$6.debug({ message }, "[Signaling] New Signaling message");
|
|
19536
|
+
this.handleSignalingMessage(message);
|
|
19537
|
+
};
|
|
19538
|
+
}
|
|
19539
|
+
disconnectSignalingServer(reason) {
|
|
19540
|
+
if (this.signalingServerConnected) {
|
|
19541
|
+
this.sendMessage({
|
|
19542
|
+
Disconnect: {
|
|
19543
|
+
type: "normal",
|
|
19544
|
+
reason,
|
|
19545
|
+
},
|
|
19546
|
+
});
|
|
19547
|
+
this.socket.close();
|
|
19548
|
+
}
|
|
19549
|
+
}
|
|
19550
|
+
handleSignalingMessage(message) {
|
|
19551
|
+
if ("AcknowledgeSession" in message) {
|
|
19552
|
+
log$6.debug({ message }, "[Signaling] Received AcknowledgeSession message");
|
|
19553
|
+
this.hasAck = true;
|
|
19554
|
+
if (message.AcknowledgeSession.acknowledge) {
|
|
19555
|
+
if (this.config.useLuxonisIceServers) {
|
|
19556
|
+
this.useLuxonisIceServers().then(() => this.createConnection());
|
|
19557
|
+
}
|
|
19558
|
+
else {
|
|
19559
|
+
this.createConnection();
|
|
19560
|
+
}
|
|
19561
|
+
}
|
|
19562
|
+
else {
|
|
19563
|
+
if (!this.events.isEventHandled("error")) {
|
|
19564
|
+
console.error("[Signaling] Connection refused:", message.AcknowledgeSession.reason);
|
|
19565
|
+
}
|
|
19566
|
+
this.events.emit("error", [
|
|
19567
|
+
"signaling_rejected",
|
|
19568
|
+
message.AcknowledgeSession.reason,
|
|
19569
|
+
]);
|
|
19570
|
+
this.dispose("Connection refused");
|
|
19571
|
+
}
|
|
19572
|
+
}
|
|
19573
|
+
else if ("Candidate" in message) {
|
|
19574
|
+
log$6.debug({ message }, "[Signaling] Received Candidate message");
|
|
19575
|
+
void this.handleCandidateMessage(message);
|
|
19576
|
+
}
|
|
19577
|
+
else if ("Disconnect" in message) {
|
|
19578
|
+
console.log({ message }, "[Signaling]: Received Disconnect message");
|
|
19579
|
+
this.dispose("Target disconnected");
|
|
19580
|
+
}
|
|
19581
|
+
}
|
|
19582
|
+
async handleCandidateMessage({ Candidate: { type: kind, candidate }, }) {
|
|
19583
|
+
if (!this.connection) {
|
|
19584
|
+
console.log("Candidate message received before connection established, adding to queue", { Candidate: { type: kind, candidate } });
|
|
19585
|
+
this.candidateQueue.push({ Candidate: { type: kind, candidate } });
|
|
19586
|
+
return;
|
|
19587
|
+
}
|
|
19588
|
+
// console.debug('[WebRTC] Processing candidate message', kind);
|
|
19589
|
+
switch (kind) {
|
|
19590
|
+
case "answer":
|
|
19591
|
+
case "offer": {
|
|
19592
|
+
const data = `${candidate}`;
|
|
19593
|
+
if (data === "null" || data === "") {
|
|
19594
|
+
console.error("[Signaling] Offer refused: remote description cannot be null");
|
|
19595
|
+
this.reconnect("Error: received invalid candidate");
|
|
19596
|
+
return;
|
|
19597
|
+
}
|
|
19598
|
+
// console.debug('[WebRTC] Offer accepted. Setting remote description..');
|
|
19599
|
+
await this.connection.setRemoteDescription(kind, candidate);
|
|
19600
|
+
// console.debug('[WebRTC] Set remote description');
|
|
19601
|
+
for (const iceCandidate of this.iceCandidates) {
|
|
19602
|
+
// console.debug('[WebRTC] Adding stored ICE candidate');
|
|
19603
|
+
void this.connection.addIceCandidate(JSON.parse(iceCandidate));
|
|
19604
|
+
}
|
|
19605
|
+
this.iceCandidates = [];
|
|
19606
|
+
if (kind === "offer") {
|
|
19607
|
+
const answer = await this.connection.createDescription("answer");
|
|
19608
|
+
// console.debug('[WebRTC] Answer created (set local description)');
|
|
19609
|
+
this.sendMessage({
|
|
19610
|
+
Candidate: {
|
|
19611
|
+
type: "answer",
|
|
19612
|
+
candidate: answer.sdp ?? "",
|
|
19613
|
+
},
|
|
19614
|
+
});
|
|
19615
|
+
}
|
|
19616
|
+
return;
|
|
19617
|
+
}
|
|
19618
|
+
case "candidate": {
|
|
19619
|
+
if (this.connection.peerConnection.remoteDescription === null) {
|
|
19620
|
+
// console.debug('[WebRTC] Storing ICE candidate (remote description is not set yet)');
|
|
19621
|
+
this.iceCandidates.push(candidate);
|
|
19622
|
+
}
|
|
19623
|
+
else {
|
|
19624
|
+
// console.debug('[WebRTC] Adding ICE candidate');
|
|
19625
|
+
return this.connection.addIceCandidate(JSON.parse(candidate));
|
|
19626
|
+
}
|
|
19627
|
+
}
|
|
19628
|
+
}
|
|
19629
|
+
}
|
|
19630
|
+
reconnect(reason) {
|
|
19631
|
+
// console.debug(`[WebRTC] Reconnecting: ${reason}`);
|
|
19632
|
+
this.disconnect(reason);
|
|
19633
|
+
this.connect();
|
|
19634
|
+
}
|
|
19635
|
+
sendMessage(message) {
|
|
19636
|
+
// console.debug('[WebRTC] Sending message', message);
|
|
19637
|
+
if (this.socket.readyState === WebSocket.OPEN) {
|
|
19638
|
+
this.socket.send(JSON.stringify(message));
|
|
19639
|
+
}
|
|
19640
|
+
}
|
|
19641
|
+
createConnection() {
|
|
19642
|
+
this.connection = new WebRtcConnection({
|
|
19643
|
+
iceServers: this.config.iceServers,
|
|
19644
|
+
onCandidate: (candidate) => {
|
|
19645
|
+
this.sendMessage({
|
|
19646
|
+
Candidate: {
|
|
19647
|
+
type: "candidate",
|
|
19648
|
+
candidate: JSON.stringify(candidate),
|
|
19649
|
+
},
|
|
19650
|
+
});
|
|
19651
|
+
},
|
|
19652
|
+
onConnectionEstablished: () => this.disconnectSignalingServer("P2P connection established"),
|
|
19653
|
+
withFragmentation: this.config.withFragmentation,
|
|
19654
|
+
});
|
|
19655
|
+
for (const candidate of this.candidateQueue) {
|
|
19656
|
+
void this.handleCandidateMessage(candidate);
|
|
19657
|
+
}
|
|
19658
|
+
this.connection.on('connection_closed', () => this.events.emit('connection_closed', []));
|
|
19659
|
+
this.events.emit("connection_established", [this.connection]);
|
|
19660
|
+
}
|
|
19661
|
+
dispose(reason) {
|
|
19662
|
+
this.disconnect(reason);
|
|
19663
|
+
this.disconnectSignalingServer(reason);
|
|
19664
|
+
}
|
|
19665
|
+
on = this.events.on.bind(this.events);
|
|
19666
|
+
}
|
|
19667
|
+
|
|
19668
|
+
const SECOND = 1000;
|
|
19669
|
+
const MINUTE = 60 * SECOND;
|
|
19670
|
+
function formatDate(date, format$1) {
|
|
19671
|
+
switch (format$1) {
|
|
19672
|
+
case 'iso':
|
|
19673
|
+
return date.toISOString();
|
|
19674
|
+
case 'time-dayofyear':
|
|
19675
|
+
return format(date, 'D HH:mm:ss', { useAdditionalDayOfYearTokens: true });
|
|
19676
|
+
case 'full':
|
|
19677
|
+
return format(date, 'yyyy/MM/dd, hh:mm a');
|
|
19678
|
+
}
|
|
19679
|
+
}
|
|
19680
|
+
|
|
19681
|
+
z.string().min(6);
|
|
19682
|
+
z
|
|
19683
|
+
.string()
|
|
19684
|
+
.regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?$/, { message: 'Version must be in the format X.Y or X.Y.Z' });
|
|
19685
|
+
|
|
19686
|
+
/**
|
|
19687
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
19688
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
19689
|
+
*/
|
|
19690
|
+
var byteToHex$1 = [];
|
|
19691
|
+
for (var i$1 = 0; i$1 < 256; ++i$1) {
|
|
19692
|
+
byteToHex$1.push((i$1 + 0x100).toString(16).slice(1));
|
|
19693
|
+
}
|
|
19694
|
+
function unsafeStringify$1(arr, offset = 0) {
|
|
19695
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
19696
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
19697
|
+
//
|
|
19698
|
+
// Note to future-self: No, you can't remove the `toLowerCase()` call.
|
|
19699
|
+
// REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
|
|
19700
|
+
return (byteToHex$1[arr[offset + 0]] + byteToHex$1[arr[offset + 1]] + byteToHex$1[arr[offset + 2]] + byteToHex$1[arr[offset + 3]] + '-' + byteToHex$1[arr[offset + 4]] + byteToHex$1[arr[offset + 5]] + '-' + byteToHex$1[arr[offset + 6]] + byteToHex$1[arr[offset + 7]] + '-' + byteToHex$1[arr[offset + 8]] + byteToHex$1[arr[offset + 9]] + '-' + byteToHex$1[arr[offset + 10]] + byteToHex$1[arr[offset + 11]] + byteToHex$1[arr[offset + 12]] + byteToHex$1[arr[offset + 13]] + byteToHex$1[arr[offset + 14]] + byteToHex$1[arr[offset + 15]]).toLowerCase();
|
|
19701
|
+
}
|
|
19702
|
+
|
|
19703
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
19704
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
19705
|
+
// generators (like Math.random()).
|
|
19706
|
+
|
|
19707
|
+
var getRandomValues$1;
|
|
19708
|
+
var rnds8$1 = new Uint8Array(16);
|
|
19709
|
+
function rng$1() {
|
|
19710
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
19711
|
+
if (!getRandomValues$1) {
|
|
19712
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
19713
|
+
getRandomValues$1 = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
19714
|
+
if (!getRandomValues$1) {
|
|
19715
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
19716
|
+
}
|
|
19717
|
+
}
|
|
19718
|
+
return getRandomValues$1(rnds8$1);
|
|
19719
|
+
}
|
|
19720
|
+
|
|
19721
|
+
var randomUUID$1 = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
19722
|
+
var native$1 = {
|
|
19723
|
+
randomUUID: randomUUID$1
|
|
19724
|
+
};
|
|
19725
|
+
|
|
19726
|
+
function v4$1(options, buf, offset) {
|
|
19727
|
+
if (native$1.randomUUID && !buf && !options) {
|
|
19728
|
+
return native$1.randomUUID();
|
|
19729
|
+
}
|
|
19730
|
+
options = options || {};
|
|
19731
|
+
var rnds = options.random || (options.rng || rng$1)();
|
|
19732
|
+
|
|
19733
|
+
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
19734
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
19735
|
+
rnds[8] = rnds[8] & 0x3f | 0x80;
|
|
19736
|
+
return unsafeStringify$1(rnds);
|
|
19737
|
+
}
|
|
19738
|
+
|
|
19739
|
+
const MB = 1024 ** 2;
|
|
19740
|
+
|
|
19741
|
+
const ANSI_BACKGROUND_OFFSET = 10;
|
|
19742
|
+
|
|
19743
|
+
const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
|
|
19744
|
+
|
|
19745
|
+
const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
|
19746
|
+
|
|
19747
|
+
const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
|
19748
|
+
|
|
19749
|
+
const styles$1 = {
|
|
19750
|
+
modifier: {
|
|
19751
|
+
reset: [0, 0],
|
|
19752
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
19753
|
+
bold: [1, 22],
|
|
19754
|
+
dim: [2, 22],
|
|
19755
|
+
italic: [3, 23],
|
|
19756
|
+
underline: [4, 24],
|
|
19757
|
+
overline: [53, 55],
|
|
19758
|
+
inverse: [7, 27],
|
|
19759
|
+
hidden: [8, 28],
|
|
19760
|
+
strikethrough: [9, 29],
|
|
19761
|
+
},
|
|
19762
|
+
color: {
|
|
19763
|
+
black: [30, 39],
|
|
19764
|
+
red: [31, 39],
|
|
19765
|
+
green: [32, 39],
|
|
19766
|
+
yellow: [33, 39],
|
|
19767
|
+
blue: [34, 39],
|
|
19768
|
+
magenta: [35, 39],
|
|
19769
|
+
cyan: [36, 39],
|
|
19770
|
+
white: [37, 39],
|
|
19771
|
+
|
|
19772
|
+
// Bright color
|
|
19773
|
+
blackBright: [90, 39],
|
|
19774
|
+
gray: [90, 39], // Alias of `blackBright`
|
|
19775
|
+
grey: [90, 39], // Alias of `blackBright`
|
|
19776
|
+
redBright: [91, 39],
|
|
19777
|
+
greenBright: [92, 39],
|
|
19778
|
+
yellowBright: [93, 39],
|
|
19779
|
+
blueBright: [94, 39],
|
|
19780
|
+
magentaBright: [95, 39],
|
|
19781
|
+
cyanBright: [96, 39],
|
|
19782
|
+
whiteBright: [97, 39],
|
|
19783
|
+
},
|
|
19784
|
+
bgColor: {
|
|
19785
|
+
bgBlack: [40, 49],
|
|
19786
|
+
bgRed: [41, 49],
|
|
19787
|
+
bgGreen: [42, 49],
|
|
19788
|
+
bgYellow: [43, 49],
|
|
19789
|
+
bgBlue: [44, 49],
|
|
19790
|
+
bgMagenta: [45, 49],
|
|
19791
|
+
bgCyan: [46, 49],
|
|
19792
|
+
bgWhite: [47, 49],
|
|
19793
|
+
|
|
19794
|
+
// Bright color
|
|
19795
|
+
bgBlackBright: [100, 49],
|
|
19796
|
+
bgGray: [100, 49], // Alias of `bgBlackBright`
|
|
19797
|
+
bgGrey: [100, 49], // Alias of `bgBlackBright`
|
|
19798
|
+
bgRedBright: [101, 49],
|
|
19799
|
+
bgGreenBright: [102, 49],
|
|
19800
|
+
bgYellowBright: [103, 49],
|
|
19801
|
+
bgBlueBright: [104, 49],
|
|
19802
|
+
bgMagentaBright: [105, 49],
|
|
19803
|
+
bgCyanBright: [106, 49],
|
|
19804
|
+
bgWhiteBright: [107, 49],
|
|
19805
|
+
},
|
|
19806
|
+
};
|
|
19807
|
+
|
|
19808
|
+
Object.keys(styles$1.modifier);
|
|
19809
|
+
const foregroundColorNames = Object.keys(styles$1.color);
|
|
19810
|
+
const backgroundColorNames = Object.keys(styles$1.bgColor);
|
|
19811
|
+
[...foregroundColorNames, ...backgroundColorNames];
|
|
19812
|
+
|
|
19813
|
+
function assembleStyles() {
|
|
19814
|
+
const codes = new Map();
|
|
19815
|
+
|
|
19816
|
+
for (const [groupName, group] of Object.entries(styles$1)) {
|
|
19817
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
19818
|
+
styles$1[styleName] = {
|
|
19819
|
+
open: `\u001B[${style[0]}m`,
|
|
19820
|
+
close: `\u001B[${style[1]}m`,
|
|
19821
|
+
};
|
|
19822
|
+
|
|
19823
|
+
group[styleName] = styles$1[styleName];
|
|
19824
|
+
|
|
19825
|
+
codes.set(style[0], style[1]);
|
|
19826
|
+
}
|
|
19827
|
+
|
|
19828
|
+
Object.defineProperty(styles$1, groupName, {
|
|
19829
|
+
value: group,
|
|
19830
|
+
enumerable: false,
|
|
19831
|
+
});
|
|
19832
|
+
}
|
|
19833
|
+
|
|
19834
|
+
Object.defineProperty(styles$1, 'codes', {
|
|
19835
|
+
value: codes,
|
|
19836
|
+
enumerable: false,
|
|
19837
|
+
});
|
|
19838
|
+
|
|
19839
|
+
styles$1.color.close = '\u001B[39m';
|
|
19840
|
+
styles$1.bgColor.close = '\u001B[49m';
|
|
19841
|
+
|
|
19842
|
+
styles$1.color.ansi = wrapAnsi16();
|
|
19843
|
+
styles$1.color.ansi256 = wrapAnsi256();
|
|
19844
|
+
styles$1.color.ansi16m = wrapAnsi16m();
|
|
19845
|
+
styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
19846
|
+
styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
19847
|
+
styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
19848
|
+
|
|
19849
|
+
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
|
|
19850
|
+
Object.defineProperties(styles$1, {
|
|
19851
|
+
rgbToAnsi256: {
|
|
19852
|
+
value(red, green, blue) {
|
|
19853
|
+
// We use the extended greyscale palette here, with the exception of
|
|
19854
|
+
// black and white. normal palette only has 4 greyscale shades.
|
|
19855
|
+
if (red === green && green === blue) {
|
|
19856
|
+
if (red < 8) {
|
|
19857
|
+
return 16;
|
|
19858
|
+
}
|
|
19859
|
+
|
|
19860
|
+
if (red > 248) {
|
|
19861
|
+
return 231;
|
|
19862
|
+
}
|
|
19863
|
+
|
|
19864
|
+
return Math.round(((red - 8) / 247) * 24) + 232;
|
|
19865
|
+
}
|
|
19866
|
+
|
|
19867
|
+
return 16
|
|
19868
|
+
+ (36 * Math.round(red / 255 * 5))
|
|
19869
|
+
+ (6 * Math.round(green / 255 * 5))
|
|
19870
|
+
+ Math.round(blue / 255 * 5);
|
|
19871
|
+
},
|
|
19872
|
+
enumerable: false,
|
|
19873
|
+
},
|
|
19874
|
+
hexToRgb: {
|
|
19875
|
+
value(hex) {
|
|
19876
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
19877
|
+
if (!matches) {
|
|
19878
|
+
return [0, 0, 0];
|
|
19879
|
+
}
|
|
19880
|
+
|
|
19881
|
+
let [colorString] = matches;
|
|
19882
|
+
|
|
19883
|
+
if (colorString.length === 3) {
|
|
19884
|
+
colorString = [...colorString].map(character => character + character).join('');
|
|
19885
|
+
}
|
|
19886
|
+
|
|
19887
|
+
const integer = Number.parseInt(colorString, 16);
|
|
19888
|
+
|
|
19889
|
+
return [
|
|
19890
|
+
/* eslint-disable no-bitwise */
|
|
19891
|
+
(integer >> 16) & 0xFF,
|
|
19892
|
+
(integer >> 8) & 0xFF,
|
|
19893
|
+
integer & 0xFF,
|
|
19894
|
+
/* eslint-enable no-bitwise */
|
|
19895
|
+
];
|
|
19896
|
+
},
|
|
19897
|
+
enumerable: false,
|
|
19898
|
+
},
|
|
19899
|
+
hexToAnsi256: {
|
|
19900
|
+
value: hex => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)),
|
|
19901
|
+
enumerable: false,
|
|
19902
|
+
},
|
|
19903
|
+
ansi256ToAnsi: {
|
|
19904
|
+
value(code) {
|
|
19905
|
+
if (code < 8) {
|
|
19906
|
+
return 30 + code;
|
|
19907
|
+
}
|
|
19908
|
+
|
|
19909
|
+
if (code < 16) {
|
|
19910
|
+
return 90 + (code - 8);
|
|
19911
|
+
}
|
|
19912
|
+
|
|
19913
|
+
let red;
|
|
19914
|
+
let green;
|
|
19915
|
+
let blue;
|
|
19916
|
+
|
|
19917
|
+
if (code >= 232) {
|
|
19918
|
+
red = (((code - 232) * 10) + 8) / 255;
|
|
19919
|
+
green = red;
|
|
19920
|
+
blue = red;
|
|
19921
|
+
} else {
|
|
19922
|
+
code -= 16;
|
|
19923
|
+
|
|
19924
|
+
const remainder = code % 36;
|
|
19925
|
+
|
|
19926
|
+
red = Math.floor(code / 36) / 5;
|
|
19927
|
+
green = Math.floor(remainder / 6) / 5;
|
|
19928
|
+
blue = (remainder % 6) / 5;
|
|
19929
|
+
}
|
|
19930
|
+
|
|
19931
|
+
const value = Math.max(red, green, blue) * 2;
|
|
19932
|
+
|
|
19933
|
+
if (value === 0) {
|
|
19934
|
+
return 30;
|
|
19935
|
+
}
|
|
19936
|
+
|
|
19937
|
+
// eslint-disable-next-line no-bitwise
|
|
19938
|
+
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
|
|
19939
|
+
|
|
19940
|
+
if (value === 2) {
|
|
19941
|
+
result += 60;
|
|
19942
|
+
}
|
|
19943
|
+
|
|
19944
|
+
return result;
|
|
19945
|
+
},
|
|
19946
|
+
enumerable: false,
|
|
19947
|
+
},
|
|
19948
|
+
rgbToAnsi: {
|
|
19949
|
+
value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
|
|
19950
|
+
enumerable: false,
|
|
19951
|
+
},
|
|
19952
|
+
hexToAnsi: {
|
|
19953
|
+
value: hex => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
|
|
19954
|
+
enumerable: false,
|
|
19955
|
+
},
|
|
19956
|
+
});
|
|
19957
|
+
|
|
19958
|
+
return styles$1;
|
|
19959
|
+
}
|
|
19960
|
+
|
|
19961
|
+
const ansiStyles = assembleStyles();
|
|
19962
|
+
|
|
19963
|
+
/* eslint-env browser */
|
|
19964
|
+
|
|
19965
|
+
const level = (() => {
|
|
19966
|
+
if (navigator.userAgentData) {
|
|
19967
|
+
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
|
19968
|
+
if (brand && brand.version > 93) {
|
|
19969
|
+
return 3;
|
|
19970
|
+
}
|
|
19971
|
+
}
|
|
19972
|
+
|
|
19973
|
+
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
|
19974
|
+
return 1;
|
|
19975
|
+
}
|
|
19976
|
+
|
|
19977
|
+
return 0;
|
|
19978
|
+
})();
|
|
19979
|
+
|
|
19980
|
+
const colorSupport = level !== 0 && {
|
|
19981
|
+
level,
|
|
19982
|
+
hasBasic: true,
|
|
19983
|
+
has256: level >= 2,
|
|
19984
|
+
has16m: level >= 3,
|
|
19985
|
+
};
|
|
19986
|
+
|
|
19987
|
+
const supportsColor = {
|
|
19988
|
+
stdout: colorSupport,
|
|
19989
|
+
stderr: colorSupport,
|
|
19990
|
+
};
|
|
19991
|
+
|
|
19992
|
+
// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.
|
|
19993
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
19994
|
+
let index = string.indexOf(substring);
|
|
19995
|
+
if (index === -1) {
|
|
19996
|
+
return string;
|
|
19997
|
+
}
|
|
19998
|
+
|
|
19999
|
+
const substringLength = substring.length;
|
|
20000
|
+
let endIndex = 0;
|
|
20001
|
+
let returnValue = '';
|
|
20002
|
+
do {
|
|
20003
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
20004
|
+
endIndex = index + substringLength;
|
|
20005
|
+
index = string.indexOf(substring, endIndex);
|
|
20006
|
+
} while (index !== -1);
|
|
20007
|
+
|
|
20008
|
+
returnValue += string.slice(endIndex);
|
|
20009
|
+
return returnValue;
|
|
20010
|
+
}
|
|
20011
|
+
|
|
20012
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
20013
|
+
let endIndex = 0;
|
|
20014
|
+
let returnValue = '';
|
|
20015
|
+
do {
|
|
20016
|
+
const gotCR = string[index - 1] === '\r';
|
|
20017
|
+
returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
|
20018
|
+
endIndex = index + 1;
|
|
20019
|
+
index = string.indexOf('\n', endIndex);
|
|
20020
|
+
} while (index !== -1);
|
|
20021
|
+
|
|
20022
|
+
returnValue += string.slice(endIndex);
|
|
20023
|
+
return returnValue;
|
|
20024
|
+
}
|
|
20025
|
+
|
|
20026
|
+
const {stdout: stdoutColor, stderr: stderrColor} = supportsColor;
|
|
20027
|
+
|
|
20028
|
+
const GENERATOR = Symbol('GENERATOR');
|
|
20029
|
+
const STYLER = Symbol('STYLER');
|
|
20030
|
+
const IS_EMPTY = Symbol('IS_EMPTY');
|
|
20031
|
+
|
|
20032
|
+
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
|
20033
|
+
const levelMapping = [
|
|
20034
|
+
'ansi',
|
|
20035
|
+
'ansi',
|
|
20036
|
+
'ansi256',
|
|
20037
|
+
'ansi16m',
|
|
20038
|
+
];
|
|
20039
|
+
|
|
20040
|
+
const styles = Object.create(null);
|
|
20041
|
+
|
|
20042
|
+
const applyOptions = (object, options = {}) => {
|
|
20043
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
20044
|
+
throw new Error('The `level` option should be an integer from 0 to 3');
|
|
20045
|
+
}
|
|
20046
|
+
|
|
20047
|
+
// Detect level if not set manually
|
|
20048
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
20049
|
+
object.level = options.level === undefined ? colorLevel : options.level;
|
|
20050
|
+
};
|
|
20051
|
+
|
|
20052
|
+
const chalkFactory = options => {
|
|
20053
|
+
const chalk = (...strings) => strings.join(' ');
|
|
20054
|
+
applyOptions(chalk, options);
|
|
20055
|
+
|
|
20056
|
+
Object.setPrototypeOf(chalk, createChalk.prototype);
|
|
20057
|
+
|
|
20058
|
+
return chalk;
|
|
20059
|
+
};
|
|
20060
|
+
|
|
20061
|
+
function createChalk(options) {
|
|
20062
|
+
return chalkFactory(options);
|
|
20063
|
+
}
|
|
20064
|
+
|
|
20065
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
20066
|
+
|
|
20067
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
20068
|
+
styles[styleName] = {
|
|
20069
|
+
get() {
|
|
20070
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
20071
|
+
Object.defineProperty(this, styleName, {value: builder});
|
|
20072
|
+
return builder;
|
|
20073
|
+
},
|
|
20074
|
+
};
|
|
20075
|
+
}
|
|
20076
|
+
|
|
20077
|
+
styles.visible = {
|
|
20078
|
+
get() {
|
|
20079
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
20080
|
+
Object.defineProperty(this, 'visible', {value: builder});
|
|
20081
|
+
return builder;
|
|
20082
|
+
},
|
|
20083
|
+
};
|
|
20084
|
+
|
|
20085
|
+
const getModelAnsi = (model, level, type, ...arguments_) => {
|
|
20086
|
+
if (model === 'rgb') {
|
|
20087
|
+
if (level === 'ansi16m') {
|
|
20088
|
+
return ansiStyles[type].ansi16m(...arguments_);
|
|
20089
|
+
}
|
|
20090
|
+
|
|
20091
|
+
if (level === 'ansi256') {
|
|
20092
|
+
return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
|
|
20093
|
+
}
|
|
20094
|
+
|
|
20095
|
+
return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
|
|
20096
|
+
}
|
|
20097
|
+
|
|
20098
|
+
if (model === 'hex') {
|
|
20099
|
+
return getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));
|
|
20100
|
+
}
|
|
20101
|
+
|
|
20102
|
+
return ansiStyles[type][model](...arguments_);
|
|
20103
|
+
};
|
|
20104
|
+
|
|
20105
|
+
const usedModels = ['rgb', 'hex', 'ansi256'];
|
|
20106
|
+
|
|
20107
|
+
for (const model of usedModels) {
|
|
20108
|
+
styles[model] = {
|
|
20109
|
+
get() {
|
|
20110
|
+
const {level} = this;
|
|
20111
|
+
return function (...arguments_) {
|
|
20112
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);
|
|
20113
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
20114
|
+
};
|
|
20115
|
+
},
|
|
20116
|
+
};
|
|
20117
|
+
|
|
20118
|
+
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
|
20119
|
+
styles[bgModel] = {
|
|
20120
|
+
get() {
|
|
20121
|
+
const {level} = this;
|
|
20122
|
+
return function (...arguments_) {
|
|
20123
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
|
|
20124
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
20125
|
+
};
|
|
20126
|
+
},
|
|
20127
|
+
};
|
|
20128
|
+
}
|
|
20129
|
+
|
|
20130
|
+
const proto$1 = Object.defineProperties(() => {}, {
|
|
20131
|
+
...styles,
|
|
20132
|
+
level: {
|
|
20133
|
+
enumerable: true,
|
|
20134
|
+
get() {
|
|
20135
|
+
return this[GENERATOR].level;
|
|
20136
|
+
},
|
|
20137
|
+
set(level) {
|
|
20138
|
+
this[GENERATOR].level = level;
|
|
20139
|
+
},
|
|
20140
|
+
},
|
|
20141
|
+
});
|
|
20142
|
+
|
|
20143
|
+
const createStyler = (open, close, parent) => {
|
|
20144
|
+
let openAll;
|
|
20145
|
+
let closeAll;
|
|
20146
|
+
if (parent === undefined) {
|
|
20147
|
+
openAll = open;
|
|
20148
|
+
closeAll = close;
|
|
20149
|
+
} else {
|
|
20150
|
+
openAll = parent.openAll + open;
|
|
20151
|
+
closeAll = close + parent.closeAll;
|
|
20152
|
+
}
|
|
20153
|
+
|
|
20154
|
+
return {
|
|
20155
|
+
open,
|
|
20156
|
+
close,
|
|
20157
|
+
openAll,
|
|
20158
|
+
closeAll,
|
|
20159
|
+
parent,
|
|
20160
|
+
};
|
|
20161
|
+
};
|
|
20162
|
+
|
|
20163
|
+
const createBuilder = (self, _styler, _isEmpty) => {
|
|
20164
|
+
// Single argument is hot path, implicit coercion is faster than anything
|
|
20165
|
+
// eslint-disable-next-line no-implicit-coercion
|
|
20166
|
+
const builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
|
20167
|
+
|
|
20168
|
+
// We alter the prototype because we must return a function, but there is
|
|
20169
|
+
// no way to create a function with a different prototype
|
|
20170
|
+
Object.setPrototypeOf(builder, proto$1);
|
|
20171
|
+
|
|
20172
|
+
builder[GENERATOR] = self;
|
|
20173
|
+
builder[STYLER] = _styler;
|
|
20174
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
20175
|
+
|
|
20176
|
+
return builder;
|
|
20177
|
+
};
|
|
20178
|
+
|
|
20179
|
+
const applyStyle = (self, string) => {
|
|
20180
|
+
if (self.level <= 0 || !string) {
|
|
20181
|
+
return self[IS_EMPTY] ? '' : string;
|
|
20182
|
+
}
|
|
20183
|
+
|
|
20184
|
+
let styler = self[STYLER];
|
|
20185
|
+
|
|
20186
|
+
if (styler === undefined) {
|
|
20187
|
+
return string;
|
|
20188
|
+
}
|
|
20189
|
+
|
|
20190
|
+
const {openAll, closeAll} = styler;
|
|
20191
|
+
if (string.includes('\u001B')) {
|
|
20192
|
+
while (styler !== undefined) {
|
|
20193
|
+
// Replace any instances already present with a re-opening code
|
|
20194
|
+
// otherwise only the part of the string until said closing code
|
|
20195
|
+
// will be colored, and the rest will simply be 'plain'.
|
|
20196
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
20197
|
+
|
|
20198
|
+
styler = styler.parent;
|
|
20199
|
+
}
|
|
20200
|
+
}
|
|
20201
|
+
|
|
20202
|
+
// We can move both next actions out of loop, because remaining actions in loop won't have
|
|
20203
|
+
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
|
20204
|
+
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
|
20205
|
+
const lfIndex = string.indexOf('\n');
|
|
20206
|
+
if (lfIndex !== -1) {
|
|
20207
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
20208
|
+
}
|
|
20209
|
+
|
|
20210
|
+
return openAll + string + closeAll;
|
|
20211
|
+
};
|
|
20212
|
+
|
|
20213
|
+
Object.defineProperties(createChalk.prototype, styles);
|
|
20214
|
+
|
|
20215
|
+
const chalk = createChalk();
|
|
20216
|
+
createChalk({level: stderrColor ? stderrColor.level : 0});
|
|
20217
|
+
|
|
20218
|
+
/* eslint-disable no-var */
|
|
20219
|
+
var LogLevel;
|
|
20220
|
+
(function (LogLevel) {
|
|
20221
|
+
LogLevel[LogLevel["trace"] = 10] = "trace";
|
|
20222
|
+
LogLevel[LogLevel["debug"] = 20] = "debug";
|
|
20223
|
+
LogLevel[LogLevel["info"] = 30] = "info";
|
|
20224
|
+
LogLevel[LogLevel["warn"] = 40] = "warn";
|
|
20225
|
+
LogLevel[LogLevel["error"] = 50] = "error";
|
|
20226
|
+
LogLevel[LogLevel["fatal"] = 60] = "fatal";
|
|
20227
|
+
})(LogLevel || (LogLevel = {}));
|
|
20228
|
+
function isLogFnParamsCtx(params) {
|
|
20229
|
+
return typeof params[0] !== 'string' && typeof params[1] !== 'undefined';
|
|
20230
|
+
}
|
|
20231
|
+
function parseLogFormat(value) {
|
|
20232
|
+
switch (value) {
|
|
20233
|
+
case 'pretty':
|
|
20234
|
+
case 'plain':
|
|
20235
|
+
case 'json':
|
|
20236
|
+
return value;
|
|
20237
|
+
default:
|
|
20238
|
+
return 'json';
|
|
20239
|
+
}
|
|
20240
|
+
}
|
|
20241
|
+
function logLevelName(level) {
|
|
20242
|
+
switch (level) {
|
|
20243
|
+
case 10:
|
|
20244
|
+
return ' T ';
|
|
20245
|
+
case 20:
|
|
20246
|
+
return ' D ';
|
|
20247
|
+
case 30:
|
|
20248
|
+
return ' I ';
|
|
20249
|
+
case 40:
|
|
20250
|
+
return ' W ';
|
|
20251
|
+
case 50:
|
|
20252
|
+
return ' E ';
|
|
20253
|
+
case 60:
|
|
20254
|
+
return ' F ';
|
|
20255
|
+
}
|
|
20256
|
+
return '?????';
|
|
20257
|
+
}
|
|
20258
|
+
function colorize(level) {
|
|
20259
|
+
switch (level) {
|
|
20260
|
+
case 10:
|
|
20261
|
+
return { color: chalk.gray, bgcolor: chalk.bgGray.black };
|
|
20262
|
+
case 20:
|
|
20263
|
+
return { color: chalk.gray, bgcolor: chalk.bgGray.black };
|
|
20264
|
+
case 30:
|
|
20265
|
+
return { color: chalk.white, bgcolor: chalk.bgWhite.black };
|
|
20266
|
+
case 40:
|
|
20267
|
+
return { color: chalk.yellow, bgcolor: chalk.bgYellow.black };
|
|
20268
|
+
case 50:
|
|
20269
|
+
return { color: chalk.red, bgcolor: chalk.bgRed.black };
|
|
20270
|
+
case 60:
|
|
20271
|
+
return { color: chalk.red, bgcolor: chalk.bgRed.black };
|
|
20272
|
+
}
|
|
20273
|
+
return { color: chalk.gray, bgcolor: chalk.bgGray.black };
|
|
20274
|
+
}
|
|
20275
|
+
function customStringify(data, useSpaces = true) {
|
|
20276
|
+
return (stringify$3(data, (_key, value) => {
|
|
20277
|
+
if (typeof Buffer !== 'undefined' && value instanceof Buffer) {
|
|
20278
|
+
return value.toString('base64');
|
|
20279
|
+
}
|
|
20280
|
+
return value;
|
|
20281
|
+
}, useSpaces ? 2 : undefined) ?? '');
|
|
20282
|
+
}
|
|
20283
|
+
function prettyMessage(message) {
|
|
20284
|
+
const logLevel = message.level ?? 30;
|
|
20285
|
+
const { color, bgcolor } = colorize(logLevel);
|
|
20286
|
+
const component = message.component ? `/${message.component}` : '';
|
|
20287
|
+
const baseMsg = [
|
|
20288
|
+
chalk.gray(formatDate(new Date(message.when), 'time-dayofyear')),
|
|
20289
|
+
bgcolor(logLevelName(logLevel)),
|
|
20290
|
+
color(`${message.logger.name}${component}`),
|
|
20291
|
+
color(':'),
|
|
20292
|
+
color(message.message),
|
|
20293
|
+
];
|
|
20294
|
+
if (Object.keys(message.context).length > 0) {
|
|
20295
|
+
for (const [key, value] of Object.entries(message.context)) {
|
|
20296
|
+
if (value instanceof Error) {
|
|
20297
|
+
try {
|
|
20298
|
+
baseMsg.push(`\n\n[key = ${key} contains Error]\n\n${customStringify(serializeError(value))}`);
|
|
20299
|
+
}
|
|
20300
|
+
catch {
|
|
20301
|
+
baseMsg.push(`\n\n[key = ${key} contains Error]\n\n${value.name}\n${value.message}`);
|
|
20302
|
+
}
|
|
20303
|
+
delete message.context[key];
|
|
20304
|
+
}
|
|
20305
|
+
}
|
|
20306
|
+
baseMsg.push(chalk.gray(`\n${customStringify(message.context)}`));
|
|
20307
|
+
}
|
|
20308
|
+
return baseMsg.join(' ');
|
|
20309
|
+
}
|
|
20310
|
+
function buildSerializeMessage(config) {
|
|
20311
|
+
if (config.format === 'pretty' || config.runtime === 'development') {
|
|
20312
|
+
chalk.level = typeof document !== 'undefined' ? 0 : 3;
|
|
20313
|
+
return prettyMessage;
|
|
20314
|
+
}
|
|
20315
|
+
else if (config.format === 'json') {
|
|
20316
|
+
return (message) => customStringify({ ...message, when: formatDate(message.when, 'iso') }, false);
|
|
20317
|
+
}
|
|
20318
|
+
else if (config.format === 'plain') {
|
|
20319
|
+
return (message) => {
|
|
20320
|
+
const logLevel = message.context.logLevel ?? 30;
|
|
20321
|
+
const component = message.context.component ? `/${JSON.stringify(message.context.component)}` : '';
|
|
20322
|
+
const baseMsg = [
|
|
20323
|
+
formatDate(message.when, 'time-dayofyear'),
|
|
20324
|
+
logLevelName(logLevel),
|
|
20325
|
+
`${message.logger.name}${component}`,
|
|
20326
|
+
':',
|
|
20327
|
+
message.message,
|
|
20328
|
+
];
|
|
20329
|
+
if (Object.keys(message.context).length > 0) {
|
|
20330
|
+
baseMsg.push(`\n${customStringify(message.context)}`);
|
|
20331
|
+
}
|
|
20332
|
+
return baseMsg.join(' ');
|
|
20333
|
+
};
|
|
20334
|
+
}
|
|
20335
|
+
else {
|
|
20336
|
+
throw new Error(`invalid configuration provided ${JSON.stringify(config, undefined, 2)}`);
|
|
20337
|
+
}
|
|
20338
|
+
}
|
|
20339
|
+
const writeMessage = (msg) => {
|
|
20340
|
+
if (msg.level < msg.logger.config.level)
|
|
20341
|
+
return;
|
|
20342
|
+
const message = msg.logger.serializeMessage(msg);
|
|
20343
|
+
if (typeof document !== 'undefined') {
|
|
20344
|
+
// eslint-disable-next-line no-console
|
|
20345
|
+
console.log(message);
|
|
20346
|
+
}
|
|
20347
|
+
else if (typeof process !== 'undefined') {
|
|
20348
|
+
process.stdout.write(`${message}\n`);
|
|
20349
|
+
}
|
|
20350
|
+
else {
|
|
20351
|
+
// eslint-disable-next-line no-console
|
|
20352
|
+
console.log(message);
|
|
20353
|
+
}
|
|
20354
|
+
};
|
|
20355
|
+
const buildLogger = (name, initialConfig) => {
|
|
20356
|
+
const _config = { ...initialConfig };
|
|
20357
|
+
let serializeMessage = buildSerializeMessage(_config);
|
|
20358
|
+
const configure = (config) => {
|
|
20359
|
+
Object.assign(_config, config);
|
|
20360
|
+
// logger.trace({ config: logger.config }, `reconfigured logger: ${name}`);
|
|
20361
|
+
serializeMessage = buildSerializeMessage(_config);
|
|
20362
|
+
};
|
|
20363
|
+
const buildBoundFns = (opts) => {
|
|
20364
|
+
const { component } = opts;
|
|
20365
|
+
return {
|
|
20366
|
+
trace: log.bind({ level: LogLevel.trace, component }),
|
|
20367
|
+
debug: log.bind({ level: LogLevel.debug, component }),
|
|
20368
|
+
info: log.bind({ level: LogLevel.info, component }),
|
|
20369
|
+
warn: log.bind({ level: LogLevel.warn, component }),
|
|
20370
|
+
error: log.bind({ level: LogLevel.error, component }),
|
|
20371
|
+
fatal: log.bind({ level: LogLevel.fatal, component }),
|
|
20372
|
+
};
|
|
20373
|
+
};
|
|
20374
|
+
function log(...params) {
|
|
20375
|
+
const ctxIndex = isLogFnParamsCtx(params) ? 0 : -1;
|
|
20376
|
+
const message = params.slice(ctxIndex + 1).join(' ');
|
|
20377
|
+
writeMessage({
|
|
20378
|
+
logger,
|
|
20379
|
+
when: new Date(),
|
|
20380
|
+
level: this.level,
|
|
20381
|
+
context: ctxIndex !== -1 ? params[ctxIndex] : {},
|
|
20382
|
+
component: this.component,
|
|
20383
|
+
message,
|
|
20384
|
+
});
|
|
20385
|
+
}
|
|
20386
|
+
const child = (component) => {
|
|
20387
|
+
const parent = logger;
|
|
20388
|
+
return {
|
|
20389
|
+
...parent,
|
|
20390
|
+
...buildBoundFns({ component }),
|
|
20391
|
+
};
|
|
20392
|
+
};
|
|
20393
|
+
const canLogLevel = (level) => {
|
|
20394
|
+
return _config.level <= level;
|
|
20395
|
+
};
|
|
20396
|
+
const logger = {
|
|
20397
|
+
get config() {
|
|
20398
|
+
return _config;
|
|
20399
|
+
},
|
|
20400
|
+
get name() {
|
|
20401
|
+
return _config.rootComponent;
|
|
20402
|
+
},
|
|
20403
|
+
serializeMessage: msg => {
|
|
20404
|
+
if (_config.format !== 'pretty') {
|
|
20405
|
+
const newContext = { ...msg.context };
|
|
20406
|
+
for (const entry of Object.entries(msg.context)) {
|
|
20407
|
+
let value = msg.context[entry[0]];
|
|
20408
|
+
if (value instanceof Error) {
|
|
20409
|
+
try {
|
|
20410
|
+
value = serializeError(value, {
|
|
20411
|
+
maxDepth: 3,
|
|
20412
|
+
});
|
|
20413
|
+
}
|
|
20414
|
+
catch (e) {
|
|
20415
|
+
logger.warn({ error: e }, `serialize of error failed`);
|
|
20416
|
+
// serialize failed, keep original value
|
|
20417
|
+
}
|
|
20418
|
+
}
|
|
20419
|
+
newContext[entry[0]] = value;
|
|
20420
|
+
}
|
|
20421
|
+
Object.assign(msg, { context: newContext });
|
|
20422
|
+
}
|
|
20423
|
+
return serializeMessage(msg);
|
|
20424
|
+
},
|
|
20425
|
+
child,
|
|
20426
|
+
configure,
|
|
20427
|
+
canLogLevel,
|
|
20428
|
+
...buildBoundFns({ component: null }),
|
|
20429
|
+
};
|
|
20430
|
+
// logger.trace({ config: logger.config }, `built logger: ${name}`);
|
|
20431
|
+
return logger;
|
|
20432
|
+
};
|
|
20433
|
+
const LOG_LEVEL_ENV = globalThis.ENV?.LOG_LEVEL ?? 'info';
|
|
20434
|
+
const defaultLogger = buildLogger('default', {
|
|
20435
|
+
level: (typeof LOG_LEVEL_ENV === 'string' ? parseInt(LOG_LEVEL_ENV) : LOG_LEVEL_ENV) ?? 10,
|
|
20436
|
+
rootComponent: globalThis.ENV?.LOG_ROOT_COMPONENT ?? 'logger',
|
|
20437
|
+
format: parseLogFormat(globalThis.ENV?.LOG_FORMAT),
|
|
20438
|
+
runtime: globalThis.ENV?.RUNTIME ?? 'development',
|
|
20439
|
+
});
|
|
20440
|
+
const log$5 = defaultLogger;
|
|
20441
|
+
globalThis.log = defaultLogger;
|
|
20442
|
+
|
|
20443
|
+
const customFormats = {
|
|
20444
|
+
number: {
|
|
20445
|
+
bytes: {
|
|
20446
|
+
style: 'decimal',
|
|
20447
|
+
maximumFractionDigits: 1,
|
|
20448
|
+
},
|
|
20449
|
+
temperature: {
|
|
20450
|
+
style: 'decimal',
|
|
20451
|
+
maximumFractionDigits: 0,
|
|
20452
|
+
},
|
|
20453
|
+
},
|
|
20454
|
+
date: {
|
|
20455
|
+
log: {
|
|
20456
|
+
dateStyle: undefined,
|
|
20457
|
+
timeStyle: 'medium',
|
|
20458
|
+
hourCycle: 'h24',
|
|
20459
|
+
},
|
|
20460
|
+
short: {
|
|
20461
|
+
dateStyle: 'short',
|
|
20462
|
+
timeStyle: 'short',
|
|
20463
|
+
},
|
|
20464
|
+
long: {
|
|
20465
|
+
dateStyle: 'long',
|
|
20466
|
+
timeStyle: 'long',
|
|
20467
|
+
},
|
|
20468
|
+
},
|
|
20469
|
+
};
|
|
20470
|
+
const onIntlError = (error) => {
|
|
20471
|
+
if (typeof window !== 'undefined') {
|
|
20472
|
+
log$5.fatal(error);
|
|
20473
|
+
}
|
|
20474
|
+
};
|
|
20475
|
+
const cache$1 = createIntlCache();
|
|
20476
|
+
createIntl({
|
|
20477
|
+
locale: 'en-US',
|
|
20478
|
+
defaultLocale: 'en-US',
|
|
20479
|
+
formats: customFormats,
|
|
20480
|
+
onError: onIntlError,
|
|
20481
|
+
}, cache$1);
|
|
20482
|
+
|
|
19700
20483
|
/**
|
|
19701
20484
|
* uuidv7: A JavaScript implementation of UUID version 7
|
|
19702
20485
|
*
|
|
@@ -86854,7 +87637,7 @@ function legacy(parser) {
|
|
|
86854
87637
|
return new LanguageSupport(StreamLanguage.define(parser));
|
|
86855
87638
|
}
|
|
86856
87639
|
function sql$1(dialectName) {
|
|
86857
|
-
return import('./index-
|
|
87640
|
+
return import('./index-Bspn2znq.js').then(m => m.sql({ dialect: m[dialectName] }));
|
|
86858
87641
|
}
|
|
86859
87642
|
/**
|
|
86860
87643
|
An array of language descriptions for known language packages.
|
|
@@ -86865,7 +87648,7 @@ const languages = [
|
|
|
86865
87648
|
name: "C",
|
|
86866
87649
|
extensions: ["c", "h", "ino"],
|
|
86867
87650
|
load() {
|
|
86868
|
-
return import('./index-
|
|
87651
|
+
return import('./index-DNvBsNl1.js').then(m => m.cpp());
|
|
86869
87652
|
}
|
|
86870
87653
|
}),
|
|
86871
87654
|
/*@__PURE__*/LanguageDescription.of({
|
|
@@ -86873,7 +87656,7 @@ const languages = [
|
|
|
86873
87656
|
alias: ["cpp"],
|
|
86874
87657
|
extensions: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"],
|
|
86875
87658
|
load() {
|
|
86876
|
-
return import('./index-
|
|
87659
|
+
return import('./index-DNvBsNl1.js').then(m => m.cpp());
|
|
86877
87660
|
}
|
|
86878
87661
|
}),
|
|
86879
87662
|
/*@__PURE__*/LanguageDescription.of({
|
|
@@ -86893,7 +87676,7 @@ const languages = [
|
|
|
86893
87676
|
name: "Go",
|
|
86894
87677
|
extensions: ["go"],
|
|
86895
87678
|
load() {
|
|
86896
|
-
return import('./index-
|
|
87679
|
+
return import('./index-BtNlfgUY.js').then(m => m.go());
|
|
86897
87680
|
}
|
|
86898
87681
|
}),
|
|
86899
87682
|
/*@__PURE__*/LanguageDescription.of({
|
|
@@ -86908,7 +87691,7 @@ const languages = [
|
|
|
86908
87691
|
name: "Java",
|
|
86909
87692
|
extensions: ["java"],
|
|
86910
87693
|
load() {
|
|
86911
|
-
return import('./index-
|
|
87694
|
+
return import('./index-DJcmDPtm.js').then(m => m.java());
|
|
86912
87695
|
}
|
|
86913
87696
|
}),
|
|
86914
87697
|
/*@__PURE__*/LanguageDescription.of({
|
|
@@ -86924,7 +87707,7 @@ const languages = [
|
|
|
86924
87707
|
alias: ["json5"],
|
|
86925
87708
|
extensions: ["json", "map"],
|
|
86926
87709
|
load() {
|
|
86927
|
-
return import('./index-
|
|
87710
|
+
return import('./index-DgwouNl2.js').then(m => m.json());
|
|
86928
87711
|
}
|
|
86929
87712
|
}),
|
|
86930
87713
|
/*@__PURE__*/LanguageDescription.of({
|
|
@@ -86938,14 +87721,14 @@ const languages = [
|
|
|
86938
87721
|
name: "LESS",
|
|
86939
87722
|
extensions: ["less"],
|
|
86940
87723
|
load() {
|
|
86941
|
-
return import('./index-
|
|
87724
|
+
return import('./index-DgOS8MMD.js').then(m => m.less());
|
|
86942
87725
|
}
|
|
86943
87726
|
}),
|
|
86944
87727
|
/*@__PURE__*/LanguageDescription.of({
|
|
86945
87728
|
name: "Liquid",
|
|
86946
87729
|
extensions: ["liquid"],
|
|
86947
87730
|
load() {
|
|
86948
|
-
return import('./index-
|
|
87731
|
+
return import('./index-CqgVBu62.js').then(m => m.liquid());
|
|
86949
87732
|
}
|
|
86950
87733
|
}),
|
|
86951
87734
|
/*@__PURE__*/LanguageDescription.of({
|
|
@@ -86971,7 +87754,7 @@ const languages = [
|
|
|
86971
87754
|
name: "PHP",
|
|
86972
87755
|
extensions: ["php", "php3", "php4", "php5", "php7", "phtml"],
|
|
86973
87756
|
load() {
|
|
86974
|
-
return import('./index-
|
|
87757
|
+
return import('./index-DDSwKM6g.js').then(m => m.php());
|
|
86975
87758
|
}
|
|
86976
87759
|
}),
|
|
86977
87760
|
/*@__PURE__*/LanguageDescription.of({
|
|
@@ -86988,28 +87771,28 @@ const languages = [
|
|
|
86988
87771
|
extensions: ["BUILD", "bzl", "py", "pyw"],
|
|
86989
87772
|
filename: /^(BUCK|BUILD)$/,
|
|
86990
87773
|
load() {
|
|
86991
|
-
return import('./index-
|
|
87774
|
+
return import('./index-BdMCbxLs.js').then(m => m.python());
|
|
86992
87775
|
}
|
|
86993
87776
|
}),
|
|
86994
87777
|
/*@__PURE__*/LanguageDescription.of({
|
|
86995
87778
|
name: "Rust",
|
|
86996
87779
|
extensions: ["rs"],
|
|
86997
87780
|
load() {
|
|
86998
|
-
return import('./index-
|
|
87781
|
+
return import('./index-BRQewqsW.js').then(m => m.rust());
|
|
86999
87782
|
}
|
|
87000
87783
|
}),
|
|
87001
87784
|
/*@__PURE__*/LanguageDescription.of({
|
|
87002
87785
|
name: "Sass",
|
|
87003
87786
|
extensions: ["sass"],
|
|
87004
87787
|
load() {
|
|
87005
|
-
return import('./index-
|
|
87788
|
+
return import('./index-CaaYr7e4.js').then(m => m.sass({ indented: true }));
|
|
87006
87789
|
}
|
|
87007
87790
|
}),
|
|
87008
87791
|
/*@__PURE__*/LanguageDescription.of({
|
|
87009
87792
|
name: "SCSS",
|
|
87010
87793
|
extensions: ["scss"],
|
|
87011
87794
|
load() {
|
|
87012
|
-
return import('./index-
|
|
87795
|
+
return import('./index-CaaYr7e4.js').then(m => m.sass());
|
|
87013
87796
|
}
|
|
87014
87797
|
}),
|
|
87015
87798
|
/*@__PURE__*/LanguageDescription.of({
|
|
@@ -87040,7 +87823,7 @@ const languages = [
|
|
|
87040
87823
|
name: "WebAssembly",
|
|
87041
87824
|
extensions: ["wat", "wast"],
|
|
87042
87825
|
load() {
|
|
87043
|
-
return import('./index-
|
|
87826
|
+
return import('./index-iOv5ZlQQ.js').then(m => m.wast());
|
|
87044
87827
|
}
|
|
87045
87828
|
}),
|
|
87046
87829
|
/*@__PURE__*/LanguageDescription.of({
|
|
@@ -87048,7 +87831,7 @@ const languages = [
|
|
|
87048
87831
|
alias: ["rss", "wsdl", "xsd"],
|
|
87049
87832
|
extensions: ["xml", "xsl", "xsd", "svg"],
|
|
87050
87833
|
load() {
|
|
87051
|
-
return import('./index-
|
|
87834
|
+
return import('./index-DIjTsK3r.js').then(m => m.xml());
|
|
87052
87835
|
}
|
|
87053
87836
|
}),
|
|
87054
87837
|
/*@__PURE__*/LanguageDescription.of({
|
|
@@ -87056,7 +87839,7 @@ const languages = [
|
|
|
87056
87839
|
alias: ["yml"],
|
|
87057
87840
|
extensions: ["yaml", "yml"],
|
|
87058
87841
|
load() {
|
|
87059
|
-
return import('./index-
|
|
87842
|
+
return import('./index-C-gyQZe6.js').then(m => m.yaml());
|
|
87060
87843
|
}
|
|
87061
87844
|
}),
|
|
87062
87845
|
// Legacy modes ported from CodeMirror 5
|
|
@@ -87852,13 +88635,13 @@ const languages = [
|
|
|
87852
88635
|
name: "Vue",
|
|
87853
88636
|
extensions: ["vue"],
|
|
87854
88637
|
load() {
|
|
87855
|
-
return import('./index-
|
|
88638
|
+
return import('./index-DQPQZ-yd.js').then(m => m.vue());
|
|
87856
88639
|
}
|
|
87857
88640
|
}),
|
|
87858
88641
|
/*@__PURE__*/LanguageDescription.of({
|
|
87859
88642
|
name: "Angular Template",
|
|
87860
88643
|
load() {
|
|
87861
|
-
return import('./index-
|
|
88644
|
+
return import('./index-DybKX-0d.js').then(m => m.angular());
|
|
87862
88645
|
}
|
|
87863
88646
|
})
|
|
87864
88647
|
];
|
|
@@ -166513,9 +167296,10 @@ const Panel = ({
|
|
|
166513
167296
|
React__default.useEffect(() => {
|
|
166514
167297
|
if (!disableAnnotations) {
|
|
166515
167298
|
setDetections(current => [...rawToAnnotations(annotationTopics, "main", current), ...rawToAnnotations(extraAnnotationTopics, "extra", current)]);
|
|
167299
|
+
} else {
|
|
167300
|
+
setDetections([]);
|
|
166516
167301
|
}
|
|
166517
|
-
|
|
166518
|
-
}, [JSON.stringify(annotationTopics), JSON.stringify(extraAnnotationTopics)]);
|
|
167302
|
+
}, [annotationTopics, extraAnnotationTopics, disableAnnotations]);
|
|
166519
167303
|
const toggleFullscreenForThisPanel = () => {
|
|
166520
167304
|
if (!toggleFullscreen || !sectionRef.current) {
|
|
166521
167305
|
return;
|
|
@@ -166582,7 +167366,7 @@ function createRenderDelaySampler() {
|
|
|
166582
167366
|
};
|
|
166583
167367
|
}
|
|
166584
167368
|
|
|
166585
|
-
const ImagePanelComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-
|
|
167369
|
+
const ImagePanelComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-B-YvYqeS.js'));
|
|
166586
167370
|
const ImagePanelBody = ({
|
|
166587
167371
|
topic,
|
|
166588
167372
|
frameRenderedEvent,
|
|
@@ -166677,7 +167461,7 @@ const DEFAULT_CAMERA_STATE = {
|
|
|
166677
167461
|
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
166678
167462
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
166679
167463
|
|
|
166680
|
-
const ThreeDeeRenderComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-
|
|
167464
|
+
const ThreeDeeRenderComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-CwGTzS5e.js'));
|
|
166681
167465
|
const PointCloudPanelBody = ({
|
|
166682
167466
|
topic,
|
|
166683
167467
|
frameRenderedEvent,
|