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