@openfeature/flagd-provider 0.13.1 → 0.13.3

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/index.cjs.js CHANGED
@@ -1,16 +1,45 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var serverSdk = require('@openfeature/server-sdk');
6
4
  var grpcJs = require('@grpc/grpc-js');
7
5
  var connectivityState = require('@grpc/grpc-js/build/src/connectivity-state');
8
6
  var lruCache = require('lru-cache');
9
- var util$6 = require('util');
7
+ var node_util = require('node:util');
10
8
  var flagdCore = require('@openfeature/flagd-core');
11
- var core = require('@openfeature/core');
12
9
  var fs = require('fs');
13
10
 
11
+ /******************************************************************************
12
+ Copyright (c) Microsoft Corporation.
13
+
14
+ Permission to use, copy, modify, and/or distribute this software for any
15
+ purpose with or without fee is hereby granted.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
20
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
+ PERFORMANCE OF THIS SOFTWARE.
24
+ ***************************************************************************** */
25
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
26
+
27
+
28
+ function __awaiter(thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ }
37
+
38
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
39
+ var e = new Error(message);
40
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
41
+ };
42
+
14
43
  const EVENT_CONFIGURATION_CHANGE = 'configuration_change';
15
44
  const EVENT_PROVIDER_READY = 'provider_ready';
16
45
  const DEFAULT_MAX_CACHE_SIZE = 1000;
@@ -35,15 +64,16 @@ var ENV_VAR;
35
64
  ENV_VAR["FLAGD_SOURCE_SELECTOR"] = "FLAGD_SOURCE_SELECTOR";
36
65
  ENV_VAR["FLAGD_RESOLVER"] = "FLAGD_RESOLVER";
37
66
  ENV_VAR["FLAGD_OFFLINE_FLAG_SOURCE_PATH"] = "FLAGD_OFFLINE_FLAG_SOURCE_PATH";
67
+ ENV_VAR["FLAGD_DEFAULT_AUTHORITY"] = "FLAGD_DEFAULT_AUTHORITY";
38
68
  })(ENV_VAR || (ENV_VAR = {}));
39
69
  const getEnvVarConfig = () => {
40
70
  var _a;
41
- return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (process.env[ENV_VAR.FLAGD_HOST] && {
71
+ return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (process.env[ENV_VAR.FLAGD_HOST] && {
42
72
  host: process.env[ENV_VAR.FLAGD_HOST],
43
73
  })), (Number(process.env[ENV_VAR.FLAGD_PORT]) && {
44
74
  port: Number(process.env[ENV_VAR.FLAGD_PORT]),
45
75
  })), (process.env[ENV_VAR.FLAGD_TLS] && {
46
- tls: ((_a = process.env[ENV_VAR.FLAGD_TLS]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'true',
76
+ tls: ((_a = process.env[ENV_VAR.FLAGD_TLS]) === null || _a === undefined ? undefined : _a.toLowerCase()) === 'true',
47
77
  })), (process.env[ENV_VAR.FLAGD_SOCKET_PATH] && {
48
78
  socketPath: process.env[ENV_VAR.FLAGD_SOCKET_PATH],
49
79
  })), ((process.env[ENV_VAR.FLAGD_CACHE] === 'lru' || process.env[ENV_VAR.FLAGD_CACHE] === 'disabled') && {
@@ -56,6 +86,8 @@ const getEnvVarConfig = () => {
56
86
  resolverType: process.env[ENV_VAR.FLAGD_RESOLVER],
57
87
  })), (process.env[ENV_VAR.FLAGD_OFFLINE_FLAG_SOURCE_PATH] && {
58
88
  offlineFlagSourcePath: process.env[ENV_VAR.FLAGD_OFFLINE_FLAG_SOURCE_PATH],
89
+ })), (process.env[ENV_VAR.FLAGD_DEFAULT_AUTHORITY] && {
90
+ defaultAuthority: process.env[ENV_VAR.FLAGD_DEFAULT_AUTHORITY],
59
91
  })));
60
92
  };
61
93
  function getConfig(options = {}) {
@@ -66,36 +98,6 @@ function getConfig(options = {}) {
66
98
  return Object.assign(Object.assign(Object.assign({}, defaultConfig), envVarConfig), options);
67
99
  }
68
100
 
69
- /******************************************************************************
70
- Copyright (c) Microsoft Corporation.
71
-
72
- Permission to use, copy, modify, and/or distribute this software for any
73
- purpose with or without fee is hereby granted.
74
-
75
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
76
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
77
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
78
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
79
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
80
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
81
- PERFORMANCE OF THIS SOFTWARE.
82
- ***************************************************************************** */
83
-
84
- function __awaiter(thisArg, _arguments, P, generator) {
85
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
86
- return new (P || (P = Promise))(function (resolve, reject) {
87
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
88
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
89
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
90
- step((generator = generator.apply(thisArg, _arguments || [])).next());
91
- });
92
- }
93
-
94
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
95
- var e = new Error(message);
96
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
97
- };
98
-
99
101
  /**
100
102
  * @license
101
103
  * Copyright 2009 The Closure Library Authors
@@ -284,7 +286,7 @@ function fromNumber(value, unsigned) {
284
286
  if (value >= TWO_PWR_64_DBL)
285
287
  return MAX_UNSIGNED_VALUE;
286
288
  } else {
287
- if (value <= -TWO_PWR_63_DBL)
289
+ if (value <= -9223372036854776e3)
288
290
  return MIN_VALUE;
289
291
  if (value + 1 >= TWO_PWR_63_DBL)
290
292
  return MAX_VALUE;
@@ -1083,7 +1085,7 @@ LongPrototype.divide = function divide(divisor) {
1083
1085
  // negative number / -1 would be 1 larger than the largest
1084
1086
  // positive number, due to two's complement.
1085
1087
  if (!this.unsigned &&
1086
- this.high === -0x80000000 &&
1088
+ this.high === -2147483648 &&
1087
1089
  divisor.low === -1 && divisor.high === -1) {
1088
1090
  // be consistent with non-wasm code path
1089
1091
  return this;
@@ -1564,1432 +1566,1506 @@ Long.fromBytesBE = function fromBytesBE(bytes, unsigned) {
1564
1566
 
1565
1567
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1566
1568
 
1569
+ function getDefaultExportFromCjs (x) {
1570
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1571
+ }
1572
+
1567
1573
  var indexMinimal = {};
1568
1574
 
1569
1575
  var minimal$1 = {};
1570
1576
 
1571
- var aspromise = asPromise;
1577
+ var aspromise;
1578
+ var hasRequiredAspromise;
1579
+
1580
+ function requireAspromise () {
1581
+ if (hasRequiredAspromise) return aspromise;
1582
+ hasRequiredAspromise = 1;
1583
+ aspromise = asPromise;
1572
1584
 
1573
- /**
1574
- * Callback as used by {@link util.asPromise}.
1575
- * @typedef asPromiseCallback
1576
- * @type {function}
1577
- * @param {Error|null} error Error, if any
1578
- * @param {...*} params Additional arguments
1579
- * @returns {undefined}
1580
- */
1585
+ /**
1586
+ * Callback as used by {@link util.asPromise}.
1587
+ * @typedef asPromiseCallback
1588
+ * @type {function}
1589
+ * @param {Error|null} error Error, if any
1590
+ * @param {...*} params Additional arguments
1591
+ * @returns {undefined}
1592
+ */
1581
1593
 
1582
- /**
1583
- * Returns a promise from a node-style callback function.
1584
- * @memberof util
1585
- * @param {asPromiseCallback} fn Function to call
1586
- * @param {*} ctx Function context
1587
- * @param {...*} params Function arguments
1588
- * @returns {Promise<*>} Promisified function
1589
- */
1590
- function asPromise(fn, ctx/*, varargs */) {
1591
- var params = new Array(arguments.length - 1),
1592
- offset = 0,
1593
- index = 2,
1594
- pending = true;
1595
- while (index < arguments.length)
1596
- params[offset++] = arguments[index++];
1597
- return new Promise(function executor(resolve, reject) {
1598
- params[offset] = function callback(err/*, varargs */) {
1599
- if (pending) {
1600
- pending = false;
1601
- if (err)
1602
- reject(err);
1603
- else {
1604
- var params = new Array(arguments.length - 1),
1605
- offset = 0;
1606
- while (offset < params.length)
1607
- params[offset++] = arguments[offset];
1608
- resolve.apply(null, params);
1609
- }
1610
- }
1611
- };
1612
- try {
1613
- fn.apply(ctx || null, params);
1614
- } catch (err) {
1615
- if (pending) {
1616
- pending = false;
1617
- reject(err);
1618
- }
1619
- }
1620
- });
1594
+ /**
1595
+ * Returns a promise from a node-style callback function.
1596
+ * @memberof util
1597
+ * @param {asPromiseCallback} fn Function to call
1598
+ * @param {*} ctx Function context
1599
+ * @param {...*} params Function arguments
1600
+ * @returns {Promise<*>} Promisified function
1601
+ */
1602
+ function asPromise(fn, ctx/*, varargs */) {
1603
+ var params = new Array(arguments.length - 1),
1604
+ offset = 0,
1605
+ index = 2,
1606
+ pending = true;
1607
+ while (index < arguments.length)
1608
+ params[offset++] = arguments[index++];
1609
+ return new Promise(function executor(resolve, reject) {
1610
+ params[offset] = function callback(err/*, varargs */) {
1611
+ if (pending) {
1612
+ pending = false;
1613
+ if (err)
1614
+ reject(err);
1615
+ else {
1616
+ var params = new Array(arguments.length - 1),
1617
+ offset = 0;
1618
+ while (offset < params.length)
1619
+ params[offset++] = arguments[offset];
1620
+ resolve.apply(null, params);
1621
+ }
1622
+ }
1623
+ };
1624
+ try {
1625
+ fn.apply(ctx || null, params);
1626
+ } catch (err) {
1627
+ if (pending) {
1628
+ pending = false;
1629
+ reject(err);
1630
+ }
1631
+ }
1632
+ });
1633
+ }
1634
+ return aspromise;
1621
1635
  }
1622
1636
 
1623
1637
  var base64$1 = {};
1624
1638
 
