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