amazon-dax-client-sdkv3
Version:
Amazon DAX Client for JavaScript
1,509 lines (1,499 loc) • 663 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/DaxClientError.ts
var DaxClientError;
var init_DaxClientError = __esm({
"src/DaxClientError.ts"() {
"use strict";
DaxClientError = class _DaxClientError extends Error {
time;
code;
retryable;
requestId;
statusCode;
_tubeInvalid;
waitForRecoveryBeforeRetrying;
constructor(message, code, retryable, requestId, statusCode) {
super(message);
this.time = Date.now();
this.code = code;
this.retryable = retryable === void 0 ? true : retryable;
this.requestId = requestId === void 0 ? null : requestId;
this.statusCode = statusCode === void 0 ? -1 : statusCode;
this._tubeInvalid = false;
this.waitForRecoveryBeforeRetrying = false;
this.message = _DaxClientError._formatMessage(code, message);
}
static _formatMessage(code, message) {
return !code || message.startsWith(code) ? message : code + ": " + message;
}
};
}
});
// src/DaxErrorCode.ts
var DaxErrorCode;
var init_DaxErrorCode = __esm({
"src/DaxErrorCode.ts"() {
"use strict";
DaxErrorCode = {
Decoder: "DecoderException",
Encoder: "EncoderException",
Unrecognized: "UnrecognizedClientException",
Authentication: "MissingAuthenticationTokenException",
MalformedResult: "MalformedResultException",
EndOfStream: "EndOfStreamException",
IllegalArgument: "IllegalArgumentException",
Validation: "ValidationException",
NoRoute: "NoRouteException",
ResourceNotFound: "ResourceNotFoundException",
ResourceInUse: "ResourceInUseException",
ProvisionedThroughputExceeded: "ProvisionedThroughputExceededException",
ConditionalCheckFailed: "ConditionalCheckFailedException",
InternalServerError: "InternalServerErrorException",
ItemCollectionSizeLimitExceeded: "ItemCollectionSizeLimitExceededException",
LimitExceeded: "LimitExceededException",
RequestLimitExceeded: "RequestLimitExceeded",
Throttling: "ThrottlingException",
Connection: "ConnectionException"
};
}
});
// src/Util.ts
import { Buffer as Buffer2 } from "buffer";
var ALPHABET, ENCRYPTED_SCHEME, UNENCRYPTED_SCHEME, SCHEMES_TO_PORTS, Util;
var init_Util = __esm({
"src/Util.ts"() {
"use strict";
init_DaxClientError();
init_DaxErrorCode();
ALPHABET = "0123456789abcdef";
ENCRYPTED_SCHEME = "daxs";
UNENCRYPTED_SCHEME = "dax";
SCHEMES_TO_PORTS = { [UNENCRYPTED_SCHEME]: 8111, [ENCRYPTED_SCHEME]: 9111 };
Util = class _Util {
static convertBase(str, baseIn, baseOut) {
if (str[0] === "-") {
str = str.slice(1);
}
let j;
let arr = [0];
let arrL;
let i = 0;
let len = str.length;
for (; i < len; ) {
for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) {
}
arr[j = 0] += ALPHABET.indexOf(str[i++]);
for (; j < arr.length; j++) {
if (arr[j] > baseOut - 1) {
if (arr[j + 1] == null) {
arr[j + 1] = 0;
}
arr[j + 1] += arr[j] / baseOut | 0;
arr[j] %= baseOut;
}
}
}
let outstr = "";
for (i = arr.length - 1; i >= 0; --i) {
outstr += ALPHABET[arr[i]];
}
if (baseOut === 16) {
switch (true) {
case outstr.length <= 2:
outstr = "0".repeat(2 - outstr.length) + outstr;
break;
case outstr.length <= 4:
outstr = "0".repeat(4 - outstr.length) + outstr;
break;
case outstr.length <= 8:
outstr = "0".repeat(8 - outstr.length) + outstr;
break;
case outstr.length <= 16:
outstr = "0".repeat(16 - outstr.length) + outstr;
break;
default:
outstr = (outstr.length % 2 ? "0" : "") + outstr;
}
}
return outstr;
}
static parseHostPorts(hostports) {
if (hostports == null || hostports == "") {
throw new DaxClientError("Provide a Cluster Discovery Endpoint to connect.");
}
if (typeof hostports === "string") {
return [_Util.parseHostPort(hostports)];
}
let addrs = [];
for (let hostport of hostports) {
addrs.push(_Util.parseHostPort(hostport));
}
const schemesInAddrs = addrs.map((addr) => addr.scheme);
const daxScheme = schemesInAddrs[0];
const areAllSchemesTheSame = schemesInAddrs.every((scheme) => scheme == daxScheme);
if (!areAllSchemesTheSame) {
throw new DaxClientError("Inconsistency between the schemes of provided endpoints.", DaxErrorCode.IllegalArgument, false);
}
if (daxScheme == ENCRYPTED_SCHEME && addrs != null && addrs.length >= 2) {
throw new DaxClientError("Only one encrypted endpoint URL is allowed.");
}
return addrs;
}
static parseHostPort(hostport) {
let url;
if (hostport.indexOf("://") == -1) {
if (hostport.indexOf(":") == -1) {
throw new DaxClientError("Invalid hostport: " + hostport, DaxErrorCode.IllegalArgument, false);
}
hostport = `${UNENCRYPTED_SCHEME}://${hostport}`;
}
try {
url = new URL(hostport);
} catch (error3) {
throw new DaxClientError("Invalid hostport: " + hostport, DaxErrorCode.IllegalArgument, false);
}
const host = url.hostname;
let port = url.port;
const scheme = url.protocol.replace(":", "");
if (!Object.keys(SCHEMES_TO_PORTS).includes(scheme)) {
throw new DaxClientError("URL scheme must be one of: " + Object.keys(SCHEMES_TO_PORTS), DaxErrorCode.IllegalArgument, false);
}
if (port == "" || port == null) {
port = SCHEMES_TO_PORTS[scheme];
}
return { host, port: parseInt(port), scheme };
}
static objEqual(a, b) {
if (!a || !b) {
return a === b;
}
if (typeof a === typeof b) {
switch (typeof a) {
case "string":
case "number":
case "boolean":
return a === b;
}
}
let aProps = Object.getOwnPropertyNames(a);
let bProps = Object.getOwnPropertyNames(b);
if (aProps.length != bProps.length) {
return false;
}
for (let i = 0; i < aProps.length; i++) {
let propName = aProps[i];
if (typeof a[propName] === "object") {
if (!_Util.objEqual(a[propName], b[propName])) {
return false;
}
} else if (a[propName] !== b[propName]) {
return false;
}
}
return true;
}
// compare two Lists
static arrayEquals(lista, listb) {
if (lista.length !== listb.length) {
return false;
}
let usedIndex = /* @__PURE__ */ new Set();
for (let i = 0; i < lista.length; ++i) {
let equal = false;
for (let j = 0; j < listb.length; ++j) {
if (!usedIndex.has(j) && _Util.objEqual(lista[i], listb[j])) {
equal = true;
usedIndex.add(j);
break;
}
}
if (!equal) {
return false;
}
}
return true;
}
// compare two sorted Lists
static sortedArrayEquals(lista, listb) {
if (lista.length !== listb.length) {
return false;
}
for (let i = 0; i < lista.length; ++i) {
if (!_Util.objEqual(lista[i], listb[i])) {
return false;
}
}
return true;
}
static objArrayEquals(a, b) {
if (!a || !b) {
return a === b;
}
if (typeof a === typeof b) {
switch (typeof a) {
case "string":
case "number":
case "boolean":
return a === b;
}
}
let aProps = Object.getOwnPropertyNames(a);
let bProps = Object.getOwnPropertyNames(b);
if (aProps.length != bProps.length) {
return false;
}
if (Array.isArray(a) && Array.isArray(b)) {
return _Util.arrayEquals(a, b);
}
for (let i = 0; i < aProps.length; i++) {
let propName = aProps[i];
if (typeof a[propName] === "object") {
if (!_Util.objArrayEquals(a[propName], b[propName])) {
return false;
}
} else if (a[propName] !== b[propName]) {
return false;
}
}
return true;
}
static deepCopy(obj) {
if (obj === void 0 || obj === null || typeof obj !== "object") {
return obj;
}
if (Array.isArray(obj)) {
return obj.map((e) => _Util.deepCopy(e));
}
if (Buffer2.isBuffer(obj)) {
return Buffer2.from(obj);
}
let clone = {};
for (let prop in obj) {
if (obj.hasOwnProperty(prop)) {
clone[prop] = _Util.deepCopy(obj[prop]);
}
}
return clone;
}
static serviceEndpointFrom(nodeId, hostname, address, port, role, zone, leaderSessionId) {
return { nodeId, hostname, address, port, role, zone, leaderSessionId };
}
static deanonymizeAttributeValues(item, attrNames) {
let attrValues = item._anonymousAttributeValues;
attrValues.forEach((attrValue, index) => {
item[attrNames[index]] = attrValue;
});
delete item._anonymousAttributeValues;
delete item._attrListId;
return item;
}
static extractKey(item, tableKeys) {
let keys = {};
for (let keyDef of tableKeys) {
let keyName = keyDef.AttributeName;
keys[keyName] = item[keyName];
}
return keys;
}
};
}
});
// src/Cache.ts
var Cache_exports = {};
__export(Cache_exports, {
Cache: () => Cache,
CacheFactory: () => CacheFactory,
CacheType: () => CacheType,
StringListCache: () => StringListCache
});
var CacheFactory, Cache, StringListCache, CacheType;
var init_Cache = __esm({
"src/Cache.ts"() {
"use strict";
init_Util();
CacheFactory = class {
static create(CacheType3, size) {
if (!CacheType3) {
throw new Error("not support Cache type");
}
return new CacheType3();
}
};
Cache = class {
_size;
_cache;
// plain object cache
constructor(size) {
this._size = size;
this._cache = {};
}
get(key) {
return this._cache[key];
}
put(key, val) {
let old = this._cache[key];
this._cache[key] = val;
return old;
}
remove(key) {
delete this._cache[key];
}
};
StringListCache = class {
_size;
_cache;
// internal storage structure { _hash: [ [key, value], ...] }
// when insert an string-list key into JS object, it will automatically
// convert into string seperated by comma e.g. ['1', '2'] => '1,2'
// to solve the conflicts we have to store its real value
// For performance, arrays are compared as if they are sorted
constructor(size) {
this._size = size;
this._cache = {};
}
_hash(key) {
return key.toString();
}
get(key) {
let keyValuePairs = this._cache[this._hash(key)];
if (!keyValuePairs) {
return null;
}
for (let keyValuePair of keyValuePairs) {
let storedKey = keyValuePair[0];
if (Util.sortedArrayEquals(key, storedKey)) {
return keyValuePair[1];
}
}
return null;
}
put(key, val) {
let old = this.get(key);
let hashedKey = this._hash(key);
if (!this._cache[hashedKey]) {
this._cache[hashedKey] = [];
}
let keyValuePairs = this._cache[hashedKey];
if (old !== null && old !== void 0) {
for (let pair of keyValuePairs) {
if (Util.sortedArrayEquals(pair[0], key)) {
pair[1] = val;
return old;
}
}
}
keyValuePairs.push([key, val]);
return old;
}
remove(key) {
let hashKey = this._hash(key);
let keyValuePairs = this._cache[hashKey];
if (keyValuePairs) {
for (let i = 0; i < keyValuePairs.length; ++i) {
let pair = keyValuePairs[i];
if (Util.sortedArrayEquals(pair[0], key)) {
this._cache[hashKey].splice(i, 1);
return;
}
}
}
}
};
CacheType = {
Cache,
StringListCache
};
}
});
// node_modules/antlr4/Utils.js
var require_Utils = __commonJS({
"node_modules/antlr4/Utils.js"(exports) {
function arrayToString(a) {
return "[" + a.join(", ") + "]";
}
String.prototype.seed = String.prototype.seed || Math.round(Math.random() * Math.pow(2, 32));
String.prototype.hashCode = function() {
var remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i, key = this.toString();
remainder = key.length & 3;
bytes = key.length - remainder;
h1 = String.prototype.seed;
c1 = 3432918353;
c2 = 461845907;
i = 0;
while (i < bytes) {
k1 = key.charCodeAt(i) & 255 | (key.charCodeAt(++i) & 255) << 8 | (key.charCodeAt(++i) & 255) << 16 | (key.charCodeAt(++i) & 255) << 24;
++i;
k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
k1 = k1 << 15 | k1 >>> 17;
k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
h1 ^= k1;
h1 = h1 << 13 | h1 >>> 19;
h1b = (h1 & 65535) * 5 + (((h1 >>> 16) * 5 & 65535) << 16) & 4294967295;
h1 = (h1b & 65535) + 27492 + (((h1b >>> 16) + 58964 & 65535) << 16);
}
k1 = 0;
switch (remainder) {
case 3:
k1 ^= (key.charCodeAt(i + 2) & 255) << 16;
case 2:
k1 ^= (key.charCodeAt(i + 1) & 255) << 8;
case 1:
k1 ^= key.charCodeAt(i) & 255;
k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
k1 = k1 << 15 | k1 >>> 17;
k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
h1 ^= k1;
}
h1 ^= key.length;
h1 ^= h1 >>> 16;
h1 = (h1 & 65535) * 2246822507 + (((h1 >>> 16) * 2246822507 & 65535) << 16) & 4294967295;
h1 ^= h1 >>> 13;
h1 = (h1 & 65535) * 3266489909 + (((h1 >>> 16) * 3266489909 & 65535) << 16) & 4294967295;
h1 ^= h1 >>> 16;
return h1 >>> 0;
};
function standardEqualsFunction(a, b) {
return a.equals(b);
}
function standardHashCodeFunction(a) {
return a.hashCode();
}
function Set2(hashFunction, equalsFunction) {
this.data = {};
this.hashFunction = hashFunction || standardHashCodeFunction;
this.equalsFunction = equalsFunction || standardEqualsFunction;
return this;
}
Object.defineProperty(Set2.prototype, "length", {
get: function() {
var l = 0;
for (var key in this.data) {
if (key.indexOf("hash_") === 0) {
l = l + this.data[key].length;
}
}
return l;
}
});
Set2.prototype.add = function(value) {
var hash = this.hashFunction(value);
var key = "hash_" + hash;
if (key in this.data) {
var values = this.data[key];
for (var i = 0; i < values.length; i++) {
if (this.equalsFunction(value, values[i])) {
return values[i];
}
}
values.push(value);
return value;
} else {
this.data[key] = [value];
return value;
}
};
Set2.prototype.contains = function(value) {
return this.get(value) != null;
};
Set2.prototype.get = function(value) {
var hash = this.hashFunction(value);
var key = "hash_" + hash;
if (key in this.data) {
var values = this.data[key];
for (var i = 0; i < values.length; i++) {
if (this.equalsFunction(value, values[i])) {
return values[i];
}
}
}
return null;
};
Set2.prototype.values = function() {
var l = [];
for (var key in this.data) {
if (key.indexOf("hash_") === 0) {
l = l.concat(this.data[key]);
}
}
return l;
};
Set2.prototype.toString = function() {
return arrayToString(this.values());
};
function BitSet() {
this.data = [];
return this;
}
BitSet.prototype.add = function(value) {
this.data[value] = true;
};
BitSet.prototype.or = function(set) {
var bits = this;
Object.keys(set.data).map(function(alt) {
bits.add(alt);
});
};
BitSet.prototype.remove = function(value) {
delete this.data[value];
};
BitSet.prototype.contains = function(value) {
return this.data[value] === true;
};
BitSet.prototype.values = function() {
return Object.keys(this.data);
};
BitSet.prototype.minValue = function() {
return Math.min.apply(null, this.values());
};
BitSet.prototype.hashCode = function() {
var hash = new Hash2();
hash.update(this.values());
return hash.finish();
};
BitSet.prototype.equals = function(other) {
if (!(other instanceof BitSet)) {
return false;
}
return this.hashCode() === other.hashCode();
};
Object.defineProperty(BitSet.prototype, "length", {
get: function() {
return this.values().length;
}
});
BitSet.prototype.toString = function() {
return "{" + this.values().join(", ") + "}";
};
function Map2(hashFunction, equalsFunction) {
this.data = {};
this.hashFunction = hashFunction || standardHashCodeFunction;
this.equalsFunction = equalsFunction || standardEqualsFunction;
return this;
}
Object.defineProperty(Map2.prototype, "length", {
get: function() {
var l = 0;
for (var hashKey in this.data) {
if (hashKey.indexOf("hash_") === 0) {
l = l + this.data[hashKey].length;
}
}
return l;
}
});
Map2.prototype.put = function(key, value) {
var hashKey = "hash_" + this.hashFunction(key);
if (hashKey in this.data) {
var entries = this.data[hashKey];
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
if (this.equalsFunction(key, entry.key)) {
var oldValue = entry.value;
entry.value = value;
return oldValue;
}
}
entries.push({ key, value });
return value;
} else {
this.data[hashKey] = [{ key, value }];
return value;
}
};
Map2.prototype.containsKey = function(key) {
var hashKey = "hash_" + this.hashFunction(key);
if (hashKey in this.data) {
var entries = this.data[hashKey];
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
if (this.equalsFunction(key, entry.key))
return true;
}
}
return false;
};
Map2.prototype.get = function(key) {
var hashKey = "hash_" + this.hashFunction(key);
if (hashKey in this.data) {
var entries = this.data[hashKey];
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
if (this.equalsFunction(key, entry.key))
return entry.value;
}
}
return null;
};
Map2.prototype.entries = function() {
var l = [];
for (var key in this.data) {
if (key.indexOf("hash_") === 0) {
l = l.concat(this.data[key]);
}
}
return l;
};
Map2.prototype.getKeys = function() {
return this.entries().map(function(e) {
return e.key;
});
};
Map2.prototype.getValues = function() {
return this.entries().map(function(e) {
return e.value;
});
};
Map2.prototype.toString = function() {
var ss = this.entries().map(function(entry) {
return "{" + entry.key + ":" + entry.value + "}";
});
return "[" + ss.join(", ") + "]";
};
function AltDict() {
this.data = {};
return this;
}
AltDict.prototype.get = function(key) {
key = "k-" + key;
if (key in this.data) {
return this.data[key];
} else {
return null;
}
};
AltDict.prototype.put = function(key, value) {
key = "k-" + key;
this.data[key] = value;
};
AltDict.prototype.values = function() {
var data = this.data;
var keys = Object.keys(this.data);
return keys.map(function(key) {
return data[key];
});
};
function DoubleDict(defaultMapCtor) {
this.defaultMapCtor = defaultMapCtor || Map2;
this.cacheMap = new this.defaultMapCtor();
return this;
}
function Hash2() {
this.count = 0;
this.hash = 0;
return this;
}
Hash2.prototype.update = function() {
for (var i = 0; i < arguments.length; i++) {
var value = arguments[i];
if (value == null)
continue;
if (Array.isArray(value))
this.update.apply(this, value);
else {
var k = 0;
switch (typeof value) {
case "undefined":
case "function":
continue;
case "number":
case "boolean":
k = value;
break;
case "string":
k = value.hashCode();
break;
default:
if (value.updateHashCode)
value.updateHashCode(this);
else
console.log("No updateHashCode for " + value.toString());
continue;
}
k = k * 3432918353;
k = k << 15 | k >>> 32 - 15;
k = k * 461845907;
this.count = this.count + 1;
var hash = this.hash ^ k;
hash = hash << 13 | hash >>> 32 - 13;
hash = hash * 5 + 3864292196;
this.hash = hash;
}
}
};
Hash2.prototype.finish = function() {
var hash = this.hash ^ this.count * 4;
hash = hash ^ hash >>> 16;
hash = hash * 2246822507;
hash = hash ^ hash >>> 13;
hash = hash * 3266489909;
hash = hash ^ hash >>> 16;
return hash;
};
function hashStuff() {
var hash = new Hash2();
hash.update.apply(hash, arguments);
return hash.finish();
}
DoubleDict.prototype.get = function(a, b) {
var d = this.cacheMap.get(a) || null;
return d === null ? null : d.get(b) || null;
};
DoubleDict.prototype.set = function(a, b, o) {
var d = this.cacheMap.get(a) || null;
if (d === null) {
d = new this.defaultMapCtor();
this.cacheMap.put(a, d);
}
d.put(b, o);
};
function escapeWhitespace(s, escapeSpaces) {
s = s.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
if (escapeSpaces) {
s = s.replace(/ /g, "\xB7");
}
return s;
}
function titleCase(str) {
return str.replace(/\w\S*/g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1);
});
}
function equalArrays(a, b) {
if (!Array.isArray(a) || !Array.isArray(b))
return false;
if (a == b)
return true;
if (a.length != b.length)
return false;
for (var i = 0; i < a.length; i++) {
if (a[i] == b[i])
continue;
if (!a[i].equals(b[i]))
return false;
}
return true;
}
exports.Hash = Hash2;
exports.Set = Set2;
exports.Map = Map2;
exports.BitSet = BitSet;
exports.AltDict = AltDict;
exports.DoubleDict = DoubleDict;
exports.hashStuff = hashStuff;
exports.escapeWhitespace = escapeWhitespace;
exports.arrayToString = arrayToString;
exports.titleCase = titleCase;
exports.equalArrays = equalArrays;
}
});
// node_modules/antlr4/Token.js
var require_Token = __commonJS({
"node_modules/antlr4/Token.js"(exports) {
function Token3() {
this.source = null;
this.type = null;
this.channel = null;
this.start = null;
this.stop = null;
this.tokenIndex = null;
this.line = null;
this.column = null;
this._text = null;
return this;
}
Token3.INVALID_TYPE = 0;
Token3.EPSILON = -2;
Token3.MIN_USER_TOKEN_TYPE = 1;
Token3.EOF = -1;
Token3.DEFAULT_CHANNEL = 0;
Token3.HIDDEN_CHANNEL = 1;
Object.defineProperty(Token3.prototype, "text", {
get: function() {
return this._text;
},
set: function(text) {
this._text = text;
}
});
Token3.prototype.getTokenSource = function() {
return this.source[0];
};
Token3.prototype.getInputStream = function() {
return this.source[1];
};
function CommonToken(source, type, channel, start, stop) {
Token3.call(this);
this.source = source !== void 0 ? source : CommonToken.EMPTY_SOURCE;
this.type = type !== void 0 ? type : null;
this.channel = channel !== void 0 ? channel : Token3.DEFAULT_CHANNEL;
this.start = start !== void 0 ? start : -1;
this.stop = stop !== void 0 ? stop : -1;
this.tokenIndex = -1;
if (this.source[0] !== null) {
this.line = source[0].line;
this.column = source[0].column;
} else {
this.column = -1;
}
return this;
}
CommonToken.prototype = Object.create(Token3.prototype);
CommonToken.prototype.constructor = CommonToken;
CommonToken.EMPTY_SOURCE = [null, null];
CommonToken.prototype.clone = function() {
var t = new CommonToken(
this.source,
this.type,
this.channel,
this.start,
this.stop
);
t.tokenIndex = this.tokenIndex;
t.line = this.line;
t.column = this.column;
t.text = this.text;
return t;
};
Object.defineProperty(CommonToken.prototype, "text", {
get: function() {
if (this._text !== null) {
return this._text;
}
var input = this.getInputStream();
if (input === null) {
return null;
}
var n = input.size;
if (this.start < n && this.stop < n) {
return input.getText(this.start, this.stop);
} else {
return "<EOF>";
}
},
set: function(text) {
this._text = text;
}
});
CommonToken.prototype.toString = function() {
var txt = this.text;
if (txt !== null) {
txt = txt.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
} else {
txt = "<no text>";
}
return "[@" + this.tokenIndex + "," + this.start + ":" + this.stop + "='" + txt + "',<" + this.type + ">" + (this.channel > 0 ? ",channel=" + this.channel : "") + "," + this.line + ":" + this.column + "]";
};
exports.Token = Token3;
exports.CommonToken = CommonToken;
}
});
// node_modules/antlr4/atn/ATNState.js
var require_ATNState = __commonJS({
"node_modules/antlr4/atn/ATNState.js"(exports) {
function ATNState() {
this.atn = null;
this.stateNumber = ATNState.INVALID_STATE_NUMBER;
this.stateType = null;
this.ruleIndex = 0;
this.epsilonOnlyTransitions = false;
this.transitions = [];
this.nextTokenWithinRule = null;
return this;
}
ATNState.INVALID_TYPE = 0;
ATNState.BASIC = 1;
ATNState.RULE_START = 2;
ATNState.BLOCK_START = 3;
ATNState.PLUS_BLOCK_START = 4;
ATNState.STAR_BLOCK_START = 5;
ATNState.TOKEN_START = 6;
ATNState.RULE_STOP = 7;
ATNState.BLOCK_END = 8;
ATNState.STAR_LOOP_BACK = 9;
ATNState.STAR_LOOP_ENTRY = 10;
ATNState.PLUS_LOOP_BACK = 11;
ATNState.LOOP_END = 12;
ATNState.serializationNames = [
"INVALID",
"BASIC",
"RULE_START",
"BLOCK_START",
"PLUS_BLOCK_START",
"STAR_BLOCK_START",
"TOKEN_START",
"RULE_STOP",
"BLOCK_END",
"STAR_LOOP_BACK",
"STAR_LOOP_ENTRY",
"PLUS_LOOP_BACK",
"LOOP_END"
];
ATNState.INVALID_STATE_NUMBER = -1;
ATNState.prototype.toString = function() {
return this.stateNumber;
};
ATNState.prototype.equals = function(other) {
if (other instanceof ATNState) {
return this.stateNumber === other.stateNumber;
} else {
return false;
}
};
ATNState.prototype.isNonGreedyExitState = function() {
return false;
};
ATNState.prototype.addTransition = function(trans, index) {
if (index === void 0) {
index = -1;
}
if (this.transitions.length === 0) {
this.epsilonOnlyTransitions = trans.isEpsilon;
} else if (this.epsilonOnlyTransitions !== trans.isEpsilon) {
this.epsilonOnlyTransitions = false;
}
if (index === -1) {
this.transitions.push(trans);
} else {
this.transitions.splice(index, 1, trans);
}
};
function BasicState() {
ATNState.call(this);
this.stateType = ATNState.BASIC;
return this;
}
BasicState.prototype = Object.create(ATNState.prototype);
BasicState.prototype.constructor = BasicState;
function DecisionState() {
ATNState.call(this);
this.decision = -1;
this.nonGreedy = false;
return this;
}
DecisionState.prototype = Object.create(ATNState.prototype);
DecisionState.prototype.constructor = DecisionState;
function BlockStartState() {
DecisionState.call(this);
this.endState = null;
return this;
}
BlockStartState.prototype = Object.create(DecisionState.prototype);
BlockStartState.prototype.constructor = BlockStartState;
function BasicBlockStartState() {
BlockStartState.call(this);
this.stateType = ATNState.BLOCK_START;
return this;
}
BasicBlockStartState.prototype = Object.create(BlockStartState.prototype);
BasicBlockStartState.prototype.constructor = BasicBlockStartState;
function BlockEndState() {
ATNState.call(this);
this.stateType = ATNState.BLOCK_END;
this.startState = null;
return this;
}
BlockEndState.prototype = Object.create(ATNState.prototype);
BlockEndState.prototype.constructor = BlockEndState;
function RuleStopState() {
ATNState.call(this);
this.stateType = ATNState.RULE_STOP;
return this;
}
RuleStopState.prototype = Object.create(ATNState.prototype);
RuleStopState.prototype.constructor = RuleStopState;
function RuleStartState() {
ATNState.call(this);
this.stateType = ATNState.RULE_START;
this.stopState = null;
this.isPrecedenceRule = false;
return this;
}
RuleStartState.prototype = Object.create(ATNState.prototype);
RuleStartState.prototype.constructor = RuleStartState;
function PlusLoopbackState() {
DecisionState.call(this);
this.stateType = ATNState.PLUS_LOOP_BACK;
return this;
}
PlusLoopbackState.prototype = Object.create(DecisionState.prototype);
PlusLoopbackState.prototype.constructor = PlusLoopbackState;
function PlusBlockStartState() {
BlockStartState.call(this);
this.stateType = ATNState.PLUS_BLOCK_START;
this.loopBackState = null;
return this;
}
PlusBlockStartState.prototype = Object.create(BlockStartState.prototype);
PlusBlockStartState.prototype.constructor = PlusBlockStartState;
function StarBlockStartState() {
BlockStartState.call(this);
this.stateType = ATNState.STAR_BLOCK_START;
return this;
}
StarBlockStartState.prototype = Object.create(BlockStartState.prototype);
StarBlockStartState.prototype.constructor = StarBlockStartState;
function StarLoopbackState() {
ATNState.call(this);
this.stateType = ATNState.STAR_LOOP_BACK;
return this;
}
StarLoopbackState.prototype = Object.create(ATNState.prototype);
StarLoopbackState.prototype.constructor = StarLoopbackState;
function StarLoopEntryState() {
DecisionState.call(this);
this.stateType = ATNState.STAR_LOOP_ENTRY;
this.loopBackState = null;
this.isPrecedenceDecision = null;
return this;
}
StarLoopEntryState.prototype = Object.create(DecisionState.prototype);
StarLoopEntryState.prototype.constructor = StarLoopEntryState;
function LoopEndState() {
ATNState.call(this);
this.stateType = ATNState.LOOP_END;
this.loopBackState = null;
return this;
}
LoopEndState.prototype = Object.create(ATNState.prototype);
LoopEndState.prototype.constructor = LoopEndState;
function TokensStartState() {
DecisionState.call(this);
this.stateType = ATNState.TOKEN_START;
return this;
}
TokensStartState.prototype = Object.create(DecisionState.prototype);
TokensStartState.prototype.constructor = TokensStartState;
exports.ATNState = ATNState;
exports.BasicState = BasicState;
exports.DecisionState = DecisionState;
exports.BlockStartState = BlockStartState;
exports.BlockEndState = BlockEndState;
exports.LoopEndState = LoopEndState;
exports.RuleStartState = RuleStartState;
exports.RuleStopState = RuleStopState;
exports.TokensStartState = TokensStartState;
exports.PlusLoopbackState = PlusLoopbackState;
exports.StarLoopbackState = StarLoopbackState;
exports.StarLoopEntryState = StarLoopEntryState;
exports.PlusBlockStartState = PlusBlockStartState;
exports.StarBlockStartState = StarBlockStartState;
exports.BasicBlockStartState = BasicBlockStartState;
}
});
// node_modules/antlr4/atn/SemanticContext.js
var require_SemanticContext = __commonJS({
"node_modules/antlr4/atn/SemanticContext.js"(exports) {
var Set2 = require_Utils().Set;
var Hash2 = require_Utils().Hash;
function SemanticContext() {
return this;
}
SemanticContext.prototype.hashCode = function() {
var hash = new Hash2();
this.updateHashCode(hash);
return hash.finish();
};
SemanticContext.prototype.evaluate = function(parser, outerContext) {
};
SemanticContext.prototype.evalPrecedence = function(parser, outerContext) {
return this;
};
SemanticContext.andContext = function(a, b) {
if (a === null || a === SemanticContext.NONE) {
return b;
}
if (b === null || b === SemanticContext.NONE) {
return a;
}
var result = new AND(a, b);
if (result.opnds.length === 1) {
return result.opnds[0];
} else {
return result;
}
};
SemanticContext.orContext = function(a, b) {
if (a === null) {
return b;
}
if (b === null) {
return a;
}
if (a === SemanticContext.NONE || b === SemanticContext.NONE) {
return SemanticContext.NONE;
}
var result = new OR(a, b);
if (result.opnds.length === 1) {
return result.opnds[0];
} else {
return result;
}
};
function Predicate(ruleIndex, predIndex, isCtxDependent) {
SemanticContext.call(this);
this.ruleIndex = ruleIndex === void 0 ? -1 : ruleIndex;
this.predIndex = predIndex === void 0 ? -1 : predIndex;
this.isCtxDependent = isCtxDependent === void 0 ? false : isCtxDependent;
return this;
}
Predicate.prototype = Object.create(SemanticContext.prototype);
Predicate.prototype.constructor = Predicate;
SemanticContext.NONE = new Predicate();
Predicate.prototype.evaluate = function(parser, outerContext) {
var localctx = this.isCtxDependent ? outerContext : null;
return parser.sempred(localctx, this.ruleIndex, this.predIndex);
};
Predicate.prototype.updateHashCode = function(hash) {
hash.update(this.ruleIndex, this.predIndex, this.isCtxDependent);
};
Predicate.prototype.equals = function(other) {
if (this === other) {
return true;
} else if (!(other instanceof Predicate)) {
return false;
} else {
return this.ruleIndex === other.ruleIndex && this.predIndex === other.predIndex && this.isCtxDependent === other.isCtxDependent;
}
};
Predicate.prototype.toString = function() {
return "{" + this.ruleIndex + ":" + this.predIndex + "}?";
};
function PrecedencePredicate(precedence) {
SemanticContext.call(this);
this.precedence = precedence === void 0 ? 0 : precedence;
}
PrecedencePredicate.prototype = Object.create(SemanticContext.prototype);
PrecedencePredicate.prototype.constructor = PrecedencePredicate;
PrecedencePredicate.prototype.evaluate = function(parser, outerContext) {
return parser.precpred(outerContext, this.precedence);
};
PrecedencePredicate.prototype.evalPrecedence = function(parser, outerContext) {
if (parser.precpred(outerContext, this.precedence)) {
return SemanticContext.NONE;
} else {
return null;
}
};
PrecedencePredicate.prototype.compareTo = function(other) {
return this.precedence - other.precedence;
};
PrecedencePredicate.prototype.updateHashCode = function(hash) {
hash.update(31);
};
PrecedencePredicate.prototype.equals = function(other) {
if (this === other) {
return true;
} else if (!(other instanceof PrecedencePredicate)) {
return false;
} else {
return this.precedence === other.precedence;
}
};
PrecedencePredicate.prototype.toString = function() {
return "{" + this.precedence + ">=prec}?";
};
PrecedencePredicate.filterPrecedencePredicates = function(set) {
var result = [];
set.values().map(function(context) {
if (context instanceof PrecedencePredicate) {
result.push(context);
}
});
return result;
};
function AND(a, b) {
SemanticContext.call(this);
var operands = new Set2();
if (a instanceof AND) {
a.opnds.map(function(o) {
operands.add(o);
});
} else {
operands.add(a);
}
if (b instanceof AND) {
b.opnds.map(function(o) {
operands.add(o);
});
} else {
operands.add(b);
}
var precedencePredicates = PrecedencePredicate.filterPrecedencePredicates(operands);
if (precedencePredicates.length > 0) {
var reduced = null;
precedencePredicates.map(function(p) {
if (reduced === null || p.precedence < reduced.precedence) {
reduced = p;
}
});
operands.add(reduced);
}
this.opnds = operands.values();
return this;
}
AND.prototype = Object.create(SemanticContext.prototype);
AND.prototype.constructor = AND;
AND.prototype.equals = function(other) {
if (this === other) {
return true;
} else if (!(other instanceof AND)) {
return false;
} else {
return this.opnds === other.opnds;
}
};
AND.prototype.updateHashCode = function(hash) {
hash.update(this.opnds, "AND");
};
AND.prototype.evaluate = function(parser, outerContext) {
for (var i = 0; i < this.opnds.length; i++) {
if (!this.opnds[i].evaluate(parser, outerContext)) {
return false;
}
}
return true;
};
AND.prototype.evalPrecedence = function(parser, outerContext) {
var differs = false;
var operands = [];
for (var i = 0; i < this.opnds.length; i++) {
var context = this.opnds[i];
var evaluated = context.evalPrecedence(parser, outerContext);
differs |= evaluated !== context;
if (evaluated === null) {
return null;
} else if (evaluated !== SemanticContext.NONE) {
operands.push(evaluated);
}
}
if (!differs) {
return this;
}
if (operands.length === 0) {
return SemanticContext.NONE;
}
var result = null;
operands.map(function(o) {
result = result === null ? o : SemanticContext.andContext(result, o);
});
return result;
};
AND.prototype.toString = function() {
var s = "";
this.opnds.map(function(o) {
s += "&& " + o.toString();
});
return s.length > 3 ? s.slice(3) : s;
};
function OR(a, b) {
SemanticContext.call(this);
var operands = new Set2();
if (a instanceof OR) {
a.opnds.map(function(o) {
operands.add(o);
});
} else {
operands.add(a);
}
if (b instanceof OR) {
b.opnds.map(function(o) {
operands.add(o);
});
} else {
operands.add(b);
}
var precedencePredicates = PrecedencePredicate.filterPrecedencePredicates(operands);
if (precedencePredicates.length > 0) {
var s = precedencePredicates.sort(function(a2, b2) {
return a2.compareTo(b2);
});
var reduced = s[s.length - 1];
operands.add(reduced);
}
this.opnds = operands.values();
return this;
}
OR.prototype = Object.create(SemanticContext.prototype);
OR.prototype.constructor = OR;
OR.prototype.constructor = function(other) {
if (this === other) {
return true;
} else if (!(other instanceof OR)) {
return false;
} else {
return this.opnds === other.opnds;
}
};
OR.prototype.updateHashCode = function(hash) {
hash.update(this.opnds, "OR");
};
OR.prototype.evaluate = function(parser, outerContext) {
for (var i = 0; i < this.opnds.length; i++) {
if (this.opnds[i].evaluate(parser, outerContext)) {
return true;
}
}
return false;
};
OR.prototype.evalPrecedence = function(parser, outerContext) {
var differs = false;
var operands = [];
for (var i = 0; i < this.opnds.length; i++) {
var context = this.opnds[i];
var evaluated = context.evalPrecedence(parser, outerContext);
differs |= evaluated !== context;
if (evaluated === SemanticContext.NONE) {
return SemanticContext.NONE;
} else if (evaluated !== null) {
operands.push(evaluated);
}
}
if (!differs) {
return this;
}
if (operands.length === 0) {
return null;
}
var result = null;
operands.map(function(o) {
return result === null ? o : SemanticContext.orContext(result, o);
});
return result;
};
OR.prototype.toString = function() {
var s = "";
this.opnds.map(function(o) {
s += "|| " + o.toString();
});
return s.length > 3 ? s.slice(3) : s;
};
exports.SemanticContext = SemanticContext;
exports.PrecedencePredicate = PrecedencePredicate;
exports.Predicate = Predicate;
}
});
// node_modules/antlr4/atn/ATNConfig.js
var require_ATNConfig = __commonJS({
"node_modules/antlr4/atn/ATNConfig.js"(exports) {
var DecisionState = require_ATNState().DecisionState;
var SemanticContext = require_SemanticContext().SemanticContext;
var Hash2 = require_Utils().Hash;
function checkParams(params, isCfg) {
if (params === null) {
var result = { state: null, alt: null, context: null, semanticContext: null };
if (isCfg) {
result.reachesIntoOuterContext = 0;
}
return result;
} else {
var props = {};
props.state = params.state || null;
props.alt = params.alt === void 0 ? null : params.alt;
props.context = params.context || null;
props.semanticContext = params.semanticContext || null;
if (isCfg) {
props.reachesIntoOuterContext = params.reachesIntoOuterContext || 0;
props.precedenceFilterSuppressed = params.precedenceFilterSuppressed || false;
}
return props;
}
}
function ATNConfig(params, config) {
this.checkContext(params, config);
params = checkParams(params);
config = checkParams(config, true);
this.state = params.state !== null ? params.state : config.state;
this.alt = params.alt !== null ? params.alt : config.alt;
this.context = params.context !== null ? params.context : config.context;
this.semanticContext = params.semanticContext !== null ? params.semanticContext : config.semanticContext !== null ? config.semanticContext : SemanticContext.NONE;
this.reachesIntoOuterContext = config.reachesIntoOuterContext;
this.precedenceFilterSuppressed = config.precedenceFilterSuppressed;
return this;
}
ATNConfig.prototype.checkContext = function(params, config) {
if ((params.context === null || params.context === void 0) && (config === null || config.context === null || config.context === void 0)) {
this.context = null;
}
};
ATNConfig.prototype.hashCode = function() {
var hash = new Hash2();
this.updateHashCode(hash);
return hash.finish();
};
ATNConfig.prototype.updateHashCode = function(hash) {
hash.update(this.state.stateNumber, this.alt, this.context, this.semanticContext);
};
ATNConfig.prototype.equals = function(other) {
if (this === other) {
return true;
} else if (!(other instanceof ATNConfig)) {
return false;
} else {
return this.state.stateNumber === other.state.stateNumber && this.alt === other.alt && (this.context === null ? other.context === null : this.context.equals(other.context)) && this.semanticContext.equals(other.semanticContext) && this.precedenceFilterSuppressed === other.precedenceFilterSuppressed;
}
};
ATNConfig.prototype.hashCodeForConfigSet = function() {
var hash = new Hash2();
hash.update(this.state.stateNumber, this.alt, this.semanticContext);
return hash.finish();
};
ATNConfig.prototype.equalsForConfigSet = function(other) {
if (this === other) {
return true;
} else if (!(other instanceof ATNConfig)) {
return false;
} else {
return this.state.stateNumber === other.state.stateNumber && this.alt === other.alt && this.semanticContext.equals(other.semanticContext);
}
};
ATNConfig.prototype.toString = function() {
return "(" + this.state + "," + this.alt + (this.context !== null ? ",[" + this.context.toString() + "]" : "") + (this.semanticContext !== SemanticContext.NONE ? "," + this.semanticContext.toString() : "") + (this.reachesIntoOuterContext > 0 ? ",up=" + this.reachesIntoOuterContext : "") + ")";
};
function LexerATNConfig(params, config) {
ATNConfig.call(this, params, config);
var lexerActionExecutor = params.lexerActionExecutor || null;
this.lexerActionExecutor = lexerActionExecutor || (config !== null ? config.lexerActionExecutor : null);
this.passedThroughNonGreedyDecision = config !== null ? this.checkNonGreedyDecision(config, this.state) : false;
return this;
}
LexerATNConfig.prototype = Object.create(ATNConfig.prototype);
LexerATNConfig.prototype.constructor = LexerATNConfig;
LexerATNConfig.prototype.updateHashCode = function(hash) {