1625
- (function (exports) {
1639
+ var hasRequiredBase64;
1640
+
1641
+ function requireBase64 () {
1642
+ if (hasRequiredBase64) return base64$1;
1643
+ hasRequiredBase64 = 1;
1644
+ (function (exports) {
1626
1645
 
1627
- /**
1628
- * A minimal base64 implementation for number arrays.
1629
- * @memberof util
1630
- * @namespace
1631
- */
1632
- var base64 = exports;
1646
+ /**
1647
+ * A minimal base64 implementation for number arrays.
1648
+ * @memberof util
1649
+ * @namespace
1650
+ */
1651
+ var base64 = exports;
1633
1652
 
1634
- /**
1635
- * Calculates the byte length of a base64 encoded string.
1636
- * @param {string} string Base64 encoded string
1637
- * @returns {number} Byte length
1638
- */
1639
- base64.length = function length(string) {
1640
- var p = string.length;
1641
- if (!p)
1642
- return 0;
1643
- var n = 0;
1644
- while (--p % 4 > 1 && string.charAt(p) === "=")
1645
- ++n;
1646
- return Math.ceil(string.length * 3) / 4 - n;
1647
- };
1653
+ /**
1654
+ * Calculates the byte length of a base64 encoded string.
1655
+ * @param {string} string Base64 encoded string
1656
+ * @returns {number} Byte length
1657
+ */
1658
+ base64.length = function length(string) {
1659
+ var p = string.length;
1660
+ if (!p)
1661
+ return 0;
1662
+ var n = 0;
1663
+ while (--p % 4 > 1 && string.charAt(p) === "=")
1664
+ ++n;
1665
+ return Math.ceil(string.length * 3) / 4 - n;
1666
+ };
1648
1667
 
1649
- // Base64 encoding table
1650
- var b64 = new Array(64);
1668
+ // Base64 encoding table
1669
+ var b64 = new Array(64);
1651
1670
 
1652
- // Base64 decoding table
1653
- var s64 = new Array(123);
1671
+ // Base64 decoding table
1672
+ var s64 = new Array(123);
1654
1673
 
1655
- // 65..90, 97..122, 48..57, 43, 47
1656
- for (var i = 0; i < 64;)
1657
- s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
1674
+ // 65..90, 97..122, 48..57, 43, 47
1675
+ for (var i = 0; i < 64;)
1676
+ s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
1658
1677
 
1659
- /**
1660
- * Encodes a buffer to a base64 encoded string.
1661
- * @param {Uint8Array} buffer Source buffer
1662
- * @param {number} start Source start
1663
- * @param {number} end Source end
1664
- * @returns {string} Base64 encoded string
1665
- */
1666
- base64.encode = function encode(buffer, start, end) {
1667
- var parts = null,
1668
- chunk = [];
1669
- var i = 0, // output index
1670
- j = 0, // goto index
1671
- t; // temporary
1672
- while (start < end) {
1673
- var b = buffer[start++];
1674
- switch (j) {
1675
- case 0:
1676
- chunk[i++] = b64[b >> 2];
1677
- t = (b & 3) << 4;
1678
- j = 1;
1679
- break;
1680
- case 1:
1681
- chunk[i++] = b64[t | b >> 4];
1682
- t = (b & 15) << 2;
1683
- j = 2;
1684
- break;
1685
- case 2:
1686
- chunk[i++] = b64[t | b >> 6];
1687
- chunk[i++] = b64[b & 63];
1688
- j = 0;
1689
- break;
1690
- }
1691
- if (i > 8191) {
1692
- (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
1693
- i = 0;
1694
- }
1695
- }
1696
- if (j) {
1697
- chunk[i++] = b64[t];
1698
- chunk[i++] = 61;
1699
- if (j === 1)
1700
- chunk[i++] = 61;
1701
- }
1702
- if (parts) {
1703
- if (i)
1704
- parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
1705
- return parts.join("");
1706
- }
1707
- return String.fromCharCode.apply(String, chunk.slice(0, i));
1708
- };
1678
+ /**
1679
+ * Encodes a buffer to a base64 encoded string.
1680
+ * @param {Uint8Array} buffer Source buffer
1681
+ * @param {number} start Source start
1682
+ * @param {number} end Source end
1683
+ * @returns {string} Base64 encoded string
1684
+ */
1685
+ base64.encode = function encode(buffer, start, end) {
1686
+ var parts = null,
1687
+ chunk = [];
1688
+ var i = 0, // output index
1689
+ j = 0, // goto index
1690
+ t; // temporary
1691
+ while (start < end) {
1692
+ var b = buffer[start++];
1693
+ switch (j) {
1694
+ case 0:
1695
+ chunk[i++] = b64[b >> 2];
1696
+ t = (b & 3) << 4;
1697
+ j = 1;
1698
+ break;
1699
+ case 1:
1700
+ chunk[i++] = b64[t | b >> 4];
1701
+ t = (b & 15) << 2;
1702
+ j = 2;
1703
+ break;
1704
+ case 2:
1705
+ chunk[i++] = b64[t | b >> 6];
1706
+ chunk[i++] = b64[b & 63];
1707
+ j = 0;
1708
+ break;
1709
+ }
1710
+ if (i > 8191) {
1711
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
1712
+ i = 0;
1713
+ }
1714
+ }
1715
+ if (j) {
1716
+ chunk[i++] = b64[t];
1717
+ chunk[i++] = 61;
1718
+ if (j === 1)
1719
+ chunk[i++] = 61;
1720
+ }
1721
+ if (parts) {
1722
+ if (i)
1723
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
1724
+ return parts.join("");
1725
+ }
1726
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
1727
+ };
1709
1728
 
1710
- var invalidEncoding = "invalid encoding";
1729
+ var invalidEncoding = "invalid encoding";
1711
1730
 
1712
- /**
1713
- * Decodes a base64 encoded string to a buffer.
1714
- * @param {string} string Source string
1715
- * @param {Uint8Array} buffer Destination buffer
1716
- * @param {number} offset Destination offset
1717
- * @returns {number} Number of bytes written
1718
- * @throws {Error} If encoding is invalid
1719
- */
1720
- base64.decode = function decode(string, buffer, offset) {
1721
- var start = offset;
1722
- var j = 0, // goto index
1723
- t; // temporary
1724
- for (var i = 0; i < string.length;) {
1725
- var c = string.charCodeAt(i++);
1726
- if (c === 61 && j > 1)
1727
- break;
1728
- if ((c = s64[c]) === undefined)
1729
- throw Error(invalidEncoding);
1730
- switch (j) {
1731
- case 0:
1732
- t = c;
1733
- j = 1;
1734
- break;
1735
- case 1:
1736
- buffer[offset++] = t << 2 | (c & 48) >> 4;
1737
- t = c;
1738
- j = 2;
1739
- break;
1740
- case 2:
1741
- buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
1742
- t = c;
1743
- j = 3;
1744
- break;
1745
- case 3:
1746
- buffer[offset++] = (t & 3) << 6 | c;
1747
- j = 0;
1748
- break;
1749
- }
1750
- }
1751
- if (j === 1)
1752
- throw Error(invalidEncoding);
1753
- return offset - start;
1754
- };
1731
+ /**
1732
+ * Decodes a base64 encoded string to a buffer.
1733
+ * @param {string} string Source string
1734
+ * @param {Uint8Array} buffer Destination buffer
1735
+ * @param {number} offset Destination offset
1736
+ * @returns {number} Number of bytes written
1737
+ * @throws {Error} If encoding is invalid
1738
+ */
1739
+ base64.decode = function decode(string, buffer, offset) {
1740
+ var start = offset;
1741
+ var j = 0, // goto index
1742
+ t; // temporary
1743
+ for (var i = 0; i < string.length;) {
1744
+ var c = string.charCodeAt(i++);
1745
+ if (c === 61 && j > 1)
1746
+ break;
1747
+ if ((c = s64[c]) === undefined)
1748
+ throw Error(invalidEncoding);
1749
+ switch (j) {
1750
+ case 0:
1751
+ t = c;
1752
+ j = 1;
1753
+ break;
1754
+ case 1:
1755
+ buffer[offset++] = t << 2 | (c & 48) >> 4;
1756
+ t = c;
1757
+ j = 2;
1758
+ break;
1759
+ case 2:
1760
+ buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
1761
+ t = c;
1762
+ j = 3;
1763
+ break;
1764
+ case 3:
1765
+ buffer[offset++] = (t & 3) << 6 | c;
1766
+ j = 0;
1767
+ break;
1768
+ }
1769
+ }
1770
+ if (j === 1)
1771
+ throw Error(invalidEncoding);
1772
+ return offset - start;
1773
+ };
1755
1774
 
1756
- /**
1757
- * Tests if the specified string appears to be base64 encoded.
1758
- * @param {string} string String to test
1759
- * @returns {boolean} `true` if probably base64 encoded, otherwise false
1760
- */
1761
- base64.test = function test(string) {
1762
- return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
1763
- };
1764
- }(base64$1));
1775
+ /**
1776
+ * Tests if the specified string appears to be base64 encoded.
1777
+ * @param {string} string String to test
1778
+ * @returns {boolean} `true` if probably base64 encoded, otherwise false
1779
+ */
1780
+ base64.test = function test(string) {
1781
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
1782
+ };
1783
+ } (base64$1));
1784
+ return base64$1;
1785
+ }
1765
1786
 
1766
- var eventemitter = EventEmitter;
1787
+ var eventemitter;
1788
+ var hasRequiredEventemitter;
1789
+
1790
+ function requireEventemitter () {
1791
+ if (hasRequiredEventemitter) return eventemitter;
1792
+ hasRequiredEventemitter = 1;
1793
+ eventemitter = EventEmitter;
1767
1794
 
1768
- /**
1769
- * Constructs a new event emitter instance.
1770
- * @classdesc A minimal event emitter.
1771
- * @memberof util
1772
- * @constructor
1773
- */
1774
- function EventEmitter() {
1795
+ /**
1796
+ * Constructs a new event emitter instance.
1797
+ * @classdesc A minimal event emitter.
1798
+ * @memberof util
1799
+ * @constructor
1800
+ */
1801
+ function EventEmitter() {
1775
1802
 
1776
- /**
1777
- * Registered listeners.
1778
- * @type {Object.<string,*>}
1779
- * @private
1780
- */
1781
- this._listeners = {};
1782
- }
1803
+ /**
1804
+ * Registered listeners.
1805
+ * @type {Object.<string,*>}
1806
+ * @private
1807
+ */
1808
+ this._listeners = {};
1809
+ }
1783
1810
 
1784
- /**
1785
- * Registers an event listener.
1786
- * @param {string} evt Event name
1787
- * @param {function} fn Listener
1788
- * @param {*} [ctx] Listener context
1789
- * @returns {util.EventEmitter} `this`
1790
- */
1791
- EventEmitter.prototype.on = function on(evt, fn, ctx) {
1792
- (this._listeners[evt] || (this._listeners[evt] = [])).push({
1793
- fn : fn,
1794
- ctx : ctx || this
1795
- });
1796
- return this;
1797
- };
1811
+ /**
1812
+ * Registers an event listener.
1813
+ * @param {string} evt Event name
1814
+ * @param {function} fn Listener
1815
+ * @param {*} [ctx] Listener context
1816
+ * @returns {util.EventEmitter} `this`
1817
+ */
1818
+ EventEmitter.prototype.on = function on(evt, fn, ctx) {
1819
+ (this._listeners[evt] || (this._listeners[evt] = [])).push({
1820
+ fn : fn,
1821
+ ctx : ctx || this
1822
+ });
1823
+ return this;
1824
+ };
1798
1825
 
1799
- /**
1800
- * Removes an event listener or any matching listeners if arguments are omitted.
1801
- * @param {string} [evt] Event name. Removes all listeners if omitted.
1802
- * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
1803
- * @returns {util.EventEmitter} `this`
1804
- */
1805
- EventEmitter.prototype.off = function off(evt, fn) {
1806
- if (evt === undefined)
1807
- this._listeners = {};
1808
- else {
1809
- if (fn === undefined)
1810
- this._listeners[evt] = [];
1811
- else {
1812
- var listeners = this._listeners[evt];
1813
- for (var i = 0; i < listeners.length;)
1814
- if (listeners[i].fn === fn)
1815
- listeners.splice(i, 1);
1816
- else
1817
- ++i;
1818
- }
1819
- }
1820
- return this;
1821
- };
1826
+ /**
1827
+ * Removes an event listener or any matching listeners if arguments are omitted.
1828
+ * @param {string} [evt] Event name. Removes all listeners if omitted.
1829
+ * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
1830
+ * @returns {util.EventEmitter} `this`
1831
+ */
1832
+ EventEmitter.prototype.off = function off(evt, fn) {
1833
+ if (evt === undefined)
1834
+ this._listeners = {};
1835
+ else {
1836
+ if (fn === undefined)
1837
+ this._listeners[evt] = [];
1838
+ else {
1839
+ var listeners = this._listeners[evt];
1840
+ for (var i = 0; i < listeners.length;)
1841
+ if (listeners[i].fn === fn)
1842
+ listeners.splice(i, 1);
1843
+ else
1844
+ ++i;
1845
+ }
1846
+ }
1847
+ return this;
1848
+ };
1822
1849
 
1823
- /**
1824
- * Emits an event by calling its listeners with the specified arguments.
1825
- * @param {string} evt Event name
1826
- * @param {...*} args Arguments
1827
- * @returns {util.EventEmitter} `this`
1828
- */
1829
- EventEmitter.prototype.emit = function emit(evt) {
1830
- var listeners = this._listeners[evt];
1831
- if (listeners) {
1832
- var args = [],
1833
- i = 1;
1834
- for (; i < arguments.length;)
1835
- args.push(arguments[i++]);
1836
- for (i = 0; i < listeners.length;)
1837
- listeners[i].fn.apply(listeners[i++].ctx, args);
1838
- }
1839
- return this;
1840
- };
1850
+ /**
1851
+ * Emits an event by calling its listeners with the specified arguments.
1852
+ * @param {string} evt Event name
1853
+ * @param {...*} args Arguments
1854
+ * @returns {util.EventEmitter} `this`
1855
+ */
1856
+ EventEmitter.prototype.emit = function emit(evt) {
1857
+ var listeners = this._listeners[evt];
1858
+ if (listeners) {
1859
+ var args = [],
1860
+ i = 1;
1861
+ for (; i < arguments.length;)
1862
+ args.push(arguments[i++]);
1863
+ for (i = 0; i < listeners.length;)
1864
+ listeners[i].fn.apply(listeners[i++].ctx, args);
1865
+ }
1866
+ return this;
1867
+ };
1868
+ return eventemitter;
1869
+ }
1841
1870
 
1842
- var float = factory(factory);
1871
+ var float;
1872
+ var hasRequiredFloat;
1873
+
1874
+ function requireFloat () {
1875
+ if (hasRequiredFloat) return float;
1876
+ hasRequiredFloat = 1;
1843
1877
 
1844
- /**
1845
- * Reads / writes floats / doubles from / to buffers.
1846
- * @name util.float
1847
- * @namespace
1848
- */
1878
+ float = factory(factory);
1849
1879
 
1850
- /**
1851
- * Writes a 32 bit float to a buffer using little endian byte order.
1852
- * @name util.float.writeFloatLE
1853
- * @function
1854
- * @param {number} val Value to write
1855
- * @param {Uint8Array} buf Target buffer
1856
- * @param {number} pos Target buffer offset
1857
- * @returns {undefined}
1858
- */
1880
+ /**
1881
+ * Reads / writes floats / doubles from / to buffers.
1882
+ * @name util.float
1883
+ * @namespace
1884
+ */
1859
1885
 
1860
- /**
1861
- * Writes a 32 bit float to a buffer using big endian byte order.
1862
- * @name util.float.writeFloatBE
1863
- * @function
1864
- * @param {number} val Value to write
1865
- * @param {Uint8Array} buf Target buffer
1866
- * @param {number} pos Target buffer offset
1867
- * @returns {undefined}
1868
- */
1886
+ /**
1887
+ * Writes a 32 bit float to a buffer using little endian byte order.
1888
+ * @name util.float.writeFloatLE
1889
+ * @function
1890
+ * @param {number} val Value to write
1891
+ * @param {Uint8Array} buf Target buffer
1892
+ * @param {number} pos Target buffer offset
1893
+ * @returns {undefined}
1894
+ */
1869
1895
 
1870
- /**
1871
- * Reads a 32 bit float from a buffer using little endian byte order.
1872
- * @name util.float.readFloatLE
1873
- * @function
1874
- * @param {Uint8Array} buf Source buffer
1875
- * @param {number} pos Source buffer offset
1876
- * @returns {number} Value read
1877
- */
1896
+ /**
1897
+ * Writes a 32 bit float to a buffer using big endian byte order.
1898
+ * @name util.float.writeFloatBE
1899
+ * @function
1900
+ * @param {number} val Value to write
1901
+ * @param {Uint8Array} buf Target buffer
1902
+ * @param {number} pos Target buffer offset
1903
+ * @returns {undefined}
1904
+ */
1878
1905
 
1879
- /**
1880
- * Reads a 32 bit float from a buffer using big endian byte order.
1881
- * @name util.float.readFloatBE
1882
- * @function
1883
- * @param {Uint8Array} buf Source buffer
1884
- * @param {number} pos Source buffer offset
1885
- * @returns {number} Value read
1886
- */
1906
+ /**
1907
+ * Reads a 32 bit float from a buffer using little endian byte order.
1908
+ * @name util.float.readFloatLE
1909
+ * @function
1910
+ * @param {Uint8Array} buf Source buffer
1911
+ * @param {number} pos Source buffer offset
1912
+ * @returns {number} Value read
1913
+ */
1887
1914
 
1888
- /**
1889
- * Writes a 64 bit double to a buffer using little endian byte order.
1890
- * @name util.float.writeDoubleLE
1891
- * @function
1892
- * @param {number} val Value to write
1893
- * @param {Uint8Array} buf Target buffer
1894
- * @param {number} pos Target buffer offset
1895
- * @returns {undefined}
1896
- */
1915
+ /**
1916
+ * Reads a 32 bit float from a buffer using big endian byte order.
1917
+ * @name util.float.readFloatBE
1918
+ * @function
1919
+ * @param {Uint8Array} buf Source buffer
1920
+ * @param {number} pos Source buffer offset
1921
+ * @returns {number} Value read
1922
+ */
1897
1923
 
1898
- /**
1899
- * Writes a 64 bit double to a buffer using big endian byte order.
1900
- * @name util.float.writeDoubleBE
1901
- * @function
1902
- * @param {number} val Value to write
1903
- * @param {Uint8Array} buf Target buffer
1904
- * @param {number} pos Target buffer offset
1905
- * @returns {undefined}
1906
- */
1924
+ /**
1925
+ * Writes a 64 bit double to a buffer using little endian byte order.
1926
+ * @name util.float.writeDoubleLE
1927
+ * @function
1928
+ * @param {number} val Value to write
1929
+ * @param {Uint8Array} buf Target buffer
1930
+ * @param {number} pos Target buffer offset
1931
+ * @returns {undefined}
1932
+ */
1907
1933
 
1908
- /**
1909
- * Reads a 64 bit double from a buffer using little endian byte order.
1910
- * @name util.float.readDoubleLE
1911
- * @function
1912
- * @param {Uint8Array} buf Source buffer
1913
- * @param {number} pos Source buffer offset
1914
- * @returns {number} Value read
1915
- */
1934
+ /**
1935
+ * Writes a 64 bit double to a buffer using big endian byte order.
1936
+ * @name util.float.writeDoubleBE
1937
+ * @function
1938
+ * @param {number} val Value to write
1939
+ * @param {Uint8Array} buf Target buffer
1940
+ * @param {number} pos Target buffer offset
1941
+ * @returns {undefined}
1942
+ */
1916
1943
 
1917
- /**
1918
- * Reads a 64 bit double from a buffer using big endian byte order.
1919
- * @name util.float.readDoubleBE
1920
- * @function
1921
- * @param {Uint8Array} buf Source buffer
1922
- * @param {number} pos Source buffer offset
1923
- * @returns {number} Value read
1924
- */
1944
+ /**
1945
+ * Reads a 64 bit double from a buffer using little endian byte order.
1946
+ * @name util.float.readDoubleLE
1947
+ * @function
1948
+ * @param {Uint8Array} buf Source buffer
1949
+ * @param {number} pos Source buffer offset
1950
+ * @returns {number} Value read
1951
+ */
1925
1952
 
1926
- // Factory function for the purpose of node-based testing in modified global environments
1927
- function factory(exports) {
1953
+ /**
1954
+ * Reads a 64 bit double from a buffer using big endian byte order.
1955
+ * @name util.float.readDoubleBE
1956
+ * @function
1957
+ * @param {Uint8Array} buf Source buffer
1958
+ * @param {number} pos Source buffer offset
1959
+ * @returns {number} Value read
1960
+ */
1928
1961
 
1929
- // float: typed array
1930
- if (typeof Float32Array !== "undefined") (function() {
1962
+ // Factory function for the purpose of node-based testing in modified global environments
1963
+ function factory(exports) {
1931
1964
 
1932
- var f32 = new Float32Array([ -0 ]),
1933
- f8b = new Uint8Array(f32.buffer),
1934
- le = f8b[3] === 128;
1965
+ // float: typed array
1966
+ if (typeof Float32Array !== "undefined") (function() {
1935
1967
 
1936
- function writeFloat_f32_cpy(val, buf, pos) {
1937
- f32[0] = val;
1938
- buf[pos ] = f8b[0];
1939
- buf[pos + 1] = f8b[1];
1940
- buf[pos + 2] = f8b[2];
1941
- buf[pos + 3] = f8b[3];
1942
- }
1968
+ var f32 = new Float32Array([ -0 ]),
1969
+ f8b = new Uint8Array(f32.buffer),
1970
+ le = f8b[3] === 128;
1943
1971
 
1944
- function writeFloat_f32_rev(val, buf, pos) {
1945
- f32[0] = val;
1946
- buf[pos ] = f8b[3];
1947
- buf[pos + 1] = f8b[2];
1948
- buf[pos + 2] = f8b[1];
1949
- buf[pos + 3] = f8b[0];
1950
- }
1972
+ function writeFloat_f32_cpy(val, buf, pos) {
1973
+ f32[0] = val;
1974
+ buf[pos ] = f8b[0];
1975
+ buf[pos + 1] = f8b[1];
1976
+ buf[pos + 2] = f8b[2];
1977
+ buf[pos + 3] = f8b[3];
1978
+ }
1951
1979
 
1952
- /* istanbul ignore next */
1953
- exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
1954
- /* istanbul ignore next */
1955
- exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
1980
+ function writeFloat_f32_rev(val, buf, pos) {
1981
+ f32[0] = val;
1982
+ buf[pos ] = f8b[3];
1983
+ buf[pos + 1] = f8b[2];
1984
+ buf[pos + 2] = f8b[1];
1985
+ buf[pos + 3] = f8b[0];
1986
+ }
1956
1987
 
1957
- function readFloat_f32_cpy(buf, pos) {
1958
- f8b[0] = buf[pos ];
1959
- f8b[1] = buf[pos + 1];
1960
- f8b[2] = buf[pos + 2];
1961
- f8b[3] = buf[pos + 3];
1962
- return f32[0];
1963
- }
1988
+ /* istanbul ignore next */
1989
+ exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
1990
+ /* istanbul ignore next */
1991
+ exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
1964
1992
 
1965
- function readFloat_f32_rev(buf, pos) {
1966
- f8b[3] = buf[pos ];
1967
- f8b[2] = buf[pos + 1];
1968
- f8b[1] = buf[pos + 2];
1969
- f8b[0] = buf[pos + 3];
1970
- return f32[0];
1971
- }
1993
+ function readFloat_f32_cpy(buf, pos) {
1994
+ f8b[0] = buf[pos ];
1995
+ f8b[1] = buf[pos + 1];
1996
+ f8b[2] = buf[pos + 2];
1997
+ f8b[3] = buf[pos + 3];
1998
+ return f32[0];
1999
+ }
1972
2000
 
1973
- /* istanbul ignore next */
1974
- exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
1975
- /* istanbul ignore next */
1976
- exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
2001
+ function readFloat_f32_rev(buf, pos) {
2002
+ f8b[3] = buf[pos ];
2003
+ f8b[2] = buf[pos + 1];
2004
+ f8b[1] = buf[pos + 2];
2005
+ f8b[0] = buf[pos + 3];
2006
+ return f32[0];
2007
+ }
1977
2008
 
1978
- // float: ieee754
1979
- })(); else (function() {
2009
+ /* istanbul ignore next */
2010
+ exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
2011
+ /* istanbul ignore next */
2012
+ exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
1980
2013
 
1981
- function writeFloat_ieee754(writeUint, val, buf, pos) {
1982
- var sign = val < 0 ? 1 : 0;
1983
- if (sign)
1984
- val = -val;
1985
- if (val === 0)
1986
- writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
1987
- else if (isNaN(val))
1988
- writeUint(2143289344, buf, pos);
1989
- else if (val > 3.4028234663852886e+38) // +-Infinity
1990
- writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
1991
- else if (val < 1.1754943508222875e-38) // denormal
1992
- writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
1993
- else {
1994
- var exponent = Math.floor(Math.log(val) / Math.LN2),
1995
- mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
1996
- writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
1997
- }
1998
- }
2014
+ // float: ieee754
2015
+ })(); else (function() {
1999
2016
 
2000
- exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
2001
- exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
2017
+ function writeFloat_ieee754(writeUint, val, buf, pos) {
2018
+ var sign = val < 0 ? 1 : 0;
2019
+ if (sign)
2020
+ val = -val;
2021
+ if (val === 0)
2022
+ writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
2023
+ else if (isNaN(val))
2024
+ writeUint(2143289344, buf, pos);
2025
+ else if (val > 3.4028234663852886e+38) // +-Infinity
2026
+ writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
2027
+ else if (val < 1.1754943508222875e-38) // denormal
2028
+ writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
2029
+ else {
2030
+ var exponent = Math.floor(Math.log(val) / Math.LN2),
2031
+ mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
2032
+ writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
2033
+ }
2034
+ }
2002
2035
 
2003
- function readFloat_ieee754(readUint, buf, pos) {
2004
- var uint = readUint(buf, pos),
2005
- sign = (uint >> 31) * 2 + 1,
2006
- exponent = uint >>> 23 & 255,
2007
- mantissa = uint & 8388607;
2008
- return exponent === 255
2009
- ? mantissa
2010
- ? NaN
2011
- : sign * Infinity
2012
- : exponent === 0 // denormal
2013
- ? sign * 1.401298464324817e-45 * mantissa
2014
- : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
2015
- }
2036
+ exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
2037
+ exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
2016
2038
 
2017
- exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
2018
- exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
2039
+ function readFloat_ieee754(readUint, buf, pos) {
2040
+ var uint = readUint(buf, pos),
2041
+ sign = (uint >> 31) * 2 + 1,
2042
+ exponent = uint >>> 23 & 255,
2043
+ mantissa = uint & 8388607;
2044
+ return exponent === 255
2045
+ ? mantissa
2046
+ ? NaN
2047
+ : sign * Infinity
2048
+ : exponent === 0 // denormal
2049
+ ? sign * 1.401298464324817e-45 * mantissa
2050
+ : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
2051
+ }
2019
2052
 
2020
- })();
2053
+ exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
2054
+ exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
2021
2055
 
2022
- // double: typed array
2023
- if (typeof Float64Array !== "undefined") (function() {
2056
+ })();
2024
2057
 
2025
- var f64 = new Float64Array([-0]),
2026
- f8b = new Uint8Array(f64.buffer),
2027
- le = f8b[7] === 128;
2058
+ // double: typed array
2059
+ if (typeof Float64Array !== "undefined") (function() {
2028
2060
 
2029
- function writeDouble_f64_cpy(val, buf, pos) {
2030
- f64[0] = val;
2031
- buf[pos ] = f8b[0];
2032
- buf[pos + 1] = f8b[1];
2033
- buf[pos + 2] = f8b[2];
2034
- buf[pos + 3] = f8b[3];
2035
- buf[pos + 4] = f8b[4];
2036
- buf[pos + 5] = f8b[5];
2037
- buf[pos + 6] = f8b[6];
2038
- buf[pos + 7] = f8b[7];
2039
- }
2061
+ var f64 = new Float64Array([-0]),
2062
+ f8b = new Uint8Array(f64.buffer),
2063
+ le = f8b[7] === 128;
2040
2064
 
2041
- function writeDouble_f64_rev(val, buf, pos) {
2042
- f64[0] = val;
2043
- buf[pos ] = f8b[7];
2044
- buf[pos + 1] = f8b[6];
2045
- buf[pos + 2] = f8b[5];
2046
- buf[pos + 3] = f8b[4];
2047
- buf[pos + 4] = f8b[3];
2048
- buf[pos + 5] = f8b[2];
2049
- buf[pos + 6] = f8b[1];
2050
- buf[pos + 7] = f8b[0];
2051
- }
2065
+ function writeDouble_f64_cpy(val, buf, pos) {
2066
+ f64[0] = val;
2067
+ buf[pos ] = f8b[0];
2068
+ buf[pos + 1] = f8b[1];
2069
+ buf[pos + 2] = f8b[2];
2070
+ buf[pos + 3] = f8b[3];
2071
+ buf[pos + 4] = f8b[4];
2072
+ buf[pos + 5] = f8b[5];
2073
+ buf[pos + 6] = f8b[6];
2074
+ buf[pos + 7] = f8b[7];
2075
+ }
2052
2076
 
2053
- /* istanbul ignore next */
2054
- exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
2055
- /* istanbul ignore next */
2056
- exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
2077
+ function writeDouble_f64_rev(val, buf, pos) {
2078
+ f64[0] = val;
2079
+ buf[pos ] = f8b[7];
2080
+ buf[pos + 1] = f8b[6];
2081
+ buf[pos + 2] = f8b[5];
2082
+ buf[pos + 3] = f8b[4];
2083
+ buf[pos + 4] = f8b[3];
2084
+ buf[pos + 5] = f8b[2];
2085
+ buf[pos + 6] = f8b[1];
2086
+ buf[pos + 7] = f8b[0];
2087
+ }
2057
2088
 
2058
- function readDouble_f64_cpy(buf, pos) {
2059
- f8b[0] = buf[pos ];
2060
- f8b[1] = buf[pos + 1];
2061
- f8b[2] = buf[pos + 2];
2062
- f8b[3] = buf[pos + 3];
2063
- f8b[4] = buf[pos + 4];
2064
- f8b[5] = buf[pos + 5];
2065
- f8b[6] = buf[pos + 6];
2066
- f8b[7] = buf[pos + 7];
2067
- return f64[0];
2068
- }
2089
+ /* istanbul ignore next */
2090
+ exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
2091
+ /* istanbul ignore next */
2092
+ exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
2069
2093
 
2070
- function readDouble_f64_rev(buf, pos) {
2071
- f8b[7] = buf[pos ];
2072
- f8b[6] = buf[pos + 1];
2073
- f8b[5] = buf[pos + 2];
2074
- f8b[4] = buf[pos + 3];
2075
- f8b[3] = buf[pos + 4];
2076
- f8b[2] = buf[pos + 5];
2077
- f8b[1] = buf[pos + 6];
2078
- f8b[0] = buf[pos + 7];
2079
- return f64[0];
2080
- }
2094
+ function readDouble_f64_cpy(buf, pos) {
2095
+ f8b[0] = buf[pos ];
2096
+ f8b[1] = buf[pos + 1];
2097
+ f8b[2] = buf[pos + 2];
2098
+ f8b[3] = buf[pos + 3];
2099
+ f8b[4] = buf[pos + 4];
2100
+ f8b[5] = buf[pos + 5];
2101
+ f8b[6] = buf[pos + 6];
2102
+ f8b[7] = buf[pos + 7];
2103
+ return f64[0];
2104
+ }
2081
2105
 
2082
- /* istanbul ignore next */
2083
- exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
2084
- /* istanbul ignore next */
2085
- exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
2106
+ function readDouble_f64_rev(buf, pos) {
2107
+ f8b[7] = buf[pos ];
2108
+ f8b[6] = buf[pos + 1];
2109
+ f8b[5] = buf[pos + 2];
2110
+ f8b[4] = buf[pos + 3];
2111
+ f8b[3] = buf[pos + 4];
2112
+ f8b[2] = buf[pos + 5];
2113
+ f8b[1] = buf[pos + 6];
2114
+ f8b[0] = buf[pos + 7];
2115
+ return f64[0];
2116
+ }
2086
2117
 
2087
- // double: ieee754
2088
- })(); else (function() {
2118
+ /* istanbul ignore next */
2119
+ exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
2120
+ /* istanbul ignore next */
2121
+ exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
2089
2122
 
2090
- function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
2091
- var sign = val < 0 ? 1 : 0;
2092
- if (sign)
2093
- val = -val;
2094
- if (val === 0) {
2095
- writeUint(0, buf, pos + off0);
2096
- writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
2097
- } else if (isNaN(val)) {
2098
- writeUint(0, buf, pos + off0);
2099
- writeUint(2146959360, buf, pos + off1);
2100
- } else if (val > 1.7976931348623157e+308) { // +-Infinity
2101
- writeUint(0, buf, pos + off0);
2102
- writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
2103
- } else {
2104
- var mantissa;
2105
- if (val < 2.2250738585072014e-308) { // denormal
2106
- mantissa = val / 5e-324;
2107
- writeUint(mantissa >>> 0, buf, pos + off0);
2108
- writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
2109
- } else {
2110
- var exponent = Math.floor(Math.log(val) / Math.LN2);
2111
- if (exponent === 1024)
2112
- exponent = 1023;
2113
- mantissa = val * Math.pow(2, -exponent);
2114
- writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
2115
- writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
2116
- }
2117
- }
2118
- }
2123
+ // double: ieee754
2124
+ })(); else (function() {
2119
2125
 
2120
- exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
2121
- exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
2126
+ function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
2127
+ var sign = val < 0 ? 1 : 0;
2128
+ if (sign)
2129
+ val = -val;
2130
+ if (val === 0) {
2131
+ writeUint(0, buf, pos + off0);
2132
+ writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
2133
+ } else if (isNaN(val)) {
2134
+ writeUint(0, buf, pos + off0);
2135
+ writeUint(2146959360, buf, pos + off1);
2136
+ } else if (val > 1.7976931348623157e+308) { // +-Infinity
2137
+ writeUint(0, buf, pos + off0);
2138
+ writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
2139
+ } else {
2140
+ var mantissa;
2141
+ if (val < 2.2250738585072014e-308) { // denormal
2142
+ mantissa = val / 5e-324;
2143
+ writeUint(mantissa >>> 0, buf, pos + off0);
2144
+ writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
2145
+ } else {
2146
+ var exponent = Math.floor(Math.log(val) / Math.LN2);
2147
+ if (exponent === 1024)
2148
+ exponent = 1023;
2149
+ mantissa = val * Math.pow(2, -exponent);
2150
+ writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
2151
+ writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
2152
+ }
2153
+ }
2154
+ }
2122
2155
 
2123
- function readDouble_ieee754(readUint, off0, off1, buf, pos) {
2124
- var lo = readUint(buf, pos + off0),
2125
- hi = readUint(buf, pos + off1);
2126
- var sign = (hi >> 31) * 2 + 1,
2127
- exponent = hi >>> 20 & 2047,
2128
- mantissa = 4294967296 * (hi & 1048575) + lo;
2129
- return exponent === 2047
2130
- ? mantissa
2131
- ? NaN
2132
- : sign * Infinity
2133
- : exponent === 0 // denormal
2134
- ? sign * 5e-324 * mantissa
2135
- : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
2136
- }
2156
+ exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
2157
+ exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
2137
2158
 
2138
- exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
2139
- exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
2159
+ function readDouble_ieee754(readUint, off0, off1, buf, pos) {
2160
+ var lo = readUint(buf, pos + off0),
2161
+ hi = readUint(buf, pos + off1);
2162
+ var sign = (hi >> 31) * 2 + 1,
2163
+ exponent = hi >>> 20 & 2047,
2164
+ mantissa = 4294967296 * (hi & 1048575) + lo;
2165
+ return exponent === 2047
2166
+ ? mantissa
2167
+ ? NaN
2168
+ : sign * Infinity
2169
+ : exponent === 0 // denormal
2170
+ ? sign * 5e-324 * mantissa
2171
+ : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
2172
+ }
2140
2173
 
2141
- })();
2174
+ exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
2175
+ exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
2142
2176
 
2143
- return exports;
2144
- }
2177
+ })();
2145
2178
 
2146
- // uint helpers
2179
+ return exports;
2180
+ }
2147
2181
 
2148
- function writeUintLE(val, buf, pos) {
2149
- buf[pos ] = val & 255;
2150
- buf[pos + 1] = val >>> 8 & 255;
2151
- buf[pos + 2] = val >>> 16 & 255;
2152
- buf[pos + 3] = val >>> 24;
2153
- }
2182
+ // uint helpers
2154
2183
 
2155
- function writeUintBE(val, buf, pos) {
2156
- buf[pos ] = val >>> 24;
2157
- buf[pos + 1] = val >>> 16 & 255;
2158
- buf[pos + 2] = val >>> 8 & 255;
2159
- buf[pos + 3] = val & 255;
2160
- }
2184
+ function writeUintLE(val, buf, pos) {
2185
+ buf[pos ] = val & 255;
2186
+ buf[pos + 1] = val >>> 8 & 255;
2187
+ buf[pos + 2] = val >>> 16 & 255;
2188
+ buf[pos + 3] = val >>> 24;
2189
+ }
2161
2190
 
2162
- function readUintLE(buf, pos) {
2163
- return (buf[pos ]
2164
- | buf[pos + 1] << 8
2165
- | buf[pos + 2] << 16
2166
- | buf[pos + 3] << 24) >>> 0;
2167
- }
2191
+ function writeUintBE(val, buf, pos) {
2192
+ buf[pos ] = val >>> 24;
2193
+ buf[pos + 1] = val >>> 16 & 255;
2194
+ buf[pos + 2] = val >>> 8 & 255;
2195
+ buf[pos + 3] = val & 255;
2196
+ }
2197
+
2198
+ function readUintLE(buf, pos) {
2199
+ return (buf[pos ]
2200
+ | buf[pos + 1] << 8
2201
+ | buf[pos + 2] << 16
2202
+ | buf[pos + 3] << 24) >>> 0;
2203
+ }
2168
2204
 
2169
- function readUintBE(buf, pos) {
2170
- return (buf[pos ] << 24
2171
- | buf[pos + 1] << 16
2172
- | buf[pos + 2] << 8
2173
- | buf[pos + 3]) >>> 0;
2205
+ function readUintBE(buf, pos) {
2206
+ return (buf[pos ] << 24
2207
+ | buf[pos + 1] << 16
2208
+ | buf[pos + 2] << 8
2209
+ | buf[pos + 3]) >>> 0;
2210
+ }
2211
+ return float;
2174
2212
  }
2175
2213
 
2176
- var inquire_1 = inquire;
2214
+ var inquire_1;
2215
+ var hasRequiredInquire;
2216
+
2217
+ function requireInquire () {
2218
+ if (hasRequiredInquire) return inquire_1;
2219
+ hasRequiredInquire = 1;
2220
+ inquire_1 = inquire;
2177
2221
 
2178
- /**
2179
- * Requires a module only if available.
2180
- * @memberof util
2181
- * @param {string} moduleName Module to require
2182
- * @returns {?Object} Required module if available and not empty, otherwise `null`
2183
- */
2184
- function inquire(moduleName) {
2185
- try {
2186
- var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
2187
- if (mod && (mod.length || Object.keys(mod).length))
2188
- return mod;
2189
- } catch (e) {} // eslint-disable-line no-empty
2190
- return null;
2222
+ /**
2223
+ * Requires a module only if available.
2224
+ * @memberof util
2225
+ * @param {string} moduleName Module to require
2226
+ * @returns {?Object} Required module if available and not empty, otherwise `null`
2227
+ */
2228
+ function inquire(moduleName) {
2229
+ try {
2230
+ var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
2231
+ if (mod && (mod.length || Object.keys(mod).length))
2232
+ return mod;
2233
+ } catch (e) {} // eslint-disable-line no-empty
2234
+ return null;
2235
+ }
2236
+ return inquire_1;
2191
2237
  }
2192
2238
 
2193
2239
  var utf8$2 = {};
2194
2240
 
2195
- (function (exports) {
2241
+ var hasRequiredUtf8;
2242
+
2243
+ function requireUtf8 () {
2244
+ if (hasRequiredUtf8) return utf8$2;
2245
+ hasRequiredUtf8 = 1;
2246
+ (function (exports) {
2196
2247
 
2197
- /**
2198
- * A minimal UTF8 implementation for number arrays.
2199
- * @memberof util
2200
- * @namespace
2201
- */
2202
- var utf8 = exports;
2248
+ /**
2249
+ * A minimal UTF8 implementation for number arrays.
2250
+ * @memberof util
2251
+ * @namespace
2252
+ */
2253
+ var utf8 = exports;
2203
2254
 
2204
- /**
2205
- * Calculates the UTF8 byte length of a string.
2206
- * @param {string} string String
2207
- * @returns {number} Byte length
2208
- */
2209
- utf8.length = function utf8_length(string) {
2210
- var len = 0,
2211
- c = 0;
2212
- for (var i = 0; i < string.length; ++i) {
2213
- c = string.charCodeAt(i);
2214
- if (c < 128)
2215
- len += 1;
2216
- else if (c < 2048)
2217
- len += 2;
2218
- else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
2219
- ++i;
2220
- len += 4;
2221
- } else
2222
- len += 3;
2223
- }
2224
- return len;
2225
- };
2255
+ /**
2256
+ * Calculates the UTF8 byte length of a string.
2257
+ * @param {string} string String
2258
+ * @returns {number} Byte length
2259
+ */
2260
+ utf8.length = function utf8_length(string) {
2261
+ var len = 0,
2262
+ c = 0;
2263
+ for (var i = 0; i < string.length; ++i) {
2264
+ c = string.charCodeAt(i);
2265
+ if (c < 128)
2266
+ len += 1;
2267
+ else if (c < 2048)
2268
+ len += 2;
2269
+ else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
2270
+ ++i;
2271
+ len += 4;
2272
+ } else
2273
+ len += 3;
2274
+ }
2275
+ return len;
2276
+ };
2226
2277
 
2227
- /**
2228
- * Reads UTF8 bytes as a string.
2229
- * @param {Uint8Array} buffer Source buffer
2230
- * @param {number} start Source start
2231
- * @param {number} end Source end
2232
- * @returns {string} String read
2233
- */
2234
- utf8.read = function utf8_read(buffer, start, end) {
2235
- var len = end - start;
2236
- if (len < 1)
2237
- return "";
2238
- var parts = null,
2239
- chunk = [],
2240
- i = 0, // char offset
2241
- t; // temporary
2242
- while (start < end) {
2243
- t = buffer[start++];
2244
- if (t < 128)
2245
- chunk[i++] = t;
2246
- else if (t > 191 && t < 224)
2247
- chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
2248
- else if (t > 239 && t < 365) {
2249
- t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
2250
- chunk[i++] = 0xD800 + (t >> 10);
2251
- chunk[i++] = 0xDC00 + (t & 1023);
2252
- } else
2253
- chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
2254
- if (i > 8191) {
2255
- (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
2256
- i = 0;
2257
- }
2258
- }
2259
- if (parts) {
2260
- if (i)
2261
- parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
2262
- return parts.join("");
2263
- }
2264
- return String.fromCharCode.apply(String, chunk.slice(0, i));
2265
- };
2278
+ /**
2279
+ * Reads UTF8 bytes as a string.
2280
+ * @param {Uint8Array} buffer Source buffer
2281
+ * @param {number} start Source start
2282
+ * @param {number} end Source end
2283
+ * @returns {string} String read
2284
+ */
2285
+ utf8.read = function utf8_read(buffer, start, end) {
2286
+ var len = end - start;
2287
+ if (len < 1)
2288
+ return "";
2289
+ var parts = null,
2290
+ chunk = [],
2291
+ i = 0, // char offset
2292
+ t; // temporary
2293
+ while (start < end) {
2294
+ t = buffer[start++];
2295
+ if (t < 128)
2296
+ chunk[i++] = t;
2297
+ else if (t > 191 && t < 224)
2298
+ chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
2299
+ else if (t > 239 && t < 365) {
2300
+ t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
2301
+ chunk[i++] = 0xD800 + (t >> 10);
2302
+ chunk[i++] = 0xDC00 + (t & 1023);
2303
+ } else
2304
+ chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
2305
+ if (i > 8191) {
2306
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
2307
+ i = 0;
2308
+ }
2309
+ }
2310
+ if (parts) {
2311
+ if (i)
2312
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
2313
+ return parts.join("");
2314
+ }
2315
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
2316
+ };
2266
2317
 
2267
- /**
2268
- * Writes a string as UTF8 bytes.
2269
- * @param {string} string Source string
2270
- * @param {Uint8Array} buffer Destination buffer
2271
- * @param {number} offset Destination offset
2272
- * @returns {number} Bytes written
2273
- */
2274
- utf8.write = function utf8_write(string, buffer, offset) {
2275
- var start = offset,
2276
- c1, // character 1
2277
- c2; // character 2
2278
- for (var i = 0; i < string.length; ++i) {
2279
- c1 = string.charCodeAt(i);
2280
- if (c1 < 128) {
2281
- buffer[offset++] = c1;
2282
- } else if (c1 < 2048) {
2283
- buffer[offset++] = c1 >> 6 | 192;
2284
- buffer[offset++] = c1 & 63 | 128;
2285
- } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
2286
- c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
2287
- ++i;
2288
- buffer[offset++] = c1 >> 18 | 240;
2289
- buffer[offset++] = c1 >> 12 & 63 | 128;
2290
- buffer[offset++] = c1 >> 6 & 63 | 128;
2291
- buffer[offset++] = c1 & 63 | 128;
2292
- } else {
2293
- buffer[offset++] = c1 >> 12 | 224;
2294
- buffer[offset++] = c1 >> 6 & 63 | 128;
2295
- buffer[offset++] = c1 & 63 | 128;
2296
- }
2297
- }
2298
- return offset - start;
2299
- };
2300
- }(utf8$2));
2318
+ /**
2319
+ * Writes a string as UTF8 bytes.
2320
+ * @param {string} string Source string
2321
+ * @param {Uint8Array} buffer Destination buffer
2322
+ * @param {number} offset Destination offset
2323
+ * @returns {number} Bytes written
2324
+ */
2325
+ utf8.write = function utf8_write(string, buffer, offset) {
2326
+ var start = offset,
2327
+ c1, // character 1
2328
+ c2; // character 2
2329
+ for (var i = 0; i < string.length; ++i) {
2330
+ c1 = string.charCodeAt(i);
2331
+ if (c1 < 128) {
2332
+ buffer[offset++] = c1;
2333
+ } else if (c1 < 2048) {
2334
+ buffer[offset++] = c1 >> 6 | 192;
2335
+ buffer[offset++] = c1 & 63 | 128;
2336
+ } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
2337
+ c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
2338
+ ++i;
2339
+ buffer[offset++] = c1 >> 18 | 240;
2340
+ buffer[offset++] = c1 >> 12 & 63 | 128;
2341
+ buffer[offset++] = c1 >> 6 & 63 | 128;
2342
+ buffer[offset++] = c1 & 63 | 128;
2343
+ } else {
2344
+ buffer[offset++] = c1 >> 12 | 224;
2345
+ buffer[offset++] = c1 >> 6 & 63 | 128;
2346
+ buffer[offset++] = c1 & 63 | 128;
2347
+ }
2348
+ }
2349
+ return offset - start;
2350
+ };
2351
+ } (utf8$2));
2352
+ return utf8$2;
2353
+ }
2354
+
2355
+ var pool_1;
2356
+ var hasRequiredPool;
2301
2357
 
2302
- var pool_1 = pool;
2358
+ function requirePool () {
2359
+ if (hasRequiredPool) return pool_1;
2360
+ hasRequiredPool = 1;
2361
+ pool_1 = pool;
2303
2362
 
2304
- /**
2305
- * An allocator as used by {@link util.pool}.
2306
- * @typedef PoolAllocator
2307
- * @type {function}
2308
- * @param {number} size Buffer size
2309
- * @returns {Uint8Array} Buffer
2310
- */
2363
+ /**
2364
+ * An allocator as used by {@link util.pool}.
2365
+ * @typedef PoolAllocator
2366
+ * @type {function}
2367
+ * @param {number} size Buffer size
2368
+ * @returns {Uint8Array} Buffer
2369
+ */
2311
2370
 
2312
- /**
2313
- * A slicer as used by {@link util.pool}.
2314
- * @typedef PoolSlicer
2315
- * @type {function}
2316
- * @param {number} start Start offset
2317
- * @param {number} end End offset
2318
- * @returns {Uint8Array} Buffer slice
2319
- * @this {Uint8Array}
2320
- */
2371
+ /**
2372
+ * A slicer as used by {@link util.pool}.
2373
+ * @typedef PoolSlicer
2374
+ * @type {function}
2375
+ * @param {number} start Start offset
2376
+ * @param {number} end End offset
2377
+ * @returns {Uint8Array} Buffer slice
2378
+ * @this {Uint8Array}
2379
+ */
2321
2380
 
2322
- /**
2323
- * A general purpose buffer pool.
2324
- * @memberof util
2325
- * @function
2326
- * @param {PoolAllocator} alloc Allocator
2327
- * @param {PoolSlicer} slice Slicer
2328
- * @param {number} [size=8192] Slab size
2329
- * @returns {PoolAllocator} Pooled allocator
2330
- */
2331
- function pool(alloc, slice, size) {
2332
- var SIZE = size || 8192;
2333
- var MAX = SIZE >>> 1;
2334
- var slab = null;
2335
- var offset = SIZE;
2336
- return function pool_alloc(size) {
2337
- if (size < 1 || size > MAX)
2338
- return alloc(size);
2339
- if (offset + size > SIZE) {
2340
- slab = alloc(SIZE);
2341
- offset = 0;
2342
- }
2343
- var buf = slice.call(slab, offset, offset += size);
2344
- if (offset & 7) // align to 32 bit
2345
- offset = (offset | 7) + 1;
2346
- return buf;
2347
- };
2381
+ /**
2382
+ * A general purpose buffer pool.
2383
+ * @memberof util
2384
+ * @function
2385
+ * @param {PoolAllocator} alloc Allocator
2386
+ * @param {PoolSlicer} slice Slicer
2387
+ * @param {number} [size=8192] Slab size
2388
+ * @returns {PoolAllocator} Pooled allocator
2389
+ */
2390
+ function pool(alloc, slice, size) {
2391
+ var SIZE = size || 8192;
2392
+ var MAX = SIZE >>> 1;
2393
+ var slab = null;
2394
+ var offset = SIZE;
2395
+ return function pool_alloc(size) {
2396
+ if (size < 1 || size > MAX)
2397
+ return alloc(size);
2398
+ if (offset + size > SIZE) {
2399
+ slab = alloc(SIZE);
2400
+ offset = 0;
2401
+ }
2402
+ var buf = slice.call(slab, offset, offset += size);
2403
+ if (offset & 7) // align to 32 bit
2404
+ offset = (offset | 7) + 1;
2405
+ return buf;
2406
+ };
2407
+ }
2408
+ return pool_1;
2348
2409
  }
2349
2410
 
2350
- var longbits = LongBits$2;
2351
-
2352
- var util$5 = minimal$1;
2353
-
2354
- /**
2355
- * Constructs new long bits.
2356
- * @classdesc Helper class for working with the low and high bits of a 64 bit value.
2357
- * @memberof util
2358
- * @constructor
2359
- * @param {number} lo Low 32 bits, unsigned
2360
- * @param {number} hi High 32 bits, unsigned
2361
- */
2362
- function LongBits$2(lo, hi) {
2363
-
2364
- // note that the casts below are theoretically unnecessary as of today, but older statically
2365
- // generated converter code might still call the ctor with signed 32bits. kept for compat.
2366
-
2367
- /**
2368
- * Low bits.
2369
- * @type {number}
2370
- */
2371
- this.lo = lo >>> 0;
2372
-
2373
- /**
2374
- * High bits.
2375
- * @type {number}
2376
- */
2377
- this.hi = hi >>> 0;
2411
+ var longbits;
2412
+ var hasRequiredLongbits;
2413
+
2414
+ function requireLongbits () {
2415
+ if (hasRequiredLongbits) return longbits;
2416
+ hasRequiredLongbits = 1;
2417
+ longbits = LongBits;
2418
+
2419
+ var util = requireMinimal();
2420
+
2421
+ /**
2422
+ * Constructs new long bits.
2423
+ * @classdesc Helper class for working with the low and high bits of a 64 bit value.
2424
+ * @memberof util
2425
+ * @constructor
2426
+ * @param {number} lo Low 32 bits, unsigned
2427
+ * @param {number} hi High 32 bits, unsigned
2428
+ */
2429
+ function LongBits(lo, hi) {
2430
+
2431
+ // note that the casts below are theoretically unnecessary as of today, but older statically
2432
+ // generated converter code might still call the ctor with signed 32bits. kept for compat.
2433
+
2434
+ /**
2435
+ * Low bits.
2436
+ * @type {number}
2437
+ */
2438
+ this.lo = lo >>> 0;
2439
+
2440
+ /**
2441
+ * High bits.
2442
+ * @type {number}
2443
+ */
2444
+ this.hi = hi >>> 0;
2445
+ }
2446
+
2447
+ /**
2448
+ * Zero bits.
2449
+ * @memberof util.LongBits
2450
+ * @type {util.LongBits}
2451
+ */
2452
+ var zero = LongBits.zero = new LongBits(0, 0);
2453
+
2454
+ zero.toNumber = function() { return 0; };
2455
+ zero.zzEncode = zero.zzDecode = function() { return this; };
2456
+ zero.length = function() { return 1; };
2457
+
2458
+ /**
2459
+ * Zero hash.
2460
+ * @memberof util.LongBits
2461
+ * @type {string}
2462
+ */
2463
+ var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0";
2464
+
2465
+ /**
2466
+ * Constructs new long bits from the specified number.
2467
+ * @param {number} value Value
2468
+ * @returns {util.LongBits} Instance
2469
+ */
2470
+ LongBits.fromNumber = function fromNumber(value) {
2471
+ if (value === 0)
2472
+ return zero;
2473
+ var sign = value < 0;
2474
+ if (sign)
2475
+ value = -value;
2476
+ var lo = value >>> 0,
2477
+ hi = (value - lo) / 4294967296 >>> 0;
2478
+ if (sign) {
2479
+ hi = ~hi >>> 0;
2480
+ lo = ~lo >>> 0;
2481
+ if (++lo > 4294967295) {
2482
+ lo = 0;
2483
+ if (++hi > 4294967295)
2484
+ hi = 0;
2485
+ }
2486
+ }
2487
+ return new LongBits(lo, hi);
2488
+ };
2489
+
2490
+ /**
2491
+ * Constructs new long bits from a number, long or string.
2492
+ * @param {Long|number|string} value Value
2493
+ * @returns {util.LongBits} Instance
2494
+ */
2495
+ LongBits.from = function from(value) {
2496
+ if (typeof value === "number")
2497
+ return LongBits.fromNumber(value);
2498
+ if (util.isString(value)) {
2499
+ /* istanbul ignore else */
2500
+ if (util.Long)
2501
+ value = util.Long.fromString(value);
2502
+ else
2503
+ return LongBits.fromNumber(parseInt(value, 10));
2504
+ }
2505
+ return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;
2506
+ };
2507
+
2508
+ /**
2509
+ * Converts this long bits to a possibly unsafe JavaScript number.
2510
+ * @param {boolean} [unsigned=false] Whether unsigned or not
2511
+ * @returns {number} Possibly unsafe number
2512
+ */
2513
+ LongBits.prototype.toNumber = function toNumber(unsigned) {
2514
+ if (!unsigned && this.hi >>> 31) {
2515
+ var lo = ~this.lo + 1 >>> 0,
2516
+ hi = ~this.hi >>> 0;
2517
+ if (!lo)
2518
+ hi = hi + 1 >>> 0;
2519
+ return -(lo + hi * 4294967296);
2520
+ }
2521
+ return this.lo + this.hi * 4294967296;
2522
+ };
2523
+
2524
+ /**
2525
+ * Converts this long bits to a long.
2526
+ * @param {boolean} [unsigned=false] Whether unsigned or not
2527
+ * @returns {Long} Long
2528
+ */
2529
+ LongBits.prototype.toLong = function toLong(unsigned) {
2530
+ return util.Long
2531
+ ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
2532
+ /* istanbul ignore next */
2533
+ : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
2534
+ };
2535
+
2536
+ var charCodeAt = String.prototype.charCodeAt;
2537
+
2538
+ /**
2539
+ * Constructs new long bits from the specified 8 characters long hash.
2540
+ * @param {string} hash Hash
2541
+ * @returns {util.LongBits} Bits
2542
+ */
2543
+ LongBits.fromHash = function fromHash(hash) {
2544
+ if (hash === zeroHash)
2545
+ return zero;
2546
+ return new LongBits(
2547
+ ( charCodeAt.call(hash, 0)
2548
+ | charCodeAt.call(hash, 1) << 8
2549
+ | charCodeAt.call(hash, 2) << 16
2550
+ | charCodeAt.call(hash, 3) << 24) >>> 0
2551
+ ,
2552
+ ( charCodeAt.call(hash, 4)
2553
+ | charCodeAt.call(hash, 5) << 8
2554
+ | charCodeAt.call(hash, 6) << 16
2555
+ | charCodeAt.call(hash, 7) << 24) >>> 0
2556
+ );
2557
+ };
2558
+
2559
+ /**
2560
+ * Converts this long bits to a 8 characters long hash.
2561
+ * @returns {string} Hash
2562
+ */
2563
+ LongBits.prototype.toHash = function toHash() {
2564
+ return String.fromCharCode(
2565
+ this.lo & 255,
2566
+ this.lo >>> 8 & 255,
2567
+ this.lo >>> 16 & 255,
2568
+ this.lo >>> 24 ,
2569
+ this.hi & 255,
2570
+ this.hi >>> 8 & 255,
2571
+ this.hi >>> 16 & 255,
2572
+ this.hi >>> 24
2573
+ );
2574
+ };
2575
+
2576
+ /**
2577
+ * Zig-zag encodes this long bits.
2578
+ * @returns {util.LongBits} `this`
2579
+ */
2580
+ LongBits.prototype.zzEncode = function zzEncode() {
2581
+ var mask = this.hi >> 31;
2582
+ this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
2583
+ this.lo = ( this.lo << 1 ^ mask) >>> 0;
2584
+ return this;
2585
+ };
2586
+
2587
+ /**
2588
+ * Zig-zag decodes this long bits.
2589
+ * @returns {util.LongBits} `this`
2590
+ */
2591
+ LongBits.prototype.zzDecode = function zzDecode() {
2592
+ var mask = -(this.lo & 1);
2593
+ this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
2594
+ this.hi = ( this.hi >>> 1 ^ mask) >>> 0;
2595
+ return this;
2596
+ };
2597
+
2598
+ /**
2599
+ * Calculates the length of this longbits when encoded as a varint.
2600
+ * @returns {number} Length
2601
+ */
2602
+ LongBits.prototype.length = function length() {
2603
+ var part0 = this.lo,
2604
+ part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,
2605
+ part2 = this.hi >>> 24;
2606
+ return part2 === 0
2607
+ ? part1 === 0
2608
+ ? part0 < 16384
2609
+ ? part0 < 128 ? 1 : 2
2610
+ : part0 < 2097152 ? 3 : 4
2611
+ : part1 < 16384
2612
+ ? part1 < 128 ? 5 : 6
2613
+ : part1 < 2097152 ? 7 : 8
2614
+ : part2 < 128 ? 9 : 10;
2615
+ };
2616
+ return longbits;
2378
2617
  }
2379
2618
 
2380
- /**
2381
- * Zero bits.
2382
- * @memberof util.LongBits
2383
- * @type {util.LongBits}
2384
- */
2385
- var zero = LongBits$2.zero = new LongBits$2(0, 0);
2386
-
2387
- zero.toNumber = function() { return 0; };
2388
- zero.zzEncode = zero.zzDecode = function() { return this; };
2389
- zero.length = function() { return 1; };
2390
-
2391
- /**
2392
- * Zero hash.
2393
- * @memberof util.LongBits
2394
- * @type {string}
2395
- */
2396
- var zeroHash = LongBits$2.zeroHash = "\0\0\0\0\0\0\0\0";
2397
-
2398
- /**
2399
- * Constructs new long bits from the specified number.
2400
- * @param {number} value Value
2401
- * @returns {util.LongBits} Instance
2402
- */
2403
- LongBits$2.fromNumber = function fromNumber(value) {
2404
- if (value === 0)
2405
- return zero;
2406
- var sign = value < 0;
2407
- if (sign)
2408
- value = -value;
2409
- var lo = value >>> 0,
2410
- hi = (value - lo) / 4294967296 >>> 0;
2411
- if (sign) {
2412
- hi = ~hi >>> 0;
2413
- lo = ~lo >>> 0;
2414
- if (++lo > 4294967295) {
2415
- lo = 0;
2416
- if (++hi > 4294967295)
2417
- hi = 0;
2418
- }
2419
- }
2420
- return new LongBits$2(lo, hi);
2421
- };
2422
-
2423
- /**
2424
- * Constructs new long bits from a number, long or string.
2425
- * @param {Long|number|string} value Value
2426
- * @returns {util.LongBits} Instance
2427
- */
2428
- LongBits$2.from = function from(value) {
2429
- if (typeof value === "number")
2430
- return LongBits$2.fromNumber(value);
2431
- if (util$5.isString(value)) {
2432
- /* istanbul ignore else */
2433
- if (util$5.Long)
2434
- value = util$5.Long.fromString(value);
2435
- else
2436
- return LongBits$2.fromNumber(parseInt(value, 10));
2437
- }
2438
- return value.low || value.high ? new LongBits$2(value.low >>> 0, value.high >>> 0) : zero;
2439
- };
2440
-
2441
- /**
2442
- * Converts this long bits to a possibly unsafe JavaScript number.
2443
- * @param {boolean} [unsigned=false] Whether unsigned or not
2444
- * @returns {number} Possibly unsafe number
2445
- */
2446
- LongBits$2.prototype.toNumber = function toNumber(unsigned) {
2447
- if (!unsigned && this.hi >>> 31) {
2448
- var lo = ~this.lo + 1 >>> 0,
2449
- hi = ~this.hi >>> 0;
2450
- if (!lo)
2451
- hi = hi + 1 >>> 0;
2452
- return -(lo + hi * 4294967296);
2453
- }
2454
- return this.lo + this.hi * 4294967296;
2455
- };
2456
-
2457
- /**
2458
- * Converts this long bits to a long.
2459
- * @param {boolean} [unsigned=false] Whether unsigned or not
2460
- * @returns {Long} Long
2461
- */
2462
- LongBits$2.prototype.toLong = function toLong(unsigned) {
2463
- return util$5.Long
2464
- ? new util$5.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
2465
- /* istanbul ignore next */
2466
- : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
2467
- };
2468
-
2469
- var charCodeAt = String.prototype.charCodeAt;
2470
-
2471
- /**
2472
- * Constructs new long bits from the specified 8 characters long hash.
2473
- * @param {string} hash Hash
2474
- * @returns {util.LongBits} Bits
2475
- */
2476
- LongBits$2.fromHash = function fromHash(hash) {
2477
- if (hash === zeroHash)
2478
- return zero;
2479
- return new LongBits$2(
2480
- ( charCodeAt.call(hash, 0)
2481
- | charCodeAt.call(hash, 1) << 8
2482
- | charCodeAt.call(hash, 2) << 16
2483
- | charCodeAt.call(hash, 3) << 24) >>> 0
2484
- ,
2485
- ( charCodeAt.call(hash, 4)
2486
- | charCodeAt.call(hash, 5) << 8
2487
- | charCodeAt.call(hash, 6) << 16
2488
- | charCodeAt.call(hash, 7) << 24) >>> 0
2489
- );
2490
- };
2491
-
2492
- /**
2493
- * Converts this long bits to a 8 characters long hash.
2494
- * @returns {string} Hash
2495
- */
2496
- LongBits$2.prototype.toHash = function toHash() {
2497
- return String.fromCharCode(
2498
- this.lo & 255,
2499
- this.lo >>> 8 & 255,
2500
- this.lo >>> 16 & 255,
2501
- this.lo >>> 24 ,
2502
- this.hi & 255,
2503
- this.hi >>> 8 & 255,
2504
- this.hi >>> 16 & 255,
2505
- this.hi >>> 24
2506
- );
2507
- };
2508
-
2509
- /**
2510
- * Zig-zag encodes this long bits.
2511
- * @returns {util.LongBits} `this`
2512
- */
2513
- LongBits$2.prototype.zzEncode = function zzEncode() {
2514
- var mask = this.hi >> 31;
2515
- this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
2516
- this.lo = ( this.lo << 1 ^ mask) >>> 0;
2517
- return this;
2518
- };
2519
-
2520
- /**
2521
- * Zig-zag decodes this long bits.
2522
- * @returns {util.LongBits} `this`
2523
- */
2524
- LongBits$2.prototype.zzDecode = function zzDecode() {
2525
- var mask = -(this.lo & 1);
2526
- this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
2527
- this.hi = ( this.hi >>> 1 ^ mask) >>> 0;
2528
- return this;
2529
- };
2530
-
2531
- /**
2532
- * Calculates the length of this longbits when encoded as a varint.
2533
- * @returns {number} Length
2534
- */
2535
- LongBits$2.prototype.length = function length() {
2536
- var part0 = this.lo,
2537
- part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,
2538
- part2 = this.hi >>> 24;
2539
- return part2 === 0
2540
- ? part1 === 0
2541
- ? part0 < 16384
2542
- ? part0 < 128 ? 1 : 2
2543
- : part0 < 2097152 ? 3 : 4
2544
- : part1 < 16384
2545
- ? part1 < 128 ? 5 : 6
2546
- : part1 < 2097152 ? 7 : 8
2547
- : part2 < 128 ? 9 : 10;
2548
- };
2549
-
2550
- (function (exports) {
2551
- var util = exports;
2552
-
2553
- // used to return a Promise where callback is omitted
2554
- util.asPromise = aspromise;
2555
-
2556
- // converts to / from base64 encoded strings
2557
- util.base64 = base64$1;
2558
-
2559
- // base class of rpc.Service
2560
- util.EventEmitter = eventemitter;
2561
-
2562
- // float handling accross browsers
2563
- util.float = float;
2564
-
2565
- // requires modules optionally and hides the call from bundlers
2566
- util.inquire = inquire_1;
2567
-
2568
- // converts to / from utf8 encoded strings
2569
- util.utf8 = utf8$2;
2570
-
2571
- // provides a node-like buffer pool in the browser
2572
- util.pool = pool_1;
2573
-
2574
- // utility to work with the low and high bits of a 64 bit value
2575
- util.LongBits = longbits;
2576
-
2577
- /**
2578
- * Whether running within node or not.
2579
- * @memberof util
2580
- * @type {boolean}
2581
- */
2582
- util.isNode = Boolean(typeof commonjsGlobal !== "undefined"
2583
- && commonjsGlobal
2584
- && commonjsGlobal.process
2585
- && commonjsGlobal.process.versions
2586
- && commonjsGlobal.process.versions.node);
2587
-
2588
- /**
2589
- * Global object reference.
2590
- * @memberof util
2591
- * @type {Object}
2592
- */
2593
- util.global = util.isNode && commonjsGlobal
2594
- || typeof window !== "undefined" && window
2595
- || typeof self !== "undefined" && self
2596
- || commonjsGlobal; // eslint-disable-line no-invalid-this
2597
-
2598
- /**
2599
- * An immuable empty array.
2600
- * @memberof util
2601
- * @type {Array.<*>}
2602
- * @const
2603
- */
2604
- util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes
2605
-
2606
- /**
2607
- * An immutable empty object.
2608
- * @type {Object}
2609
- * @const
2610
- */
2611
- util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes
2612
-
2613
- /**
2614
- * Tests if the specified value is an integer.
2615
- * @function
2616
- * @param {*} value Value to test
2617
- * @returns {boolean} `true` if the value is an integer
2618
- */
2619
- util.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) {
2620
- return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
2621
- };
2622
-
2623
- /**
2624
- * Tests if the specified value is a string.
2625
- * @param {*} value Value to test
2626
- * @returns {boolean} `true` if the value is a string
2627
- */
2628
- util.isString = function isString(value) {
2629
- return typeof value === "string" || value instanceof String;
2630
- };
2631
-
2632
- /**
2633
- * Tests if the specified value is a non-null object.
2634
- * @param {*} value Value to test
2635
- * @returns {boolean} `true` if the value is a non-null object
2636
- */
2637
- util.isObject = function isObject(value) {
2638
- return value && typeof value === "object";
2639
- };
2640
-
2641
- /**
2642
- * Checks if a property on a message is considered to be present.
2643
- * This is an alias of {@link util.isSet}.
2644
- * @function
2645
- * @param {Object} obj Plain object or message instance
2646
- * @param {string} prop Property name
2647
- * @returns {boolean} `true` if considered to be present, otherwise `false`
2648
- */
2649
- util.isset =
2650
-
2651
- /**
2652
- * Checks if a property on a message is considered to be present.
2653
- * @param {Object} obj Plain object or message instance
2654
- * @param {string} prop Property name
2655
- * @returns {boolean} `true` if considered to be present, otherwise `false`
2656
- */
2657
- util.isSet = function isSet(obj, prop) {
2658
- var value = obj[prop];
2659
- if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins
2660
- return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;
2661
- return false;
2662
- };
2663
-
2664
- /**
2665
- * Any compatible Buffer instance.
2666
- * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.
2667
- * @interface Buffer
2668
- * @extends Uint8Array
2669
- */
2670
-
2671
- /**
2672
- * Node's Buffer class if available.
2673
- * @type {Constructor<Buffer>}
2674
- */
2675
- util.Buffer = (function() {
2676
- try {
2677
- var Buffer = util.inquire("buffer").Buffer;
2678
- // refuse to use non-node buffers if not explicitly assigned (perf reasons):
2679
- return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null;
2680
- } catch (e) {
2681
- /* istanbul ignore next */
2682
- return null;
2683
- }
2684
- })();
2685
-
2686
- // Internal alias of or polyfull for Buffer.from.
2687
- util._Buffer_from = null;
2688
-
2689
- // Internal alias of or polyfill for Buffer.allocUnsafe.
2690
- util._Buffer_allocUnsafe = null;
2691
-
2692
- /**
2693
- * Creates a new buffer of whatever type supported by the environment.
2694
- * @param {number|number[]} [sizeOrArray=0] Buffer size or number array
2695
- * @returns {Uint8Array|Buffer} Buffer
2696
- */
2697
- util.newBuffer = function newBuffer(sizeOrArray) {
2698
- /* istanbul ignore next */
2699
- return typeof sizeOrArray === "number"
2700
- ? util.Buffer
2701
- ? util._Buffer_allocUnsafe(sizeOrArray)
2702
- : new util.Array(sizeOrArray)
2703
- : util.Buffer
2704
- ? util._Buffer_from(sizeOrArray)
2705
- : typeof Uint8Array === "undefined"
2706
- ? sizeOrArray
2707
- : new Uint8Array(sizeOrArray);
2708
- };
2709
-
2710
- /**
2711
- * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.
2712
- * @type {Constructor<Uint8Array>}
2713
- */
2714
- util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array;
2715
-
2716
- /**
2717
- * Any compatible Long instance.
2718
- * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.
2719
- * @interface Long
2720
- * @property {number} low Low bits
2721
- * @property {number} high High bits
2722
- * @property {boolean} unsigned Whether unsigned or not
2723
- */
2724
-
2725
- /**
2726
- * Long.js's Long class if available.
2727
- * @type {Constructor<Long>}
2728
- */
2729
- util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long
2730
- || /* istanbul ignore next */ util.global.Long
2731
- || util.inquire("long");
2732
-
2733
- /**
2734
- * Regular expression used to verify 2 bit (`bool`) map keys.
2735
- * @type {RegExp}
2736
- * @const
2737
- */
2738
- util.key2Re = /^true|false|0|1$/;
2739
-
2740
- /**
2741
- * Regular expression used to verify 32 bit (`int32` etc.) map keys.
2742
- * @type {RegExp}
2743
- * @const
2744
- */
2745
- util.key32Re = /^-?(?:0|[1-9][0-9]*)$/;
2746
-
2747
- /**
2748
- * Regular expression used to verify 64 bit (`int64` etc.) map keys.
2749
- * @type {RegExp}
2750
- * @const
2751
- */
2752
- util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;
2753
-
2754
- /**
2755
- * Converts a number or long to an 8 characters long hash string.
2756
- * @param {Long|number} value Value to convert
2757
- * @returns {string} Hash
2758
- */
2759
- util.longToHash = function longToHash(value) {
2760
- return value
2761
- ? util.LongBits.from(value).toHash()
2762
- : util.LongBits.zeroHash;
2763
- };
2764
-
2765
- /**
2766
- * Converts an 8 characters long hash string to a long or number.
2767
- * @param {string} hash Hash
2768
- * @param {boolean} [unsigned=false] Whether unsigned or not
2769
- * @returns {Long|number} Original value
2770
- */
2771
- util.longFromHash = function longFromHash(hash, unsigned) {
2772
- var bits = util.LongBits.fromHash(hash);
2773
- if (util.Long)
2774
- return util.Long.fromBits(bits.lo, bits.hi, unsigned);
2775
- return bits.toNumber(Boolean(unsigned));
2776
- };
2777
-
2778
- /**
2779
- * Merges the properties of the source object into the destination object.
2780
- * @memberof util
2781
- * @param {Object.<string,*>} dst Destination object
2782
- * @param {Object.<string,*>} src Source object
2783
- * @param {boolean} [ifNotSet=false] Merges only if the key is not already set
2784
- * @returns {Object.<string,*>} Destination object
2785
- */
2786
- function merge(dst, src, ifNotSet) { // used by converters
2787
- for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
2788
- if (dst[keys[i]] === undefined || !ifNotSet)
2789
- dst[keys[i]] = src[keys[i]];
2790
- return dst;
2791
- }
2792
-
2793
- util.merge = merge;
2794
-
2795
- /**
2796
- * Converts the first character of a string to lower case.
2797
- * @param {string} str String to convert
2798
- * @returns {string} Converted string
2799
- */
2800
- util.lcFirst = function lcFirst(str) {
2801
- return str.charAt(0).toLowerCase() + str.substring(1);
2802
- };
2803
-
2804
- /**
2805
- * Creates a custom error constructor.
2806
- * @memberof util
2807
- * @param {string} name Error name
2808
- * @returns {Constructor<Error>} Custom error constructor
2809
- */
2810
- function newError(name) {
2811
-
2812
- function CustomError(message, properties) {
2813
-
2814
- if (!(this instanceof CustomError))
2815
- return new CustomError(message, properties);
2816
-
2817
- // Error.call(this, message);
2818
- // ^ just returns a new error instance because the ctor can be called as a function
2819
-
2820
- Object.defineProperty(this, "message", { get: function() { return message; } });
2821
-
2822
- /* istanbul ignore next */
2823
- if (Error.captureStackTrace) // node
2824
- Error.captureStackTrace(this, CustomError);
2825
- else
2826
- Object.defineProperty(this, "stack", { value: new Error().stack || "" });
2827
-
2828
- if (properties)
2829
- merge(this, properties);
2830
- }
2831
-
2832
- CustomError.prototype = Object.create(Error.prototype, {
2833
- constructor: {
2834
- value: CustomError,
2835
- writable: true,
2836
- enumerable: false,
2837
- configurable: true,
2838
- },
2839
- name: {
2840
- get: function get() { return name; },
2841
- set: undefined,
2842
- enumerable: false,
2843
- // configurable: false would accurately preserve the behavior of
2844
- // the original, but I'm guessing that was not intentional.
2845
- // For an actual error subclass, this property would
2846
- // be configurable.
2847
- configurable: true,
2848
- },
2849
- toString: {
2850
- value: function value() { return this.name + ": " + this.message; },
2851
- writable: true,
2852
- enumerable: false,
2853
- configurable: true,
2854
- },
2855
- });
2856
-
2857
- return CustomError;
2619
+ var hasRequiredMinimal;
2620
+
2621
+ function requireMinimal () {
2622
+ if (hasRequiredMinimal) return minimal$1;
2623
+ hasRequiredMinimal = 1;
2624
+ (function (exports) {
2625
+ var util = exports;
2626
+
2627
+ // used to return a Promise where callback is omitted
2628
+ util.asPromise = requireAspromise();
2629
+
2630
+ // converts to / from base64 encoded strings
2631
+ util.base64 = requireBase64();
2632
+
2633
+ // base class of rpc.Service
2634
+ util.EventEmitter = requireEventemitter();
2635
+
2636
+ // float handling accross browsers
2637
+ util.float = requireFloat();
2638
+
2639
+ // requires modules optionally and hides the call from bundlers
2640
+ util.inquire = requireInquire();
2641
+
2642
+ // converts to / from utf8 encoded strings
2643
+ util.utf8 = requireUtf8();
2644
+
2645
+ // provides a node-like buffer pool in the browser
2646
+ util.pool = requirePool();
2647
+
2648
+ // utility to work with the low and high bits of a 64 bit value
2649
+ util.LongBits = requireLongbits();
2650
+
2651
+ /**
2652
+ * Whether running within node or not.
2653
+ * @memberof util
2654
+ * @type {boolean}
2655
+ */
2656
+ util.isNode = Boolean(typeof commonjsGlobal !== "undefined"
2657
+ && commonjsGlobal
2658
+ && commonjsGlobal.process
2659
+ && commonjsGlobal.process.versions
2660
+ && commonjsGlobal.process.versions.node);
2661
+
2662
+ /**
2663
+ * Global object reference.
2664
+ * @memberof util
2665
+ * @type {Object}
2666
+ */
2667
+ util.global = util.isNode && commonjsGlobal
2668
+ || typeof window !== "undefined" && window
2669
+ || typeof self !== "undefined" && self
2670
+ || commonjsGlobal; // eslint-disable-line no-invalid-this
2671
+
2672
+ /**
2673
+ * An immuable empty array.
2674
+ * @memberof util
2675
+ * @type {Array.<*>}
2676
+ * @const
2677
+ */
2678
+ util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes
2679
+
2680
+ /**
2681
+ * An immutable empty object.
2682
+ * @type {Object}
2683
+ * @const
2684
+ */
2685
+ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes
2686
+
2687
+ /**
2688
+ * Tests if the specified value is an integer.
2689
+ * @function
2690
+ * @param {*} value Value to test
2691
+ * @returns {boolean} `true` if the value is an integer
2692
+ */
2693
+ util.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) {
2694
+ return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
2695
+ };
2696
+
2697
+ /**
2698
+ * Tests if the specified value is a string.
2699
+ * @param {*} value Value to test
2700
+ * @returns {boolean} `true` if the value is a string
2701
+ */
2702
+ util.isString = function isString(value) {
2703
+ return typeof value === "string" || value instanceof String;
2704
+ };
2705
+
2706
+ /**
2707
+ * Tests if the specified value is a non-null object.
2708
+ * @param {*} value Value to test
2709
+ * @returns {boolean} `true` if the value is a non-null object
2710
+ */
2711
+ util.isObject = function isObject(value) {
2712
+ return value && typeof value === "object";
2713
+ };
2714
+
2715
+ /**
2716
+ * Checks if a property on a message is considered to be present.
2717
+ * This is an alias of {@link util.isSet}.
2718
+ * @function
2719
+ * @param {Object} obj Plain object or message instance
2720
+ * @param {string} prop Property name
2721
+ * @returns {boolean} `true` if considered to be present, otherwise `false`
2722
+ */
2723
+ util.isset =
2724
+
2725
+ /**
2726
+ * Checks if a property on a message is considered to be present.
2727
+ * @param {Object} obj Plain object or message instance
2728
+ * @param {string} prop Property name
2729
+ * @returns {boolean} `true` if considered to be present, otherwise `false`
2730
+ */
2731
+ util.isSet = function isSet(obj, prop) {
2732
+ var value = obj[prop];
2733
+ if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins
2734
+ return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;
2735
+ return false;
2736
+ };
2737
+
2738
+ /**
2739
+ * Any compatible Buffer instance.
2740
+ * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.
2741
+ * @interface Buffer
2742
+ * @extends Uint8Array
2743
+ */
2744
+
2745
+ /**
2746
+ * Node's Buffer class if available.
2747
+ * @type {Constructor<Buffer>}
2748
+ */
2749
+ util.Buffer = (function() {
2750
+ try {
2751
+ var Buffer = util.inquire("buffer").Buffer;
2752
+ // refuse to use non-node buffers if not explicitly assigned (perf reasons):
2753
+ return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null;
2754
+ } catch (e) {
2755
+ /* istanbul ignore next */
2756
+ return null;
2757
+ }
2758
+ })();
2759
+
2760
+ // Internal alias of or polyfull for Buffer.from.
2761
+ util._Buffer_from = null;
2762
+
2763
+ // Internal alias of or polyfill for Buffer.allocUnsafe.
2764
+ util._Buffer_allocUnsafe = null;
2765
+
2766
+ /**
2767
+ * Creates a new buffer of whatever type supported by the environment.
2768
+ * @param {number|number[]} [sizeOrArray=0] Buffer size or number array
2769
+ * @returns {Uint8Array|Buffer} Buffer
2770
+ */
2771
+ util.newBuffer = function newBuffer(sizeOrArray) {
2772
+ /* istanbul ignore next */
2773
+ return typeof sizeOrArray === "number"
2774
+ ? util.Buffer
2775
+ ? util._Buffer_allocUnsafe(sizeOrArray)
2776
+ : new util.Array(sizeOrArray)
2777
+ : util.Buffer
2778
+ ? util._Buffer_from(sizeOrArray)
2779
+ : typeof Uint8Array === "undefined"
2780
+ ? sizeOrArray
2781
+ : new Uint8Array(sizeOrArray);
2782
+ };
2783
+
2784
+ /**
2785
+ * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.
2786
+ * @type {Constructor<Uint8Array>}
2787
+ */
2788
+ util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array;
2789
+
2790
+ /**
2791
+ * Any compatible Long instance.
2792
+ * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.
2793
+ * @interface Long
2794
+ * @property {number} low Low bits
2795
+ * @property {number} high High bits
2796
+ * @property {boolean} unsigned Whether unsigned or not
2797
+ */
2798
+
2799
+ /**
2800
+ * Long.js's Long class if available.
2801
+ * @type {Constructor<Long>}
2802
+ */
2803
+ util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long
2804
+ || /* istanbul ignore next */ util.global.Long
2805
+ || util.inquire("long");
2806
+
2807
+ /**
2808
+ * Regular expression used to verify 2 bit (`bool`) map keys.
2809
+ * @type {RegExp}
2810
+ * @const
2811
+ */
2812
+ util.key2Re = /^true|false|0|1$/;
2813
+
2814
+ /**
2815
+ * Regular expression used to verify 32 bit (`int32` etc.) map keys.
2816
+ * @type {RegExp}
2817
+ * @const
2818
+ */
2819
+ util.key32Re = /^-?(?:0|[1-9][0-9]*)$/;
2820
+
2821
+ /**
2822
+ * Regular expression used to verify 64 bit (`int64` etc.) map keys.
2823
+ * @type {RegExp}
2824
+ * @const
2825
+ */
2826
+ util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;
2827
+
2828
+ /**
2829
+ * Converts a number or long to an 8 characters long hash string.
2830
+ * @param {Long|number} value Value to convert
2831
+ * @returns {string} Hash
2832
+ */
2833
+ util.longToHash = function longToHash(value) {
2834
+ return value
2835
+ ? util.LongBits.from(value).toHash()
2836
+ : util.LongBits.zeroHash;
2837
+ };
2838
+
2839
+ /**
2840
+ * Converts an 8 characters long hash string to a long or number.
2841
+ * @param {string} hash Hash
2842
+ * @param {boolean} [unsigned=false] Whether unsigned or not
2843
+ * @returns {Long|number} Original value
2844
+ */
2845
+ util.longFromHash = function longFromHash(hash, unsigned) {
2846
+ var bits = util.LongBits.fromHash(hash);
2847
+ if (util.Long)
2848
+ return util.Long.fromBits(bits.lo, bits.hi, unsigned);
2849
+ return bits.toNumber(Boolean(unsigned));
2850
+ };
2851
+
2852
+ /**
2853
+ * Merges the properties of the source object into the destination object.
2854
+ * @memberof util
2855
+ * @param {Object.<string,*>} dst Destination object
2856
+ * @param {Object.<string,*>} src Source object
2857
+ * @param {boolean} [ifNotSet=false] Merges only if the key is not already set
2858
+ * @returns {Object.<string,*>} Destination object
2859
+ */
2860
+ function merge(dst, src, ifNotSet) { // used by converters
2861
+ for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
2862
+ if (dst[keys[i]] === undefined || !ifNotSet)
2863
+ dst[keys[i]] = src[keys[i]];
2864
+ return dst;
2865
+ }
2866
+
2867
+ util.merge = merge;
2868
+
2869
+ /**
2870
+ * Converts the first character of a string to lower case.
2871
+ * @param {string} str String to convert
2872
+ * @returns {string} Converted string
2873
+ */
2874
+ util.lcFirst = function lcFirst(str) {
2875
+ return str.charAt(0).toLowerCase() + str.substring(1);
2876
+ };
2877
+
2878
+ /**
2879
+ * Creates a custom error constructor.
2880
+ * @memberof util
2881
+ * @param {string} name Error name
2882
+ * @returns {Constructor<Error>} Custom error constructor
2883
+ */
2884
+ function newError(name) {
2885
+
2886
+ function CustomError(message, properties) {
2887
+
2888
+ if (!(this instanceof CustomError))
2889
+ return new CustomError(message, properties);
2890
+
2891
+ // Error.call(this, message);
2892
+ // ^ just returns a new error instance because the ctor can be called as a function
2893
+
2894
+ Object.defineProperty(this, "message", { get: function() { return message; } });
2895
+
2896
+ /* istanbul ignore next */
2897
+ if (Error.captureStackTrace) // node
2898
+ Error.captureStackTrace(this, CustomError);
2899
+ else
2900
+ Object.defineProperty(this, "stack", { value: new Error().stack || "" });
2901
+
2902
+ if (properties)
2903
+ merge(this, properties);
2904
+ }
2905
+
2906
+ CustomError.prototype = Object.create(Error.prototype, {
2907
+ constructor: {
2908
+ value: CustomError,
2909
+ writable: true,
2910
+ enumerable: false,
2911
+ configurable: true,
2912
+ },
2913
+ name: {
2914
+ get: function get() { return name; },
2915
+ set: undefined,
2916
+ enumerable: false,
2917
+ // configurable: false would accurately preserve the behavior of
2918
+ // the original, but I'm guessing that was not intentional.
2919
+ // For an actual error subclass, this property would
2920
+ // be configurable.
2921
+ configurable: true,
2922
+ },
2923
+ toString: {
2924
+ value: function value() { return this.name + ": " + this.message; },
2925
+ writable: true,
2926
+ enumerable: false,
2927
+ configurable: true,
2928
+ },
2929
+ });
2930
+
2931
+ return CustomError;
2932
+ }
2933
+
2934
+ util.newError = newError;
2935
+
2936
+ /**
2937
+ * Constructs a new protocol error.
2938
+ * @classdesc Error subclass indicating a protocol specifc error.
2939
+ * @memberof util
2940
+ * @extends Error
2941
+ * @template T extends Message<T>
2942
+ * @constructor
2943
+ * @param {string} message Error message
2944
+ * @param {Object.<string,*>} [properties] Additional properties
2945
+ * @example
2946
+ * try {
2947
+ * MyMessage.decode(someBuffer); // throws if required fields are missing
2948
+ * } catch (e) {
2949
+ * if (e instanceof ProtocolError && e.instance)
2950
+ * console.log("decoded so far: " + JSON.stringify(e.instance));
2951
+ * }
2952
+ */
2953
+ util.ProtocolError = newError("ProtocolError");
2954
+
2955
+ /**
2956
+ * So far decoded message instance.
2957
+ * @name util.ProtocolError#instance
2958
+ * @type {Message<T>}
2959
+ */
2960
+
2961
+ /**
2962
+ * A OneOf getter as returned by {@link util.oneOfGetter}.
2963
+ * @typedef OneOfGetter
2964
+ * @type {function}
2965
+ * @returns {string|undefined} Set field name, if any
2966
+ */
2967
+
2968
+ /**
2969
+ * Builds a getter for a oneof's present field name.
2970
+ * @param {string[]} fieldNames Field names
2971
+ * @returns {OneOfGetter} Unbound getter
2972
+ */
2973
+ util.oneOfGetter = function getOneOf(fieldNames) {
2974
+ var fieldMap = {};
2975
+ for (var i = 0; i < fieldNames.length; ++i)
2976
+ fieldMap[fieldNames[i]] = 1;
2977
+
2978
+ /**
2979
+ * @returns {string|undefined} Set field name, if any
2980
+ * @this Object
2981
+ * @ignore
2982
+ */
2983
+ return function() { // eslint-disable-line consistent-return
2984
+ for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i)
2985
+ if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null)
2986
+ return keys[i];
2987
+ };
2988
+ };
2989
+
2990
+ /**
2991
+ * A OneOf setter as returned by {@link util.oneOfSetter}.
2992
+ * @typedef OneOfSetter
2993
+ * @type {function}
2994
+ * @param {string|undefined} value Field name
2995
+ * @returns {undefined}
2996
+ */
2997
+
2998
+ /**
2999
+ * Builds a setter for a oneof's present field name.
3000
+ * @param {string[]} fieldNames Field names
3001
+ * @returns {OneOfSetter} Unbound setter
3002
+ */
3003
+ util.oneOfSetter = function setOneOf(fieldNames) {
3004
+
3005
+ /**
3006
+ * @param {string} name Field name
3007
+ * @returns {undefined}
3008
+ * @this Object
3009
+ * @ignore
3010
+ */
3011
+ return function(name) {
3012
+ for (var i = 0; i < fieldNames.length; ++i)
3013
+ if (fieldNames[i] !== name)
3014
+ delete this[fieldNames[i]];
3015
+ };
3016
+ };
3017
+
3018
+ /**
3019
+ * Default conversion options used for {@link Message#toJSON} implementations.
3020
+ *
3021
+ * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:
3022
+ *
3023
+ * - Longs become strings
3024
+ * - Enums become string keys
3025
+ * - Bytes become base64 encoded strings
3026
+ * - (Sub-)Messages become plain objects
3027
+ * - Maps become plain objects with all string keys
3028
+ * - Repeated fields become arrays
3029
+ * - NaN and Infinity for float and double fields become strings
3030
+ *
3031
+ * @type {IConversionOptions}
3032
+ * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json
3033
+ */
3034
+ util.toJSONOptions = {
3035
+ longs: String,
3036
+ enums: String,
3037
+ bytes: String,
3038
+ json: true
3039
+ };
3040
+
3041
+ // Sets up buffer utility according to the environment (called in index-minimal)
3042
+ util._configure = function() {
3043
+ var Buffer = util.Buffer;
3044
+ /* istanbul ignore if */
3045
+ if (!Buffer) {
3046
+ util._Buffer_from = util._Buffer_allocUnsafe = null;
3047
+ return;
3048
+ }
3049
+ // because node 4.x buffers are incompatible & immutable
3050
+ // see: https://github.com/dcodeIO/protobuf.js/pull/665
3051
+ util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from ||
3052
+ /* istanbul ignore next */
3053
+ function Buffer_from(value, encoding) {
3054
+ return new Buffer(value, encoding);
3055
+ };
3056
+ util._Buffer_allocUnsafe = Buffer.allocUnsafe ||
3057
+ /* istanbul ignore next */
3058
+ function Buffer_allocUnsafe(size) {
3059
+ return new Buffer(size);
3060
+ };
3061
+ };
3062
+ } (minimal$1));
3063
+ return minimal$1;
2858
3064
  }
2859
3065
 
2860
- util.newError = newError;
2861
-
2862
- /**
2863
- * Constructs a new protocol error.
2864
- * @classdesc Error subclass indicating a protocol specifc error.
2865
- * @memberof util
2866
- * @extends Error
2867
- * @template T extends Message<T>
2868
- * @constructor
2869
- * @param {string} message Error message
2870
- * @param {Object.<string,*>} [properties] Additional properties
2871
- * @example
2872
- * try {
2873
- * MyMessage.decode(someBuffer); // throws if required fields are missing
2874
- * } catch (e) {
2875
- * if (e instanceof ProtocolError && e.instance)
2876
- * console.log("decoded so far: " + JSON.stringify(e.instance));
2877
- * }
2878
- */
2879
- util.ProtocolError = newError("ProtocolError");
2880
-
2881
- /**
2882
- * So far decoded message instance.
2883
- * @name util.ProtocolError#instance
2884
- * @type {Message<T>}
2885
- */
2886
-
2887
- /**
2888
- * A OneOf getter as returned by {@link util.oneOfGetter}.
2889
- * @typedef OneOfGetter
2890
- * @type {function}
2891
- * @returns {string|undefined} Set field name, if any
2892
- */
2893
-
2894
- /**
2895
- * Builds a getter for a oneof's present field name.
2896
- * @param {string[]} fieldNames Field names
2897
- * @returns {OneOfGetter} Unbound getter
2898
- */
2899
- util.oneOfGetter = function getOneOf(fieldNames) {
2900
- var fieldMap = {};
2901
- for (var i = 0; i < fieldNames.length; ++i)
2902
- fieldMap[fieldNames[i]] = 1;
2903
-
2904
- /**
2905
- * @returns {string|undefined} Set field name, if any
2906
- * @this Object
2907
- * @ignore
2908
- */
2909
- return function() { // eslint-disable-line consistent-return
2910
- for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i)
2911
- if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null)
2912
- return keys[i];
2913
- };
2914
- };
2915
-
2916
- /**
2917
- * A OneOf setter as returned by {@link util.oneOfSetter}.
2918
- * @typedef OneOfSetter
2919
- * @type {function}
2920
- * @param {string|undefined} value Field name
2921
- * @returns {undefined}
2922
- */
2923
-
2924
- /**
2925
- * Builds a setter for a oneof's present field name.
2926
- * @param {string[]} fieldNames Field names
2927
- * @returns {OneOfSetter} Unbound setter
2928
- */
2929
- util.oneOfSetter = function setOneOf(fieldNames) {
2930
-
2931
- /**
2932
- * @param {string} name Field name
2933
- * @returns {undefined}
2934
- * @this Object
2935
- * @ignore
2936
- */
2937
- return function(name) {
2938
- for (var i = 0; i < fieldNames.length; ++i)
2939
- if (fieldNames[i] !== name)
2940
- delete this[fieldNames[i]];
2941
- };
2942
- };
2943
-
2944
- /**
2945
- * Default conversion options used for {@link Message#toJSON} implementations.
2946
- *
2947
- * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:
2948
- *
2949
- * - Longs become strings
2950
- * - Enums become string keys
2951
- * - Bytes become base64 encoded strings
2952
- * - (Sub-)Messages become plain objects
2953
- * - Maps become plain objects with all string keys
2954
- * - Repeated fields become arrays
2955
- * - NaN and Infinity for float and double fields become strings
2956
- *
2957
- * @type {IConversionOptions}
2958
- * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json
2959
- */
2960
- util.toJSONOptions = {
2961
- longs: String,
2962
- enums: String,
2963
- bytes: String,
2964
- json: true
2965
- };
2966
-
2967
- // Sets up buffer utility according to the environment (called in index-minimal)
2968
- util._configure = function() {
2969
- var Buffer = util.Buffer;
2970
- /* istanbul ignore if */
2971
- if (!Buffer) {
2972
- util._Buffer_from = util._Buffer_allocUnsafe = null;
2973
- return;
2974
- }
2975
- // because node 4.x buffers are incompatible & immutable
2976
- // see: https://github.com/dcodeIO/protobuf.js/pull/665
2977
- util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from ||
2978
- /* istanbul ignore next */
2979
- function Buffer_from(value, encoding) {
2980
- return new Buffer(value, encoding);
2981
- };
2982
- util._Buffer_allocUnsafe = Buffer.allocUnsafe ||
2983
- /* istanbul ignore next */
2984
- function Buffer_allocUnsafe(size) {
2985
- return new Buffer(size);
2986
- };
2987
- };
2988
- }(minimal$1));
2989
-
2990
3066
  var writer = Writer$1;
2991
3067
 
2992
- var util$4 = minimal$1;
3068
+ var util$4 = requireMinimal();
2993
3069
 
2994
3070
  var BufferWriter$1; // cyclic
2995
3071
 
@@ -3458,7 +3534,7 @@ var writer_buffer = BufferWriter;
3458
3534
  var Writer = writer;
3459
3535
  (BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;
3460
3536
 
3461
- var util$3 = minimal$1;
3537
+ var util$3 = requireMinimal();
3462
3538
 
3463
3539
  /**
3464
3540
  * Constructs a new buffer writer instance.
@@ -3539,7 +3615,7 @@ BufferWriter._configure();
3539
3615
 
3540
3616
  var reader = Reader$1;
3541
3617
 
3542
- var util$2 = minimal$1;
3618
+ var util$2 = requireMinimal();
3543
3619
 
3544
3620
  var BufferReader$1; // cyclic
3545
3621
 
@@ -3959,7 +4035,7 @@ var reader_buffer = BufferReader;
3959
4035
  var Reader = reader;
3960
4036
  (BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
3961
4037
 
3962
- var util$1 = minimal$1;
4038
+ var util$1 = requireMinimal();
3963
4039
 
3964
4040
  /**
3965
4041
  * Constructs a new buffer reader instance.
@@ -4008,7 +4084,7 @@ var rpc = {};
4008
4084
 
4009
4085
  var service = Service;
4010
4086
 
4011
- var util = minimal$1;
4087
+ var util = requireMinimal();
4012
4088
 
4013
4089
  // Extends EventEmitter
4014
4090
  (Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;
@@ -4150,84 +4226,86 @@ Service.prototype.end = function end(endedByRPC) {
4150
4226
 
4151
4227
  (function (exports) {
4152
4228
 
4153
- /**
4154
- * Streaming RPC helpers.
4155
- * @namespace
4156
- */
4157
- var rpc = exports;
4158
-
4159
- /**
4160
- * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets.
4161
- * @typedef RPCImpl
4162
- * @type {function}
4163
- * @param {Method|rpc.ServiceMethod<Message<{}>,Message<{}>>} method Reflected or static method being called
4164
- * @param {Uint8Array} requestData Request data
4165
- * @param {RPCImplCallback} callback Callback function
4166
- * @returns {undefined}
4167
- * @example
4168
- * function rpcImpl(method, requestData, callback) {
4169
- * if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code
4170
- * throw Error("no such method");
4171
- * asynchronouslyObtainAResponse(requestData, function(err, responseData) {
4172
- * callback(err, responseData);
4173
- * });
4174
- * }
4175
- */
4176
-
4177
- /**
4178
- * Node-style callback as used by {@link RPCImpl}.
4179
- * @typedef RPCImplCallback
4180
- * @type {function}
4181
- * @param {Error|null} error Error, if any, otherwise `null`
4182
- * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error
4183
- * @returns {undefined}
4184
- */
4185
-
4186
- rpc.Service = service;
4187
- }(rpc));
4229
+ /**
4230
+ * Streaming RPC helpers.
4231
+ * @namespace
4232
+ */
4233
+ var rpc = exports;
4234
+
4235
+ /**
4236
+ * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets.
4237
+ * @typedef RPCImpl
4238
+ * @type {function}
4239
+ * @param {Method|rpc.ServiceMethod<Message<{}>,Message<{}>>} method Reflected or static method being called
4240
+ * @param {Uint8Array} requestData Request data
4241
+ * @param {RPCImplCallback} callback Callback function
4242
+ * @returns {undefined}
4243
+ * @example
4244
+ * function rpcImpl(method, requestData, callback) {
4245
+ * if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code
4246
+ * throw Error("no such method");
4247
+ * asynchronouslyObtainAResponse(requestData, function(err, responseData) {
4248
+ * callback(err, responseData);
4249
+ * });
4250
+ * }
4251
+ */
4252
+
4253
+ /**
4254
+ * Node-style callback as used by {@link RPCImpl}.
4255
+ * @typedef RPCImplCallback
4256
+ * @type {function}
4257
+ * @param {Error|null} error Error, if any, otherwise `null`
4258
+ * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error
4259
+ * @returns {undefined}
4260
+ */
4261
+
4262
+ rpc.Service = service;
4263
+ } (rpc));
4188
4264
 
4189
4265
  var roots = {};
4190
4266
 
4191
4267
  (function (exports) {
4192
- var protobuf = exports;
4193
-
4194
- /**
4195
- * Build type, one of `"full"`, `"light"` or `"minimal"`.
4196
- * @name build
4197
- * @type {string}
4198
- * @const
4199
- */
4200
- protobuf.build = "minimal";
4201
-
4202
- // Serialization
4203
- protobuf.Writer = writer;
4204
- protobuf.BufferWriter = writer_buffer;
4205
- protobuf.Reader = reader;
4206
- protobuf.BufferReader = reader_buffer;
4207
-
4208
- // Utility
4209
- protobuf.util = minimal$1;
4210
- protobuf.rpc = rpc;
4211
- protobuf.roots = roots;
4212
- protobuf.configure = configure;
4213
-
4214
- /* istanbul ignore next */
4215
- /**
4216
- * Reconfigures the library according to the environment.
4217
- * @returns {undefined}
4218
- */
4219
- function configure() {
4220
- protobuf.util._configure();
4221
- protobuf.Writer._configure(protobuf.BufferWriter);
4222
- protobuf.Reader._configure(protobuf.BufferReader);
4223
- }
4224
-
4225
- // Set up buffer utility according to the environment
4226
- configure();
4227
- }(indexMinimal));
4268
+ var protobuf = exports;
4269
+
4270
+ /**
4271
+ * Build type, one of `"full"`, `"light"` or `"minimal"`.
4272
+ * @name build
4273
+ * @type {string}
4274
+ * @const
4275
+ */
4276
+ protobuf.build = "minimal";
4277
+
4278
+ // Serialization
4279
+ protobuf.Writer = writer;
4280
+ protobuf.BufferWriter = writer_buffer;
4281
+ protobuf.Reader = reader;
4282
+ protobuf.BufferReader = reader_buffer;
4283
+
4284
+ // Utility
4285
+ protobuf.util = requireMinimal();
4286
+ protobuf.rpc = rpc;
4287
+ protobuf.roots = roots;
4288
+ protobuf.configure = configure;
4289
+
4290
+ /* istanbul ignore next */
4291
+ /**
4292
+ * Reconfigures the library according to the environment.
4293
+ * @returns {undefined}
4294
+ */
4295
+ function configure() {
4296
+ protobuf.util._configure();
4297
+ protobuf.Writer._configure(protobuf.BufferWriter);
4298
+ protobuf.Reader._configure(protobuf.BufferReader);
4299
+ }
4300
+
4301
+ // Set up buffer utility according to the environment
4302
+ configure();
4303
+ } (indexMinimal));
4228
4304
 
4229
4305
  var minimal = indexMinimal;
4230
4306
 
4307
+ var _m0 = /*@__PURE__*/getDefaultExportFromCjs(minimal);
4308
+
4231
4309
  /* eslint-disable */
4232
4310
  /**
4233
4311
  * `NullValue` is a singleton enumeration to represent the null value for the
@@ -4265,7 +4343,7 @@ function createBaseStruct() {
4265
4343
  return { fields: {} };
4266
4344
  }
4267
4345
  const Struct = {
4268
- encode(message, writer = minimal.Writer.create()) {
4346
+ encode(message, writer = _m0.Writer.create()) {
4269
4347
  Object.entries(message.fields).forEach(([key, value]) => {
4270
4348
  if (value !== undefined) {
4271
4349
  Struct_FieldsEntry.encode({ key: key, value }, writer.uint32(10).fork()).ldelim();
@@ -4274,7 +4352,7 @@ const Struct = {
4274
4352
  return writer;
4275
4353
  },
4276
4354
  decode(input, length) {
4277
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
4355
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
4278
4356
  let end = length === undefined ? reader.len : reader.pos + length;
4279
4357
  const message = createBaseStruct();
4280
4358
  while (reader.pos < end) {
@@ -4321,12 +4399,12 @@ const Struct = {
4321
4399
  return obj;
4322
4400
  },
4323
4401
  create(base) {
4324
- return Struct.fromPartial(base !== null && base !== void 0 ? base : {});
4402
+ return Struct.fromPartial(base !== null && base !== undefined ? base : {});
4325
4403
  },
4326
4404
  fromPartial(object) {
4327
4405
  var _a;
4328
4406
  const message = createBaseStruct();
4329
- message.fields = Object.entries((_a = object.fields) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
4407
+ message.fields = Object.entries((_a = object.fields) !== null && _a !== undefined ? _a : {}).reduce((acc, [key, value]) => {
4330
4408
  if (value !== undefined) {
4331
4409
  acc[key] = value;
4332
4410
  }
@@ -4357,7 +4435,7 @@ function createBaseStruct_FieldsEntry() {
4357
4435
  return { key: "", value: undefined };
4358
4436
  }
4359
4437
  const Struct_FieldsEntry = {
4360
- encode(message, writer = minimal.Writer.create()) {
4438
+ encode(message, writer = _m0.Writer.create()) {
4361
4439
  if (message.key !== "") {
4362
4440
  writer.uint32(10).string(message.key);
4363
4441
  }
@@ -4367,7 +4445,7 @@ const Struct_FieldsEntry = {
4367
4445
  return writer;
4368
4446
  },
4369
4447
  decode(input, length) {
4370
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
4448
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
4371
4449
  let end = length === undefined ? reader.len : reader.pos + length;
4372
4450
  const message = createBaseStruct_FieldsEntry();
4373
4451
  while (reader.pos < end) {
@@ -4394,7 +4472,7 @@ const Struct_FieldsEntry = {
4394
4472
  return message;
4395
4473
  },
4396
4474
  fromJSON(object) {
4397
- return { key: isSet$2(object.key) ? String(object.key) : "", value: isSet$2(object === null || object === void 0 ? void 0 : object.value) ? object.value : undefined };
4475
+ return { key: isSet$2(object.key) ? String(object.key) : "", value: isSet$2(object === null || object === undefined ? undefined : object.value) ? object.value : undefined };
4398
4476
  },
4399
4477
  toJSON(message) {
4400
4478
  const obj = {};
@@ -4407,13 +4485,13 @@ const Struct_FieldsEntry = {
4407
4485
  return obj;
4408
4486
  },
4409
4487
  create(base) {
4410
- return Struct_FieldsEntry.fromPartial(base !== null && base !== void 0 ? base : {});
4488
+ return Struct_FieldsEntry.fromPartial(base !== null && base !== undefined ? base : {});
4411
4489
  },
4412
4490
  fromPartial(object) {
4413
4491
  var _a, _b;
4414
4492
  const message = createBaseStruct_FieldsEntry();
4415
- message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
4416
- message.value = (_b = object.value) !== null && _b !== void 0 ? _b : undefined;
4493
+ message.key = (_a = object.key) !== null && _a !== undefined ? _a : "";
4494
+ message.value = (_b = object.value) !== null && _b !== undefined ? _b : undefined;
4417
4495
  return message;
4418
4496
  },
4419
4497
  };
@@ -4428,7 +4506,7 @@ function createBaseValue() {
4428
4506
  };
4429
4507
  }
4430
4508
  const Value = {
4431
- encode(message, writer = minimal.Writer.create()) {
4509
+ encode(message, writer = _m0.Writer.create()) {
4432
4510
  if (message.nullValue !== undefined) {
4433
4511
  writer.uint32(8).int32(message.nullValue);
4434
4512
  }
@@ -4450,7 +4528,7 @@ const Value = {
4450
4528
  return writer;
4451
4529
  },
4452
4530
  decode(input, length) {
4453
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
4531
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
4454
4532
  let end = length === undefined ? reader.len : reader.pos + length;
4455
4533
  const message = createBaseValue();
4456
4534
  while (reader.pos < end) {
@@ -4533,17 +4611,17 @@ const Value = {
4533
4611
  return obj;
4534
4612
  },
4535
4613
  create(base) {
4536
- return Value.fromPartial(base !== null && base !== void 0 ? base : {});
4614
+ return Value.fromPartial(base !== null && base !== undefined ? base : {});
4537
4615
  },
4538
4616
  fromPartial(object) {
4539
4617
  var _a, _b, _c, _d, _e, _f;
4540
4618
  const message = createBaseValue();
4541
- message.nullValue = (_a = object.nullValue) !== null && _a !== void 0 ? _a : undefined;
4542
- message.numberValue = (_b = object.numberValue) !== null && _b !== void 0 ? _b : undefined;
4543
- message.stringValue = (_c = object.stringValue) !== null && _c !== void 0 ? _c : undefined;
4544
- message.boolValue = (_d = object.boolValue) !== null && _d !== void 0 ? _d : undefined;
4545
- message.structValue = (_e = object.structValue) !== null && _e !== void 0 ? _e : undefined;
4546
- message.listValue = (_f = object.listValue) !== null && _f !== void 0 ? _f : undefined;
4619
+ message.nullValue = (_a = object.nullValue) !== null && _a !== undefined ? _a : undefined;
4620
+ message.numberValue = (_b = object.numberValue) !== null && _b !== undefined ? _b : undefined;
4621
+ message.stringValue = (_c = object.stringValue) !== null && _c !== undefined ? _c : undefined;
4622
+ message.boolValue = (_d = object.boolValue) !== null && _d !== undefined ? _d : undefined;
4623
+ message.structValue = (_e = object.structValue) !== null && _e !== undefined ? _e : undefined;
4624
+ message.listValue = (_f = object.listValue) !== null && _f !== undefined ? _f : undefined;
4547
4625
  return message;
4548
4626
  },
4549
4627
  wrap(value) {
@@ -4575,19 +4653,19 @@ const Value = {
4575
4653
  if (message.stringValue !== undefined) {
4576
4654
  return message.stringValue;
4577
4655
  }
4578
- else if ((message === null || message === void 0 ? void 0 : message.numberValue) !== undefined) {
4656
+ else if ((message === null || message === undefined ? undefined : message.numberValue) !== undefined) {
4579
4657
  return message.numberValue;
4580
4658
  }
4581
- else if ((message === null || message === void 0 ? void 0 : message.boolValue) !== undefined) {
4659
+ else if ((message === null || message === undefined ? undefined : message.boolValue) !== undefined) {
4582
4660
  return message.boolValue;
4583
4661
  }
4584
- else if ((message === null || message === void 0 ? void 0 : message.structValue) !== undefined) {
4662
+ else if ((message === null || message === undefined ? undefined : message.structValue) !== undefined) {
4585
4663
  return message.structValue;
4586
4664
  }
4587
- else if ((message === null || message === void 0 ? void 0 : message.listValue) !== undefined) {
4665
+ else if ((message === null || message === undefined ? undefined : message.listValue) !== undefined) {
4588
4666
  return message.listValue;
4589
4667
  }
4590
- else if ((message === null || message === void 0 ? void 0 : message.nullValue) !== undefined) {
4668
+ else if ((message === null || message === undefined ? undefined : message.nullValue) !== undefined) {
4591
4669
  return null;
4592
4670
  }
4593
4671
  return undefined;
@@ -4597,14 +4675,14 @@ function createBaseListValue() {
4597
4675
  return { values: [] };
4598
4676
  }
4599
4677
  const ListValue = {
4600
- encode(message, writer = minimal.Writer.create()) {
4678
+ encode(message, writer = _m0.Writer.create()) {
4601
4679
  for (const v of message.values) {
4602
4680
  Value.encode(Value.wrap(v), writer.uint32(10).fork()).ldelim();
4603
4681
  }
4604
4682
  return writer;
4605
4683
  },
4606
4684
  decode(input, length) {
4607
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
4685
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
4608
4686
  let end = length === undefined ? reader.len : reader.pos + length;
4609
4687
  const message = createBaseListValue();
4610
4688
  while (reader.pos < end) {
@@ -4625,32 +4703,32 @@ const ListValue = {
4625
4703
  return message;
4626
4704
  },
4627
4705
  fromJSON(object) {
4628
- return { values: Array.isArray(object === null || object === void 0 ? void 0 : object.values) ? [...object.values] : [] };
4706
+ return { values: Array.isArray(object === null || object === undefined ? undefined : object.values) ? [...object.values] : [] };
4629
4707
  },
4630
4708
  toJSON(message) {
4631
4709
  var _a;
4632
4710
  const obj = {};
4633
- if ((_a = message.values) === null || _a === void 0 ? void 0 : _a.length) {
4711
+ if ((_a = message.values) === null || _a === undefined ? undefined : _a.length) {
4634
4712
  obj.values = message.values;
4635
4713
  }
4636
4714
  return obj;
4637
4715
  },
4638
4716
  create(base) {
4639
- return ListValue.fromPartial(base !== null && base !== void 0 ? base : {});
4717
+ return ListValue.fromPartial(base !== null && base !== undefined ? base : {});
4640
4718
  },
4641
4719
  fromPartial(object) {
4642
4720
  var _a;
4643
4721
  const message = createBaseListValue();
4644
- message.values = ((_a = object.values) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
4722
+ message.values = ((_a = object.values) === null || _a === undefined ? undefined : _a.map((e) => e)) || [];
4645
4723
  return message;
4646
4724
  },
4647
4725
  wrap(array) {
4648
4726
  const result = createBaseListValue();
4649
- result.values = array !== null && array !== void 0 ? array : [];
4727
+ result.values = array !== null && array !== undefined ? array : [];
4650
4728
  return result;
4651
4729
  },
4652
4730
  unwrap(message) {
4653
- if ((message === null || message === void 0 ? void 0 : message.hasOwnProperty("values")) && Array.isArray(message.values)) {
4731
+ if ((message === null || message === undefined ? undefined : message.hasOwnProperty("values")) && Array.isArray(message.values)) {
4654
4732
  return message.values;
4655
4733
  }
4656
4734
  else {
@@ -4670,14 +4748,14 @@ function createBaseResolveAllRequest() {
4670
4748
  return { context: undefined };
4671
4749
  }
4672
4750
  const ResolveAllRequest = {
4673
- encode(message, writer = minimal.Writer.create()) {
4751
+ encode(message, writer = _m0.Writer.create()) {
4674
4752
  if (message.context !== undefined) {
4675
4753
  Struct.encode(Struct.wrap(message.context), writer.uint32(10).fork()).ldelim();
4676
4754
  }
4677
4755
  return writer;
4678
4756
  },
4679
4757
  decode(input, length) {
4680
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
4758
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
4681
4759
  let end = length === undefined ? reader.len : reader.pos + length;
4682
4760
  const message = createBaseResolveAllRequest();
4683
4761
  while (reader.pos < end) {
@@ -4708,27 +4786,30 @@ const ResolveAllRequest = {
4708
4786
  return obj;
4709
4787
  },
4710
4788
  create(base) {
4711
- return ResolveAllRequest.fromPartial(base !== null && base !== void 0 ? base : {});
4789
+ return ResolveAllRequest.fromPartial(base !== null && base !== undefined ? base : {});
4712
4790
  },
4713
4791
  fromPartial(object) {
4714
4792
  var _a;
4715
4793
  const message = createBaseResolveAllRequest();
4716
- message.context = (_a = object.context) !== null && _a !== void 0 ? _a : undefined;
4794
+ message.context = (_a = object.context) !== null && _a !== undefined ? _a : undefined;
4717
4795
  return message;
4718
4796
  },
4719
4797
  };
4720
4798
  function createBaseResolveAllResponse() {
4721
- return { flags: {} };
4799
+ return { flags: {}, metadata: undefined };
4722
4800
  }
4723
4801
  const ResolveAllResponse = {
4724
- encode(message, writer = minimal.Writer.create()) {
4802
+ encode(message, writer = _m0.Writer.create()) {
4725
4803
  Object.entries(message.flags).forEach(([key, value]) => {
4726
4804
  ResolveAllResponse_FlagsEntry.encode({ key: key, value }, writer.uint32(10).fork()).ldelim();
4727
4805
  });
4806
+ if (message.metadata !== undefined) {
4807
+ Struct.encode(Struct.wrap(message.metadata), writer.uint32(18).fork()).ldelim();
4808
+ }
4728
4809
  return writer;
4729
4810
  },
4730
4811
  decode(input, length) {
4731
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
4812
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
4732
4813
  let end = length === undefined ? reader.len : reader.pos + length;
4733
4814
  const message = createBaseResolveAllResponse();
4734
4815
  while (reader.pos < end) {
@@ -4743,6 +4824,12 @@ const ResolveAllResponse = {
4743
4824
  message.flags[entry1.key] = entry1.value;
4744
4825
  }
4745
4826
  continue;
4827
+ case 2:
4828
+ if (tag !== 18) {
4829
+ break;
4830
+ }
4831
+ message.metadata = Struct.unwrap(Struct.decode(reader, reader.uint32()));
4832
+ continue;
4746
4833
  }
4747
4834
  if ((tag & 7) === 4 || tag === 0) {
4748
4835
  break;
@@ -4759,6 +4846,7 @@ const ResolveAllResponse = {
4759
4846
  return acc;
4760
4847
  }, {})
4761
4848
  : {},
4849
+ metadata: isObject$1(object.metadata) ? object.metadata : undefined,
4762
4850
  };
4763
4851
  },
4764
4852
  toJSON(message) {
@@ -4772,20 +4860,24 @@ const ResolveAllResponse = {
4772
4860
  });
4773
4861
  }
4774
4862
  }
4863
+ if (message.metadata !== undefined) {
4864
+ obj.metadata = message.metadata;
4865
+ }
4775
4866
  return obj;
4776
4867
  },
4777
4868
  create(base) {
4778
- return ResolveAllResponse.fromPartial(base !== null && base !== void 0 ? base : {});
4869
+ return ResolveAllResponse.fromPartial(base !== null && base !== undefined ? base : {});
4779
4870
  },
4780
4871
  fromPartial(object) {
4781
- var _a;
4872
+ var _a, _b;
4782
4873
  const message = createBaseResolveAllResponse();
4783
- message.flags = Object.entries((_a = object.flags) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
4874
+ message.flags = Object.entries((_a = object.flags) !== null && _a !== undefined ? _a : {}).reduce((acc, [key, value]) => {
4784
4875
  if (value !== undefined) {
4785
4876
  acc[key] = AnyFlag.fromPartial(value);
4786
4877
  }
4787
4878
  return acc;
4788
4879
  }, {});
4880
+ message.metadata = (_b = object.metadata) !== null && _b !== undefined ? _b : undefined;
4789
4881
  return message;
4790
4882
  },
4791
4883
  };
@@ -4793,7 +4885,7 @@ function createBaseResolveAllResponse_FlagsEntry() {
4793
4885
  return { key: "", value: undefined };
4794
4886
  }
4795
4887
  const ResolveAllResponse_FlagsEntry = {
4796
- encode(message, writer = minimal.Writer.create()) {
4888
+ encode(message, writer = _m0.Writer.create()) {
4797
4889
  if (message.key !== "") {
4798
4890
  writer.uint32(10).string(message.key);
4799
4891
  }
@@ -4803,7 +4895,7 @@ const ResolveAllResponse_FlagsEntry = {
4803
4895
  return writer;
4804
4896
  },
4805
4897
  decode(input, length) {
4806
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
4898
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
4807
4899
  let end = length === undefined ? reader.len : reader.pos + length;
4808
4900
  const message = createBaseResolveAllResponse_FlagsEntry();
4809
4901
  while (reader.pos < end) {
@@ -4846,12 +4938,12 @@ const ResolveAllResponse_FlagsEntry = {
4846
4938
  return obj;
4847
4939
  },
4848
4940
  create(base) {
4849
- return ResolveAllResponse_FlagsEntry.fromPartial(base !== null && base !== void 0 ? base : {});
4941
+ return ResolveAllResponse_FlagsEntry.fromPartial(base !== null && base !== undefined ? base : {});
4850
4942
  },
4851
4943
  fromPartial(object) {
4852
4944
  var _a;
4853
4945
  const message = createBaseResolveAllResponse_FlagsEntry();
4854
- message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
4946
+ message.key = (_a = object.key) !== null && _a !== undefined ? _a : "";
4855
4947
  message.value = (object.value !== undefined && object.value !== null)
4856
4948
  ? AnyFlag.fromPartial(object.value)
4857
4949
  : undefined;
@@ -4866,10 +4958,11 @@ function createBaseAnyFlag() {
4866
4958
  stringValue: undefined,
4867
4959
  doubleValue: undefined,
4868
4960
  objectValue: undefined,
4961
+ metadata: undefined,
4869
4962
  };
4870
4963
  }
4871
4964
  const AnyFlag = {
4872
- encode(message, writer = minimal.Writer.create()) {
4965
+ encode(message, writer = _m0.Writer.create()) {
4873
4966
  if (message.reason !== "") {
4874
4967
  writer.uint32(10).string(message.reason);
4875
4968
  }
@@ -4888,10 +4981,13 @@ const AnyFlag = {
4888
4981
  if (message.objectValue !== undefined) {
4889
4982
  Struct.encode(Struct.wrap(message.objectValue), writer.uint32(50).fork()).ldelim();
4890
4983
  }
4984
+ if (message.metadata !== undefined) {
4985
+ Struct.encode(Struct.wrap(message.metadata), writer.uint32(58).fork()).ldelim();
4986
+ }
4891
4987
  return writer;
4892
4988
  },
4893
4989
  decode(input, length) {
4894
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
4990
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
4895
4991
  let end = length === undefined ? reader.len : reader.pos + length;
4896
4992
  const message = createBaseAnyFlag();
4897
4993
  while (reader.pos < end) {
@@ -4933,6 +5029,12 @@ const AnyFlag = {
4933
5029
  }
4934
5030
  message.objectValue = Struct.unwrap(Struct.decode(reader, reader.uint32()));
4935
5031
  continue;
5032
+ case 7:
5033
+ if (tag !== 58) {
5034
+ break;
5035
+ }
5036
+ message.metadata = Struct.unwrap(Struct.decode(reader, reader.uint32()));
5037
+ continue;
4936
5038
  }
4937
5039
  if ((tag & 7) === 4 || tag === 0) {
4938
5040
  break;
@@ -4949,6 +5051,7 @@ const AnyFlag = {
4949
5051
  stringValue: isSet$1(object.stringValue) ? String(object.stringValue) : undefined,
4950
5052
  doubleValue: isSet$1(object.doubleValue) ? Number(object.doubleValue) : undefined,
4951
5053
  objectValue: isObject$1(object.objectValue) ? object.objectValue : undefined,
5054
+ metadata: isObject$1(object.metadata) ? object.metadata : undefined,
4952
5055
  };
4953
5056
  },
4954
5057
  toJSON(message) {
@@ -4971,20 +5074,24 @@ const AnyFlag = {
4971
5074
  if (message.objectValue !== undefined) {
4972
5075
  obj.objectValue = message.objectValue;
4973
5076
  }
5077
+ if (message.metadata !== undefined) {
5078
+ obj.metadata = message.metadata;
5079
+ }
4974
5080
  return obj;
4975
5081
  },
4976
5082
  create(base) {
4977
- return AnyFlag.fromPartial(base !== null && base !== void 0 ? base : {});
5083
+ return AnyFlag.fromPartial(base !== null && base !== undefined ? base : {});
4978
5084
  },
4979
5085
  fromPartial(object) {
4980
- var _a, _b, _c, _d, _e, _f;
5086
+ var _a, _b, _c, _d, _e, _f, _g;
4981
5087
  const message = createBaseAnyFlag();
4982
- message.reason = (_a = object.reason) !== null && _a !== void 0 ? _a : "";
4983
- message.variant = (_b = object.variant) !== null && _b !== void 0 ? _b : "";
4984
- message.boolValue = (_c = object.boolValue) !== null && _c !== void 0 ? _c : undefined;
4985
- message.stringValue = (_d = object.stringValue) !== null && _d !== void 0 ? _d : undefined;
4986
- message.doubleValue = (_e = object.doubleValue) !== null && _e !== void 0 ? _e : undefined;
4987
- message.objectValue = (_f = object.objectValue) !== null && _f !== void 0 ? _f : undefined;
5088
+ message.reason = (_a = object.reason) !== null && _a !== undefined ? _a : "";
5089
+ message.variant = (_b = object.variant) !== null && _b !== undefined ? _b : "";
5090
+ message.boolValue = (_c = object.boolValue) !== null && _c !== undefined ? _c : undefined;
5091
+ message.stringValue = (_d = object.stringValue) !== null && _d !== undefined ? _d : undefined;
5092
+ message.doubleValue = (_e = object.doubleValue) !== null && _e !== undefined ? _e : undefined;
5093
+ message.objectValue = (_f = object.objectValue) !== null && _f !== undefined ? _f : undefined;
5094
+ message.metadata = (_g = object.metadata) !== null && _g !== undefined ? _g : undefined;
4988
5095
  return message;
4989
5096
  },
4990
5097
  };
@@ -4992,7 +5099,7 @@ function createBaseResolveBooleanRequest() {
4992
5099
  return { flagKey: "", context: undefined };
4993
5100
  }
4994
5101
  const ResolveBooleanRequest = {
4995
- encode(message, writer = minimal.Writer.create()) {
5102
+ encode(message, writer = _m0.Writer.create()) {
4996
5103
  if (message.flagKey !== "") {
4997
5104
  writer.uint32(10).string(message.flagKey);
4998
5105
  }
@@ -5002,7 +5109,7 @@ const ResolveBooleanRequest = {
5002
5109
  return writer;
5003
5110
  },
5004
5111
  decode(input, length) {
5005
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5112
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5006
5113
  let end = length === undefined ? reader.len : reader.pos + length;
5007
5114
  const message = createBaseResolveBooleanRequest();
5008
5115
  while (reader.pos < end) {
@@ -5045,13 +5152,13 @@ const ResolveBooleanRequest = {
5045
5152
  return obj;
5046
5153
  },
5047
5154
  create(base) {
5048
- return ResolveBooleanRequest.fromPartial(base !== null && base !== void 0 ? base : {});
5155
+ return ResolveBooleanRequest.fromPartial(base !== null && base !== undefined ? base : {});
5049
5156
  },
5050
5157
  fromPartial(object) {
5051
5158
  var _a, _b;
5052
5159
  const message = createBaseResolveBooleanRequest();
5053
- message.flagKey = (_a = object.flagKey) !== null && _a !== void 0 ? _a : "";
5054
- message.context = (_b = object.context) !== null && _b !== void 0 ? _b : undefined;
5160
+ message.flagKey = (_a = object.flagKey) !== null && _a !== undefined ? _a : "";
5161
+ message.context = (_b = object.context) !== null && _b !== undefined ? _b : undefined;
5055
5162
  return message;
5056
5163
  },
5057
5164
  };
@@ -5059,7 +5166,7 @@ function createBaseResolveBooleanResponse() {
5059
5166
  return { value: false, reason: "", variant: "", metadata: undefined };
5060
5167
  }
5061
5168
  const ResolveBooleanResponse = {
5062
- encode(message, writer = minimal.Writer.create()) {
5169
+ encode(message, writer = _m0.Writer.create()) {
5063
5170
  if (message.value === true) {
5064
5171
  writer.uint32(8).bool(message.value);
5065
5172
  }
@@ -5075,7 +5182,7 @@ const ResolveBooleanResponse = {
5075
5182
  return writer;
5076
5183
  },
5077
5184
  decode(input, length) {
5078
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5185
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5079
5186
  let end = length === undefined ? reader.len : reader.pos + length;
5080
5187
  const message = createBaseResolveBooleanResponse();
5081
5188
  while (reader.pos < end) {
@@ -5138,15 +5245,15 @@ const ResolveBooleanResponse = {
5138
5245
  return obj;
5139
5246
  },
5140
5247
  create(base) {
5141
- return ResolveBooleanResponse.fromPartial(base !== null && base !== void 0 ? base : {});
5248
+ return ResolveBooleanResponse.fromPartial(base !== null && base !== undefined ? base : {});
5142
5249
  },
5143
5250
  fromPartial(object) {
5144
5251
  var _a, _b, _c, _d;
5145
5252
  const message = createBaseResolveBooleanResponse();
5146
- message.value = (_a = object.value) !== null && _a !== void 0 ? _a : false;
5147
- message.reason = (_b = object.reason) !== null && _b !== void 0 ? _b : "";
5148
- message.variant = (_c = object.variant) !== null && _c !== void 0 ? _c : "";
5149
- message.metadata = (_d = object.metadata) !== null && _d !== void 0 ? _d : undefined;
5253
+ message.value = (_a = object.value) !== null && _a !== undefined ? _a : false;
5254
+ message.reason = (_b = object.reason) !== null && _b !== undefined ? _b : "";
5255
+ message.variant = (_c = object.variant) !== null && _c !== undefined ? _c : "";
5256
+ message.metadata = (_d = object.metadata) !== null && _d !== undefined ? _d : undefined;
5150
5257
  return message;
5151
5258
  },
5152
5259
  };
@@ -5154,7 +5261,7 @@ function createBaseResolveStringRequest() {
5154
5261
  return { flagKey: "", context: undefined };
5155
5262
  }
5156
5263
  const ResolveStringRequest = {
5157
- encode(message, writer = minimal.Writer.create()) {
5264
+ encode(message, writer = _m0.Writer.create()) {
5158
5265
  if (message.flagKey !== "") {
5159
5266
  writer.uint32(10).string(message.flagKey);
5160
5267
  }
@@ -5164,7 +5271,7 @@ const ResolveStringRequest = {
5164
5271
  return writer;
5165
5272
  },
5166
5273
  decode(input, length) {
5167
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5274
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5168
5275
  let end = length === undefined ? reader.len : reader.pos + length;
5169
5276
  const message = createBaseResolveStringRequest();
5170
5277
  while (reader.pos < end) {
@@ -5207,13 +5314,13 @@ const ResolveStringRequest = {
5207
5314
  return obj;
5208
5315
  },
5209
5316
  create(base) {
5210
- return ResolveStringRequest.fromPartial(base !== null && base !== void 0 ? base : {});
5317
+ return ResolveStringRequest.fromPartial(base !== null && base !== undefined ? base : {});
5211
5318
  },
5212
5319
  fromPartial(object) {
5213
5320
  var _a, _b;
5214
5321
  const message = createBaseResolveStringRequest();
5215
- message.flagKey = (_a = object.flagKey) !== null && _a !== void 0 ? _a : "";
5216
- message.context = (_b = object.context) !== null && _b !== void 0 ? _b : undefined;
5322
+ message.flagKey = (_a = object.flagKey) !== null && _a !== undefined ? _a : "";
5323
+ message.context = (_b = object.context) !== null && _b !== undefined ? _b : undefined;
5217
5324
  return message;
5218
5325
  },
5219
5326
  };
@@ -5221,7 +5328,7 @@ function createBaseResolveStringResponse() {
5221
5328
  return { value: "", reason: "", variant: "", metadata: undefined };
5222
5329
  }
5223
5330
  const ResolveStringResponse = {
5224
- encode(message, writer = minimal.Writer.create()) {
5331
+ encode(message, writer = _m0.Writer.create()) {
5225
5332
  if (message.value !== "") {
5226
5333
  writer.uint32(10).string(message.value);
5227
5334
  }
@@ -5237,7 +5344,7 @@ const ResolveStringResponse = {
5237
5344
  return writer;
5238
5345
  },
5239
5346
  decode(input, length) {
5240
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5347
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5241
5348
  let end = length === undefined ? reader.len : reader.pos + length;
5242
5349
  const message = createBaseResolveStringResponse();
5243
5350
  while (reader.pos < end) {
@@ -5300,15 +5407,15 @@ const ResolveStringResponse = {
5300
5407
  return obj;
5301
5408
  },
5302
5409
  create(base) {
5303
- return ResolveStringResponse.fromPartial(base !== null && base !== void 0 ? base : {});
5410
+ return ResolveStringResponse.fromPartial(base !== null && base !== undefined ? base : {});
5304
5411
  },
5305
5412
  fromPartial(object) {
5306
5413
  var _a, _b, _c, _d;
5307
5414
  const message = createBaseResolveStringResponse();
5308
- message.value = (_a = object.value) !== null && _a !== void 0 ? _a : "";
5309
- message.reason = (_b = object.reason) !== null && _b !== void 0 ? _b : "";
5310
- message.variant = (_c = object.variant) !== null && _c !== void 0 ? _c : "";
5311
- message.metadata = (_d = object.metadata) !== null && _d !== void 0 ? _d : undefined;
5415
+ message.value = (_a = object.value) !== null && _a !== undefined ? _a : "";
5416
+ message.reason = (_b = object.reason) !== null && _b !== undefined ? _b : "";
5417
+ message.variant = (_c = object.variant) !== null && _c !== undefined ? _c : "";
5418
+ message.metadata = (_d = object.metadata) !== null && _d !== undefined ? _d : undefined;
5312
5419
  return message;
5313
5420
  },
5314
5421
  };
@@ -5316,7 +5423,7 @@ function createBaseResolveFloatRequest() {
5316
5423
  return { flagKey: "", context: undefined };
5317
5424
  }
5318
5425
  const ResolveFloatRequest = {
5319
- encode(message, writer = minimal.Writer.create()) {
5426
+ encode(message, writer = _m0.Writer.create()) {
5320
5427
  if (message.flagKey !== "") {
5321
5428
  writer.uint32(10).string(message.flagKey);
5322
5429
  }
@@ -5326,7 +5433,7 @@ const ResolveFloatRequest = {
5326
5433
  return writer;
5327
5434
  },
5328
5435
  decode(input, length) {
5329
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5436
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5330
5437
  let end = length === undefined ? reader.len : reader.pos + length;
5331
5438
  const message = createBaseResolveFloatRequest();
5332
5439
  while (reader.pos < end) {
@@ -5369,13 +5476,13 @@ const ResolveFloatRequest = {
5369
5476
  return obj;
5370
5477
  },
5371
5478
  create(base) {
5372
- return ResolveFloatRequest.fromPartial(base !== null && base !== void 0 ? base : {});
5479
+ return ResolveFloatRequest.fromPartial(base !== null && base !== undefined ? base : {});
5373
5480
  },
5374
5481
  fromPartial(object) {
5375
5482
  var _a, _b;
5376
5483
  const message = createBaseResolveFloatRequest();
5377
- message.flagKey = (_a = object.flagKey) !== null && _a !== void 0 ? _a : "";
5378
- message.context = (_b = object.context) !== null && _b !== void 0 ? _b : undefined;
5484
+ message.flagKey = (_a = object.flagKey) !== null && _a !== undefined ? _a : "";
5485
+ message.context = (_b = object.context) !== null && _b !== undefined ? _b : undefined;
5379
5486
  return message;
5380
5487
  },
5381
5488
  };
@@ -5383,7 +5490,7 @@ function createBaseResolveFloatResponse() {
5383
5490
  return { value: 0, reason: "", variant: "", metadata: undefined };
5384
5491
  }
5385
5492
  const ResolveFloatResponse = {
5386
- encode(message, writer = minimal.Writer.create()) {
5493
+ encode(message, writer = _m0.Writer.create()) {
5387
5494
  if (message.value !== 0) {
5388
5495
  writer.uint32(9).double(message.value);
5389
5496
  }
@@ -5399,7 +5506,7 @@ const ResolveFloatResponse = {
5399
5506
  return writer;
5400
5507
  },
5401
5508
  decode(input, length) {
5402
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5509
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5403
5510
  let end = length === undefined ? reader.len : reader.pos + length;
5404
5511
  const message = createBaseResolveFloatResponse();
5405
5512
  while (reader.pos < end) {
@@ -5462,15 +5569,15 @@ const ResolveFloatResponse = {
5462
5569
  return obj;
5463
5570
  },
5464
5571
  create(base) {
5465
- return ResolveFloatResponse.fromPartial(base !== null && base !== void 0 ? base : {});
5572
+ return ResolveFloatResponse.fromPartial(base !== null && base !== undefined ? base : {});
5466
5573
  },
5467
5574
  fromPartial(object) {
5468
5575
  var _a, _b, _c, _d;
5469
5576
  const message = createBaseResolveFloatResponse();
5470
- message.value = (_a = object.value) !== null && _a !== void 0 ? _a : 0;
5471
- message.reason = (_b = object.reason) !== null && _b !== void 0 ? _b : "";
5472
- message.variant = (_c = object.variant) !== null && _c !== void 0 ? _c : "";
5473
- message.metadata = (_d = object.metadata) !== null && _d !== void 0 ? _d : undefined;
5577
+ message.value = (_a = object.value) !== null && _a !== undefined ? _a : 0;
5578
+ message.reason = (_b = object.reason) !== null && _b !== undefined ? _b : "";
5579
+ message.variant = (_c = object.variant) !== null && _c !== undefined ? _c : "";
5580
+ message.metadata = (_d = object.metadata) !== null && _d !== undefined ? _d : undefined;
5474
5581
  return message;
5475
5582
  },
5476
5583
  };
@@ -5478,7 +5585,7 @@ function createBaseResolveIntRequest() {
5478
5585
  return { flagKey: "", context: undefined };
5479
5586
  }
5480
5587
  const ResolveIntRequest = {
5481
- encode(message, writer = minimal.Writer.create()) {
5588
+ encode(message, writer = _m0.Writer.create()) {
5482
5589
  if (message.flagKey !== "") {
5483
5590
  writer.uint32(10).string(message.flagKey);
5484
5591
  }
@@ -5488,7 +5595,7 @@ const ResolveIntRequest = {
5488
5595
  return writer;
5489
5596
  },
5490
5597
  decode(input, length) {
5491
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5598
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5492
5599
  let end = length === undefined ? reader.len : reader.pos + length;
5493
5600
  const message = createBaseResolveIntRequest();
5494
5601
  while (reader.pos < end) {
@@ -5531,13 +5638,13 @@ const ResolveIntRequest = {
5531
5638
  return obj;
5532
5639
  },
5533
5640
  create(base) {
5534
- return ResolveIntRequest.fromPartial(base !== null && base !== void 0 ? base : {});
5641
+ return ResolveIntRequest.fromPartial(base !== null && base !== undefined ? base : {});
5535
5642
  },
5536
5643
  fromPartial(object) {
5537
5644
  var _a, _b;
5538
5645
  const message = createBaseResolveIntRequest();
5539
- message.flagKey = (_a = object.flagKey) !== null && _a !== void 0 ? _a : "";
5540
- message.context = (_b = object.context) !== null && _b !== void 0 ? _b : undefined;
5646
+ message.flagKey = (_a = object.flagKey) !== null && _a !== undefined ? _a : "";
5647
+ message.context = (_b = object.context) !== null && _b !== undefined ? _b : undefined;
5541
5648
  return message;
5542
5649
  },
5543
5650
  };
@@ -5545,7 +5652,7 @@ function createBaseResolveIntResponse() {
5545
5652
  return { value: "0", reason: "", variant: "", metadata: undefined };
5546
5653
  }
5547
5654
  const ResolveIntResponse = {
5548
- encode(message, writer = minimal.Writer.create()) {
5655
+ encode(message, writer = _m0.Writer.create()) {
5549
5656
  if (message.value !== "0") {
5550
5657
  writer.uint32(8).int64(message.value);
5551
5658
  }
@@ -5561,7 +5668,7 @@ const ResolveIntResponse = {
5561
5668
  return writer;
5562
5669
  },
5563
5670
  decode(input, length) {
5564
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5671
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5565
5672
  let end = length === undefined ? reader.len : reader.pos + length;
5566
5673
  const message = createBaseResolveIntResponse();
5567
5674
  while (reader.pos < end) {
@@ -5624,15 +5731,15 @@ const ResolveIntResponse = {
5624
5731
  return obj;
5625
5732
  },
5626
5733
  create(base) {
5627
- return ResolveIntResponse.fromPartial(base !== null && base !== void 0 ? base : {});
5734
+ return ResolveIntResponse.fromPartial(base !== null && base !== undefined ? base : {});
5628
5735
  },
5629
5736
  fromPartial(object) {
5630
5737
  var _a, _b, _c, _d;
5631
5738
  const message = createBaseResolveIntResponse();
5632
- message.value = (_a = object.value) !== null && _a !== void 0 ? _a : "0";
5633
- message.reason = (_b = object.reason) !== null && _b !== void 0 ? _b : "";
5634
- message.variant = (_c = object.variant) !== null && _c !== void 0 ? _c : "";
5635
- message.metadata = (_d = object.metadata) !== null && _d !== void 0 ? _d : undefined;
5739
+ message.value = (_a = object.value) !== null && _a !== undefined ? _a : "0";
5740
+ message.reason = (_b = object.reason) !== null && _b !== undefined ? _b : "";
5741
+ message.variant = (_c = object.variant) !== null && _c !== undefined ? _c : "";
5742
+ message.metadata = (_d = object.metadata) !== null && _d !== undefined ? _d : undefined;
5636
5743
  return message;
5637
5744
  },
5638
5745
  };
@@ -5640,7 +5747,7 @@ function createBaseResolveObjectRequest() {
5640
5747
  return { flagKey: "", context: undefined };
5641
5748
  }
5642
5749
  const ResolveObjectRequest = {
5643
- encode(message, writer = minimal.Writer.create()) {
5750
+ encode(message, writer = _m0.Writer.create()) {
5644
5751
  if (message.flagKey !== "") {
5645
5752
  writer.uint32(10).string(message.flagKey);
5646
5753
  }
@@ -5650,7 +5757,7 @@ const ResolveObjectRequest = {
5650
5757
  return writer;
5651
5758
  },
5652
5759
  decode(input, length) {
5653
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5760
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5654
5761
  let end = length === undefined ? reader.len : reader.pos + length;
5655
5762
  const message = createBaseResolveObjectRequest();
5656
5763
  while (reader.pos < end) {
@@ -5693,13 +5800,13 @@ const ResolveObjectRequest = {
5693
5800
  return obj;
5694
5801
  },
5695
5802
  create(base) {
5696
- return ResolveObjectRequest.fromPartial(base !== null && base !== void 0 ? base : {});
5803
+ return ResolveObjectRequest.fromPartial(base !== null && base !== undefined ? base : {});
5697
5804
  },
5698
5805
  fromPartial(object) {
5699
5806
  var _a, _b;
5700
5807
  const message = createBaseResolveObjectRequest();
5701
- message.flagKey = (_a = object.flagKey) !== null && _a !== void 0 ? _a : "";
5702
- message.context = (_b = object.context) !== null && _b !== void 0 ? _b : undefined;
5808
+ message.flagKey = (_a = object.flagKey) !== null && _a !== undefined ? _a : "";
5809
+ message.context = (_b = object.context) !== null && _b !== undefined ? _b : undefined;
5703
5810
  return message;
5704
5811
  },
5705
5812
  };
@@ -5707,7 +5814,7 @@ function createBaseResolveObjectResponse() {
5707
5814
  return { value: undefined, reason: "", variant: "", metadata: undefined };
5708
5815
  }
5709
5816
  const ResolveObjectResponse = {
5710
- encode(message, writer = minimal.Writer.create()) {
5817
+ encode(message, writer = _m0.Writer.create()) {
5711
5818
  if (message.value !== undefined) {
5712
5819
  Struct.encode(Struct.wrap(message.value), writer.uint32(10).fork()).ldelim();
5713
5820
  }
@@ -5723,7 +5830,7 @@ const ResolveObjectResponse = {
5723
5830
  return writer;
5724
5831
  },
5725
5832
  decode(input, length) {
5726
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5833
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5727
5834
  let end = length === undefined ? reader.len : reader.pos + length;
5728
5835
  const message = createBaseResolveObjectResponse();
5729
5836
  while (reader.pos < end) {
@@ -5786,15 +5893,15 @@ const ResolveObjectResponse = {
5786
5893
  return obj;
5787
5894
  },
5788
5895
  create(base) {
5789
- return ResolveObjectResponse.fromPartial(base !== null && base !== void 0 ? base : {});
5896
+ return ResolveObjectResponse.fromPartial(base !== null && base !== undefined ? base : {});
5790
5897
  },
5791
5898
  fromPartial(object) {
5792
5899
  var _a, _b, _c, _d;
5793
5900
  const message = createBaseResolveObjectResponse();
5794
- message.value = (_a = object.value) !== null && _a !== void 0 ? _a : undefined;
5795
- message.reason = (_b = object.reason) !== null && _b !== void 0 ? _b : "";
5796
- message.variant = (_c = object.variant) !== null && _c !== void 0 ? _c : "";
5797
- message.metadata = (_d = object.metadata) !== null && _d !== void 0 ? _d : undefined;
5901
+ message.value = (_a = object.value) !== null && _a !== undefined ? _a : undefined;
5902
+ message.reason = (_b = object.reason) !== null && _b !== undefined ? _b : "";
5903
+ message.variant = (_c = object.variant) !== null && _c !== undefined ? _c : "";
5904
+ message.metadata = (_d = object.metadata) !== null && _d !== undefined ? _d : undefined;
5798
5905
  return message;
5799
5906
  },
5800
5907
  };
@@ -5802,7 +5909,7 @@ function createBaseEventStreamResponse() {
5802
5909
  return { type: "", data: undefined };
5803
5910
  }
5804
5911
  const EventStreamResponse = {
5805
- encode(message, writer = minimal.Writer.create()) {
5912
+ encode(message, writer = _m0.Writer.create()) {
5806
5913
  if (message.type !== "") {
5807
5914
  writer.uint32(10).string(message.type);
5808
5915
  }
@@ -5812,7 +5919,7 @@ const EventStreamResponse = {
5812
5919
  return writer;
5813
5920
  },
5814
5921
  decode(input, length) {
5815
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5922
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5816
5923
  let end = length === undefined ? reader.len : reader.pos + length;
5817
5924
  const message = createBaseEventStreamResponse();
5818
5925
  while (reader.pos < end) {
@@ -5855,13 +5962,13 @@ const EventStreamResponse = {
5855
5962
  return obj;
5856
5963
  },
5857
5964
  create(base) {
5858
- return EventStreamResponse.fromPartial(base !== null && base !== void 0 ? base : {});
5965
+ return EventStreamResponse.fromPartial(base !== null && base !== undefined ? base : {});
5859
5966
  },
5860
5967
  fromPartial(object) {
5861
5968
  var _a, _b;
5862
5969
  const message = createBaseEventStreamResponse();
5863
- message.type = (_a = object.type) !== null && _a !== void 0 ? _a : "";
5864
- message.data = (_b = object.data) !== null && _b !== void 0 ? _b : undefined;
5970
+ message.type = (_a = object.type) !== null && _a !== undefined ? _a : "";
5971
+ message.data = (_b = object.data) !== null && _b !== undefined ? _b : undefined;
5865
5972
  return message;
5866
5973
  },
5867
5974
  };
@@ -5869,11 +5976,11 @@ function createBaseEventStreamRequest() {
5869
5976
  return {};
5870
5977
  }
5871
5978
  const EventStreamRequest = {
5872
- encode(_, writer = minimal.Writer.create()) {
5979
+ encode(_, writer = _m0.Writer.create()) {
5873
5980
  return writer;
5874
5981
  },
5875
5982
  decode(input, length) {
5876
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
5983
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
5877
5984
  let end = length === undefined ? reader.len : reader.pos + length;
5878
5985
  const message = createBaseEventStreamRequest();
5879
5986
  while (reader.pos < end) {
@@ -5893,7 +6000,7 @@ const EventStreamRequest = {
5893
6000
  return obj;
5894
6001
  },
5895
6002
  create(base) {
5896
- return EventStreamRequest.fromPartial(base !== null && base !== void 0 ? base : {});
6003
+ return EventStreamRequest.fromPartial(base !== null && base !== undefined ? base : {});
5897
6004
  },
5898
6005
  fromPartial(_) {
5899
6006
  const message = createBaseEventStreamRequest();
@@ -5969,9 +6076,9 @@ const ServiceClient = grpcJs.makeGenericClientConstructor(ServiceService, "flagd
5969
6076
  function longToString(long) {
5970
6077
  return long.toString();
5971
6078
  }
5972
- if (minimal.util.Long !== Long) {
5973
- minimal.util.Long = Long;
5974
- minimal.configure();
6079
+ if (_m0.util.Long !== Long) {
6080
+ _m0.util.Long = Long;
6081
+ _m0.configure();
5975
6082
  }
5976
6083
  function isObject$1(value) {
5977
6084
  return typeof value === "object" && value !== null;
@@ -6006,7 +6113,7 @@ class GRPCService {
6006
6113
  this._eventStream = undefined;
6007
6114
  this.onRejected = (err) => {
6008
6115
  // map the errors
6009
- switch (err === null || err === void 0 ? void 0 : err.code) {
6116
+ switch (err === null || err === undefined ? undefined : err.code) {
6010
6117
  case grpcJs.status.DATA_LOSS:
6011
6118
  throw new serverSdk.ParseError(err.details);
6012
6119
  case grpcJs.status.INVALID_ARGUMENT:
@@ -6016,13 +6123,19 @@ class GRPCService {
6016
6123
  case grpcJs.status.UNAVAILABLE:
6017
6124
  throw new serverSdk.FlagNotFoundError(err.details);
6018
6125
  default:
6019
- throw new serverSdk.GeneralError(err === null || err === void 0 ? void 0 : err.details);
6126
+ throw new serverSdk.GeneralError(err === null || err === undefined ? undefined : err.details);
6020
6127
  }
6021
6128
  };
6022
- const { host, port, tls, socketPath } = config;
6129
+ const { host, port, tls, socketPath, defaultAuthority } = config;
6130
+ let clientOptions;
6131
+ if (defaultAuthority) {
6132
+ clientOptions = {
6133
+ 'grpc.default_authority': defaultAuthority,
6134
+ };
6135
+ }
6023
6136
  this._client = client
6024
6137
  ? client
6025
- : new ServiceClient(socketPath ? `unix://${socketPath}` : `${host}:${port}`, tls ? grpcJs.credentials.createSsl() : grpcJs.credentials.createInsecure());
6138
+ : new ServiceClient(socketPath ? `unix://${socketPath}` : `${host}:${port}`, tls ? grpcJs.credentials.createSsl() : grpcJs.credentials.createInsecure(), clientOptions);
6026
6139
  if (config.cache === 'lru') {
6027
6140
  this._cacheEnabled = true;
6028
6141
  this._cache = new lruCache.LRUCache({ maxSize: config.maxCacheSize || DEFAULT_MAX_CACHE_SIZE, sizeCalculation: () => 1 });
@@ -6032,45 +6145,45 @@ class GRPCService {
6032
6145
  return new Promise((resolve, reject) => this.listen(reconnectCallback, changedCallback, disconnectCallback, resolve, reject));
6033
6146
  }
6034
6147
  disconnect() {
6035
- return __awaiter(this, void 0, void 0, function* () {
6148
+ return __awaiter(this, undefined, undefined, function* () {
6036
6149
  closeStreamIfDefined(this._eventStream);
6037
6150
  this._client.close();
6038
6151
  });
6039
6152
  }
6040
6153
  resolveBoolean(flagKey, _, context, logger) {
6041
- return __awaiter(this, void 0, void 0, function* () {
6154
+ return __awaiter(this, undefined, undefined, function* () {
6042
6155
  return this.resolve(this._client.resolveBoolean, flagKey, context, logger);
6043
6156
  });
6044
6157
  }
6045
6158
  resolveString(flagKey, _, context, logger) {
6046
- return __awaiter(this, void 0, void 0, function* () {
6159
+ return __awaiter(this, undefined, undefined, function* () {
6047
6160
  return this.resolve(this._client.resolveString, flagKey, context, logger);
6048
6161
  });
6049
6162
  }
6050
6163
  resolveNumber(flagKey, _, context, logger) {
6051
- return __awaiter(this, void 0, void 0, function* () {
6164
+ return __awaiter(this, undefined, undefined, function* () {
6052
6165
  return this.resolve(this._client.resolveFloat, flagKey, context, logger);
6053
6166
  });
6054
6167
  }
6055
6168
  resolveObject(flagKey, _, context, logger) {
6056
- return __awaiter(this, void 0, void 0, function* () {
6169
+ return __awaiter(this, undefined, undefined, function* () {
6057
6170
  return this.resolve(this._client.resolveObject, flagKey, context, logger);
6058
6171
  });
6059
6172
  }
6060
6173
  listen(reconnectCallback, changedCallback, disconnectCallback, resolveConnect, rejectConnect) {
6061
6174
  var _a;
6062
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`${FlagdProvider.name}: connecting stream...`);
6175
+ (_a = this.logger) === null || _a === undefined ? undefined : _a.debug(`${FlagdProvider.name}: connecting stream...`);
6063
6176
  // close the previous stream if we're reconnecting
6064
6177
  closeStreamIfDefined(this._eventStream);
6065
6178
  const stream = this._client.eventStream({}, {});
6066
6179
  stream.on('error', (err) => {
6067
- rejectConnect === null || rejectConnect === void 0 ? void 0 : rejectConnect(err);
6180
+ rejectConnect === null || rejectConnect === undefined ? undefined : rejectConnect(err);
6068
6181
  this.handleError(reconnectCallback, changedCallback, disconnectCallback);
6069
6182
  });
6070
6183
  stream.on('data', (message) => {
6071
6184
  var _a;
6072
6185
  if (message.type === EVENT_PROVIDER_READY) {
6073
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`${FlagdProvider.name}: streaming connection established with flagd`);
6186
+ (_a = this.logger) === null || _a === undefined ? undefined : _a.debug(`${FlagdProvider.name}: streaming connection established with flagd`);
6074
6187
  // if resolveConnect is undefined, this is a reconnection; we only want to fire the reconnect callback in that case
6075
6188
  if (resolveConnect) {
6076
6189
  resolveConnect();
@@ -6089,16 +6202,16 @@ class GRPCService {
6089
6202
  var _a;
6090
6203
  if (message.data) {
6091
6204
  const data = message.data;
6092
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`${FlagdProvider.name}: got message: ${JSON.stringify(data, undefined, 2)}`);
6093
- if (data && typeof data === 'object' && 'flags' in data && (data === null || data === void 0 ? void 0 : data['flags'])) {
6205
+ (_a = this.logger) === null || _a === undefined ? undefined : _a.debug(`${FlagdProvider.name}: got message: ${JSON.stringify(data, undefined, 2)}`);
6206
+ if (data && typeof data === 'object' && 'flags' in data && (data === null || data === undefined ? undefined : data['flags'])) {
6094
6207
  const flagChangeMessage = data;
6095
6208
  const flagsChanged = Object.keys(flagChangeMessage.flags || []);
6096
6209
  if (this._cacheEnabled) {
6097
6210
  // remove each changed key from cache
6098
6211
  flagsChanged.forEach((key) => {
6099
6212
  var _a, _b;
6100
- if ((_a = this._cache) === null || _a === void 0 ? void 0 : _a.delete(key)) {
6101
- (_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(`${FlagdProvider.name}: evicted key: ${key} from cache.`);
6213
+ if ((_a = this._cache) === null || _a === undefined ? undefined : _a.delete(key)) {
6214
+ (_b = this.logger) === null || _b === undefined ? undefined : _b.debug(`${FlagdProvider.name}: evicted key: ${key} from cache.`);
6102
6215
  }
6103
6216
  });
6104
6217
  }
@@ -6115,16 +6228,16 @@ class GRPCService {
6115
6228
  handleError(reconnectCallback, changedCallback, disconnectCallback) {
6116
6229
  var _a, _b;
6117
6230
  disconnectCallback('streaming connection error, will attempt reconnect...');
6118
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(`${FlagdProvider.name}: streaming connection error, will attempt reconnect...`);
6119
- (_b = this._cache) === null || _b === void 0 ? void 0 : _b.clear();
6231
+ (_a = this.logger) === null || _a === undefined ? undefined : _a.error(`${FlagdProvider.name}: streaming connection error, will attempt reconnect...`);
6232
+ (_b = this._cache) === null || _b === undefined ? undefined : _b.clear();
6120
6233
  this.reconnect(reconnectCallback, changedCallback, disconnectCallback);
6121
6234
  }
6122
6235
  resolve(promise, flagKey, context, logger) {
6123
- return __awaiter(this, void 0, void 0, function* () {
6236
+ return __awaiter(this, undefined, undefined, function* () {
6124
6237
  var _a, _b;
6125
- const resolver = util$6.promisify(promise);
6238
+ const resolver = node_util.promisify(promise);
6126
6239
  if (this._cacheActive) {
6127
- const cached = (_a = this._cache) === null || _a === void 0 ? void 0 : _a.get(flagKey);
6240
+ const cached = (_a = this._cache) === null || _a === undefined ? undefined : _a.get(flagKey);
6128
6241
  if (cached) {
6129
6242
  return Object.assign(Object.assign({}, cached), { reason: serverSdk.StandardResolutionReasons.CACHED });
6130
6243
  }
@@ -6142,19 +6255,73 @@ class GRPCService {
6142
6255
  logger.debug(`${FlagdProvider.name}: resolved flag with key: ${resolved.value}, variant: ${response.variant}, reason: ${response.reason}`);
6143
6256
  if (this._cacheActive && response.reason === serverSdk.StandardResolutionReasons.STATIC) {
6144
6257
  // cache this static value
6145
- (_b = this._cache) === null || _b === void 0 ? void 0 : _b.set(flagKey, resolved);
6258
+ (_b = this._cache) === null || _b === undefined ? undefined : _b.set(flagKey, resolved);
6146
6259
  }
6147
6260
  return resolved;
6148
6261
  });
6149
6262
  }
6150
6263
  }
6151
6264
 
6265
+ const encoding = 'utf8';
6266
+ class FileFetch {
6267
+ constructor(filename, logger) {
6268
+ this._filename = filename;
6269
+ this._logger = logger;
6270
+ }
6271
+ connect(dataFillCallback, _, changedCallback) {
6272
+ return __awaiter(this, undefined, undefined, function* () {
6273
+ var _a, _b;
6274
+ (_a = this._logger) === null || _a === undefined ? undefined : _a.debug('Starting file sync connection');
6275
+ try {
6276
+ const output = yield fs.promises.readFile(this._filename, encoding);
6277
+ // Don't emit the change event for the initial read
6278
+ dataFillCallback(output);
6279
+ // Using watchFile instead of watch to support virtualized host file systems.
6280
+ fs.watchFile(this._filename, () => __awaiter(this, void 0, void 0, function* () {
6281
+ var _a;
6282
+ try {
6283
+ const data = yield fs.promises.readFile(this._filename, encoding);
6284
+ const changes = dataFillCallback(data);
6285
+ if (changes.length > 0) {
6286
+ changedCallback(changes);
6287
+ }
6288
+ }
6289
+ catch (err) {
6290
+ (_a = this._logger) === null || _a === void 0 ? void 0 : _a.error(`Error reading file: ${err}`);
6291
+ }
6292
+ }));
6293
+ }
6294
+ catch (err) {
6295
+ if (err instanceof serverSdk.OpenFeatureError) {
6296
+ throw err;
6297
+ }
6298
+ else {
6299
+ switch (err === null || err === undefined ? undefined : err.code) {
6300
+ case 'ENOENT':
6301
+ throw new serverSdk.GeneralError(`File not found: ${this._filename}`);
6302
+ case 'EACCES':
6303
+ throw new serverSdk.GeneralError(`File not accessible: ${this._filename}`);
6304
+ default:
6305
+ (_b = this._logger) === null || _b === undefined ? undefined : _b.debug(`Error reading file: ${err}`);
6306
+ throw new serverSdk.GeneralError();
6307
+ }
6308
+ }
6309
+ }
6310
+ });
6311
+ }
6312
+ disconnect() {
6313
+ return __awaiter(this, undefined, undefined, function* () {
6314
+ fs.unwatchFile(this._filename);
6315
+ });
6316
+ }
6317
+ }
6318
+
6152
6319
  /* eslint-disable */
6153
6320
  function createBaseSyncFlagsRequest() {
6154
6321
  return { providerId: "", selector: "" };
6155
6322
  }
6156
6323
  const SyncFlagsRequest = {
6157
- encode(message, writer = minimal.Writer.create()) {
6324
+ encode(message, writer = _m0.Writer.create()) {
6158
6325
  if (message.providerId !== "") {
6159
6326
  writer.uint32(10).string(message.providerId);
6160
6327
  }
@@ -6164,7 +6331,7 @@ const SyncFlagsRequest = {
6164
6331
  return writer;
6165
6332
  },
6166
6333
  decode(input, length) {
6167
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
6334
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
6168
6335
  let end = length === undefined ? reader.len : reader.pos + length;
6169
6336
  const message = createBaseSyncFlagsRequest();
6170
6337
  while (reader.pos < end) {
@@ -6207,13 +6374,13 @@ const SyncFlagsRequest = {
6207
6374
  return obj;
6208
6375
  },
6209
6376
  create(base) {
6210
- return SyncFlagsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
6377
+ return SyncFlagsRequest.fromPartial(base !== null && base !== undefined ? base : {});
6211
6378
  },
6212
6379
  fromPartial(object) {
6213
6380
  var _a, _b;
6214
6381
  const message = createBaseSyncFlagsRequest();
6215
- message.providerId = (_a = object.providerId) !== null && _a !== void 0 ? _a : "";
6216
- message.selector = (_b = object.selector) !== null && _b !== void 0 ? _b : "";
6382
+ message.providerId = (_a = object.providerId) !== null && _a !== undefined ? _a : "";
6383
+ message.selector = (_b = object.selector) !== null && _b !== undefined ? _b : "";
6217
6384
  return message;
6218
6385
  },
6219
6386
  };
@@ -6221,14 +6388,14 @@ function createBaseSyncFlagsResponse() {
6221
6388
  return { flagConfiguration: "" };
6222
6389
  }
6223
6390
  const SyncFlagsResponse = {
6224
- encode(message, writer = minimal.Writer.create()) {
6391
+ encode(message, writer = _m0.Writer.create()) {
6225
6392
  if (message.flagConfiguration !== "") {
6226
6393
  writer.uint32(10).string(message.flagConfiguration);
6227
6394
  }
6228
6395
  return writer;
6229
6396
  },
6230
6397
  decode(input, length) {
6231
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
6398
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
6232
6399
  let end = length === undefined ? reader.len : reader.pos + length;
6233
6400
  const message = createBaseSyncFlagsResponse();
6234
6401
  while (reader.pos < end) {
@@ -6259,12 +6426,12 @@ const SyncFlagsResponse = {
6259
6426
  return obj;
6260
6427
  },
6261
6428
  create(base) {
6262
- return SyncFlagsResponse.fromPartial(base !== null && base !== void 0 ? base : {});
6429
+ return SyncFlagsResponse.fromPartial(base !== null && base !== undefined ? base : {});
6263
6430
  },
6264
6431
  fromPartial(object) {
6265
6432
  var _a;
6266
6433
  const message = createBaseSyncFlagsResponse();
6267
- message.flagConfiguration = (_a = object.flagConfiguration) !== null && _a !== void 0 ? _a : "";
6434
+ message.flagConfiguration = (_a = object.flagConfiguration) !== null && _a !== undefined ? _a : "";
6268
6435
  return message;
6269
6436
  },
6270
6437
  };
@@ -6272,7 +6439,7 @@ function createBaseFetchAllFlagsRequest() {
6272
6439
  return { providerId: "", selector: "" };
6273
6440
  }
6274
6441
  const FetchAllFlagsRequest = {
6275
- encode(message, writer = minimal.Writer.create()) {
6442
+ encode(message, writer = _m0.Writer.create()) {
6276
6443
  if (message.providerId !== "") {
6277
6444
  writer.uint32(10).string(message.providerId);
6278
6445
  }
@@ -6282,7 +6449,7 @@ const FetchAllFlagsRequest = {
6282
6449
  return writer;
6283
6450
  },
6284
6451
  decode(input, length) {
6285
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
6452
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
6286
6453
  let end = length === undefined ? reader.len : reader.pos + length;
6287
6454
  const message = createBaseFetchAllFlagsRequest();
6288
6455
  while (reader.pos < end) {
@@ -6325,13 +6492,13 @@ const FetchAllFlagsRequest = {
6325
6492
  return obj;
6326
6493
  },
6327
6494
  create(base) {
6328
- return FetchAllFlagsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
6495
+ return FetchAllFlagsRequest.fromPartial(base !== null && base !== undefined ? base : {});
6329
6496
  },
6330
6497
  fromPartial(object) {
6331
6498
  var _a, _b;
6332
6499
  const message = createBaseFetchAllFlagsRequest();
6333
- message.providerId = (_a = object.providerId) !== null && _a !== void 0 ? _a : "";
6334
- message.selector = (_b = object.selector) !== null && _b !== void 0 ? _b : "";
6500
+ message.providerId = (_a = object.providerId) !== null && _a !== undefined ? _a : "";
6501
+ message.selector = (_b = object.selector) !== null && _b !== undefined ? _b : "";
6335
6502
  return message;
6336
6503
  },
6337
6504
  };
@@ -6339,14 +6506,14 @@ function createBaseFetchAllFlagsResponse() {
6339
6506
  return { flagConfiguration: "" };
6340
6507
  }
6341
6508
  const FetchAllFlagsResponse = {
6342
- encode(message, writer = minimal.Writer.create()) {
6509
+ encode(message, writer = _m0.Writer.create()) {
6343
6510
  if (message.flagConfiguration !== "") {
6344
6511
  writer.uint32(10).string(message.flagConfiguration);
6345
6512
  }
6346
6513
  return writer;
6347
6514
  },
6348
6515
  decode(input, length) {
6349
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
6516
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
6350
6517
  let end = length === undefined ? reader.len : reader.pos + length;
6351
6518
  const message = createBaseFetchAllFlagsResponse();
6352
6519
  while (reader.pos < end) {
@@ -6377,12 +6544,12 @@ const FetchAllFlagsResponse = {
6377
6544
  return obj;
6378
6545
  },
6379
6546
  create(base) {
6380
- return FetchAllFlagsResponse.fromPartial(base !== null && base !== void 0 ? base : {});
6547
+ return FetchAllFlagsResponse.fromPartial(base !== null && base !== undefined ? base : {});
6381
6548
  },
6382
6549
  fromPartial(object) {
6383
6550
  var _a;
6384
6551
  const message = createBaseFetchAllFlagsResponse();
6385
- message.flagConfiguration = (_a = object.flagConfiguration) !== null && _a !== void 0 ? _a : "";
6552
+ message.flagConfiguration = (_a = object.flagConfiguration) !== null && _a !== undefined ? _a : "";
6386
6553
  return message;
6387
6554
  },
6388
6555
  };
@@ -6390,11 +6557,11 @@ function createBaseGetMetadataRequest() {
6390
6557
  return {};
6391
6558
  }
6392
6559
  const GetMetadataRequest = {
6393
- encode(_, writer = minimal.Writer.create()) {
6560
+ encode(_, writer = _m0.Writer.create()) {
6394
6561
  return writer;
6395
6562
  },
6396
6563
  decode(input, length) {
6397
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
6564
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
6398
6565
  let end = length === undefined ? reader.len : reader.pos + length;
6399
6566
  const message = createBaseGetMetadataRequest();
6400
6567
  while (reader.pos < end) {
@@ -6414,7 +6581,7 @@ const GetMetadataRequest = {
6414
6581
  return obj;
6415
6582
  },
6416
6583
  create(base) {
6417
- return GetMetadataRequest.fromPartial(base !== null && base !== void 0 ? base : {});
6584
+ return GetMetadataRequest.fromPartial(base !== null && base !== undefined ? base : {});
6418
6585
  },
6419
6586
  fromPartial(_) {
6420
6587
  const message = createBaseGetMetadataRequest();
@@ -6425,14 +6592,14 @@ function createBaseGetMetadataResponse() {
6425
6592
  return { metadata: undefined };
6426
6593
  }
6427
6594
  const GetMetadataResponse = {
6428
- encode(message, writer = minimal.Writer.create()) {
6595
+ encode(message, writer = _m0.Writer.create()) {
6429
6596
  if (message.metadata !== undefined) {
6430
6597
  Struct.encode(Struct.wrap(message.metadata), writer.uint32(18).fork()).ldelim();
6431
6598
  }
6432
6599
  return writer;
6433
6600
  },
6434
6601
  decode(input, length) {
6435
- const reader = input instanceof minimal.Reader ? input : minimal.Reader.create(input);
6602
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
6436
6603
  let end = length === undefined ? reader.len : reader.pos + length;
6437
6604
  const message = createBaseGetMetadataResponse();
6438
6605
  while (reader.pos < end) {
@@ -6463,12 +6630,12 @@ const GetMetadataResponse = {
6463
6630
  return obj;
6464
6631
  },
6465
6632
  create(base) {
6466
- return GetMetadataResponse.fromPartial(base !== null && base !== void 0 ? base : {});
6633
+ return GetMetadataResponse.fromPartial(base !== null && base !== undefined ? base : {});
6467
6634
  },
6468
6635
  fromPartial(object) {
6469
6636
  var _a;
6470
6637
  const message = createBaseGetMetadataResponse();
6471
- message.metadata = (_a = object.metadata) !== null && _a !== void 0 ? _a : undefined;
6638
+ message.metadata = (_a = object.metadata) !== null && _a !== undefined ? _a : undefined;
6472
6639
  return message;
6473
6640
  },
6474
6641
  };
@@ -6526,29 +6693,36 @@ class GrpcFetch {
6526
6693
  * false if the connection is lost.
6527
6694
  */
6528
6695
  this._isConnected = false;
6529
- const { host, port, tls, socketPath, selector } = config;
6696
+ const { host, port, tls, socketPath, selector, defaultAuthority } = config;
6697
+ let clientOptions;
6698
+ if (defaultAuthority) {
6699
+ clientOptions = {
6700
+ 'grpc.default_authority': defaultAuthority,
6701
+ };
6702
+ }
6530
6703
  this._syncClient = syncServiceClient
6531
6704
  ? syncServiceClient
6532
- : new FlagSyncServiceClient(socketPath ? `unix://${socketPath}` : `${host}:${port}`, tls ? grpcJs.credentials.createSsl() : grpcJs.credentials.createInsecure());
6705
+ : new FlagSyncServiceClient(socketPath ? `unix://${socketPath}` : `${host}:${port}`, tls ? grpcJs.credentials.createSsl() : grpcJs.credentials.createInsecure(), clientOptions);
6533
6706
  this._logger = logger;
6534
6707
  this._request = { providerId: '', selector: selector ? selector : '' };
6535
6708
  }
6536
6709
  connect(dataCallback, reconnectCallback, changedCallback, disconnectCallback) {
6537
- return new Promise((resolve, reject) => this.listen(dataCallback, reconnectCallback, changedCallback, disconnectCallback, resolve, reject)).then(() => {
6710
+ return __awaiter(this, undefined, undefined, function* () {
6711
+ yield new Promise((resolve, reject) => this.listen(dataCallback, reconnectCallback, changedCallback, disconnectCallback, resolve, reject));
6538
6712
  this._initialized = true;
6539
6713
  });
6540
6714
  }
6541
6715
  disconnect() {
6542
- return __awaiter(this, void 0, void 0, function* () {
6716
+ return __awaiter(this, undefined, undefined, function* () {
6543
6717
  var _a;
6544
- (_a = this._logger) === null || _a === void 0 ? void 0 : _a.debug('Disconnecting gRPC sync connection');
6718
+ (_a = this._logger) === null || _a === undefined ? undefined : _a.debug('Disconnecting gRPC sync connection');
6545
6719
  closeStreamIfDefined(this._syncStream);
6546
6720
  this._syncClient.close();
6547
6721
  });
6548
6722
  }
6549
6723
  listen(dataCallback, reconnectCallback, changedCallback, disconnectCallback, resolveConnect, rejectConnect) {
6550
6724
  var _a;
6551
- (_a = this._logger) === null || _a === void 0 ? void 0 : _a.debug('Starting gRPC sync connection');
6725
+ (_a = this._logger) === null || _a === undefined ? undefined : _a.debug('Starting gRPC sync connection');
6552
6726
  closeStreamIfDefined(this._syncStream);
6553
6727
  try {
6554
6728
  this._syncStream = this._syncClient.syncFlags(this._request);
@@ -6584,12 +6758,12 @@ class GrpcFetch {
6584
6758
  }
6585
6759
  handleError(err, dataCallback, reconnectCallback, changedCallback, disconnectCallback, rejectConnect) {
6586
6760
  var _a, _b, _c;
6587
- (_a = this._logger) === null || _a === void 0 ? void 0 : _a.error('Connection error, attempting to reconnect');
6588
- (_b = this._logger) === null || _b === void 0 ? void 0 : _b.debug(err);
6761
+ (_a = this._logger) === null || _a === undefined ? undefined : _a.error('Connection error, attempting to reconnect');
6762
+ (_b = this._logger) === null || _b === undefined ? undefined : _b.debug(err);
6589
6763
  this._isConnected = false;
6590
- const errorMessage = (_c = err === null || err === void 0 ? void 0 : err.message) !== null && _c !== void 0 ? _c : 'Failed to connect to syncFlags stream';
6764
+ const errorMessage = (_c = err === null || err === undefined ? undefined : err.message) !== null && _c !== undefined ? _c : 'Failed to connect to syncFlags stream';
6591
6765
  disconnectCallback(errorMessage);
6592
- rejectConnect === null || rejectConnect === void 0 ? void 0 : rejectConnect(new serverSdk.GeneralError(errorMessage));
6766
+ rejectConnect === null || rejectConnect === undefined ? undefined : rejectConnect(new serverSdk.GeneralError(errorMessage));
6593
6767
  this.reconnect(dataCallback, reconnectCallback, changedCallback, disconnectCallback);
6594
6768
  }
6595
6769
  reconnect(dataCallback, reconnectCallback, changedCallback, disconnectCallback) {
@@ -6600,60 +6774,6 @@ class GrpcFetch {
6600
6774
  }
6601
6775
  }
6602
6776
 
6603
- const encoding = 'utf8';
6604
- class FileFetch {
6605
- constructor(filename, logger) {
6606
- this._filename = filename;
6607
- this._logger = logger;
6608
- }
6609
- connect(dataFillCallback, _, changedCallback) {
6610
- return __awaiter(this, void 0, void 0, function* () {
6611
- var _a, _b;
6612
- (_a = this._logger) === null || _a === void 0 ? void 0 : _a.debug('Starting file sync connection');
6613
- try {
6614
- const output = yield fs.promises.readFile(this._filename, encoding);
6615
- // Don't emit the change event for the initial read
6616
- dataFillCallback(output);
6617
- // Using watchFile instead of watch to support virtualized host file systems.
6618
- fs.watchFile(this._filename, () => __awaiter(this, void 0, void 0, function* () {
6619
- var _a;
6620
- try {
6621
- const data = yield fs.promises.readFile(this._filename, encoding);
6622
- const changes = dataFillCallback(data);
6623
- if (changes.length > 0) {
6624
- changedCallback(changes);
6625
- }
6626
- }
6627
- catch (err) {
6628
- (_a = this._logger) === null || _a === void 0 ? void 0 : _a.error(`Error reading file: ${err}`);
6629
- }
6630
- }));
6631
- }
6632
- catch (err) {
6633
- if (err instanceof core.OpenFeatureError) {
6634
- throw err;
6635
- }
6636
- else {
6637
- switch (err === null || err === void 0 ? void 0 : err.code) {
6638
- case 'ENOENT':
6639
- throw new core.GeneralError(`File not found: ${this._filename}`);
6640
- case 'EACCES':
6641
- throw new core.GeneralError(`File not accessible: ${this._filename}`);
6642
- default:
6643
- (_b = this._logger) === null || _b === void 0 ? void 0 : _b.debug(`Error reading file: ${err}`);
6644
- throw new core.GeneralError();
6645
- }
6646
- }
6647
- }
6648
- });
6649
- }
6650
- disconnect() {
6651
- return __awaiter(this, void 0, void 0, function* () {
6652
- fs.unwatchFile(this._filename);
6653
- });
6654
- }
6655
- }
6656
-
6657
6777
  class InProcessService {
6658
6778
  constructor(config, dataFetcher, logger) {
6659
6779
  this.config = config;
@@ -6668,39 +6788,37 @@ class InProcessService {
6668
6788
  return this._dataFetcher.connect(this.setFlagConfiguration.bind(this), reconnectCallback, changedCallback, disconnectCallback);
6669
6789
  }
6670
6790
  disconnect() {
6671
- return __awaiter(this, void 0, void 0, function* () {
6791
+ return __awaiter(this, undefined, undefined, function* () {
6672
6792
  this._dataFetcher.disconnect();
6673
6793
  });
6674
6794
  }
6675
6795
  resolveBoolean(flagKey, defaultValue, context, logger) {
6676
- return __awaiter(this, void 0, void 0, function* () {
6796
+ return __awaiter(this, undefined, undefined, function* () {
6677
6797
  return this.evaluate('boolean', flagKey, defaultValue, context, logger);
6678
6798
  });
6679
6799
  }
6680
6800
  resolveNumber(flagKey, defaultValue, context, logger) {
6681
- return __awaiter(this, void 0, void 0, function* () {
6801
+ return __awaiter(this, undefined, undefined, function* () {
6682
6802
  return this.evaluate('number', flagKey, defaultValue, context, logger);
6683
6803
  });
6684
6804
  }
6685
6805
  resolveString(flagKey, defaultValue, context, logger) {
6686
- return __awaiter(this, void 0, void 0, function* () {
6806
+ return __awaiter(this, undefined, undefined, function* () {
6687
6807
  return this.evaluate('string', flagKey, defaultValue, context, logger);
6688
6808
  });
6689
6809
  }
6690
6810
  resolveObject(flagKey, defaultValue, context, logger) {
6691
- return __awaiter(this, void 0, void 0, function* () {
6811
+ return __awaiter(this, undefined, undefined, function* () {
6692
6812
  return this.evaluate('object', flagKey, defaultValue, context, logger);
6693
6813
  });
6694
6814
  }
6695
6815
  evaluate(type, flagKey, defaultValue, context, logger) {
6696
- const details = this._flagdCore.resolve(type, flagKey, defaultValue, context, logger);
6697
- return Object.assign(Object.assign({}, details), { flagMetadata: this.addFlagMetadata() });
6698
- }
6699
- /**
6700
- * Adds the flag metadata to the resolution details
6701
- */
6702
- addFlagMetadata() {
6703
- return Object.assign({}, (this.config.selector ? { scope: this.config.selector } : {}));
6816
+ const resolution = this._flagdCore.resolve(type, flagKey, defaultValue, context, logger);
6817
+ // Add selector as scope if not already present in flag metadata
6818
+ if (this.config.selector && !resolution.flagMetadata['scope']) {
6819
+ return Object.assign(Object.assign({}, resolution), { flagMetadata: Object.assign(Object.assign({}, resolution.flagMetadata), { scope: this.config.selector }) });
6820
+ }
6821
+ return resolution;
6704
6822
  }
6705
6823
  /**
6706
6824
  * Sets the flag configuration
@@ -6714,12 +6832,6 @@ class InProcessService {
6714
6832
  }
6715
6833
 
6716
6834
  class FlagdProvider {
6717
- get status() {
6718
- return this._status;
6719
- }
6720
- get events() {
6721
- return this._events;
6722
- }
6723
6835
  /**
6724
6836
  * Construct a new flagd provider.
6725
6837
  *
@@ -6730,16 +6842,10 @@ class FlagdProvider {
6730
6842
  constructor(options, logger, service) {
6731
6843
  this.logger = logger;
6732
6844
  this.metadata = {
6733
- name: 'flagd Provider',
6845
+ name: 'flagd',
6734
6846
  };
6735
6847
  this.runsOn = 'server';
6736
- this._status = serverSdk.ProviderStatus.NOT_READY;
6737
- this._events = new serverSdk.OpenFeatureEventEmitter();
6738
- this.logRejected = (err, flagKey, logger) => {
6739
- logger.error(`Error resolving flag ${flagKey}: ${err === null || err === void 0 ? void 0 : err.message}`);
6740
- logger.error(err === null || err === void 0 ? void 0 : err.stack);
6741
- throw err;
6742
- };
6848
+ this.events = new serverSdk.OpenFeatureEventEmitter();
6743
6849
  const config = getConfig(options);
6744
6850
  this._service = service
6745
6851
  ? service
@@ -6748,56 +6854,44 @@ class FlagdProvider {
6748
6854
  : new GRPCService(config, undefined, logger);
6749
6855
  }
6750
6856
  initialize() {
6751
- return this._service
6752
- .connect(this.handleReconnect.bind(this), this.handleChanged.bind(this), this.handleError.bind(this))
6753
- .then(() => {
6754
- var _a;
6755
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`${this.metadata.name}: ready`);
6756
- this._status = serverSdk.ProviderStatus.READY;
6757
- })
6758
- .catch((err) => {
6759
- var _a, _b;
6760
- this._status = serverSdk.ProviderStatus.ERROR;
6761
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(`${this.metadata.name}: error during initialization: ${err.message}`);
6762
- (_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(err);
6763
- throw err;
6857
+ return __awaiter(this, undefined, undefined, function* () {
6858
+ var _a, _b, _c;
6859
+ try {
6860
+ yield this._service.connect(this.handleReconnect.bind(this), this.handleChanged.bind(this), this.handleError.bind(this));
6861
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`${this.metadata.name}: ready`);
6862
+ }
6863
+ catch (err) {
6864
+ (_b = this.logger) === null || _b === undefined ? undefined : _b.error(`${this.metadata.name}: error during initialization: ${err === null || err === undefined ? undefined : err.message}`);
6865
+ (_c = this.logger) === null || _c === undefined ? undefined : _c.debug(err);
6866
+ throw err;
6867
+ }
6764
6868
  });
6765
6869
  }
6766
6870
  onClose() {
6767
6871
  var _a;
6768
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`${this.metadata.name}: shutting down`);
6872
+ (_a = this.logger) === null || _a === undefined ? undefined : _a.debug(`${this.metadata.name}: shutting down`);
6769
6873
  return this._service.disconnect();
6770
6874
  }
6771
6875
  resolveBooleanEvaluation(flagKey, defaultValue, transformedContext, logger) {
6772
- return this._service
6773
- .resolveBoolean(flagKey, defaultValue, transformedContext, logger)
6774
- .catch((err) => this.logRejected(err, flagKey, logger));
6876
+ return this._service.resolveBoolean(flagKey, defaultValue, transformedContext, logger);
6775
6877
  }
6776
6878
  resolveStringEvaluation(flagKey, defaultValue, transformedContext, logger) {
6777
- return this._service
6778
- .resolveString(flagKey, defaultValue, transformedContext, logger)
6779
- .catch((err) => this.logRejected(err, flagKey, logger));
6879
+ return this._service.resolveString(flagKey, defaultValue, transformedContext, logger);
6780
6880
  }
6781
6881
  resolveNumberEvaluation(flagKey, defaultValue, transformedContext, logger) {
6782
- return this._service
6783
- .resolveNumber(flagKey, defaultValue, transformedContext, logger)
6784
- .catch((err) => this.logRejected(err, flagKey, logger));
6882
+ return this._service.resolveNumber(flagKey, defaultValue, transformedContext, logger);
6785
6883
  }
6786
6884
  resolveObjectEvaluation(flagKey, defaultValue, transformedContext, logger) {
6787
- return this._service
6788
- .resolveObject(flagKey, defaultValue, transformedContext, logger)
6789
- .catch((err) => this.logRejected(err, flagKey, logger));
6885
+ return this._service.resolveObject(flagKey, defaultValue, transformedContext, logger);
6790
6886
  }
6791
6887
  handleReconnect() {
6792
- this._status = serverSdk.ProviderStatus.READY;
6793
- this._events.emit(serverSdk.ProviderEvents.Ready);
6888
+ this.events.emit(serverSdk.ProviderEvents.Ready);
6794
6889
  }
6795
6890
  handleError(message) {
6796
- this._status = serverSdk.ProviderStatus.ERROR;
6797
- this._events.emit(serverSdk.ProviderEvents.Error, { message });
6891
+ this.events.emit(serverSdk.ProviderEvents.Error, { message });
6798
6892
  }
6799
6893
  handleChanged(flagsChanged) {
6800
- this._events.emit(serverSdk.ProviderEvents.ConfigurationChanged, { flagsChanged });
6894
+ this.events.emit(serverSdk.ProviderEvents.ConfigurationChanged, { flagsChanged });
6801
6895
  }
6802
6896
  }
6803
6897